diff options
| author | ziejd2 | 2018-09-13 23:59:20 -0500 |
|---|---|---|
| committer | ziejd2 | 2018-09-13 23:59:20 -0500 |
| commit | e3f7237ffcb19f19db3b68777b5a94b89e07f66a (patch) | |
| tree | 554a8013776ebeae3e2976074020c09c2d1af8b0 /sourcecodes/input_validate.php | |
| parent | a7eb61ff7a09f39bee67014bf24b8919eaccfc19 (diff) | |
| download | BNW-e3f7237ffcb19f19db3b68777b5a94b89e07f66a.tar.gz | |
New parameter learning options
The main change here is in the parameter learning methods. The parameters that are learned at first (i.e., if there is no evidence) are the distributions that are found directly in the data. I had to create or significantly modify several BNT files for this. If there is evidence, the parameters are learned using a Dirichlet prior. This only required a couple of small changes to the BNW parameter learning files.
Diffstat (limited to 'sourcecodes/input_validate.php')
| -rw-r--r-- | sourcecodes/input_validate.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/sourcecodes/input_validate.php b/sourcecodes/input_validate.php new file mode 100644 index 00000000..7c9dbe60 --- /dev/null +++ b/sourcecodes/input_validate.php @@ -0,0 +1,30 @@ +<?php +//This file will contain input validation functions. + +function valid_keyval($keyval) +{ + $keyval = trim($keyval); + $keyval = stripslashes($keyval); + $keyval = htmlspecialchars($keyval); + //check if keyval contains only uppercase or lowercase letters. + if (!preg_match('/^[a-zA-Z]+$/',$keyval)) { + header("Location: keyval_error.php"); + } + if (strlen($keyval)!=3) { + header("Location: keyval_error.php"); + } + return $keyval; +} + + +function valid_input($input) +{ + $input = trim($input); + $input = stripslashes($input); + $input = htmlspecialchars($input); + //check if keyval contains only letters, numbers, hyphens, underscore, periods, or whitespace. + if (!preg_match('/^[-A-Za-z\d\ \t\r\n_\.]+$/',$input)) { + header("Location: input_error.php"); + } + return $input; +} |
