-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.php
150 lines (115 loc) · 4.22 KB
/
config.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
<?php
mb_internal_encoding("UTF-8");
mb_http_output('UTF-8');
mb_http_input('UTF-8');
mb_regex_encoding('UTF-8');
//echo mb_internal_encoding();
//echo mb_http_output();
error_reporting(~E_ALL & ~E_NOTICE & ~E_WARNING);
///////////////
// DB INFO
$server = "localhost"; // db server 127.0.0.1 may also work, if you have a dedicated server then use its local IP address.
$database_name = ""; // db name
$database_username = ""; // db username
$database_password = ""; // db password
// END DB INFO
///////////////
//////////////
// BEGIN TABLE CONVERSIONS
$sqltable_devices_inventory = "devices_inventory";
$sqltable_errorlog = "errorlog";
//////////////
///////////////////////////
// SITE CONFIGURATION STUFF
///////////////////////////
//site name information
$hostsitename = "MyPartsBin-Open Source";
////////////////////////////
// URL STUFF
///////////////////////////
// PAGES
/////////
// Main page
$mainpageurl = "index.php"; // may need to change this to be just /index.php
// devices Inventory page
$devicesinventorypageurl = "devicesinventory.php";
// Export Inventory Page.
$exportinventoryurl = "exportinventory.php?export=1";
// Import Inventory Page.
$importinventoryurl = "importinventory.php";
// SQL Errors page.
$sqlerrorlogurl = "sqlerrorlog.php";
///////////////////////
// DATE AND TIME STUFF
//////////////////////
// Time and date display format (Fri 3:00:48pm 14th Apr 2006)
$datetimeformat = "g:i:sa D jS M Y";// (THIS MUST NOT BE CHANGED !!
// File export date format
$exportdatetimeformat = "g:ia_D_jS_M_Y";// (THIS MUST NOT BE CHANGED !!
// Site time zone
$offsetzone = 12; // NZ = +12, can change this to suit your location if required.
$zone = 3600*$offsetzone;
// Get current year (for copyright notice)
$currentyear = gmdate("Y", time() + $zone);
////////////////
// BEGIN CODE NZ Daylight Savings Time (automatic)
$getmonth = gmdate("n", time() + $zone); // get current month
if ($getmonth >= 10 || $getmonth <= 3){ // if months are well within DST time, than just add DST
$zone = $zone +3600;
}
else{ // work out whether or not DST should be added
$currenthour = gmdate("G", time() + $zone); // get current hour of the day, in 24 hour format
$getday = gmdate("j", time() + $zone); // get current date (day)
$getweekday = gmdate("D", time() + $zone); // get current weekday
$daycheck = array("Sun","Sat","Fri","Thu","Wed","Tue","Mon");
$calcday = 30 - $getday; // work out how many days are left in month (for Sept)
$calcday2 = 7 - $getday; // work out how many days have gone in month (for April)
if ($getmonth == 9 && $getday >= 24){ // Find last Sunday of Sept. (beginning of DST is last Sunday in Sept)
for ($i = 0;$i < 7; $i++){
if ($getweekday == $daycheck[$i]){
if (($calcday < $i) || ($calcday == 0 && $getweekday != "Sun") || ($currenthour >= 2 && $getweekday == "Sun")){
$zone = $zone +3600;
break;
}
}
}
}
if ($getmonth == 4 && $getday <= 7){ // Find first Sunday of April (ending of DST is first Sunday in April)
for ($i = 0;$i < 7; $i++){
if ($getweekday == $daycheck[$i]){
if (($calcday2 >= $i && $getweekday != "Sun") || ($currenthour <= 2 && $getweekday == "Sun")){
$zone = $zone +3600;
break;
}
}
}
}
}
/////////////
// get current time for use on all pages
$timestamp = time() + $zone;
// flag to ID that config file is loaded
$configloaded = 1;
if ($_SERVER['HTTP_X_FORWARDED_FOR']) {
if ($_SERVER['REMOTE_ADDR'] != $_SERVER['HTTP_X_FORWARDED_FOR']){
$ip = $_SERVER['REMOTE_ADDR'] . ", " . $_SERVER['HTTP_X_FORWARDED_FOR'];
}
else{
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
$ip = str_replace(", unknown", "", $ip); // remove "unknown" IP from variable
if (($ip == "") || ($ip == NULL)){
$ip = $_SERVER['REMOTE_ADDR'];
}
}
else {
$ip = $_SERVER['REMOTE_ADDR'];
}
$ip = trim($ip); // remove any whitespace at beginning and end.
$ip = mysqli_real_escape_string($ip); // block IP address SQL injection - can happen by user sent HTTP_X_FORWARDED_FOR headers.
// BEGIN CODE db connection and check
//make the connection to the database
$connection = @mysqli_connect($server, $database_username, $database_password,$database_name) or die(mysqli_error());
//$database = @mysqli_select_db($connection,$database_name) or die("UNABLE TO CONNECT TO DB");
///////
?>