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

Random redirecting...

Discussion in 'BlackHat Lounge' started by element94, May 8, 2008.

  1. element94

    element94 Junior Member

    Joined:
    Mar 14, 2008
    Messages:
    144
    Likes Received:
    17
    Is there a way to make a page redirect to a random url from several given ?
     
  2. element94

    element94 Junior Member

    Joined:
    Mar 14, 2008
    Messages:
    144
    Likes Received:
    17
    Never mind i figured it out :

    <script type="text/javascript">

    var urls = new Array("http://www.url1.com/", "http://www.url2.com/");

    function redirect()
    {
    window.location = urls[Math.floor(urls.length*Math.random())];
    }

    var temp = setInterval("redirect()", 3000);

    </script>
     
  3. Zak_A

    Zak_A Jr. VIP Jr. VIP Premium Member

    Joined:
    Mar 16, 2008
    Messages:
    808
    Likes Received:
    873
    Gender:
    Male
    Occupation:
    WP designer & developer
    Location:
    Western Europe
    Yep, but this will work only if javascript is enabled.

    I'd rather do it in php, with meta refresh :

    <?
    $urls[]="http://www.url1.com/";
    $urls[]="http://www.url2.com/";
    //Add as many urls as you want this way
    $rnd=rand(0,count($urls)-1);
    $redirect=$url[$rnd];
    echo "<html><head><meta http-equiv='refresh' content='0;url=".$redirect."'></head><body></body></html>";
    ?>

    hope this helps ;)
     
    • Thanks Thanks x 1
  4. element94

    element94 Junior Member

    Joined:
    Mar 14, 2008
    Messages:
    144
    Likes Received:
    17
    Thanks for this one. Is there a way to show google.com or whatever as ref url ?
     
  5. Zak_A

    Zak_A Jr. VIP Jr. VIP Premium Member

    Joined:
    Mar 16, 2008
    Messages:
    808
    Likes Received:
    873
    Gender:
    Male
    Occupation:
    WP designer & developer
    Location:
    Western Europe
    I'm not sure whether that would be possible or not to change the ref url. Anyway I'm sorry I have no idea how you could do this...
     
  6. sdesignb

    sdesignb Junior Member

    Joined:
    May 7, 2008
    Messages:
    107
    Likes Received:
    24
  7. creztor

    creztor Power Member

    Joined:
    Jan 20, 2007
    Messages:
    731
    Likes Received:
    295
    Location:
    Australia
    Home Page:
    Using that code above from Zak_A above my browser gets stuck in an endless loop. I am running php4 I believe, can anyone help plz?
     
  8. Butler

    Butler Registered Member Premium Member

    Joined:
    Feb 4, 2008
    Messages:
    71
    Likes Received:
    1
    If you are using links yes, stuffing images, no.
     
  9. drori

    drori Newbie

    Joined:
    Aug 13, 2013
    Messages:
    0
    Likes Received:
    0
    Hi

    I think (please correct me if i;m wrong) there was a typo in Zak's code,

    and it should have been

    $redirect=$urls[$rnd];

    instead of

    $redirect=$url[$rnd];



    but in any case, i'm still getting this error:

    [h=1]Not Found[/h] The requested URL /.$redirect. was not found on this server.

    - the link i was placing is a full url to a different website


    ideas/suggestions ?
     
  10. gentam

    gentam Newbie

    Joined:
    Oct 30, 2013
    Messages:
    12
    Likes Received:
    5
    you are wrong
    it is just a value he set
     
  11. RushingWind

    RushingWind Elite Member

    Joined:
    Apr 6, 2013
    Messages:
    2,416
    Likes Received:
    3,333
    I'm sure someone already told him that 5 years ago.