Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- //landing pages filenames, theses will be rotated between eachother
- //theses landing pages must be in the same DIRECTORY as this file
- //you can add as many landing pages here as you like
- $landingpage[0] = 'landingpage1.php';
- $landingpage[1] = 'landingpage2.php';
- $landingpage[2] = 'landingpage3.php';
- $lpcount = count($landingpage);
- //this is the text file, which will be stored in the same directory as this file,
- //count.txt needs to be CHMOD to 777, full privlledges, to read and write to it.
- $myFile = "count.txt";
- // check cookie for security
- // loading a php script based on a cookie is scary without checking it
- $usecookie = false;
- if ($_COOKIE['landing']) {
- for ($i = 0; $i < $lpcount; $i++) {
- if ($_COOKIE['landing'] == $landingpage[$i]) {
- $usecookie = true;
- $lpNumber = $i;
- }
- }
- }
- if ($usecookie === false) { // use myFile
- //open the txt file
- $fh = @fopen($myFile, 'r');
- $lpNumber = @fread($fh, 5);
- @fclose($fh);
- //see which landing page is next in line to be shown.
- if ($lpNumber >= count($landingpage)) {
- $lpNumber = 1;
- } else {
- $lpNumber = $lpNumber + 1;
- }
- //write to the txt file.
- $fh = fopen($myFile, 'w') or die("can't open file");
- $stringData = $lpNumber . "\n";
- fwrite($fh, $stringData);
- fclose($fh);
- // set the cookie
- $expire = time() + 60*60*24*7;
- setcookie("landing", $landingpage[$lpNumber], $expire);
- }
- //include the landing page
- include_once($landingpage[$lpNumber]);
- //terminate script
- die();
- ?>
Add Comment
Please, Sign In to add comment