mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-06-28 00:24:23 +00:00
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:
@@ -13,11 +13,8 @@
|
||||
|
||||
include_once("../../Account.php");
|
||||
|
||||
mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS);
|
||||
mysqli_select_db(SQL_DB);
|
||||
|
||||
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!");
|
||||
|
||||
$id = (int) $_POST['id'];
|
||||
$village = $database->getVillage($id);
|
||||
|
||||
+1
-3
@@ -10,10 +10,8 @@
|
||||
## ##
|
||||
#################################################################################
|
||||
include_once("../../Account.php");
|
||||
mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS);
|
||||
mysqli_select_db(SQL_DB);
|
||||
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!");
|
||||
|
||||
$id = (int) $_POST['id'];
|
||||
$admid = (int) $_POST['admid'];
|
||||
|
||||
@@ -10,10 +10,8 @@
|
||||
#################################################################################
|
||||
|
||||
include_once("../../Account.php");
|
||||
mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS);
|
||||
mysqli_select_db(SQL_DB);
|
||||
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!");
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -10,10 +10,8 @@
|
||||
#################################################################################
|
||||
|
||||
include_once("../../Account.php");
|
||||
mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS);
|
||||
mysqli_select_db(SQL_DB);
|
||||
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!");
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -10,10 +10,8 @@
|
||||
## ##
|
||||
#################################################################################
|
||||
include_once("../../Account.php");
|
||||
mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS);
|
||||
mysqli_select_db(SQL_DB);
|
||||
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!");
|
||||
|
||||
foreach ($_POST as $key => $value) {
|
||||
$_POST[$key] = $database->escape($value);
|
||||
|
||||
+1
-3
@@ -10,10 +10,8 @@
|
||||
## ##
|
||||
#################################################################################
|
||||
include_once("../../Account.php");
|
||||
mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS);
|
||||
mysqli_select_db(SQL_DB);
|
||||
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!");
|
||||
|
||||
$id = (int) $_POST['id'];
|
||||
$gold = (int) $_POST['gold'];
|
||||
|
||||
@@ -10,10 +10,8 @@
|
||||
## ##
|
||||
#################################################################################
|
||||
include_once("../../Account.php");
|
||||
mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS);
|
||||
mysqli_select_db(SQL_DB);
|
||||
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!");
|
||||
|
||||
$id = $_POST['id'];
|
||||
$admid = (int) $_POST['admid'];
|
||||
|
||||
@@ -11,11 +11,8 @@
|
||||
|
||||
include_once("../../Account.php");
|
||||
|
||||
mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS);
|
||||
mysqli_select_db(SQL_DB);
|
||||
|
||||
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!");
|
||||
|
||||
$medalid = (int) $_POST['medalid'];
|
||||
$uid = (int) $_POST['uid'];
|
||||
|
||||
@@ -10,11 +10,8 @@
|
||||
|
||||
include_once("../../Account.php");
|
||||
|
||||
mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS);
|
||||
mysqli_select_db(SQL_DB);
|
||||
|
||||
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!");
|
||||
|
||||
$origname = $_POST['villagename'];
|
||||
|
||||
|
||||
@@ -12,9 +12,6 @@
|
||||
include_once("../../GameEngine/config.php");
|
||||
include_once("../../GameEngine/Database.php");
|
||||
|
||||
mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS);
|
||||
mysqli_select_db(SQL_DB);
|
||||
|
||||
if (!isset($_SESSION)) {
|
||||
session_start();
|
||||
}
|
||||
@@ -100,4 +97,4 @@ mysqli_query($GLOBALS["link"], "DELETE FROM ".TB_PREFIX."vdata WHERE owner<>5");
|
||||
mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."ww_attacks");
|
||||
|
||||
header("Location: ../admin.php?p=resetdone");
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -24,8 +24,6 @@ include_once($autoprefix."GameEngine/config.php");
|
||||
include_once($autoprefix."GameEngine/Session.php");
|
||||
include_once($autoprefix."GameEngine/Automation.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);
|
||||
|
||||
@@ -71,12 +69,12 @@ else
|
||||
$userName = $baseName . $i;
|
||||
// Random passwords disallow admin logging in to use the accounts
|
||||
$password = $generator->generateRandStr(20);
|
||||
|
||||
|
||||
// Leaving the line below but commented out - could be used to
|
||||
// allow admin to log in to the generated accounts and play them
|
||||
// Easily guessed by players so should only be used for testing
|
||||
//$password = $baseName . $i . 'PASS';
|
||||
|
||||
|
||||
$email = $baseName . $i . '@example.com';
|
||||
if ($postTribe == 0)
|
||||
{
|
||||
@@ -92,7 +90,7 @@ else
|
||||
$kid = rand(1,4);
|
||||
// Dont need to activate, not 100% sure we need to initialise $act
|
||||
$act = "";
|
||||
|
||||
|
||||
// Check username not already registered
|
||||
if(User::exists($database, $userName))
|
||||
{
|
||||
@@ -116,14 +114,14 @@ else
|
||||
* Don't directly access the DB, create a $database function
|
||||
* where required
|
||||
*/
|
||||
|
||||
|
||||
// Show the dove in User Profile - will show this even if
|
||||
// beginners protection is not checked
|
||||
// Need a $database function for this
|
||||
// (assuming we don't already have one as creating Natars also updates this way)
|
||||
$q = "UPDATE " . TB_PREFIX . "users SET desc2 = '[#0]' WHERE id = ".(int) $uid;
|
||||
mysqli_query($GLOBALS["link"], $q) or die(mysqli_error($database->dblink));
|
||||
|
||||
|
||||
if (!$beginnersProtection)
|
||||
{
|
||||
// No beginners protection so set it to current time
|
||||
@@ -135,17 +133,17 @@ else
|
||||
protect = '".$protection."'
|
||||
WHERE id = ".(int) $uid) or die(mysqli_error($database->dblink));
|
||||
}
|
||||
|
||||
|
||||
$database->updateUserField($uid,"act","",1);
|
||||
$wid = $database->generateBase($kid,0,false);
|
||||
$database->setFieldTaken($wid);
|
||||
|
||||
|
||||
//calculate random generate value and level building
|
||||
$rand_resource=rand(30000, 80000);
|
||||
$level_storage=rand(10, 20);
|
||||
$cap_storage=$wgarray[$level_storage]*(STORAGE_BASE/800);
|
||||
$rand_resource=($rand_resource>$cap_storage)? $cap_storage:$rand_resource;
|
||||
|
||||
|
||||
//insert village with all resource and building with random level
|
||||
$time = time();
|
||||
$q = "INSERT INTO ".TB_PREFIX."vdata (`wref`,`owner`,`name`,`capital`,`pop`,`cp`,`celebration`,`type`,`wood`,`clay`,`iron`,`maxstore`,`crop`,`maxcrop`,`lastupdate`,`loyalty`,`exp1`,`exp2`,`exp3`,`created`) values (".(int) $wid.",".(int) $uid.",'".$userName."\'s village',1,200,1,0,0,$rand_resource,$rand_resource,$rand_resource,$cap_storage,$rand_resource,$cap_storage,$time,100,0,0,0,$time)";
|
||||
@@ -158,13 +156,13 @@ WHERE id = ".(int) $uid) or die(mysqli_error($database->dblink));
|
||||
$addTechWrefs[] = $wid;
|
||||
$addABTechWrefs[] = $wid;
|
||||
$database->updateUserField($uid,"access",USER,1);
|
||||
|
||||
|
||||
//insert units randomly generate the number of troops
|
||||
$q = "UPDATE " . TB_PREFIX . "units SET u".(($tribe-1)*10+1)." = ".rand(100, 2000).", u".(($tribe-1)*10+2)." = ".rand(100, 2400).", u".(($tribe-1)*10+3)." = ".rand(100, 1600).", u".(($tribe-1)*10+4)." = ".rand(100, 1500).", u".(($tribe-1)*10+5)." = " .rand(48, 1700).", u".(($tribe-1)*10+6)." = ".rand(60, 1800)." WHERE vref = '".$wid."'";
|
||||
mysqli_query($GLOBALS["link"], $q);
|
||||
|
||||
$created ++;
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -12,8 +12,6 @@ include_once("../../config.php");
|
||||
include_once("../../Database.php");
|
||||
if (!isset($_SESSION)) session_start();
|
||||
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'];
|
||||
$admid = $_POST['admid'];
|
||||
|
||||
@@ -12,8 +12,17 @@ if (!isset($_SESSION)) session_start();
|
||||
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
|
||||
include_once("../../config.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'];
|
||||
$admid = (int) $_POST['admid'];
|
||||
|
||||
@@ -12,8 +12,17 @@ if (!isset($_SESSION)) session_start();
|
||||
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
|
||||
include_once("../../config.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");
|
||||
|
||||
$delete = (int) $_POST['medalid'];
|
||||
$aid =(int) $_POST['aid'];
|
||||
|
||||
@@ -12,8 +12,17 @@ if (!isset($_SESSION)) session_start();
|
||||
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
|
||||
include_once("../../config.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");
|
||||
|
||||
$allyid =(int) $_POST['allyid'];
|
||||
$aid = (int) $_POST['aid'];
|
||||
|
||||
@@ -12,8 +12,17 @@ if (!isset($_SESSION)) session_start();
|
||||
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
|
||||
include_once("../../config.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");
|
||||
|
||||
$deleteweek = (int) $_POST['deleteweek'];
|
||||
$session = (int) $_POST['admid'];
|
||||
|
||||
@@ -12,8 +12,17 @@ if (!isset($_SESSION)) session_start();
|
||||
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
|
||||
include_once("../../config.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");
|
||||
|
||||
$userid = (int) $_POST['userid'];
|
||||
$session = (int) $_POST['admid'];
|
||||
|
||||
@@ -12,8 +12,17 @@ if (!isset($_SESSION)) session_start();
|
||||
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
|
||||
include_once("../../config.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");
|
||||
|
||||
$deleteweek = (int) $_POST['medalweek'];
|
||||
$session = (int) $_POST['admid'];
|
||||
|
||||
@@ -12,8 +12,17 @@ if (!isset($_SESSION)) session_start();
|
||||
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
|
||||
include_once("../../config.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");
|
||||
|
||||
$session = (int) $_POST['admid'];
|
||||
$id = (int) $_POST['uid'];
|
||||
|
||||
@@ -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>");
|
||||
|
||||
include_once("../../config.php");
|
||||
include_once("../../Database.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");
|
||||
|
||||
foreach ($_POST as $key => $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!");
|
||||
include_once("../../config.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");
|
||||
|
||||
$session = (int) $_POST['admid'];
|
||||
$id = (int) $_POST['id'];
|
||||
|
||||
@@ -12,8 +12,17 @@ if (!isset($_SESSION)) session_start();
|
||||
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
|
||||
include_once("../../config.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");
|
||||
|
||||
$session = (int) $_POST['admid'];
|
||||
$id = (int) $_POST['uid'];
|
||||
|
||||
@@ -12,8 +12,17 @@ if (!isset($_SESSION)) session_start();
|
||||
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
|
||||
include_once("../../config.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");
|
||||
|
||||
$session = (int) $_POST['admid'];
|
||||
$id = (int) $_POST['id'];
|
||||
|
||||
@@ -12,8 +12,17 @@ if (!isset($_SESSION)) session_start();
|
||||
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
|
||||
include_once("../../config.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");
|
||||
|
||||
$session = (int) $_POST['admid'];
|
||||
$id = (int) $_POST['id'];
|
||||
|
||||
@@ -12,8 +12,17 @@ if (!isset($_SESSION)) session_start();
|
||||
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
|
||||
include_once("../../config.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");
|
||||
|
||||
$session = (int) $_POST['admid'];
|
||||
$id = (int) $_POST['did'];
|
||||
|
||||
@@ -12,8 +12,17 @@ if (!isset($_SESSION)) session_start();
|
||||
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
|
||||
include_once("../../config.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");
|
||||
|
||||
$session = (int) $_POST['admid'];
|
||||
$id = (int) $_POST['id'];
|
||||
|
||||
@@ -11,10 +11,18 @@
|
||||
if (!isset($_SESSION)) session_start();
|
||||
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
|
||||
include_once("../../config.php");
|
||||
include_once("../../Database.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");
|
||||
|
||||
foreach ($_POST as $key => $value) {
|
||||
$_POST[$key] = $database->escape($value);
|
||||
|
||||
@@ -11,10 +11,18 @@
|
||||
if (!isset($_SESSION)) session_start();
|
||||
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
|
||||
include_once("../../config.php");
|
||||
include_once("../../Database.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");
|
||||
|
||||
foreach ($_POST as $key => $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!");
|
||||
include_once("../../config.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");
|
||||
|
||||
$session = (int) $_POST['admid'];
|
||||
$id = (int) $_POST['did'];
|
||||
|
||||
@@ -12,8 +12,17 @@ if (!isset($_SESSION)) session_start();
|
||||
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
|
||||
include_once("../../config.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");
|
||||
|
||||
$session = (int) $_POST['admid'];
|
||||
$id = (int) $_POST['id'];
|
||||
|
||||
@@ -18,8 +18,17 @@ function mysqli_result($res, $row, $field=0) {
|
||||
return $datarow[$field];
|
||||
}
|
||||
|
||||
$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");
|
||||
|
||||
$session = (int) $_POST['admid'];
|
||||
|
||||
|
||||
@@ -18,8 +18,17 @@ function mysqli_result($res, $row, $field=0) {
|
||||
return $datarow[$field];
|
||||
}
|
||||
|
||||
$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");
|
||||
|
||||
$session = (int) $_POST['admid'];
|
||||
|
||||
|
||||
@@ -14,8 +14,17 @@ include_once("../../config.php");
|
||||
|
||||
error_reporting(E_ALL);
|
||||
|
||||
$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");
|
||||
|
||||
$session = (int) $_POST['admid'];
|
||||
|
||||
|
||||
@@ -14,8 +14,17 @@ include_once("../../config.php");
|
||||
|
||||
error_reporting(E_ALL);
|
||||
|
||||
$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");
|
||||
|
||||
$session = (int) $_POST['admid'];
|
||||
|
||||
|
||||
@@ -9,11 +9,20 @@
|
||||
## ##
|
||||
#################################################################################
|
||||
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");
|
||||
|
||||
$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");
|
||||
|
||||
$session = (int) $_POST['admid'];
|
||||
$id = (int) $_POST['id'];
|
||||
|
||||
@@ -11,10 +11,18 @@
|
||||
if (!isset($_SESSION)) session_start();
|
||||
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
|
||||
include_once("../../config.php");
|
||||
include_once("../../Database.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");
|
||||
|
||||
foreach ($_POST as $key => $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!");
|
||||
include_once("../../config.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");
|
||||
|
||||
$session = (int) $_POST['admid'];
|
||||
|
||||
|
||||
@@ -12,8 +12,17 @@ if (!isset($_SESSION)) session_start();
|
||||
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
|
||||
include_once("../../config.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");
|
||||
|
||||
$session = (int) $_POST['admid'];
|
||||
|
||||
|
||||
@@ -12,8 +12,17 @@ if (!isset($_SESSION)) session_start();
|
||||
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
|
||||
include_once("../../config.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");
|
||||
|
||||
$session = (int) $_POST['admid'];
|
||||
|
||||
|
||||
@@ -12,8 +12,17 @@ if (!isset($_SESSION)) session_start();
|
||||
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
|
||||
include_once("../../config.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");
|
||||
|
||||
$session = (int) $_POST['admid'];
|
||||
|
||||
|
||||
@@ -11,10 +11,18 @@
|
||||
if (!isset($_SESSION)) session_start();
|
||||
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
|
||||
include_once("../../config.php");
|
||||
include_once("../../Database.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");
|
||||
|
||||
foreach ($_POST as $key => $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!");
|
||||
include_once("../../Account.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");
|
||||
|
||||
if (!isset($_SESSION)) session_start();
|
||||
if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!");
|
||||
|
||||
@@ -12,8 +12,18 @@
|
||||
include_once("../../config.php");
|
||||
include_once("../../Session.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'];
|
||||
$amt = (int) $_POST['vill_amount'];
|
||||
|
||||
@@ -12,8 +12,18 @@
|
||||
include_once("../../config.php");
|
||||
include_once("../../Session.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'];
|
||||
$amt = (int) $_POST['vill_amount'];
|
||||
@@ -38,7 +48,7 @@ for($i=1;$i<=$amt;$i++) {
|
||||
$addTechWrefs[] = $wid;
|
||||
$addABTechWrefs[] = $wid;
|
||||
$speed = NATARS_UNITS;
|
||||
|
||||
|
||||
//new with random amount of troops
|
||||
$q = "UPDATE " . TB_PREFIX . "units SET u41 = " . (rand(50, 1200) * $speed) . ", u42 = " . (rand(100, 1400) * $speed) . ", u43 = " . (rand(200, 1600) * $speed) . ", u44 = " . (rand(10, 50) * $speed) . ", u45 = " . (rand(48, 1700) * $speed) . ", u46 = " . (rand(60, 1800) * $speed) . ", u47 = " . (rand(200, 1600) * $speed) . ", u48 = " . (rand(40, 200) * $speed) . " , u49 = " . (rand(4, 20) * $speed) . ", u50 = " . (rand(5, 25) * $speed) . " WHERE vref = '".$wid."'";
|
||||
mysqli_query($GLOBALS["link"], $q);
|
||||
|
||||
@@ -11,14 +11,22 @@
|
||||
if (!isset($_SESSION)) session_start();
|
||||
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
|
||||
include_once("../../config.php");
|
||||
include_once("../../Database.php");
|
||||
|
||||
foreach ($_POST as $key => $value) {
|
||||
$_POST[$key] = $database->escape($value);
|
||||
}
|
||||
|
||||
$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");
|
||||
|
||||
$session = (int) $_POST['admid'];
|
||||
$id = (int) $_POST['id'];
|
||||
|
||||
@@ -11,10 +11,18 @@
|
||||
if (!isset($_SESSION)) session_start();
|
||||
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
|
||||
include_once("../../config.php");
|
||||
include_once("../../Database.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");
|
||||
|
||||
$nameorig = $_POST['villagename'];
|
||||
|
||||
|
||||
@@ -12,8 +12,17 @@ if (!isset($_SESSION)) session_start();
|
||||
if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!");
|
||||
include_once("../../config.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");
|
||||
|
||||
$session = (int) $_POST['admid'];
|
||||
|
||||
|
||||
@@ -44,21 +44,21 @@ if(isset($gameinstall) && $gameinstall == 1){
|
||||
}
|
||||
include_once($autoprefix."GameEngine/Database.php");
|
||||
class adm_DB {
|
||||
|
||||
var $connection;
|
||||
|
||||
var $connection;
|
||||
function __construct(){
|
||||
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();
|
||||
}
|
||||
|
||||
function Login($username,$password){
|
||||
global $database;
|
||||
list($username,$password) = $database->escape_input($username,$password);
|
||||
|
||||
|
||||
$q = "SELECT id, password, is_bcrypt FROM ".TB_PREFIX."users where username = '$username' and access >= ".MULTIHUNTER;
|
||||
$result = mysqli_query($this->connection, $q);
|
||||
|
||||
|
||||
// if we didn't update the database for bcrypt hashes yet...
|
||||
if (mysqli_error($database->dblink) != '') {
|
||||
$q = "SELECT id, password, 0 as is_bcrypt FROM ".TB_PREFIX."users where username = '$username' and access >= ".MULTIHUNTER;
|
||||
@@ -67,27 +67,27 @@ class adm_DB {
|
||||
} else {
|
||||
$bcrypt_update_done = true;
|
||||
}
|
||||
|
||||
|
||||
$dbarray = mysqli_fetch_array($result);
|
||||
|
||||
|
||||
// even if we didn't do a DB conversion for bcrypt passwords,
|
||||
// we still need to check if this password wasn't encrypted via password_hash,
|
||||
// since all methods were updated to use that instead of md5 and therefore
|
||||
// new passwords in DB will be bcrypt already even without the is_bcrypt field present
|
||||
$bcrypted = true;
|
||||
$pwOk = password_verify($password, $dbarray['password']);
|
||||
|
||||
|
||||
if (!$pwOk && !$dbarray['is_bcrypt']) {
|
||||
$pwOk = ($dbarray['password'] == md5($password));
|
||||
$bcrypted = false;
|
||||
}
|
||||
|
||||
|
||||
if($pwOk) {
|
||||
// update password to bcrypt, if correct
|
||||
if (!$dbarray['is_bcrypt'] && !$bcrypted) {
|
||||
mysqli_query($this->connection, "UPDATE " . TB_PREFIX . "users SET password = '".password_hash($password, PASSWORD_BCRYPT,['cost' => 12])."'".($bcrypt_update_done ? ', is_bcrypt = 1' : '')." where id = ".(int) $dbarray['id']);
|
||||
}
|
||||
|
||||
|
||||
mysqli_query($this->connection,"Insert into ".TB_PREFIX."admin_log values (0,'X','$username logged in (IP: <b>".$_SERVER['REMOTE_ADDR']."</b>)',".time().")");
|
||||
return true;
|
||||
}
|
||||
@@ -122,7 +122,7 @@ class adm_DB {
|
||||
$q = "UPDATE ".TB_PREFIX."vdata set pop = $popTot where wref = ".(int) $vid;
|
||||
mysqli_query($this->connection, $q);
|
||||
}
|
||||
|
||||
|
||||
function recountCP($vid){
|
||||
global $database;
|
||||
$fdata = $database->getResourceLevel($vid);
|
||||
@@ -149,18 +149,18 @@ class adm_DB {
|
||||
}
|
||||
return $popT;
|
||||
}
|
||||
|
||||
|
||||
function buildingCP($f,$lvl){
|
||||
$name = "bid".$f;
|
||||
global $$name;
|
||||
$popT = 0;
|
||||
$dataarray = $$name;
|
||||
|
||||
|
||||
for ($i = 1; $i <= $lvl; $i++) {
|
||||
$popT += $dataarray[$i]['cp'];
|
||||
}
|
||||
return $popT;
|
||||
}
|
||||
}
|
||||
|
||||
function getWref($x,$y) {
|
||||
$q = "SELECT id FROM ".TB_PREFIX."wdata where x = ".(int) $x." and y = ".(int) $y;
|
||||
@@ -261,7 +261,7 @@ class adm_DB {
|
||||
}
|
||||
$q = "DELETE FROM ".TB_PREFIX."hero where uid = ".(int) $uid;
|
||||
mysqli_query($this->connection,$q);
|
||||
|
||||
|
||||
$name = $database->getUserField($uid,"username",0);
|
||||
mysqli_query($this->connection,"Insert into ".TB_PREFIX."admin_log values (0,$ID,'Deleted user <a>$name</a>',".time().")");
|
||||
|
||||
@@ -270,7 +270,7 @@ class adm_DB {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@ class adm_DB {
|
||||
function CheckPass($password,$uid){
|
||||
$q = "SELECT id,password, is_bcrypt FROM ".TB_PREFIX."users where id = ".(int) $uid." and access = ".ADMIN;
|
||||
$result = mysqli_query($this->connection, $q);
|
||||
|
||||
|
||||
// if we didn't update the database for bcrypt hashes yet...
|
||||
if (mysqli_error($this->connection) != '') {
|
||||
// no need to select ID here, since the DB is not updated, so there will be no password conversion later
|
||||
@@ -296,19 +296,19 @@ class adm_DB {
|
||||
}
|
||||
|
||||
$dbarray = mysqli_fetch_array($result);
|
||||
|
||||
|
||||
// even if we didn't do a DB conversion for bcrypt passwords,
|
||||
// we still need to check if this password wasn't encrypted via password_hash,
|
||||
// since all methods were updated to use that instead of md5 and therefore
|
||||
// new passwords in DB will be bcrypt already even without the is_bcrypt field present
|
||||
$bcrypted = true;
|
||||
$pwOk = password_verify($password, $dbarray['password']);
|
||||
|
||||
|
||||
if (!$pwOk && !$dbarray['is_bcrypt']) {
|
||||
$pwOk = ($dbarray['password'] == md5($password));
|
||||
$bcrypted = false;
|
||||
}
|
||||
|
||||
|
||||
if($pwOk) {
|
||||
// update password to bcrypt, if correct
|
||||
if ($bcrypt_update_done && !$dbarray['is_bcrypt']) {
|
||||
@@ -334,7 +334,7 @@ class adm_DB {
|
||||
mysqli_query($this->connection,"Insert into ".TB_PREFIX."admin_log values (0,".(int) $_SESSION['id'].",'Deleted village <b>$wref</b>',".time().")");
|
||||
|
||||
$database->clearExpansionSlot($wref);
|
||||
|
||||
|
||||
$q = "DELETE FROM ".TB_PREFIX."abdata where vref = $wref";
|
||||
mysqli_query($this->connection, $q);
|
||||
$q = "DELETE FROM ".TB_PREFIX."bdata where wid = $wref";
|
||||
@@ -357,13 +357,13 @@ class adm_DB {
|
||||
mysqli_query($this->connection, $q);
|
||||
$q = "DELETE FROM ".TB_PREFIX."raidlist where towref = $wref";
|
||||
mysqli_query($this->connection, $q);
|
||||
|
||||
|
||||
$q = "DELETE FROM ".TB_PREFIX."movement where `from` = $wref and proc=0";
|
||||
mysqli_query($this->connection, $q);
|
||||
|
||||
|
||||
$q = "UPDATE ".TB_PREFIX."wdata SET occupied = 0 where id = $wref";
|
||||
mysqli_query($this->connection, $q);
|
||||
|
||||
|
||||
$getmovement = $database->getMovement(3,$wref,1);
|
||||
foreach($getmovement as $movedata) {
|
||||
$time = microtime(true);
|
||||
@@ -375,14 +375,14 @@ class adm_DB {
|
||||
|
||||
//check return enforcement from del village
|
||||
$this->returnTroops($wref);
|
||||
|
||||
|
||||
$q = "DELETE FROM ".TB_PREFIX."vdata WHERE `wref` = $wref";
|
||||
mysqli_query($this->connection, $q);
|
||||
|
||||
|
||||
if (mysqli_affected_rows($this->connection)>0) {
|
||||
$q = "UPDATE ".TB_PREFIX."wdata set occupied = 0 where id = $wref";
|
||||
mysqli_query($this->connection, $q);
|
||||
|
||||
|
||||
$getprisoners = $database->getPrisoners($wref);
|
||||
foreach($getprisoners as $pris) {
|
||||
$troops = 0;
|
||||
@@ -403,8 +403,8 @@ class adm_DB {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function DelBan($uid,$id){
|
||||
global $database;
|
||||
$name = addslashes($database->getUserField($uid,"username",0));
|
||||
@@ -511,7 +511,7 @@ class adm_DB {
|
||||
public function getTypeLevel($tid,$vid) {
|
||||
global $village,$database;
|
||||
$keyholder = array();
|
||||
|
||||
|
||||
if($vid == 0) {
|
||||
$resourcearray = $village->resarray;
|
||||
} else {
|
||||
@@ -560,7 +560,7 @@ class adm_DB {
|
||||
|
||||
public function procDistanceTime($coor,$thiscoor,$ref,$vid) {
|
||||
global $bid28,$bid14;
|
||||
|
||||
|
||||
$xdistance = ABS($thiscoor['x'] - $coor['x']);
|
||||
if($xdistance > WORLD_MAX) {
|
||||
$xdistance = (2 * WORLD_MAX + 1) - $xdistance;
|
||||
@@ -585,17 +585,17 @@ class adm_DB {
|
||||
global $database;
|
||||
|
||||
$getenforce=$database->getEnforceVillage($wref,0);
|
||||
|
||||
|
||||
//if(($enforce['from']==$village->wid) || ($enforce['vref']==$village->wid)){
|
||||
foreach($getenforce as $enforce) {
|
||||
|
||||
|
||||
$to = $database->getVillage($enforce['from']);
|
||||
$Gtribe = "";
|
||||
if ($database->getUserField($to['owner'],'tribe',0) == '2'){ $Gtribe = "1"; }
|
||||
else if ($database->getUserField($to['owner'],'tribe',0) == '3'){ $Gtribe = "2"; }
|
||||
else if ($database->getUserField($to['owner'],'tribe',0) == '4'){ $Gtribe = "3"; }
|
||||
else if ($database->getUserField($to['owner'],'tribe',0) == '5'){ $Gtribe = "4"; }
|
||||
|
||||
|
||||
$start = ($database->getUserField($to['owner'],'tribe',0)-1)*10+1;
|
||||
$end = ($database->getUserField($to['owner'],'tribe',0)*10);
|
||||
|
||||
@@ -609,20 +609,20 @@ class adm_DB {
|
||||
|
||||
//find slowest unit.
|
||||
for($i=$start;$i<=$end;$i++){
|
||||
|
||||
|
||||
if(intval($enforce['u'.$i]) > 0){
|
||||
if($unitarray) { reset($unitarray); }
|
||||
$unitarray = $GLOBALS["u".$i];
|
||||
$speeds[] = $unitarray['speed'];
|
||||
//echo print_r(array_keys($speeds))."unitspd\n".$i."trib\n";
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
$enforce['u'.$i]='0';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
if( intval($enforce['hero']) > 0){
|
||||
$q = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".(int) $from['owner']." AND dead = 0";
|
||||
$result = mysqli_query($q);
|
||||
@@ -632,7 +632,7 @@ class adm_DB {
|
||||
} else {
|
||||
$enforce['hero']='0';
|
||||
}
|
||||
|
||||
|
||||
$artefact = count($database->getOwnUniqueArtefactInfo2($from['owner'],2,3,0));
|
||||
$artefact1 = count($database->getOwnUniqueArtefactInfo2($enforce['from'],2,1,1));
|
||||
$artefact2 = count($database->getOwnUniqueArtefactInfo2($from['owner'],2,2,0));
|
||||
@@ -646,7 +646,7 @@ class adm_DB {
|
||||
$fastertroops = 1;
|
||||
}
|
||||
$time = round($this->procDistanceTime($fromCor,$toCor,min($speeds),$enforce['from'])/$fastertroops);
|
||||
|
||||
|
||||
$foolartefact2 = $database->getFoolArtefactInfo(2,$enforce['from'],$from['owner']);
|
||||
if(count($foolartefact2) > 0){
|
||||
foreach($foolartefact2 as $arte){
|
||||
@@ -662,7 +662,7 @@ class adm_DB {
|
||||
$database->addMovement(4,$wref,$enforce['from'],$reference,time(),($time+time()));
|
||||
$database->deleteReinf($enforce['id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function calculateProduction($wid,$uid,$b1,$b2,$b3,$b4,$fdata,$ocounter,$pop) {
|
||||
@@ -671,8 +671,8 @@ class adm_DB {
|
||||
$largeA = $database->getOwnUniqueArtefactInfo($uid,4,2);
|
||||
$uniqueA = $database->getOwnUniqueArtefactInfo($uid,4,3);
|
||||
$upkeep = $this->getUpkeep($this->getAllUnits($wid),0,$wid,$uid);
|
||||
|
||||
|
||||
|
||||
|
||||
$production=array();
|
||||
$production['wood'] = $this->getWoodProd($fdata, $ocounter,$b1);
|
||||
$production['clay'] = $this->getClayProd($fdata, $ocounter,$b2);
|
||||
@@ -822,9 +822,9 @@ class adm_DB {
|
||||
}
|
||||
$ownunit['hero'] += $enforce['hero'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$prisoners = $database->getPrisoners($base,1);
|
||||
if(!empty($prisoners)) {
|
||||
foreach($prisoners as $prisoner){
|
||||
@@ -840,7 +840,7 @@ class adm_DB {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!$InVillageOnly) {
|
||||
$movement = $database->getVillageMovement($base);
|
||||
if(!empty($movement)) {
|
||||
@@ -854,7 +854,7 @@ class adm_DB {
|
||||
}
|
||||
return $ownunit;
|
||||
}
|
||||
|
||||
|
||||
public function getUpkeep($array,$type,$vid,$uid,$prisoners=0) {
|
||||
global $database;
|
||||
$buildarray = array();
|
||||
@@ -956,7 +956,7 @@ class adm_DB {
|
||||
}
|
||||
return $upkeep;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
$admin = new adm_DB;
|
||||
|
||||
+11
-7
@@ -442,15 +442,19 @@ class MYSQLi_DB implements IDbConnection {
|
||||
*/
|
||||
public function 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
|
||||
if (mysqli_error($this->dblink)) {
|
||||
return false;
|
||||
}
|
||||
// return on error
|
||||
if (mysqli_error($this->dblink)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// select the DB to use
|
||||
mysqli_select_db($this->dblink, $this->dbname);
|
||||
// select the DB to use
|
||||
mysqli_select_db($this->dblink, $this->dbname);
|
||||
}
|
||||
|
||||
// return on error
|
||||
if (mysqli_error($this->dblink)) {
|
||||
|
||||
+14
-5
@@ -2,12 +2,21 @@
|
||||
$count="0";
|
||||
include_once("GameEngine/Config.php");
|
||||
|
||||
$connection = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS) or die(mysqli_error($database->dblink));
|
||||
mysqli_select_db(SQL_DB, $connection) or die(mysqli_error($database->dblink));
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
$q = "SELECT Count(*) as Total FROM ".TB_PREFIX."movement where endtime < ".time()." and proc = 0";
|
||||
$result = mysqli_fetch_array(mysqli_query($GLOBALS["link"], $q, $connection), MYSQLI_ASSOC);
|
||||
$count=$result['Total'];
|
||||
include_once($autoprefix."GameEngine/Database.php");
|
||||
|
||||
$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'];
|
||||
|
||||
?>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user