-
Notifications
You must be signed in to change notification settings - Fork 80
/
index.php
493 lines (423 loc) · 20.1 KB
/
index.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
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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
<?php
/**
* Module: index.php
* Description: This module is the delivery vehicle for all modules.
*
*/
// ---------------------------- Load Config Scripts ------------------------------
require_once ('paths.php');
require_once (CONFIG.'bootstrap.php');
require_once (DB.'mods.db.php');
$account_pages = array("list","pay","brewer","user","brew","pay","evaluation");
if ((!$logged_in) && (in_array($section,$account_pages))) {
$redirect = $base_url."index.php?section=login&msg=99";
$redirect = prep_redirect_link($redirect);
$redirect_go_to = sprintf("Location: %s", $redirect);
header($redirect_go_to);
exit();
}
if (MAINT) {
if ((!$logged_in) || (($logged_in) && ($_SESSION['userLevel'] > 0))) {
$redirect = $base_url."maintenance.php";
$redirect = prep_redirect_link($redirect);
$redirect_go_to = sprintf("Location: %s", $redirect);
header($redirect_go_to);
exit();
}
}
// ---------------------------- Admin Only Functions -------------------------------
if ($section == "admin") {
// Redirect if non-admins try to access admin functions
if (!$logged_in) {
$redirect = $base_url."index.php?section=login&msg=0";
$redirect = prep_redirect_link($redirect);
$redirect_go_to = sprintf("Location: %s", $redirect);
header($redirect_go_to);
exit();
}
if (($logged_in) && ($_SESSION['userLevel'] > 1)) {
$redirect = $base_url."index.php?msg=4";
$redirect = prep_redirect_link($redirect);
$redirect_go_to = sprintf("Location: %s", $redirect);
header($redirect_go_to);
exit();
}
require_once (LIB.'admin.lib.php');
require_once (DB.'admin_common.db.php');
require_once (DB.'judging_locations.db.php');
require_once (DB.'stewarding.db.php');
require_once (DB.'dropoff.db.php');
require_once (DB.'contacts.db.php');
}
// ---------------------------- Other Top-Level Constants -------------------------------
require_once (INCLUDES.'constants_post_lang.inc.php');
// Hosted installations only
if (HOSTED) require_once (LIB.'hosted.lib.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?php echo $_SESSION['contestName']; ?> - Brew Competition Online Entry & Management</title>
<?php
if (CDN) include (INCLUDES.'load_cdn_libraries.inc.php');
else include (INCLUDES.'load_local_libraries.inc.php');
?>
<!-- Load BCOE&M Custom CSS - Contains Bootstrap overrides and custom classes common to all BCOE&M themes -->
<link rel="stylesheet" type="text/css" href="<?php echo $css_common_url; ?>" />
<link rel="stylesheet" type="text/css" href="<?php echo $theme; ?>" />
<script type="text/javascript">
var username_url = "<?php echo $ajax_url; ?>username.ajax.php";
var email_url="<?php echo $ajax_url; ?>valid_email.ajax.php";
var user_agent_msg = "<?php echo $alert_text_086; ?>";
var setup = 0;
</script>
<!-- Open Graph Implementation -->
<?php if (!empty($_SESSION['contestName'])) { ?>
<meta property="og:title" content="<?php echo $_SESSION['contestName']?>" />
<?php } ?>
<?php if (!empty($_SESSION['contestLogo'])) { ?>
<meta property="og:image" content="<?php echo $base_url."user_images/".$_SESSION['contestLogo']; ?>" />
<?php } ?>
<meta property="og:url" content="<?php echo "http" . ((!empty($_SERVER['HTTPS'])) ? "s://" : "://") . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; ?>" />
</head>
<body>
<a name="top"></a>
<!-- LOADER -->
<div id="loader-submit">
<div class="center">
<span class="fa fa-cog fa-spin fa-5x fa-fw"></span>
<p><strong><?php echo $label_working; ?>.<br><?php echo $output_text_030." ".$output_text_031; ?></strong></p>
</div>
</div>
<!-- ./LOADER -->
<!-- MAIN NAV -->
<div class="<?php echo $container_main; ?> hidden-print">
<?php include (SECTIONS.'nav.sec.php'); ?>
</div><!-- container -->
<!-- ./MAIN NAV -->
<!-- ALERTS -->
<div class="<?php echo $container_main; ?> bcoem-warning-container">
<?php
$errors_display = "";
if ((!empty($_SESSION['error_output'])) || (!empty($error_output))) {
$errors_display .= "<div class=\"bcoem-admin-element\">";
$errors_display .= "<div class=\"alert alert-danger alert-dismissible hidden-print fade in\">";
$errors_display .= "<p><span class=\"fa fa-lg fa-exclamation-circle\"></span> <strong>Error(s)</strong></p>";
$errors_display .= "<p>The following errors were logged on the last MySQL server call:</p>";
$errors_display .= "<ul>";
if (!empty($error_output)) {
foreach ($error_output as $key => $value) {
$errors_display .= "<li>".$value."</li>";
}
}
if (!empty($_SESSION['error_output'])) {
foreach ($_SESSION['error_output'] as $key => $value) {
$errors_display .= "<li>".$value."</li>";
}
}
$errors_display .= "</ul>";
$errors_display .= "</div>";
$errors_display .= "</div>";
}
if (!empty($errors_display)) echo $errors_display;
include (SECTIONS.'alerts.sec.php');
?>
</div><!-- ./container -->
<!-- ./ALERTS -->
<!-- Top line JS -->
<script>
$("#no-js-alert").hide();
try {
var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE ");
if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) {
alert(user_agent_msg)
}
} catch (error) {
console.error('Error checking user agent.', error)
}
</script>
<!-- DEBUG -->
<div class="<?php echo $container_main; ?> hidden-print">
<?php if (DEBUG_SESSION_VARS) include (DEBUGGING.'session_vars.debug.php'); ?>
</div>
<!-- ./DEBUG -->
<?php if ($_SESSION['prefsUseMods'] == "Y") { ?>
<!-- MODS TOP -->
<div class="<?php echo $container_main; ?> hidden-print">
<?php include (INCLUDES.'mods_top.inc.php'); ?>
</div>
<!-- ./MODS TOP -->
<?php } ?>
<?php if (($section == "admin") && (($logged_in) && ($_SESSION['userLevel'] <= 1))) { ?>
<!-- Admin Pages (Fluid Layout) -->
<div class="container-fluid">
<?php if ($go == "default") { ?>
<!-- Admin Dashboard - Has sidebar -->
<div class="row">
<div class="col col-lg-9 col-md-8 col-sm-12 col-xs-12">
<div class="page-header">
<h1><?php echo $header_output; ?></h1>
</div>
<?php include (ADMIN.'default.admin.php'); ?>
</div><!-- ./left column -->
<div class="sidebar col col-lg-3 col-md-4 col-sm-12 col-xs-12">
<?php include (ADMIN.'sidebar.admin.php'); ?>
</div><!-- ./sidebar -->
</div><!-- ./row -->
<?php } else { ?>
<!-- Admin Page - full width of viewport -->
<div class="page-header">
<h1><?php echo $header_output; ?></h1>
</div>
<?php
if ($go == "judging") include (ADMIN.'judging_locations.admin.php');
if ($go == "non-judging") include (ADMIN.'non-judging_locations.admin.php');
if ($go == "judging_preferences") include (ADMIN.'judging_preferences.admin.php');
if ($go == "judging_tables") include (ADMIN.'judging_tables.admin.php');
if ($go == "judging_flights") include (ADMIN.'judging_flights.admin.php');
if ($go == "judging_scores") include (ADMIN.'judging_scores.admin.php');
if ($go == "judging_scores_bos") include (ADMIN.'judging_scores_bos.admin.php');
if ($go == "participants") include (ADMIN.'participants.admin.php');
if ($go == "entries") include (ADMIN.'entries.admin.php');
if ($go == "contacts") include (ADMIN.'contacts.admin.php');
if ($go == "dropoff") include (ADMIN.'dropoff.admin.php');
if ($go == "checkin") include (ADMIN.'barcode_check-in.admin.php');
if ($go == "count_by_style") include (ADMIN.'entries_by_style.admin.php');
if ($go == "count_by_substyle") include (ADMIN.'entries_by_substyle.admin.php');
if ($action == "register") include (SECTIONS.'register.sec.php');
if ($go == "upload_scoresheets") include (ADMIN.'upload_scoresheets.admin.php');
if ($go == "payments") include (ADMIN.'payments.admin.php');
if (($_SESSION['prefsEval'] == 1) && ($go == "eval")) include (EVALS.'admin.eval.php');
if ($_SESSION['userLevel'] == "0") {
if ($go == "styles") include (ADMIN.'styles.admin.php');
if ($go == "archive") include (ADMIN.'archive.admin.php');
if ($go == "make_admin") include (ADMIN.'make_admin.admin.php');
if ($go == "contest_info") include (ADMIN.'competition_info.admin.php');
if ($go == "preferences") include (ADMIN.'site_preferences.admin.php');
if ($go == "sponsors") include (ADMIN.'sponsors.admin.php');
if ($go == "style_types") include (ADMIN.'style_types.admin.php');
if ($go == "special_best") include (ADMIN.'special_best.admin.php');
if ($go == "special_best_data") include (ADMIN.'special_best_data.admin.php');
if ($go == "mods") include (ADMIN.'mods.admin.php');
if ($go == "upload") include (ADMIN.'upload.admin.php');
if ($go == "change_user_password") include (ADMIN.'change_user_password.admin.php');
if ($go == "dates") include (ADMIN.'all_dates.admin.php');
}
} ?>
</div><!-- ./container-fluid -->
<!-- ./Admin Pages -->
<?php } elseif (($_SESSION['prefsEval'] == 1) && ($section == "evaluation") && ($logged_in)) {
if (($view == "admin") && ($filter == "default")) $container_eval = "container-fluid";
else $container_eval = "container";
?>
<!-- Electronic Scoresheets Container -->
<div class="<?php echo $container_eval; ?>">
<div class="page-header">
<h1><?php echo $header_output; ?></h1>
</div>
<?php
if ($go == "default") include (EVALS.'default.eval.php');
if ($go == "scoresheet") include (EVALS.'scoresheet.eval.php');
?>
</div><!-- ./container-fluid -->
<?php } else { ?>
<!-- Public Pages (Fixed Layout with Sidebar) -->
<div id="main-content" class="container">
<div class="row">
<div class="col col-lg-9 col-md-8 col-sm-12 col-xs-12">
<?php if ($section != "competition") { ?>
<div class="page-header">
<h1><?php echo $header_output; ?></h1>
</div>
<?php }
if (ENABLE_MARKDOWN) {
include (CLASSES.'parsedown/Parsedown.php');
$Parsedown = new Parsedown();
}
if (SINGLE) include (SSO.'sections/default.sec.php');
else {
if (($section == "default") || ($section == "past-winners")) include (SECTIONS.'default.sec.php');
if ($section == "entry") include (SECTIONS.'entry_info.sec.php');
if ($section == "contact") include (SECTIONS.'contact.sec.php');
if ($section == "volunteers") include (SECTIONS.'volunteers.sec.php');
if ($section == "sponsors") include (SECTIONS.'sponsors.sec.php');
if ($section == "register") include (SECTIONS.'register.sec.php');
if ($section == "login") include (SECTIONS.'login.sec.php');
// if ($section == "past_winners") include (SECTIONS.'past_winners.sec.php');
if ($section == "competition") include (SECTIONS.'custom_competition_info.sec.php');
if ($logged_in) {
if ($section == "brewer") include (SECTIONS.'brewer.sec.php');
if ($section == "list") include (SECTIONS.'list.sec.php');
if ($section == "brew") include (SECTIONS.'brew.sec.php');
if ($section == "pay") include (SECTIONS.'pay.sec.php');
if ($section == "user") include (SECTIONS.'user.sec.php');
}
}
?>
</div><!-- ./left column -->
<div class="sidebar col col-lg-3 col-md-4 col-sm-12 col-xs-12">
<?php include (SECTIONS.'sidebar.sec.php'); ?>
</div><!-- ./sidebar -->
</div><!-- ./row -->
<!-- ./Public Pages -->
</div><!-- ./container -->
<!-- ./Public Pages -->
<?php } ?>
<?php if (DEBUG) { ?>
<div class="<?php echo $container_main; ?> hidden-print">
<?php
include(DEBUGGING.'query_count_end.debug.php');
echo $output_query_count;
?>
</div>
<?php } ?>
<?php if ($_SESSION['prefsUseMods'] == "Y") { ?>
<!-- Mods Bottom -->
<div class="<?php echo $container_main; ?> hidden-print">
<?php include (INCLUDES.'mods_bottom.inc.php'); ?>
</div>
<!-- ./Mods Bottom -->
<?php } ?>
<!-- Footer -->
<footer class="footer hidden-xs">
<div class="navbar <?php echo $nav_container; ?> navbar-fixed-bottom">
<div class="<?php echo $container_main; ?> text-center">
<p class="navbar-text col-md-12 col-sm-12 col-xs-12 text-muted small bcoem-footer"><?php include (SECTIONS.'footer.sec.php'); ?></p>
</div>
</div>
</footer><!-- ./footer -->
<!-- ./ Footer -->
<?php
session_write_close();
if ($logged_in) {
$session_end_seconds = (time() + ($session_expire_after * 60));
$session_end = date('Y-m-d H:i:s',$session_end_seconds);
if (!empty($error_output)) $_SESSION['error_output'] = $error_output;
?>
<!-- Session Expiring Modal: 2 Minute Warning -->
<div class="modal fade" id="session-expire-warning" tabindex="-1" role="dialog" aria-labelledby="session-expire-warning-label">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="session-expire-warning-label"><?php echo $label_session_expire; ?></h4>
</div>
<div class="modal-body">
<p><?php echo $alert_text_090; ?></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><?php echo $label_stay_here; ?></button>
<button type="button" class="btn btn-success" data-dismiss="modal" onclick="window.location.reload()"><?php echo $label_refresh; ?></button>
<button type="button" class="btn btn-danger" data-dismiss="modal" onclick="window.location.replace('<?php echo $base_url; ?>includes/process.inc.php?section=logout&action=logout')"><?php echo $label_log_out; ?></button>
</div>
</div>
</div>
</div>
<!-- Session Expiring Modal: 30 Second Warning -->
<div class="modal fade" id="session-expire-warning-30" tabindex="-1" role="dialog" aria-labelledby="session-expire-warning-30-label">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="session-expire-warning-30-label"><?php echo $label_session_expire; ?></h4>
</div>
<div class="modal-body">
<p><?php echo $alert_text_091; ?></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-success" data-dismiss="modal" onclick="window.location.reload()"><?php echo $label_refresh; ?></button>
<button type="button" class="btn btn-danger" data-dismiss="modal" onclick="window.location.replace('<?php echo $base_url; ?>includes/process.inc.php?section=logout&action=logout')"><?php echo $label_log_out; ?></button>
</div>
</div>
</div>
</div>
<script src="<?php echo $js_app_url; ?>"></script>
<?php if ((!in_array($go,$datetime_load)) || ($go == "default")) { ?>
<!-- Session Timer Displays and Auto Logout -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.32/moment-timezone-with-data.min.js"></script>
<script>
var session_end = moment.tz("<?php echo $session_end; ?>","<?php echo get_timezone($_SESSION['prefsTimeZone']); ?>");
var session_end_min = "<?php echo $session_expire_after; ?>";
var session_end_seconds = "<?php echo $session_end_seconds; ?>";
var session_end_redirect = "<?php echo $base_url; ?>includes/process.inc.php?section=logout&action=logout";
</script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.countdown/2.2.0/jquery.countdown.min.js"></script>
<script type="text/javascript" src="<?php echo $js_url; ?>autologout.min.js"></script>
<?php } ?>
<?php if (($_SESSION['prefsEval'] == 1) && ($section == "evaluation")) include (EVALS.'warnings.eval.php'); ?>
<?php
$brewery_ttb = "false";
$brewery_prod = "false";
if (isset($row_brewer['brewerBreweryInfo'])) {
$brewery_info = json_decode($row_brewer['brewerBreweryInfo'],true);
if (isset($brewery_info['TTB'])) $brewery_ttb = "true";
if (isset($brewery_info['Production'])) $brewery_prod = "true";
}
?>
<script type="text/javascript">
<?php if ($section == "brewer") { ?>
var club_other = <?php if ($club_other) echo "true"; else echo "false"; ?>;
<?php } ?>
var brewer_country = "<?php if (isset($row_brewer)) echo $row_brewer['brewerCountry']; ?>";
var brewer_judge = "<?php if (isset($row_brewer)) echo $row_brewer['brewerJudge']; ?>";
var brewer_steward = "<?php if (isset($row_brewer)) echo $row_brewer['brewerSteward']; ?>";
var brewer_staff = "<?php if (isset($row_brewer)) echo $row_brewer['brewerStaff']; ?>";
var brewer_brewery_ttb = <?php echo $brewery_ttb; ?>;
var brewer_brewery_prod = <?php echo $brewery_prod; ?>;
var user_question_answer = "<?php if (isset($_SESSION['userQuestionAnswer'])) echo $_SESSION['userQuestionAnswer']; ?>";
</script>
<?php } // end if ($logged_in) ?>
<script type="text/javascript">
var section = "<?php echo $section; ?>";
var action = "<?php echo $action; ?>";
var go = "<?php echo $go; ?>";
var edit_style = "<?php echo $action; ?>";
var user_level = "<?php if ((isset($_SESSION['userLevel'])) && ($bid != "default")) echo $_SESSION['userLevel']; else echo "2"; ?>";
</script>
<?php if (($section == "admin") && ($go == "styles") && ($action != "default")) { ?>
<script>
var specialty_ipa_subs = <?php echo json_encode($specialty_ipa_subs); ?>;
var historical_subs = <?php echo json_encode($historical_subs); ?>;
if (edit_style == "edit") {
var req_special = "<?php echo $row_styles['brewStyleReqSpec']; ?>";
var style_type = "<?php echo $row_styles['brewStyleType']; ?>";
} else {
var req_special = "0";
var style_type = "1";
}
</script>
<?php } ?>
<?php if ($section == "brew") { ?>
<script type="text/javascript">
var style_set = "<?php echo $_SESSION['prefsStyleSet']; ?>";
var req_pouring = <?php echo json_encode($req_pouring); ?>;
var req_special_ing_styles = <?php echo json_encode($req_special_ing_styles); ?>;
var req_strength_styles = <?php echo json_encode($req_strength_styles); ?>;
var req_sweetness_styles = <?php echo json_encode($req_sweetness_styles); ?>;
var req_carb_styles = <?php echo json_encode($req_carb_styles); ?>;
var cider_sweetness_custom_styles = <?php echo json_encode($cider_sweetness_custom_styles); ?>;
var mead_sweetness_custom_styles = <?php echo json_encode($mead_sweetness_custom_styles); ?>;
var optional_info_styles = <?php echo json_encode($optional_info_styles); ?>;
var edit_style = "<?php echo ltrim($view,"0"); ?>";
var label_this_style = "<?php echo $label_this_style; ?>";
var req_special_ing_style_info = <?php echo json_encode($styles_entry_text, JSON_UNESCAPED_SLASHES); ?>;
<?php if (($action == "edit") && (!empty($row_log['brewPossAllergens']))) { ?>
var possible_allergens = "<?php echo $row_log['brewPossAllergens']; ?>";
<?php } else { ?>
possible_allergens = null;
<?php } ?>
</script>
<?php } // end if ($section == "brew")
if (($_SESSION['prefsEval'] == 1) && ($section == "evaluation")) include (EVALS.'warnings.eval.php');
// Perform version check if NOT going into setup
if (strpos($section, 'step') === FALSE) {
version_check($version,$current_version,$current_version_date_display);
}
?>
</body>
</html>