/** * Deze functie is om input van formulieren te controleren. * * Indien er een error optreed, wordt deze in $error gezet * * @return mixed De gevalideerde waarde **/ function validate_var($arr_submit, $bln_keep_post_values = false) { global $error; $str_empty_fields = ''; $array = $_REQUEST; $arr_values = array(); foreach ($arr_submit as $key => $value) { $val_value = ''; $str_fieldname = $value[0]; if (isset($_REQUEST[$value[0]])) { $var_to_check = $_REQUEST[$value[0]]; if (!$bln_keep_post_values) { unset($_REQUEST[$value[0]]); } } $str_type = $value[1]; $bln_required = $value[2]; $default = !empty($value[3]) || $value[3] === 0 ? $value[3] : ''; if (strstr($default, 'substr')) { $f = String::getSubstring($default, '(', '', ',', ''); $n = String::findNumberInString($default, true); $s = String::getSubstring($n, ',', '', ',', ''); $e = String::getPartAfterLastGivenChar($n, ','); $default = substr($array['message'], $s, $e); } if (!empty($var_to_check)) { //Controleer type $val_value = checkvar($str_fieldname, $var_to_check, $str_type, $default); $arr_values[$str_fieldname] = $val_value; } else { if ($bln_required == true) { //required, but not filled in if (!empty($str_empty_fields)) { $str_empty_fields .= ' , ' . $str_fieldname; } else { $str_empty_fields .= $str_fieldname; } $error = 'These are required fields: `' . $str_empty_fields . '` '; } else { if ($bln_required == false) { $arr_values[$str_fieldname] = $default; } } } $val_value = ''; $default = ''; $var_to_check = ''; } return $arr_values; }
/** * Deze functie is om input van formulieren te controleren. * * Indien er een error optreed, wordt deze in $error gezet * * @return mixed De gevalideerde waarde **/ function validate_var($arr_submit) { global $error; $str_empty_fields = ''; $arr_values = array(); $array = $_REQUEST; foreach ($arr_submit as $key => $value) { $val_value = ''; $var_to_check = ''; $str_fieldname = $value[0]; if (isset($_REQUEST[$value[0]])) { $var_to_check = $_REQUEST[$value[0]]; unset($_REQUEST[$value[0]]); } $str_type = $value[1]; $bln_required = $value[2]; $default = !empty($value[3]) ? $value[3] : ''; if (!empty($var_to_check)) { //Controleer type $val_value = checkvar($str_fieldname, $var_to_check, $str_type, $default); $arr_values[$str_fieldname] = $val_value; } else { if ($bln_required == true) { //required, but not filled in if (!empty($str_empty_fields)) { $str_empty_fields .= ' , ' . $str_fieldname; } else { $str_empty_fields .= $str_fieldname; } $error = 'These are required fields: `' . $str_empty_fields . '` '; } else { if ($bln_required == false) { $arr_values[$str_fieldname] = $default; } } } $val_value = ''; $default = ''; $var_to_check = ''; } //print_r($arr_values); return $arr_values; }
<?php $type = checkvar("type"); $key = checkvar("key"); $unique = $type . "_" . $key; $val = apc_fetch($unique); if (empty($val)) { $url = "valstore.nuqe.net/get?key=" . $key . "&type=" . $type; $ch = curl_init($url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $val = curl_exec($ch); curl_close($ch); apc_store($unique, $val, 20); } echo $val; function checkvar($varname) { if (!isset($_REQUEST[$varname])) { exit; } if (empty($_REQUEST[$varname])) { exit; } if (!ctype_alnum($_REQUEST[$varname])) { exit; } return $_REQUEST[$varname]; }
if ($_POST[$varName."_".$multi_count]<>"") { $_POST[$varName]=$_POST[$varName."_".$multi_count]; }; if ($msg=="") { $msg=checkvar ($varName,$lfaction_type,$lfaction_reg,$lfaction_mt,$msg,$_POST,$lfaction_set); // Check mail var if ($lfaction_type[$varName]=="mail") { $email=$lfaction_mail[$varName]; }; }; $multi_count++; }; } else { if ($msg=="") { $msg=checkvar ($varName,$lfaction_type,$lfaction_reg,$lfaction_mt,$msg,$_POST,$lfaction_set); if ($lfaction_type[$varName]=="mail") { $email=$lfaction_mail[$varName]; }; }; }; //if ($lfaction_multi[$varName] if ($_POST['lfupdate']=="yes") { // if ($lfaction_set['allow_update'] == "yes") { // If in update mode include $table_file[$lfaction_set['table']]; // include table file } }; // Check mail var if ($lfaction_type[$varName]=="mail") {