1: <?php
2: 3: 4: 5: 6: 7: 8: 9:
10:
11: 12: 13: 14: 15: 16:
17: class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_CompileBase
18: {
19: 20: 21: 22: 23: 24: 25: 26: 27:
28: public function compile($args, $compiler, $parameter)
29: {
30: $_index = preg_split("/\]\[/", substr($parameter, 1, strlen($parameter) - 2));
31: $compiled_ref = ' ';
32: $variable = trim($_index[0], "'");
33: switch ($variable) {
34: case 'foreach':
35: return "\$_smarty_tpl->getVariable('smarty')->value$parameter";
36: case 'section':
37: return "\$_smarty_tpl->getVariable('smarty')->value$parameter";
38: case 'capture':
39: return "Smarty::\$_smarty_vars$parameter";
40: case 'now':
41: return 'time()';
42: case 'cookies':
43: if (isset($compiler->smarty->security_policy) && !$compiler->smarty->security_policy->allow_super_globals) {
44: $compiler->trigger_template_error("(secure mode) super globals not permitted");
45: break;
46: }
47: $compiled_ref = '$_COOKIE';
48: break;
49:
50: case 'get':
51: case 'post':
52: case 'env':
53: case 'server':
54: case 'session':
55: case 'request':
56: if (isset($compiler->smarty->security_policy) && !$compiler->smarty->security_policy->allow_super_globals) {
57: $compiler->trigger_template_error("(secure mode) super globals not permitted");
58: break;
59: }
60: $compiled_ref = '$_' . strtoupper($variable);
61: break;
62:
63: case 'template':
64: return 'basename($_smarty_tpl->source->filepath)';
65:
66: case 'template_object':
67: return '$_smarty_tpl';
68:
69: case 'current_dir':
70: return 'dirname($_smarty_tpl->source->filepath)';
71:
72: case 'version':
73: $_version = Smarty::SMARTY_VERSION;
74:
75: return "'$_version'";
76:
77: case 'const':
78: if (isset($compiler->smarty->security_policy) && !$compiler->smarty->security_policy->allow_constants) {
79: $compiler->trigger_template_error("(secure mode) constants not permitted");
80: break;
81: }
82:
83: return "@constant({$_index[1]})";
84:
85: case 'config':
86: if (isset($_index[2])) {
87: return "(is_array(\$tmp = \$_smarty_tpl->getConfigVariable($_index[1])) ? \$tmp[$_index[2]] : null)";
88: } else {
89: return "\$_smarty_tpl->getConfigVariable($_index[1])";
90: }
91: case 'ldelim':
92: $_ldelim = $compiler->smarty->left_delimiter;
93:
94: return "'$_ldelim'";
95:
96: case 'rdelim':
97: $_rdelim = $compiler->smarty->right_delimiter;
98:
99: return "'$_rdelim'";
100:
101: default:
102: $compiler->trigger_template_error('$smarty.' . trim($_index[0], "'") . ' is invalid');
103: break;
104: }
105: if (isset($_index[1])) {
106: array_shift($_index);
107: foreach ($_index as $_ind) {
108: $compiled_ref = $compiled_ref . "[$_ind]";
109: }
110: }
111:
112: return $compiled_ref;
113: }
114: }
115: