refactor: installation happens at MySQL side

A lot has happened here. Here's the list:

1. autoloader was added that should prevent various "failed to open
stream" errors when trying to load new classes

2. PHP-based data generation was replaced by MySQL-based one, hopefully
fixing the installation problems when insert payload it too high and the
DB wouldn't populate with some users

3. thanks to step 2, the installation should be really almost
instantenious, instead of waiting a long time for many SQL connections
and queries to populate the world

4. World Data & Oasis generation and population is done in 1 step now
This commit is contained in:
Martin Ambrus
2017-10-27 18:27:03 +02:00
parent 93fbba445e
commit 1066fff9a2
26 changed files with 957 additions and 447 deletions
+1 -2
View File
@@ -19,11 +19,10 @@ GameEngine/Prevention/*
GameEngine/Notes/* GameEngine/Notes/*
# Install instalation_done marker left by install script # Install instalation_done marker left by install script
install/installation_done
/.buildpath /.buildpath
/.project /.project
/installed_*/ /installed_*/
/installation_done /var/installed
# Eclipse settings # Eclipse settings
.settings .settings
+7 -2
View File
@@ -1,9 +1,14 @@
<Files "*.tpl"> <Files "*.tpl">
Order Deny,Allow Order Allow,Deny
Deny from all Deny from all
</Files> </Files>
<Files "*.sql"> <Files "*.sql">
Order Deny,Allow Order Allow,Deny
Deny from all
</Files>
<Files "installed">
Order Allow,Deny
Deny from all Deny from all
</Files> </Files>
+7 -4
View File
@@ -20,6 +20,11 @@ if (!isset($_SESSION)) {
} }
if($_SESSION['access'] != ADMIN) die("<h1><font color=\"red\">Access Denied: You are not Admin!</font></h1>"); if($_SESSION['access'] != ADMIN) die("<h1><font color=\"red\">Access Denied: You are not Admin!</font></h1>");
set_time_limit(0); set_time_limit(0);
// TODO: truncate ALL tables (in a single query, not like this),
// then perform install steps (createDbStructure() && populateWorldData())
// .. no need for updates and inserts here, as that would keep autoincrements high
// and one nice day, after 100th reset, there will be no more integers to go for
// and the whole game would be screwed :P
mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."a2b"); mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."a2b");
mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."abdata"); mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."abdata");
mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."activate"); mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."activate");
@@ -71,12 +76,11 @@ mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."tdata");
mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."tech_log"); mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."tech_log");
mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."training"); mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."training");
mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."units"); mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."units");
mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."wdata");
$time=time(); $time=time();
mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."odata"); mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."odata");
$database->populateOasisdata();
$database->populateOasis();
$database->populateOasisUnits2();
$uid=$database->getVillageID(5); $uid=$database->getVillageID(5);
$passw=password_hash("12345", PASSWORD_BCRYPT,['cost' => 12]); $passw=password_hash("12345", PASSWORD_BCRYPT,['cost' => 12]);
@@ -93,7 +97,6 @@ mysqli_query($GLOBALS["link"], "INSERT INTO ".TB_PREFIX."tdata (vref) VALUES ($u
mysqli_query($GLOBALS["link"], "INSERT INTO ".TB_PREFIX."fdata (vref, f1t, f2t, f3t, f4t, f5t, f6t, f7t, f8t, f9t, f10t, f11t, f12t, f13t, f14t, f15t, f16t, f17t, f18t, f26, f26t, wwname) VALUES ($uid, '1', '4', '1', '3', '2', '2', '3', '4', '4', '3', '3', '4', '4', '1', '4', '2', '1', '2', '1', '15', 'World Wonder')"); mysqli_query($GLOBALS["link"], "INSERT INTO ".TB_PREFIX."fdata (vref, f1t, f2t, f3t, f4t, f5t, f6t, f7t, f8t, f9t, f10t, f11t, f12t, f13t, f14t, f15t, f16t, f17t, f18t, f26, f26t, wwname) VALUES ($uid, '1', '4', '1', '3', '2', '2', '3', '4', '4', '3', '3', '4', '4', '1', '4', '2', '1', '2', '1', '15', 'World Wonder')");
mysqli_query($GLOBALS["link"], "DELETE FROM ".TB_PREFIX."vdata WHERE owner<>5"); mysqli_query($GLOBALS["link"], "DELETE FROM ".TB_PREFIX."vdata WHERE owner<>5");
mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."wdata SET occupied=0 WHERE id<>$uid");
mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."ww_attacks"); mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."ww_attacks");
header("Location: ../admin.php?p=resetdone"); header("Location: ../admin.php?p=resetdone");
+8 -4
View File
@@ -4726,11 +4726,15 @@ $wallimg = "<img src=\"".GP_LOCATE."img/g/g3".$targettribe."Icon.gif\" height=\"
$time = time(); $time = time();
$time2 = NATURE_REGTIME; $time2 = NATURE_REGTIME;
$timeFinal = $time - $time2; $timeFinal = $time - $time2;
$q = "SELECT * FROM " . TB_PREFIX . "odata where conqured = 0 and lastupdated2 < $timeFinal"; $q = "SELECT wref FROM " . TB_PREFIX . "odata where conqured = 0 and lastupdated2 < $timeFinal";
$array = $database->query_return($q); $array = $database->query_return($q);
foreach($array as $oasis) { if (count($array)) {
$database->populateOasisUnits($oasis['wref'],$oasis['high']); $ids = [];
$database->updateOasis2($oasis['wref'], $time2); foreach($array as $oasis) {
$ids[] = $oasis['wref'];
}
$database->regenerateOasisUnits($ids, true);
} }
} }
+116 -131
View File
@@ -15,25 +15,26 @@
## ## ## ##
################################################################################# #################################################################################
if (!isset($src_prefix)) { global $autoprefix;
$src_prefix = '';
// even with autoloader created, we can't use it here yet, as it's not been created
if (substr(getcwd(), -5) === 'Admin') { // ... so, let's see where it is and include it
$src_prefix = '../'; $autoloader_found = false;
} // go max 5 levels up - we don't have folders that go deeper than that
for ($i = 0; $i < 5; $i++) {
if (substr(getcwd(), -4) === 'Mods') { $autoprefix = str_repeat('../', $i);
$src_prefix = '../../../'; if (file_exists($autoprefix.'autoloader.php')) {
} $autoloader_found = true;
include_once $autoprefix.'autoloader.php';
if (substr(getcwd(), -7) === 'include') { break;
$src_prefix = '../../';
} }
} }
if (!$autoloader_found) {
die('Could not find autoloading class.');
}
include_once("config.php"); include_once("config.php");
include_once($src_prefix."src/Database/IDbConnection.php");
include_once($src_prefix."src/Utils/Math.php");
use App\Database\IDbConnection; use App\Database\IDbConnection;
use App\Utils\Math; use App\Utils\Math;
@@ -117,7 +118,7 @@ class MYSQLi_DB implements IDbConnection {
// connect to the DB // connect to the DB
if (!$this->connect()) { if (!$this->connect()) {
die(mysqli_errno($this->dblink)); die(mysqli_error($this->dblink));
} }
// we will operate in UTF8 // we will operate in UTF8
@@ -903,110 +904,25 @@ class MYSQLi_DB implements IDbConnection {
} }
} }
function populateOasis() { function regenerateOasisUnits($wid, $automation = false) {
$q = "INSERT INTO " . TB_PREFIX . "units (vref) SELECT id FROM " . TB_PREFIX . "wdata WHERE oasistype <> 0"; global $autoprefix;
mysqli_query($this->dblink,$q);
}
function populateOasisUnits($wid, $high) { if (is_array($wid)) {
list($wid, $high) = $this->escape_input((int) $wid, $high); $wid = implode(',', $wid);
} else {
$wid = (int) $wid;
}
$basearray = $this->getOasisInfo($wid); // load the oasis regeneration (in-game) and units generation (during install) SQL file
if($high == 0){ // and replace village ID for the given $wid
$max = rand(15,30); $str = file_get_contents($autoprefix."var/db/datagen-oasis-troops-regen.sql");
}elseif($high == 1){ $str = preg_replace(["'%PREFIX%'", "'%VILLAGEID%'", "'%NATURE_REG_TIME%'"], [TB_PREFIX, $wid, ($automation ? NATURE_REGTIME : -1)], $str);
$max = rand(50,70); $result = $this->dblink->multi_query($str);
}elseif($high == 2){ if (!$result) {
$max = rand(90,120); return false;
} else { }
$max = rand(50,70);
} return true;
$max2 = 0;
$rand = rand(0,3);
if($rand == 1){
$max2 = 3;
}
//each Troop is a Set for oasis type like mountains have rats spiders and snakes fields tigers elphants clay wolves so on stonger one more not so less
switch($basearray['type']) {
case 1:
case 2:
//+25% lumber per hour
$q = "UPDATE " . TB_PREFIX . "units SET u35 = u35 + '".rand(0,5)."', u36 = u36 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND (u35 <= ".$max." OR u36 <= ".$max." OR u37 <= ".$max.")";
$result = mysqli_query($this->dblink,$q);
break;
case 3:
//+25% lumber and +25% crop per hour
$q = "UPDATE " . TB_PREFIX . "units SET u35 = u35 + '".rand(0,5)."', u36 = u36 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."', u38 = u38 + '".rand(0,5)."', u40 = u40 + '".rand(0,$max2)."' WHERE vref = '" . $wid . "' AND (u36 <= ".$max." OR u37 <= ".$max." OR u38 <= ".$max.")";
$result = mysqli_query($this->dblink,$q);
break;
case 4:
case 5:
//+25% clay per hour
$q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(0,5)."', u32 = u32 + '".rand(0,5)."', u35 = u35 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND (u31 <= ".$max." OR u32 <= ".$max." OR u35 <= ".$max.")";
$result = mysqli_query($this->dblink,$q);
break;
case 6:
//+25% clay and +25% crop per hour
$q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(0,5)."', u32 = u32 + '".rand(0,5)."', u35 = u35 + '".rand(0,5)."', u40 = u40 + '".rand(0,$max2)."' WHERE vref = '" . $wid . "' AND (u31 <= ".$max." OR u32 <= ".$max." OR u35 <= ".$max.")";
$result = mysqli_query($this->dblink,$q);
break;
case 7:
case 8:
//+25% iron per hour
$q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(0,5)."', u32 = u32 + '".rand(0,5)."', u34 = u34 + '".rand(0,5)."' WHERE vref = '" . $wid . "' AND (u31 <= ".$max." OR u32 <= ".$max." OR u34 <= ".$max.")";
$result = mysqli_query($this->dblink,$q);
break;
case 9:
//+25% iron and +25% crop
$q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + '".rand(0,5)."', u32 = u32 + '".rand(0,5)."', u34 = u34 + '".rand(0,5)."', u39 = u39 + '".rand(0,$max2)."' WHERE vref = '" . $wid . "' AND (u31 <= ".$max." OR u32 <= ".$max." OR u34 <= ".$max.")";
$result = mysqli_query($this->dblink,$q);
break;
case 10:
case 11:
//+25% crop per hour
$q = "UPDATE " . TB_PREFIX . "units SET u33 = u33 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."', u38 = u38 + '".rand(0,5)."', u39 = u39 + '".rand(0,$max2)."' WHERE vref = '" . $wid . "' AND (u33 <= ".$max." OR u37 <= ".$max." OR u38 <= ".$max.")";
$result = mysqli_query($this->dblink,$q);
break;
case 12:
//+50% crop per hour
$q = "UPDATE " . TB_PREFIX . "units SET u33 = u33 + '".rand(0,5)."', u37 = u37 + '".rand(0,5)."', u38 = u38 + '".rand(0,5)."', u39 = u39 + '".rand(0,5)."', u40 = u40 + '".rand(0,$max2)."' WHERE vref = '" . $wid . "' AND (u33 <= ".$max." OR u37 <= ".$max." OR u38 <= ".$max." OR u39 <= ".$max.")";
$result = mysqli_query($this->dblink,$q);
break;
}
}
function populateOasisUnits2() {
// +25% lumber oasis
$q = "UPDATE " . TB_PREFIX . "units SET u35 = u35 + (FLOOR(5 + RAND() * 10)), u36 = u36 + (FLOOR(0 + RAND() * 5)), u37 = u37 + (FLOOR(0 + RAND() * 5)) WHERE vref IN(SELECT id FROM " . TB_PREFIX . "wdata WHERE oasistype IN(1,2)) AND u35 <= 10 AND u36 <= 10 AND u37 <= 10";
mysqli_query($this->dblink,$q);
// +25% lumber and +25% crop oasis
$q = "UPDATE " . TB_PREFIX . "units SET u35 = u35 + (FLOOR(5 + RAND() * 15)), u36 = u36 + (FLOOR(0 + RAND() * 5)), u37 = u37 + (FLOOR(0 + RAND() * 5)) WHERE vref IN(SELECT id FROM " . TB_PREFIX . "wdata WHERE oasistype IN(3)) AND u35 <= 10 AND u36 <= 10 AND u37 <= 10";
mysqli_query($this->dblink,$q);
// +25% clay oasis
$q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + (FLOOR(10 + RAND() * 15)), u32 = u32 + (FLOOR(5 + RAND() * 15)), u35 = u35 + (FLOOR(0 + RAND() * 10)) WHERE vref IN(SELECT id FROM " . TB_PREFIX . "wdata WHERE oasistype IN(4,5)) AND u31 <= 10 AND u32 <= 10 AND u35 <= 10";
mysqli_query($this->dblink,$q);
// +25% clay and +25% crop oasis
$q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + (FLOOR(15 + RAND() * 20)), u32 = u32 + (FLOOR(10 + RAND() * 15)), u35 = u35 + (FLOOR(0 + RAND() * 10)) WHERE vref IN(SELECT id FROM " . TB_PREFIX . "wdata WHERE oasistype IN(6)) AND u31 <= 10 AND u32 <= 10 AND u35 <= 10";
mysqli_query($this->dblink,$q);
// +25% iron oasis
$q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + (FLOOR(10 + RAND() * 15)), u32 = u32 + (FLOOR(5 + RAND() * 15)), u34 = u34 + (FLOOR(0 + RAND() * 10)) WHERE vref IN(SELECT id FROM " . TB_PREFIX . "wdata WHERE oasistype IN(7,8)) AND u31 <= 10 AND u32 <= 10 AND u34 <= 10";
mysqli_query($this->dblink,$q);
// +25% iron and +25% crop oasis
$q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + (FLOOR(15 + RAND() * 20)), u32 = u32 + (FLOOR(10 + RAND() * 15)), u34 = u34 + (FLOOR(0 + RAND() * 10)) WHERE vref IN(SELECT id FROM " . TB_PREFIX . "wdata WHERE oasistype IN(9)) AND u31 <= 10 AND u32 <= 10 AND u34 <= 10";
mysqli_query($this->dblink,$q);
// +25% crop oasis
$q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + (FLOOR(5 + RAND() * 15)), u33 = u33 + (FLOOR(5 + RAND() * 10)), u37 = u37 + (FLOOR(0 + RAND() * 10)), u39 = u39 + (FLOOR(0 + RAND() * 5)) WHERE vref IN(SELECT id FROM " . TB_PREFIX . "wdata WHERE oasistype IN(10,11)) AND u31 <= 10 AND u33 <= 10 AND u37 <= 10 AND u39 <= 10";
mysqli_query($this->dblink,$q);
// +50% crop oasis
$q = "UPDATE " . TB_PREFIX . "units SET u31 = u31 + (FLOOR(10 + RAND() * 15)), u33 = u33 + (FLOOR(5 + RAND() * 10)), u38 = u38 + (FLOOR(0 + RAND() * 5)), u39 = u39 + (FLOOR(0 + RAND() * 5)) WHERE vref IN(SELECT id FROM " . TB_PREFIX . "wdata WHERE oasistype IN(12)) AND u31 <= 10 AND u33 <= 10 AND u38 <= 10 AND u39 <= 10";
mysqli_query($this->dblink,$q);
} }
function removeOases($wref) { function removeOases($wref) {
@@ -2279,15 +2195,6 @@ class MYSQLi_DB implements IDbConnection {
return mysqli_query($this->dblink,$q); return mysqli_query($this->dblink,$q);
} }
function updateOasis2($vid, $time) {
list($vid, $time) = $this->escape_input((int) $vid, $time);
$time = time();
$time2 = NATURE_REGTIME;
$q = "UPDATE " . TB_PREFIX . "odata set lastupdated2 = $time + $time2 where wref = $vid";
return mysqli_query($this->dblink,$q);
}
function setVillageName($vid, $name) { function setVillageName($vid, $name) {
list($vid, $name) = $this->escape_input((int) $vid, $name); list($vid, $name) = $this->escape_input((int) $vid, $name);
@@ -3953,10 +3860,88 @@ class MYSQLi_DB implements IDbConnection {
} }
} }
function populateOasisdata() { /**
$q = "INSERT INTO " . TB_PREFIX . "odata SELECT id, oasistype, 0, 800, 800, 800, 800, 800, 800, UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), 100, 2 , \"Unoccupied Oasis\", CASE WHEN oasistype < 4 THEN 1 WHEN oasistype < 10 THEN 2 ELSE 0 END FROM " . TB_PREFIX . "wdata WHERE oasistype <> 0"; * Creates a database structure for the game.
mysqli_query($this->dblink,$q) OR DIE (mysqli_error($this->dblink)); * Used during installation.
} *
* @return boolean|number Returns TRUE, FALSE or -1. True is for successful data import
* (from prepared SQL file), false is in case of an SQL error.
* -1 will be returned in case of any unexpected behavior
* and unhandled exceptions.
*/
public function createDbStructure() {
global $autoprefix;
try {
// check that we don't have the structure in place already
// (we'd have at least 1 user present, since 4 are being created by default - Support, Nature, Multihunter & Taskmaster)
$data_exist = $this->query_return("SELECT * FROM " . TB_PREFIX . "users LIMIT 1");
if ($data_exist && count($data_exist)) {
return false;
}
// load the DB structure SQL file
$str = file_get_contents($autoprefix."var/db/struct.sql");
$str = preg_replace("'%PREFIX%'", TB_PREFIX, $str);
$result = $this->dblink->multi_query($str);
if (!$result) {
echo mysqli_error($this->dblink); exit;
return false;
}
} catch (\Exception $e) {
return -1;
}
return true;
}
/**
* Populates the game database with Map World Data (i.e. creates the whole
* world with X,Y coordinate squares and their types).
*
* Also populates oasis' table data for the squares where there are oasis.
*
* @return boolean|number Returns TRUE, FALSE or -1. True is for successful data import
* (from prepared SQL file), false is in case of an SQL error.
* -1 will be returned in case of any unexpected behavior
* and unhandled exceptions.
*/
public function populateWorldData() {
global $autoprefix;
try {
// check if we don't already have world data
$data_exist = $this->query_return("SELECT * FROM " . TB_PREFIX . "wdata LIMIT 1");
if ($data_exist && count($data_exist)) {
return false;
}
// load the data generation SQL file
$str = file_get_contents($autoprefix."var/db/datagen-world-data.sql");
$str = preg_replace(["'%PREFIX%'", "'%WORLDSIZE%'"], [TB_PREFIX, WORLD_MAX], $str);
$result = $this->dblink->multi_query($str);
if (!$result) {
return -1;
} else {
// we need to flush the result of our previous multi_query
// or the next multi_query in regenerateOasisUnits() will cause
// a "Commands out of sync; you can't run this command now" error
// more info: https://stackoverflow.com/a/27926561/467164
while (mysqli_next_result($this->dblink)) {;}
}
$result = $this->regenerateOasisUnits(-1);
if (!$result) {
echo mysqli_error($this->dblink);
return -1;
}
} catch (\Exception $e) {
return -1;
}
return true;
}
public function getAvailableExpansionTraining() { public function getAvailableExpansionTraining() {
global $building, $session, $technology, $village; global $building, $session, $technology, $village;
+3 -4
View File
@@ -20,10 +20,9 @@ mb_internal_encoding("UTF-8"); // Add for utf8 varriables.
## ## ## ##
################################################################################# #################################################################################
if(file_exists('GameEngine/config.php') || file_exists('../../GameEngine/config.php') || file_exists('../../config.php') || file_exists('../GameEngine/config.php')) { if(!file_exists('GameEngine/config.php') && !file_exists('../GameEngine/config.php') && !file_exists('../../GameEngine/config.php') && !file_exists('../../config.php')) {
}else{ header("Location: install/");
header("Location: install/"); exit;
exit;
} }
$script_name = ($_SERVER['REQUEST_URI'] == 'karte.php') ? 'karte' : $_SERVER['REQUEST_URI']; $script_name = ($_SERVER['REQUEST_URI'] == 'karte.php') ? 'karte' : $_SERVER['REQUEST_URI'];
+1 -5
View File
@@ -248,11 +248,7 @@ class Units {
} }
//set oasis to default //set oasis to default
if (count($getenforce1)>0) { if (count($getenforce1)>0) {
$q = "DELETE FROM ".TB_PREFIX."ndata WHERE toWref=".(int) $getenforce1[0]['vref']; $database->regenerateOasisUnits($getenforce1[0]['vref']);
$database->query($q);
$database->populateOasisUnits($getenforce1[0]['vref'],$getenforce1[0]['high']);
$q = "UPDATE ".TB_PREFIX."odata SET conqured=0,wood=800,iron=800,clay=800,maxstore=800,crop=800,maxcrop=800,lastupdated=". time().",lastupdated2=".time().",loyalty=100,owner=2,name='Unoccupied Oasis' WHERE conqured=".(int) $wref;
$database->query($q);
} }
} }
+23
View File
@@ -0,0 +1,23 @@
<?php
function autoloadClass($class) {
// strip the App classname's namespace
$clazz = str_replace(['App\\', '\\'], ['', '/'], $class);
// search for class
$class_found = false;
// go max 5 levels up - we don't have folders that go deeper than that
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
if (file_exists($autoprefix.'src/' . $clazz . '.php')) {
$class_found = true;
include_once $autoprefix.'src/' . $clazz . '.php';
break;
}
}
if (!$class_found) {
throw new Exception('Unable to find class ' . $clazz . '.');
}
}
spl_autoload_register('autoloadClass');
+1 -1
View File
@@ -17,7 +17,7 @@
## ## ## ##
################################################################################# #################################################################################
if(!file_exists('GameEngine/config.php')) { if(!file_exists('var/installed')) {
header("Location: install/"); header("Location: install/");
exit; exit;
} }
-30
View File
@@ -1,30 +0,0 @@
<?php
//////////////////////////////////////////////////////////////////////////////////////////////////////
// TRAVIANX //
// Only for advanced users, do not edit if you dont know what are you doing! //
// Made by: Dzoki & Dixie (TravianX) //
// - TravianX = Travian Clone Project - //
// DO NOT REMOVE COPYRIGHT NOTICE! //
//////////////////////////////////////////////////////////////////////////////////////////////////////
include("constant.php");
class MYSQLi_DB {
var $connection;
function MYSQLi_DB() {
$this->connection = mysqli_connect(SQL_SERVER, SQL_USER, SQL_PASS, SQL_DB) or die(mysqli_error($database->dblink));
}
function query($query) {
return mysqli_query($this->connection, $query);
}
function query_return($query) {
$q = mysqli_query($this->connection, $query);
return mysqli_fetch_assoc($q);
}
};
if(DB_TYPE) {
$database = new MYSQLi_DB;
}
?>
-28
View File
@@ -1,28 +0,0 @@
<?php
// don't let SQL time out when 30-500 seconds (depending on php.ini) is not enough
@set_time_limit(0);
if(!isset($_SESSION)) session_start();
$gameinstall = 1;
include ("../../GameEngine/config.php");
include ("../../GameEngine/Database.php");
include ("../../GameEngine/Admin/database.php");
// check if we don't already have world data
$data_exist = $database->query_return("SELECT * FROM " . TB_PREFIX . "odata LIMIT 1");
if (count($data_exist)) {
header("Location: ../index.php?s=6&err=1");
exit;
}
$database->populateOasisdata();
$database->populateOasis();
$database->populateOasisUnits2();
header("Location: ../index.php?s=7");
?>
-140
View File
@@ -1,140 +0,0 @@
<?php
//////////////////////////////////////////////////////////////////////////////////////////////////////
// TRAVIANX //
// Only for advanced users, do not edit if you dont know what are you doing! //
// Made by: Dzoki & Dixie (TravianX) //
// - TravianX = Travian Clone Project - //
// DO NOT REMOVE COPYRIGHT NOTICE! //
//////////////////////////////////////////////////////////////////////////////////////////////////////
// don't let SQL time out when 30-500 seconds (depending on php.ini) is not enough
@set_time_limit(0);
include("database.php");
// check if we don't already have world data
$data_exist = $database->query_return("SELECT * FROM " . TB_PREFIX . "wdata LIMIT 1");
if (count($data_exist)) {
header("Location: ../index.php?s=3&err=1");
exit;
}
$xyas=(1+(2*WORLD_MAX));
$values_batch = [];
$max_batch_size = 10000;
for($i=0; $i<$xyas; $i++){
$y=(WORLD_MAX-$i);
for($j=0; $j<$xyas; $j++){
$x=((WORLD_MAX*-1)+$j);
//choose a field type
if(($x == 0 & $y == 0) || ($x == WORLD_MAX & $y == WORLD_MAX)) {
$typ='3';
$otype='0';
}else{
$rand=rand(1, 1000);
if("10" >= $rand){
$typ='1';
$otype='0';
} else if("90" >= $rand){
$typ='2';
$otype='0';
} else if("400" >= $rand){
$typ='3';
$otype='0';
} else if("480" >= $rand){
$typ='4';
$otype='0';
} else if("560" >= $rand){
$typ='5';
$otype='0';
} else if("570" >= $rand){
$typ='6';
$otype='0';
} else if("600" >= $rand){
$typ='7';
$otype='0';
} else if("630" >= $rand){
$typ='8';
$otype='0';
} else if("660" >= $rand){
$typ='9';
$otype='0';
} else if("740" >= $rand){
$typ='10';
$otype='0';
} else if("820" >= $rand){
$typ='11';
$otype='0';
} else if("900" >= $rand){
$typ='12';
$otype='0';
} else if("908" >= $rand){
$typ='0';
$otype='1';
} else if("916" >= $rand){
$typ='0';
$otype='2';
} else if("924" >= $rand){
$typ='0';
$otype='3';
} else if("932" >= $rand){
$typ='0';
$otype='4';
} else if("940" >= $rand){
$typ='0';
$otype='5';
} else if("948" >= $rand){
$typ='0';
$otype='6';
} else if("956" >= $rand){
$typ='0';
$otype='7';
} else if("964" >= $rand){
$typ='0';
$otype='8';
} else if("972" >= $rand){
$typ='0';
$otype='9';
} else if("980" >= $rand){
$typ='0';
$otype='10';
} else if("988" >= $rand){
$typ='0';
$otype='11';
} else {
$typ='0';
$otype='12';
}
}
//image pick
if($otype=='0'){
$image="t".rand(0,9)."";
} else {
$image="o".$otype."";
}
//into database
$values_batch[] = "(0,'".$typ."','".$otype."','".$x."','".$y."',0,'".$image."')";
// insert the full batch when threshold is reached
if (count($values_batch) === $max_batch_size) {
$q = "INSERT into ".TB_PREFIX."wdata VALUES ".implode(',', $values_batch);
$database->query($q);
$values_batch = [];
}
}
}
// last batch may not be as big as $max_batch_size
if (count($values_batch)) {
$q = "INSERT into ".TB_PREFIX."wdata VALUES ".implode(',', $values_batch);
$database->query($q);
$values_batch = [];
}
header("Location: ../index.php?s=4");
?>
+14 -9
View File
@@ -53,8 +53,16 @@ function refresh(tz) {
location="?s=1&t="+tz; location="?s=1&t="+tz;
} }
function proceed() { function proceed() {
document.dataform.Submit.disabled=true; var e = document.getElementById('Submit');
return(true);
// if we disable the button right away, we wouldn't be able to submit the form
setTimeout(function() {
e.disabled = "disabled";
}, 500);
e.value = "Processing...";
return true;
} }
</script> </script>
<div class="wrapper"> <div class="wrapper">
@@ -74,7 +82,7 @@ function proceed() {
<div id="content" class="login"> <div id="content" class="login">
<?php <?php
IHG_Progressbar::draw_css(); IHG_Progressbar::draw_css();
$bar = new IHG_Progressbar(8, 'Step %d from %d '); $bar = new IHG_Progressbar(7, 'Step %d from %d ');
$bar->draw(); $bar->draw();
for($i = 0; $i < ($_GET['s']+1); $i++) { for($i = 0; $i < ($_GET['s']+1); $i++) {
$bar->tick(); $bar->tick();
@@ -88,8 +96,8 @@ function proceed() {
if(substr(sprintf('%o', fileperms('../')), -4)<'700'){ if(substr(sprintf('%o', fileperms('../')), -4)<'700'){
echo"<span class='f18 c5'>ERROR!</span><br />It's not possible to write the config file. Change the permission to '777'. After that, refresh this page!"; echo"<span class='f18 c5'>ERROR!</span><br />It's not possible to write the config file. Change the permission to '777'. After that, refresh this page!";
} }
else if (file_exists("installation_done")) { else if (file_exists("../var/installed")) {
echo"<span class='f18 c5'>ERROR!</span><br />Installation appears to have been completed.<br />If this is an error remove installation_done file in install directory."; echo"<span class='f18 c5'>ERROR!</span><br />Installation appears to have been completed.<br />If this is an error remove /var/installed file in install directory.";
} }
else else
switch($_GET['s']){ switch($_GET['s']){
@@ -103,7 +111,7 @@ function proceed() {
include("templates/dataform.tpl"); include("templates/dataform.tpl");
break; break;
case 3: case 3:
include("templates/field.tpl"); include("templates/wdata.tpl");
break; break;
case 4: case 4:
include("templates/multihunter.tpl"); include("templates/multihunter.tpl");
@@ -112,9 +120,6 @@ function proceed() {
include("templates/support.tpl"); include("templates/support.tpl");
break; break;
case 6: case 6:
include("templates/oasis.tpl");
break;
case 7:
include("templates/end.tpl"); include("templates/end.tpl");
break; break;
} }
+49 -23
View File
@@ -12,12 +12,9 @@
// don't let SQL time out when 30-500 seconds (depending on php.ini) is not enough // don't let SQL time out when 30-500 seconds (depending on php.ini) is not enough
@set_time_limit(0); @set_time_limit(0);
if(file_exists("include/constant.php")) {
include ("include/database.php");
}
class Process { class Process {
function Process() { function __construct() {
if(isset($_POST['subconst'])) { if(isset($_POST['subconst'])) {
$this->constForm(); $this->constForm();
} else } else
@@ -34,15 +31,16 @@ class Process {
} }
} }
function constForm() { private function constForm() {
$myFile = "include/constant.php"; $myFile = "../GameEngine/config.php";
$fh = fopen($myFile, 'w') or die("<br/><br/><br/>Can't open file: install\include\constant.php"); $fh = @fopen($myFile, 'w') or die("<br/><br/><br/>Can't create or update file: GameEngine\config.php");
$text = file_get_contents("data/constant_format.tpl"); $text = file_get_contents("data/constant_format.tpl");
$text = preg_replace("'%SERVERNAME%'", $_POST['servername'], $text); $text = preg_replace("'%SERVERNAME%'", $_POST['servername'], $text);
$text = preg_replace("'%SSTARTDATE%'", $_POST['start_date'], $text); $text = preg_replace("'%SSTARTDATE%'", $_POST['start_date'], $text);
$text = preg_replace("'%SSTARTTIME%'", $_POST['start_time'], $text); $text = preg_replace("'%SSTARTTIME%'", $_POST['start_time'], $text);
$tz = explode(",",$_POST['tzone']); $tz = explode(",",$_POST['tzone']);
$text = preg_replace("'%STIMEZONE%'", $tz[1], $text); $text = preg_replace("'%STIMEZONE%'", $tz[1], $text);
$text = preg_replace("'%LANG%'", $_POST['lang'], $text); $text = preg_replace("'%LANG%'", $_POST['lang'], $text);
$text = preg_replace("'%SPEED%'", $_POST['speed'], $text); $text = preg_replace("'%SPEED%'", $_POST['speed'], $text);
$text = preg_replace("'%INCSPEED%'", $_POST['incspeed'], $text); $text = preg_replace("'%INCSPEED%'", $_POST['incspeed'], $text);
@@ -125,7 +123,7 @@ class Process {
fwrite($fh, $text); fwrite($fh, $text);
if(file_exists("include/constant.php")) { if(file_exists("../GameEngine/config.php")) {
header("Location: index.php?s=2"); header("Location: index.php?s=2");
} else { } else {
header("Location: index.php?s=1&c=1"); header("Location: index.php?s=1&c=1");
@@ -134,24 +132,52 @@ class Process {
fclose($fh); fclose($fh);
} }
/**
* Creates database structure for the game.
*/
function createStruc() { function createStruc() {
global $database; global $database;
$str = file_get_contents("data/sql.sql");
$str = preg_replace("'%PREFIX%'", TB_PREFIX, $str); include ("../GameEngine/config.php");
if(DB_TYPE) { include ("../GameEngine/Database.php");
$result = $database->connection->multi_query($str); include ("../GameEngine/Admin/database.php");
} else {
$result = $database->mysql_exec_batch($str); // create table structure
} $result = $database->createDbStructure();
if($result) { if ($result === false) {
header("Location: index.php?s=3"); header("Location: index.php?s=2&err=1");
} else { exit;
header("Location: index.php?s=2&c=1"); } else if ($result === -1) {
} header("Location: index.php?s=2&c=1");
exit;
}
header("Location: index.php?s=3");
exit;
} }
/**
* Generates map data and populates it with oasis.
*/
function createWdata() { function createWdata() {
header("Location: include/wdata.php"); global $database;
include ("../GameEngine/config.php");
include ("../GameEngine/Database.php");
include ("../GameEngine/Admin/database.php");
// populate world data
$result = $database->populateWorldData();
if ($result === false) {
header("Location: index.php?s=3&err=1");
exit;
} else if ($result === -1) {
header("Location: index.php?s=3&c=1");
exit;
}
header("Location: index.php?s=4");
exit;
} }
} }
+29 -9
View File
@@ -14,20 +14,40 @@
## Source code: https://github.com/Shadowss/TravianZ ## ## Source code: https://github.com/Shadowss/TravianZ ##
## ## ## ##
################################################################################# #################################################################################
include_once('../GameEngine/config.php');
if(isset($_GET['c']) && $_GET['c'] == 1) { if(isset($_GET['c']) && $_GET['c'] == 1) {
echo "<div class=\"headline\"><span class=\"f10 c5\">Error importing database. Check configuration.</span></div><br>"; echo "<div class=\"headline\"><span class=\"f10 c5\">Error importing database. Check configuration.</span></div><br>";
}
if(isset($_GET['err']) && $_GET['err'] == 1) {
echo "<br /><hr /><br /><div class=\"headline\"><span class=\"f10 c5\">Existing structure was found in the database! Please remove old game tables with the <i>".TB_PREFIX."</i> prefix from the '<strong>".SQL_DB."</strong>' database before continuing.</span></div><br /><br />";
} }
?> ?>
<form action="process.php" method="post" id="dataform"> <form action="process.php" method="post" id="dataform">
<input type="hidden" name="substruc" value="1"> <input type="hidden" name="substruc" value="1">
<p> <p>
<span class="f10 c">Create SQL Structure</span> <span class="f10 c">Create Database Structure</span>
<table>
<tr><td>Warning: This can take some time. Wait till the next page has been loaded! Click Create to proceed..</td></tr> <table>
<tr><td><center><input type="submit" name="Submit" id="Submit" value="Create.." onClick="return proceed()"></center></td></tr> <tr>
</table> <td>
</p> Warning: This can take some time. Please wait until the next page has been loaded. Click Create to proceed...
<br />
<br />
</td>
</tr>
<tr>
<td>
<center>
<input type="submit" name="Submit" id="Submit" value="Create" onClick="return proceed()" />
<br />
<br />
</center>
</td>
</tr>
</table>
</p>
</form> </form>
</div> </div>
+1 -1
View File
@@ -37,7 +37,7 @@ All the files are placed. The database is created, so you can now start playing
<?php include("../GameEngine/config.php"); <?php include("../GameEngine/config.php");
$time = time(); $time = time();
rename("../install/","../installed_".$time); rename("../install/","../installed_".$time);
touch("../installation_done"); touch('../var/installed');
?> ?>
<p> <p>
<center><font size="4"><a href="<?php echo HOMEPAGE; ?>">> My TravianZ homepage <</font></a></center> <center><font size="4"><a href="<?php echo HOMEPAGE; ?>">> My TravianZ homepage <</font></a></center>
+7 -10
View File
@@ -19,28 +19,25 @@
switch($_GET['s']) { switch($_GET['s']) {
case 0: case 0:
echo "<li class=\"c2 f9\">Intro</li><li class=\"c1 f9\">Configuration</li><li class=\"c1 f9\">Database</li><li class= \"c1 f9\">Field</li><li class=\"c1 f9\">Multihunter</li><li class=\"c1 f9\">Support</li><li class=\"c1 f9\">Oasis</li><li class=\"c1 f9\">End</li>"; echo "<li class=\"c2 f9\">Intro</li><li class=\"c1 f9\">Configuration</li><li class=\"c1 f9\">Database</li><li class= \"c1 f9\">World Data</li><li class=\"c1 f9\">Multihunter</li><li class=\"c1 f9\">Support</li><li class=\"c1 f9\">End</li>";
break; break;
case 1: case 1:
echo "<li class=\"c3 f9\">Intro</li><li class=\"c2 f9\">Configuration</li><li class=\"c1 f9\">Database</li><li class= \"c1 f9\">Field</li><li class=\"c1 f9\">Multihunter</li><li class=\"c1 f9\">Support</li><li class=\"c1 f9\">Oasis</li><li class=\"c1 f9\">End</li>"; echo "<li class=\"c3 f9\">Intro</li><li class=\"c2 f9\">Configuration</li><li class=\"c1 f9\">Database</li><li class= \"c1 f9\">World Data</li><li class=\"c1 f9\">Multihunter</li><li class=\"c1 f9\">Support</li><li class=\"c1 f9\">End</li>";
break; break;
case 2: case 2:
echo "<li class=\"c3 f9\">Intro</li><li class=\"c3 f9\">Configuration</li><li class=\"c2 f9\">Database</li><li class= \"c1 f9\">Field</li><li class=\"c1 f9\">Multihunter</li><li class=\"c1 f9\">Support</li><li class=\"c1 f9\">Oasis</li><li class=\"c1 f9\">End</li>"; echo "<li class=\"c3 f9\">Intro</li><li class=\"c3 f9\">Configuration</li><li class=\"c2 f9\">Database</li><li class= \"c1 f9\">World Data</li><li class=\"c1 f9\">Multihunter</li><li class=\"c1 f9\">Support</li><li class=\"c1 f9\">End</li>";
break; break;
case 3: case 3:
echo "<li class=\"c3 f9\">Intro</li><li class=\"c3 f9\">Configuration</li><li class=\"c3 f9\">Database</li><li class= \"c2 f9\">Field</li><li class=\"c1 f9\">Multihunter</li><li class=\"c1 f9\">Support</li><li class=\"c1 f9\">Oasis</li><li class=\"c1 f9\">End</li>"; echo "<li class=\"c3 f9\">Intro</li><li class=\"c3 f9\">Configuration</li><li class=\"c3 f9\">Database</li><li class= \"c2 f9\">World Data</li><li class=\"c1 f9\">Multihunter</li><li class=\"c1 f9\">Support</li><li class=\"c1 f9\">End</li>";
break; break;
case 4: case 4:
echo "<li class=\"c3 f9\">Intro</li><li class=\"c3 f9\">Configuration</li><li class=\"c3 f9\">Database</li><li class= \"c3 f9\">Field</li><li class=\"c2 f9\">Multihunter</li><li class=\"c1 f9\">Support</li><li class=\"c1 f9\">Oasis</li><li class=\"c1 f9\">End</li>"; echo "<li class=\"c3 f9\">Intro</li><li class=\"c3 f9\">Configuration</li><li class=\"c3 f9\">Database</li><li class= \"c3 f9\">World Data</li><li class=\"c2 f9\">Multihunter</li><li class=\"c1 f9\">Support</li><li class=\"c1 f9\">End</li>";
break; break;
case 5: case 5:
echo "<li class=\"c3 f9\">Intro</li><li class=\"c3 f9\">Configuration</li><li class=\"c3 f9\">Database</li><li class= \"c3 f9\">Field</li><li class=\"c3 f9\">Multihunter</li><li class=\"c2 f9\">Support</li><li class=\"c1 f9\">Oasis</li><li class=\"c1 f9\">End</li>"; echo "<li class=\"c3 f9\">Intro</li><li class=\"c3 f9\">Configuration</li><li class=\"c3 f9\">Database</li><li class= \"c3 f9\">World Data</li><li class=\"c3 f9\">Multihunter</li><li class=\"c2 f9\">Support</li><li class=\"c1 f9\">End</li>";
break; break;
case 6: case 6:
echo "<li class=\"c3 f9\">Intro</li><li class=\"c3 f9\">Configuration</li><li class=\"c3 f9\">Database</li><li class= \"c3 f9\">Field</li><li class=\"c3 f9\">Multihunter</li><li class=\"c3 f9\">Support</li><li class=\"c2 f9\">Oasis</li><li class=\"c1 f9\">End</li>"; echo "<li class=\"c3 f9\">Intro</li><li class=\"c3 f9\">Configuration</li><li class=\"c3 f9\">Database</li><li class= \"c3 f9\">World Data</li><li class=\"c3 f9\">Multihunter</li><li class=\"c3 f9\">Support</li><li class=\"c2 f9\">End</li>";
break;
case 7:
echo "<li class=\"c3 f9\">Intro</li><li class=\"c3 f9\">Configuration</li><li class=\"c3 f9\">Database</li><li class= \"c3 f9\">Field</li><li class=\"c3 f9\">Multihunter</li><li class=\"c3 f9\">Support</li><li class=\"c3 f9\">Oasis</li><li class=\"c2 f9\">End</li>";
break; break;
} }
-1
View File
@@ -14,7 +14,6 @@
## Source code: https://github.com/Shadowss/TravianZ ## ## Source code: https://github.com/Shadowss/TravianZ ##
## ## ## ##
################################################################################# #################################################################################
rename("include/constant.php","../GameEngine/config.php");
?> ?>
-24
View File
@@ -1,24 +0,0 @@
<?php
//////////////////////////////////////////////////////////////////////////////////////////////////////
// TRAVIANX //
// Only for advanced users, do not edit if you dont know what are you doing! //
// Made by: Dzoki & Dixie (TravianX) //
// - TravianX = Travian Clone Project - //
// DO NOT REMOVE COPYRIGHT NOTICE! //
//////////////////////////////////////////////////////////////////////////////////////////////////////
if(isset($_GET['err']) && $_GET['err'] == 1) {
echo "<br /><hr /><br /><div class=\"headline\"><span class=\"f10 c5\">Existing Oasis data found in the database! Please clear the 'odata' table before continuing.</span></div><br /><br />";
}
?>
<form action="include/oasis.php" method="post" id="dataform">
<p>
<span class="f10 c">Populate Oasis</span>
<table>
<tr><td><b>Warning</b>: This can take some time. Wait till the next page has been loaded! Click Create to proceed..</td></tr>
<tr><td><center><input type="submit" name="Submit" id="Submit" value="Create.." onClick="return proceed()"></center></td></tr>
</table>
</p>
</form>
</div>
@@ -4,7 +4,7 @@
## --------------------------------------------------------------------------- ## ## --------------------------------------------------------------------------- ##
## Project: TravianZ ## ## Project: TravianZ ##
## Version: 22.06.2015 ## ## Version: 22.06.2015 ##
## Filename field.tpl ## ## Filename wdata.tpl ##
## Developed by: Mr.php , Advocaite , brainiacX , yi12345 , Shadow , ronix ## ## Developed by: Mr.php , Advocaite , brainiacX , yi12345 , Shadow , ronix ##
## Fixed by: Shadow - STARVATION , HERO FIXED COMPL. ## ## Fixed by: Shadow - STARVATION , HERO FIXED COMPL. ##
## Fixed by: InCube - double troops ## ## Fixed by: InCube - double troops ##
@@ -15,12 +15,14 @@
## ## ## ##
################################################################################# #################################################################################
include_once('../GameEngine/config.php');
if(isset($_GET['c']) && $_GET['c'] == 1) { if(isset($_GET['c']) && $_GET['c'] == 1) {
echo "<br /><hr /><br /><div class=\"headline\"><span class=\"f10 c5\">Error creating wdata. Check configuration or file.</span></div><br><br>"; echo "<br /><hr /><br /><div class=\"headline\"><span class=\"f10 c5\">Error creating wdata. Check configuration or file.</span></div><br><br>";
} }
if(isset($_GET['err']) && $_GET['err'] == 1) { if(isset($_GET['err']) && $_GET['err'] == 1) {
echo "<br /><hr /><br /><div class=\"headline\"><span class=\"f10 c5\">Existing World Data found in the database! Please clear your database before continuing.</span></div><br /><br />"; echo "<br /><hr /><br /><div class=\"headline\"><span class=\"f10 c5\">Existing World Data found in the database! Please empty tables <i>".TB_PREFIX."odata, ".TB_PREFIX."units, ".TB_PREFIX."vdata, ".TB_PREFIX."wdata</i> before continuing.</span></div><br /><br />";
} }
?> ?>
<form action="process.php" method="post" id="dataform"> <form action="process.php" method="post" id="dataform">
+1 -1
View File
@@ -9,7 +9,7 @@
## Copyright: TravianX (c) 2010-2011. All rights reserved. ## ## Copyright: TravianX (c) 2010-2011. All rights reserved. ##
## ## ## ##
################################################################################# #################################################################################
if(!file_exists('GameEngine/config.php')) { if(!file_exists('var/installed')) {
header("Location: install/"); header("Location: install/");
exit; exit;
} }
-15
View File
@@ -14,21 +14,6 @@
namespace App\Entity; namespace App\Entity;
if (!isset($src_prefix)) {
$src_prefix = '';
if (substr(getcwd(), -5) === 'Admin') {
$src_prefix = '../';
}
if (substr(getcwd(), -4) === 'Mods') {
$src_prefix = '../../../';
}
}
include_once($src_prefix."src/Database/IDbConnection.php");
include_once($src_prefix."src/Utils/Math.php");
use App\Database\IDbConnection; use App\Database\IDbConnection;
use App\Utils\Math; use App\Utils\Math;
+1
View File
@@ -1,4 +1,5 @@
- link username to user when sending alliance forum notification message - link username to user when sending alliance forum notification message
- link username to user in message sender
- add checkbox when sending units for a raid to include the attack in the raid list, if eligible - add checkbox when sending units for a raid to include the attack in the raid list, if eligible
- change "incoming attacker" title of the raid list icon when actually attacking a farm (it should be "Own attacking troops") - change "incoming attacker" title of the raid list icon when actually attacking a farm (it should be "Own attacking troops")
- change "select all" button to actually select all checkboxes via JS, not via page reload - change "select all" button to actually select all checkboxes via JS, not via page reload
+535
View File
@@ -0,0 +1,535 @@
-- ----------------------------------------------------------------------------------------
-- oasis regeneration script
-- used during installation, server reset, oasis reset & automation (nature repopulation)
--
-- author: martinambrus
-- ----------------------------------------------------------------------------------------
-- Nature regeneration time.
--
-- type: int
-- description: when > -1, used to update the last oasis reset time (Automation nature regeneration)
-- when == -1, used to reset oasis data into original state (conquered > unoccupied)
SET @natureRegTime = %NATURE_REG_TIME%;
-- Oasis village ID.
--
-- type: int
-- description: when > -1, used to regenerate units of a single oasis (when conquered > unoccupied)
-- when == -1, installation or server reset in progress, all oasis data are updated
SET @village = %VILLAGEID%;
-- minimum and maximum number of units for oasis with "high" field set to 0
SET @minUnitsForOasis0 = 15;
SET @maxUnitsForOasis0 = 30;
-- minimum and maximum number of units for oasis with "high" field set to 1
SET @minUnitsForOasis1 = 50;
SET @maxUnitsForOasis1 = 70;
-- minimum and maximum number of units for oasis with "high" field set to 2
SET @minUnitsForOasis2 = 90;
SET @maxUnitsForOasis2 = 120;
-- ----------------------------------------
-- reset oasis data (conquered > unoccupied)
-- ------------------------------------------
UPDATE %PREFIX%odata
SET
conqured = 0,
wood = 800,
iron = 800,
clay = 800,
maxstore = 800,
crop = 800,
maxcrop = 800,
lastupdated = UNIX_TIMESTAMP(),
lastupdated2 = UNIX_TIMESTAMP(),
loyalty=100,
owner=2,
name='Unoccupied Oasis'
WHERE
@natureRegTime = -1
AND
conqured IN ( @village );
-- ---------------------------------------------
-- remove past reports (conquered > unoccupied)
-- ---------------------------------------------
DELETE FROM %PREFIX%ndata
WHERE
@natureRegTime = -1
AND
toWref IN ( @village );
-- ----------------------------------------------------------------
-- update next regeneration time (Automation, nature regeneration)
-- ----------------------------------------------------------------
UPDATE
%PREFIX%odata
SET
lastupdated2 = UNIX_TIMESTAMP() + @natureRegTime
WHERE
@natureRegTime > -1
AND
wref IN ( @village );
-- -----------------------------------------------------------------------
-- update number of units depending on the oasis type --
-- the more lucrative the oasis is, the better defense will it get :-P --
-- -----------------------------------------------------------------------
-- +25% lumber oasis
UPDATE %PREFIX%units u
JOIN %PREFIX%odata o
ON u.vref = o.wref
SET
u.u35 = u.u35 + (FLOOR(5 + RAND() * 10)),
u36 = u36 + (FLOOR(0 + RAND() * 5)),
u37 = u37 + (FLOOR(0 + RAND() * 5))
WHERE
(
(
@village = -1
AND
vref IN(
SELECT
id
FROM
s1_wdata
WHERE
oasistype IN(1,2)
)
)
OR
(
@village > -1
AND
vref = @village
)
)
AND
(
u35 <= (
CASE o.high
WHEN 0 THEN (FLOOR(@minUnitsForOasis0 + RAND() * @maxUnitsForOasis0))
WHEN 1 THEN (FLOOR(@minUnitsForOasis1 + RAND() * @maxUnitsForOasis1))
WHEN 2 THEN (FLOOR(@minUnitsForOasis2 + RAND() * @maxUnitsForOasis2))
END
)
OR u36 <= (
CASE o.high
WHEN 0 THEN (FLOOR(@minUnitsForOasis0 + RAND() * @maxUnitsForOasis0))
WHEN 1 THEN (FLOOR(@minUnitsForOasis1 + RAND() * @maxUnitsForOasis1))
WHEN 2 THEN (FLOOR(@minUnitsForOasis2 + RAND() * @maxUnitsForOasis2))
END
)
OR u37 <= (
CASE o.high
WHEN 0 THEN (FLOOR(@minUnitsForOasis0 + RAND() * @maxUnitsForOasis0))
WHEN 1 THEN (FLOOR(@minUnitsForOasis1 + RAND() * @maxUnitsForOasis1))
WHEN 2 THEN (FLOOR(@minUnitsForOasis2 + RAND() * @maxUnitsForOasis2))
END
)
);
-- +25% lumber and +25% crop oasis
UPDATE %PREFIX%units u
JOIN %PREFIX%odata o
ON u.vref = o.wref
SET
u35 = u35 + (FLOOR(5 + RAND() * 15)),
u36 = u36 + (FLOOR(0 + RAND() * 5)),
u37 = u37 + (FLOOR(0 + RAND() * 5)),
u38 = u38 + (FLOOR(0 + RAND() * 5)),
u40 = u40 + (FLOOR(0 + RAND() * 3))
WHERE
(
(
@village = -1
AND
vref IN(
SELECT
id
FROM
s1_wdata
WHERE
oasistype IN(3)
)
)
OR
(
@village > -1
AND
vref = @village
)
)
AND
(
u36 <= (
CASE o.high
WHEN 0 THEN (FLOOR(@minUnitsForOasis0 + RAND() * @maxUnitsForOasis0))
WHEN 1 THEN (FLOOR(@minUnitsForOasis1 + RAND() * @maxUnitsForOasis1))
WHEN 2 THEN (FLOOR(@minUnitsForOasis2 + RAND() * @maxUnitsForOasis2))
END
)
OR u37 <= (
CASE o.high
WHEN 0 THEN (FLOOR(@minUnitsForOasis0 + RAND() * @maxUnitsForOasis0))
WHEN 1 THEN (FLOOR(@minUnitsForOasis1 + RAND() * @maxUnitsForOasis1))
WHEN 2 THEN (FLOOR(@minUnitsForOasis2 + RAND() * @maxUnitsForOasis2))
END
)
OR u38 <= (
CASE o.high
WHEN 0 THEN (FLOOR(@minUnitsForOasis0 + RAND() * @maxUnitsForOasis0))
WHEN 1 THEN (FLOOR(@minUnitsForOasis1 + RAND() * @maxUnitsForOasis1))
WHEN 2 THEN (FLOOR(@minUnitsForOasis2 + RAND() * @maxUnitsForOasis2))
END
)
);
-- +25% clay oasis
UPDATE %PREFIX%units u
JOIN %PREFIX%odata o
ON u.vref = o.wref
SET
u31 = u31 + (FLOOR(10 + RAND() * 15)),
u32 = u32 + (FLOOR(5 + RAND() * 15)),
u35 = u35 + (FLOOR(0 + RAND() * 10))
WHERE
(
(
@village = -1
AND
vref IN(
SELECT
id
FROM
s1_wdata
WHERE
oasistype IN(4,5)
)
)
OR
(
@village > -1
AND
vref = @village
)
)
AND u31 <= (
CASE o.high
WHEN 0 THEN (FLOOR(@minUnitsForOasis0 + RAND() * @maxUnitsForOasis0))
WHEN 1 THEN (FLOOR(@minUnitsForOasis1 + RAND() * @maxUnitsForOasis1))
WHEN 2 THEN (FLOOR(@minUnitsForOasis2 + RAND() * @maxUnitsForOasis2))
END
)
AND u32 <= (
CASE o.high
WHEN 0 THEN (FLOOR(@minUnitsForOasis0 + RAND() * @maxUnitsForOasis0))
WHEN 1 THEN (FLOOR(@minUnitsForOasis1 + RAND() * @maxUnitsForOasis1))
WHEN 2 THEN (FLOOR(@minUnitsForOasis2 + RAND() * @maxUnitsForOasis2))
END
)
AND u35 <= (
CASE o.high
WHEN 0 THEN (FLOOR(@minUnitsForOasis0 + RAND() * @maxUnitsForOasis0))
WHEN 1 THEN (FLOOR(@minUnitsForOasis1 + RAND() * @maxUnitsForOasis1))
WHEN 2 THEN (FLOOR(@minUnitsForOasis2 + RAND() * @maxUnitsForOasis2))
END
);
-- +25% clay and +25% crop oasis
UPDATE %PREFIX%units u
JOIN %PREFIX%odata o
ON u.vref = o.wref
SET
u31 = u31 + (FLOOR(15 + RAND() * 20)),
u32 = u32 + (FLOOR(10 + RAND() * 15)),
u35 = u35 + (FLOOR(0 + RAND() * 10)),
u40 = u40 + (FLOOR(0 + RAND() * 3))
WHERE
(
(
@village = -1
AND
vref IN(
SELECT
id
FROM
s1_wdata
WHERE
oasistype IN(6)
)
)
OR
(
@village > -1
AND
vref = @village
)
)
AND u31 <= (
CASE o.high
WHEN 0 THEN (FLOOR(@minUnitsForOasis0 + RAND() * @maxUnitsForOasis0))
WHEN 1 THEN (FLOOR(@minUnitsForOasis1 + RAND() * @maxUnitsForOasis1))
WHEN 2 THEN (FLOOR(@minUnitsForOasis2 + RAND() * @maxUnitsForOasis2))
END
)
AND u32 <= (
CASE o.high
WHEN 0 THEN (FLOOR(@minUnitsForOasis0 + RAND() * @maxUnitsForOasis0))
WHEN 1 THEN (FLOOR(@minUnitsForOasis1 + RAND() * @maxUnitsForOasis1))
WHEN 2 THEN (FLOOR(@minUnitsForOasis2 + RAND() * @maxUnitsForOasis2))
END
)
AND u35 <= (
CASE o.high
WHEN 0 THEN (FLOOR(@minUnitsForOasis0 + RAND() * @maxUnitsForOasis0))
WHEN 1 THEN (FLOOR(@minUnitsForOasis1 + RAND() * @maxUnitsForOasis1))
WHEN 2 THEN (FLOOR(@minUnitsForOasis2 + RAND() * @maxUnitsForOasis2))
END
);
-- +25% iron oasis
UPDATE %PREFIX%units u
JOIN %PREFIX%odata o
ON u.vref = o.wref
SET
u31 = u31 + (FLOOR(10 + RAND() * 15)),
u32 = u32 + (FLOOR(5 + RAND() * 15)),
u34 = u34 + (FLOOR(0 + RAND() * 10))
WHERE
(
(
@village = -1
AND
vref IN(
SELECT
id
FROM
s1_wdata
WHERE
oasistype IN(7,8)
)
)
OR
(
@village > -1
AND
vref = @village
)
)
AND u31 <= (
CASE o.high
WHEN 0 THEN (FLOOR(@minUnitsForOasis0 + RAND() * @maxUnitsForOasis0))
WHEN 1 THEN (FLOOR(@minUnitsForOasis1 + RAND() * @maxUnitsForOasis1))
WHEN 2 THEN (FLOOR(@minUnitsForOasis2 + RAND() * @maxUnitsForOasis2))
END
)
AND u32 <= (
CASE o.high
WHEN 0 THEN (FLOOR(@minUnitsForOasis0 + RAND() * @maxUnitsForOasis0))
WHEN 1 THEN (FLOOR(@minUnitsForOasis1 + RAND() * @maxUnitsForOasis1))
WHEN 2 THEN (FLOOR(@minUnitsForOasis2 + RAND() * @maxUnitsForOasis2))
END
)
AND u34 <= (
CASE o.high
WHEN 0 THEN (FLOOR(@minUnitsForOasis0 + RAND() * @maxUnitsForOasis0))
WHEN 1 THEN (FLOOR(@minUnitsForOasis1 + RAND() * @maxUnitsForOasis1))
WHEN 2 THEN (FLOOR(@minUnitsForOasis2 + RAND() * @maxUnitsForOasis2))
END
);
-- +25% iron and +25% crop oasis
UPDATE %PREFIX%units u
JOIN %PREFIX%odata o
ON u.vref = o.wref
SET
u31 = u31 + (FLOOR(15 + RAND() * 20)),
u32 = u32 + (FLOOR(10 + RAND() * 15)),
u34 = u34 + (FLOOR(0 + RAND() * 10)),
u39 = u39 + (FLOOR(0 + RAND() * 3))
WHERE
(
(
@village = -1
AND
vref IN(
SELECT
id
FROM
s1_wdata
WHERE
oasistype IN(9)
)
)
OR
(
@village > -1
AND
vref = @village
)
)
AND u31 <= (
CASE o.high
WHEN 0 THEN (FLOOR(@minUnitsForOasis0 + RAND() * @maxUnitsForOasis0))
WHEN 1 THEN (FLOOR(@minUnitsForOasis1 + RAND() * @maxUnitsForOasis1))
WHEN 2 THEN (FLOOR(@minUnitsForOasis2 + RAND() * @maxUnitsForOasis2))
END
)
AND u32 <= (
CASE o.high
WHEN 0 THEN (FLOOR(@minUnitsForOasis0 + RAND() * @maxUnitsForOasis0))
WHEN 1 THEN (FLOOR(@minUnitsForOasis1 + RAND() * @maxUnitsForOasis1))
WHEN 2 THEN (FLOOR(@minUnitsForOasis2 + RAND() * @maxUnitsForOasis2))
END
)
AND u34 <= (
CASE o.high
WHEN 0 THEN (FLOOR(@minUnitsForOasis0 + RAND() * @maxUnitsForOasis0))
WHEN 1 THEN (FLOOR(@minUnitsForOasis1 + RAND() * @maxUnitsForOasis1))
WHEN 2 THEN (FLOOR(@minUnitsForOasis2 + RAND() * @maxUnitsForOasis2))
END
);
-- +25% crop oasis
UPDATE %PREFIX%units u
JOIN %PREFIX%odata o
ON u.vref = o.wref
SET
u31 = u31 + (FLOOR(5 + RAND() * 15)),
u33 = u33 + (FLOOR(5 + RAND() * 10)),
u37 = u37 + (FLOOR(0 + RAND() * 10)),
u38 = u38 + (FLOOR(0 + RAND() * 5)),
u39 = u39 + (FLOOR(0 + RAND() * 5))
WHERE
(
(
@village = -1
AND
vref IN(
SELECT
id
FROM
s1_wdata
WHERE
oasistype IN(10,11)
)
)
OR
(
@village > -1
AND
vref = @village
)
)
AND u31 <= (
CASE o.high
WHEN 0 THEN (FLOOR(@minUnitsForOasis0 + RAND() * @maxUnitsForOasis0))
WHEN 1 THEN (FLOOR(@minUnitsForOasis1 + RAND() * @maxUnitsForOasis1))
WHEN 2 THEN (FLOOR(@minUnitsForOasis2 + RAND() * @maxUnitsForOasis2))
END
)
AND u33 <= (
CASE o.high
WHEN 0 THEN (FLOOR(@minUnitsForOasis0 + RAND() * @maxUnitsForOasis0))
WHEN 1 THEN (FLOOR(@minUnitsForOasis1 + RAND() * @maxUnitsForOasis1))
WHEN 2 THEN (FLOOR(@minUnitsForOasis2 + RAND() * @maxUnitsForOasis2))
END
)
AND u37 <= (
CASE o.high
WHEN 0 THEN (FLOOR(@minUnitsForOasis0 + RAND() * @maxUnitsForOasis0))
WHEN 1 THEN (FLOOR(@minUnitsForOasis1 + RAND() * @maxUnitsForOasis1))
WHEN 2 THEN (FLOOR(@minUnitsForOasis2 + RAND() * @maxUnitsForOasis2))
END
)
AND u38 <= (
CASE o.high
WHEN 0 THEN (FLOOR(@minUnitsForOasis0 + RAND() * @maxUnitsForOasis0))
WHEN 1 THEN (FLOOR(@minUnitsForOasis1 + RAND() * @maxUnitsForOasis1))
WHEN 2 THEN (FLOOR(@minUnitsForOasis2 + RAND() * @maxUnitsForOasis2))
END
);
-- +50% crop oasis
UPDATE %PREFIX%units u
JOIN %PREFIX%odata o
ON u.vref = o.wref
SET
u31 = u31 + (FLOOR(10 + RAND() * 15)),
u33 = u33 + (FLOOR(5 + RAND() * 10)),
u37 = u37 + (FLOOR(0 + RAND() * 10)),
u38 = u38 + (FLOOR(0 + RAND() * 5)),
u39 = u39 + (FLOOR(0 + RAND() * 5)),
u40 = u40 + (FLOOR(0 + RAND() * 3))
WHERE
(
(
@village = -1
AND
vref IN(
SELECT
id
FROM
s1_wdata
WHERE
oasistype IN(12)
)
)
OR
(
@village > -1
AND
vref = @village
)
)
AND u31 <= (
CASE o.high
WHEN 0 THEN (FLOOR(@minUnitsForOasis0 + RAND() * @maxUnitsForOasis0))
WHEN 1 THEN (FLOOR(@minUnitsForOasis1 + RAND() * @maxUnitsForOasis1))
WHEN 2 THEN (FLOOR(@minUnitsForOasis2 + RAND() * @maxUnitsForOasis2))
END
)
AND u33 <= (
CASE o.high
WHEN 0 THEN (FLOOR(@minUnitsForOasis0 + RAND() * @maxUnitsForOasis0))
WHEN 1 THEN (FLOOR(@minUnitsForOasis1 + RAND() * @maxUnitsForOasis1))
WHEN 2 THEN (FLOOR(@minUnitsForOasis2 + RAND() * @maxUnitsForOasis2))
END
)
AND u37 <= (
CASE o.high
WHEN 0 THEN (FLOOR(@minUnitsForOasis0 + RAND() * @maxUnitsForOasis0))
WHEN 1 THEN (FLOOR(@minUnitsForOasis1 + RAND() * @maxUnitsForOasis1))
WHEN 2 THEN (FLOOR(@minUnitsForOasis2 + RAND() * @maxUnitsForOasis2))
END
)
AND u38 <= (
CASE o.high
WHEN 0 THEN (FLOOR(@minUnitsForOasis0 + RAND() * @maxUnitsForOasis0))
WHEN 1 THEN (FLOOR(@minUnitsForOasis1 + RAND() * @maxUnitsForOasis1))
WHEN 2 THEN (FLOOR(@minUnitsForOasis2 + RAND() * @maxUnitsForOasis2))
END
)
AND u39 <= (
CASE o.high
WHEN 0 THEN (FLOOR(@minUnitsForOasis0 + RAND() * @maxUnitsForOasis0))
WHEN 1 THEN (FLOOR(@minUnitsForOasis1 + RAND() * @maxUnitsForOasis1))
WHEN 2 THEN (FLOOR(@minUnitsForOasis2 + RAND() * @maxUnitsForOasis2))
END
);
+148
View File
@@ -0,0 +1,148 @@
-- generate world map data
INSERT INTO %PREFIX%wdata
-- this select gets the right number of columns for the wdata table
SELECT 0 as id, fieldtype, oasistype, x, y, 0 as occupied, image FROM
-- this select prepares (i.e. generates) the world data
(SELECT
-- save a random number from 1 to 1000 into a variable
@rnd := (FLOOR(1 + RAND() * 1000)),
-- fieldtype is always 3 for the middle and the word border
IF (
(x = 0 AND y = 0) OR (x = 100 AND y = 100),
3,
-- get a field type based on the random number previously generated
CASE
WHEN @rnd <= 10 THEN @ftype := 1
WHEN @rnd <= 90 THEN @ftype := 2
WHEN @rnd <= 400 THEN @ftype := 3
WHEN @rnd <= 480 THEN @ftype := 4
WHEN @rnd <= 560 THEN @ftype := 5
WHEN @rnd <= 570 THEN @ftype := 6
WHEN @rnd <= 600 THEN @ftype := 7
WHEN @rnd <= 630 THEN @ftype := 8
WHEN @rnd <= 660 THEN @ftype := 9
WHEN @rnd <= 740 THEN @ftype := 10
WHEN @rnd <= 820 THEN @ftype := 11
WHEN @rnd <= 900 THEN @ftype := 12
WHEN @rnd <= 1000 THEN @ftype := 0
END
) as fieldtype,
-- there are no oasis' in the middle and by the word border
IF (
(x = 0 AND y = 0) OR (x = 100 AND y = 100),
0,
-- get an oasis type if the field type generated in the previous IF statement
-- is 0, based on the random number previously generated
CASE
WHEN @ftype > 0 THEN @otype := 0
WHEN @rnd <= 908 THEN @otype := 1
WHEN @rnd <= 916 THEN @otype := 2
WHEN @rnd <= 924 THEN @otype := 3
WHEN @rnd <= 932 THEN @otype := 4
WHEN @rnd <= 940 THEN @otype := 5
WHEN @rnd <= 948 THEN @otype := 6
WHEN @rnd <= 956 THEN @otype := 7
WHEN @rnd <= 964 THEN @otype := 8
WHEN @rnd <= 972 THEN @otype := 9
WHEN @rnd <= 980 THEN @otype := 10
WHEN @rnd <= 988 THEN @otype := 11
ELSE @otype := 12
END
) as oasistype,
-- x and y coordinates come from the subqueries below
x, y,
-- create a random image name for the field or the oasis square
IF (@otype = 0, CONCAT("t", (FLOOR(0 + RAND() * 9)) ), CONCAT("o", @otype) ) as image
FROM
-- the following select will generate a number from -%WORLDSIZE% to +%WORLDSIZE% as an X coordinate
-- (courtesy of Unreason, https://stackoverflow.com/a/2652051/467164)
-- this first line will keep incrementing @row until we run out of all the data provided by the "t" subselects below
(SELECT @row := @row + 1 as x FROM
-- t and t2 each contain 10 rows of dummy data,
-- cartesian product of these is 10^4, i.e. 10000 rows of dummy data
-- and the outer select is just mysql version of rownumber
(select 0 union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t,
(select 0 union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t2,
-- in t3, we only need 4 rows of dummy data, as 400 is currently the maximum allowed map size
-- which brings us to `t1` x `t2` x `t3` = 10 x 10 x 4 = 400
(select 0 union select 1 union select 2 union select 3) t3,
-- here we tell MySQL where to start, so if we have a world 100x100, this will set @row to -101
-- (not -100 because the first select already increments the @row by 1, so we'd start at -99 instead)
(SELECT @row := -(%WORLDSIZE% + 1)) as final
-- since we maxed out the potential of world generation to number 400, we need to use a WHERE here
-- as to only get the number of rows we need for the current map size
WHERE @row <= (%WORLDSIZE% - 1)) as x,
-- this query is the same as previous query for X coordinate but will generate numbers
-- for the Y coordinate - both of these joined together this way will generate data such as:
-- -100, -100; -100, -99; -100, -98 ...
(SELECT @row2 := @row2 + 1 as y FROM
(select 0 union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t,
(select 0 union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t2,
(select 0 union select 1 union select 2) t3,
(SELECT @row2 := -(%WORLDSIZE% + 1)) as final
WHERE @row2 <= (%WORLDSIZE% - 1)) as y
) as generator;
-- populate oasis data
INSERT INTO %PREFIX%odata
SELECT
-- automatic ID
id,
-- type of oasis from wdata table
oasistype,
-- oasis is not conquered
0,
-- wood
800,
-- iron
800,
-- clay
800,
-- maximum storage for the 3 resources above
800,
-- crop
800,
-- maximum storage for crop
800,
-- last updated timestamps
UNIX_TIMESTAMP(),
UNIX_TIMESTAMP(),
-- loyalty (100%)
100,
-- owner (2 = Nature)
2,
-- name for this square
"Unoccupied Oasis",
-- how many units would be (re)generated for this oasis, based on its type
CASE
WHEN oasistype < 4 THEN 1
WHEN oasistype < 10 THEN 2
ELSE 0
END
FROM
%PREFIX%wdata
WHERE
oasistype <> 0;
-- create some defensive units for existing oasis
INSERT INTO %PREFIX%units (vref)
SELECT
id
FROM
%PREFIX%wdata
WHERE
oasistype <> 0;
+1 -1
View File
@@ -50,7 +50,7 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%a2b` (
-- Table structure for table `%PREFIX%links` -- Table structure for table `%PREFIX%links`
-- --
CREATE TABLE `%PREFIX%links` ( CREATE TABLE IF NOT EXISTS `%PREFIX%links` (
`id` INT( 25 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , `id` INT( 25 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`userid` INT( 25 ) NULL , `userid` INT( 25 ) NULL ,
`name` VARCHAR( 50 ) NULL , `name` VARCHAR( 50 ) NULL ,