diff options
author | Pim van den Berg | 2010-01-01 19:36:31 +0100 |
---|---|---|
committer | Pim van den Berg | 2010-01-01 19:36:31 +0100 |
commit | bc31ed0e4647a568a1596cc2e09664675479a70d (patch) | |
tree | 9670e334534e18a9588e18d3feabbcb3a67e734e /inc/functions.inc.php | |
parent | add swap_io support (diff) | |
download | apt-panopticon_cgp-bc31ed0e4647a568a1596cc2e09664675479a70d.zip apt-panopticon_cgp-bc31ed0e4647a568a1596cc2e09664675479a70d.tar.gz apt-panopticon_cgp-bc31ed0e4647a568a1596cc2e09664675479a70d.tar.bz2 apt-panopticon_cgp-bc31ed0e4647a568a1596cc2e09664675479a70d.tar.xz |
better validation of possible user input (get)
Diffstat (limited to '')
-rw-r--r-- | inc/functions.inc.php | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/inc/functions.inc.php b/inc/functions.inc.php new file mode 100644 index 0000000..2906530 --- /dev/null +++ b/inc/functions.inc.php | |||
@@ -0,0 +1,27 @@ | |||
1 | <?php | ||
2 | |||
3 | # global functions | ||
4 | |||
5 | function validate_get($value, $type) { | ||
6 | switch($type) { | ||
7 | case 'host': | ||
8 | if (!preg_match('/^[\d\w\W]+$/', $value)) | ||
9 | return NULL; | ||
10 | break; | ||
11 | case 'plugin': | ||
12 | case 'type': | ||
13 | if (!preg_match('/^\w+$/', $value)) | ||
14 | return NULL; | ||
15 | break; | ||
16 | case 'pinstance': | ||
17 | case 'tinstance': | ||
18 | if (!preg_match('/^[\d\w-]+$/', $value)) | ||
19 | return NULL; | ||
20 | break; | ||
21 | } | ||
22 | |||
23 | return $value; | ||
24 | } | ||
25 | |||
26 | |||
27 | ?> | ||