forked from bestbug456/tinnitushunt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
handler.php
84 lines (71 loc) · 2.15 KB
/
handler.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
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
<?php
if (is_ajax()) {
if (isset($_POST["action"]) && !empty($_POST["action"])) { //Checks if action value exists
$action = $_POST["action"];
switch($action) { //Switch case for value of action
case "insert": addNewAcufene(); break;
case "getData": getInfoForm(); break;
case "getTotal": getTotal();break;
case "getListOfZips": getZips();break;
}
}
}
//Function to check if the request is an AJAX request
function is_ajax() {
return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
}
function addNewAcufene(){
include_once dirname(__FILE__).'/database/handlerDb.php';
if(addData(array($_POST['id'],$_POST['email'],$_POST['indirizzo'],$_POST['contatto'])))
$return["status"] = "ok";
else{
$return["status"] = "error";
$return['errorInfo'] = $GLOBALS['errorSql'];
}
$return["json"] = json_encode($return);
echo json_encode($return);
}
function getInfoForm(){
include_once dirname(__FILE__).'/database/handlerDb.php';
$id = $_POST['id'];
$info = getData($id);
if($GLOBALS['dataUser'] == NULL & $info == true){
$return["status"] = "ok";
$return['info'] = "NOT_EXIST";
}elseif($info == false){
$return["status"] = "error";
$return['errorInfo'] = $GLOBALS['errorSql'];
}else{
$return['status'] = "ok";
$return['dataUser'] = $GLOBALS['dataUser'];
}
$return["json"] = json_encode($return);
echo json_encode($return);
}
function getTotal(){
include_once dirname(__FILE__).'/database/handlerDb.php';
$info = getTotalFromDb();
if(!$info){
$return["status"] = "error";
$return['errorInfo'] = $GLOBALS['errorSql'];
}else{
$return['status'] = "ok";
$return['dataUser'] = $info;
}
$return["json"] = json_encode($return);
echo json_encode($return);
}
function getZips(){
include_once dirname(__FILE__).'/database/handlerDb.php';
$info = getListZips();
if(!$info){
$return["status"] = "error";
$return['errorInfo'] = $GLOBALS['errorSql'];
}else{
$return['status'] = "ok";
$return['dataUser'] = $info;
}
$return["json"] = json_encode($return);
echo json_encode($return);
}
?>