fix: DB connection is global and tries 2 tested ways to connect

Some installations seem to support localhost:port for 1st parameter of
mysqli_connect(), others will only support the official parameters with
port towards the end. This fix tries them both - first the official one,
then the localhost:port one.

Also, there were a lot of mysqli_connect()'s inside Admin mods. These
now also use the central Database class.
This commit is contained in:
Martin Ambrus
2017-11-20 01:09:49 +01:00
parent c27b397016
commit 0984c7ef34
50 changed files with 482 additions and 187 deletions
-3
View File
@@ -13,9 +13,6 @@
include_once("../../Account.php"); include_once("../../Account.php");
mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS);
mysqli_select_db(SQL_DB);
if (!isset($_SESSION)) session_start(); if (!isset($_SESSION)) session_start();
if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!");
-2
View File
@@ -10,8 +10,6 @@
## ## ## ##
################################################################################# #################################################################################
include_once("../../Account.php"); include_once("../../Account.php");
mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS);
mysqli_select_db(SQL_DB);
if (!isset($_SESSION)) session_start(); if (!isset($_SESSION)) session_start();
if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!");
-2
View File
@@ -10,8 +10,6 @@
################################################################################# #################################################################################
include_once("../../Account.php"); include_once("../../Account.php");
mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS);
mysqli_select_db(SQL_DB);
if (!isset($_SESSION)) session_start(); if (!isset($_SESSION)) session_start();
if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!");
-2
View File
@@ -10,8 +10,6 @@
################################################################################# #################################################################################
include_once("../../Account.php"); include_once("../../Account.php");
mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS);
mysqli_select_db(SQL_DB);
if (!isset($_SESSION)) session_start(); if (!isset($_SESSION)) session_start();
if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!");
-2
View File
@@ -10,8 +10,6 @@
## ## ## ##
################################################################################# #################################################################################
include_once("../../Account.php"); include_once("../../Account.php");
mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS);
mysqli_select_db(SQL_DB);
if (!isset($_SESSION)) session_start(); if (!isset($_SESSION)) session_start();
if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!");
-2
View File
@@ -10,8 +10,6 @@
## ## ## ##
################################################################################# #################################################################################
include_once("../../Account.php"); include_once("../../Account.php");
mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS);
mysqli_select_db(SQL_DB);
if (!isset($_SESSION)) session_start(); if (!isset($_SESSION)) session_start();
if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!");
-2
View File
@@ -10,8 +10,6 @@
## ## ## ##
################################################################################# #################################################################################
include_once("../../Account.php"); include_once("../../Account.php");
mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS);
mysqli_select_db(SQL_DB);
if (!isset($_SESSION)) session_start(); if (!isset($_SESSION)) session_start();
if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!");
-3
View File
@@ -11,9 +11,6 @@
include_once("../../Account.php"); include_once("../../Account.php");
mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS);
mysqli_select_db(SQL_DB);
if (!isset($_SESSION)) session_start(); if (!isset($_SESSION)) session_start();
if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!");
-3
View File
@@ -10,9 +10,6 @@
include_once("../../Account.php"); include_once("../../Account.php");
mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS);
mysqli_select_db(SQL_DB);
if (!isset($_SESSION)) session_start(); if (!isset($_SESSION)) session_start();
if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!");
-3
View File
@@ -12,9 +12,6 @@
include_once("../../GameEngine/config.php"); include_once("../../GameEngine/config.php");
include_once("../../GameEngine/Database.php"); include_once("../../GameEngine/Database.php");
mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS);
mysqli_select_db(SQL_DB);
if (!isset($_SESSION)) { if (!isset($_SESSION)) {
session_start(); session_start();
} }
-2
View File
@@ -24,8 +24,6 @@ include_once($autoprefix."GameEngine/config.php");
include_once($autoprefix."GameEngine/Session.php"); include_once($autoprefix."GameEngine/Session.php");
include_once($autoprefix."GameEngine/Automation.php"); include_once($autoprefix."GameEngine/Automation.php");
include_once($autoprefix."GameEngine/Database.php"); include_once($autoprefix."GameEngine/Database.php");
$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS);
mysqli_select_db($GLOBALS["link"], SQL_DB);
$wgarray=array(1=>1200,1700,2300,3100,4000,5000,6300,7800,9600,11800,14400,17600,21400,25900,31300,37900,45700,55100,66400,80000); $wgarray=array(1=>1200,1700,2300,3100,4000,5000,6300,7800,9600,11800,14400,17600,21400,25900,31300,37900,45700,55100,66400,80000);
-2
View File
@@ -12,8 +12,6 @@ include_once("../../config.php");
include_once("../../Database.php"); include_once("../../Database.php");
if (!isset($_SESSION)) session_start(); if (!isset($_SESSION)) session_start();
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS);
mysqli_select_db($GLOBALS["link"], SQL_DB);
$id = (int) $_POST['id']; $id = (int) $_POST['id'];
$admid = $_POST['admid']; $admid = $_POST['admid'];
+11 -2
View File
@@ -12,8 +12,17 @@ if (!isset($_SESSION)) session_start();
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
include_once("../../config.php"); include_once("../../config.php");
$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); // go max 5 levels up - we don't have folders that go deeper than that
mysqli_select_db($GLOBALS["link"], SQL_DB); $autoprefix = '';
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
if (file_exists($autoprefix.'autoloader.php')) {
// we have our path, let's leave
break;
}
}
include_once($autoprefix."GameEngine/Database.php");
$id = (int) $_POST['id']; $id = (int) $_POST['id'];
$admid = (int) $_POST['admid']; $admid = (int) $_POST['admid'];
+11 -2
View File
@@ -12,8 +12,17 @@ if (!isset($_SESSION)) session_start();
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
include_once("../../config.php"); include_once("../../config.php");
$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); // go max 5 levels up - we don't have folders that go deeper than that
mysqli_select_db($GLOBALS["link"], SQL_DB); $autoprefix = '';
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
if (file_exists($autoprefix.'autoloader.php')) {
// we have our path, let's leave
break;
}
}
include_once($autoprefix."GameEngine/Database.php");
$delete = (int) $_POST['medalid']; $delete = (int) $_POST['medalid'];
$aid =(int) $_POST['aid']; $aid =(int) $_POST['aid'];
+11 -2
View File
@@ -12,8 +12,17 @@ if (!isset($_SESSION)) session_start();
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
include_once("../../config.php"); include_once("../../config.php");
$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); // go max 5 levels up - we don't have folders that go deeper than that
mysqli_select_db($GLOBALS["link"], SQL_DB); $autoprefix = '';
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
if (file_exists($autoprefix.'autoloader.php')) {
// we have our path, let's leave
break;
}
}
include_once($autoprefix."GameEngine/Database.php");
$allyid =(int) $_POST['allyid']; $allyid =(int) $_POST['allyid'];
$aid = (int) $_POST['aid']; $aid = (int) $_POST['aid'];
+11 -2
View File
@@ -12,8 +12,17 @@ if (!isset($_SESSION)) session_start();
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
include_once("../../config.php"); include_once("../../config.php");
$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); // go max 5 levels up - we don't have folders that go deeper than that
mysqli_select_db($GLOBALS["link"], SQL_DB); $autoprefix = '';
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
if (file_exists($autoprefix.'autoloader.php')) {
// we have our path, let's leave
break;
}
}
include_once($autoprefix."GameEngine/Database.php");
$deleteweek = (int) $_POST['deleteweek']; $deleteweek = (int) $_POST['deleteweek'];
$session = (int) $_POST['admid']; $session = (int) $_POST['admid'];
+11 -2
View File
@@ -12,8 +12,17 @@ if (!isset($_SESSION)) session_start();
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
include_once("../../config.php"); include_once("../../config.php");
$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); // go max 5 levels up - we don't have folders that go deeper than that
mysqli_select_db($GLOBALS["link"], SQL_DB); $autoprefix = '';
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
if (file_exists($autoprefix.'autoloader.php')) {
// we have our path, let's leave
break;
}
}
include_once($autoprefix."GameEngine/Database.php");
$userid = (int) $_POST['userid']; $userid = (int) $_POST['userid'];
$session = (int) $_POST['admid']; $session = (int) $_POST['admid'];
+11 -2
View File
@@ -12,8 +12,17 @@ if (!isset($_SESSION)) session_start();
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
include_once("../../config.php"); include_once("../../config.php");
$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); // go max 5 levels up - we don't have folders that go deeper than that
mysqli_select_db($GLOBALS["link"], SQL_DB); $autoprefix = '';
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
if (file_exists($autoprefix.'autoloader.php')) {
// we have our path, let's leave
break;
}
}
include_once($autoprefix."GameEngine/Database.php");
$deleteweek = (int) $_POST['medalweek']; $deleteweek = (int) $_POST['medalweek'];
$session = (int) $_POST['admid']; $session = (int) $_POST['admid'];
+11 -2
View File
@@ -12,8 +12,17 @@ if (!isset($_SESSION)) session_start();
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
include_once("../../config.php"); include_once("../../config.php");
$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); // go max 5 levels up - we don't have folders that go deeper than that
mysqli_select_db($GLOBALS["link"], SQL_DB); $autoprefix = '';
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
if (file_exists($autoprefix.'autoloader.php')) {
// we have our path, let's leave
break;
}
}
include_once($autoprefix."GameEngine/Database.php");
$session = (int) $_POST['admid']; $session = (int) $_POST['admid'];
$id = (int) $_POST['uid']; $id = (int) $_POST['uid'];
+11 -3
View File
@@ -14,10 +14,18 @@ if(!isset($_SESSION)) session_start();
if($_SESSION['access'] < 9) die("<h1><font color=\"red\">Access Denied: You are not Admin!</font></h1>"); if($_SESSION['access'] < 9) die("<h1><font color=\"red\">Access Denied: You are not Admin!</font></h1>");
include_once("../../config.php"); include_once("../../config.php");
include_once("../../Database.php");
$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); // go max 5 levels up - we don't have folders that go deeper than that
mysqli_select_db($GLOBALS["link"], SQL_DB); $autoprefix = '';
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
if (file_exists($autoprefix.'autoloader.php')) {
// we have our path, let's leave
break;
}
}
include_once($autoprefix."GameEngine/Database.php");
foreach ($_POST as $key => $value) { foreach ($_POST as $key => $value) {
$_POST[$key] = $database->escape($value); $_POST[$key] = $database->escape($value);
+11 -2
View File
@@ -12,8 +12,17 @@ if (!isset($_SESSION)) session_start();
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
include_once("../../config.php"); include_once("../../config.php");
$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); // go max 5 levels up - we don't have folders that go deeper than that
mysqli_select_db($GLOBALS["link"], SQL_DB); $autoprefix = '';
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
if (file_exists($autoprefix.'autoloader.php')) {
// we have our path, let's leave
break;
}
}
include_once($autoprefix."GameEngine/Database.php");
$session = (int) $_POST['admid']; $session = (int) $_POST['admid'];
$id = (int) $_POST['id']; $id = (int) $_POST['id'];
+11 -2
View File
@@ -12,8 +12,17 @@ if (!isset($_SESSION)) session_start();
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
include_once("../../config.php"); include_once("../../config.php");
$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); // go max 5 levels up - we don't have folders that go deeper than that
mysqli_select_db($GLOBALS["link"], SQL_DB); $autoprefix = '';
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
if (file_exists($autoprefix.'autoloader.php')) {
// we have our path, let's leave
break;
}
}
include_once($autoprefix."GameEngine/Database.php");
$session = (int) $_POST['admid']; $session = (int) $_POST['admid'];
$id = (int) $_POST['uid']; $id = (int) $_POST['uid'];
+11 -2
View File
@@ -12,8 +12,17 @@ if (!isset($_SESSION)) session_start();
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
include_once("../../config.php"); include_once("../../config.php");
$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); // go max 5 levels up - we don't have folders that go deeper than that
mysqli_select_db($GLOBALS["link"], SQL_DB); $autoprefix = '';
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
if (file_exists($autoprefix.'autoloader.php')) {
// we have our path, let's leave
break;
}
}
include_once($autoprefix."GameEngine/Database.php");
$session = (int) $_POST['admid']; $session = (int) $_POST['admid'];
$id = (int) $_POST['id']; $id = (int) $_POST['id'];
+11 -2
View File
@@ -12,8 +12,17 @@ if (!isset($_SESSION)) session_start();
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
include_once("../../config.php"); include_once("../../config.php");
$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); // go max 5 levels up - we don't have folders that go deeper than that
mysqli_select_db($GLOBALS["link"], SQL_DB); $autoprefix = '';
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
if (file_exists($autoprefix.'autoloader.php')) {
// we have our path, let's leave
break;
}
}
include_once($autoprefix."GameEngine/Database.php");
$session = (int) $_POST['admid']; $session = (int) $_POST['admid'];
$id = (int) $_POST['id']; $id = (int) $_POST['id'];
+11 -2
View File
@@ -12,8 +12,17 @@ if (!isset($_SESSION)) session_start();
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
include_once("../../config.php"); include_once("../../config.php");
$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); // go max 5 levels up - we don't have folders that go deeper than that
mysqli_select_db($GLOBALS["link"], SQL_DB); $autoprefix = '';
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
if (file_exists($autoprefix.'autoloader.php')) {
// we have our path, let's leave
break;
}
}
include_once($autoprefix."GameEngine/Database.php");
$session = (int) $_POST['admid']; $session = (int) $_POST['admid'];
$id = (int) $_POST['did']; $id = (int) $_POST['did'];
+11 -2
View File
@@ -12,8 +12,17 @@ if (!isset($_SESSION)) session_start();
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
include_once("../../config.php"); include_once("../../config.php");
$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); // go max 5 levels up - we don't have folders that go deeper than that
mysqli_select_db($GLOBALS["link"], SQL_DB); $autoprefix = '';
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
if (file_exists($autoprefix.'autoloader.php')) {
// we have our path, let's leave
break;
}
}
include_once($autoprefix."GameEngine/Database.php");
$session = (int) $_POST['admid']; $session = (int) $_POST['admid'];
$id = (int) $_POST['id']; $id = (int) $_POST['id'];
+11 -3
View File
@@ -11,10 +11,18 @@
if (!isset($_SESSION)) session_start(); if (!isset($_SESSION)) session_start();
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
include_once("../../config.php"); include_once("../../config.php");
include_once("../../Database.php");
$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); // go max 5 levels up - we don't have folders that go deeper than that
mysqli_select_db($GLOBALS["link"], SQL_DB); $autoprefix = '';
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
if (file_exists($autoprefix.'autoloader.php')) {
// we have our path, let's leave
break;
}
}
include_once($autoprefix."GameEngine/Database.php");
foreach ($_POST as $key => $value) { foreach ($_POST as $key => $value) {
$_POST[$key] = $database->escape($value); $_POST[$key] = $database->escape($value);
+11 -3
View File
@@ -11,10 +11,18 @@
if (!isset($_SESSION)) session_start(); if (!isset($_SESSION)) session_start();
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
include_once("../../config.php"); include_once("../../config.php");
include_once("../../Database.php");
$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); // go max 5 levels up - we don't have folders that go deeper than that
mysqli_select_db($GLOBALS["link"], SQL_DB); $autoprefix = '';
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
if (file_exists($autoprefix.'autoloader.php')) {
// we have our path, let's leave
break;
}
}
include_once($autoprefix."GameEngine/Database.php");
foreach ($_POST as $key => $value) { foreach ($_POST as $key => $value) {
$_POST[$key] = $database->escape($value); $_POST[$key] = $database->escape($value);
+11 -2
View File
@@ -12,8 +12,17 @@ if (!isset($_SESSION)) session_start();
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
include_once("../../config.php"); include_once("../../config.php");
$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); // go max 5 levels up - we don't have folders that go deeper than that
mysqli_select_db($GLOBALS["link"], SQL_DB); $autoprefix = '';
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
if (file_exists($autoprefix.'autoloader.php')) {
// we have our path, let's leave
break;
}
}
include_once($autoprefix."GameEngine/Database.php");
$session = (int) $_POST['admid']; $session = (int) $_POST['admid'];
$id = (int) $_POST['did']; $id = (int) $_POST['did'];
+11 -2
View File
@@ -12,8 +12,17 @@ if (!isset($_SESSION)) session_start();
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
include_once("../../config.php"); include_once("../../config.php");
$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); // go max 5 levels up - we don't have folders that go deeper than that
mysqli_select_db($GLOBALS["link"], SQL_DB); $autoprefix = '';
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
if (file_exists($autoprefix.'autoloader.php')) {
// we have our path, let's leave
break;
}
}
include_once($autoprefix."GameEngine/Database.php");
$session = (int) $_POST['admid']; $session = (int) $_POST['admid'];
$id = (int) $_POST['id']; $id = (int) $_POST['id'];
+11 -2
View File
@@ -18,8 +18,17 @@ function mysqli_result($res, $row, $field=0) {
return $datarow[$field]; return $datarow[$field];
} }
$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); // go max 5 levels up - we don't have folders that go deeper than that
mysqli_select_db($GLOBALS["link"], SQL_DB); $autoprefix = '';
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
if (file_exists($autoprefix.'autoloader.php')) {
// we have our path, let's leave
break;
}
}
include_once($autoprefix."GameEngine/Database.php");
$session = (int) $_POST['admid']; $session = (int) $_POST['admid'];
+11 -2
View File
@@ -18,8 +18,17 @@ function mysqli_result($res, $row, $field=0) {
return $datarow[$field]; return $datarow[$field];
} }
$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); // go max 5 levels up - we don't have folders that go deeper than that
mysqli_select_db($GLOBALS["link"], SQL_DB); $autoprefix = '';
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
if (file_exists($autoprefix.'autoloader.php')) {
// we have our path, let's leave
break;
}
}
include_once($autoprefix."GameEngine/Database.php");
$session = (int) $_POST['admid']; $session = (int) $_POST['admid'];
+11 -2
View File
@@ -14,8 +14,17 @@ include_once("../../config.php");
error_reporting(E_ALL); error_reporting(E_ALL);
$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); // go max 5 levels up - we don't have folders that go deeper than that
mysqli_select_db($GLOBALS["link"], SQL_DB); $autoprefix = '';
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
if (file_exists($autoprefix.'autoloader.php')) {
// we have our path, let's leave
break;
}
}
include_once($autoprefix."GameEngine/Database.php");
$session = (int) $_POST['admid']; $session = (int) $_POST['admid'];
+11 -2
View File
@@ -14,8 +14,17 @@ include_once("../../config.php");
error_reporting(E_ALL); error_reporting(E_ALL);
$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); // go max 5 levels up - we don't have folders that go deeper than that
mysqli_select_db($GLOBALS["link"], SQL_DB); $autoprefix = '';
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
if (file_exists($autoprefix.'autoloader.php')) {
// we have our path, let's leave
break;
}
}
include_once($autoprefix."GameEngine/Database.php");
$session = (int) $_POST['admid']; $session = (int) $_POST['admid'];
+11 -2
View File
@@ -12,8 +12,17 @@ if (!isset($_SESSION)) session_start();
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
include_once("../../config.php"); include_once("../../config.php");
$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); // go max 5 levels up - we don't have folders that go deeper than that
mysqli_select_db($GLOBALS["link"], SQL_DB); $autoprefix = '';
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
if (file_exists($autoprefix.'autoloader.php')) {
// we have our path, let's leave
break;
}
}
include_once($autoprefix."GameEngine/Database.php");
$session = (int) $_POST['admid']; $session = (int) $_POST['admid'];
$id = (int) $_POST['id']; $id = (int) $_POST['id'];
+11 -3
View File
@@ -11,10 +11,18 @@
if (!isset($_SESSION)) session_start(); if (!isset($_SESSION)) session_start();
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
include_once("../../config.php"); include_once("../../config.php");
include_once("../../Database.php");
$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); // go max 5 levels up - we don't have folders that go deeper than that
mysqli_select_db($GLOBALS["link"], SQL_DB); $autoprefix = '';
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
if (file_exists($autoprefix.'autoloader.php')) {
// we have our path, let's leave
break;
}
}
include_once($autoprefix."GameEngine/Database.php");
foreach ($_POST as $key => $value) { foreach ($_POST as $key => $value) {
$_POST[$key] = $database->escape($value); $_POST[$key] = $database->escape($value);
@@ -12,8 +12,17 @@ if (!isset($_SESSION)) session_start();
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
include_once("../../config.php"); include_once("../../config.php");
$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); // go max 5 levels up - we don't have folders that go deeper than that
mysqli_select_db($GLOBALS["link"], SQL_DB); $autoprefix = '';
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
if (file_exists($autoprefix.'autoloader.php')) {
// we have our path, let's leave
break;
}
}
include_once($autoprefix."GameEngine/Database.php");
$session = (int) $_POST['admid']; $session = (int) $_POST['admid'];
+11 -2
View File
@@ -12,8 +12,17 @@ if (!isset($_SESSION)) session_start();
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
include_once("../../config.php"); include_once("../../config.php");
$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); // go max 5 levels up - we don't have folders that go deeper than that
mysqli_select_db($GLOBALS["link"], SQL_DB); $autoprefix = '';
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
if (file_exists($autoprefix.'autoloader.php')) {
// we have our path, let's leave
break;
}
}
include_once($autoprefix."GameEngine/Database.php");
$session = (int) $_POST['admid']; $session = (int) $_POST['admid'];
+11 -2
View File
@@ -12,8 +12,17 @@ if (!isset($_SESSION)) session_start();
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
include_once("../../config.php"); include_once("../../config.php");
$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); // go max 5 levels up - we don't have folders that go deeper than that
mysqli_select_db($GLOBALS["link"], SQL_DB); $autoprefix = '';
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
if (file_exists($autoprefix.'autoloader.php')) {
// we have our path, let's leave
break;
}
}
include_once($autoprefix."GameEngine/Database.php");
$session = (int) $_POST['admid']; $session = (int) $_POST['admid'];
@@ -12,8 +12,17 @@ if (!isset($_SESSION)) session_start();
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
include_once("../../config.php"); include_once("../../config.php");
$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); // go max 5 levels up - we don't have folders that go deeper than that
mysqli_select_db($GLOBALS["link"], SQL_DB); $autoprefix = '';
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
if (file_exists($autoprefix.'autoloader.php')) {
// we have our path, let's leave
break;
}
}
include_once($autoprefix."GameEngine/Database.php");
$session = (int) $_POST['admid']; $session = (int) $_POST['admid'];
+11 -3
View File
@@ -11,10 +11,18 @@
if (!isset($_SESSION)) session_start(); if (!isset($_SESSION)) session_start();
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
include_once("../../config.php"); include_once("../../config.php");
include_once("../../Database.php");
$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); // go max 5 levels up - we don't have folders that go deeper than that
mysqli_select_db($GLOBALS["link"], SQL_DB); $autoprefix = '';
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
if (file_exists($autoprefix.'autoloader.php')) {
// we have our path, let's leave
break;
}
}
include_once($autoprefix."GameEngine/Database.php");
foreach ($_POST as $key => $value) { foreach ($_POST as $key => $value) {
$_POST[$key] = $database->escape($value); $_POST[$key] = $database->escape($value);
+11 -2
View File
@@ -12,8 +12,17 @@ if (!isset($_SESSION)) session_start();
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
include_once("../../Account.php"); include_once("../../Account.php");
$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); // go max 5 levels up - we don't have folders that go deeper than that
mysqli_select_db($GLOBALS["link"], SQL_DB); $autoprefix = '';
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
if (file_exists($autoprefix.'autoloader.php')) {
// we have our path, let's leave
break;
}
}
include_once($autoprefix."GameEngine/Database.php");
if (!isset($_SESSION)) session_start(); if (!isset($_SESSION)) session_start();
if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!");
+12 -2
View File
@@ -12,8 +12,18 @@
include_once("../../config.php"); include_once("../../config.php");
include_once("../../Session.php"); include_once("../../Session.php");
include_once("../../Automation.php"); include_once("../../Automation.php");
$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS);
mysqli_select_db($GLOBALS["link"], SQL_DB); // go max 5 levels up - we don't have folders that go deeper than that
$autoprefix = '';
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
if (file_exists($autoprefix.'autoloader.php')) {
// we have our path, let's leave
break;
}
}
include_once($autoprefix."GameEngine/Database.php");
$id = (int) $_POST['id']; $id = (int) $_POST['id'];
$amt = (int) $_POST['vill_amount']; $amt = (int) $_POST['vill_amount'];
+12 -2
View File
@@ -12,8 +12,18 @@
include_once("../../config.php"); include_once("../../config.php");
include_once("../../Session.php"); include_once("../../Session.php");
include_once("../../Automation.php"); include_once("../../Automation.php");
$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS);
mysqli_select_db($GLOBALS["link"], SQL_DB); // go max 5 levels up - we don't have folders that go deeper than that
$autoprefix = '';
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
if (file_exists($autoprefix.'autoloader.php')) {
// we have our path, let's leave
break;
}
}
include_once($autoprefix."GameEngine/Database.php");
$id = (int) $_POST['id']; $id = (int) $_POST['id'];
$amt = (int) $_POST['vill_amount']; $amt = (int) $_POST['vill_amount'];
+11 -3
View File
@@ -11,14 +11,22 @@
if (!isset($_SESSION)) session_start(); if (!isset($_SESSION)) session_start();
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
include_once("../../config.php"); include_once("../../config.php");
include_once("../../Database.php");
foreach ($_POST as $key => $value) { foreach ($_POST as $key => $value) {
$_POST[$key] = $database->escape($value); $_POST[$key] = $database->escape($value);
} }
$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); // go max 5 levels up - we don't have folders that go deeper than that
mysqli_select_db($GLOBALS["link"], SQL_DB); $autoprefix = '';
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
if (file_exists($autoprefix.'autoloader.php')) {
// we have our path, let's leave
break;
}
}
include_once($autoprefix."GameEngine/Database.php");
$session = (int) $_POST['admid']; $session = (int) $_POST['admid'];
$id = (int) $_POST['id']; $id = (int) $_POST['id'];
+11 -3
View File
@@ -11,10 +11,18 @@
if (!isset($_SESSION)) session_start(); if (!isset($_SESSION)) session_start();
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
include_once("../../config.php"); include_once("../../config.php");
include_once("../../Database.php");
$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); // go max 5 levels up - we don't have folders that go deeper than that
mysqli_select_db($GLOBALS["link"], SQL_DB); $autoprefix = '';
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
if (file_exists($autoprefix.'autoloader.php')) {
// we have our path, let's leave
break;
}
}
include_once($autoprefix."GameEngine/Database.php");
$nameorig = $_POST['villagename']; $nameorig = $_POST['villagename'];
+11 -2
View File
@@ -12,8 +12,17 @@ if (!isset($_SESSION)) session_start();
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
include_once("../../config.php"); include_once("../../config.php");
$GLOBALS["link"] = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS); // go max 5 levels up - we don't have folders that go deeper than that
mysqli_select_db($GLOBALS["link"], SQL_DB); $autoprefix = '';
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
if (file_exists($autoprefix.'autoloader.php')) {
// we have our path, let's leave
break;
}
}
include_once($autoprefix."GameEngine/Database.php");
$session = (int) $_POST['admid']; $session = (int) $_POST['admid'];
+1 -1
View File
@@ -48,7 +48,7 @@ class adm_DB {
var $connection; var $connection;
function __construct(){ function __construct(){
global $database; global $database;
$database = new MYSQLi_DB(SQL_SERVER.':'.(defined('SQL_PORT') ? SQL_PORT : 3306), SQL_USER, SQL_PASS, SQL_DB); $database = new MYSQLi_DB(SQL_SERVER, SQL_USER, SQL_PASS, SQL_DB, (defined('SQL_PORT') ? SQL_PORT : 3306));
$this->connection = $database->return_link(); $this->connection = $database->return_link();
} }
+11 -7
View File
@@ -442,15 +442,19 @@ class MYSQLi_DB implements IDbConnection {
*/ */
public function connect() { public function connect() {
// try to connect // try to connect
$this->dblink = mysqli_connect($this->hostname.':'.$this->port, $this->username, $this->password); try {
$this->dblink = mysqli_connect( $this->hostname, $this->username, $this->password, $this->dbname, $this->port );
} catch (\Exception $exception) {
$this->dblink = mysqli_connect( $this->hostname . ':' . $this->port, $this->username, $this->password );
// return on error // return on error
if (mysqli_error($this->dblink)) { if (mysqli_error($this->dblink)) {
return false; return false;
} }
// select the DB to use // select the DB to use
mysqli_select_db($this->dblink, $this->dbname); mysqli_select_db($this->dblink, $this->dbname);
}
// return on error // return on error
if (mysqli_error($this->dblink)) { if (mysqli_error($this->dblink)) {
+14 -5
View File
@@ -2,12 +2,21 @@
$count="0"; $count="0";
include_once("GameEngine/Config.php"); include_once("GameEngine/Config.php");
$connection = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS) or die(mysqli_error($database->dblink)); // go max 5 levels up - we don't have folders that go deeper than that
mysqli_select_db(SQL_DB, $connection) or die(mysqli_error($database->dblink)); $autoprefix = '';
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
if (file_exists($autoprefix.'autoloader.php')) {
// we have our path, let's leave
break;
}
}
$q = "SELECT Count(*) as Total FROM ".TB_PREFIX."movement where endtime < ".time()." and proc = 0"; include_once($autoprefix."GameEngine/Database.php");
$result = mysqli_fetch_array(mysqli_query($GLOBALS["link"], $q, $connection), MYSQLI_ASSOC);
$count=$result['Total']; $q = "SELECT Count(*) as Total FROM ".TB_PREFIX."movement where endtime < ".time()." and proc = 0";
$result = mysqli_fetch_array(mysqli_query($GLOBALS["link"], $q), MYSQLI_ASSOC);
$count=$result['Total'];
?> ?>