Click to See Complete Forum and Search --> : Unable to get HTML code from external websites


dougmcc1
12-21-2005, 06:49 PM
All of the following coding examples should work but all produce no output. The script is on an internal network, not viewable from the public and there is a firewall in place. What do I need to configure in order for the following code to work?

$html = strtolower(file_get_contents("http://www.yahoo.com"));
echo $html;

$html = strtolower(implode('', file("http://www.yahoo.com")));
echo $html;

$fp = fopen("http://www.yahoo.com", 'r');
$html = '';
while (!feof($fp)) {
$html .= fread($fp, 4096);
}
fclose($fp);
echo $html;

bpat1434
12-21-2005, 07:12 PM
Open up port 80 in teh firewall. If the outside can't see the computer (and vice versa) then you're not going to get external websites. If the server can't browse teh web like a normal computer can, then you can't use that scirpt.

~Brett

jayant
12-21-2005, 07:17 PM
Well to get answer to a question you should remember not to post in multiple forums

http://www.phpbuilder.com/board/showthread.php?p=10685110

Installer
12-21-2005, 07:23 PM
Did you try curl (if you have it enabled)?$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.yahoo.com/');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);You should mark your other thread resolved.

dougmcc1
12-21-2005, 07:39 PM
Installer, your code produced the following error message:
Notice: Undefined offset: 0 in C:\sokkit\site\myfile.php on line 328

Not sure how to tell if I even have curl enabled (does the fact that I even get an error message mean that I do, or is the reason I'm getting that error message is because I dont?).

Brett, I dont have access to the company's firewall and port 80 should already be "opened up" because I can browse the web from Internet Explorer. I did try your suggestion of adding :80 onto the end of the URL but that didnt work.

Before I can start browsing the web from IE I do have to login through Novell. Is there somewhere in php.ini or similar file where I can put the username and password so the script can connect to the web as well? I assumed once I put that information in, everything else on my machine was able to connect to the internet, not just the browser.

Jayant, I dont have to connect through a proxy. I assumed this forum had different moderators or else I wouldnt have bothered posting the message again. I'll mark both threads resolved after we're done.

Installer
12-21-2005, 08:21 PM
You probably have curl enabled or you'd have gotten an "undefined" message or something.

What's line 328?

bpat1434
12-21-2005, 08:25 PM
Well, if Novell is restricting access without your login, you could try executing the novell login from PHP.

Something like:
<?php

// Execute an external program (Novell)
$login = exec('Novell -u username -p password');
// Whatever the path to Novell login is
// With username and password switches
$failed =''; // This would be the output of a failed login from the Novell Server
if($login != $failed)
{
// Try getting your information here
}
else
{
echo 'Unable to login to Novell. Outside access restricted.';
}
?>

~Brett