From f6bb3389f6c5bbb0f0b4a235b8753ad777bc09af Mon Sep 17 00:00:00 2001 From: messju Date: Fri, 19 Dec 2003 17:18:56 +0000 Subject: [PATCH] removed tabs. fixed indentiation. --- libs/plugins/function.counter.php | 12 +- libs/plugins/function.fetch.php | 340 +++++++++---------- libs/plugins/function.popup_init.php | 12 +- libs/plugins/modifier.capitalize.php | 2 +- libs/plugins/modifier.cat.php | 4 +- libs/plugins/modifier.date_format.php | 16 +- libs/plugins/modifier.debug_print_var.php | 2 +- libs/plugins/modifier.escape.php | 26 +- libs/plugins/modifier.indent.php | 2 +- libs/plugins/modifier.lower.php | 2 +- libs/plugins/modifier.nl2br.php | 2 +- libs/plugins/modifier.strip.php | 2 +- libs/plugins/modifier.upper.php | 2 +- libs/plugins/modifier.wordwrap.php | 2 +- libs/plugins/outputfilter.trimwhitespace.php | 48 +-- libs/plugins/shared.escape_special_chars.php | 12 +- 16 files changed, 243 insertions(+), 243 deletions(-) diff --git a/libs/plugins/function.counter.php b/libs/plugins/function.counter.php index a186b4d5..cfe5dd88 100644 --- a/libs/plugins/function.counter.php +++ b/libs/plugins/function.counter.php @@ -53,9 +53,9 @@ function smarty_function_counter($params, &$smarty) if ($print) { $retval = $counter['count']; - } else { - $retval = null; - } + } else { + $retval = null; + } if (isset($params['skip'])) { $counter['skip'] = $params['skip']; @@ -69,9 +69,9 @@ function smarty_function_counter($params, &$smarty) $counter['count'] -= $counter['skip']; else $counter['count'] += $counter['skip']; - - return $retval; - + + return $retval; + } /* vim: set expandtab: */ diff --git a/libs/plugins/function.fetch.php b/libs/plugins/function.fetch.php index b013b8c3..a3273a1e 100644 --- a/libs/plugins/function.fetch.php +++ b/libs/plugins/function.fetch.php @@ -27,182 +27,182 @@ function smarty_function_fetch($params, &$smarty) } if ($smarty->security && !preg_match('!^(http|ftp)://!i', $params['file'])) { - $_params = array('resource_type' => 'file', 'resource_name' => $params['file']); - require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.is_secure.php'); - if(!smarty_core_is_secure($_params, $smarty)) { + $_params = array('resource_type' => 'file', 'resource_name' => $params['file']); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.is_secure.php'); + if(!smarty_core_is_secure($_params, $smarty)) { $smarty->_trigger_fatal_error('[plugin] (secure mode) fetch \'' . $params['file'] . '\' is not allowed'); - return; - } - - // fetch the file - if($fp = @fopen($params['file'],'r')) { - while(!feof($fp)) { - $content .= fgets ($fp,4096); - } - fclose($fp); - } else { + return; + } + + // fetch the file + if($fp = @fopen($params['file'],'r')) { + while(!feof($fp)) { + $content .= fgets ($fp,4096); + } + fclose($fp); + } else { $smarty->_trigger_fatal_error('[plugin] fetch cannot read file \'' . $params['file'] . '\''); - return; - } + return; + } } else { - // not a local file - if(preg_match('!^http://!i',$params['file'])) { - // http fetch - if($uri_parts = parse_url($params['file'])) { - // set defaults - $host = $server_name = $uri_parts['host']; - $timeout = 30; - $accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*"; - $agent = "Smarty Template Engine ".$smarty->_version; - $referer = ""; - $uri = !empty($uri_parts['path']) ? $uri_parts['path'] : '/'; - $uri .= !empty($uri_parts['query']) ? '?' . $uri_parts['query'] : ''; - $_is_proxy = false; - if(empty($uri_parts['port'])) { - $port = 80; - } else { - $port = $uri_parts['port']; - } - if(empty($uri_parts['user'])) { - $user = ''; - } - // loop through parameters, setup headers - foreach($params as $param_key => $param_value) { - switch($param_key) { - case "file": - case "assign": - case "assign_headers": - break; - case "user": - if(!empty($param_value)) { - $user = $param_value; - } - break; - case "pass": - if(!empty($param_value)) { - $pass = $param_value; - } - break; - case "accept": - if(!empty($param_value)) { - $accept = $param_value; - } - break; - case "header": - if(!empty($param_value)) { - if(!preg_match('![\w\d-]+: .+!',$param_value)) { - $smarty->_trigger_fatal_error("[plugin] invalid header format '".$param_value."'"); - return; - } else { - $extra_headers[] = $param_value; - } - } - break; - case "proxy_host": - if(!empty($param_value)) { - $proxy_host = $param_value; - } - break; - case "proxy_port": - if(!preg_match('!\D!', $param_value)) { - $proxy_port = (int) $param_value; - } else { - $smarty->_trigger_fatal_error("[plugin] invalid value for attribute '".$param_key."'"); - return; - } - break; - case "agent": - if(!empty($param_value)) { - $agent = $param_value; - } - break; - case "referer": - if(!empty($param_value)) { - $referer = $param_value; - } - break; - case "timeout": - if(!preg_match('!\D!', $param_value)) { - $timeout = (int) $param_value; - } else { - $smarty->_trigger_fatal_error("[plugin] invalid value for attribute '".$param_key."'"); - return; - } - break; - default: - $smarty->_trigger_fatal_error("[plugin] unrecognized attribute '".$param_key."'"); - return; - } - } - if(!empty($proxy_host) && !empty($proxy_port)) { - $_is_proxy = true; - $fp = fsockopen($proxy_host,$proxy_port,$errno,$errstr,$timeout); - } else { - $fp = fsockopen($server_name,$port,$errno,$errstr,$timeout); - } + // not a local file + if(preg_match('!^http://!i',$params['file'])) { + // http fetch + if($uri_parts = parse_url($params['file'])) { + // set defaults + $host = $server_name = $uri_parts['host']; + $timeout = 30; + $accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*"; + $agent = "Smarty Template Engine ".$smarty->_version; + $referer = ""; + $uri = !empty($uri_parts['path']) ? $uri_parts['path'] : '/'; + $uri .= !empty($uri_parts['query']) ? '?' . $uri_parts['query'] : ''; + $_is_proxy = false; + if(empty($uri_parts['port'])) { + $port = 80; + } else { + $port = $uri_parts['port']; + } + if(empty($uri_parts['user'])) { + $user = ''; + } + // loop through parameters, setup headers + foreach($params as $param_key => $param_value) { + switch($param_key) { + case "file": + case "assign": + case "assign_headers": + break; + case "user": + if(!empty($param_value)) { + $user = $param_value; + } + break; + case "pass": + if(!empty($param_value)) { + $pass = $param_value; + } + break; + case "accept": + if(!empty($param_value)) { + $accept = $param_value; + } + break; + case "header": + if(!empty($param_value)) { + if(!preg_match('![\w\d-]+: .+!',$param_value)) { + $smarty->_trigger_fatal_error("[plugin] invalid header format '".$param_value."'"); + return; + } else { + $extra_headers[] = $param_value; + } + } + break; + case "proxy_host": + if(!empty($param_value)) { + $proxy_host = $param_value; + } + break; + case "proxy_port": + if(!preg_match('!\D!', $param_value)) { + $proxy_port = (int) $param_value; + } else { + $smarty->_trigger_fatal_error("[plugin] invalid value for attribute '".$param_key."'"); + return; + } + break; + case "agent": + if(!empty($param_value)) { + $agent = $param_value; + } + break; + case "referer": + if(!empty($param_value)) { + $referer = $param_value; + } + break; + case "timeout": + if(!preg_match('!\D!', $param_value)) { + $timeout = (int) $param_value; + } else { + $smarty->_trigger_fatal_error("[plugin] invalid value for attribute '".$param_key."'"); + return; + } + break; + default: + $smarty->_trigger_fatal_error("[plugin] unrecognized attribute '".$param_key."'"); + return; + } + } + if(!empty($proxy_host) && !empty($proxy_port)) { + $_is_proxy = true; + $fp = fsockopen($proxy_host,$proxy_port,$errno,$errstr,$timeout); + } else { + $fp = fsockopen($server_name,$port,$errno,$errstr,$timeout); + } - if(!$fp) { - $smarty->_trigger_fatal_error("[plugin] unable to fetch: $errstr ($errno)"); - return; - } else { - if($_is_proxy) { - fputs($fp, 'GET ' . $params['file'] . " HTTP/1.0\r\n"); - } else { - fputs($fp, "GET $uri HTTP/1.0\r\n"); - } - if(!empty($host)) { - fputs($fp, "Host: $host\r\n"); - } - if(!empty($accept)) { - fputs($fp, "Accept: $accept\r\n"); - } - if(!empty($agent)) { - fputs($fp, "User-Agent: $agent\r\n"); - } - if(!empty($referer)) { - fputs($fp, "Referer: $referer\r\n"); - } - if(isset($extra_headers) && is_array($extra_headers)) { - foreach($extra_headers as $curr_header) { - fputs($fp, $curr_header."\r\n"); - } - } - if(!empty($user) && !empty($pass)) { - fputs($fp, "Authorization: BASIC ".base64_encode("$user:$pass")."\r\n"); - } + if(!$fp) { + $smarty->_trigger_fatal_error("[plugin] unable to fetch: $errstr ($errno)"); + return; + } else { + if($_is_proxy) { + fputs($fp, 'GET ' . $params['file'] . " HTTP/1.0\r\n"); + } else { + fputs($fp, "GET $uri HTTP/1.0\r\n"); + } + if(!empty($host)) { + fputs($fp, "Host: $host\r\n"); + } + if(!empty($accept)) { + fputs($fp, "Accept: $accept\r\n"); + } + if(!empty($agent)) { + fputs($fp, "User-Agent: $agent\r\n"); + } + if(!empty($referer)) { + fputs($fp, "Referer: $referer\r\n"); + } + if(isset($extra_headers) && is_array($extra_headers)) { + foreach($extra_headers as $curr_header) { + fputs($fp, $curr_header."\r\n"); + } + } + if(!empty($user) && !empty($pass)) { + fputs($fp, "Authorization: BASIC ".base64_encode("$user:$pass")."\r\n"); + } - $content = ''; - fputs($fp, "\r\n"); - while(!feof($fp)) { - $content .= fgets($fp,4096); - } - fclose($fp); - $csplit = split("\r\n\r\n",$content,2); + $content = ''; + fputs($fp, "\r\n"); + while(!feof($fp)) { + $content .= fgets($fp,4096); + } + fclose($fp); + $csplit = split("\r\n\r\n",$content,2); - $content = $csplit[1]; - - if(!empty($params['assign_headers'])) { - $smarty->assign($params['assign_headers'],split("\r\n",$csplit[0])); - } - } - } else { - $smarty->_trigger_fatal_error("[plugin] unable to parse URL, check syntax"); - return; - } - } else { - // ftp fetch - if($fp = @fopen($params['file'],'r')) { - while(!feof($fp)) { - $content .= fgets ($fp,4096); - } - fclose($fp); - } else { - $smarty->_trigger_fatal_error('[plugin] fetch cannot read file \'' . $params['file'] .'\''); - return; - } - } - - } + $content = $csplit[1]; + + if(!empty($params['assign_headers'])) { + $smarty->assign($params['assign_headers'],split("\r\n",$csplit[0])); + } + } + } else { + $smarty->_trigger_fatal_error("[plugin] unable to parse URL, check syntax"); + return; + } + } else { + // ftp fetch + if($fp = @fopen($params['file'],'r')) { + while(!feof($fp)) { + $content .= fgets ($fp,4096); + } + fclose($fp); + } else { + $smarty->_trigger_fatal_error('[plugin] fetch cannot read file \'' . $params['file'] .'\''); + return; + } + } + + } if (!empty($params['assign'])) { diff --git a/libs/plugins/function.popup_init.php b/libs/plugins/function.popup_init.php index d9b42bd0..f62c33c1 100644 --- a/libs/plugins/function.popup_init.php +++ b/libs/plugins/function.popup_init.php @@ -20,14 +20,14 @@ */ function smarty_function_popup_init($params, &$smarty) { - $zindex = 1000; - + $zindex = 1000; + if (!empty($params['zindex'])) { - $zindex = $params['zindex']; - } - + $zindex = $params['zindex']; + } + if (!empty($params['src'])) { - return '' . "\n" + return '' . "\n" . '' . "\n"; } else { $smarty->trigger_error("popup_init: missing src parameter"); diff --git a/libs/plugins/modifier.capitalize.php b/libs/plugins/modifier.capitalize.php index 41d63eda..adf862b3 100644 --- a/libs/plugins/modifier.capitalize.php +++ b/libs/plugins/modifier.capitalize.php @@ -19,7 +19,7 @@ */ function smarty_modifier_capitalize($string) { - return ucwords($string); + return ucwords($string); } ?> diff --git a/libs/plugins/modifier.cat.php b/libs/plugins/modifier.cat.php index 8dc73240..f5dc3d68 100644 --- a/libs/plugins/modifier.cat.php +++ b/libs/plugins/modifier.cat.php @@ -17,7 +17,7 @@ * Example: {$var|cat:"foo"} * @link http://smarty.php.net/manual/en/language.modifier.cat.php cat * (Smarty online manual) - * @author Monte Ohrt + * @author Monte Ohrt * @version 1.0 * @param string * @param string @@ -25,7 +25,7 @@ */ function smarty_modifier_cat($string, $cat) { - return $string . $cat; + return $string . $cat; } /* vim: set expandtab: */ diff --git a/libs/plugins/modifier.date_format.php b/libs/plugins/modifier.date_format.php index dbe26a55..351a4b65 100644 --- a/libs/plugins/modifier.date_format.php +++ b/libs/plugins/modifier.date_format.php @@ -11,7 +11,7 @@ require_once $smarty->_get_plugin_filepath('shared','make_timestamp'); /** * Smarty date_format modifier plugin - * + * * Type: modifier
* Name: date_format
* Purpose: format datestamps via strftime
@@ -29,13 +29,13 @@ require_once $smarty->_get_plugin_filepath('shared','make_timestamp'); */ function smarty_modifier_date_format($string, $format="%b %e, %Y", $default_date=null) { - if($string != '') { - return strftime($format, smarty_make_timestamp($string)); - } elseif (isset($default_date) && $default_date != '') { - return strftime($format, smarty_make_timestamp($default_date)); - } else { - return; - } + if($string != '') { + return strftime($format, smarty_make_timestamp($string)); + } elseif (isset($default_date) && $default_date != '') { + return strftime($format, smarty_make_timestamp($default_date)); + } else { + return; + } } /* vim: set expandtab: */ diff --git a/libs/plugins/modifier.debug_print_var.php b/libs/plugins/modifier.debug_print_var.php index 754d4c2f..b9bb1848 100644 --- a/libs/plugins/modifier.debug_print_var.php +++ b/libs/plugins/modifier.debug_print_var.php @@ -21,7 +21,7 @@ */ function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40) { - $_replace = array("\n"=>'\n', "\r"=>'\r', "\t"=>'\t'); + $_replace = array("\n"=>'\n', "\r"=>'\r', "\t"=>'\t'); if (is_array($var)) { $results = "Array (".count($var).")"; foreach ($var as $curr_key => $curr_val) { diff --git a/libs/plugins/modifier.escape.php b/libs/plugins/modifier.escape.php index f9d0eed9..b4979554 100644 --- a/libs/plugins/modifier.escape.php +++ b/libs/plugins/modifier.escape.php @@ -34,20 +34,20 @@ function smarty_modifier_escape($string, $esc_type = 'html') // escape unescaped single quotes return preg_replace("%(? diff --git a/libs/plugins/modifier.lower.php b/libs/plugins/modifier.lower.php index ee374233..0b4d1517 100644 --- a/libs/plugins/modifier.lower.php +++ b/libs/plugins/modifier.lower.php @@ -19,7 +19,7 @@ */ function smarty_modifier_lower($string) { - return strtolower($string); + return strtolower($string); } ?> diff --git a/libs/plugins/modifier.nl2br.php b/libs/plugins/modifier.nl2br.php index 5a9b7445..86a28d20 100644 --- a/libs/plugins/modifier.nl2br.php +++ b/libs/plugins/modifier.nl2br.php @@ -21,7 +21,7 @@ * @link http://smarty.php.net/manual/en/language.modifier.nl2br.php * nl2br (Smarty online manual) * @version 1.0 - * @author Monte Ohrt + * @author Monte Ohrt * @param string * @return string */ diff --git a/libs/plugins/modifier.strip.php b/libs/plugins/modifier.strip.php index 0db2f8ae..738c6407 100644 --- a/libs/plugins/modifier.strip.php +++ b/libs/plugins/modifier.strip.php @@ -25,7 +25,7 @@ */ function smarty_modifier_strip($text, $replace = ' ') { - return preg_replace('!\s+!', $replace, $text); + return preg_replace('!\s+!', $replace, $text); } /* vim: set expandtab: */ diff --git a/libs/plugins/modifier.upper.php b/libs/plugins/modifier.upper.php index 9d9ef356..69960ae7 100644 --- a/libs/plugins/modifier.upper.php +++ b/libs/plugins/modifier.upper.php @@ -19,7 +19,7 @@ */ function smarty_modifier_upper($string) { - return strtoupper($string); + return strtoupper($string); } ?> diff --git a/libs/plugins/modifier.wordwrap.php b/libs/plugins/modifier.wordwrap.php index 55b4a1df..b9a9fe94 100644 --- a/libs/plugins/modifier.wordwrap.php +++ b/libs/plugins/modifier.wordwrap.php @@ -22,7 +22,7 @@ */ function smarty_modifier_wordwrap($string,$length=80,$break="\n",$cut=false) { - return wordwrap($string,$length,$break,$cut); + return wordwrap($string,$length,$break,$cut); } ?> diff --git a/libs/plugins/outputfilter.trimwhitespace.php b/libs/plugins/outputfilter.trimwhitespace.php index e82acc1c..9979e858 100644 --- a/libs/plugins/outputfilter.trimwhitespace.php +++ b/libs/plugins/outputfilter.trimwhitespace.php @@ -16,7 +16,7 @@ * template source after it gets interpreted, cleaning * up code and saving bandwidth. Does not affect * <
>
and blocks.
- * Install: Drop into the plugin directory, call + * Install: Drop into the plugin directory, call * $smarty->load_filter('output','trimwhitespace'); * from application. * @author Monte Ohrt @@ -25,51 +25,51 @@ * @param string * @param Smarty */ - function smarty_outputfilter_trimwhitespace($source, &$smarty) - { +function smarty_outputfilter_trimwhitespace($source, &$smarty) +{ // Pull out the script blocks preg_match_all("!]+>.*?!is", $source, $match); $_script_blocks = $match[0]; $source = preg_replace("!]+>.*?!is", - '@@@SMARTY:TRIM:SCRIPT@@@', $source); + '@@@SMARTY:TRIM:SCRIPT@@@', $source); // Pull out the pre blocks preg_match_all("!
.*?
!is", $source, $match); $_pre_blocks = $match[0]; $source = preg_replace("!
.*?
!is", - '@@@SMARTY:TRIM:PRE@@@', $source); + '@@@SMARTY:TRIM:PRE@@@', $source); // Pull out the textarea blocks preg_match_all("!]+>.*?!is", $source, $match); $_textarea_blocks = $match[0]; $source = preg_replace("!]+>.*?!is", - '@@@SMARTY:TRIM:TEXTAREA@@@', $source); + '@@@SMARTY:TRIM:TEXTAREA@@@', $source); - // remove all leading spaces, tabs and carriage returns NOT - // preceeded by a php close tag. - $source = trim(preg_replace('/((?)\n)[\s]+/m', '\1', $source)); + // remove all leading spaces, tabs and carriage returns NOT + // preceeded by a php close tag. + $source = trim(preg_replace('/((?)\n)[\s]+/m', '\1', $source)); - // replace script blocks - smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:SCRIPT@@@",$_script_blocks, $source); + // replace script blocks + smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:SCRIPT@@@",$_script_blocks, $source); - // replace pre blocks - smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:PRE@@@",$_pre_blocks, $source); + // replace pre blocks + smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:PRE@@@",$_pre_blocks, $source); // replace textarea blocks - smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:TEXTAREA@@@",$_textarea_blocks, $source); + smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:TEXTAREA@@@",$_textarea_blocks, $source); - return $source; - } + return $source; +} function smarty_outputfilter_trimwhitespace_replace($search_str, $replace, &$subject) { - $_len = strlen($search_str); - $_pos = 0; - for ($_i=0, $_count=count($replace); $_i<$_count; $_i++) - if (($_pos=strpos($subject, $search_str, $_pos))!==false) - $subject = substr_replace($subject, $replace[$_i], $_pos, $_len); - else - break; - + $_len = strlen($search_str); + $_pos = 0; + for ($_i=0, $_count=count($replace); $_i<$_count; $_i++) + if (($_pos=strpos($subject, $search_str, $_pos))!==false) + $subject = substr_replace($subject, $replace[$_i], $_pos, $_len); + else + break; + } ?> diff --git a/libs/plugins/shared.escape_special_chars.php b/libs/plugins/shared.escape_special_chars.php index 090ee9cd..515763ab 100644 --- a/libs/plugins/shared.escape_special_chars.php +++ b/libs/plugins/shared.escape_special_chars.php @@ -17,12 +17,12 @@ */ function smarty_function_escape_special_chars($string) { - if(!is_array($string)) { - $string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string); - $string = htmlspecialchars($string); - $string = str_replace(array('%%%SMARTY_START%%%','%%%SMARTY_END%%%'), array('&',';'), $string); - } - return $string; + if(!is_array($string)) { + $string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string); + $string = htmlspecialchars($string); + $string = str_replace(array('%%%SMARTY_START%%%','%%%SMARTY_END%%%'), array('&',';'), $string); + } + return $string; } /* vim: set expandtab: */