Simple Redirect Script - Recommendations?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • darnit
    Confirmed User
    • Jul 2001
    • 2439

    #1

    Simple Redirect Script - Recommendations?

    Hi,

    Im seeking a free php based script that can covert outgoing links to something like this:

    http://www.somedomain.com/target/?id=45

    Anyone found a good one? This is low volume SE traffic so no need to handle massive volume

    <disclaimer>

    Yes ive googled the fuck out of it - just dont want to install some crap so looking for a tested one.

    </disclaimer>

    ablility to work over multiple domains a plus but not necessary

    Thanks!
  • SmokeyTheBear
    ►SouthOfHeaven
    • Jun 2004
    • 28609

    #2
    make a directory called "out" like yourserver.com/out/

    in that folder make a file called link.txt

    put your outgoing links seperated by "~" like this
    http://site1.com~http://site2.com~http://site3.com

    save this as index.php

    Code:
    <?php
    $url = "link.txt";
    $links = file_get_contents($url);
    $link = explode('~',$links);
    $go = $link[$out];
    header("Location: $go"); 
    ?>

    call it like http://yourserver.com/out/?out=2
    hatisblack at yahoo.com

    Comment

    • Spud
      Confirmed User
      • Jul 2001
      • 340

      #3
      Smokey! you kick ass

      Comment

      • Dagwolf
        President of Canada
        • Sep 2003
        • 23141

        #4
        Originally posted by Spud
        Smokey! you kick ass
        Yeah, I guess he kinda does sometimes.
        Sleep well, and dream of large women.

        Comment

        • Bro Media - BANNED FOR LIFE
          MOBILE PORN: IMOBILEPORN
          • Jan 2004
          • 16502

          #5
          or to make it cleaner, you can do this

          http://www.site1.com
          http://www.site2.com

          then use this modified version of his script
          Code:
          <?php
          $url = "link.txt";
          $links = file_get_contents($url);
          $link = explode('\n',$links);
          $go = $link[$out];
          header("Location: $go"); 
          ?>
          that uses the line break code as the explode instead of ~ which makes it easier to edit your file and add/delete links

          Comment

          • mrkris
            Confirmed User
            • May 2005
            • 2737

            #6
            Originally posted by SmokeyTheBear
            make a directory called "out" like yourserver.com/out/

            in that folder make a file called link.txt

            put your outgoing links seperated by "~" like this
            http://site1.com~http://site2.com~http://site3.com

            save this as index.php

            Code:
            <?php
            $url = "link.txt";
            $links = file_get_contents($url);
            $link = explode('~',$links);
            $go = $link[$out];
            header("Location: $go"); 
            ?>

            call it like http://yourserver.com/out/?out=2
            Register globals are the devil.

            PHP-MySQL-Rails | ICQ: 342500546

            Comment

            • Nookster
              Confirmed IT Professional
              • Nov 2005
              • 3744

              #7
              Originally posted by mrkris
              Register globals are the devil.
              Code:
              if (@ini_get('register_globals')) {
                 foreach ($_REQUEST as $var_name => $void) {
                    unset($$var_name);
                 }
              }
              The Best Affiliate Software, Ever.

              Comment

              • GrouchyAdmin
                Now choke yourself!
                • Apr 2006
                • 12085

                #8
                You might also want to test for \r\n, FWIW.. edit that file in Mike-Rowe-Sawft Winders and that's going to be a very broken redirect script.

                Comment

                • Bro Media - BANNED FOR LIFE
                  MOBILE PORN: IMOBILEPORN
                  • Jan 2004
                  • 16502

                  #9
                  or better yet

                  Code:
                  <?php
                  $link[1] = "http://www.site.com";
                  $link[2] = "http://www.site2.com";
                  
                  $id = $_GET['id'];
                  header("location: " . $link[$id]);
                  ?>

                  Comment

                  Working...