-
Notifications
You must be signed in to change notification settings - Fork 0
/
bff_codes.php
44 lines (37 loc) · 1.05 KB
/
bff_codes.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
<?php
require 'config.php';
function log_access($name) {
$myFile = "access.log";
$fh = fopen($myFile, 'a') or die;
$stringData = date('c') . ': ' . $name . "\n";
fwrite($fh, $stringData);
fclose($fh);
}
$code = $_REQUEST['Digits'];
# Time lock
if ($overnightStart && $overnightEnd) {
$date = new DateTime("now", new DateTimeZone($timezone));
$day = $date->format('Y-m-d');
$time = $date->format('H:i');
if (($time > $overnightStart) && ($time < $overnightEnd)){
log_access('Out of Hours: ' . ($codeList[$code] ?? 'Unknown Code'));
header('Location: return_outoftime.php');
die;
}
}
# Dial 0 for operator, if $operatorPhoneNumber is set
if ($code == '0' && $operatorPhoneNumber) {
log_access('Code 0: Called Operator');
header('Location: return_operator.php');
die;
}
# Successful code
if (array_key_exists($code, $codeList)) {
log_access('Code Accepted: ' . $codeList[$code]);
header('Location: return_open.php');
die;
}
# Code does not match
log_access('Code Rejected: ' . ($code ?? 'No Code Provided'));
header('Location: return_failed.php');
die;