-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidation.php
More file actions
87 lines (85 loc) · 2.78 KB
/
Copy pathvalidation.php
File metadata and controls
87 lines (85 loc) · 2.78 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
$errMsg = "";
function checkExistence() {
global $errMsg;
if (!array_key_exists("age", $_POST)) {
$errMsg = "Age value does not exist";
return false;
}
if (!array_key_exists("wbc", $_POST)) {
$errMsg = "WBC value does not exist";
return false;
}
if (!array_key_exists("nlr", $_POST)) {
$errMsg = "NLR value does not exist";
return false;
}
if (!array_key_exists("ast", $_POST)) {
$errMsg = "AST value does not exist";
return false;
}
if (!array_key_exists("albumin", $_POST)) {
$errMsg = "Albumin value does not exist";
return false;
}
if (!array_key_exists("ldh", $_POST)) {
$errMsg = "LDH value does not exist";
return false;
}
if (!array_key_exists("crp", $_POST)) {
$errMsg = "CRP value does not exist";
return false;
}
if (!array_key_exists("model_id", $_POST)) {
$errMsg = "Regression model does not exist";
return false;
}
return true;
}
function checkRanges() {
global $errMsg;
if(!is_numeric($_POST["age"]) or intval($_POST["age"])<1) {
$errMsg = "Invalid Age value";
return false;
}
if(!is_numeric($_POST["wbc"]) or floatval($_POST["wbc"])<0) {
$errMsg = "Invalid WBC value";
return false;
}
if(!is_numeric($_POST["nlr"]) or floatval($_POST["nlr"])<0) {
$errMsg = "Invalid NLR value";
return false;
}
if(!is_numeric($_POST["ast"]) or floatval($_POST["ast"])<0) {
$errMsg = "Invalid AST value";
return false;
}
if(!is_numeric($_POST["albumin"]) or floatval($_POST["albumin"])<0) {
$errMsg = "Invalid Albumin value";
return false;
}
if(!is_numeric($_POST["ldh"]) or floatval($_POST["ldh"])<0) {
$errMsg = "Invalid LDH value";
return false;
}
if(!is_numeric($_POST["crp"]) or floatval($_POST["crp"])<0) {
$errMsg = "Invalid CRP value";
return false;
}
// echo "<p>".$_POST["model_id"]."</p>";
// echo strcmp($_POST["model_id"], "SVR");
// echo strcmp($_POST["model_id"], "SVR");
if(strcmp($_POST["model_id"], "SVR") != 0 and strcmp($_POST["model_id"], "MLPR") != 0) {
$errMsg = "Invalid model selected";
return false;
}
return true;
}
function validateInput() {
if(!checkExistence())
return false;
if(!checkRanges())
return false;
return true;
}
?>