"2.0", "222" => "2.2x", "302" => "3.0-3.02", "304" => "3.03-3.04", "340" => "3.1-3.3", "350" => "3.4-3.42", "400" => "3.5-3.52", "405" => "4.0-4.04", "411" => "4.05-4.11", "420" => "4.12" ); if (!isset($_POST['version'])) { ?> Update
\n"; $error_occured = true; } else { echo "\n"; } if (!empty($attributes_content)) { echo "\n"; $error_occured = true; } else { echo "\n"; } if (empty($owner)) { echo "\n"; $error_occured = true; } else { echo "\n"; } if (empty($default_language)) { echo "\n"; $error_occured = true; } else { echo "\n"; } if (empty($global_universe) || !is_numeric($global_universe)) { echo "\n"; $error_occured = true; } else { echo "\n"; } $link = mysql_connect($dbhost, $dbusername, $dbpassword); if (!$link) { echo "\n"; echo "\n"; echo "\n"; $error_occured = true; } else { echo "\n"; $db_selected = mysql_select_db($dbname, $link); if (!$db_selected) { echo "\n"; $error_occured = true; } else { echo "\n"; $query = "SELECT VERSION() as version"; $res = mysql_query($query) or die(mysql_error()); $version = mysql_fetch_object($res); if (strpos($version->version,"-") > 0) { $version = substr($version->version,0,strpos($version->version,"-")); } else { $version = $version->version; } $subversion = explode(".",$version); if (!isset($subversion[0]) || $subversion[0] < 4) { echo "\n"; $error_occured = true; } else { if ($subversion[0] == 4) { // MySQL 4.x.x if (!isset($subversion[1]) || $subversion[1] < 1) { echo "\n"; $error_occured = true; } else { if (!isset($subversion[2]) || $subversion[2] < 16) { echo "\n"; $error_occured = true; } else { // success echo "\n"; } } } elseif ($subversion[0] == 5) { // MySQL 5.x.x if (!isset($subversion[1]) || !isset($subversion[2]) || ($subversion[1] == 0 && $subversion[2] < 16)) { echo "\n"; $error_occured = true; } else { // success echo "\n"; } } elseif ($subversion[0] == 6) { // MySQL 6.x.x echo "\n"; } } } } //if (!empty($old_dbtablename) && $old_dbtablename != $dbtablename && //!empty($old_utablename) && $old_utablename != $utablename && //!empty($old_pstablename) && $old_pstablename != $playertable && //!empty($old_astablename) && $old_astablename != $allytable && //!empty($old_noticetable) && $old_noticetable != $noticetable && //!empty($old_reporttable) && $old_reporttable != $reporttable && //!empty($old_iptablename) && $old_iptablename != $iptablename && //!empty($old_shouttable) && $old_shouttable != $shouttable && //!empty($old_allyhistory) && $old_allyhistory != $allyhistory ) { // // echo "\n"; //} else { // echo "\n"; // $error_occured = true; //} if (!$error_occured) { echo ' '; } else { echo "\n"; } ?>
Galaxytool - Update check
Syntax: config.phpfailed
Syntax: config.phpsuccess
Syntax: attributes.phpfailed
Syntax: attributes.phpsuccess
Ownerfailed
Owner$owner
Languagefailed
Language$default_language
Universefailed
Universe$global_universe
MySQL connectionfailed
Database existencyfailed
MySQL version checkfailed
MySQL connectionsuccess
Database existencyfailed
Database existencysuccess
MySQL version check$version
MySQL version check$version
MySQL version check$version
MySQL version check$version
MySQL version check$version
MySQL version check$version
MySQL version check$version
tablenamessuccess
tablenamesfailure
Select your old Version:
Check again
Update
"; } $version = (int)$_POST['version']; mysql_connect($dbhost,$dbusername,$dbpassword) or die(mysql_error()); mysql_select_db($dbname) or die(mysql_error()); if ($version <= 200) { echo "Updating from Version 2.0 ...
\n"; // Update from 2.0 to version 2.2x $query = "ALTER TABLE $dbtablename ADD mondgr SMALLINT UNSIGNED DEFAULT '0' NOT NULL AFTER mond , ADD metall INT UNSIGNED DEFAULT '0' NOT NULL AFTER mondgr , ADD kristall INT UNSIGNED DEFAULT '0' NOT NULL AFTER metall"; mysql_query($query) or die(mysql_error()); echo "33% done
\n"; $query = "CREATE TABLE $pstablename ( playername VARCHAR( 30 ) NOT NULL , rank SMALLINT UNSIGNED DEFAULT '0' NOT NULL , last_update VARCHAR( 20 ) NOT NULL , PRIMARY KEY ( playername ) )"; mysql_query($query) or die(mysql_error()); echo "66% done
\n"; $query = "CREATE TABLE $astablename ( allyname VARCHAR( 30 ) NOT NULL , rank SMALLINT UNSIGNED DEFAULT '0' NOT NULL , members SMALLINT UNSIGNED DEFAULT '0' NOT NULL , last_update VARCHAR( 20 ) NOT NULL , PRIMARY KEY ( allyname ) )"; mysql_query($query) or die(mysql_error()); echo "100% done
\n"; } if ($version <= 222) { echo "Updating from Version 2.2x ...
\n"; // Update from 2.2x to 3.0 echo "Update of $dbtablename running (this may take some time!) ...
\n"; flush(); $query = "ALTER TABLE $dbtablename ADD coordinates varchar(9) NOT NULL default '' AFTER mond , ADD notices enum('true','false') NOT NULL default 'false' AFTER userid , ADD reports enum('true','false') NOT NULL default 'false' AFTER notices "; mysql_query($query) or die(mysql_error()); echo "12,5% done
\n"; flush(); $query = "UPDATE $dbtablename SET coordinates=CONCAT(galaxie,':',system,':',planet)"; mysql_query($query) or die(mysql_error()); echo "25% done
\n"; flush(); $query = "ALTER TABLE $dbtablename DROP INDEX galaxie"; mysql_query($query) or die(mysql_error()); echo "37,5% done
\n"; flush(); $query = "ALTER TABLE $dbtablename DROP INDEX system"; mysql_query($query) or die(mysql_error()); echo "50% done
\n"; flush(); $query = "ALTER TABLE $dbtablename DROP INDEX planet"; mysql_query($query) or die(mysql_error()); echo "62,5% done
\n"; flush(); $query = "ALTER TABLE $dbtablename ADD INDEX (spielername)"; mysql_query($query) or die(mysql_error()); echo "75% done
\n"; flush(); $query = "ALTER TABLE $dbtablename ADD INDEX (ally)"; mysql_query($query) or die(mysql_error()); echo "87,5% done
\n"; flush(); $query = "ALTER TABLE $dbtablename ADD INDEX (coordinates)"; mysql_query($query) or die(mysql_error()); echo "100% done
\n"; flush(); echo "Update of $utablename running...
\n"; $query = "ALTER TABLE $utablename ADD stylepath varchar(255) NOT NULL default '' AFTER userpass"; mysql_query($query) or die(mysql_error()); echo "done
\n"; echo "Create Table for notices...
\n"; $query = "CREATE TABLE IF NOT EXISTS $noticetable ( id int(11) NOT NULL auto_increment, userid smallint(6) NOT NULL default '0', public enum('true','false') NOT NULL default 'true', noticetext text NOT NULL, coordinates varchar(9) NOT NULL default '', timevalue varchar(20) NOT NULL default '', PRIMARY KEY (id), UNIQUE KEY coordinates (coordinates,userid), KEY userid (userid), KEY public (public), KEY coordinates_2 (coordinates) )"; mysql_query($query) or die(mysql_error()); echo "done
\n"; echo "Create Table for Reports...
\n"; $query = "CREATE TABLE IF NOT EXISTS $reporttable ( id int(10) unsigned NOT NULL auto_increment, coordinates varchar(9) NOT NULL default '', moon enum('true','false') NOT NULL default 'false', metal int(10) unsigned NOT NULL default '0', crystal int(10) unsigned NOT NULL default '0', deuterium int(10) unsigned NOT NULL default '0', energy int(10) unsigned NOT NULL default '0', kt mediumint(8) unsigned NOT NULL default '0', gt mediumint(8) unsigned NOT NULL default '0', lj mediumint(8) unsigned NOT NULL default '0', sj mediumint(8) unsigned NOT NULL default '0', krz mediumint(8) unsigned NOT NULL default '0', ss mediumint(8) unsigned NOT NULL default '0', kolo mediumint(8) unsigned NOT NULL default '0', rec mediumint(8) unsigned NOT NULL default '0', spio mediumint(8) unsigned NOT NULL default '0', bomb mediumint(8) unsigned NOT NULL default '0', zerri mediumint(8) unsigned NOT NULL default '0', ds mediumint(8) unsigned NOT NULL default '0', sat mediumint(8) unsigned NOT NULL default '0', rak mediumint(8) unsigned NOT NULL default '0', ll mediumint(8) unsigned NOT NULL default '0', sl mediumint(8) unsigned NOT NULL default '0', ion mediumint(8) unsigned NOT NULL default '0', gauss mediumint(8) unsigned NOT NULL default '0', plasma mediumint(8) unsigned NOT NULL default '0', ksk mediumint(8) unsigned NOT NULL default '0', gsk mediumint(8) unsigned NOT NULL default '0', arak mediumint(8) unsigned NOT NULL default '0', irak mediumint(8) unsigned NOT NULL default '0', memi tinyint(3) unsigned NOT NULL default '0', krimi tinyint(3) unsigned NOT NULL default '0', deutsyn tinyint(3) unsigned NOT NULL default '0', solar tinyint(3) unsigned NOT NULL default '0', fusion tinyint(3) unsigned NOT NULL default '0', robo tinyint(3) unsigned NOT NULL default '0', nani tinyint(3) unsigned NOT NULL default '0', rawe tinyint(3) unsigned NOT NULL default '0', mesp tinyint(3) unsigned NOT NULL default '0', krissp tinyint(3) unsigned NOT NULL default '0', deutsp tinyint(3) unsigned NOT NULL default '0', folab tinyint(3) unsigned NOT NULL default '0', allydep tinyint(3) unsigned NOT NULL default '0', raksilo tinyint(3) unsigned NOT NULL default '0', mbase tinyint(3) unsigned NOT NULL default '0', sensor tinyint(3) unsigned NOT NULL default '0', sprungtor tinyint(3) unsigned NOT NULL default '0', spiolvl tinyint(3) unsigned NOT NULL default '0', computech tinyint(3) unsigned NOT NULL default '0', waffentech tinyint(3) unsigned NOT NULL default '0', schildtech tinyint(3) unsigned NOT NULL default '0', rpz tinyint(3) unsigned NOT NULL default '0', energytech tinyint(3) unsigned NOT NULL default '0', hypertech tinyint(3) unsigned NOT NULL default '0', vbt tinyint(3) unsigned NOT NULL default '0', impulse tinyint(3) unsigned NOT NULL default '0', hra tinyint(3) unsigned NOT NULL default '0', lasertech tinyint(3) unsigned NOT NULL default '0', iontech tinyint(3) unsigned NOT NULL default '0', plasmatech tinyint(3) unsigned NOT NULL default '0', forschungsnetz tinyint(3) unsigned NOT NULL default '0', gravi tinyint(3) unsigned NOT NULL default '0', scantime varchar(14) NOT NULL default '', PRIMARY KEY (id), UNIQUE KEY coordinates_2 (coordinates,moon) )"; mysql_query($query) or die(mysql_error()); echo "done
\n"; } if ($version <= 302) { // Update from 3.0 bis 3.02 to 3.03 echo "Updating from 3.0-3.02 to 3.03...
\n"; $query = "ALTER TABLE $reporttable ADD terra TINYINT(3) UNSIGNED DEFAULT '0' NOT NULL AFTER folab"; mysql_query($query) or die(mysql_error()); echo "done
\n"; } if ($version <= 304) { echo "Updating from Version 3.03 or 3.04 ...
\n"; // Update from 3.04 to 3.1 $query = "ALTER TABLE $reporttable ADD scanned ENUM( 'ressources', 'fleet', 'defence', 'buildings', 'research' ) DEFAULT 'ressources' NOT NULL AFTER scantime"; mysql_query($query) or die(mysql_error()); echo "done
\n"; $query = "UPDATE $reporttable SET scanned='fleet' where kt>'0' OR gt>'0' OR lj>'0' OR sj>'0' OR krz>'0' OR ss>'0' OR kolo>'0' OR rec>'0' OR spio>'0' OR bomb>'0' OR zerri>'0' OR ds>'0' OR sat>'0'"; mysql_query($query) or die(mysql_error()); echo "done
\n"; $query = "UPDATE $reporttable SET scanned='defence' where rak>'0' OR ll>'0' OR sl>'0' OR ion>'0' OR gauss>'0' OR plasma>'0' OR ksk>'0' OR gsk>'0' OR arak>'0' OR irak>'0'"; mysql_query($query) or die(mysql_error()); echo "done
\n"; $query = "UPDATE $reporttable SET scanned='buildings' where memi>'0' OR krimi>'0' OR deutsyn>'0' OR solar>'0' OR fusion>'0' OR robo>'0' OR nani>'0' OR rawe>'0' OR mesp>'0' OR krissp>'0' OR deutsp>'0' OR folab>'0' OR allydep>'0' OR raksilo>'0' OR mbase>'0' OR sensor>'0' OR sprungtor"; mysql_query($query) or die(mysql_error()); echo "done
\n"; $query = "UPDATE $reporttable SET scanned='research' where spiolvl>'0' OR computech>'0' OR waffentech>'0' OR schildtech>'0' OR rpz>'0' OR energytech>'0' OR hypertech>'0' OR vbt>'0' OR impulse>'0' OR hra>'0' OR lasertech>'0' OR iontech>'0' OR plasmatech>'0' OR forschungsnetz>'0' OR gravi>'0'"; mysql_query($query) or die(mysql_error()); echo "done
\n"; $query = "ALTER TABLE $astablename ADD allystatus ENUM( 'nap', 'ally', 'war', 'boycott', 'neutral', 'nothing', 'own', 'wing' ) DEFAULT 'nothing' NOT NULL AFTER members, ADD points INT UNSIGNED DEFAULT '0' NOT NULL AFTER rank , ADD frank SMALLINT UNSIGNED DEFAULT '0' NOT NULL AFTER points , ADD fpoints INT UNSIGNED DEFAULT '0' NOT NULL AFTER frank , ADD rrank SMALLINT UNSIGNED DEFAULT '0' NOT NULL AFTER fpoints , ADD rpoints INT UNSIGNED DEFAULT '0' NOT NULL AFTER rrank"; mysql_query($query) or die(mysql_error()); echo "done
\n"; $query = "TRUNCATE TABLE $pstablename"; mysql_query($query) or die(mysql_error()); echo "done
\n"; $query = "ALTER TABLE $pstablename ADD points INT UNSIGNED DEFAULT '0' NOT NULL AFTER rank , ADD frank SMALLINT UNSIGNED DEFAULT '0' NOT NULL AFTER points , ADD fpoints INT UNSIGNED DEFAULT '0' NOT NULL AFTER frank , ADD rrank SMALLINT UNSIGNED DEFAULT '0' NOT NULL AFTER fpoints , ADD rpoints INT UNSIGNED DEFAULT '0' NOT NULL AFTER rrank, ADD ogame_playerid INT UNSIGNED DEFAULT '0' NOT NULL AFTER playername"; mysql_query($query) or die(mysql_error()); echo "done
\n"; $query = "ALTER TABLE $pstablename ADD UNIQUE (ogame_playerid)"; mysql_query($query) or die(mysql_error()); echo "done
\n"; $query = "ALTER TABLE $utablename ADD probeview ENUM( 'true', 'false' ) DEFAULT 'false' NOT NULL AFTER statusview, ADD status ENUM( 'email', 'admin', 'active' ) DEFAULT 'email' NOT NULL AFTER userman, ADD email VARCHAR( 50 ) NOT NULL AFTER userpass , ADD ingame VARCHAR( 20 ) NOT NULL AFTER email, ADD allytag VARCHAR( 10 ) NOT NULL AFTER ingame, ADD logins SMALLINT UNSIGNED DEFAULT '0' NOT NULL AFTER status, ADD lastlogin DATETIME NOT NULL AFTER logins "; mysql_query($query) or die(mysql_error()); echo "done
\n"; $query = "ALTER TABLE $utablename DROP styles"; mysql_query($query) or die(mysql_error()); echo "done
\n"; $query = "UPDATE $utablename SET probeview = 'true'"; mysql_query($query) or die(mysql_error()); echo "done
\n"; $query = "UPDATE $utablename SET status = 'active'"; mysql_query($query) or die(mysql_error()); echo "done
\n"; $query = "CREATE TABLE $iptablename ( id INT UNSIGNED NOT NULL AUTO_INCREMENT , userid SMALLINT UNSIGNED NOT NULL , ip VARCHAR( 15 ) NOT NULL , logintime DATETIME NOT NULL , PRIMARY KEY ( id ) )"; mysql_query($query) or die(mysql_error()); echo "done
\n"; $query = "CREATE TABLE $shouttable ( id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT , username VARCHAR( 20 ) NOT NULL , shouttext VARCHAR( 255 ) NOT NULL , shoutdate DATETIME NOT NULL , PRIMARY KEY ( id ) )"; mysql_query($query) or die(mysql_error()); echo "done
\n"; } if ($version <= 340) { echo "Updating from Version 3.1 or later ...
\n"; // Update from 3.1 to 3.4 $query = "ALTER TABLE $shouttable CHANGE id id MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT"; mysql_query($query) or die(mysql_error()); echo "done
\n"; $query = "ALTER TABLE $utablename ADD allyhistory ENUM( 'true', 'false' ) DEFAULT 'false' NOT NULL AFTER userman ;"; mysql_query($query) or die(mysql_error()); $query = "ALTER TABLE $utablename ADD diplomatic ENUM( 'true', 'false' ) DEFAULT 'false' NOT NULL AFTER allyhistory ;"; mysql_query($query) or die(mysql_error()); echo "done
\n"; $query = "ALTER TABLE $utablename ADD ogame_playerid INT( 11 ) UNSIGNED NOT NULL AFTER userpass;"; mysql_query($query) or die(mysql_error()); echo "done
\n"; $query = "CREATE TABLE $allyhistory ( id int(10) unsigned NOT NULL auto_increment, ogame_playerid int(11) unsigned NOT NULL default '0', playername varchar(30) NOT NULL default '', score int(11) unsigned NOT NULL default '0', date_added date NOT NULL default '0000-00-00', PRIMARY KEY (id), UNIQUE KEY ogame_playerid (ogame_playerid,date_added) )"; mysql_query($query) or die(mysql_error()); echo "done
\n"; } if ($version <= 350) { $query = "ALTER TABLE $allyhistory ADD alliance VARCHAR(30) DEFAULT 'main' NOT NULL AFTER playername"; mysql_query($query) or die(mysql_error()); echo "done
\n"; $query = "ALTER TABLE $reporttable ADD fleet_resis BIGINT UNSIGNED DEFAULT '0' NOT NULL AFTER gravi , ADD defence_resis BIGINT UNSIGNED DEFAULT '0' NOT NULL AFTER fleet_resis;"; mysql_query($query) or die(mysql_error()); echo "done
\n"; $query = "UPDATE $reporttable SET fleet_resis=(kt*4000 + gt*12000 + lj*4000 + sj*10000 + krz*27000 + ss*60000 + kolo*30000 + rec*30000 + spio*1000 + bomb*22500 + zerri*110000 + ds*9000000 + sat*2000), defence_resis=(rak*600 + ll*600 + sl*2400 + ion*2400 + gauss*10500 + plasma*30000 + ksk*6000 + gsk*30000)"; mysql_query($query) or die(mysql_error()); echo "done
\n"; $query = "ALTER TABLE $pstablename ADD ally VARCHAR( 30 ) NOT NULL AFTER playername"; mysql_query($query) or die(mysql_error()); echo "done
\n"; $query = "UPDATE $dbtablename SET mond='1' WHERE mond='t'"; mysql_query($query) or die(mysql_error()); echo "done
\n"; $query = "UPDATE $dbtablename SET mond='0' WHERE mond='f'"; mysql_query($query) or die(mysql_error()); echo "done
\n"; $query = "ALTER TABLE $dbtablename ADD ogame_playerid INT( 11 ) UNSIGNED NOT NULL DEFAULT '0' AFTER spielername"; mysql_query($query) or die(mysql_error()); echo "done
\n"; $query = "ALTER TABLE $dbtablename ADD INDEX ( ogame_playerid )"; mysql_query($query) or die(mysql_error()); echo "done
\n"; } if ($version <= 400) { // new table for galaxyview echo "create new galaxytable... "; $query = "CREATE TABLE ".$dbtablename." ( galaxy int(2) NOT NULL default '0', system int(3) NOT NULL default '0', planet int(2) NOT NULL default '0', player_id smallint(5) unsigned NOT NULL default '0', moon enum('true','false') NOT NULL default 'false', moonsize smallint(5) unsigned NOT NULL default '0', metal int(10) unsigned NOT NULL default '0', crystal int(10) unsigned NOT NULL default '0', planetname varchar(20) NOT NULL default '', last_update datetime NOT NULL default '0000-00-00 00:00:00', user_id smallint(5) unsigned NOT NULL default '0', PRIMARY KEY (galaxy,system,planet), KEY player_id (player_id) ) DEFAULT CHARSET=utf8"; mysql_query($query) or die(mysql_error()); echo "done
\n"; echo "create new usertable... "; $query = "CREATE TABLE ".$utablename." ( id smallint(10) unsigned NOT NULL auto_increment, username varchar(20) NOT NULL default '', userpass varchar(32) NOT NULL default '', ogame_playerid int(11) unsigned NOT NULL default '0', email varchar(50) NOT NULL default '', ingame varchar(20) NOT NULL default '', allytag varchar(10) NOT NULL default '', stylepath varchar(255) NOT NULL default '', cansearch enum('true','false') NOT NULL default 'false', caninsert enum('true','false') NOT NULL default 'false', statusview enum('true','false') NOT NULL default 'false', probeview enum('true','false') NOT NULL default 'false', userman enum('true','false') NOT NULL default 'false', allyhistory enum('true','false') NOT NULL default 'false', diplomatic enum('true','false') NOT NULL default 'false', status enum('email','admin','active') NOT NULL default 'email', logins smallint(5) unsigned NOT NULL default '0', lastlogin datetime NOT NULL default '0000-00-00 00:00:00', last_action datetime NOT NULL default '0000-00-00 00:00:00', statspage mediumint(8) unsigned NOT NULL default '100', links text NOT NULL, bb_coordinates varchar(25) NOT NULL default 'deeppink', bb_moon varchar(25) NOT NULL default 'burlywood', bb_debris varchar(25) NOT NULL default 'firebrick', bb_ally varchar(25) NOT NULL default 'tomato', bb_allydetails varchar(25) NOT NULL default 'coral', bb_playername varchar(25) NOT NULL default 'teal', bb_banned varchar(25) NOT NULL default 'red', bb_vacation varchar(25) NOT NULL default 'skyblue', bb_noob varchar(25) NOT NULL default 'limegreen', bb_inactive varchar(25) NOT NULL default 'silver', bb_longinactive varchar(25) NOT NULL default 'silver', PRIMARY KEY (id), UNIQUE KEY username (username) ) DEFAULT CHARSET=utf8"; mysql_query($query) or die(mysql_error()); echo "done
\n"; echo "create new playertable... "; $query = "CREATE TABLE $playertable ( id smallint(5) unsigned NOT NULL auto_increment, playername varchar(30) NOT NULL default '', ogame_playerid int(11) unsigned default NULL, alliance_id smallint(5) unsigned NOT NULL default '0', rank smallint(5) unsigned NOT NULL default '0', points int(10) unsigned NOT NULL default '0', frank smallint(5) unsigned NOT NULL default '0', fpoints int(10) unsigned NOT NULL default '0', rrank smallint(5) unsigned NOT NULL default '0', rpoints int(10) unsigned NOT NULL default '0', last_stats_update datetime NOT NULL default '0000-00-00 00:00:00', noob enum('true','false') NOT NULL default 'false', banned enum('true','false') NOT NULL default 'false', vacation enum('true','false') NOT NULL default 'false', inactive enum('true','false') NOT NULL default 'false', long_inactive enum('true','false') NOT NULL default 'false', diplomatic_status enum('nap','ally','war','boycott','neutral','nothing','own','wing') NOT NULL default 'nothing', spiolvl tinyint(3) unsigned NOT NULL default '0', computech tinyint(3) unsigned NOT NULL default '0', waffentech tinyint(3) unsigned NOT NULL default '0', schildtech tinyint(3) unsigned NOT NULL default '0', rpz tinyint(3) unsigned NOT NULL default '0', energytech tinyint(3) unsigned NOT NULL default '0', hypertech tinyint(3) unsigned NOT NULL default '0', vbt tinyint(3) unsigned NOT NULL default '0', impulse tinyint(3) unsigned NOT NULL default '0', hra tinyint(3) unsigned NOT NULL default '0', lasertech tinyint(3) unsigned NOT NULL default '0', iontech tinyint(3) unsigned NOT NULL default '0', plasmatech tinyint(3) unsigned NOT NULL default '0', forschungsnetz tinyint(3) unsigned NOT NULL default '0', gravi tinyint(3) unsigned NOT NULL default '0', last_tech_update datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (id), UNIQUE KEY playername (playername), UNIQUE KEY ogame_playerid (ogame_playerid), KEY alliance_id (alliance_id), KEY noob (noob), KEY banned (banned), KEY vacation (vacation), KEY inactive (inactive) ) DEFAULT CHARSET=utf8"; mysql_query($query) or die(mysql_error()); echo "done
\n"; echo "create new allytable... "; $query = "CREATE TABLE $allytable ( id smallint(5) unsigned NOT NULL auto_increment, allyname varchar(30) default NULL, rank smallint(5) unsigned NOT NULL default '0', points int(10) unsigned NOT NULL default '0', frank smallint(5) unsigned NOT NULL default '0', fpoints int(10) unsigned NOT NULL default '0', rrank smallint(5) unsigned NOT NULL default '0', rpoints int(10) unsigned NOT NULL default '0', members smallint(5) unsigned NOT NULL default '0', diplomatic_status enum('nap','ally','war','boycott','neutral','nothing','own','wing') default 'nothing', last_update datetime default '0000-00-00 00:00:00', PRIMARY KEY (id), UNIQUE KEY allyname (allyname), KEY last_update (last_update) ) DEFAULT CHARSET=utf8"; mysql_query($query) or die(mysql_error()); echo "done
\n"; echo "create new noticetable... "; $query = "CREATE TABLE ".$noticetable." ( id int(11) NOT NULL auto_increment, noticetext text NOT NULL, player_id smallint(5) unsigned NOT NULL default '0', last_update datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (id), UNIQUE KEY player_id (player_id) ) DEFAULT CHARSET=utf8"; mysql_query($query) or die(mysql_error()); echo "done
\n"; echo "create new reporttable... "; $query = "CREATE TABLE ".$reporttable." ( id int(10) unsigned NOT NULL auto_increment, galaxy int(2) unsigned NOT NULL default '0', system int(3) unsigned NOT NULL default '0', planet int(2) unsigned NOT NULL default '0', planetname varchar(20) NOT NULL default '', moon enum('true','false') NOT NULL default 'false', metal int(10) unsigned NOT NULL default '0', crystal int(10) unsigned NOT NULL default '0', deuterium int(10) unsigned NOT NULL default '0', energy int(10) unsigned NOT NULL default '0', kt mediumint(8) unsigned NOT NULL default '0', gt mediumint(8) unsigned NOT NULL default '0', lj mediumint(8) unsigned NOT NULL default '0', sj mediumint(8) unsigned NOT NULL default '0', krz mediumint(8) unsigned NOT NULL default '0', ss mediumint(8) unsigned NOT NULL default '0', kolo mediumint(8) unsigned NOT NULL default '0', rec mediumint(8) unsigned NOT NULL default '0', spio mediumint(8) unsigned NOT NULL default '0', bomb mediumint(8) unsigned NOT NULL default '0', zerri mediumint(8) unsigned NOT NULL default '0', ds mediumint(8) unsigned NOT NULL default '0', skrz mediumint(8) unsigned NOT NULL default '0', sat mediumint(8) unsigned NOT NULL default '0', rak mediumint(8) unsigned NOT NULL default '0', ll mediumint(8) unsigned NOT NULL default '0', sl mediumint(8) unsigned NOT NULL default '0', ion mediumint(8) unsigned NOT NULL default '0', gauss mediumint(8) unsigned NOT NULL default '0', plasma mediumint(8) unsigned NOT NULL default '0', ksk mediumint(8) unsigned NOT NULL default '0', gsk mediumint(8) unsigned NOT NULL default '0', arak mediumint(8) unsigned NOT NULL default '0', irak mediumint(8) unsigned NOT NULL default '0', memi tinyint(3) unsigned NOT NULL default '0', krimi tinyint(3) unsigned NOT NULL default '0', deutsyn tinyint(3) unsigned NOT NULL default '0', solar tinyint(3) unsigned NOT NULL default '0', fusion tinyint(3) unsigned NOT NULL default '0', robo tinyint(3) unsigned NOT NULL default '0', nani tinyint(3) unsigned NOT NULL default '0', rawe tinyint(3) unsigned NOT NULL default '0', mesp tinyint(3) unsigned NOT NULL default '0', krissp tinyint(3) unsigned NOT NULL default '0', deutsp tinyint(3) unsigned NOT NULL default '0', folab tinyint(3) unsigned NOT NULL default '0', terra tinyint(3) unsigned NOT NULL default '0', allydep tinyint(3) unsigned NOT NULL default '0', raksilo tinyint(3) unsigned NOT NULL default '0', mbase tinyint(3) unsigned NOT NULL default '0', sensor tinyint(3) unsigned NOT NULL default '0', sprungtor tinyint(3) unsigned NOT NULL default '0', spiolvl tinyint(3) unsigned NOT NULL default '0', computech tinyint(3) unsigned NOT NULL default '0', waffentech tinyint(3) unsigned NOT NULL default '0', schildtech tinyint(3) unsigned NOT NULL default '0', rpz tinyint(3) unsigned NOT NULL default '0', energytech tinyint(3) unsigned NOT NULL default '0', hypertech tinyint(3) unsigned NOT NULL default '0', vbt tinyint(3) unsigned NOT NULL default '0', impulse tinyint(3) unsigned NOT NULL default '0', hra tinyint(3) unsigned NOT NULL default '0', lasertech tinyint(3) unsigned NOT NULL default '0', iontech tinyint(3) unsigned NOT NULL default '0', plasmatech tinyint(3) unsigned NOT NULL default '0', forschungsnetz tinyint(3) unsigned NOT NULL default '0', gravi tinyint(3) unsigned NOT NULL default '0', fleet_resis bigint(20) unsigned NOT NULL default '0', defence_resis bigint(20) unsigned NOT NULL default '0', scantime varchar(14) NOT NULL default '', scanned enum('ressources','fleet','defence','buildings','research') NOT NULL default 'ressources', PRIMARY KEY (id), UNIQUE KEY coordinates (galaxy,system,planet,moon) ) DEFAULT CHARSET=utf8"; mysql_query($query) or die(mysql_error()); echo "done
\n"; echo "create new iptable... "; $query = "CREATE TABLE ".$iptablename." ( id int(10) unsigned NOT NULL auto_increment, userid smallint(5) unsigned NOT NULL default '0', ip varchar(15) NOT NULL default '', logintime datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (id), KEY userid (userid) ) DEFAULT CHARSET=utf8"; mysql_query($query) or die(mysql_error()); echo "done
\n"; echo "create new shoutbox... "; $query = "CREATE TABLE ".$shouttable." ( id mediumint(8) unsigned NOT NULL auto_increment, username varchar(20) NOT NULL default '', shouttext varchar(255) NOT NULL default '', shoutdate datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (id) ) DEFAULT CHARSET=utf8"; mysql_query($query) or die(mysql_error()); echo "done
\n"; echo "create new allyhistorytable... "; $query = "CREATE TABLE ".$allyhistory." ( alliance_id smallint(5) unsigned NOT NULL default '0', year smallint(5) unsigned NOT NULL default '0', month tinyint(3) unsigned NOT NULL default '0', day tinyint(3) unsigned NOT NULL default '0', rank smallint(5) unsigned NOT NULL default '0', points int(10) unsigned NOT NULL default '0', frank smallint(5) unsigned NOT NULL default '0', fpoints int(10) unsigned NOT NULL default '0', rrank smallint(5) unsigned NOT NULL default '0', rpoints int(10) unsigned NOT NULL default '0', members smallint(5) unsigned NOT NULL default '0', PRIMARY KEY (alliance_id,year,month,day) ) DEFAULT CHARSET=utf8"; mysql_query($query) or die(mysql_error()); echo "done
\n"; echo "create new playerhistorytable... "; $query = "CREATE TABLE ".$playerhistory." ( player_id smallint(5) unsigned NOT NULL default '0', alliance_id smallint(5) unsigned NOT NULL default '0', year smallint(5) unsigned NOT NULL default '0', month tinyint(3) unsigned NOT NULL default '0', day tinyint(3) unsigned NOT NULL default '0', rank smallint(5) unsigned NOT NULL default '0', points int(10) unsigned NOT NULL default '0', frank smallint(5) unsigned NOT NULL default '0', fpoints int(10) unsigned NOT NULL default '0', rrank smallint(5) unsigned NOT NULL default '0', rpoints int(10) unsigned NOT NULL default '0', PRIMARY KEY (player_id,year,month,day) ) DEFAULT CHARSET=utf8"; mysql_query($query) or die(mysql_error()); echo "done
\n"; // now all tables are created - fill new tables with data from old tables // usertable echo "fill usertable... "; flush(); $query = "INSERT LOW_PRIORITY INTO $utablename (id,username,userpass,ogame_playerid,email,ingame,allytag,stylepath,links,cansearch,caninsert,statusview,probeview,userman,allyhistory,diplomatic,status,logins,lastlogin) ". "SELECT id,username,userpass,ogame_playerid,email,ingame,allytag,stylepath,'Galaxytool;http://www.galaxytool.eu',cansearch,caninsert,statusview,probeview,userman,allyhistory,diplomatic,status,logins,lastlogin FROM $old_dbname".".$old_utablename"; mysql_query($query) or die(mysql_error()); echo "done
\n"; // shoutbox echo "fill shoutbox... "; flush(); $query = "INSERT LOW_PRIORITY INTO $shouttable SELECT * FROM $old_dbname".".$old_shouttable"; mysql_query($query) or die(mysql_error()); echo "done
\n"; // IP table echo "fill IP table... "; flush(); $query = "INSERT LOW_PRIORITY INTO $iptablename SELECT * FROM $old_dbname".".$old_iptablename"; mysql_query($query) or die(mysql_error()); echo "done
\n"; // reports echo "fill reporttable... "; flush(); $query = "INSERT INTO $reporttable (galaxy,system,planet,moon,metal,crystal,deuterium,energy,". "kt,gt,lj,sj,krz,ss,kolo,rec,spio,bomb,zerri,ds,sat,". "rak,ll,sl,ion,gauss,plasma,ksk,gsk,arak,irak,memi,krimi,deutsyn,". "solar,fusion,robo,nani,rawe,mesp,krissp,deutsp,folab,terra,allydep,raksilo,mbase,sensor,sprungtor,spiolvl,". "computech,waffentech,schildtech,rpz,energytech,hypertech,vbt,impulse,hra,lasertech,iontech,plasmatech,forschungsnetz,gravi,". "fleet_resis,defence_resis,scantime,scanned) ". "SELECT substring(coordinates from 1 for (locate(':',coordinates)-1)) as galaxie, substring(coordinates from locate(':',coordinates)+1 for (locate(':',substring(coordinates, locate(':',coordinates)+1)))-1) as system, substring(coordinates FROM -3+locate(':',substring(coordinates, -3))) as planet, moon,metal,crystal,deuterium,energy,". "kt,gt,lj,sj,krz,ss,kolo,rec,spio,bomb,zerri,ds,sat,". "rak,ll,sl,ion,gauss,plasma,ksk,gsk,arak,irak,memi,krimi,deutsyn,". "solar,fusion,robo,nani,rawe,mesp,krissp,deutsp,folab,terra,allydep,raksilo,mbase,sensor,sprungtor,spiolvl,". "computech,waffentech,schildtech,rpz,energytech,hypertech,vbt,impulse,hra,lasertech,iontech,plasmatech,forschungsnetz,gravi,". "fleet_resis,defence_resis,scantime,scanned ". "FROM $old_dbname".".$old_reporttable"; mysql_query($query) or die(mysql_error()); echo "done
\n"; // allynames echo "fill allytable... "; flush(); $query = "INSERT LOW_PRIORITY INTO $allytable (allyname) ". "SELECT distinct(ally) FROM $old_dbname".".$old_dbtablename"; mysql_query($query) or die(mysql_error()); echo "done
\n"; // playernames echo "fill playertable... "; flush(); $query = "INSERT LOW_PRIORITY INTO $playertable (playername,ogame_playerid) ". "SELECT distinct(spielername),ogame_playerid FROM $old_dbname".".$old_dbtablename WHERE ogame_playerid > 0 GROUP BY ogame_playerid HAVING max(zeit)"; $res = mysql_query($query) or die(mysql_error()); echo "done1, \n"; flush(); $query = "INSERT LOW_PRIORITY INTO $playertable (playername) ". "SELECT distinct(spielername) FROM $old_dbname".".$old_dbtablename WHERE ogame_playerid = 0 ". "ON DUPLICATE KEY UPDATE playername=VALUES(playername)"; $res = mysql_query($query) or die(mysql_error()); echo "done2
\n"; // galaxyview echo "get galaxydata... "; flush(); $query = "SELECT ogt.*,a.id as alliance_id, p.id as player_id FROM ". " $old_dbname".".$old_dbtablename ogt, $allytable a, $playertable p ". " WHERE ogt.ally = a.allyname AND ogt.spielername = p.playername AND ogt.planet > 0 AND ogt.planet < 16". " ORDER BY last_update ASC"; // oldest first $res = mysql_query($query) or die(mysql_error()); echo "done
\n"; echo "fill galaxytable."; flush(); $query = "INSERT LOW_PRIORITY INTO $dbtablename (galaxy,system,planet,player_id,moon,moonsize,metal,crystal,planetname) VALUES "; $playerarray = array(); $i = 0; while ($line = mysql_fetch_object($res)) { if (trim($line->spielername) != '') { $playerarray[$line->player_id]["alliance_id"] = $line->alliance_id; $playerarray[$line->player_id]["ogame_playerid"] = $line->ogame_playerid; $playerarray[$line->player_id]["banned"] = (strpos($line->status,"g") !== false) ? 'true' : 'false'; $playerarray[$line->player_id]["vacation"] = (strpos($line->status,"u") !== false) ? 'true' : 'false'; $playerarray[$line->player_id]["noob"] = (strpos($line->status,"n") !== false) ? 'true' : 'false'; $playerarray[$line->player_id]["inactive"] = (strpos($line->status,"i") !== false) ? 'true' : 'false'; $playerarray[$line->player_id]["long_inactive"] = (strpos($line->status,"I") !== false) ? 'true' : 'false'; } $moon = ($line->mond == 1) ? 'true' : 'false'; $query .= "('".$line->galaxie."','".$line->system."','".$line->planet."','".$line->player_id."','".$moon."','".$line->mondgr."','".$line->metall."','".$line->kristall."','".$line->planetname."'),"; if ($i == 1000) { // send data $query = substr($query,0,strlen($query)-1); mysql_query($query) or die($query."
".mysql_error()); echo "."; flush(); // reset data $i = 0; $query = "INSERT LOW_PRIORITY INTO $dbtablename (galaxy,system,planet,player_id,moon,moonsize,metal,crystal,planetname) VALUES "; } $i++; } // send data if (strlen($query) > strlen("INSERT LOW_PRIORITY INTO $dbtablename (galaxy,system,planet,player_id,moon,moonsize,metal,crystal,planetname) VALUES ")) { $query = substr($query,0,strlen($query)-1); $res = mysql_query($query) or die(mysql_error()); } echo "done
\n"; // update playerdata echo "update playerdata... "; flush(); $query = "INSERT LOW_PRIORITY INTO $playertable (id,alliance_id,ogame_playerid,noob,banned,vacation,inactive,long_inactive) VALUES "; foreach ($playerarray as $playerid => $value) { if ($value['ogame_playerid'] == 0) $value['ogame_playerid'] = 'NULL'; $query .= "('$playerid','".$value['alliance_id']."','".$value['ogame_playerid']."','".$value['noob']."','".$value['banned']."','".$value['vacation']."','".$value['inactive']."','".$value['long_inactive']."'),"; } $query = substr($query,0,strlen($query)-1); if (strlen($query) > strlen("INSERT LOW_PRIORITY INTO $playertable (id,alliance_id,ogame_playerid,noob,banned,vacation,inactive,long_inactive) VALUES ")) { $query .= " ON DUPLICATE KEY UPDATE alliance_id=VALUES(alliance_id),noob=VALUES(noob),banned=VALUES(banned),vacation=VALUES(vacation),inactive=VALUES(inactive),long_inactive=VALUES(long_inactive)"; // ogame playerid must not be updated, or duplicate key problems may occur $res = mysql_query($query) or die(mysql_error()); } echo "done
\n"; // playerstats echo "fill playerstats... "; flush(); $query = "INSERT LOW_PRIORITY INTO $playertable (rank,points,frank,fpoints,rrank,rpoints,playername) ". "SELECT rank,points,frank,fpoints,rrank,rpoints,playername FROM $old_dbname".".$old_pstablename ". "ON DUPLICATE KEY UPDATE rank=VALUES(rank),points=VALUES(points),frank=VALUES(frank),fpoints=VALUES(fpoints),rrank=VALUES(rrank),rpoints=VALUES(rpoints),playername=VALUES(playername)"; $res = mysql_query($query) or die(mysql_error()); echo "done
\n"; // allystats echo "fill allystats... "; flush(); $query = "INSERT LOW_PRIORITY INTO $allytable (allyname,rank,points,frank,fpoints,rrank,rpoints,members,diplomatic_status) ". "SELECT allyname,rank,points,frank,fpoints,rrank,rpoints,members,allystatus as diplomatic_status FROM $old_dbname".".$old_astablename ". "ON DUPLICATE KEY UPDATE allyname=VALUES(allyname),rank=VALUES(rank),points=VALUES(points),frank=VALUES(frank),fpoints=VALUES(fpoints),rrank=VALUES(rrank),rpoints=VALUES(rpoints),members=VALUES(members),diplomatic_status=VALUES(diplomatic_status)"; $res = mysql_query($query) or die(mysql_error()); echo "done
\n"; // set alliance diplomatic status for players too echo "set diplomatic status... "; flush(); $query = "SELECT diplomatic_status,id FROM $allytable WHERE diplomatic_status != 'nothing'"; $res = mysql_query($query) or die(mysql_error()); while ($line = mysql_fetch_object($res)) { $query2 = "UPDATE $playertable SET diplomatic_status='".$line->diplomatic_status."' WHERE alliance_id='".$line->id."'"; mysql_query($query) or die(mysql_error()); } echo "done
\n"; // insert allyhistory echo "fill player + allyhistory... "; flush(); $query = "SELECT ah.*, a.id as alliance_id, p.id as player_id FROM $allytable a, $old_dbname".".$old_allyhistory ah, $playertable p WHERE a.allyname=ah.alliance AND p.playername=ah.playername ORDER BY date_added"; $res = mysql_query($query) or die(mysql_error()); $query2 = "INSERT LOW_PRIORITY INTO $playerhistory (player_id,alliance_id,year,month,day,points) VALUES "; $query3 = "INSERT LOW_PRIORITY INTO $allyhistory (alliance_id,year,month,day,points) VALUES "; $last_date_added = ""; while ($line = mysql_fetch_object($res)) { // store alliance if ($line->date_added != $last_date_added) { if (isset($allyarray) && count($allyarray) > 0) { // add to query foreach ($allyarray as $allyid => $allyscore) { $query3 .= "($allyid,".substr($line->date_added,0,4).",".substr($line->date_added,5,2).",".substr($line->date_added,8,2).",$allyscore),"; } } // reset data $allyarray = array(); $last_date_added = $line->date_added; } if (!isset($allyarray[$line->alliance_id])) $allyarray[$line->alliance_id] = $line->score; else $allyarray[$line->alliance_id] += $line->score; $query2 .= "($line->player_id,$line->alliance_id,".substr($line->date_added,0,4).",".substr($line->date_added,5,2).",".substr($line->date_added,8,2).",$line->score),"; } if (strlen($query2) > strlen("INSERT LOW_PRIORITY INTO $playerhistory (player_id,alliance_id,year,month,day,points) VALUES ")) { $query2 = substr($query2,0,strlen($query2)-1); mysql_query($query2) or die(mysql_error()); } echo "done\n"; if (strlen($query3) > strlen("INSERT LOW_PRIORITY INTO $allyhistory (alliance_id,year,month,day,points) VALUES ")) { $query3 = substr($query3,0,strlen($query3)-1); mysql_query($query3) or die(mysql_error()); } echo "done
\n"; // get "blank" player echo "starting cleanup..."; flush(); $query = "SELECT id FROM $playertable WHERE playername=''"; $res = mysql_query($query) or die(mysql_error()); $line = mysql_fetch_object($res); $empty_player = '0'; while ($line = mysql_fetch_object($res)) { $empty_player = $line->id; } // delete them at galaxytable $query = "UPDATE $dbtablename SET player_id='0' WHERE player_id='$empty_player'"; mysql_query($query) or die(mysql_error()); // delete them at player and alliance table $query = "DELETE FROM $playertable WHERE id='$empty_player'"; $res = mysql_query($query) or die(mysql_error()); $query = "DELETE FROM $allytable WHERE allyname=''"; $res = mysql_query($query) or die(mysql_error()); // change key for playername from unique to index $query = "ALTER TABLE $playertable DROP INDEX playername , ADD INDEX playername ( playername )"; $res = mysql_query($query) or die(mysql_error()); echo "done
\n"; echo "add some indices..."; flush(); // add new indices $query = "ALTER TABLE $allytable ADD INDEX (diplomatic_status) "; $res = mysql_query($query) or die(mysql_error()); $query = "ALTER TABLE $allytable ADD INDEX (rank) "; $res = mysql_query($query) or die(mysql_error()); $query = "ALTER TABLE $dbtablename ADD INDEX (moon)"; $res = mysql_query($query) or die(mysql_error()); $query = "ALTER TABLE $dbtablename ADD INDEX (last_update) "; $res = mysql_query($query) or die(mysql_error()); $query = "ALTER TABLE $dbtablename ADD INDEX (metal) "; $res = mysql_query($query) or die(mysql_error()); $query = "ALTER TABLE $dbtablename ADD INDEX (crystal) "; $res = mysql_query($query) or die(mysql_error()); $query = "ALTER TABLE $playertable ADD INDEX (rank) "; $res = mysql_query($query) or die(mysql_error()); $query = "ALTER TABLE $playertable ADD INDEX (frank) "; $res = mysql_query($query) or die(mysql_error()); $query = "ALTER TABLE $utablename ADD INDEX (last_action) "; $res = mysql_query($query) or die(mysql_error()); $query = "ALTER TABLE $reporttable ADD INDEX (scantime)"; $res = mysql_query($query) or die(mysql_error()); $query = "ALTER TABLE $reporttable ADD INDEX (metal) "; $res = mysql_query($query) or die(mysql_error()); $query = "ALTER TABLE $reporttable ADD INDEX (crystal)"; $res = mysql_query($query) or die(mysql_error()); $query = "ALTER TABLE $reporttable ADD INDEX (deuterium)"; $res = mysql_query($query) or die(mysql_error()); echo "done
\n"; // Updateinstruktionen: // Allyhistory: Namen der Allianz muss mit dem richtigen Allynamen übereinstimmen - nicht "Wing" oder "main" !!! } if ($version <= 405) { // next version with DB update $query = "ALTER TABLE $utablename ADD INDEX (ingame)"; $res = mysql_query($query) or die(mysql_error()); echo "done
\n"; $query = "ALTER TABLE $utablename ADD INDEX (ogame_playerid)"; $res = mysql_query($query) or die(mysql_error()); echo "done
\n"; $query = "ALTER TABLE $playertable ADD INDEX (last_stats_update)"; $res = mysql_query($query) or die(mysql_error()); echo "done
\n"; $query = "ALTER TABLE $reporttable ADD min_phalanx INT( 3 ) UNSIGNED NULL , ADD max_phalanx INT( 3 ) UNSIGNED NULL , ADD min_rak INT( 3 ) UNSIGNED NULL , ADD max_rak INT( 3 ) UNSIGNED NULL"; $res = mysql_query($query) or die(mysql_error()); echo "done
\n"; $query = "ALTER TABLE $reporttable ADD INDEX min_rak (galaxy,min_rak)"; $res = mysql_query($query) or die(mysql_error()); echo "done
\n"; $query = "ALTER TABLE $reporttable ADD INDEX min_phalanx (galaxy,min_phalanx)"; $res = mysql_query($query) or die(mysql_error()); echo "done
\n"; $query = "UPDATE $reporttable SET min_rak=(system - ((impulse*2)-1)), max_rak=(system + ((impulse*2)+1)) WHERE raksilo>3"; $res = mysql_query($query) or die(mysql_error()); echo "done
\n"; $query = "UPDATE $reporttable SET min_phalanx=(system - ((sensor*sensor)-1)), max_phalanx=(system + ((sensor*sensor)-1)) WHERE sensor>0"; $res = mysql_query($query) or die(mysql_error()); echo "done
\n"; $query = " ALTER TABLE $dbtablename CHANGE planetname planetname VARCHAR( 40 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL"; $res = mysql_query($query) or die(mysql_error()); echo "done
\n"; } if ($version <= 411) { $query = "ALTER TABLE $dbtablename ADD INDEX ( planet )"; $res = mysql_query($query) or die(mysql_error()); echo "done
\n"; $query = "ALTER TABLE $reporttable ADD expedition TINYINT( 3 ) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Expedition technology' AFTER forschungsnetz"; $res = mysql_query($query) or die(mysql_error()); echo "done
\n"; } if ($version <= 420) { $query = "ALTER TABLE $utablename ADD timezone_offset VARCHAR( 6 ) NOT NULL DEFAULT '+00:00' AFTER allytag"; $res = mysql_query($query) or die(mysql_error()); echo "done
\n"; $query = "ALTER TABLE $reporttable ADD user_id SMALLINT( 5 ) UNSIGNED NOT NULL DEFAULT '0' AFTER scantime"; $res = mysql_query($query) or die(mysql_error()); echo "done
\n"; $query = "ALTER TABLE $playertable ADD user_id SMALLINT( 5 ) UNSIGNED NOT NULL DEFAULT '0' AFTER last_stats_update"; $res = mysql_query($query) or die(mysql_error()); echo "done
\n"; $query = "ALTER TABLE $allytable ADD user_id SMALLINT( 5 ) UNSIGNED NOT NULL DEFAULT '0' AFTER last_update"; $res = mysql_query($query) or die(mysql_error()); echo "done
\n"; $query = "ALTER TABLE $reporttable ADD INDEX ( user_id )"; $res = mysql_query($query) or die(mysql_error()); echo "done
\n"; $query = "ALTER TABLE $utablename ADD is_admin ENUM( 'true', 'false' ) NOT NULL DEFAULT 'false' AFTER stylepath"; $res = mysql_query($query) or die(mysql_error()); echo "done
\n"; $query = "ALTER TABLE $utablename ADD INDEX ( is_admin )"; $res = mysql_query($query) or die(mysql_error()); echo "done
\n"; $query = "update $utablename set is_admin = 'true' where username = 'admin'"; $res = mysql_query($query) or die(mysql_error()); echo "done
\n"; // if no admin account was found - create a new one if (mysql_affected_rows() == 0) { $query = "INSERT INTO $utablename (username, userpass, stylepath, is_admin, cansearch, caninsert, statusview, probeview, userman, allyhistory, diplomatic, status, links) VALUES ('admin', md5('galatool'),'styles.css', 'true', 'true', 'true', 'true', 'true', 'true', 'true', 'true', 'active', 'Galaxytool;http://www.galaxytool.eu')"; $res = mysql_query($query) or die(mysql_error()); echo "New adminuser (username: admin) created - change password! (default: galatool)
\n"; } $query = "ALTER TABLE $playertable ADD expedition TINYINT UNSIGNED NOT NULL DEFAULT '0' AFTER forschungsnetz"; $res = mysql_query($query) or die(mysql_error()); echo "done
\n"; // calculate min and max rak with new formula (0.78c) $query = "UPDATE $reporttable SET min_rak=(system - ((impulse*5)-1)), max_rak=(system + ((impulse*5)-1)) WHERE raksilo > 3"; $res = mysql_query($query) or die(mysql_error()); echo "done
\n"; } // new version // in some versions this index is also there // ALTER TABLE `galaxy` DROP INDEX `moon_2` echo "Update complete."; echo "
"; } ?>