-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
executable file
·1327 lines (1175 loc) · 45.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
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
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/***************************************************************************
File Name : index.php
Domain : http://www.PHPSupportTickets.com/
----------------------------------------------------------------------------
Author : Ian Warner
Copyright : (C) 2001 Triangle Solutions Ltd
Email : [email protected]
URL : http://www.triangle-solutions.com/
Description : Brings together all the elements of the Support Tickets app.
Date Created : Wednesday 19 January 2005 16:13:23
File Version : 1.9
\\||************************************************************************/
#############################################################################################
############################### CURRENT CASEID'S ON THIS PAGE ###############################
#############################################################################################
// home - LINE 401
// view - LINE 669
// NewTicket - LINE 1018
#############################################################################################
################## INCLUDE THE CONFIG, FUNCTIONS, LANGUAGE AND HEADER FILE ##################
#############################################################################################
// STARTS THE SESSION FOR THE USERS SO LOGIN IS TRACKED THROUGH THE PAGES
session_start();
// INCLUDE THE CONFIG AND FUNCTIONS AND LANGUAGE FILE
include_once ('config.php');
include_once ('class/functions.php');
// BAG 2019.06.03
//-------------------------------------------
// DB CONNECTION
//-------------------------------------------
IF ($dbcon = mysqli_connect($host, $user, $pass))
{
IF (!mysqli_select_db($dbcon, $data))
{
echo 'This script has connected to the MySQL but could not connect to the Database - change database name in config.';
exit();
}
}
ELSE
{
echo 'This script could not connect to the MySQL server change host/user/pass values in config.';
exit();
}
//-------------------------------------------
// end DB CONNECTION
//-------------------------------------------
IF (!isset($_REQUEST['lang']))
{
$_REQUEST['lang'] = $langdefault;
}
IF (!isset($_GET['action']))
{
$_GET['action'] = 'Login';
}
include_once ('language/'.$_REQUEST['lang'].'.php');
include_once ('header.php');
#############################################################################################
####################### AUTH LOGIN AND LOGOUT SYSTEM REQUIRES SESSIONS ######################
#############################################################################################
// LOGOUT
IF (isset($_GET['action']) && $_GET['action'] == 'Logout')
{
unset($_SESSION['stu_username']);
unset($_SESSION['stu_password']);
$_GET['action'] = 'Login';
}
// WHAT TO DO IF NO USERNAME OR PASSWORD IS SET
IF (!isset($_SESSION['stu_username']) && !isset($_SESSION['stu_password']))
{
?>
<table width="<?php echo $maintablewidth ?>" cellspacing="1" cellpadding="1" class="boxborder" align="<?php echo $maintablealign ?>">
<tr>
<td class="boxborder text" bgcolor="<?php echo $background ?>"><?php echo $_GET['action'] ?></td>
<td class="boxborder list-menu" width="15%"><a href="<?php echo htmlspecialchars($_SERVER['PHP_SELF']) ?>?action=Login"><?php echo $text_login ?></a></td>
<?php
IF (isset($allowreg) && $allowreg == 'ON')
{
?>
<td class="boxborder list-menu" width="15%"><a href="<?php echo htmlspecialchars($_SERVER['PHP_SELF']) ?>?action=Register"><?php echo $text_register ?></a></td>
<?php
}
?>
<td class="boxborder list-menu" width="15%"><a href="<?php echo htmlspecialchars($_SERVER['PHP_SELF']) ?>?action=Resend"><?php echo $text_resend ?></a></td>
<td class="boxborder list-menu" width="10%"><a href="javascript:popwindow('help.php#userpage','top=150,left=300,width=400,height=400,buttons=no,scrollbars=YES,location=no,menubar=no,resizable=no,status=no,directories=no,toolbar=no')"><?php echo $text_help ?></a></td>
</tr>
</table>
<?php
// CREATE LOGIN AREA
IF ($_GET['action'] == 'Login')
{
IF (isset($_GET['sub']))
{
IF ((AuthUser($dbcon, $_REQUEST['username'], $_REQUEST['password'])) || (isset($_COOKIE['demomode']) && $demomode == 'ON' && $_POST['username'] == 'demo' && $_POST['password'] == 'demo'))
{
$_SESSION['stu_username'] = $_POST['username'];
$_SESSION['stu_password'] = $_POST['password'];
// LOG THE LOGIN TIMES ONLY DO THIS WHEN NOT IN DEMO MODE
IF (!isset($_COOKIE['demomode']) || $demomode != 'ON')
{
// SELECT THE LAST LOGGED IN FIELD
$query = " SELECT tickets_users_newlogin
FROM tickets_users
WHERE tickets_users_username = '".$_SESSION['stu_username']."'";
$result = mysqli_query($dbcon, $query);
$row = mysqli_fetch_array($result);
// UPDATE THE NEW LOGGED IN FIELD IN THE USER ACCOUNT
$query = " UPDATE tickets_users
SET
tickets_users_newlogin = '".time()."',
tickets_users_lastlogin = '".$row['0']."'
WHERE tickets_users_username = '".$_SESSION['stu_username']."'";
$result = mysqli_query($dbcon, $query);
}
?>
<meta http-equiv="refresh" content="0;url=<?php echo htmlspecialchars($_SERVER['PHP_SELF']) ?>" />
<?php
}
ELSE
{
?>
<table width="<?php echo $maintablewidth ?>" cellspacing="1" cellpadding="1" class="boxborder" align="<?php echo $maintablealign ?>">
<tr>
<td class="text">
<?php echo $text_loginpage ?>
<input type="button" value="<?php echo $text_loginback ?>" onclick="history.back()" />
</td>
</tr>
</table>
<?php
}
}
ELSE
{
?>
<form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']) ?>?action=Login&sub=verify" method="post">
<table width="<?php echo $maintablewidth ?>" cellspacing="1" cellpadding="1" class="boxborder" align="<?php echo $maintablealign ?>">
<tr>
<td class="text" align="center"><br />
<?php echo $text_username ?>: <input name="username" size="20"
<?php
IF (isset($_COOKIE['demomode']) && $demomode == 'ON')
{
echo 'value="demo"';
}
?>
/> <?php echo $text_password ?>: <input type="password" name="password" size="20"
<?php
IF (isset($_COOKIE['demomode']) && $demomode == 'ON')
{
echo 'value="demo"';
}
?>
/> <input type="submit" name="form" value="<?php echo $text_login ?>" /><br /><br />
</td>
</tr>
</table>
</form>
<?php
}
}
// DEAL WITH THE RESEND REQUESTS
IF ($_GET['action'] == 'Resend')
{
IF (isset($_GET['sub']))
{
$query = " SELECT tickets_users_name, tickets_users_username, tickets_users_password
FROM tickets_users
WHERE tickets_users_email = '".$_POST['email']."'";
$result = mysqli_query($dbcon, $query);
IF (mysqli_num_rows($result) > '0')
{
$row = mysqli_fetch_array($result);
// OUTGOING EMAIL MESSAGE TO USERS WHO REQUEST RESEND DETAILS
$message = "Dear ".$row['tickets_users_name']."\n\n";
$message .= "Below are the requested Account Details.\n";
$message .= "Username: ".$row['tickets_users_username']."\n";
$message .= "Password: ".$row['tickets_users_password']."\n\n";
$message .= "Kind Regards\n";
$message .= "Customer Care at ".$socketfromname."\n";
?>
<table width="<?php echo $maintablewidth ?>" cellspacing="1" cellpadding="1" class="boxborder" align="<?php echo $maintablealign ?>">
<tr>
<td class="text"><?php echo SendMail($_POST['email'], $row['tickets_users_name'], 'Account Details Request', $message) ?></td>
</tr>
</table>
<?php
}
ELSE
{
?>
<table width="<?php echo $maintablewidth ?>" cellspacing="1" cellpadding="1" class="boxborder" align="<?php echo $maintablealign ?>">
<tr>
<td class="text"><?php echo $text_resenderror ?><input type="button" value="<?php echo $text_resendback ?>" onclick="history.back()" /></td>
</tr>
</table>
<?php
}
}
ELSE
{
?>
<table width="<?php echo $maintablewidth ?>" cellspacing="1" cellpadding="1" class="boxborder" align="<?php echo $maintablealign ?>">
<tr>
<td class="text"><?php echo $text_resendpage ?></td>
</tr>
</table><br />
<form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']) ?>?action=Resend&sub=verify" method="post">
<table width="300" cellspacing="1" cellpadding="1" class="boxborder" align="center">
<tr>
<td width="100%" class="boxborder text"><?php echo $text_email ?>:</td>
<td class="boxborder"><input name="email"
<?php
IF (isset($_POST['email']))
{
?>
value="<?php echo $_POST['email'] ?>"
<?php
}
?>
size="42" /></td>
</tr>
</table>
<table width="300" cellspacing="1" cellpadding="1" align="center">
<tr>
<td align="right"><input type="submit" value="<?php echo $text_submit ?>" /></td>
</tr>
</table>
</form>
<?php
}
}
// DEAL WITH THE USER SELF REGISTRY OPTIONS
IF ($_GET['action'] == 'Register')
{
IF (isset($_GET['sub']) && $allowreg == 'ON')
{
IF ($_POST['name'] == '' || !eregi('^[0-9a-z]{6,16}$', $_POST['username']) || !eregi('^[0-9a-z]{6,16}$', $_POST['password']) || $_POST['email'] == '' || !ereg('^..*\@.+\..+[A-Za-z0-9]$', $_POST['email']))
{
?>
<table width="<?php echo $maintablewidth ?>" cellspacing="1" cellpadding="1" class="boxborder" align="<?php echo $maintablealign ?>">
<tr>
<td class="text"><?php echo $text_regpageerr ?>
<input type="button" value="<?php echo $text_regpagback ?>" onclick="history.back()" />
</td>
</tr>
</table>
<?php
}
ELSE
{
// TEST FOR DUPLICATE USERNAME
$query = " SELECT tickets_users_id
FROM tickets_users
WHERE tickets_users_username = '".$_POST['username']."'
LIMIT 0,1";
$result = mysqli_query($dbcon, $query);
IF (mysqli_num_rows($result) <= '0')
{
$query = " INSERT INTO tickets_users
SET
tickets_users_name = '".$_POST['name']."',
tickets_users_username = '".$_POST['username']."',
tickets_users_password = '".$_POST['password']."',
tickets_users_email = '".$_POST['email']."'";
IF ($result = mysqli_query($dbcon, $query))
{
// REGISTRATION EMAIL
$message = 'Dear '.$_POST['name']."\n\n";
$message .= "Thank you for registering.\n";
$message .= 'Username: '.$_POST['username']."\n";
$message .= 'Password: '.$_POST['password']."\n";
$message .= 'Email: '.$_POST['email']."\n\n";
$message .= "Kind Regards\n";
$message .= 'Customer Care at '.$socketfromname."\n";
$msg = $text_regconf.SendMail($_POST['email'], $_POST['name'], $text_regsubject, $message);
}
}
ELSE
{
$msg = $text_regusererr.'<input type="button" value="'.$text_regpagback.'" onclick="history.back()" />';
}
?>
<table width="<?php echo $maintablewidth ?>" cellspacing="1" cellpadding="1" class="boxborder" align="<?php echo $maintablealign ?>">
<tr>
<td class="text"><?php echo $msg ?></td>
</tr>
</table><br />
<?php
}
}
ELSE
{
?>
<table width="<?php echo $maintablewidth ?>" cellspacing="1" cellpadding="1" class="boxborder" align="<?php echo $maintablealign ?>">
<tr>
<td class="text"><?php echo $text_regpage ?></td>
</tr>
</table><br />
<form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']) ?>?action=Register&sub=verify" method="post">
<table width="300" cellspacing="1" cellpadding="1" class="boxborder" align="center">
<tr>
<td class="boxborder text"><?php echo $text_regname ?></td>
<td class="boxborder"><input name="name" size="35" /></td>
</tr>
<tr>
<td class="boxborder text"><?php echo $text_reguser ?></td>
<td class="boxborder"><input name="username" size="35" /></td>
</tr>
<tr>
<td class="boxborder text"><?php echo $text_regpass ?></td>
<td class="boxborder"><input type="password" name="password" size="35" /></td>
</tr>
<tr>
<td width="100%" class="boxborder text"><?php echo $text_regemail ?></td>
<td class="boxborder"><input name="email" size="35" /></td>
</tr>
</table>
<table width="300" cellspacing="0" cellpadding="2" align="center">
<tr>
<td align="right"><input type="submit" value="<?php echo $text_regsubmit ?>" /></td>
</tr>
</table>
</form>
<?php
}
}
include_once ('footer.php');
Exit();
}
#############################################################################################
################ MAKE SURE THE RIGHT CASEID IS ENTERED OR DEFAULT TO HOME ID ################
#############################################################################################
IF (!isset($_GET['caseid']) || $_GET['caseid'] == '' || $_GET['caseid'] != 'home' && $_GET['caseid'] != 'view' && $_GET['caseid'] != 'NewTicket')
{
$_GET['caseid'] = 'home';
}
#############################################################################################
########################### DISPLAY THE PAGE TITLE AND NAVIGATION ###########################
#############################################################################################
?>
<form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']) ?>?caseid=home" method="post">
<table width="<?php echo $maintablewidth ?>" cellspacing="1" cellpadding="1" align="<?php echo $maintablealign ?>">
<tr>
<td><a href="<?php echo htmlspecialchars($_SERVER['PHP_SELF']) ?>"><img src="images/support_tickets_logo.gif" width="83" height="61" title="Triangle Solutions PHP Support Tickets" alt="Triangle Solutions PHP Support Tickets" vspace="2" border="0" /></td>
<td valign="bottom" align="right" class="text" style="padding:2px">Search Tickets:
<input name="keywords" size="24" onfocus="javascript:this.value=''" value="Search Ticket Subject" />
<input type="submit" value="Go" />
</td>
</tr>
</table>
</form>
<table width="<?php echo $maintablewidth ?>" cellspacing="1" cellpadding="1" class="boxborder" align="<?php echo $maintablealign ?>">
<tr>
<td class="boxborder text" bgcolor="<?php echo $background ?>"><a href="<?php echo htmlspecialchars($_SERVER['PHP_SELF']) ?>"><?php echo $text_titlelink ?></a> - <?php echo $text_title ?></td>
<td class="boxborder list-menu" width="15%"><a href="<?php echo htmlspecialchars($_SERVER['PHP_SELF']) ?>?caseid=NewTicket"><?php echo $text_titlereq ?></a></td>
<td class="boxborder list-menu" width="15%"><a href="<?php echo htmlspecialchars($_SERVER['PHP_SELF']) ?>?caseid=home&order=Open"><?php echo $text_titleope ?></a></td>
<td class="boxborder list-menu" width="15%"><a href="<?php echo htmlspecialchars($_SERVER['PHP_SELF']) ?>?caseid=home&order=Closed"><?php echo $text_titleclo ?></a></td>
<td class="boxborder list-menu" width="10%"><a href="<?php echo htmlspecialchars($_SERVER['PHP_SELF']) ?>?caseid=home&action=Logout"><?php echo $text_titlelog ?></a></td>
</tr>
</table>
<?php
#############################################################################################
############## HOME DEFAULT CASE THIS DEALS WITH THE DISPLAYING OF ANY TICKETS ##############
#############################################################################################
SWITCH ($_GET['caseid'])
{
CASE 'home':
IF (!isset($_GET['order']) && !isset($_POST['keywords']))
{
$_GET['order'] = 'Open';
}
// PROCESS THE FUNCTIONS WHEN THE CHECKBOXES ARE CHECKED - IE OPEN CLOSE TICKET
IF (isset($_POST['status']))
{
IF (isset($_POST['ticket']))
{
FOREACH ($_POST['ticket'] AS $ticketid)
{
$query = " UPDATE tickets_tickets
SET tickets_status = '".$_POST['status']."'
WHERE tickets_id = '".$ticketid."'";
IF (mysqli_query($dbcon, $query))
{
$msg = 'Ticket '.$_POST['status'];
}
ELSE
{
$msg = 'This could not be done at this time';
}
}
}
ELSE
{
$msg = 'Please select a Ticket.';
}
?>
<table width="<?php echo $maintablewidth ?>" cellspacing="1" cellpadding="1" class="boxborder" align="<?php echo $maintablealign ?>">
<tr bgcolor="#AACCEE">
<td class="text"><?php echo $msg ?></td>
</tr>
</table>
<?php
}
// QUERY TO SELECT THE TICKETS LISTING - THIS CAN BE CHANGED TO OPEN OR CLOSED ONLY
// DEPENDING ON THE LINK THAT IS HIT ON THE NAV BAR - HOME PAGE DEFAULTS TO BOTH.
$query = " SELECT tickets_id, tickets_subject, tickets_timestamp, tickets_status,
tickets_status_name, tickets_status_color, tickets_categories_name
FROM tickets_tickets a, tickets_status b, tickets_categories c
WHERE a.tickets_username = '".$_SESSION['stu_username']."'
AND a.tickets_child = '0'
AND a.tickets_urgency = b.tickets_status_id
AND a.tickets_category = c.tickets_categories_id";
IF (isset($_GET['order']))
{
$query .= " AND a.tickets_status = '".$_GET['order']."'";
$addon = '&order='.$_GET['order'];
}
ELSEIF (isset($_POST['keywords']))
{
$query .= " AND a.tickets_subject LIKE '%".$_POST['keywords']."%'";
$addon = '';
}
$query .= ' ORDER BY a.tickets_id DESC, a.tickets_timestamp DESC';
// SET PAGE NUMBER IF NONE SPECIFIED ASSUME IT IS EQUAL TO ONE
$result = mysqli_query($dbcon, $query);
$totaltickets = mysqli_num_rows($result);
$per_page = $ticket_display;
IF (!isset($_GET['display']))
{
$_GET['display'] = '1';
}
$prev_page = $_GET['display'] - 1;
$next_page = $_GET['display'] + 1;
// SET UP PAGE
$page_start = ($per_page * $_GET['display']) - $per_page;
$num_rows = $totaltickets;
IF ($num_rows <= $per_page)
{
$num_pages = '1';
}
ELSEIF (($num_rows % $per_page) == '0')
{
$num_pages = ($num_rows / $per_page);
}
ELSE
{
$num_pages = ($num_rows / $per_page) + 1;
}
$num_pages = (int) $num_pages;
// DISPLAY RESULTS
$query = $query . " LIMIT $page_start, $per_page";
$result = mysqli_query($dbcon, $query);
?>
<div style="padding-top:5px"></div>
<?php
IF ($totaltickets > '0')
{
ShowPaging( $_SERVER['PHP_SELF'].'?'.htmlentities($_SERVER['QUERY_STRING']),
$prev_page,
$next_page,
$num_pages,
$_GET['display']
);
}
?>
<table width="<?php echo $maintablewidth ?>" cellspacing="1" cellpadding="1" class="boxborder" align="<?php echo $maintablealign ?>">
<tr bgcolor="<?php echo $background ?>">
<td class="boxborder text"><?php echo $text_listtitle ?>
<?php
IF ($totaltickets > '0')
{
echo ' '.$totaltickets.' - '.$text_listmsg;
}
ELSE
{
echo ' 0';
}
?>
</td>
</tr>
</table>
<?php
IF ($totaltickets > '0')
{
?>
<script language="javascript" type="text/javascript">
<!--
function check_all()
{
for (var c = 0; c < document.myform.elements.length; c++)
{
if (document.myform.elements[c].type == 'checkbox')
{
if(document.myform.elements[c].checked == true)
{
document.myform.elements[c].checked = false;
}
else
{
document.myform.elements[c].checked = true;
}
}
}
}
// -->
</script>
<form name="myform" action="index.php?caseid=home<?php echo $addon ?>" method="post">
<table width="<?php echo $maintablewidth ?>" cellspacing="1" cellpadding="1" class="boxborder" align="<?php echo $maintablealign ?>">
<tr align="center" bgcolor="<?php echo $background ?>">
<td class="boxborder text" onclick="check_all();" style="cursor:pointer"><b><u>All</u></b></td>
<td class="boxborder text"><b>Ticket ID</b></td>
<td class="boxborder text"><b>Replies</b></td>
<td class="boxborder text"><b><?php echo $text_listsub ?></b></td>
<td class="boxborder text"><b>Date / Time</b></td>
<td class="boxborder text"><b><?php echo $text_listurg ?></b></td>
<td class="boxborder text"><b>Department</b></td>
<td class="boxborder text"><b><?php echo $text_liststa ?></b></td>
</tr>
<?php
// LOOP THROUGH THE REQUESTS FOR THE USERS ACCOUNT
WHILE ($row = mysqli_fetch_array($result))
{
// QUERY TO GET THE AMOUNT OF REPLIES TO A CERTAIN TICKET AND DATE OF LAST ENTRY
$queryA = " SELECT COUNT(*) AS ticket_count, MAX(tickets_timestamp) AS date, tickets_users_lastlogin
FROM tickets_tickets a, tickets_users b
WHERE tickets_child = '".$row['tickets_id']."'
AND a.tickets_username = b.tickets_users_username
GROUP BY tickets_child";
$resultA = mysqli_query($dbcon, $queryA);
$rowA = mysqli_fetch_array($resultA);
IF ($rowA['ticket_count'] <= '0')
{
$rowA['ticket_count'] = '0';
}
?>
<tr align="center" bgcolor="<?php echo UseColor() ?>">
<td class="boxborder"><input type="checkbox" name="ticket[]" value="<?php echo $row['tickets_id'] ?>" /></td>
<td class="boxborder list-menu"><a href="<?php echo htmlspecialchars($_SERVER['PHP_SELF']) ?>?caseid=view&ticketid=<?php echo $row['tickets_id'] ?>"><?php echo $row['tickets_id'] ?></a></td>
<td class="boxborder text">[<?php echo $rowA['ticket_count'] ?>]
<?php
IF (isset($rowA['date']) && ($rowA['date'] > $rowA['tickets_users_lastlogin']))
{
echo '<img src="images/new_reply.gif" border="0" />';
}
?>
</td>
<td class="boxborder text"><?php echo $row['tickets_subject'] ?></td>
<td class="boxborder text"><?php echo date($dformat, $row['tickets_timestamp']).' '.date('H:i:s', $row['tickets_timestamp']) ?></td>
<td class="boxborder text" bgcolor="#<?php echo $row['tickets_status_color'] ?>"><?php echo $row['tickets_status_name'] ?></td>
<td class="boxborder text"><?php echo $row['tickets_categories_name'] ?></td>
<td class="boxborder text">
<?php
IF ($row['tickets_status'] == 'Closed')
{
echo '<span style="color:#FF0000">';
}
ELSE
{
echo '<span style="color:#000000">';
}
?>
<?php echo $row['tickets_status'] ?></span></td>
</tr>
<?php
}
?>
<tr>
<td colspan="8">
<select name="status">
<option value="Open">Open</option>
<option value="Closed">Closed</option>
</select>
<input type="submit" name="sub" value="Go">
</td>
</tr>
</table>
</form>
<?php
ShowPaging( $_SERVER['PHP_SELF'].'?'.htmlentities($_SERVER['QUERY_STRING']),
$prev_page,
$next_page,
$num_pages,
$_GET['display']
);
}
// IF THERE ARE NO TICKETS TO SHOW THEN PLACE A DEFAULT MESSAGE
ELSE
{
IF (isset($_POST['keywords']))
{
$msg = $text_searcherr;
}
ELSE
{
$msg = $text_listnon;
}
?>
<table width="<?php echo $maintablewidth ?>" cellspacing="1" cellpadding="1" class="boxborder" align="<?php echo $maintablealign ?>">
<tr>
<td class="text"><?php echo $msg ?></td>
</tr>
</table>
<?php
}
BREAK;
#############################################################################################
######## VIEW A TICKET - VALID IF THE USER CLICKS LINK FROM SEARCH OR HOME LISTINGS #########
#############################################################################################
CASE 'view':
// CLOSE OR REOPEN A TICKET
IF (isset($_GET['closesub']))
{
$query = " UPDATE tickets_tickets
SET
tickets_status = '".$_GET['closesub']."'
WHERE tickets_id = '".$_GET['ticketid']."'";
IF (mysqli_query($dbcon, $query))
{
$msg = 'Ticket '.$_GET['closesub'];
}
ELSE
{
$msg = 'This could not be done at this time';
}
?>
<table width="<?php echo $maintablewidth ?>" cellspacing="1" cellpadding="1" class="boxborder" align="<?php echo $maintablealign ?>">
<tr bgcolor="#AACCEE">
<td class="text"><?php echo $msg ?></td>
</tr>
</table>
<?php
}
// INSERT THE TICKET INTO THE DATABASE AND SEND THE EMAIL
IF (isset($_GET['sub']))
{
IF ($_POST['message'] == '')
{
$msg = 'Please complete all the fields';
}
ELSE
{
$_POST['postsubject'] = Clean_It($_POST['postsubject']);
$_POST['posturgency'] = Clean_It($_POST['posturgency']);
$_POST['postcategory'] = Clean_It($_POST['postcategory']);
$_GET['ticketid'] = Clean_It($_GET['ticketid']);
$_POST['message'] = Clean_It($_POST['message']);
$urgency = explode('|', $_POST['posturgency']);
$category = explode('|', $_POST['postcategory']);
$query = " INSERT INTO tickets_tickets
SET
tickets_username = '".$_SESSION['stu_username']."',
tickets_subject = '".$_POST['postsubject']."',
tickets_timestamp = '".time()."',
tickets_urgency = '".$urgency['0']."',
tickets_category = '".$category['0']."',
tickets_child = '".$_GET['ticketid']."',
tickets_question = '".addslashes($_POST['message'])."'";
IF ($result = mysqli_query($dbcon, $query))
{
// CHECK THE FILE ATTACHMENT AND DISPLAY ANY ERRORS
IF ($allowattachments == 'TRUE' && (!isset($_COOKIE['demomode']) || $demomode != 'ON'))
{
FileUploadsVerification("$_FILES(userfile)", mysqli_insert_id($dbcon));
}
// EMAIL ADMINISTRATOR THE TICKET NOTIFICATION
$message = "Ticket ID:\t ".$_GET['ticketid']."\n";
$message .= "Name:\t\t ".$_POST['name']."\n";
$message .= "Subject:\t ".$_POST['postsubject']."\n";
$message .= "Urgency:\t ".$urgency['1']."\n";
$message .= "Department:\t ".$category['1']."\n";
$message .= "Post Date:\t ".date($dformatemail)."\n";
$message .= "----------------------------------------------------------------------\n";
$message .= "Message:\n";
$message .= stripslashes($_POST['message'])."\n";
$message .= "----------------------------------------------------------------------\n\n\n";
$message .= "Previous Thread Messages (Latest First):\n";
$message .= "----------------------------------------------------------------------\n";
// LOOP THROUGH THE PREVIOUS MESSAGES AND ADD DATA REGARDING QUESTION TIME AND ATTACHMENT
FOR ($i = COUNT($_POST['ticketquestion']) - 1; $i >= '0'; $i--)
{
$message .= $_POST['postedby'][$i]." - ".$_POST['postdate'][$i]."\n";
$message .= stripslashes($_POST['ticketquestion'][$i]);
IF (isset($_POST['attachment'][$i]) && $_POST['attachment'][$i] != '')
{
$message .= "\nAttachment - ".$_POST['attachment'][$i];
}
$message .= "\n----------------------------------------------------------------------\n";
}
$message .= "\nRegards\n\n";
$message .= $socketfromname;
?>
<table width="<?php echo $maintablewidth ?>" cellspacing="1" cellpadding="1" class="boxborder" align="<?php echo $maintablealign ?>">
<tr>
<td class="text">
<?php
echo SendMail( $_POST['email'],
$_POST['name'],
'Response To Ticket '.$_GET['ticketid'].' Written By - '.$_SESSION['stu_username'],
$message);
IF ($emailuser == 'TRUE')
{
echo SendMail( $_POST['email'],
$_POST['name'],
'Response To Ticket '.$_GET['ticketid'].' Written By - '.$_SESSION['stu_username'],
$message,
'1');
}
?>
</td>
</tr>
</table>
<?php
$refresh = 'TRUE';
}
}
}
// QUERY TO GET THE TICKET IN QUESTION AND ANY REPLIES TO THAT TICKET
$query = " SELECT tickets_id, tickets_subject, tickets_timestamp, tickets_status, tickets_name, tickets_email, tickets_admin, tickets_child, tickets_question, tickets_status_id, tickets_status_name, tickets_status_color, tickets_categories_id, tickets_categories_name
FROM tickets_tickets a, tickets_status b, tickets_categories c
WHERE (a.tickets_id = '".$_GET['ticketid']."'
OR tickets_child = '".$_GET['ticketid']."')
AND a.tickets_urgency = b.tickets_status_id
AND a.tickets_category = c.tickets_categories_id
AND tickets_username = '".$_SESSION['stu_username']."'
ORDER BY tickets_id ASC";
$result = mysqli_query($dbcon, $query);
$totaltickets = mysqli_num_rows($result);
$row = mysqli_fetch_array($result);
// PRINT OUT THE TABLES TO HOLD THE TICKET INFO - REPLY SUBMISSION AND TOPIC AND ANY REPLIES AND ATTACHMENTS
?>
<form enctype="multipart/form-data" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']) ?>?caseid=view&ticketid=<?php echo $_GET['ticketid'] ?>&sub=add" method="post">
<table width="<?php echo $maintablewidth ?>" cellspacing="1" cellpadding="1" class="boxborder" align="<?php echo $maintablealign ?>">
<tr>
<td class="boxborder" width="50%" valign="top" style="padding-top:5px">
<table width="97%" cellspacing="1" cellpadding="1" class="boxborder" align="center">
<tr>
<td bgcolor="#AABBDD" class="boxborder text"><b>Ticket #<?php echo $_GET['ticketid'] ?> Information</b></td>
<?php
IF ($row['tickets_status'] == 'Open')
{
?>
<td class="boxborder list-menu" width="30%"><a href="<?php echo htmlspecialchars($_SERVER['PHP_SELF']) ?>?caseid=view&ticketid=<?php echo $_GET['ticketid'] ?>&closesub=Closed">Close Ticket</a></td>
<?php
}
ELSE
{
?>
<td class="boxborder list-menu"" width="30%"><a href="<?php echo htmlspecialchars($_SERVER['PHP_SELF']) ?>?caseid=view&ticketid=<?php echo $_GET['ticketid'] ?>&closesub=Open">Reopen Ticket</a></td>
<?php
}
?>
</tr>
</table>
<table width="97%" cellspacing="1" cellpadding="1" class="boxborder" align="center">
<tr>
<td bgcolor="#EEEEEE" class="boxborder text"><b>Account:</b></td>
<td class="boxborder text"><?php echo $_SESSION['stu_username'] ?></td>
</tr>
<tr>
<td bgcolor="#EEEEEE" class="boxborder text"><b>Name:</b></td>
<td class="boxborder text"><?php echo $row['tickets_name'] ?></td>
</tr>
<tr>
<td bgcolor="#EEEEEE" class="boxborder text"><b>Email:</b></td>
<td class="boxborder text"><?php echo $row['tickets_email'] ?></td>
</tr>
<tr>
<td bgcolor="#EEEEEE" class="boxborder text"><b>Subject:</b></td>
<td class="boxborder text"><?php echo $row['tickets_subject'] ?></td>
</tr>
<tr>
<td bgcolor="#EEEEEE" class="boxborder text"><b>Department:</b></td>
<td class="boxborder text"><?php echo $row['tickets_categories_name'] ?></td>
</tr>
<tr>
<td bgcolor="#EEEEEE" class="boxborder text"><b>Urgency:</b></td>
<td class="boxborder text" bgcolor="#<?php echo $row['tickets_status_color'] ?>"><b><?php echo $row['tickets_status_name'] ?></b></td>
</tr>
<tr>
<td bgcolor="#EEEEEE" class="boxborder text"><b>Status:</b></td>
<td class="boxborder text">
<?php
IF ($row['tickets_status'] == 'Closed')
{
echo '<span style="color:#FF0000">';
}
ELSE
{
echo '<span style="color:#000000">';
}
echo $row['tickets_status'];
?>
</span></td>
</tr>
</table><div style="padding-top:5px"></div>
<?php
IF ($row['tickets_status'] != 'Closed')
{
?>
<table width="97%" cellspacing="1" cellpadding="1" class="boxborder" align="center">
<tr bgcolor="#AABBDD">
<td class="boxborder text"><b>Respond</b></td>
</tr>
<tr>
<td align="center"><textarea name="message" cols="80" rows="10"></textarea></td>
</tr>
<tr>
<td align="right">
<input type="hidden" name="name" value="<?php echo $row['tickets_name'] ?>" />
<input type="hidden" name="email" value="<?php echo $row['tickets_email'] ?>" />
<input type="hidden" name="postsubject" value="<?php echo $row['tickets_subject'] ?>" />
<input type="hidden" name="posturgency" value="<?php echo $row['tickets_status_id'] ?>|<?php echo $row['tickets_status_name'] ?>" />
<input type="hidden" name="postcategory" value="<?php echo $row['tickets_categories_id'] ?>|<?php echo $row['tickets_categories_name'] ?>" />
<input type="submit" value="Submit" />
</td>
</tr>
</table><div style="padding-top:5px"></div>
<?php
// ALLOW THE USERS TO ATTACH A FILE TO THE TICKET
IF ($allowattachments == 'TRUE' && (!isset($_COOKIE['demomode']) || $demomode != 'ON'))
{
FileUploadForm();
}
}
?>
<br /></td>
<td width="50%" valign="top" style="padding-top:5px">
<?php
$j = '0';
$result = mysqli_query($dbcon, $query);
// LOOP THROUGH THE QUESTIOSN AND RESPONSES TO THIS QUESTION
WHILE ($row = mysqli_fetch_array($result))
{
?>
<table width="97%" cellspacing="1" cellpadding="1" class="boxborder" align="center">
<tr bgcolor="#AABBDD">
<td class="boxborder text"><b>
<?php
IF ($j == '0')
{
echo ' Dialog Question';
}
ELSE
{
echo ' Response '.$j;
}
?>
</b></td>
<td class="boxborder text" bgcolor="#AACCDD" width="50%" align="right"><?php echo date($dformat.' H:i:s', $row['tickets_timestamp']) ?></td>
</tr>
<?php
IF ($row['tickets_admin'] == 'Admin')
{
$bgcolor = '#FFF000';
}
ELSE
{
$bgcolor = '#AACCEE';
}
?>
<tr>
<td class="boxborder text" colspan="2"><?php echo nl2br($row['tickets_question']) ?></td>
</tr>
<tr bgcolor="<?php echo $bgcolor ?>">
<td class="boxborder text">Posted By: <?php echo $row['tickets_admin'] ?></td>
<td class="text">
<?php
// SCAN THE UPLOAD DIRECTORY FOR ATTACHMENTS TO THIS POST IF ATTACHMENTS ARE OFF THEN THIS WONT DO IT
IF ($allowattachments == 'TRUE')
{
$d = dir($uploadpath);
WHILE (false !== ($files = $d -> read()))
{
$files = explode('.', $files);
IF ($files['0'] == $row['tickets_id'])
{
?>
<b>Attachment:</b> <?php echo $files['0'] ?>.<?php echo $files['1'] ?>
<a href="<?php echo $relativepath.$files['0'] ?>.<?php echo $files['1'] ?>" target="_blank">
<img src="images/download.gif" width="13" height="13" align="absmiddle" border="0" /></a>
<?php
$filename = $files['0'].'.'.$files['1'];
?>
<input type="hidden" name="attachment[<?php echo $_GET['ticketid'] - 1 ?>]" value="<?php echo $filename ?>" />