} # # The value has to be plain text, but thats about it. We will escape # it before passing off to mysql in a query. # if (!TBvalid_userdata($value)) { $errors["Value {$which}"] = TBFieldErrorString(); } } FormValidate($form, $errors, $fields, $formfields); # Check the save search stuff; easier then trying to automate it since # I need to figure out how to automate correlated checks. if (isset($formfields['savesearch']) && $formfields['savesearch']) { if (!isset($formfields['savename']) || $formfields['savename'] == "") { $errors['Save Name'] = "Must provide a search save name"; } elseif (!TBcheck_dbslot($formfields['savename'], "experiment_template_searches", "name", TBDB_CHECKDBSLOT_WARN | TBDB_CHECKDBSLOT_ERROR)) { $errors['Save Name'] = TBFieldErrorString(); } } # # If any errors, respit the form with the current values and the # error messages displayed. Iterate until happy. # if (count($errors)) { SPITFORM($formfields, $errors); PAGEFOOTER(); return; } # # Build up the match clauses first. #
$newtime = $formfields[$time_name]; if (!TBvalid_float($newtime)) { $errors["{$vname} time"] = TBFieldErrorString(); } elseif ($newtime < 0) { $errors["{$vname} time"] = "Cannot be less then zero"; } else { if (!isset($changes[$vname])) { $changes[$vname] = array(); } $changes[$vname]["time"] = $newtime; } } # Modify the arguments if (isset($formfields[$args_name]) && $formfields[$args_name] != "{$args}") { $newargs = $formfields[$args_name]; if (!TBcheck_dbslot($newargs, 'eventlist', 'arguments', TBDB_CHECKDBSLOT_WARN | TBDB_CHECKDBSLOT_ERROR)) { $errors["{$vname} time"] = TBFieldErrorString(); } else { if (!isset($changes[$vname])) { $changes[$vname] = array(); } $changes[$vname]["arguments"] = $newargs; } } } if (count($errors)) { SPITFORM($template, $formfields, $errors); PAGEFOOTER(); exit(1); } #
function FormValidateElement($name, &$errors, $attributes, &$submitted, $parent_label) { $error_label = CombineLabels($parent_label, $attributes); # Check for required fields not filled out if (isset($attributes['#prep']) && isset($submitted[$name]) && $submitted[$name] != "") { $submitted[$name] = $attributes['#prep']($submitted[$name]); } if (isset($attributes['#required']) && $attributes['#required'] && !(isset($submitted[$name]) && $submitted[$name] != "")) { $errors[$error_label] = "Missing required value"; } elseif (isset($attributes['#checkslot']) && isset($submitted[$name]) && $submitted[$name] != "") { $check = $attributes['#checkslot']; if (function_exists($check)) { $check($name, $errors, $attributes, $submitted[$name]); } elseif (preg_match("/^([-\\w]+):([-\\w]+)\$/", $check, $matches)) { # # What if not required and not set? # if (!isset($submitted[$name]) || $submitted[$name] == "") { $submitted[$name] = ""; } if (!TBcheck_dbslot($submitted[$name], $matches[1], $matches[2], TBDB_CHECKDBSLOT_WARN | TBDB_CHECKDBSLOT_ERROR)) { $errors[$error_label] = TBFieldErrorString(); } } elseif (substr($check, 0, 1) == "/") { # Regular expression. if (!preg_match($check, $submitted[$name])) { $errors[$error_label] = "Illegal characters"; } } else { TBERROR("Could not parse checkslot: {$check}", 1); } } }
function TBvalid_experiment_run_description($token) { return TBcheck_dbslot($token, "experiment_runs", "description", TBDB_CHECKDBSLOT_WARN | TBDB_CHECKDBSLOT_ERROR); }