5

I am currently trying to use the php function 'include' to include an external url. This is so that whenever the webpage is updated it will automatically update mine. The trouble I'm having however is that I keep getting an error saying the following...

Warning: require() [function.require]: http:// wrapper is disabled in the server configuration by allow_url_include=0 in C:\wamp\www\starterpack\starterpack2\header.php on line 48

I have tried to find a way to fix this error or find a way around it but cannot find one. Does anyone have any ideas?

P.S I am building the site using wampserver, could permissions of the wampserver be causing this error?

5 Answers 5

11

You would be better using echo file_get_contents($url) as the include statement could execute any PHP code returned by the other site.

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

Comments

8

Look at your php.ini and make sure allow_url_include is set to 1. Restart HTTPD, done.

Comments

5
function getter($url) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
}

echo getter('http://yourdomain.com/externalfile.php');

And you're done :)

Comments

0

This will load an external website and also gives external links an absolute website link address

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.your_external_website.com");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$result = curl_exec($ch);
curl_close($ch);
$result = preg_replace("#(<\s*a\s+[^>]*href\s*=\s*[\"'])(?!http)([^\"'>]+)([\"'>]+)#",'$1http://www.your_external_website.com/$2$3', $result);
echo $result

1 Comment

Your answer is identical @squallstars.
0

Look at your php.ini and make sure allow_url_include is set to 1

Otherwise use following ...

function getter($url) 
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
$data = curl_exec($ch);
curl_close($ch);
return $data;}
echo getter('http://yourdomain.com/externalfile.php');

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.