1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
<?php
function smarty_function_load_env_array($params, &$smarty)
{
$t_source = strtoupper($params['source']);
$_text_array_name = 'ENV_DATA';
if(isset($params['name'])) $_text_array_name = $params['name'];
$t_exclude_list = $params['exclude'];
$t_data_array = array();
switch($t_source) {
case 'GET': $t_data_array = $_GET; break;
case 'POST': $t_data_array = $_POST; break;
}
$t_exclude_array = explode(',', $t_exclude_list);
for($i=0; $i<sizeof($t_exclude_array); $i++)
{
unset($t_data_array[$t_exclude_array[$i]]);
}
$t_output_array = array();
foreach($t_data_array as $t_key => $t_value)
{
$c_key = htmlentities_wrapper($t_key);
if(is_array($t_value)) {
$c_value = '';
} else {
$c_value = htmlentities_wrapper($t_value);
}
$t_output_array[$c_key] = $c_value;
}
$smarty->assign($_text_array_name, $t_output_array);
}
?>