Thursday 29 April 2004 1:12:53 am
hi all i wrote a simple function called send_viasocket(host) that constructs a socket and communicates with the host on the port 1351.
//send a socket request
case $this->SendViaSocket:
{
$host="127.0.0.1" ; //my host address is secret! :)
$target=$namedParameters['address'] ;
$port=1351 ;
$timeout=60;
$protocol="HTTP/1.0" ;
$br="\r\n" ;
$sk=fsockopen($host,$port,$errnum,$errstr,$timeout) ;
if(!is_resource($sk))
{
echo ("Connessione fallita: ".$errnum." ".$errstr." <br>") ;
}
else
{
$headers="GET ".$target." ".$protocol.$br ;
$headers.="Accept: image/gif, image/x-xbitmap, image/jpeg".$br ;
$headers.="Accept-Language: dialetto veneto".$br ;
$headers.="Host: ".$host.$br ;
$headers.="Connection: Keep-Alive".$br ;
$headers.="User-Agent: Socket-PHP-browser 1.0".$br;
$headers.="Referer: http://www.bwbwabwa.it".$br ;
$headers.="X-INVENTATO: Ciao a tutti".$br.$br;
fputs($sk,$headers) ;
$dati="" ;
}
fclose($sk) ;
$operatorValue="";
}break;
in my pagelayout.tpl i call the function in this way: {"---"|send_viasocket("/index.php?name=alessandro")}
and all works great, as the socket communicates with host:1351/index.php?name=alessandro i wrote the "$operatorValue="";" line because i want the call to the function to be hidden: in this way no output is made to the screen. the problem is in the other templates (for example folder.tpl) where in the 90% of times i call the function i get the string "---" (the function operator) and the function isn't executed (it seems not to be reached). ps: i placed the function in the lib/eztemplate/classes/eztemplatestringoperator.php
i hope i have been clear icq# 326 457 502
best regards alessandro
|