From 73bf8e96faf5239537e4f3bdbadb4b7036f785c5 Mon Sep 17 00:00:00 2001
From: skeeter <skeeter@alumni.egroupware.org>
Date: Sun, 1 Sep 2002 13:37:10 +0000
Subject: [PATCH] GNU Patch #492.

---
 phpgwapi/inc/class.network.inc.php | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/phpgwapi/inc/class.network.inc.php b/phpgwapi/inc/class.network.inc.php
index 73baec6191..8b7db56e02 100644
--- a/phpgwapi/inc/class.network.inc.php
+++ b/phpgwapi/inc/class.network.inc.php
@@ -187,16 +187,27 @@
 		 This allows for parsing of xml where the formatting was not ideal (elements
 		 opened and closed on a single line).
 		*/
-		function gethttpsocketfile($file,$string=False)
+		function gethttpsocketfile($file,$string=False,$user='',$passwd='')
 		{
 			$server = str_replace('http://','',$file);
 			$file = strstr($server,'/');
 			$server = str_replace($file,'',$server);
+
+			//allows for access to http-auth pages - added by Dave Hall <dave.hall@mbox.com.au>
+			if(!((empty($user))&&(empty($passwd))))
+			{
+				$auth = 'Authorization: Basic '.base64_encode("$user:$passwd")."\n";
+			}
+			else
+			{
+				$auth = '';
+			}
+
 			if($GLOBALS['phpgw_info']['server']['httpproxy_server'])
 			{
 				if ($this->open_port($server,80, 15))
 				{
-					if(!$this->write_port('GET http://' . $server . $file . ' HTTP/1.0'."\r\n\r\n"))
+					if(!$this->write_port('GET http://' . $server . $file . ' HTTP/1.0'."\n".$auth."\r\n\r\n"))
 					{
 						return False;
 					}
@@ -231,7 +242,7 @@
 			{
 				if($this->open_port($server, 80, 15))
 				{
-					if(!$this->write_port('GET '.$file.' HTTP/1.0'."\n".'Host: '.$server."\r\n\r\n"))
+					if(!$this->write_port('GET '.$file.' HTTP/1.0'."\n".'Host: '.$server."\n".$auth."\r\n\r\n"))
 					{
 						return 0;
 					}
@@ -258,4 +269,4 @@
 			}
 		}
 	}
-?>
+?>
\ No newline at end of file