Still looking

Discussion in 'PHP' started by brightguy07, Aug 22, 2009.

  1. #1
    Still looking for a script that can change a url every xx minutes so that each time a visitor visits the url page they click a different link.

    Don't want them sharing the link :|
     
    brightguy07, Aug 22, 2009 IP
  2. astrazone

    astrazone Member

    Messages:
    358
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    33
    #2
    can you give me an example of the link?
     
    astrazone, Aug 22, 2009 IP
  3. Goramba

    Goramba Peon

    Messages:
    128
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hrm. I think I get what you're saying, and that's an interesting challenge. I cooked up a little script that would do what you want, but it's not without flaws you would have to change for your specific needs.

    RUN:
    create table secretdb(seed int,page varchar(50));

    Page that links to the "secret" page, call it loader.php:

    $con = mysql_connect('localhost', 'user', 'pass');
    mysql_select_db("database", $con);
    $sql="select seed from secretdb;";
    $result = mysql_query($sql);
    while($row = mysql_fetch_array($result))
    {
    echo '<a href="middleman.php?pin='.$row['seed'].'">Click here</a>';
    }
    PHP:
    middleman.php
    $pin=$_GET["pin"];
    $page="secretpage.php";
    $random=rand(1,400);
    $sql="select page from secretdb where seed = '$pin';";
    $result = mysql_query($sql);
    $number=mysql_num_rows($result); 
    if ($number < 1){
    echo "Sorry, you don't have access to view this page.";
    }
    else{
    $sql="truncate secretdb;";
    $result = mysql_query($sql);
    $sql="insert into secretdb values('$random','$page');";
    $result = mysql_query($sql);
    include 'secretpage.php';
    }
    PHP:
    What it does:

    When a person visits loader.php it checks the database and grabs the seed, which is just a big random number. It adds that to the link for middleman.php. When middleman is loaded as: middleman.php?pin=1234 it checks if 1234 is the seed necessary to load the real 'secretpage.php' and if so it clears the database and loads a new random seed, then includes secretpage.pnp in the current page. Otherwise it tells them they don't have access.

    The only problem with it is if two people load loader.php they'll both have the same seed but only the first person to click the link will get in. Not sure if that matters to you but there ya go, it's a start.
     
    Goramba, Aug 22, 2009 IP