ccsnet Posted November 27, 2008 Share Posted November 27, 2008 Hi, I got the following script from the main php site but been a noob I'm not doing too well. Ideally I want to log in to the site which sits behind basic IIS athentication ( user ID & PW ) and either grab all the files I need in one go.... around 20 and copy to a specific dir on my own site and / or grab each one and pull the data in to SQL. So far I have not been able to even get one file transfered over and now I am gettin server 500 problems. Because of this and a lack of debug skills ( and tbh noobness ) I'm not sure where its even going wrong. Can any one help me ? Eventually I want to get all the data in to a MySQL DB which I will be using a C# application with. Thanks Terran <?php /* Simple PHP Script to login on a Basic Authentication page. */ /* Access Configuration */ define ('x401_host', 'EDITED'); define ('x401_port', '80'); define ('x401_user', 'EDITED'); define ('x401_pass', 'EDITED); /* Function */ function get401Page($file) { $out = "GET $file HTTP/1.1\r\n"; $out .= "Host: ".x401_host."t\r\n"; $out .= "Connection: Close\r\n"; $out .= "Authorization: Basic ".base64_encode(x401_user.":".x401_pass)."\r\n"; $out .= "\r\n"; if (!$conex = @fsockopen(x401_host, x401_port, $errno, $errstr, 10)) return 0; fwrite($conex, $out); $data = ''; while (!feof($conex)); { $data .= fgets($conex, 512); } fclose($conex); return $data; } /* Code */ if ($source = get401Page('/absolute/path/file.php?get=value')) { echo $source; } else; { echo "I can't connect!"; } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.