cvs: smarty /plugins function.fetch.php

From: Date: Mon, 06 May 2002 14:50:38 +0000
Subject: cvs: smarty /plugins function.fetch.php
Groups: php.smarty.cvs 
Request: Send a blank email to php-smarty-cvs+get-103@lists.php.net to get a copy of this message
mohrt Mon May 6 10:50:38 2002 EDT Modified files: /smarty/plugins function.fetch.php Log: update fetch function with more error checking Index: smarty/plugins/function.fetch.php diff -u smarty/plugins/function.fetch.php:1.6 smarty/plugins/function.fetch.php:1.7 --- smarty/plugins/function.fetch.php:1.6 Tue Apr 30 09:57:14 2002 +++ smarty/plugins/function.fetch.php Mon May 6 10:50:37 2002 @@ -29,16 +29,16 @@ $smarty->_trigger_plugin_error("(secure mode) fetch '$file' is not allowed"); return; } - if (!@is_readable($file)) { - $smarty->_trigger_plugin_error("fetch cannot read file '$file'"); - return; - } // fetch the file - $fp = fopen($file,'r'); - while(!feof($fp)) { - $content .= fgets ($fp,4096); + if($fp = @fopen($file,'r')) { + while(!feof($fp)) { + $content .= fgets ($fp,4096); + } + fclose($fp); + } else { + $smarty->_trigger_plugin_error("fetch cannot read file '$file'"); + return; } - fclose($fp); } else { // not a local file if(preg_match('!^http://!i',$file)) { @@ -127,12 +127,6 @@ return; } break; - case "cluster_host": - if(!empty($param_value) - && (gethostbyname($param_value) != $param_value)) { - $server_name = $param_value; - } - break; default: $smarty->_trigger_plugin_error("unrecognized attribute '".$param_key."'"); return; @@ -194,11 +188,15 @@ } } else { // ftp fetch - $fp = fopen($file,'r'); - while(!feof($fp)) { - $content .= fgets ($fp,4096); + if($fp = @fopen($file,'r')) { + while(!feof($fp)) { + $content .= fgets ($fp,4096); + } + fclose($fp); + } else { + $smarty->_trigger_plugin_error("fetch cannot read file '$file'"); + return; } - fclose($fp); } }

« previous php.smarty.cvs (#103) next »