Jump to content

Collecting Mutiple Files Behind Basic IIS Athentication Script Problem


ccsnet

Recommended Posts

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!";
}

?> 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.