2

I have the simple PHP script:

<?php
$url = $_REQUEST['url'];
if (preg_match('/\b(https?|ftp):\/\/*/', $url) !== 1) die;
echo (file_get_contents($url));
?>

I am trying to echo the page:

http://forum.bodybuilding.com/showthread.php?t=162984431&page=10

but the echo shows:

http://forum.bodybuilding.com/showthread.php?t=162984431

example:

http://www.kylesbox.com/forumbuddy/fetch/fetch.php?url=http://forum.bodybuilding.com/showthread.php?t=162984431&page=10

I am not a PHP expert but I think this has something to do with persistent URLs? How would I go about fixng this so the echo displays everything after the & symbol as well? I do have cURL installed on my server if that helps. Thanks!

1 Answer 1

1

Here the "&" sign is part of query string element. So it will avoid to get value from first "&". We can two more lines on your script to get the work done.

<?php
$query=$_SERVER['QUERY_STRING'];  //get the full query string in url
$query_arr=explode("url=",$query);  //split the string by first get key

$url = $query_arr[1];  //take second parameter as url to be loaded
if (preg_match('/\b(https?|ftp):\/\/*/', $url) !== 1) die;
echo (file_get_contents($url));
?>

The she script available at following url as working script.

http://sugunan.net/demo/fetch.php?url=http://forum.bodybuilding.com/showthread.php?t=162984431&page=10

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.