/
index.php
450 lines (420 loc) · 17.2 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
<?php
require_once("includes/functions.php");
//Print page function
function print_page($page){
global $connection;
global $folders;
global $date;
$query="UPDATE `pages` SET views = views + 1 WHERE `id` = {$page['id']}";
$result=mysqli_query( $connection, $query);
switch ($page['type']){
case "Link":
redirect_to($page['url']);
break;
case "Blog":
$pgsettings = array(
"title" => $page['name'],
"pageselection" => "true",
"nav" => $page['horiz_menu_visible'],
"banner" => $page['banner'],
"slider" => $page['slider'],
"use_google_analytics" => 1,
);
require_once("includes/begin_html.php");
include_once("blog.php");
break;
case "Forum":
$pgsettings = array(
"title" => $page['name'],
"pageselection" => "true",
"nav" => $page['horiz_menu_visible'],
"banner" => $page['banner'],
"slider" => $page['slider'],
"use_google_analytics" => 1,
);
require_once("includes/begin_html.php");
include_once("forums.php");
break;
case "Staff":
$pgsettings = array(
"title" => $page["name"],
"pageselection" => "true",
"nav" => true,
"banner" => $page['banner'],
"slider" => $page['slider'],
"use_google_analytics" => 1,
);
$staffquery="SELECT * FROM `staff` ORDER BY `order`";
$staffresult=mysqli_query( $connection, $staffquery);
require_once("includes/begin_html.php");?>
<h2><?php echo $page["name"]; ?></h2>
<?php
if(mysqli_num_rows($staffresult)!=0){
$i=0;
while($staff=mysqli_fetch_array($staffresult)){
$profile_pic = false;
$dir = USER_DIR."staff/".$staff['id']."/";
foreach (scandir($dir) as $item) {
if ($item == '.' || $item == '..' || $item == 'Thumbs.db') continue;
$profile_pic = $item;
}
?>
<div class="staff ">
<div class="card">
<div class="card-image waves-effect waves-block waves-light">
<?php if($profile_pic != false){ ?><img class="activator" src="<?php echo $GLOBALS['HOST'].'/'.$dir.$item; ?>" width="120" height="auto" /><?php }else{echo "[No Picture]";} ?>
</div>
<div class="card-content">
<span class="card-title activator grey-text text-darken-4"><?php echo $staff['name']; ?><i class="material-icons right">more_vert</i></span>
<p><a href="#">This is a link</a></p>
</div>
<div class="card-reveal">
<span class="card-title grey-text text-darken-4">Card Title<i class="material-icons right">close</i></span>
<p>Here is some more information about this product that is only revealed once clicked on.</p>
</div>
</div>
</div>
<!--<div class="staffBlock" href="#staff<?php echo $i; ?>" rel="prettyPhoto[staff]">
<span><?php if($profile_pic != false){ ?><img src="<?php echo $GLOBALS['HOST'].'/'.$dir.$item; ?>" width="120" height="auto" /><?php }else{echo "[No Picture]";} ?></span>
<span><?php echo $staff['name']; ?></span>
</div>
<div id="staff<?php echo $i; ?>" style="display:none;">
<span style="float:left; margin-right:10px; display:block; width:300px; height:auto; text-align:center; background-color:#C5C5C5; padding:10px;"><span style="line-height:300px; height:300px; display:block; padding-bottom:5px;"><?php if($profile_pic != false){ ?><img src="<?php echo $GLOBALS['HOST'].'/'.$dir.$item; ?>" width="300" height="auto" /><?php }else{echo "[No Picture]";} ?></span><span style="line-height:50px; height:50px; display:block;"><strong><?php echo $staff['name']; ?></strong></span></span>
<span style="float:left; display:block;"><?php if($staff['role']!=""){ ?><strong>Role: </strong><?php echo $staff['role']; ?><br><?php } ?>
<strong>Bio: </strong><?php if($staff['bio']!=""){echo $staff['bio'];}else{echo '[No bio]';} ?></span>
</div> -->
<?php
$i++;
}?>
<div class="clear"></div>
<?php
}else{?>
<p>[No Staff!]</p>
<?php
}
if($page['doc_folder']!=""){
order_doc_files($page['doc_folder']);
}
break;
case "Custom":
$pgsettings = array(
"title" => $page["name"],
"pageselection" => "true",
"nav" => true,
"banner" => $page['banner'],
"slider" => $page['slider'],
"use_google_analytics" => 1,
);
if($page['forms']!=""){
$pageforms=unserialize($page['forms']);
if(isset($_POST['form_id'])){
$query="SELECT * FROM `forms` WHERE `id` = {$_POST['form_id']}";
$result=mysqli_query($connection, $query);
if(mysqli_num_rows($result) == 1){
$formPost=mysqli_fetch_array($result);
$field_validators=unserialize($formPost['field_validators']);
$field_types=unserialize($formPost['field_types']);
$form_validation = array();
$count=0;
$form_send = true;
foreach($_POST as $post_key => $post_val){
if($post_key != $formPost['u_name']&&$post_key != 'form_id'){
$fixed_post_key = str_replace('_', ' ', $post_key);
switch($field_validators[$count]){
case "none":
$form_validation[$fixed_post_key] = true;
break;
case "email":
if(filter_var($_POST[$post_key],FILTER_VALIDATE_EMAIL)){
$form_validation[$fixed_post_key] = true;
break;
}else{
$form_send = false;
$form_validation[$fixed_post_key] = false;
$error = "There were errors in form \"".$formPost['name']."\", please fix them below.";
}
break;
case "notempty":
if($_POST[$post_key]!=""){
$form_validation[$fixed_post_key] = true;
break;
}else{
$form_send = false;
$form_validation[$fixed_post_key] = false;
$error = "There were errors in form \"".$formPost['name']."\", please fix them below.";
}
break;
case "numbers":
if(is_numeric($_POST[$post_key])){
$form_validation[$fixed_post_key] = true;
break;
}else{
$form_send = false;
$form_validation[$fixed_post_key] = false;
$error = "There were errors in form \"".$formPost['name']."\", please fix them below.";
}
break;
case "phone":
if(preg_match("/^[0-9]{3}-[0-9]{3}-[0-9]{4}$/" ,$_POST[$post_key])){
$form_validation[$fixed_post_key] = true;
break;
}else{
$form_send = false;
$form_validation[$fixed_post_key] = false;
$error = "There were errors in form \"".$formPost['name']."\", please fix them below.";
}
break;
}
}
$count++;
}
if($form_send == true){
$email_message = 'Data from form "'.$formPost['name'].'", submitted at '.$date.'<br/>';
foreach($_POST as $post_key => $post_val){
if($post_key != $formPost['u_name']&&$post_key != 'form_id'){
$email_message .= '<b>'.str_replace('_', ' ', $post_key).': </b>'.$post_val.'<br/>';
}
}
$to = $formPost['email_to'];
$email_subject = '"'.$formPost['name'].'" form submission';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: ".$formPost['email_from']."\r\n"."X-Mailer: php";
if(mail ( $to , $email_subject , $email_message , $headers )){
$success = 'Your response has been recorded! Thank you.';
}
}
}
}
}
require_once("includes/begin_html.php");?>
<?php
echo $page['content'];
if($page['doc_folder']!=""){
order_doc_files($page['doc_folder']);
}
//Calendars
if($page['calendars']!=""){
$pageCalendars=unserialize($page['calendars']);
foreach($pageCalendars as $pgCalendar){
getCalendar($pgCalendar);
}
}
//Forms
if($page['forms']!=""){
$pageforms=unserialize($page['forms']);
foreach($pageforms as $pg_form){
$query="SELECT * FROM `forms` WHERE `id` = {$pg_form}";
$result=mysqli_query($connection, $query);
$form=mysqli_fetch_array($result);
$field_names=unserialize($form['field_names']);
$field_types=unserialize($form['field_types']);
$field_descs=unserialize($form['field_descs']);
$field_placeholders=unserialize($form['field_placeholders']);
$field_maxchars=unserialize($form['field_maxchars']);
$field_validators=unserialize($form['field_validators']);
$num_fields = count($field_names);
$count = 0;
?>
<br><br>
<h2><?php echo $form['name']; ?></h2>
<form method="post" name="<?php echo $form['u_name']; ?>">
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<?php while($num_fields>$count){
$maxchars = intval($field_maxchars[$count]);
//echo 'valid ';print_r($form_validation);echo '<br>';
//echo 'post ';print_r($_POST);echo '<br>';
if(isset($form_validation[$field_names[$count]])&&$form['id']==$_POST['form_id']){
$validation_arr=$form_validation[$field_names[$count]];
}else{
unset($validation_arr);
}
$temp = str_replace(' ', '_', $field_names[$count]);
if(isset($_POST[$temp])&&$form['id']==$_POST['form_id']){
$post_name = str_replace('_', ' ', $_POST[$temp]);
}else{
$post_name="";
}
?>
<tr>
<td>
<?php if($field_types[$count] != "textblock"){?>
<label for="<?php echo $field_names[$count]; ?>" style="margin-left:10px;"><?php echo $field_names[$count].':'; if($field_validators[$count]=="notempty"||$field_validators[$count]=="email"){echo '*';}?> </label><?php if(isset($validation_arr)&&$validation_arr!=true){?><div style=" display:inline; border-radius:5px; background-color:#9F0002; color:#FFFFFF; padding:3px; font-size:16px;"><?php if($field_validators[$count]=="email"){echo 'Invalid email';}elseif($field_validators[$count]=="notempty"){echo 'Cannot be blank';}elseif($field_validators[$count]=="numbers"){echo 'Field can only contain numbers';}elseif($field_validators[$count]=="phone"){echo 'Invalid Phone, valid format: "555-555-5555"';}?></div><?php } ?><br>
<?php } ?>
<span class="tooltips" style="vertical-align:middle;">
<?php if($field_types[$count] == "text"){?>
<input name="<?php echo $field_names[$count]; ?>" id="<?php echo $field_names[$count]; ?>" style=" width:250px; <?php if(isset($validation_arr)&&$validation_arr!=true){echo 'border:2px solid #9F0002;"';} ?>" value="<?php echo $post_name; ?>" type="text"<?php if($field_placeholders[$count] != ""){echo ' placeholder="'.$field_placeholders[$count].'"';} ?><?php if($maxchars != ""){echo ' maxlength="'.$maxchars.'"';} ?> />
<?php if($field_descs[$count]!=""){echo "<span>".$field_descs[$count]."</span>";}?>
<?php }elseif($field_types[$count] == "textarea"){ ?>
<textarea name="<?php echo $field_names[$count]; ?>" id="<?php echo $field_names[$count]; ?>"<?php if(isset($form_validation[$field_names[$count]])&&$form_validation[$field_names[$count]]!=true){echo ' style="border:2px solid #9F0002;"';} ?> rows="15" cols="75"<?php if($field_placeholders[$count] != ""||$maxchars != ""){$placeholder = $field_placeholders[$count]; if($maxchars != ""){$placeholder.=' (Max. '.$maxchars.' characters)';} echo ' placeholder="'.$placeholder.'"';} ?><?php if($maxchars != ""){echo ' maxlength="'.$maxchars.'"';} ?>><?php if(isset($_POST[$field_names[$count]])){echo $_POST[$field_names[$count]];} ?></textarea>
<?php if($field_descs[$count]!=""){echo "<span>".$field_descs[$count]."</span>";}?>
<?php }elseif($field_types[$count] == "textblock"){ ?>
<?php echo $field_descs[$count]; ?>
<?php } ?>
</span>
</td>
</tr>
<?php
$count++;
}
?>
<tr>
<td>
<input type="hidden" name="form_id" value="<?php echo $form['id']; ?>">
<input type="submit" name="<?php echo $form['u_name']; ?>" class="btn green" value="<?php if($form['submit_value']!=""){echo $form['submit_value'];}else{echo 'Submit';} ?>" />
</td>
</tr>
</table>
</form>
<?php
}
}
if($page['galleries']!=""){
$pagegalleries=unserialize($page['galleries']);
if(count($pagegalleries)>1){
?>
<div id="TabbedPanels1" class="TabbedPanels">
<ul class="TabbedPanelsTabGroup">
<?php
foreach($pagegalleries as $gallery){
$query="SELECT * FROM `galleries` WHERE `id`={$gallery}";
$result=mysqli_query( $connection, $query);
$pagegallery=mysqli_fetch_array($result);
?>
<li class="TabbedPanelsTab" tabindex="0"><?php echo $pagegallery['name'] ?></li>
<?php
}
?>
</ul>
<div class="TabbedPanelsContentGroup">
<?php
foreach($pagegalleries as $gallery){
$query="SELECT * FROM `galleries` WHERE `id`={$gallery}";
$result=mysqli_query( $connection, $query);
$pagegallery=mysqli_fetch_array($result);
?>
<div class="TabbedPanelsContent">
<?php
gallery($gallery, $gallery);
if($pagegallery['subgalleries']!=""){
$subgalleries = unserialize($pagegallery['subgalleries']);
foreach($subgalleries as $subgalleryid){
$query="SELECT * FROM `galleries` WHERE `id`={$subgalleryid}";
$result=mysqli_query( $connection, $query);
$subgallery=mysqli_fetch_array($result);
?>
<h2><?php echo $subgallery['name'] ?></h2>
<?php
gallery($subgalleryid, $subgallery['id']);
}
}
?>
</div>
<?php
}
?>
</div>
</div>
<?php
}else{
$query="SELECT * FROM `galleries` WHERE `id`={$pagegalleries[0]}";
$result=mysqli_query( $connection, $query);
$onegallery=mysqli_fetch_array($result);?>
<h2><?php echo $onegallery['name'] ?></h2>
<?php
gallery($pagegalleries[0], $onegallery['id']);
if($onegallery['subgalleries']!=""){
$subgalleries = unserialize($onegallery['subgalleries']);
foreach($subgalleries as $subgalleryid){
$query="SELECT * FROM `galleries` WHERE `id`={$subgalleryid}";
$result=mysqli_query( $connection, $query);
$subgallery=mysqli_fetch_array($result);
?>
<h2><?php echo $subgallery['name'] ?></h2>
<?php
gallery($subgalleryid, $subgallery['id']);
}
}
}
}
break;
}
}
$query="SELECT * FROM `pages` ORDER BY `position` ASC LIMIT 1";
$result=mysqli_query($connection, $query);
$firstpage=mysqli_fetch_array($result);
$query="SELECT * FROM `pages` WHERE `id` = {$GLOBALS['site_info']['homepage']}";
$result_homepage=mysqli_query($connection, $query);
confirm_query($result_homepage);
$query="SELECT * FROM `pages`";
$result=mysqli_query($connection, $query);
$rows=mysqli_num_rows($result);
if(($rows)!=0){
if(isset($_GET['page'])){
$id=intval($_GET['page']);
$pgname=urldecode($_GET['page']);
$query="SELECT * FROM `pages` WHERE name='{$pgname}'";
$result=mysqli_query( $connection, $query);
$page=mysqli_fetch_array($result);
if(mysqli_num_rows($result)==0){
$error = "No page by this name found. Maybe it was deleted or renamed?";
$pgsettings = array(
"title" => "No page by this name found!",
"pageselection" => "true",
"nav" => true,
"banner" => 1,
"use_google_analytics" => 1,
);
require_once("includes/begin_html.php");
}else{
if($page['published']==1){
if(canView(unserialize($page['visible']))){
print_page($page);
}else{
$pgsettings = array(
"title" => "You Do Not Have Permission",
"pageselection" => false,
"nav" => true,
"banner" => 1,
"use_google_analytics" => 1,
);
require_once("includes/begin_html.php");
?><p>(You don't have permission to view this page.)</p><?php
}
}else{
$pgsettings = array(
"title" => "Unpublished",
"pageselection" => false,
"nav" => true,
"banner" => 1,
"use_google_analytics" => 1,
);
require_once("includes/begin_html.php");
?><p>(You cannot view this page, it isn't published.)</p><?php
}
}
}else{
if(mysqli_num_rows($result_homepage)!=0){
$homepage=mysqli_fetch_array($result_homepage);
print_page($homepage);
}else{
print_page($firstpage);
}
}
}else{
$pgsettings = array(
"title" => "No pages!",
"pageselection" => false,
"nav" => true,
"banner" => 1,
"use_google_analytics" => 1,
);
require_once("includes/begin_html.php");
?>
<p>(This website has no pages to display! Admin user must go add pages in the <a href="administrator/">Control Panel</a> to add content.)</p>
<?php
}
?>
<?php
require_once("includes/end_html.php");
?>