-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchkvacation.php
71 lines (64 loc) · 1.43 KB
/
chkvacation.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
<?php
require_once('inc/common.php');
if(!isset($_SESSION['role']) || decoded($_SESSION['role']) != 'SuperAdmin')
{
header('Location: /');
exit;
}
if(!isset($_POST['domain']) || !isset($_POST['actiond']))
{
header('Location: /');
exit;
}
if($_POST['actiond'] != 'save' && $_POST['actiond'] != 'remove' && $_POST['actiond'] != 'update')
{
header('Location: /');
exit;
}
$obj = new stdClass();
$obj->response = true;
$errObj = new stdClass();
if($_POST['domain'] == '')
{
$errObj->domain = "Please Enter Vacation domain name";
$obj->response = false;
}
if($_POST['actiond'] != 'save')
{
if(!isset($_POST['dmID']) || empty($_POST['dmID']) || decoded($_POST['dmID']) != $_POST['udp'])
{
$errObj->domain = "Invalid Domain";
$obj->response = false;
}
}
if($obj->response == false)
{
$obj->errors = $errObj;
header("content-type: application/json");
echo json_encode($obj);
exit;
}
if($_POST['actiond'] == 'remove')
{
$db->delete($TBL_transport, "destination = 'vacation:'");
}
else
{
$newdomain = array(
"domain" => escape_string(trim(strtolower($_POST['domain']))),
"destination" => 'vacation:'
);
if($_POST['actiond'] == 'save')
{
$db->insert($TBL_transport, $newdomain);
}
else
{
unset($newdomain['destination']);
$db->update($TBL_transport, $newdomain, "destination = 'vacation:'");
}
}
$obj->page = "/vacation";
header("content-type: application/json");
echo json_encode($obj);
?>