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

[REQ] A Random-Link-From-List Redirect Script

Discussion in 'PHP & Perl' started by OTrap, Nov 2, 2010.

  1. OTrap

    OTrap Elite Member

    Joined:
    Jul 12, 2008
    Messages:
    2,281
    Likes Received:
    1,051
    I'm assuming PHP (from talking with tacopocalypse) for this. All I need would be the ability to import a list (.txt) of links and generate a link that would redirect to any of the links in the list randomly.

    Anything like this? Thanks and Rep for it.
     
  2. Inter

    Inter Newbie

    Joined:
    Nov 2, 2010
    Messages:
    17
    Likes Received:
    2
    I am new to the blackhat world so I don't know of a script... but a script like this would not be hard to make.
    Please stay tuned for a basic script.
     
    • Thanks Thanks x 1
    Last edited: Nov 3, 2010
  3. Inter

    Inter Newbie

    Joined:
    Nov 2, 2010
    Messages:
    17
    Likes Received:
    2
    Here is a quick sample....

    Code:
    <?php
    // load flat file into an array
    $myfile = 'test.txt';
    $lines = file($myfile);  
     
    // randomly generate a number between 0 and the count of the last line in the array.
    $line = rand(0, count($lines) - 1);
     
    // server redirect to the randomize line of the file
    header("Location: $lines[$line]");
    ?>
    
    If you need any help with implementation just give me a PM.
     
    • Thanks Thanks x 1
    Last edited: Nov 3, 2010
  4. fatboy

    fatboy Elite Member

    Joined:
    Aug 13, 2008
    Messages:
    1,618
    Likes Received:
    3,227
    Occupation:
    Retired
    Location:
    Old Peoples Home
    I tend to use the array_rand() function to select a random array element.
    Going off Inters code above:

    Code:
    <?php
    // load flat file into an array
    $myfile = 'test.txt';
    $lines = file($myfile);  
     
    // server redirect to the randomize line of the file
    header("Location: " . array_rand($lines));
    ?>
    
    Haven't tested it and also on my first coffee of the day, but should work ;)
     
  5. OTrap

    OTrap Elite Member

    Joined:
    Jul 12, 2008
    Messages:
    2,281
    Likes Received:
    1,051
    I do need some help implementing this. Would anyone mind going into more detail? PM me your AIM, and I'll hit you up. If it works, shoot, I'll PayPal a couple bucks your way.
     
  6. OTrap

    OTrap Elite Member

    Joined:
    Jul 12, 2008
    Messages:
    2,281
    Likes Received:
    1,051
    Nevermind. Got it.