forked from BoatrightTBC/timeclock
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheader_bootstrap.php
More file actions
90 lines (69 loc) · 2.58 KB
/
Copy pathheader_bootstrap.php
File metadata and controls
90 lines (69 loc) · 2.58 KB
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
<?php
/**
* Bootstrap-based drop-in replacement for header.php. Same connectivity/IP/
* timezone checks as header.php -- only the HTML output differs. Used by
* pages migrated to the new Bootstrap layout (see issue #40); header.php
* itself is untouched and still serves every page not yet migrated.
*/
include_once 'functions.php';
ob_start();
echo "<!doctype html>\n<html lang=\"en\">\n";
// grab the connecting ip address. //
$connecting_ip = get_ipaddress();
if (empty($connecting_ip)) {
return false;
}
// determine if connecting ip address is allowed to connect to PHP Timeclock //
if ($restrict_ips == "yes") {
for ($x = 0; $x < count($allowed_networks); $x++) {
$is_allowed = ip_range($allowed_networks[$x], $connecting_ip);
if (!empty($is_allowed)) {
$allowed = true;
}
}
if (!isset($allowed)) {
echo "You are not authorized to view this page.";
exit;
}
}
// connect to db and check for correct db version //
require_once 'lib/db.php';
$table = "dbversion";
// $db_prefix comes from config.inc.php, not user input -- same trusted-config
// concatenation pattern used throughout functions.php for table names, which
// can't be bound as query parameters.
$result = mysqli_query($GLOBALS["___mysqli_ston"], "SHOW TABLES LIKE '" . $db_prefix . $table . "'"); // NOSONAR
@$rows = mysqli_num_rows($result);
if ($rows == "1") {
$dbexists = "1";
} else {
$dbexists = "0";
}
// Same trusted-config table-name concatenation as above.
$db_version_result = mysqli_query($GLOBALS["___mysqli_ston"], "select * from " . $db_prefix . "dbversion"); // NOSONAR
while (@$row = mysqli_fetch_array($db_version_result)) {
@$my_dbversion = "" . $row["dbversion"] . "";
}
if (($use_client_tz == "yes") && ($use_server_tz == "yes")) {
echo 'Please reconfigure your config.inc.php file, you cannot have both $use_client_tz AND $use_server_tz set to \'yes\'';
exit;
}
echo "<head>\n";
echo "<meta charset=\"utf-8\">\n";
echo "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n";
if ($use_client_tz == "yes" && !isset($_COOKIE['tzoffset'])) {
include_once 'tzoffset.php';
echo "<meta http-equiv='refresh' content='0;URL=timeclock.php'>\n";
}
echo "<link rel='stylesheet' href='css/bootstrap.min.css'>\n";
echo "<link rel='stylesheet' href='css/bootstrap-theme.css'>\n";
// set refresh rate for each page //
if ($refresh == "none") {
echo "</head>\n";
} else {
echo "<meta http-equiv='refresh' content=\"$refresh;URL=timeclock.php\">\n";
echo "</head>\n";
}
setTimeZone();
?>
<body class="bg-light">