/
scan.php
61 lines (46 loc) · 1.47 KB
/
scan.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
<?php
require_once('inc/bootstrap.php');
$scanner = new scanner();
$ticket = new ticket();
$returnCodes = array(
0 => 'Invalid Ticket ID',
1 => 'Duplicate Scan',
2 => 'Missing username',
3 => 'Success (cleared to enter)'
);
$col = TICKET_COL;
$user = filter_input(INPUT_GET, 'user', FILTER_SANITIZE_SPECIAL_CHARS);
$barcode = $ticket->sanitizeBarcode(filter_input(INPUT_POST, 'ticket', FILTER_SANITIZE_SPECIAL_CHARS));
if (!$user){
$return = json_encode(array('message'=>"No username specified", 'code'=>2));
$scanner->logEvent("NU","Tried to scan without a username");
return;
}
if ($barcode){
$return = $ticket->scanTicket($barcode,$user);
} else {
$return = json_encode(array('message'=>"Barcode cannot be empty", 'code'=>2));
}
if (isset($_GET['barcode']) && is_admin()){
$return = $ticket->scanTicket($_GET['barcode'],$_GET['user']);
}
if (isset($_GET['format'])) :?>
<?php require_once('header.php'); ?>
<div class="jumbotron">
<h1>Ready to scan</h1>
<input id="username" name="username" placeholder="Who are you" />
<input id="ticket" name="ticket" placeholder="Barcode" />
</div>
<div class="panel panel-default hide" id="ticketInfo">
<div class="panel-heading">
<h3 class="panel-title">Duplicate Ticket Info</h3>
</div>
<div class="panel-body">
</div>
</div>
</div>
<?php require_once('footer.php'); ?>
<script>success(<?php echo $return;?>);</script>
<?php else :
echo $return;
endif; ?>