-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcreateevent.php
150 lines (128 loc) · 3.39 KB
/
createevent.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<?php
error_reporting(0);
//Database Connection
define('INCLUDE_CHECK', true);
require 'connect.php';
//json decode the values recieved
$_POST = json_decode(file_get_contents('php://input'), true);
//Params passed or not
if(!isset($_POST['brief'])){
$output = array(
"status" => false,
"error" => "brief is not set",
"errorCode" => "102",
"response" => ""
);
die(json_encode($output));
}
if(!isset($_POST['timestamp'])){
$output = array(
"status" => false,
"error" => "timestamp is not set ",
"errorCode" => "102",
"response" => ""
);
die(json_encode($output));
}
if(!isset($_POST['userID'])){
$output = array(
"status" => false,
"error" => "userID is not set ",
"errorCode" => "102",
"response" => ""
);
die(json_encode($output));
}
if(!isset($_POST['audienceFlag'])){
$output = array(
"status" => false,
"error" => "Audience Flag is not set ",
"errorCode" => "102",
"response" => ""
);
die(json_encode($output));
}
if(!isset($_POST['audienceList'])){
$output = array(
"status" => false,
"error" => "audience List is not set ",
"errorCode" => "102",
"response" => ""
);
die(json_encode($output));
}
if(!isset($_POST['venue'])){
$output = array(
"status" => false,
"error" => "venue is not set ",
"errorCode" => "102",
"response" => ""
);
die(json_encode($output));
}
if(!isset($_POST['startTime'])){
$output = array(
"status" => false,
"error" => "start time is not set ",
"errorCode" => "102",
"response" => ""
);
die(json_encode($output));
}
if(!isset($_POST['endTime'])){
$output = array(
"status" => false,
"error" => "end time is not set ",
"errorCode" => "102",
"response" => ""
);
die(json_encode($output));
}
if(!isset($_POST['displayFlag'])){
$output = array(
"status" => false,
"error" => "display flag is not set ",
"errorCode" => "102",
"response" => ""
);
die(json_encode($output));
}
//assign the values to local varibles
$brief=$_POST['brief'];
$audienceFlag=$_POST['audienceFlag'];
$audienceList=json_encode($_POST['audienceList']);
$userID=$_POST['userID'];
$photoURL=$_POST['photoURL'];
$photoFlag= $photoURL=="" ? 0 : 1 ;
$startTime=$_POST['startTime'];
$endTime=$_POST['endTime'];
$venue=$_POST['venue'];
$displayFlag=$_POST['displayFlag'];
//check if the event already exists
$clash = false;
$event=mysql_query("SELECT `id`, `brief`, `audienceFlag`, `audienceList`, `venue`, `startTime`, `endTime`, `userID`, `photoFlag`, `photoURL`, `displayFlag`, `timestamp` FROM `dash_events` WHERE `brief`='{$brief}' AND `audienceFlag` = '{$audienceFlag}' AND `audienceList`='{$audienceList}'");
while($row = mysql_fetch_assoc($event)){
$clash=true;
$output = array(
"status" => false,
"error" => "This particular event already Exists",
"errorCode" => "201",
"response" => ""
);
die(json_encode($output));
}
//if new notofication add to database
if(!$clash){
mysql_query("INSERT INTO `dash_events`(`id`, `brief`, `audienceFlag`, `audienceList`, `venue`, `startTime`, `endTime`, `userID`, `photoFlag`, `photoURL`, `displayFlag`, `timestamp`) VALUES ('','{$brief}','{$audienceFlag}','{$audienceList}','{$venue}','{$startTime}','{$endTime}','{$userID}','{$photoFlag}','{$photoURL}','{$displayFlag}','')");
$response = array(
"message" => "event was created sucessfully"
);
$output = array(
"status" => true,
"error" => "",
"errorCode" => "",
"response" => $response
);
echo json_encode($output);
}
?>