-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgetevent_data.php
More file actions
executable file
·317 lines (244 loc) · 9.49 KB
/
getevent_data.php
File metadata and controls
executable file
·317 lines (244 loc) · 9.49 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
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
<?php
///// General data
function add_data() {
global $db;
global $output;
global $config;
$get_event_stmt = $db->prepare("SELECT * FROM event where ID=:id");
$get_event_stmt->bindParam(":id", sanitize_id($_GET['id']));
$get_event_stmt->execute();
$get_event_res = $get_event_stmt->fetchAll(PDO::FETCH_ASSOC);
if(count($get_event_res) != 1) {
die();
}
$get_event_res = $get_event_res[0];
if(!$get_event_res["visible"]) {
die();
}
$output["general"] = array(
"version_num"=>$get_event_res["config_version"].",".$get_event_res["notif_version"],
"refresh_rate" => $get_event_res["refresh_rate"],
"refresh" => "15", // for compatibility only
"refresh_expire" => date("m/d/Y",strtotime($get_event_res["refresh_expire"])),
"time_zone" =>$get_event_res["TZcatagory"]."/".$get_event_res["time_zone"],
"welcome_message" => $get_event_res["welcome_message"],
"notifications_url" => stripFileName(). "getnotifications.php?id=" . sanitize_id($_GET['id']),
"year" => $get_event_res["year"]?$get_event_res["year"]:date("Y", strtotime($get_event_res["refresh_expire"])),
"logo" => $get_event_res["logo"],
"custom_time_zone"=> $get_event_res["custom_tz"],
"remote_viewing"=>$get_event_res["view_remote"],
"allow_qr_share"=>$get_event_res["allow_qr_share"],
"event_name"=>$get_event_res["name"]
);
///// Contact page sections
$get_cpages_stmt = $db->prepare("SELECT * FROM contact_page_sections where event_ID=:id");
$get_cpages_stmt->bindValue(":id",$get_event_res["internal_ID"]);
$get_cpages_stmt->execute();
// If we have a contact page section then include the contact_page section.
if($get_cpages_res = $get_cpages_stmt->fetch(PDO::FETCH_ASSOC)) {
$output["contact_page"] = array(
"nav" => $get_event_res["contact_nav"],
"icon" => $get_event_res["contact_icon"]
);
do { $contact;
if($get_cpages_res["sequential_ID"] != 1){
$names=explode(":",$get_cpages_res["content"]);
$tempstring="";
$counter=0;
foreach ($names as $id){
$get_contacts_stmt = $db->prepare("SELECT name FROM contacts where event_ID=:id and ID= :CID");
$get_contacts_stmt->bindValue(":id",$get_event_res["internal_ID"]);
$get_contacts_stmt->bindValue(":CID",$id);
$get_contacts_stmt->execute();
$get_contact_res=$get_contacts_stmt->fetch(PDO::FETCH_ASSOC);
if (!$counter==0){
$tempstring.=":";
}
$tempstring.=$get_contact_res["name"];
$counter++;
}
$contact=$tempstring;
}
else{
$contact=$get_cpages_res["content"];
}
$output["contact_page"]["section_" . $get_cpages_res["sequential_ID"]] = array(
"header" => $get_cpages_res["header"],
"content" => $contact,
"id" => "".($get_cpages_res["sequential_ID"]-1).""
);
} while($get_cpages_res = $get_cpages_stmt->fetch(PDO::FETCH_ASSOC));
}
////// Contacts
$get_contacts_stmt = $db->prepare("SELECT * FROM contacts where event_ID=:id");
$get_contacts_stmt->bindValue(":id",$get_event_res["internal_ID"]);
$get_contacts_stmt->execute();
// If we have a contacts then include that section.
if($get_contacts_res = $get_contacts_stmt->fetch(PDO::FETCH_ASSOC)) {
$output["contacts"] = array();
do {
$output["contacts"][$get_contacts_res["name"]] = array(
"address" => $get_contacts_res["address"],
"phone" => $get_contacts_res["phone"],
);
} while($get_contacts_res = $get_contacts_stmt->fetch(PDO::FETCH_ASSOC));
}
///// Schedule
$get_sched_item_stmt = $db->prepare("SELECT * FROM schedule_items where event_ID=:id");
$get_sched_item_stmt->bindValue(":id",$get_event_res["internal_ID"]);
$get_sched_item_stmt->execute();
// If we have a schedule items then include that section.
if($get_sched_item_res = $get_sched_item_stmt->fetch(PDO::FETCH_ASSOC)) {
$output["schedule"] = array(
"nav" => $get_event_res["sched_nav"],
"icon" => $get_event_res["sched_icon"]
);
do {
$date = date("m/d/Y",strtotime($get_sched_item_res["date"]));
$get_name =$db->prepare("SELECT name FROM contacts WHERE event_ID = :EID AND ID= :CID");
$get_name->bindValue(":EID",$get_event_res["internal_ID"]);
$get_name->bindValue(":CID",$get_sched_item_res["location"]);
$get_name->execute();
$get_name_res=$get_name->fetch(PDO::FETCH_ASSOC);
if ($get_sched_item_res["location"] == ""){
$locationName = "null";
} else {
$locationName = $get_name_res["name"];
}
$themeID = $get_sched_item_res["category"];
$get_theme = $db->prepare("SELECT theme_name FROM themes WHERE ID=:id");
$get_theme -> bindValue(":id",$themeID);
$get_theme -> execute();
$theme_name_res = $get_theme->fetch(PDO::FETCH_ASSOC);
if ($themeID == ""){
$themeName = "schedule_blank";
} else {
$themeName = $theme_name_res["theme_name"];
}
// Create the key $date if necessary, then use the $var[] = ... syntax to push a dictionary onto the array of items on that date.
$output["schedule"][$date][] = array(
"start_time" => $get_sched_item_res["start_time"]+1-1,
"length" => $get_sched_item_res["length"]+1-1,
"description" => $get_sched_item_res["description"],
"location" => $locationName,
"category" => $themeName,
);
} while($get_sched_item_res = $get_sched_item_stmt->fetch(PDO::FETCH_ASSOC));
}
///// Housing
$get_housing_stmt = $db->prepare("SELECT * FROM housing where event_ID=:id");
$get_housing_stmt->bindValue(":id",$get_event_res["internal_ID"]);
$get_housing_stmt->execute();
// If we have a housing items then include that section.
if($get_housing_res = $get_housing_stmt->fetch(PDO::FETCH_ASSOC)) {
$output["housing"] = array(
"nav" => $get_event_res["housing_nav"],
"icon" => $get_event_res["housing_icon"]
);
do {
$get_guest_stmt = $db->prepare("SELECT * FROM attendees where house_ID=:id");
$get_guest_stmt->bindValue(":id",$get_housing_res["ID"]);
$get_guest_stmt->execute();
$str = "";
$first = true;
while($get_guest_res = $get_guest_stmt->fetch(PDO::FETCH_ASSOC)) {
if(!$first) {
$str =$str . "\n";
}
else {
$first = false;
}
$str =$str. $get_guest_res["name"];
}
$get_name =$db->prepare("SELECT name FROM contacts WHERE event_ID = :EID AND ID= :CID");
$get_name->bindValue(":EID",$get_event_res["internal_ID"]);
$get_name->bindValue(":CID",$get_housing_res["host_name"]);
$get_name->execute();
$get_name_res=$get_name->fetch(PDO::FETCH_ASSOC);
$output["housing"][$get_name_res["name"]] = array(
"driver" => $get_housing_res["driver"],
"students" => $str,
);
} while($get_housing_res = $get_housing_stmt->fetch(PDO::FETCH_ASSOC));
}
///// Prayer Partners
$get_prayer_partners_stmt = $db->prepare("SELECT * FROM prayer_partners where event_ID=:id");
$get_prayer_partners_stmt->bindValue(":id",$get_event_res["internal_ID"]);
$get_prayer_partners_stmt->execute();
// Includes a prayer partner page if there is one
if($get_prayer_partners_res = $get_prayer_partners_stmt->fetch(PDO::FETCH_ASSOC)) {
$output["prayer_partners"] = array();
$output["prayer_partners"][] = array(
"nav" => $get_event_res["prayer_nav"],
"icon" => $get_event_res["prayer_icon"]
);
do {
$get_attendee_stmt = $db->prepare("SELECT * FROM attendees where prayer_group_ID=:id");
$get_attendee_stmt->bindValue(":id",$get_prayer_partners_res["group_ID"]);
$get_attendee_stmt->execute();
$str = "";
$first = true;
while($get_attendee_res = $get_attendee_stmt->fetch(PDO::FETCH_ASSOC)) {
if(!$first) {
$str .= "\n";
}
else {
$first = false;
}
$str .= $get_attendee_res["name"];
}
$output["prayer_partners"][] = array(
"students" => $str,
);
} while($get_prayer_partners_res = $get_prayer_partners_stmt->fetch(PDO::FETCH_ASSOC));
}
///// Additional Information Pages
$get_info_page_stmt = $db->prepare("SELECT * FROM info_page where event_ID=:id");
$get_info_page_stmt->bindValue(":id",$get_event_res["internal_ID"]);
$get_info_page_stmt->execute();
// Includes any additional information pages
if($get_info_page_res = $get_info_page_stmt->fetch(PDO::FETCH_ASSOC)) {
$output["information_page"] = array();
do {
$page = "page_" . $get_info_page_res["sequential_ID"];
$output["information_page"][$page] = array();
$output["information_page"][$page][] = array(
"nav" => $get_info_page_res["nav"],
"icon" => $get_info_page_res["icon"],
);
$get_info_section_stmt = $db->prepare("SELECT * FROM info_page_sections where info_page_ID=:id");
$get_info_section_stmt->bindValue(":id",$get_info_page_res["ID"]);
$get_info_section_stmt->execute();
while($get_info_section_res = $get_info_section_stmt->fetch(PDO::FETCH_ASSOC)) {
$output["information_page"][$page][] = array(
"title" => $get_info_section_res["header"],
"description" => $get_info_section_res["content"],
);
}
} while($get_info_page_res = $get_info_page_stmt->fetch(PDO::FETCH_ASSOC));
}
///// Themes
$get_themes_stmt = $db->prepare("SELECT * FROM themes where event_ID=:id");
$get_themes_stmt->bindValue(":id", $get_event_res["internal_ID"]);
$get_themes_stmt->execute();
$output["theme"] = array(
array(
"themeColor" => $get_event_res["theme_color"]
),
array(
"themeMedium" => $get_event_res["theme_medium"]
),
array(
"themeDark" => $get_event_res["theme_dark"]
),
array(
"schedule_blank" => "#d6d4d4"
)
);
while ($get_themes_res = $get_themes_stmt->fetch(PDO::FETCH_ASSOC)) {
$output["theme"][] = array(
$get_themes_res["theme_name"] => $get_themes_res["theme_color"],
);
}
}
?>