phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] CVS: phpgwapi/inc class.network.inc.php,1.8,1.9


From: Miles Lott <address@hidden>
Subject: [Phpgroupware-cvs] CVS: phpgwapi/inc class.network.inc.php,1.8,1.9
Date: Sat, 30 Mar 2002 11:32:10 -0500

Update of /cvsroot/phpgroupware/phpgwapi/inc
In directory subversions:/tmp/cvs-serv9608

Modified Files:
        class.network.inc.php 
Log Message:
add string return option to gethttpsocketfile()

Index: class.network.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.network.inc.php,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** class.network.inc.php       23 Sep 2001 19:41:20 -0000      1.8
--- class.network.inc.php       30 Mar 2002 16:32:08 -0000      1.9
***************
*** 21,25 ****
    * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA            *
    \**************************************************************************/
!       
    /* $Id$ */
  
--- 21,25 ----
    * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA            *
    \**************************************************************************/
! 
    /* $Id$ */
  
***************
*** 84,88 ****
                                $this->socket = 
fsockopen($server,$port,&$errcode,&$errmsg);
                        }
!                       if (!$this->socket)
                        {
                                return 
$this->set_error('Error',$errcode.':'.$errmsg,'Connection to 
'.$server.':'.$port.' failed - could not open socket.');
--- 84,88 ----
                                $this->socket = 
fsockopen($server,$port,&$errcode,&$errmsg);
                        }
!                       if(!$this->socket)
                        {
                                return 
$this->set_error('Error',$errcode.':'.$errmsg,'Connection to 
'.$server.':'.$port.' failed - could not open socket.');
***************
*** 112,116 ****
                {
                        $ok = fputs($this->socket,$this->add_crlf($str));
!                       if (!$ok)
                        {
                                return $this->set_error('Error','Connection 
Lost','lost connection to server');
--- 112,116 ----
                {
                        $ok = fputs($this->socket,$this->add_crlf($str));
!                       if(!$ok)
                        {
                                return $this->set_error('Error','Connection 
Lost','lost connection to server');
***************
*** 124,128 ****
                function bs_write_port($str,$bytes=0)
                {
!                       if ($bytes)
                        {
                                $ok = 
fwrite($this->socket,$this->add_crlf($str),$bytes);
--- 124,128 ----
                function bs_write_port($str,$bytes=0)
                {
!                       if($bytes)
                        {
                                $ok = 
fwrite($this->socket,$this->add_crlf($str),$bytes);
***************
*** 132,136 ****
                                $ok = 
fwrite($this->socket,$this->add_crlf($str));
                        }
!                       if (!$ok)
                        {
                                return $this->set_error('Error','Connection 
Lost','lost connection to server');
--- 132,136 ----
                                $ok = 
fwrite($this->socket,$this->add_crlf($str));
                        }
!                       if(!$ok)
                        {
                                return $this->set_error('Error','Connection 
Lost','lost connection to server');
***************
*** 149,153 ****
                                        'The required socked does not exist.  
The settings for your mail server may be wrong.');
                        }
!                       if (!$this->write_port($str))
                        {
                                if(substr($expected_response,1,1) == '+')
--- 149,153 ----
                                        'The required socked does not exist.  
The settings for your mail server may be wrong.');
                        }
!                       if(!$this->write_port($str))
                        {
                                if(substr($expected_response,1,1) == '+')
***************
*** 161,170 ****
                        }
                        $response = $this->read_port();
!                       if 
(!ereg(strtoupper($expected_response),strtoupper($response)))
                        {
                                if(substr($expected_response,1,1) == '+')
                                {
                                        return $this->set_error('550','','');
!                               }       
                                $pos = strpos(' ',$response);
                                return 
$this->set_error(substr($response,0,$pos),
--- 161,170 ----
                        }
                        $response = $this->read_port();
!                       
if(!ereg(strtoupper($expected_response),strtoupper($response)))
                        {
                                if(substr($expected_response,1,1) == '+')
                                {
                                        return $this->set_error('550','','');
!                               }
                                $pos = strpos(' ',$response);
                                return 
$this->set_error(substr($response,0,$pos),
***************
*** 178,203 ****
                }
  
!               // return contents of a web url as an array or false if timeout
!               function gethttpsocketfile($file)
                {
                        $server = str_replace('http://','',$file);
                        $file = strstr($server,'/');
                        $server = str_replace($file,'',$server);
!                       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'."\n\n"))
                                        {
                                                return False;
                                        }
                                        $i = 0;
!                                       while ($line = $this->read_port())
                                        {
!                                               if (feof($this->socket))
                                                {
                                                        break;
                                                }
!                                               $lines[] = $line;
                                                $i++;
                                        }
--- 178,217 ----
                }
  
!               /*
!                Return contents of a web url as an array or false if timeout.
!                If $string is set (True), a string is returned with all \r and 
\n removed.
!                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)
                {
                        $server = str_replace('http://','',$file);
                        $file = strstr($server,'/');
                        $server = str_replace($file,'',$server);
!                       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'."\n\n"))
                                        {
                                                return False;
                                        }
                                        $i = 0;
!                                       while($line = $this->read_port())
                                        {
!                                               if(feof($this->socket))
                                                {
                                                        break;
                                                }
!                                               if($string)
!                                               {
!                                                       $line = 
ereg_replace("\n",'',$line);
!                                                       $line = 
ereg_replace("\r",'',$line);
!                                                       $lines .= $line;
!                                               }
!                                               else
!                                               {
!                                                       $lines[] = $line;
!                                               }
                                                $i++;
                                        }
***************
*** 212,224 ****
                        else
                        {
!                               if ($this->open_port($server, 80, 15))
                                {
!                                       if (!$this->write_port('GET '.$file.' 
HTTP/1.0'."\n".'Host: '.$server."\n\n"))
                                        {
                                                return 0;
                                        }
!                                       while ($line = $this->read_port())
                                        {
!                                               $lines[] = $line;
                                        }
                                        $this->close_port();
--- 226,247 ----
                        else
                        {
!                               if($this->open_port($server, 80, 15))
                                {
!                                       if(!$this->write_port('GET '.$file.' 
HTTP/1.0'."\n".'Host: '.$server."\n\n"))
                                        {
                                                return 0;
                                        }
!                                       while($line = $this->read_port())
                                        {
!                                               if($string)
!                                               {
!                                                       $line = 
ereg_replace("\n",'',$line);
!                                                       $line = 
ereg_replace("\r",'',$line);
!                                                       $lines .= $line;
!                                               }
!                                               else
!                                               {
!                                                       $lines[] = $line;
!                                               }
                                        }
                                        $this->close_port();




reply via email to

[Prev in Thread] Current Thread [Next in Thread]