mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-06-24 20:01:36 +02:00
add string return option to gethttpsocketfile()
This commit is contained in:
parent
bef6b7ed7b
commit
87f3a8e6b8
@ -177,8 +177,13 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// return contents of a web url as an array or false if timeout
|
/*
|
||||||
function gethttpsocketfile($file)
|
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);
|
$server = str_replace('http://','',$file);
|
||||||
$file = strstr($server,'/');
|
$file = strstr($server,'/');
|
||||||
@ -198,7 +203,16 @@
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if($string)
|
||||||
|
{
|
||||||
|
$line = ereg_replace("\n",'',$line);
|
||||||
|
$line = ereg_replace("\r",'',$line);
|
||||||
|
$lines .= $line;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$lines[] = $line;
|
$lines[] = $line;
|
||||||
|
}
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
$this->close_port();
|
$this->close_port();
|
||||||
@ -218,9 +232,18 @@
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
while($line = $this->read_port())
|
while($line = $this->read_port())
|
||||||
|
{
|
||||||
|
if($string)
|
||||||
|
{
|
||||||
|
$line = ereg_replace("\n",'',$line);
|
||||||
|
$line = ereg_replace("\r",'',$line);
|
||||||
|
$lines .= $line;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
$lines[] = $line;
|
$lines[] = $line;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$this->close_port();
|
$this->close_port();
|
||||||
return $lines;
|
return $lines;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user