problems calling my own php function from a tpl (not pagelayout)

Author Message

Alessandro Cipriani

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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 19 2025 09:38:42
Script start
Timing: Jan 19 2025 09:38:42
Module start 'layout'
Timing: Jan 19 2025 09:38:42
Module start 'content'
Timing: Jan 19 2025 09:38:42
Module end 'content'
Timing: Jan 19 2025 09:38:42
Script end

Main resources:

Total runtime0.0176 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0072 589.4141152.6563
Module start 'layout' 0.00720.0036 742.070339.5078
Module start 'content' 0.01080.0046 781.578189.5234
Module end 'content' 0.01540.0022 871.101630.3047
Script end 0.0176  901.4063 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002614.9754140.0002
Check MTime0.00126.8254140.0001
Mysql Total
Database connection0.00084.818310.0008
Mysqli_queries0.003721.218330.0012
Looping result0.00000.118910.0000
Template Total0.001810.110.0018
Template load0.00095.237310.0009
Template processing0.00094.846710.0009
Override
Cache load0.00063.638410.0006
General
dbfile0.00031.767980.0000
String conversion0.00000.046040.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs