formatting

This commit is contained in:
Miles Lott 2001-11-13 14:05:13 +00:00
parent 7e77cf8439
commit 09512b2072

View File

@ -1,4 +1,4 @@
<? <?php
/**************************************************************************\ /**************************************************************************\
* phpGroupWare API - HTTP protocol class * * phpGroupWare API - HTTP protocol class *
* http://www.phpgroupware.org/api * * http://www.phpgroupware.org/api *
@ -13,286 +13,341 @@
/* $Id$ */ /* $Id$ */
class http class http
{ {
var $host_name=""; var $host_name = '';
var $host_port=80; var $host_port = 80;
var $proxy_host_name=""; var $proxy_host_name = '';
var $proxy_host_port=80; var $proxy_host_port = 80;
var $request_method="GET"; var $request_method = 'GET';
var $user_agent="Manuel Lemos HTTP class test script"; var $user_agent = 'Manuel Lemos HTTP class test script';
var $request_uri=""; var $request_uri = '';
var $protocol_version="1.0"; var $protocol_version = '1.0';
var $debug=0; var $debug = 0;
var $support_cookies=1; var $support_cookies = 1;
var $cookies=array(); var $cookies = array();
/* private variables - DO NOT ACCESS */ /* private variables - DO NOT ACCESS */
var $state="Disconnected"; var $state = 'Disconnected';
var $connection=0; var $connection = 0;
var $content_length=0; var $content_length = 0;
var $read_length=0; var $read_length = 0;
var $request_host=""; var $request_host = '';
var $months=array( var $months = array(
"Jan"=>"01", 'Jan' => '01',
"Feb"=>"02", 'Feb' => '02',
"Mar"=>"03", 'Mar' => '03',
"Apr"=>"04", 'Apr' => '04',
"May"=>"05", 'May' => '05',
"Jun"=>"06", 'Jun' => '06',
"Jul"=>"07", 'Jul' => '07',
"Aug"=>"08", 'Aug' => '08',
"Sep"=>"09", 'Sep' => '09',
"Oct"=>"10", 'Oct' => '10',
"Nov"=>"11", 'Nov' => '11',
"Dec"=>"12"); 'Dec' => '12'
);
/* Private methods - DO NOT CALL */ /* Private methods - DO NOT CALL */
Function OutputDebug($message) function OutputDebug($message)
{ {
echo $message,"\n"; echo $message,"\n";
} }
Function GetLine() function GetLine()
{ {
for($line="";;) for($line='';;)
{
if(feof($this->connection) || !($part=fgets($this->connection,100)))
{ {
if(feof($this->connection)
|| !($part=fgets($this->connection,100)))
return(0); return(0);
}
$line.=$part; $line.=$part;
$length=strlen($line); $length=strlen($line);
if($length>=2 if($length>=2 && substr($line,$length-2,2)=="\r\n")
&& substr($line,$length-2,2)=="\r\n")
{ {
$line=substr($line,0,$length-2); $line=substr($line,0,$length-2);
if($this->debug) if($this->debug)
{
$this->OutputDebug("< $line"); $this->OutputDebug("< $line");
}
return($line); return($line);
} }
} }
} }
Function PutLine($line) function PutLine($line)
{ {
if($this->debug) if($this->debug)
{
$this->OutputDebug("> $line"); $this->OutputDebug("> $line");
}
return(fputs($this->connection,"$line\r\n")); return(fputs($this->connection,"$line\r\n"));
} }
Function PutData($data) function PutData($data)
{ {
if($this->debug) if($this->debug)
{
$this->OutputDebug("> $data"); $this->OutputDebug("> $data");
}
return(fputs($this->connection,$data)); return(fputs($this->connection,$data));
} }
Function Readbytes($length) function Readbytes($length)
{ {
if($this->debug) if($this->debug)
{ {
if(($bytes=fread($this->connection,$length))!="") if(($bytes=fread($this->connection,$length))!="")
{
$this->OutputDebug("< $bytes"); $this->OutputDebug("< $bytes");
}
return($bytes); return($bytes);
} }
else else
{
return(fread($this->connection,$length)); return(fread($this->connection,$length));
} }
}
Function EndOfInput() function EndOfInput()
{ {
return(feof($this->connection)); return(feof($this->connection));
} }
Function Connect($host_name,$host_port) function Connect($host_name,$host_port)
{ {
if($this->debug) if($this->debug)
{
$this->OutputDebug("Connecting to $host_name..."); $this->OutputDebug("Connecting to $host_name...");
}
if(($this->connection=fsockopen($host_name,$host_port,&$error))==0) if(($this->connection=fsockopen($host_name,$host_port,&$error))==0)
{ {
switch($error) switch($error)
{ {
case -3: case -3:
return("-3 socket could not be created"); return('-3 socket could not be created');
case -4: case -4:
return("-4 dns lookup on hostname \"".$host_name."\" failed"); return('-4 dns lookup on hostname "'.$host_name.'" failed');
case -5: case -5:
return("-5 connection refused or timed out"); return('-5 connection refused or timed out');
case -6: case -6:
return("-6 fdopen() call failed"); return('-6 fdopen() call failed');
case -7: case -7:
return("-7 setvbuf() call failed"); return('-7 setvbuf() call failed');
default: default:
return($error." could not connect to the host \"".$host_name."\""); return($error.' could not connect to the host "'.$host_name.'"');
} }
} }
else else
{ {
if($this->debug) if($this->debug)
{
$this->OutputDebug("Connected to $host_name"); $this->OutputDebug("Connected to $host_name");
$this->state="Connected"; }
$this->state='Connected';
return(""); return("");
} }
} }
Function Disconnect() function Disconnect()
{ {
if($this->debug) if($this->debug)
$this->OutputDebug("Disconnected from ".$this->host_name); {
$this->OutputDebug('Disconnected from '.$this->host_name);
}
fclose($this->connection); fclose($this->connection);
return(""); return('');
} }
/* Public methods */ /* Public methods */
Function Open($arguments) function Open($arguments)
{ {
if($this->state!="Disconnected") if($this->state!='Disconnected')
return("1 already connected"); {
if(IsSet($arguments["HostName"])) return('1 already connected');
$this->host_name=$arguments["HostName"]; }
if(IsSet($arguments["HostPort"])) if(IsSet($arguments['HostName']))
$this->host_port=$arguments["HostPort"]; {
if(IsSet($arguments["ProxyHostName"])) $this->host_name=$arguments['HostName'];
$this->proxy_host_name=$arguments["ProxyHostName"]; }
if(IsSet($arguments["ProxyHostPort"])) if(IsSet($arguments['HostPort']))
$this->proxy_host_port=$arguments["ProxyHostPort"]; {
$this->host_port=$arguments['HostPort'];
}
if(IsSet($arguments['ProxyHostName']))
{
$this->proxy_host_name=$arguments['ProxyHostName'];
}
if(IsSet($arguments['ProxyHostPort']))
{
$this->proxy_host_port=$arguments['ProxyHostPort'];
}
if(strlen($this->proxy_host_name)==0) if(strlen($this->proxy_host_name)==0)
{ {
if(strlen($this->host_name)==0) if(strlen($this->host_name)==0)
return("2 it was not specified a valid hostname"); {
$host_name=$this->host_name; return('2 it was not specified a valid hostname');
$host_port=$this->host_port; }
$host_name = $this->host_name;
$host_port = $this->host_port;
} }
else else
{ {
$host_name=$this->proxy_host_name; $host_name = $this->proxy_host_name;
$host_port=$this->proxy_host_port; $host_port = $this->proxy_host_port;
} }
$error=$this->Connect($host_name,$host_port); $error = $this->Connect($host_name,$host_port);
if(strlen($error)==0) if(strlen($error)==0)
$this->state="Connected";
return($error);
}
Function Close()
{ {
if($this->state=="Disconnected") $this->state = 'Connected';
return("1 already disconnected"); }
$error=$this->Disconnect();
if(strlen($error)==0)
$this->state="Disconnected";
return($error); return($error);
} }
Function SendRequest($arguments) function Close()
{
if($this->state == 'Disconnected')
{
return('1 already disconnected');
}
$error = $this->Disconnect();
if(strlen($error) == 0)
{
$this->state = 'Disconnected';
}
return($error);
}
function SendRequest($arguments)
{ {
switch($this->state) switch($this->state)
{ {
case "Disconnected": case 'Disconnected':
return("1 connection was not yet established"); return('1 connection was not yet established');
case "Connected": case 'Connected':
break; break;
default: default:
return("2 can not send request in the current connection state"); return('2 can not send request in the current connection state');
} }
if(IsSet($arguments["RequestMethod"])) if(IsSet($arguments['RequestMethod']))
$this->request_method=$arguments["RequestMethod"];
if(IsSet($arguments["User-Agent"]))
$this->user_agent=$arguments["User-Agent"];
if(strlen($this->request_method)==0)
return("3 it was not specified a valid request method");
if(IsSet($arguments["RequestURI"]))
$this->request_uri=$arguments["RequestURI"];
if(strlen($this->request_uri)==0
|| substr($this->request_uri,0,1)!="/")
return("4 it was not specified a valid request URI");
$request_body="";
$headers=(IsSet($arguments["Headers"]) ? $arguments["Headers"] : array());
if($this->request_method=="POST")
{ {
if(IsSet($arguments["PostValues"])) $this->request_method = $arguments['RequestMethod'];
}
if(IsSet($arguments['User-Agent']))
{ {
$values=$arguments["PostValues"]; $this->user_agent = $arguments['User-Agent'];
if(GetType($values)!="array") }
return("5 it was not specified a valid POST method values array"); if(strlen($this->request_method) == 0)
for($request_body="",Reset($values),$value=0;$value<count($values);Next($values),$value++) {
return('3 it was not specified a valid request method');
}
if(IsSet($arguments['RequestURI']))
{
$this->request_uri = $arguments['RequestURI'];
}
if(strlen($this->request_uri) == 0 || substr($this->request_uri,0,1) != '/')
{
return('4 it was not specified a valid request URI');
}
$request_body = '';
$headers=(IsSet($arguments['Headers']) ? $arguments['Headers'] : array());
if($this->request_method == 'POST')
{
if(IsSet($arguments['PostValues']))
{
$values = $arguments['PostValues'];
if(GetType($values) != 'array')
{
return('5 it was not specified a valid POST method values array');
}
for($request_body = '',Reset($values),$value=0;$value<count($values);Next($values),$value++)
{ {
if($value>0) if($value>0)
$request_body.="&";
$request_body.=Key($values)."=".UrlEncode($values[Key($values)]);
}
$headers["Content-type"]="application/x-www-form-urlencoded";
}
}
if(strlen($this->proxy_host_name)==0)
$request_uri=$this->request_uri;
else
$request_uri="http://".$this->host_name.($this->host_port==80 ? "" : ":".$this->host_port).$this->request_uri;
if(($success=$this->PutLine($this->request_method." ".$request_uri." HTTP/".$this->protocol_version)))
{ {
if(($body_length=strlen($request_body))) $request_body .= '&';
$headers["Content-length"]=$body_length; }
$request_body.=Key($values).'='.UrlEncode($values[Key($values)]);
}
$headers['Content-type'] = 'application/x-www-form-urlencoded';
}
}
if(strlen($this->proxy_host_name) == 0)
{
$request_uri = $this->request_uri;
}
else
{
$request_uri = 'http://'.$this->host_name.($this->host_port==80 ? '' : ':'.$this->host_port).$this->request_uri;
}
if(($success = $this->PutLine($this->request_method.' '.$request_uri.' HTTP/'.$this->protocol_version)))
{
if(($body_length = strlen($request_body)))
{
$headers['Content-length'] = $body_length;
}
for($host_set=0,Reset($headers),$header=0;$header<count($headers);Next($headers),$header++) for($host_set=0,Reset($headers),$header=0;$header<count($headers);Next($headers),$header++)
{ {
$header_name=Key($headers); $header_name = Key($headers);
$header_value=$headers[$header_name]; $header_value = $headers[$header_name];
if(GetType($header_value)=="array") if(GetType($header_value)=='array')
{ {
for(Reset($header_value),$value=0;$value<count($header_value);Next($header_value),$value++) for(Reset($header_value),$value=0;$value<count($header_value);Next($header_value),$value++)
{ {
if(!$success=$this->PutLine("$header_name: ".$header_value[Key($header_value)])) if(!$success = $this->PutLine("$header_name: ".$header_value[Key($header_value)]))
{
break 2; break 2;
} }
} }
}
else else
{ {
if(!$success=$this->PutLine("$header_name: $header_value")) if(!$success = $this->PutLine("$header_name: $header_value"))
{
break; break;
} }
if(strtolower(Key($headers))=="host") }
if(strtolower(Key($headers)) == 'host')
{ {
$this->request_host=strtolower($header_value); $this->request_host = strtolower($header_value);
$host_set=1; $host_set = 1;
} }
} }
if($success) if($success)
{ {
if(!$host_set) if(!$host_set)
{ {
$success=$this->PutLine("Host: ".$this->host_name); $success = $this->PutLine('Host: '.$this->host_name);
$this->request_host=strtolower($this->host_name); $this->request_host = strtolower($this->host_name);
} }
if(count($this->cookies) if(count($this->cookies) && IsSet($this->cookies[0]))
&& IsSet($this->cookies[0]))
{ {
$now=gmdate("Y-m-d H-i-s"); $now = gmdate('Y-m-d H-i-s');
for($cookies=array(),$domain=0,Reset($this->cookies[0]);$domain<count($this->cookies[0]);Next($this->cookies[0]),$domain++) for($cookies = array(),$domain=0,Reset($this->cookies[0]);$domain<count($this->cookies[0]);Next($this->cookies[0]),$domain++)
{ {
$domain_pattern=Key($this->cookies[0]); $domain_pattern = Key($this->cookies[0]);
$match=strlen($this->request_host)-strlen($domain_pattern); $match = strlen($this->request_host)-strlen($domain_pattern);
if($match>=0 if($match >= 0 &&
&& !strcmp($domain_pattern,substr($this->request_host,$match)) !strcmp($domain_pattern,substr($this->request_host,$match)) &&
&& ($match==0 ($match == 0 || $domain_pattern[0] == '.' || $this->request_host[$match-1] == '.'))
|| $domain_pattern[0]=="."
|| $this->request_host[$match-1]=="."))
{ {
for(Reset($this->cookies[0][$domain_pattern]),$path_part=0;$path_part<count($this->cookies[0][$domain_pattern]);Next($this->cookies[0][$domain_pattern]),$path_part++) for(Reset($this->cookies[0][$domain_pattern]),$path_part=0;$path_part<count($this->cookies[0][$domain_pattern]);Next($this->cookies[0][$domain_pattern]),$path_part++)
{ {
$path=Key($this->cookies[0][$domain_pattern]); $path = Key($this->cookies[0][$domain_pattern]);
if(strlen($this->request_uri)>=strlen($path) if(strlen($this->request_uri) >= strlen($path) && substr($this->request_uri,0,strlen($path)) == $path)
&& substr($this->request_uri,0,strlen($path))==$path)
{ {
for(Reset($this->cookies[0][$domain_pattern][$path]),$cookie=0;$cookie<count($this->cookies[0][$domain_pattern][$path]);Next($this->cookies[0][$domain_pattern][$path]),$cookie++) for(Reset($this->cookies[0][$domain_pattern][$path]),$cookie = 0;$cookie<count($this->cookies[0][$domain_pattern][$path]);Next($this->cookies[0][$domain_pattern][$path]),$cookie++)
{ {
$cookie_name=Key($this->cookies[0][$domain_pattern][$path]); $cookie_name = Key($this->cookies[0][$domain_pattern][$path]);
$expires=$this->cookies[0][$domain_pattern][$path][$cookie_name]["expires"]; $expires = $this->cookies[0][$domain_pattern][$path][$cookie_name]['expires'];
if($expires=="" if($expires == '' || strcmp($now,$expires)<0)
|| strcmp($now,$expires)<0) {
$cookies[$cookie_name]=$this->cookies[0][$domain_pattern][$path][$cookie_name]; $cookies[$cookie_name] = $this->cookies[0][$domain_pattern][$path][$cookie_name];
}
} }
} }
} }
@ -300,175 +355,193 @@ class http
} }
for(Reset($cookies),$cookie=0;$cookie<count($cookies);Next($cookies),$cookie++) for(Reset($cookies),$cookie=0;$cookie<count($cookies);Next($cookies),$cookie++)
{ {
$cookie_name=Key($cookies); $cookie_name = Key($cookies);
if(!($success=$this->PutLine("Cookie: ".UrlEncode($cookie_name)."=".$cookies[$cookie_name]["value"].";"))) if(!($success = $this->PutLine('Cookie: '.UrlEncode($cookie_name).'='.$cookies[$cookie_name]['value'].';')))
{
break; break;
} }
} }
}
if($success) if($success)
{ {
if($success) if($success)
{ {
$success=$this->PutLine(""); $success = $this->PutLine('');
if($body_length if($body_length && $success)
&& $success) {
$success=$this->PutData($request_body); $success = $this->PutData($request_body);
}
} }
} }
} }
} }
if(!$success) if(!$success)
return("5 could not send the HTTP request"); {
$this->state="RequestSent"; return('5 could not send the HTTP request');
return(""); }
$this->state = 'RequestSent';
return('');
} }
Function ReadReplyHeaders(&$headers) function ReadReplyHeaders(&$headers)
{ {
switch($this->state) switch($this->state)
{ {
case "Disconnected": case 'Disconnected':
return("1 connection was not yet established"); return('1 connection was not yet established');
case "Connected": case 'Connected':
return("2 request was not sent"); return('2 request was not sent');
case "RequestSent": case 'RequestSent':
break; break;
default: default:
return("3 can not get request headers in the current connection state"); return('3 can not get request headers in the current connection state');
} }
$headers=array(); $headers = array();
$this->content_length=$this->read_length=0; $this->content_length = $this->read_length = 0;
$this->content_length_set=0; $this->content_length_set = 0;
for(;;) for(;;)
{ {
$line=$this->GetLine(); $line = $this->GetLine();
if(GetType($line)!="string") if(GetType($line) != 'string')
return("4 could not read request reply");
if($line=="")
{ {
$this->state="GotReplyHeaders"; return('4 could not read request reply');
return("");
} }
$header_name=strtolower(strtok($line,":")); if($line == '')
$header_value=Trim(Chop(strtok("\r\n"))); {
$this->state = 'GotReplyHeaders';
return('');
}
$header_name = strtolower(strtok($line,':'));
$header_value = Trim(Chop(strtok("\r\n")));
if(IsSet($headers[$header_name])) if(IsSet($headers[$header_name]))
{ {
if(GetType($headers[$header_name])=="string") if(GetType($headers[$header_name]) == 'string')
$headers[$header_name]=array($headers[$header_name]); {
$headers[$header_name][]=$header_value; $headers[$header_name] = array($headers[$header_name]);
}
$headers[$header_name][] = $header_value;
} }
else else
$headers[$header_name]=$header_value; {
$headers[$header_name] = $header_value;
}
switch($header_name) switch($header_name)
{ {
case "content-length": case 'content-length':
$this->content_length=intval($headers[$header_name]); $this->content_length = intval($headers[$header_name]);
$this->content_length_set=1; $this->content_length_set = 1;
break; break;
case "set-cookie": case 'set-cookie':
if($this->support_cookies) if($this->support_cookies)
{ {
$cookie_name=trim(strtok($headers[$header_name],"=")); $cookie_name = trim(strtok($headers[$header_name],'='));
$cookie_value=strtok(";"); $cookie_value = strtok(';');
$domain=$this->request_host; $domain = $this->request_host;
$path="/"; $path = '/';
$expires=""; $expires = '';
$secure=0; $secure = 0;
while(($name=strtolower(trim(strtok("="))))!="") while(($name=strtolower(trim(strtok('=')))) != '')
{ {
$value=UrlDecode(strtok(";")); $value=UrlDecode(strtok(';'));
switch($name) switch($name)
{ {
case "domain": case 'domain':
if($value=="" if($value == '' || !strpos($value,'.',$value[0] == '.'))
|| !strpos($value,".",$value[0]==".")) {
break; break;
$domain=strtolower($value); }
$domain = strtolower($value);
break; break;
case "path": case 'path':
if($value!="" if($value != '' && $value[0] == '/')
&& $value[0]=="/") {
$path=$value; $path = $value;
}
break; break;
case "expires": case 'expires':
if(ereg("^((Mon|Monday|Tue|Tuesday|Wed|Wednesday|Thu|Thursday|Fri|Friday|Sat|Saturday|Sun|Sunday), )?([0-9]{2})\\-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\\-([0-9]{2,4}) ([0-9]{2})\\:([0-9]{2})\\:([0-9]{2}) GMT$",$value,$matches)) if(ereg("^((Mon|Monday|Tue|Tuesday|Wed|Wednesday|Thu|Thursday|Fri|Friday|Sat|Saturday|Sun|Sunday), )?([0-9]{2})\\-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\\-([0-9]{2,4}) ([0-9]{2})\\:([0-9]{2})\\:([0-9]{2}) GMT$",$value,$matches))
{ {
$year=intval($matches[5]); $year = intval($matches[5]);
if($year<1900) if($year<1900)
$year+=($year<70 ? 2000 : 1900); {
$expires="$year-".$this->months[$matches[4]]."-".$matches[3]." ".$matches[6].":".$matches[7].":".$matches[8]; $year += ($year<70 ? 2000 : 1900);
}
$expires = "$year-".$this->months[$matches[4]].'-'.$matches[3].' '.$matches[6].':'.$matches[7].':'.$matches[8];
} }
break; break;
case "secure": case 'secure':
$secure=1; $secure = 1;
break; break;
} }
} }
$this->cookies[$secure][$domain][$path][$cookie_name]=array( $this->cookies[$secure][$domain][$path][$cookie_name] = array(
"name"=>$cookie_name, 'name' => $cookie_name,
"value"=>$cookie_value, 'value' => $cookie_value,
"domain"=>$domain, 'domain' => $domain,
"path"=>$path, 'path' => $path,
"expires"=>$expires, 'expires' => $expires,
"secure"=>$secure 'secure' => $secure
); );
} }
} }
} }
} }
Function ReadReplyBody(&$body,$length) function ReadReplyBody(&$body,$length)
{ {
switch($this->state) switch($this->state)
{ {
case "Disconnected": case 'Disconnected':
return("1 connection was not yet established"); return('1 connection was not yet established');
case "Connected": case 'Connected':
return("2 request was not sent"); return('2 request was not sent');
case "RequestSent": case 'RequestSent':
if(($error=$this->ReadReplyHeaders(&$headers))!="") if(($error = $this->ReadReplyHeaders(&$headers)) != '')
{
return($error); return($error);
}
break; break;
case "GotReplyHeaders": case 'GotReplyHeaders':
break; break;
default: default:
return("3 can not get request headers in the current connection state"); return('3 can not get request headers in the current connection state');
} }
$body=""; $body = '';
if($this->content_length_set) if($this->content_length_set)
$length=min($this->content_length-$this->read_length,$length); {
if($length>0 $length = min($this->content_length-$this->read_length,$length);
&& !$this->EndOfInput() }
&& ($body=$this->ReadBytes($length))=="") if($length>0 && !$this->EndOfInput() && ($body = $this->ReadBytes($length)) == '')
return("4 could not get the request reply body"); {
return(""); return('4 could not get the request reply body');
}
return('');
} }
Function GetPersistentCookies(&$cookies) function GetPersistentCookies(&$cookies)
{ {
$now=gmdate("Y-m-d H-i-s"); $now = gmdate('Y-m-d H-i-s');
$cookies=array(); $cookies = array();
for($secure_cookies=0,Reset($this->cookies);$secure_cookies<count($this->cookies);Next($this->cookies),$secure_cookies++) for($secure_cookies = 0,Reset($this->cookies);$secure_cookies<count($this->cookies);Next($this->cookies),$secure_cookies++)
{ {
$secure=Key($this->cookies); $secure = Key($this->cookies);
for($domain=0,Reset($this->cookies[$secure]);$domain<count($this->cookies[$secure]);Next($this->cookies[$secure]),$domain++) for($domain = 0,Reset($this->cookies[$secure]);$domain<count($this->cookies[$secure]);Next($this->cookies[$secure]),$domain++)
{ {
$domain_pattern=Key($this->cookies[$secure]); $domain_pattern = Key($this->cookies[$secure]);
for(Reset($this->cookies[$secure][$domain_pattern]),$path_part=0;$path_part<count($this->cookies[$secure][$domain_pattern]);Next($this->cookies[$secure][$domain_pattern]),$path_part++) for(Reset($this->cookies[$secure][$domain_pattern]),$path_part=0;$path_part<count($this->cookies[$secure][$domain_pattern]);Next($this->cookies[$secure][$domain_pattern]),$path_part++)
{ {
$path=Key($this->cookies[$secure][$domain_pattern]); $path=Key($this->cookies[$secure][$domain_pattern]);
for(Reset($this->cookies[$secure][$domain_pattern][$path]),$cookie=0;$cookie<count($this->cookies[$secure][$domain_pattern][$path]);Next($this->cookies[$secure][$domain_pattern][$path]),$cookie++) for(Reset($this->cookies[$secure][$domain_pattern][$path]),$cookie=0;$cookie<count($this->cookies[$secure][$domain_pattern][$path]);Next($this->cookies[$secure][$domain_pattern][$path]),$cookie++)
{ {
$cookie_name=Key($this->cookies[$secure][$domain_pattern][$path]); $cookie_name = Key($this->cookies[$secure][$domain_pattern][$path]);
$expires=$this->cookies[$secure][$domain_pattern][$path][$cookie_name]["expires"]; $expires = $this->cookies[$secure][$domain_pattern][$path][$cookie_name]['expires'];
if($expires!="" if($expires != '' && strcmp($now,$expires)<0)
&& strcmp($now,$expires)<0) {
$cookies[$secure][$domain_pattern][$path][$cookie_name]=$this->cookies[$secure][$domain_pattern][$path][$cookie_name]; $cookies[$secure][$domain_pattern][$path][$cookie_name] = $this->cookies[$secure][$domain_pattern][$path][$cookie_name];
}
}
} }
} }
} }
} }
} }
};