0) { foreach ($vars as $key=>$value) { $param[] = $key.'='.urlencode($value); } $pars = '?' . implode('&', $param); } else { $pars = ''; } if ($name != '') { Header('Location: '.$ns->config->baseurl.'/'.$name . $pars); } elseif (isset ($GLOBALS['followup_to'])) { Header('Location: '.$GLOBALS['followup_to'] . $pars); } elseif (isset ($GLOBALS['HTTP_REFERER'])) { Header('Location: '.$GLOBALS['HTTP_REFERER'] . $pars); } else { error('Fehler: Weiss nicht mehr wohin jetzt.'); }; } function param_check(&$parameters, &$new_check_fields, $optionals=array()) { $check_parameters = array(); $params_required = isset($optionals['params_required']) ? $optionals['params_required']: true; $form_id = isset($optionals['form_id']) ? $optionals['form_id'] : $parameters['form_id']; if ( ! isset($form_id) ) if ( $params_required ) error('Formular ID: not set'); else { $form_id='default'; } if ( $form_id == 'default' && ! isset($new_check_fields[$form_id]) ) return $check_parameters; if ( ! isset($new_check_fields[$form_id]) ) error("Formular ID: is set ('$form_id') but no ruleset defined"); assert($form_id !== false ); assert($new_check_fields[$form_id] !== false); $check_fields = $new_check_fields[$form_id]; foreach( $check_fields as $field_name => $field ) { if ( !isset($parameters[$field_name]) && $field['type'] != 'boolean' ) { if (!$field['optional'] ) error('Parameter '.$field_name.' not found'); } else { if ( isset($field['length']) && strlen($parameters[$field_name])>$field['length'] ) error('Parameter '.$field_name.' to long'); unset($result); switch ($field['type']) { case 'integer': if (!(is_numeric($parameters[$field_name]) && is_int($parameters[$field_name] + 0))) error($field_name . ' is not an Integer'); $result=$parameters[$field_name] + 0; break; case 'decimal': if (! isset($field['scale']) ) $field['scale'] = 0; assert(isset($field['precision'])); assert(isset($field['scale'])); $vorkomma = '[0-9]{0,'.($field['precision'] - $field['scale']).'}'; $nachkomma = '[0-9]{0,'.($field['scale']).'}'; $regex = $vorkomma . '(\.'.$nachkomma.')?'; $matches = preg_match('/^'.$regex.'$/', $parameters[$field_name]); if (! $matches) error($field_name . " is not Decimal (matching $regex)"); $result=$parameters[$field_name]; if ($result === '') $result = 0; break; case 'string': if (!is_string($parameters[$field_name])) error($field_name . ' is not a String'); $result=trim($parameters[$field_name]); break; case 'boolean': if ($parameters[$field_name]) $result=true; else $result=false; break; case 'anything': $result=$parameters[$field_name]; break; default: error('unkown Type '.$field['type'].' in Ruleset '.$form_id.' for field '.$field_name); } assert(isset($result)); if ( isset( $field['modifier'] ) ) if ( is_array($field['modifier']) ) foreach ($field['modifier'] as $modifier) { assert(is_callable($modifier)); $result = $modifier($result); } else { assert(is_callable($field['modifier'])); $result = $field['modifier']($result); } if (! $field['discard']) $check_parameters[$field_name] = $result; } } $check_parameters['form_id']=$form_id; return $check_parameters; } function print_array(&$fields, $die = 0) { echo "
";
	print_r($fields);
	echo "XXXXXXXXXXXX
"; if ($die) exit; } # vim:set ts=4: # vim:set syntax=php: # vim:set shiftwidth=4: ?>