-
Notifications
You must be signed in to change notification settings - Fork 0
/
validate_options.php
47 lines (40 loc) · 1.01 KB
/
validate_options.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
//////////////////////////////////////////////
// Validate options passed to API
//
// Note that if multiple errors detected, only
// the last gets reported
//////////////////////////////////////////////
// Sources
// NOT YET USED
if (array_key_exists('sources', $opt_arr)) {
$sources = $opt_arr['sources'];
if ( trim($sources) == "" ) {
$sources = $NSR_DEF_SOURCES;
} else {
$src_arr = explode(",",$sources);
$valid = count(array_intersect($src_arr, $NSR_SOURCES)) == count($src_arr);
if ( $valid === false ) {
$err_msg="ERROR: Invalid option '$sources' for 'sources'\r\n";
$err_code=400; $err=true;
}
}
} else {
$sources = $NSR_DEF_SOURCES;
}
// Processing mode
if (array_key_exists('mode', $opt_arr)) {
$mode = $opt_arr['mode'];
if ( trim($mode) == "" ) {
$mode = $NSR_DEF_MODE;
} else {
$valid = in_array($mode, $NSR_MODES);
if ( $valid === false ) {
$err_msg="ERROR: Invalid option '$mode' for 'mode'\r\n";
$err_code=400; $err=true;
}
}
} else {
$mode = $NSR_DEF_MODE;
}
?>