Server IP : 103.119.228.120 / Your IP : 18.216.99.18 Web Server : Apache System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : nobody ( 99) PHP Version : 5.6.40 Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/hendraso/public_html/Additional/smarty3/sysplugins/ |
Upload File : |
<?php /** * Smarty Internal Plugin Compile Foreach * * Compiles the {foreach} {foreachelse} {/foreach} tags * * @package Smarty * @subpackage Compiler * @author Uwe Tews */ /** * Smarty Internal Plugin Compile Foreach Class * * @package Smarty * @subpackage Compiler */ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_CompileBase { /** * Attribute definition: Overwrites base class. * * @var array * @see Smarty_Internal_CompileBase */ public $required_attributes = array('from', 'item'); /** * Attribute definition: Overwrites base class. * * @var array * @see Smarty_Internal_CompileBase */ public $optional_attributes = array('name', 'key'); /** * Attribute definition: Overwrites base class. * * @var array * @see Smarty_Internal_CompileBase */ public $shorttag_order = array('from','item','key','name'); /** * Compiles code for the {foreach} tag * * @param array $args array with attributes from parser * @param object $compiler compiler object * @param array $parameter array with compilation parameter * @return string compiled code */ public function compile($args, $compiler, $parameter) { // check and get attributes $_attr = $this->getAttributes($compiler, $args); $from = $_attr['from']; $item = $_attr['item']; if (!strncmp("\$_smarty_tpl->tpl_vars[$item]", $from, strlen($item) + 24)) { $compiler->trigger_template_error("item variable {$item} may not be the same variable as at 'from'", $compiler->lex->taglineno); } if (isset($_attr['key'])) { $key = $_attr['key']; } else { $key = null; } $this->openTag($compiler, 'foreach', array('foreach', $compiler->nocache, $item, $key)); // maybe nocache because of nocache variables $compiler->nocache = $compiler->nocache | $compiler->tag_nocache; if (isset($_attr['name'])) { $name = $_attr['name']; $has_name = true; $SmartyVarName = '$smarty.foreach.' . trim($name, '\'"') . '.'; } else { $name = null; $has_name = false; } $ItemVarName = '$' . trim($item, '\'"') . '@'; // evaluates which Smarty variables and properties have to be computed if ($has_name) { $usesSmartyFirst = strpos($compiler->lex->data, $SmartyVarName . 'first') !== false; $usesSmartyLast = strpos($compiler->lex->data, $SmartyVarName . 'last') !== false; $usesSmartyIndex = strpos($compiler->lex->data, $SmartyVarName . 'index') !== false; $usesSmartyIteration = strpos($compiler->lex->data, $SmartyVarName . 'iteration') !== false; $usesSmartyShow = strpos($compiler->lex->data, $SmartyVarName . 'show') !== false; $usesSmartyTotal = strpos($compiler->lex->data, $SmartyVarName . 'total') !== false; } else { $usesSmartyFirst = false; $usesSmartyLast = false; $usesSmartyTotal = false; $usesSmartyShow = false; } $usesPropFirst = $usesSmartyFirst || strpos($compiler->lex->data, $ItemVarName . 'first') !== false; $usesPropLast = $usesSmartyLast || strpos($compiler->lex->data, $ItemVarName . 'last') !== false; $usesPropIndex = $usesPropFirst || strpos($compiler->lex->data, $ItemVarName . 'index') !== false; $usesPropIteration = $usesPropLast || strpos($compiler->lex->data, $ItemVarName . 'iteration') !== false; $usesPropShow = strpos($compiler->lex->data, $ItemVarName . 'show') !== false; $usesPropTotal = $usesSmartyTotal || $usesSmartyShow || $usesPropShow || $usesPropLast || strpos($compiler->lex->data, $ItemVarName . 'total') !== false; // generate output code $output = "<?php "; $output .= " \$_smarty_tpl->tpl_vars[$item] = new Smarty_Variable; \$_smarty_tpl->tpl_vars[$item]->_loop = false;\n"; if ($key != null) { $output .= " \$_smarty_tpl->tpl_vars[$key] = new Smarty_Variable;\n"; } $output .= " \$_from = $from; if (!is_array(\$_from) && !is_object(\$_from)) { settype(\$_from, 'array');}\n"; if ($usesPropTotal) { $output .= " \$_smarty_tpl->tpl_vars[$item]->total= \$_smarty_tpl->_count(\$_from);\n"; } if ($usesPropIteration) { $output .= " \$_smarty_tpl->tpl_vars[$item]->iteration=0;\n"; } if ($usesPropIndex) { $output .= " \$_smarty_tpl->tpl_vars[$item]->index=-1;\n"; } if ($usesPropShow) { $output .= " \$_smarty_tpl->tpl_vars[$item]->show = (\$_smarty_tpl->tpl_vars[$item]->total > 0);\n"; } if ($has_name) { if ($usesSmartyTotal) { $output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['total'] = \$_smarty_tpl->tpl_vars[$item]->total;\n"; } if ($usesSmartyIteration) { $output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['iteration']=0;\n"; } if ($usesSmartyIndex) { $output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['index']=-1;\n"; } if ($usesSmartyShow) { $output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['show']=(\$_smarty_tpl->tpl_vars[$item]->total > 0);\n"; } } $output .= "foreach (\$_from as \$_smarty_tpl->tpl_vars[$item]->key => \$_smarty_tpl->tpl_vars[$item]->value) {\n\$_smarty_tpl->tpl_vars[$item]->_loop = true;\n"; if ($key != null) { $output .= " \$_smarty_tpl->tpl_vars[$key]->value = \$_smarty_tpl->tpl_vars[$item]->key;\n"; } if ($usesPropIteration) { $output .= " \$_smarty_tpl->tpl_vars[$item]->iteration++;\n"; } if ($usesPropIndex) { $output .= " \$_smarty_tpl->tpl_vars[$item]->index++;\n"; } if ($usesPropFirst) { $output .= " \$_smarty_tpl->tpl_vars[$item]->first = \$_smarty_tpl->tpl_vars[$item]->index === 0;\n"; } if ($usesPropLast) { $output .= " \$_smarty_tpl->tpl_vars[$item]->last = \$_smarty_tpl->tpl_vars[$item]->iteration === \$_smarty_tpl->tpl_vars[$item]->total;\n"; } if ($has_name) { if ($usesSmartyFirst) { $output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['first'] = \$_smarty_tpl->tpl_vars[$item]->first;\n"; } if ($usesSmartyIteration) { $output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['iteration']++;\n"; } if ($usesSmartyIndex) { $output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['index']++;\n"; } if ($usesSmartyLast) { $output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['last'] = \$_smarty_tpl->tpl_vars[$item]->last;\n"; } } $output .= "?>"; return $output; } } /** * Smarty Internal Plugin Compile Foreachelse Class * * @package Smarty * @subpackage Compiler */ class Smarty_Internal_Compile_Foreachelse extends Smarty_Internal_CompileBase { /** * Compiles code for the {foreachelse} tag * * @param array $args array with attributes from parser * @param object $compiler compiler object * @param array $parameter array with compilation parameter * @return string compiled code */ public function compile($args, $compiler, $parameter) { // check and get attributes $_attr = $this->getAttributes($compiler, $args); list($openTag, $nocache, $item, $key) = $this->closeTag($compiler, array('foreach')); $this->openTag($compiler, 'foreachelse', array('foreachelse', $nocache, $item, $key)); return "<?php }\nif (!\$_smarty_tpl->tpl_vars[$item]->_loop) {\n?>"; } } /** * Smarty Internal Plugin Compile Foreachclose Class * * @package Smarty * @subpackage Compiler */ class Smarty_Internal_Compile_Foreachclose extends Smarty_Internal_CompileBase { /** * Compiles code for the {/foreach} tag * * @param array $args array with attributes from parser * @param object $compiler compiler object * @param array $parameter array with compilation parameter * @return string compiled code */ public function compile($args, $compiler, $parameter) { // check and get attributes $_attr = $this->getAttributes($compiler, $args); // must endblock be nocache? if ($compiler->nocache) { $compiler->tag_nocache = true; } list($openTag, $compiler->nocache, $item, $key) = $this->closeTag($compiler, array('foreach', 'foreachelse')); return "<?php } ?>"; } }