@Ghazascanner
_2019runbot
Ghazascanner File Manager
server :Linux phosweb007 3.10.0-1160.el7.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 x86_64
Current Path :
/
homepage
/
v-mt
/
php
/
lib
/
Path :
Upload File :
New :
File
Dir
//homepage/v-mt/php/lib/compiler.defun.php
<?php # Movable Type (r) (C) 2001-2008 Six Apart, Ltd. All Rights Reserved. # This code cannot be redistributed without permission from www.sixapart.com. # For more information, consult your Movable Type license. # # $Id: compiler.defun.php 1174 2008-01-08 21:02:50Z bchoate $ /* create code for a function call */ function smarty_compiler_fun($tag_args, &$compiler) { $_attrs = $compiler->_parse_attrs($tag_args); if (!isset($_attrs['name'])) $compiler->_syntax_error("fun: missing name parameter"); $_func_name = $compiler->_dequote($_attrs['name']); $_func = 'smarty_fun_'.$_func_name; $_params = 'array('; $_sep = ''; unset($_attrs['name']); foreach ($_attrs as $_key=>$_value) { $_params .= "$_sep'$_key'=>$_value"; $_sep = ','; } $_params .= ')'; return "$_func(\$this, $_params);"; } $this->register_compiler_function('fun', 'smarty_compiler_fun'); /* create code for a function declaration */ function smarty_compiler_defun($tag_args, &$compiler) { $attrs = $compiler->_parse_attrs($tag_args); $func_key = '"' . md5('php-5') . '[[' . md5(uniqid('sucks')) . '";'; array_push($compiler->_tag_stack, array('defun', $attrs, $tag_args, $func_key)); if (!isset($attrs['name'])) $compiler->_syntax_error("defun: missing name parameter"); $func_name = $compiler->_dequote($attrs['name']); $func = 'smarty_fun_'.$func_name; return $func_key . "if (!function_exists('$func')) { function $func(&\$this, \$params) { \$_fun_tpl_vars = \$this->_tpl_vars; \$this->assign(\$params);"; } /* create code for closing a function definition and calling said function */ function smarty_compiler_defun_close($tag_args, &$compiler) { list($name, $attrs, $open_tag_args, $func_key) = array_pop($compiler->_tag_stack); if ($name!='defun') $compiler->_syntax_error("unexpected {/defun}"); return " \$this->_tpl_vars = \$_fun_tpl_vars; }} " . $func_key . smarty_compiler_fun($open_tag_args, $compiler); } $this->register_compiler_function('/defun', 'smarty_compiler_defun_close'); /* callback: replace all $this with $smarty */ function smarty_replace_fun($match) { $tokens = token_get_all('<?php ' . $match[2]); for ($i=0, $count=count($tokens); $i<$count; $i++) { if (is_array($tokens[$i])) { if ($tokens[$i][0] == T_VARIABLE && $tokens[$i][1] == '$this') { $tokens[$i] = '$smarty'; } else { $tokens[$i] = $tokens[$i][1]; } } } $result = implode('', $tokens); $result = preg_replace('/^<\?php/', '', $result); return $result; } /* postfilter to squeeze the code to make php5 happy */ function smarty_postfilter_defun($source, &$compiler) { $search = '("' . md5('php-5') . '\[\[[0-9a-f]{32}";)'; if ((double)phpversion()>=5.0) { /* filter sourcecode. look for func_keys and replace all $this in-between with $smarty */ while (1) { $new_source = preg_replace_callback('/' . $search . '(.*)\\1/Us', 'smarty_replace_fun', $source); if (strcmp($new_source, $source)==0) break; $source = $new_source; } } else { /* remove func_keys */ $source = preg_replace('/' . $search . '/', '', $source); } return $source; } $this->register_postfilter('smarty_postfilter_defun'); ?>