-
Notifications
You must be signed in to change notification settings - Fork 0
/
DBCon.php
executable file
·121 lines (107 loc) · 3.17 KB
/
DBCon.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
<?php
/*
Copyright © 2009,2015,2022 Siggi Bjarnason.
Licensed under GNU GPL v3 and later. Check out LICENSE.TXT for details
or see <https://www.gnu.org/licenses/gpl-3.0-standalone.html>
Main connection file, handles DB connections and other initialization
*/
require_once("functions.php");
ini_set( "default_charset", "UTF-8" );
set_time_limit(30);
$DevEnvironment = getenv("DEVENV");
$ROOTPATH = "/";
$RefreshMin = 1;
$CompanyName = "SuperGeek";
$SupportEmail = "[email protected]";
$HomeURL = "https://supergeek.us";
$Copyright = "Siggi Bjarnason";
$DefExpire = 7;
$RefreshSec = $RefreshMin * 60;
$HeadImg ="ShareASecret.png";
$CSSName = "SiteStyle.css";
$ErrMsg = "We seem to be experiencing some technical difficulties, " .
"hopefully we'll have it resolved shortly.<br>" .
"If you have any questions please contact us at $SupportEmail";
# All Environment and secret vars are specified in ExtVars.php
# Follow instruction there on how to adjust.
require("ExtVars.php");
if($DBServerName == "" or $UID == "" or $PWD == "")
{
error_log("One or more of the required DB creds variable are blank");
error_log("Make sure database connections conf in DBCon.php are correct.");
ShowErrHead();
}
date_default_timezone_set("UTC");
$strRemoteIP = $_SERVER["REMOTE_ADDR"];
$strHost = $_SERVER["SERVER_NAME"];
if($_SERVER["SERVER_PORT"] != 80 and $_SERVER["SERVER_PORT"] != 443)
{
$strHost .= ":".$_SERVER["SERVER_PORT"];
}
$strScriptName = $_SERVER["SCRIPT_NAME"];
$strURI = $_SERVER["REQUEST_URI"];
$HeadAdd = "";
$strSiteLabel = "";
$DBError = "false";
$strHostNameParts = explode(".",$strHost);
$HostnamePartCount = count($strHostNameParts);
$OSEnv = "not used";
if($HostnamePartCount == 1)
{
$SiteType = "a";
}
else
{
$SiteType = $strHostNameParts[0];
}
$strURL = "Localhost/";
try
{
$dbh = new mysqli($DBServerName, $UID, $PWD, $DefaultDB);
}
catch(Exception $e)
{
error_log("Error while attempting to create a new mysqli client to $DBServerName.$DefaultDB using $UID and password that starts with "
. substr($PWD,0,3) . " " . $e->getMessage());
error_log("Make sure database connections in DBCon.php are correct.");
ShowErrHead();
}
$dbh->set_charset("utf8");
if($dbh->connect_errno)
{
error_log( "Failed to connect to $DBServerName.$DefaultDB using $UID and password that starts with " . substr($PWD,0,3) . " Error(" . $dbh->connect_errno . ") " . $dbh->connect_error);
error_log("Make sure database connections in DBCon.php are correct.");
$DBError = "true";
}
else
{
}
if(isset($_SERVER["HTTP_REFERER"]))
{
$strReferer = $_SERVER["HTTP_REFERER"];
}
else
{
$strReferer = "";
}
if(isset($_SERVER["HTTP_USER_AGENT"]))
{
$strAgent = $_SERVER["HTTP_USER_AGENT"];
}
else
{
$strAgent = "";
}
if(isset($_SERVER["HTTPS"]))
{
$strProto = "https://";
}
else
{
$strProto = "http://";
}
$strPageURL = $strProto . $strHost . $strURI;
$PostVarCount = count($_POST);
$dtNow = date('Y-m-d H:i:s');
$strPageName = $_SERVER['PHP_SELF'];
?>