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