1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Page Rotator

Discussion in 'CPA' started by nato76, Jul 9, 2009.

  1. nato76

    nato76 Junior Member

    Joined:
    Jan 6, 2009
    Messages:
    152
    Likes Received:
    18
    I did a search and could not find this. I am running multiple offers and want a script that rotates what offers people are getting sent to.

    For example:

    I send an email to my list and they click on the link. I don't want them all going to the same offer. I want them going to different pages with different offers. Anyone have a script to accomplish this?
     
  2. ukescuba

    ukescuba Jr. VIP Jr. VIP Premium Member

    Joined:
    Feb 24, 2008
    Messages:
    994
    Likes Received:
    634
    Occupation:
    Mobile Marketer & QR Code Junkie
    Location:
    San Antonio, TX
    Home Page:
    in its simplest form you can do this....

    create each of your offers as you would do normally ie using html but save the files as php include files ie .inc instead of .html

    name each offer like this ie 1.inc, 2.inc, 3.inc, etc

    on your main page generate a random number using php

    ie
    Code:
    <?php $incnum = rand(1, 10); ?>
    then on your main page just call the file like this
    Code:
    <?php include("$incnum.inc"); ?>
    
    every time someone loads the page it will pull in a different .inc file....

    look here for more info on using include files:

    Code:
    http://www.tizag.com/phpT/include.php
    havent tested the code but in theory thats probably the simplest way of doing it and should point you in the right diretion...

    hth

    thanks

    ukescuba
     
    • Thanks Thanks x 2
  3. Mondlicht

    Mondlicht Junior Member

    Joined:
    May 14, 2009
    Messages:
    166
    Likes Received:
    63
    Location:
    UK or GER
    Code:
    switch(rand(1,10)){
    case 1:
    include("1.php");
    break;
    case 2:
    include("1.php");
    break;
    
    etc..
    
    
    }
    
    works the same, more handwriting :) as well as you can use alternative filenames therefor as a Plus!
     
  4. durruti

    durruti Newbie

    Joined:
    May 14, 2009
    Messages:
    8
    Likes Received:
    18
    i'm using this:

    PHP:
    <?PHP

    $file_handle 
    fopen("l.txt""rb");
    $line_of_text fgets($file_handle);
    $i 0;
    $mypages[$i] = $line_of_text;
    $i=1;
    while (!
    feof($file_handle) ) {
    $line_of_text fgets($file_handle);
    $mypages[$i] = $line_of_text;
    $i $i+1;

    }

    fclose($file_handle);
    $myrandompage $mypages[mt_rand(0$i -1)];
    ?>

    <META HTTP-EQUIV="REFRESH" CONTENT="0;URL=<?php echo $myrandompage?>">
    and 1.txt, whit offers (1 per line)
     
    • Thanks Thanks x 3
  5. ukescuba

    ukescuba Jr. VIP Jr. VIP Premium Member

    Joined:
    Feb 24, 2008
    Messages:
    994
    Likes Received:
    634
    Occupation:
    Mobile Marketer & QR Code Junkie
    Location:
    San Antonio, TX
    Home Page:
    you know what KISS stands for right ;)
     
  6. nato76

    nato76 Junior Member

    Joined:
    Jan 6, 2009
    Messages:
    152
    Likes Received:
    18
    All this code is confusing me. Trying to find out which one would be the easiest to implement.
     
  7. nato76

    nato76 Junior Member

    Joined:
    Jan 6, 2009
    Messages:
    152
    Likes Received:
    18
    Managed to figure this out. The .inc extension was confusing me but now I'm like DUH. Thanks a lot for this.
     
  8. ukescuba

    ukescuba Jr. VIP Jr. VIP Premium Member

    Joined:
    Feb 24, 2008
    Messages:
    994
    Likes Received:
    634
    Occupation:
    Mobile Marketer & QR Code Junkie
    Location:
    San Antonio, TX
    Home Page:
    i use include a lot when building my own stuff they come in handy... remember if you position them inside a div layer you can place them anywhere on the screen with css

    similar to joomla and positioning modules... this was my duh moment for understanding joomla template design

    if you need help with css let me know! :)
     
  9. Cashflowninja

    Cashflowninja Newbie

    Joined:
    Feb 8, 2009
    Messages:
    18
    Likes Received:
    2
    Occupation:
    Network Engineer
    Location:
    No Where
    Home Page:
    Search prosper202 they have a php example of this.
     
  10. nato76

    nato76 Junior Member

    Joined:
    Jan 6, 2009
    Messages:
    152
    Likes Received:
    18
    Why does this work?

    Code:
    <?php $incnum = rand(1, 2); ?>
    <?php include("$incnum.html"); ?>
    But this doesn't:

    Code:
    <?php $incnum = rand(1, 2, 3); ?>
    <?php include("$incnum.html"); ?>

    Trying to rotate 3 pages. Works with 2. I don't know anything about php btw.
     
    Last edited: Sep 2, 2009
  11. fcuku

    fcuku BANNED BANNED

    Joined:
    Aug 17, 2009
    Messages:
    49
    Likes Received:
    237
    Here's a rotate with geo-location that I use.

    rotate-geo-locate.php
    Code:
    <script language="JavaScript" src="http://j.maxmind.com/app/geoip.js"></script>
    <script language="JavaScript">
    
    var country = geoip_country_code();
    
    switch (country)
    {
    case (country = "US"):
      window.location = "us/index.php";
    break;
    case (country = "CA"):
      window.location = "ca/index.php";
    break;
    case (country = "UK"):
      window.location = "rotator/uk/index.php";
    break;
    default:
      window.location = "rotator/int/index.php";
    break;
    }
    </script>
    
    us/index.php
    Code:
    <?PHP
    
    $file_handle = fopen("us.txt", "rb");
    $line_of_text = fgets($file_handle);
    $i = 0;
    $mypages[$i] = $line_of_text;
    $i=1;
    while (!feof($file_handle) ) {
    $line_of_text = fgets($file_handle);
    $mypages[$i] = $line_of_text;
    $i = $i+1;
    
    }
    
    fclose($file_handle);
    $myrandompage = $mypages[mt_rand(0, $i -1)];
    ?>
    
    us.txt
    Code:
    your US offers here 1
    your US offers here 2
    your US offers here 3
    your US offers here 4
    your US offers here 5
    
    Rinse. Repeat with other countries.
     
    • Thanks Thanks x 1
  12. ukescuba

    ukescuba Jr. VIP Jr. VIP Premium Member

    Joined:
    Feb 24, 2008
    Messages:
    994
    Likes Received:
    634
    Occupation:
    Mobile Marketer & QR Code Junkie
    Location:
    San Antonio, TX
    Home Page:
    change rand(1, 2, 3) to rand(1, 3)

    the numbers in the brackets are your limits - ie if you wanted to pick a random number beween 5 and 10 you would put rand(5,10)

    hope that makes sense...
     
    • Thanks Thanks x 1
  13. nato76

    nato76 Junior Member

    Joined:
    Jan 6, 2009
    Messages:
    152
    Likes Received:
    18
    ukescuba thank you so much. That worked.

    Repped and thanked.
     
    • Thanks Thanks x 1