forked from andrew867/timeclock
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathheader.php
86 lines (66 loc) · 2.27 KB
/
header.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
<?php
include 'functions.php';
ob_start();
echo "<html>\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 anc check for correct db version //
@ $db = ($GLOBALS["___mysqli_ston"] = mysqli_connect($db_hostname, $db_username, $db_password));
if (!$db) {
echo "Error: Could not connect to the database. Please try again later.";
exit;
}
mysqli_select_db($GLOBALS["___mysqli_ston"], $db_name);
$table = "dbversion";
$result = mysqli_query($GLOBALS["___mysqli_ston"], "SHOW TABLES LIKE '" . $db_prefix . $table . "'");
@$rows = mysqli_num_rows($result);
if ($rows == "1") {
$dbexists = "1";
} else {
$dbexists = "0";
}
$db_version_result = mysqli_query($GLOBALS["___mysqli_ston"], "select * from " . $db_prefix . "dbversion");
while (@$row = mysqli_fetch_array($db_version_result)) {
@$my_dbversion = "" . $row["dbversion"] . "";
}
// include css and timezone offset//
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";
if ($use_client_tz == "yes") {
if (!isset($_COOKIE['tzoffset'])) {
include 'tzoffset.php';
echo "<meta http-equiv='refresh' content='0;URL=timeclock.php'>\n";
}
}
echo "<link rel='stylesheet' type='text/css' media='screen' href='css/default.css' />\n";
echo "<link rel='stylesheet' type='text/css' media='print' href='css/print.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 "<script language=\"javascript\" src=\"scripts/pnguin_timeclock.js\"></script>\n";
echo "</head>\n";
}
setTimeZone();
?>
<body>