Guest User

Untitled

a guest
May 24th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. <?
  2.  
  3. //landing pages filenames, theses will be rotated between eachother
  4. //theses landing pages must be in the same DIRECTORY as this file
  5. //you can add as many landing pages here as you like
  6. $landingpage[0] = 'landingpage1.php';
  7. $landingpage[1] = 'landingpage2.php';
  8. $landingpage[2] = 'landingpage3.php';
  9. $lpcount = count($landingpage);
  10.  
  11. //this is the text file, which will be stored in the same directory as this file,
  12. //count.txt needs to be CHMOD to 777, full privlledges, to read and write to it.
  13. $myFile = "count.txt";
  14.  
  15. // check cookie for security
  16. // loading a php script based on a cookie is scary without checking it
  17. $usecookie = false;
  18. if ($_COOKIE['landing']) {
  19. for ($i = 0; $i < $lpcount; $i++) {
  20. if ($_COOKIE['landing'] == $landingpage[$i]) {
  21. $usecookie = true;
  22. $lpNumber = $i;
  23. }
  24. }
  25. }
  26.  
  27. if ($usecookie === false) { // use myFile
  28. //open the txt file
  29. $fh = @fopen($myFile, 'r');
  30. $lpNumber = @fread($fh, 5);
  31. @fclose($fh);
  32.  
  33. //see which landing page is next in line to be shown.
  34. if ($lpNumber >= count($landingpage)) {
  35. $lpNumber = 1;
  36. } else {
  37. $lpNumber = $lpNumber + 1;
  38. }
  39.  
  40. //write to the txt file.
  41. $fh = fopen($myFile, 'w') or die("can't open file");
  42. $stringData = $lpNumber . "\n";
  43. fwrite($fh, $stringData);
  44. fclose($fh);
  45.  
  46. // set the cookie
  47. $expire = time() + 60*60*24*7;
  48. setcookie("landing", $landingpage[$lpNumber], $expire);
  49. }
  50.  
  51. //include the landing page
  52. include_once($landingpage[$lpNumber]);
  53.  
  54. //terminate script
  55. die();
  56.  
  57. ?>
Add Comment
Please, Sign In to add comment