I need a go.php code/file

Discussion in 'PHP' started by dilluzionz, Aug 9, 2008.

  1. #1
    I need to create a go.php file to work with this line in my index file.

    <div class="itemtitle"><a href="go.php?url=http://news.google.com/news/url?sa=T&ct=us/0-0&fd=R&url=http://www.nytimes.com/2008/07/20/sports/baseball/20sandomir.html%3Fem%26ex%3D1216699200%26en%3Da20ecc73d3459c77%26ei%3D5087%250A&cid=1228684920&ei=5YSDSP3MAp_K8ATg96zuBw&usg=AFQjCNG_OyeYckF1MDxitV_NT9et1pr0bQ">Sports Business Citigroup Puts Its Money Where Its Name Will Be - New York Times</a>

    Any help will be appreciated. I don't know what to put in the go.php to make it work.
     
    dilluzionz, Aug 9, 2008 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    
    <?php
    
    $url = preg_replace('~[\r\n]+~', null, $_GET['url']);
    header("Location: {$url}");
    
    ?>
    
    PHP:
     
    nico_swd, Aug 9, 2008 IP
    dilluzionz likes this.
  3. Next

    Next Active Member

    Messages:
    249
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    90
    #3
    Or this might be simpler for you

    <?php header('Location: '.$_GET['url']); ?>
    Code (markup):
     
    Next, Aug 9, 2008 IP
    dilluzionz likes this.
  4. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #4
    It's pretty much the same, except that yours allows HTTP header injections...
     
    nico_swd, Aug 9, 2008 IP
  5. dilluzionz

    dilluzionz Peon

    Messages:
    379
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks for the replies. I get this error when using either one of the codes:

    Forbidden
    You don't have permission to access /go.php on this server.

    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

    Do I need to change the permissions?
     
    dilluzionz, Aug 9, 2008 IP
  6. jpinheiro

    jpinheiro Peon

    Messages:
    1,211
    Likes Received:
    15
    Best Answers:
    1
    Trophy Points:
    0
    #6
    yea thats usually when you get a error regarding permission chmod go.php to 0777

    i would suggest using nico_swd technique
     
    jpinheiro, Aug 9, 2008 IP
  7. jpinheiro

    jpinheiro Peon

    Messages:
    1,211
    Likes Received:
    15
    Best Answers:
    1
    Trophy Points:
    0
    #7
    jpinheiro, Aug 9, 2008 IP
    dilluzionz likes this.
  8. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #8
    Working fine for me.

    Peace,
     
    Barti1987, Aug 9, 2008 IP
  9. Next

    Next Active Member

    Messages:
    249
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    90
    #9
    Yes sorry, that is true. I just trying to help as simple as possible.

    Glad to help,
    Next
     
    Next, Aug 9, 2008 IP