Updated install script

Fixed CSS issues

Signed-off-by: Gregory PLANCHAT <g.planchat@gmail.com>
This commit is contained in:
Gregory PLANCHAT 2011-12-05 18:52:05 +01:00
commit 4bb4693d2e
26 changed files with 917 additions and 330 deletions

View file

@ -33,34 +33,35 @@ define('INSTALL' , false);
define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) {
includeLang('admin');
$user = Wootook_Empire_Model_User::getSingleton();
$parse = $lang;
$parse['dpath'] = $dpath;
$parse['mf'] = $mf;
if (!in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) {
message( $lang['sys_noalloaw'], $lang['sys_noaccess'] );
exit(0);
}
$PageTPL = gettemplate('admin/activeplanet_body');
$AllActivPlanet = doquery("SELECT * FROM {{table}} WHERE `last_update` >= '". (time()-15 * 60) ."' ORDER BY `id` ASC", 'planets');
$Count = 0;
includeLang('admin');
while ($ActivPlanet = $AllActivPlanet->fetch(PDO::FETCH_BOTH)) {
$parse['online_list'] .= "<tr>";
$parse['online_list'] .= "<td class=b><center><b>". $ActivPlanet['name'] ."</b></center></td>";
$parse['online_list'] .= "<td class=b><center><b>[". $ActivPlanet['galaxy'] .":". $ActivPlanet['system'] .":". $ActivPlanet['planet'] ."]</b></center></td>";
$parse['online_list'] .= "<td class=m><center><b>". pretty_number($ActivPlanet['points'] / 1000) ."</b></center></td>";
$parse['online_list'] .= "<td class=b><center><b>". pretty_time(time() - $ActivPlanet['last_update']) . "</b></center></td>";
$parse['online_list'] .= "</tr>";
$Count++;
}
$parse['online_list'] .= "<tr>";
$parse['online_list'] .= "<th class=\"b\" colspan=\"4\">". $lang['adm_pl_they'] ." ". $Count ." ". $lang['adm_pl_apla'] ."</th>";
$parse['online_list'] .= "</tr>";
$parse = $lang;
$parse['dpath'] = $dpath;
$parse['mf'] = $mf;
$page = parsetemplate( $PageTPL , $parse );
display( $page, $lang['adm_pl_title'], false, '', true );
} else {
message( $lang['sys_noalloaw'], $lang['sys_noaccess'] );
}
$PageTPL = gettemplate('admin/activeplanet_body');
$AllActivPlanet = doquery("SELECT * FROM {{table}} WHERE `last_update` >= '". (time()-15 * 60) ."' ORDER BY `id` ASC", 'planets');
$Count = 0;
?>
while ($ActivPlanet = $AllActivPlanet->fetch(PDO::FETCH_BOTH)) {
$parse['online_list'] .= "<tr>";
$parse['online_list'] .= "<td class=b><center><b>". $ActivPlanet['name'] ."</b></center></td>";
$parse['online_list'] .= "<td class=b><center><b>[". $ActivPlanet['galaxy'] .":". $ActivPlanet['system'] .":". $ActivPlanet['planet'] ."]</b></center></td>";
$parse['online_list'] .= "<td class=m><center><b>". pretty_number($ActivPlanet['points'] / 1000) ."</b></center></td>";
$parse['online_list'] .= "<td class=b><center><b>". pretty_time(time() - $ActivPlanet['last_update']) . "</b></center></td>";
$parse['online_list'] .= "</tr>";
$Count++;
}
$parse['online_list'] .= "<tr>";
$parse['online_list'] .= "<th class=\"b\" colspan=\"4\">". $lang['adm_pl_they'] ." ". $Count ." ". $lang['adm_pl_apla'] ."</th>";
$parse['online_list'] .= "</tr>";
$page = parsetemplate( $PageTPL , $parse );
display( $page, $lang['adm_pl_title'], false, '', true );

View file

@ -31,71 +31,73 @@
define('INSIDE' , true);
define('INSTALL' , false);
define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
if ($user['authlevel'] >= 1) {
includeLang('admin/add_fleet');
$mode = $_GET['mode'];
$user = Wootook_Empire_Model_User::getSingleton();
if($mode != 'add') {
$parse['ID'] = $lang['Id'];
$parse['Cle'] = $lang['cle'];
$parse['Clourd'] = $lang['clourd'];
$parse['Pt'] = $lang['pt'];
$parse['Gt'] = $lang['gt'];
$parse['Cruise'] = $lang['cruise'];
$parse['Vb'] = $lang['vb'];
$parse['Colo'] = $lang['colo'];
$parse['Rc'] = $lang['rc'];
$parse['Spy'] = $lang['spy'];
$parse['Bomb'] = $lang['bomb'];
$parse['Solar'] = $lang['solar'];
$parse['Des'] = $lang['des'];
$parse['Rip'] = $lang['rip'];
$parse['Traq'] = $lang['traq'];
if (!in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) {
message( $lang['sys_noalloaw'], $lang['sys_noaccess'] );
exit(0);
}
} elseif($mode == 'add') {
$id = $_POST['id'];
$cle = $_POST['cle'];
$clourd = $_POST['clourd'];
$pt = $_POST['pt'];
$gt = $_POST['gt'];
$cruise = $_POST['cruise'];
$vb = $_POST['vb'];
$colo = $_POST['colo'];
$rc = $_POST['rc'];
$spy = $_POST['spy'];
$bomb = $_POST['bomb'];
$solar = $_POST['solar'];
$des = $_POST['des'];
$rip = $_POST['rip'];
$traq = $_POST['traq'];
includeLang('admin/add_fleet');
$mode = $_GET['mode'];
$SqlAdd = "UPDATE {{table}} SET";
$SqlAdd .= "`light_hunter` = '".$cle."+light_hunter', ";
$SqlAdd .= "`heavy_hunter` = '".$clourd."+heavy_hunter', ";
$SqlAdd .= "`small_ship_cargo` = '".$pt."+small_ship_cargo', ";
$SqlAdd .= "`big_ship_cargo` = '".$gt."+big_ship_cargo', ";
$SqlAdd .= "`crusher` = '".$cruise."+crusher', ";
$SqlAdd .= "`battle_ship` = '".$vb."+battle_ship', ";
$SqlAdd .= "`colonizer` = '".$colo."+colonizer', ";
$SqlAdd .= "`recycler` = '".$rc."+recycler', ";
$SqlAdd .= "`spy_sonde`= '".$spy."+spy_sonde', ";
$SqlAdd .= "`bomber_ship` = '".$bomb."+bomber_ship', ";
$SqlAdd .= "`solar_satelit` = '".$solar."+solar_satelit', ";
$SqlAdd .= "`destructor` = '".$des."+destructor', ";
$SqlAdd .= "`dearth_star` = '".$rip."+dearth_star', ";
$SqlAdd .= "`battleship` = '".$traq."+battleship', ";
$SqlAdd .= " WHERE `id` = '".$id."' LIMIT 1";
doquery($SqlAdd, "planets");
message('Ajout OK');
}
if($mode != 'add') {
$parse['ID'] = $lang['Id'];
$parse['Cle'] = $lang['cle'];
$parse['Clourd'] = $lang['clourd'];
$parse['Pt'] = $lang['pt'];
$parse['Gt'] = $lang['gt'];
$parse['Cruise'] = $lang['cruise'];
$parse['Vb'] = $lang['vb'];
$parse['Colo'] = $lang['colo'];
$parse['Rc'] = $lang['rc'];
$parse['Spy'] = $lang['spy'];
$parse['Bomb'] = $lang['bomb'];
$parse['Solar'] = $lang['solar'];
$parse['Des'] = $lang['des'];
$parse['Rip'] = $lang['rip'];
$parse['Traq'] = $lang['traq'];
$page = parsetemplate(gettemplate('admin/add_fleet'), $parse);
display( $page);
} else if($mode == 'add') {
$id = $_POST['id'];
$cle = $_POST['cle'];
$clourd = $_POST['clourd'];
$pt = $_POST['pt'];
$gt = $_POST['gt'];
$cruise = $_POST['cruise'];
$vb = $_POST['vb'];
$colo = $_POST['colo'];
$rc = $_POST['rc'];
$spy = $_POST['spy'];
$bomb = $_POST['bomb'];
$solar = $_POST['solar'];
$des = $_POST['des'];
$rip = $_POST['rip'];
$traq = $_POST['traq'];
} else {
message( $lang['sys_noalloaw'], $lang['sys_noaccess'] );
}
$SqlAdd = "UPDATE {{table}} SET";
$SqlAdd .= "`light_hunter` = '".$cle."+light_hunter', ";
$SqlAdd .= "`heavy_hunter` = '".$clourd."+heavy_hunter', ";
$SqlAdd .= "`small_ship_cargo` = '".$pt."+small_ship_cargo', ";
$SqlAdd .= "`big_ship_cargo` = '".$gt."+big_ship_cargo', ";
$SqlAdd .= "`crusher` = '".$cruise."+crusher', ";
$SqlAdd .= "`battle_ship` = '".$vb."+battle_ship', ";
$SqlAdd .= "`colonizer` = '".$colo."+colonizer', ";
$SqlAdd .= "`recycler` = '".$rc."+recycler', ";
$SqlAdd .= "`spy_sonde`= '".$spy."+spy_sonde', ";
$SqlAdd .= "`bomber_ship` = '".$bomb."+bomber_ship', ";
$SqlAdd .= "`solar_satelit` = '".$solar."+solar_satelit', ";
$SqlAdd .= "`destructor` = '".$des."+destructor', ";
$SqlAdd .= "`dearth_star` = '".$rip."+dearth_star', ";
$SqlAdd .= "`battleship` = '".$traq."+battleship', ";
$SqlAdd .= " WHERE `id` = '".$id."' LIMIT 1";
doquery($SqlAdd, "planets");
message('Ajout OK');
}
$page = parsetemplate(gettemplate('admin/add_fleet'), $parse);
display( $page);
?>

View file

@ -33,35 +33,36 @@ define('INSTALL' , false);
define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) {
includeLang('admin');
$user = Wootook_Empire_Model_User::getSingleton();
$mode = $_POST['mode'];
if (!in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) {
message( $lang['sys_noalloaw'], $lang['sys_noaccess'] );
exit(0);
}
$PageTpl = gettemplate("admin/add_money");
$parse = $lang;
includeLang('admin');
if ($mode == 'addit') {
$id = $_POST['id'];
$metal = $_POST['metal'];
$cristal = $_POST['cristal'];
$deut = $_POST['deut'];
$mode = $_POST['mode'];
$QryUpdatePlanet = "UPDATE {{table}} SET ";
$QryUpdatePlanet .= "`metal` = `metal` + '". $metal ."', ";
$QryUpdatePlanet .= "`crystal` = `crystal` + '". $cristal ."', ";
$QryUpdatePlanet .= "`deuterium` = `deuterium` + '". $deut ."' ";
$QryUpdatePlanet .= "WHERE ";
$QryUpdatePlanet .= "`id` = '". $id ."' ";
doquery( $QryUpdatePlanet, "planets");
$PageTpl = gettemplate("admin/add_money");
$parse = $lang;
AdminMessage ( $lang['adm_am_done'], $lang['adm_am_ttle'] );
}
$Page = parsetemplate($PageTpl, $parse);
if ($mode == 'addit') {
$id = $_POST['id'];
$metal = $_POST['metal'];
$cristal = $_POST['cristal'];
$deut = $_POST['deut'];
display ($Page, $lang['adm_am_ttle'], false, '', true);
} else {
AdminMessage ( $lang['sys_noalloaw'], $lang['sys_noaccess'] );
}
$QryUpdatePlanet = "UPDATE {{table}} SET ";
$QryUpdatePlanet .= "`metal` = `metal` + '". $metal ."', ";
$QryUpdatePlanet .= "`crystal` = `crystal` + '". $cristal ."', ";
$QryUpdatePlanet .= "`deuterium` = `deuterium` + '". $deut ."' ";
$QryUpdatePlanet .= "WHERE ";
$QryUpdatePlanet .= "`id` = '". $id ."' ";
doquery( $QryUpdatePlanet, "planets");
?>
AdminMessage ( $lang['adm_am_done'], $lang['adm_am_ttle'] );
}
$Page = parsetemplate($PageTpl, $parse);
display ($Page, $lang['adm_am_ttle'], false, '', true);

View file

@ -37,11 +37,11 @@ $dpath = (!$userrow["dpath"]) ? DEFAULT_SKINPATH : $userrow["dpath"];
if(!is_numeric($_GET["a"]) || !$_GET["a"] ){ message("Ung&uuml;ltige Allianz-ID","Fehler");}
$allyrow = doquery("SELECT ally_name,ally_tag,ally_description,ally_web,ally_image FROM {{table}} WHERE id=".$_GET["a"],"alliance",true);
$allyrow = doquery("SELECT ally_name,ally_tag,ally_description,ally_web,ally_image FROM {{table}} WHERE id=".intval($_GET["a"]),"alliance",true);
if(!$allyrow){ message("Alliance non trouv&eacute;e","Erreur");}
$count = doquery("SELECT COUNT(DISTINCT(id)) FROM {{table}} WHERE ally_id=".$_GET["a"].";","users",true);
$count = doquery("SELECT COUNT(DISTINCT(id)) FROM {{table}} WHERE ally_id=".intval($_GET["a"]).";","users",true);
$ally_member_scount = $count[0];
$page .="<table width=519><tr><td class=c colspan=2>Informations sur l'alliance</td></tr>";

View file

@ -41,30 +41,31 @@ echo 'parent.location="../";';
echo '</script>';
}
$mode = isset($_GET['mode']) ? $_GET['mode'] : null;
$yes = isset($_GET['yes']) ? $_GET['yes'] : null;
$edit = isset($_GET['edit']) ? $_GET['edit'] : null;
$allyid = isset($_GET['allyid']) ? intval($_GET['allyid']) : null;
$kick = isset($_GET['kick']) ? $_GET['kick'] : null;
$show = isset($_GET['show']) ? intval($_GET['show']) : null;
$sort = isset($_GET['sort']) ? intval($_GET['sort']) : null;
$sendmail = isset($_GET['sendmail']) ? intval($_GET['sendmail']) : null;
$rank = isset($_GET['rank']) ? intval($_GET['rank']) : null;
$t = isset($_GET['t']) ? $_GET['t'] : null;
$a = isset($_GET['a']) ? intval($_GET['a']) : null;
$tag = isset($_GET['tag']) ? $db->quote($_GET['tag']) : null;
$page = isset($page) ? $page : null;
$d = isset($_GET['d']) ? $_GET['d'] : null;
$id = isset($_GET['id']) ? $_GET['id'] : null;
$request = Wootook::getRequest();
$_POST['id'] = isset($_POST['id']) ? $_POST['id'] : null;
$_POST['t'] = isset($_POST['t']) ? $_POST['t'] : null;
$_POST['options'] = isset($_POST['options']) ? $_POST['options'] : null;
$_POST['action'] = isset($_POST['action']) ? $_POST['action'] : null;
$mode = $request->getQuery('mode');
$yes = $request->getQuery('yes');
$edit = $request->getQuery('edit');
$allyid = intval($request->getQuery('allyid'));
$kick = $request->getQuery('kick');
$show = intval($request->getQuery('show'));
$sort = intval($request->getQuery('sort'));
$sendmail = intval($request->getQuery('sendmail'));
$rank = intval($request->getQuery('rank'));
$t = $request->getQuery('t');
$allianceId = intval($request->getQuery('a'));
$tag = $request->getQuery('tag');
$page = $request->getQuery('page');
$d = $request->getQuery('d');
$id = $request->getQuery('id');
$allianceIds = $request->getPost('id');
$actionType = $request->getPost('t');
$options = $request->getPost('options');
$action = $request->getPost('action');
includeLang('alliance');
/**
*Alliance information display.
*/
@ -73,9 +74,9 @@ if ($mode == 'ainfo') {
$lang['Alliance_information'] = "Information Alliance";
if ($tag) {
$allyrow = doquery("SELECT * FROM {{table}} WHERE ally_tag={$tag}", "alliance", true);
} elseif (is_numeric($a) && $a != 0) {
$allyrow = doquery("SELECT * FROM {{table}} WHERE id='{$a}'", "alliance", true);
$allyrow = doquery("SELECT * FROM {{table}} WHERE ally_tag={$db->quote($tag)}", "alliance", true);
} elseif (is_numeric($allianceId) && $allianceId != 0) {
$allyrow = doquery("SELECT * FROM {{table}} WHERE id='{$allianceId}'", "alliance", true);
} else {
message("Cette alliance n'existe pas !", "Information Alliance (1)");
}
@ -138,17 +139,17 @@ if ($user->getData('ally_id') == 0) {
/*
* Creation of the alliance
*/
if ($yes == 1 && isset($_POST)) {
if ($yes == 1 && isset($request->isPost())) {
if (empty($_POST['atag'])) {
if ($request->getPost('atag') !== null) {
message($lang['have_not_tag'], $lang['make_alliance']);
}
if (empty($_POST['aname'])) {
if ($request->getPost('aname') !== null) {
message($lang['have_not_name'], $lang['make_alliance']);
}
$alliance_name = $db->quote($_POST['aname']);
$alliance_tag = $db->quote($_POST['atag']);
$alliance_name = $db->quote($request->getPost('aname'));
$alliance_tag = $db->quote($request->getPost('atag'));
$tagquery = doquery("SELECT * FROM {{table}} WHERE ally_tag=" .$alliance_tag. ";", 'alliance', true);
@ -156,7 +157,7 @@ if ($user->getData('ally_id') == 0) {
message(str_replace('%s', $alliance_tag, $lang['always_exist']), $lang['make_alliance']);
}
$ranks = '';
$allianz_raenge[] = array('name' => 'Novice',
$allianz_raenge[] = array('name' => 'Novice',
'mails' => 0,
'delete' => 0,
'kick' => 0,
@ -175,7 +176,7 @@ if ($user->getData('ally_id') == 0) {
`ally_tag`=" . $alliance_tag . " ,
`ally_owner`='" .$user->getId(). "',
`ally_owner_range`='Leader',
`ally_ranks`='" . $ranks . "',
`ally_ranks`='" . $ranks . "',
`ally_members`='1',
`ally_register_time`=" . time() , "alliance");
@ -200,11 +201,11 @@ if ($user->getData('ally_id') == 0) {
if ($mode == 'search' && $user->getData('ally_request') == 0) {
$parse = $lang;
$search_text = isset($_POST['searchtext']) ? $_POST['searchtext'] : null;
$search_text = $request->getPost('searchtext');
$lang['searchtext'] = $search_text;
$page = parsetemplate(gettemplate('alliance_searchform'), $lang);
if (isset($_POST['searchtext'])) {
if ($request->getPost('searchtext') !== null) {
$stmt = $db->prepare("SELECT * FROM {$db->getTable('alliance')} WHERE ally_name LIKE :search_field OR ally_tag LIKE :search_field LIMIT 30");
$stmt->execute(array(':search_field' => '%' .$search_text. '%'));
if ($stmt->rowCount() != 0) {
@ -244,8 +245,8 @@ if ($user->getData('ally_id') == 0) {
extract($allyrow);
if (isset($_POST['further']) && $_POST['further'] == $lang['Send']) {
doquery("UPDATE {{table}} SET `ally_request`='" . $allyid . "', ally_request_text=" . $db->quote($_POST['text']) . ", ally_register_time='" . time() . "' WHERE `id`='" . $user->getId(). "'", "users");
if ($request->getPost('further') !== null && $request->getPost('further') == $lang['Send']) {
doquery("UPDATE {{table}} SET `ally_request`='" . $allyid . "', ally_request_text=" . $db->quote($request->getPost('text')) . ", ally_register_time='" . time() . "' WHERE `id`='" . $user->getId(). "'", "users");
message($lang['apply_registered'], $lang['your_apply']);
} else {
$text_apply = ($ally_request) ? $ally_request : $lang['There_is_no_a_text_apply'];
@ -269,7 +270,7 @@ if ($user->getData('ally_id') == 0) {
$allyquery = doquery("SELECT ally_tag FROM {{table}} WHERE id='" . $user->getData('ally_request') . "' ORDER BY `id`", "alliance", true);
extract($allyquery);
if (isset($_POST['bcancel'])) {
if ($request->getPost('bcancel') !== null) {
doquery("UPDATE {{table}} SET `ally_request`=0 WHERE `id`=" . $user->getId('id'), "users");
$lang['request_text'] = str_replace('%s', $ally_tag, $lang['Canceled_a_request_text']);
@ -394,9 +395,9 @@ elseif ($user->getData('ally_id') != 0 && $user->getData('ally_request') == 0) {
message($lang['Denied_access'], $lang['Members_list']);
}
// Order of displaying the different users
$sort2 = isset($_GET['sort2']) ? intval($_GET['sort2']) : null;
$sort2 = intval($request->getQuery('sort2'));
if ($sort2) {
$sort1 = isset($_GET['sort1']) ? intval($_GET['sort1']) : null;
$sort1 = intval($request->getQuery('sort1'));
switch($sort1){
case 1:
$sort = " ORDER BY `username`";
@ -506,9 +507,9 @@ elseif ($user->getData('ally_id') != 0 && $user->getData('ally_request') == 0) {
}
if ($sendmail == 1) {
if (isset($_POST['r']) && is_numeric($_POST['r'])){
$group_rank = intval($_POST['r']);
$message_text = $db->quote($_POST['text']);
if ($request->getPost('r') !== null && is_numeric($request->getPost('r'))){
$group_rank = intval($request->getPost('r'));
$message_text = $db->quote($request->getPost('text'));
if ($group_rang == 0) {
$sq = doquery("SELECT id,username FROM {{table}} WHERE ally_id='{$user['ally_id']}'", "users");
} else {
@ -558,8 +559,8 @@ elseif ($user->getData('ally_id') != 0 && $user->getData('ally_request') == 0) {
if ($ally['ally_owner'] != $user->getId() && !$user_can_edit_rights) {
message($lang['Denied_access'], $lang['Members_list']);
} elseif (!empty($_POST['newrangname'])) {
$name = strip_tags($_POST['newrangname']);
} else if ($request->getPost('newrangname') != '') {
$name = strip_tags($request->getPost('newrangname'));
$allianz_raenge[] = array('name' => $name,
'mails' => 0,
@ -581,63 +582,63 @@ elseif ($user->getData('ally_id') != 0 && $user->getData('ally_request') == 0) {
header("Location: " . $goto);
exit();
} elseif ($_POST['id'] != '' && is_array($_POST['id'])) {
} elseif (is_array($allianceIds) && !empty($allianceIds)) {
$ally_ranks_new = array();
foreach ($_POST['id'] as $id) {
foreach ($allianceIds as $id) {
$name = $allianz_raenge[$id]['name'];
$ally_ranks_new[$id]['name'] = $name;
if (isset($_POST['u' . $id . 'r0'])) {
if ($request->getPost('u' . $id . 'r0') !== null) {
$ally_ranks_new[$id]['delete'] = 1;
} else {
$ally_ranks_new[$id]['delete'] = 0;
}
if (isset($_POST['u' . $id . 'r1']) && $ally['ally_owner'] == $user->getId()) {
if ($request->getPost('u' . $id . 'r1') !== null && $ally['ally_owner'] == $user->getId()) {
$ally_ranks_new[$id]['kick'] = 1;
} else {
$ally_ranks_new[$id]['kick'] = 0;
}
if (isset($_POST['u' . $id . 'r2'])) {
if ($request->getPost('u' . $id . 'r2') !== null) {
$ally_ranks_new[$id]['bewerbungen'] = 1;
} else {
$ally_ranks_new[$id]['bewerbungen'] = 0;
}
if (isset($_POST['u' . $id . 'r3'])) {
if ($request->getPost('u' . $id . 'r3') !== null) {
$ally_ranks_new[$id]['memberlist'] = 1;
} else {
$ally_ranks_new[$id]['memberlist'] = 0;
}
if (isset($_POST['u' . $id . 'r4'])) {
if ($request->getPost('u' . $id . 'r4') !== null) {
$ally_ranks_new[$id]['bewerbungenbearbeiten'] = 1;
} else {
$ally_ranks_new[$id]['bewerbungenbearbeiten'] = 0;
}
if (isset($_POST['u' . $id . 'r5'])) {
if ($request->getPost('u' . $id . 'r5') !== null) {
$ally_ranks_new[$id]['administrieren'] = 1;
} else {
$ally_ranks_new[$id]['administrieren'] = 0;
}
if (isset($_POST['u' . $id . 'r6'])) {
if ($request->getPost('u' . $id . 'r6') !== null) {
$ally_ranks_new[$id]['onlinestatus'] = 1;
} else {
$ally_ranks_new[$id]['onlinestatus'] = 0;
}
if (isset($_POST['u' . $id . 'r7'])) {
if ($request->getPost('u' . $id . 'r7') !== null) {
$ally_ranks_new[$id]['mails'] = 1;
} else {
$ally_ranks_new[$id]['mails'] = 0;
}
if (isset($_POST['u' . $id . 'r8'])) {
if ($request->getPost('u' . $id . 'r8') !== null) {
$ally_ranks_new[$id]['rechtehand'] = 1;
} else {
$ally_ranks_new[$id]['rechtehand'] = 0;
@ -719,24 +720,18 @@ elseif ($user->getData('ally_id') != 0 && $user->getData('ally_request') == 0) {
if ($t != 1 && $t != 2 && $t != 3) {
$t = 1;
}
if (!get_magic_quotes_gpc()) {
$_POST['owner_range'] = isset($_POST['owner_range']) ? stripslashes($_POST['owner_range']) : null;
$_POST['web'] = isset($_POST['web']) ? stripslashes($_POST['web']) : null;
$_POST['image'] = isset($_POST['image']) ? stripslashes($_POST['image']) : null;
$_POST['text'] = isset($_POST['text']) ? stripslashes($_POST['text']) : null;
}
if ($_POST['options']) {
$ally['ally_owner_range'] = htmlspecialchars(strip_tags($_POST['owner_range']));
if ($options) {
$ally['ally_owner_range'] = htmlspecialchars(strip_tags($request->getPost('owner_range')));
$ally['ally_web'] = htmlspecialchars(strip_tags($_POST['web']));
$ally['ally_web'] = htmlspecialchars(strip_tags($request->getPost('web')));
$ally['ally_image'] = htmlspecialchars(strip_tags($_POST['image']));
$ally['ally_image'] = htmlspecialchars(strip_tags($request->getPost('image')));
$ally['ally_request_notallow'] = intval($_POST['request_notallow']);
$ally['ally_request_notallow'] = intval($request->getPost('request_notallow'));
if ($ally['ally_request_notallow'] != 0 && $ally['ally_request_notallow'] != 1) {
message("Aller � \"Candidature\" et sur une option dans le formulaire!", "Erreur");
message("Aller � \"Candidature\" et sur une option dans le formulaire!", "Erreur");
exit;
}
@ -746,20 +741,20 @@ elseif ($user->getData('ally_id') != 0 && $user->getData('ally_request') == 0) {
`ally_web`={$db->quote($ally['ally_web'])},
`ally_request_notallow`='{$ally['ally_request_notallow']}'
WHERE `id`='{$ally['id']}'", "alliance");
} elseif ($_POST['t']) {
} elseif ($actionType) {
if ($t == 3) {
$ally['ally_request'] = strip_tags($_POST['text']);
$ally['ally_request'] = strip_tags($request->getPost('text'));
doquery("UPDATE {{table}} SET
`ally_request`={$db->quote($ally['ally_request'])}
WHERE `id`='{$ally['id']}'", "alliance");
} elseif ($t == 2) {
$ally['ally_text'] = strip_tags($_POST['text']);
$ally['ally_text'] = strip_tags($request->getPost('text'));
doquery("UPDATE {{table}} SET
`ally_text`={$db->quote($ally['ally_text'])}
WHERE `id`='{$ally['id']}'", "alliance");
} else {
$ally['ally_description'] = strip_tags($_POST['text']);
$ally['ally_description'] = strip_tags($request->getPost('text'));
doquery("UPDATE {{table}} SET
`ally_description`=" . $db->quote($ally['ally_description']) . "
@ -806,8 +801,8 @@ elseif ($user->getData('ally_id') != 0 && $user->getData('ally_request') == 0) {
}
if ($mode == 'admin' && $edit == 'give') {
if ($_POST["id"]) {
doquery("update {{table}} set `ally_owner`=".$db->quote($_POST["id"])." where `id`='".$user['ally_id']."'",'alliance');
if ($request->getPost('id')) {
doquery("update {{table}} set `ally_owner`=".$db->quote($request->getPost('id'))." where `id`='".$user['ally_id']."'",'alliance');
} else {
$selection=doquery("SELECT * FROM {{table}} where ally_id='".$user['ally_id']."'",'users');
$select='';
@ -846,12 +841,12 @@ elseif ($user->getData('ally_id') != 0 && $user->getData('ally_request') == 0) {
if ($u['ally_id'] == $ally['id'] && $u['id'] != $ally['ally_owner']) {
doquery("UPDATE {{table}} SET `ally_id`='0', `ally_name`='', `ally_rank_id` = '0' WHERE `id`='{$u['id']}'", 'users');
}
} elseif (isset($_POST['newrang'])) {
$newrank = isset($_POST['newrang']) ? intval($_POST['newrang']) : null;
$q = doquery("SELECT * FROM {{table}} WHERE id='{intval($id}' LIMIT 1", 'users', true);
} else if ($request->getPost('newrang') !== null) {
$newrank = $request->getPost('newrang');
$selectedUser = Wootook_Empire_Model_User::factory($id);
if (isset($ally_ranks[$newrank]) && $q['id'] != $ally['ally_owner']) {
doquery("UPDATE {{table}} SET `ally_rank_id`=" . $newrank . " WHERE `id`='" . intval($id) . "'", 'users');
if ($newrank !== null && isset($ally_ranks[$newrank]) && $selectedUser->getId() != $ally['ally_owner']) {
$selectedUser->setData('ally_rank_id', $newrank)->save();
}
}
@ -859,9 +854,9 @@ elseif ($user->getData('ally_id') != 0 && $user->getData('ally_request') == 0) {
$f_template = gettemplate('alliance_admin_members_function');
// Order of displaying the different users
$sort2 = isset($_GET['sort2']) ? intval($_GET['sort2']) : null;
$sort2 = intval($request->getQuery('sort2'));
if ($sort2) {
$sort1 = isset($_GET['sort1']) ? intval($_GET['sort1']) : null;
$sort1 = intval($request->getQuery('sort1'));
switch($sort1){
case 1:
$sort = " ORDER BY `username`";
@ -997,9 +992,7 @@ elseif ($user->getData('ally_id') != 0 && $user->getData('ally_request') == 0) {
message($lang['Denied_access'], $lang['Check_the_requests']);
}
if ($_POST['action'] == "Accepter") {
$_POST['text'] = strip_tags($_POST['text']);
if ($action == "Accepter") {
$u = doquery("SELECT * FROM {{table}} WHERE id=$show", 'users', true);
// add points from the user who join the alliance
doquery("UPDATE {{table}} SET
@ -1015,7 +1008,7 @@ elseif ($user->getData('ally_id') != 0 && $user->getData('ally_request') == 0) {
mnl_alliance=mnl_alliance+1
WHERE id='{$show}'", 'users');
$message = "Bonjour,<br>L'Alliance <b>{$ally['ally_name']}</b> a accepté votre candidature.<br>Charte:<br>{$_POST['text']}";
$message = "Bonjour,<br>L'Alliance <b>{$ally['ally_name']}</b> a accepté votre candidature.<br>Charte:<br>{$request->getPost('text')}";
// Send a message to the new member of the alliance
doquery("INSERT INTO {{table}} SET
`message_owner`=" .$db->quote($show).",
@ -1029,12 +1022,10 @@ elseif ($user->getData('ally_id') != 0 && $user->getData('ally_request') == 0) {
header('Location: alliance.php?mode=admin&edit=requests');
die();
} elseif ($_POST['action'] == "Refuser" && $_POST['action'] != '') {
$_POST['text'] = strip_tags($_POST['text']);
} elseif ($action == "Refuser" && $action != '') {
doquery("UPDATE {{table}} SET ally_request_text='',ally_request='0',ally_id='0',new_message=new_message+1, mnl_alliance=mnl_alliance+1 WHERE id={$db->quote($show)}", 'users');
$message = "Bonjour,<br>L'Alliance <b>{$ally['ally_name']}</b> a refusé votre candidature.<br>Raison:<br>{$_POST['text']}";
$message = "Bonjour,<br>L'Alliance <b>{$ally['ally_name']}</b> a refusé votre candidature.<br>Raison:<br>{$request->getPost('text')}";
// Send a polite message to the player that he is too noobish for that alliance.
doquery("INSERT INTO {{table}} SET
`message_owner`=" .$db->quote($show).",
@ -1102,10 +1093,10 @@ elseif ($user->getData('ally_id') != 0 && $user->getData('ally_request') == 0) {
message($lang['Denied_access'], $lang['Members_list']);
}
if (isset($_POST['newname'])) {
if ($request->getPost('newname') !== null) {
// Y a le nouveau Nom
// New name so lets update all
$ally['ally_name'] = strip_tags($_POST['newname']);
$ally['ally_name'] = strip_tags($request->getPost('newname'));
doquery("UPDATE {{table}} SET `ally_name` = ". $db->quote($ally['ally_name']) ." WHERE `id` = '". $user->getData('ally_id') ."';", 'alliance');
doquery("UPDATE {{table}} SET `ally_name` = ". $db->quote($ally['ally_name']) ." WHERE `ally_id` = '". $ally['id'] ."';", 'users');
}
@ -1130,10 +1121,10 @@ elseif ($user->getData('ally_id') != 0 && $user->getData('ally_request') == 0) {
message($lang['Denied_access'], $lang['Members_list']);
}
if (isset($_POST['newtag'])) {
if ($request->getPost('newtag') !== null) {
// Y a le nouveau TAG
// new TAG, lets update the table
$ally['ally_tag'] = strip_tags($_POST['newtag']);
$ally['ally_tag'] = strip_tags($request->getPost('newtag'));
doquery("UPDATE {{table}} SET `ally_tag` = ". $db->quote($ally['ally_tag']) ." WHERE `id` = '". $user->getData('ally_id') ."';", 'alliance');
}

View file

@ -0,0 +1,159 @@
<?php
/**
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://www.wootook.com/
*
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* --> NOTICE <--
* This file is part of the core development branch, changing its contents will
* make you unable to use the automatic updates manager. Please refer to the
* documentation for further information about customizing Wootook.
*
*/
/**
*
* Enter description here ...
* @author Greg
*
*/
class Generations_Empire
{
const TYPE_BUILDING = 'building';
const TYPE_RESEARCH = 'technology';
const TYPE_SHIP = 'fleet';
const TYPE_DEFENSE = 'defense';
const TYPE_SPECIAL = 'special';
const TYPE_PRODUCTION = 'prodution';
const TYPE_FLEET_MISSION = 'mission';
const RESOURCE_GOLD = 'gold';
const RESOURCE_TITANIUM = 'titanium';
const RESOURCE_ZIRCONIUM = 'zirconium';
const RESOURCE_TRITIUM = 'tritium';
const RESOURCE_POPULATION = 'population';
const RESOURCE_ENERGY = 'energy';
const RESOURCE_MULTIPLIER = 'multiplier';
const RESOURCE_CLASS = 'class';
const BASE_BUILDING_TIME = 'base_time';
const SHIPS_CONSUMPTION_PRIMARY = 'primary_consumption';
const SHIPS_CELERITY_PRIMARY = 'primary_speed';
const SHIPS_CONSUMPTION_SECONDARY = 'secondary_consumption';
const SHIPS_CELERITY_SECONDARY = 'secondary_speed';
const SHIPS_CAPACITY_PRIMARY = 'primary_capacity';
const SHIPS_CAPACITY_SECONDARY = 'secondary_capacity';
const ID_BUILDING_GOLD_MINE = 1;
const ID_BUILDING_GERMANUIM_MINE = 2;
const ID_BUILDING_DEUTERIUM_SYNTHETISER = 3;
const ID_BUILDING_SOLAR_PLANT = 4;
const ID_BUILDING_FUSION_REACTOR = 12;
const ID_BUILDING_ROBOTIC_FACTORY = 14;
const ID_BUILDING_NANITE_FACTORY = 15;
const ID_BUILDING_SHIPYARD = 21;
const ID_BUILDING_METAL_STORAGE = 22;
const ID_BUILDING_CRISTAL_STORAGE = 23;
const ID_BUILDING_DEUTERIUM_TANK = 24;
const ID_BUILDING_RESEARCH_LAB = 31;
const ID_BUILDING_TERRAFORMER = 33;
const ID_BUILDING_ALLIANCE_DEPOT = 34;
const ID_BUILDING_LUNAR_BASE = 41;
const ID_BUILDING_SENSOR_PHALANX = 42;
const ID_BUILDING_JUMP_GATE = 43;
const ID_BUILDING_MISSILE_SILO = 44;
const ID_RESEARCH_ESPIONAGE_TECHNOLOGY = 106;
const ID_RESEARCH_COMPUTER_TECHNOLOGY = 108;
const ID_RESEARCH_WEAPON_TECHNOLOGY = 109;
const ID_RESEARCH_SHIELDING_TECHNOLOGY = 110;
const ID_RESEARCH_ARMOUR_TECHNOLOGY = 111;
const ID_RESEARCH_ENERGY_TECHNOLOGY = 113;
const ID_RESEARCH_HYPERSPACE_TECHNOLOGY = 114;
const ID_RESEARCH_COMBUSTION_DRIVE = 115;
const ID_RESEARCH_IMPULSE_DRIVE = 117;
const ID_RESEARCH_HYPERSPACE_DRIVE = 118;
const ID_RESEARCH_LASER_TECHNOLOGY = 120;
const ID_RESEARCH_ION_TECHNOLOGY = 121;
const ID_RESEARCH_PLASMA_TECHNOLOGY = 122;
const ID_RESEARCH_INTERGALACTIC_RESEARCH_NETWORK = 123;
const ID_RESEARCH_EXPEDITION_TECHNOLOGY = 124;
const ID_RESEARCH_ASTROPHYSICS = 124;
const ID_RESEARCH_GRAVITON_TECHNOLOGY = 199;
const ID_SHIP_LIGHT_TRANSPORT = 202;
const ID_SHIP_LARGE_TRANSPORT = 203;
const ID_SHIP_LIGHT_FIGHTER = 204;
const ID_SHIP_HEAVY_FIGHTER = 205;
const ID_SHIP_CRUISER = 206;
const ID_SHIP_BATTLESHIP = 207;
const ID_SHIP_COLONY_SHIP = 208;
const ID_SHIP_RECYCLER = 209;
const ID_SHIP_SPY_DRONE = 210;
const ID_SHIP_BOMBER = 211;
const ID_SHIP_SOLAR_SATELLITE = 212;
const ID_SHIP_DESTRUCTOR = 213;
const ID_SHIP_DEATH_STAR = 214;
const ID_SHIP_BATTLECRUISER = 215;
const ID_SHIP_SUPERNOVA = 216;
const ID_DEFENSE_ROCKET_LAUNCHER = 401;
const ID_DEFENSE_LIGHT_LASER = 402;
const ID_DEFENSE_HEAVY_LASER = 403;
const ID_DEFENSE_ION_CANNON = 404;
const ID_DEFENSE_GAUSS_CANNON = 405;
const ID_DEFENSE_PLASMA_TURRET = 406;
const ID_DEFENSE_SMALL_SHIELD_DOME = 407;
const ID_DEFENSE_LARGE_SHIELD_DOME = 408;
const ID_SPECIAL_ANTIBALLISTIC_MISSILE = 502;
const ID_SPECIAL_INTERPLANETARY_MISSILE = 503;
const ID_COMBAT_SHIELDS = 'shield';
const ID_COMBAT_FIREPOWER = 'attack';
const ID_COMBAT_RAPID_FIRE = 'rapidfire';
const ID_MISSION_ATTACK = 1;
const ID_MISSION_GROUP_ATTACK = 2;
const ID_MISSION_TRANSPORT = 3;
const ID_MISSION_STATION = 4;
const ID_MISSION_STATION_ALLY = 5;
const ID_MISSION_SPY = 6;
const ID_MISSION_SETTLE_COLONY = 7;
const ID_MISSION_RECYCLE = 8;
const ID_MISSION_DESTROY = 9;
const ID_MISSION_MISSILES = 10;
const ID_MISSION_BLOCUS = 11;
const ID_MISSION_BLOCUS = 11;
const ID_MISSION_EXPEDITION = 15;
public static function getFieldName($id)
{
$fieldsAlias = Wootook_Empire_Model_Game_FieldsAlias::getSingleton();
if (!isset($fieldsAlias[$id])) {
return null;
}
return $fieldsAlias[$id];
}
}

View file

@ -31,7 +31,7 @@
$this->setSetupConnection('core_setup');
$sql = <<<SQL_EOF
CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/aks')} (
CREATE TABLE IF NOT EXISTS {$this->getTableName('aks')} (
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(50) NULL,
`teilnehmer` TEXT NULL,
@ -48,7 +48,7 @@ SQL_EOF;
$this->query($sql);
$sql = <<<SQL_EOF
CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/alliance')} (
CREATE TABLE IF NOT EXISTS {$this->getTableName('alliance')} (
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`ally_name` VARCHAR(32) NOT NULL,
`ally_tag` VARCHAR(8) NOT NULL,
@ -71,7 +71,7 @@ SQL_EOF;
$this->query($sql);
$sql = <<<SQL_EOF
CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/annonce')} (
CREATE TABLE IF NOT EXISTS {$this->getTableName('annonce')} (
`id` SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
`user` TEXT NOT NULL,
`galaxie` TINYINT UNSIGNED NOT NULL,
@ -89,7 +89,7 @@ SQL_EOF;
$this->query($sql);
$sql = <<<SQL_EOF
CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/banned')} (
CREATE TABLE IF NOT EXISTS {$this->getTableName('banned')} (
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`who` BIGINT UNSIGNED NOT NULL,
`theme` TEXT NOT NULL,
@ -105,7 +105,7 @@ SQL_EOF;
$this->query($sql);
$sql = <<<SQL_EOF
CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/buddy')} (
CREATE TABLE IF NOT EXISTS {$this->getTableName('buddy')} (
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`sender` BIGINT UNSIGNED NOT NULL,
`owner` BIGINT UNSIGNED NOT NULL,
@ -118,7 +118,7 @@ SQL_EOF;
$this->query($sql);
$sql = <<<SQL_EOF
CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/chat')} (
CREATE TABLE IF NOT EXISTS {$this->getTableName('chat')} (
`messageid` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`user` VARCHAR(255) NOT NULL,
`message` TEXT NOT NULL,
@ -130,7 +130,7 @@ SQL_EOF;
$this->query($sql);
$sql = <<<SQL_EOF
CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/config')} (
CREATE TABLE IF NOT EXISTS {$this->getTableName('config')} (
`config_name` VARCHAR(64) NOT NULL,
`config_value` TEXT NOT NULL,
UNIQUE KEY (`config_name`)
@ -140,32 +140,40 @@ SQL_EOF;
$this->query($sql);
$sql = <<<SQL_EOF
INSERT INTO {$this->getTableName('legacies/config')} (`config_name`, `config_value`) VALUES
INSERT IGNORE INTO {$this->getTableName('config')} (`config_name`, `config_value`) VALUES
-- ('game/1/resource/income/base/metal', '20'),
-- ('game/1/resource/income/base/cristal', '10'),
-- ('game/1/resource/income/base/deuterium', '0'),
-- ('game/1/resource/income/base/energy', '0'),
-- ('game/1/resource/multiplier', '1000'),
-- ('game/1/speed/general', '2500'),
-- ('game/1/speed/fleet', '2500'),
('game_speed', '2500'),
('fleet_speed', '2500'),
('resource_multiplier', '1000'),
('Fleet_Cdr', '30'),
('Defs_Cdr', '30'),
('initial_fields', '5000'),
('COOKIE_NAME', 'xnova-legacies'),
('game_name', 'Wootook:Legacies'),
('game_disable', '1'),
('close_reason', 'Le jeu est clos pour le moment!'),
('metal_basic_income', '20'),
('cristal_basic_income', '10'),
('deuterium_basic_income', '0'),
('energy_basic_income', '0'),
('Fleet_Cdr', '30'),
('Defs_Cdr', '30'),
('initial_fields', '5000'),
('COOKIE_NAME', 'wootook'),
('game_name', 'Wootook'),
('game_disable', '1'),
('close_reason', 'Le jeu est clos pour le moment!'),
('BuildLabWhileRun', '0'),
('LastSettedGalaxyPos', '1'),
('LastSettedSystemPos', '1'),
('LastSettedPlanetPos', '1'),
('urlaubs_modus_erz', '1'),
('noobprotection', '1'),
('noobprotectiontime', '5000'),
('noobprotectionmulti', '5'),
('forum_url', 'http://board.xnova-ng.org/'),
('OverviewNewsFrame', '1'),
('OverviewNewsTEXT', 'Bienvenue sur le nouveau serveur Wootook Legacies'),
('OverviewNewsTEXT', 'Bienvenue sur le nouveau serveur Wootook'),
('OverviewExternChat', '0'),
('OverviewExternChatCmd', ''),
('OverviewBanner', '0'),
@ -182,18 +190,17 @@ INSERT INTO {$this->getTableName('legacies/config')} (`config_name`, `config_val
('enable_marchand', '1'),
('enable_notes', '1'),
('bot_name', 'XNoviana Reali'),
('bot_adress', 'xnova@xnova.fr'),
('bot_adress', 'contact@wootook.org'),
('banner_source_post', '../images/bann.png'),
('ban_duration', '30'),
('enable_bot', '0'),
('enable_bbcode', '1'),
('debug', '0');
('enable_bbcode', '1');
SQL_EOF;
$this->query($sql);
$sql = <<<SQL_EOF
CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/declared')} (
CREATE TABLE IF NOT EXISTS {$this->getTableName('declared')} (
`declarator` TEXT NOT NULL,
`declared_1` TEXT NOT NULL,
`declared_2` TEXT NOT NULL,
@ -206,7 +213,7 @@ SQL_EOF;
$this->query($sql);
$sql = <<<SQL_EOF
CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/errors')} (
CREATE TABLE IF NOT EXISTS {$this->getTableName('errors')} (
`error_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`error_sender` VARCHAR(32) NOT NULL,
`error_time` TIMESTAMP NOT NULL,
@ -219,7 +226,7 @@ SQL_EOF;
$this->query($sql);
$sql = <<<SQL_EOF
CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/fleets')} (
CREATE TABLE IF NOT EXISTS {$this->getTableName('fleets')} (
`fleet_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`fleet_owner` BIGINT UNSIGNED NOT NULL,
`fleet_mission` TINYINT UNSIGNED NOT NULL,
@ -251,7 +258,7 @@ SQL_EOF;
$this->query($sql);
$sql = <<<SQL_EOF
CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/galaxy')} (
CREATE TABLE IF NOT EXISTS {$this->getTableName('galaxy')} (
`galaxy` TINYINT UNSIGNED NOT NULL,
`system` SMALLINT UNSIGNED NOT NULL,
`planet` TINYINT UNSIGNED NOT NULL,
@ -270,7 +277,7 @@ SQL_EOF;
$this->query($sql);
$sql = <<<SQL_EOF
CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/iraks')} (
CREATE TABLE IF NOT EXISTS {$this->getTableName('iraks')} (
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`zeit` TIMESTAMP NOT NULL,
`galaxy` TINYINT UNSIGNED NOT NULL,
@ -290,7 +297,7 @@ SQL_EOF;
$this->query($sql);
$sql = <<<SQL_EOF
CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/lunas')} (
CREATE TABLE IF NOT EXISTS {$this->getTableName('lunas')} (
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`id_luna` BIGINT UNSIGNED NOT NULL,
`name` VARCHAR(100) NOT NULL DEFAULT 'Lune',
@ -310,7 +317,7 @@ SQL_EOF;
$this->query($sql);
$sql = <<<SQL_EOF
CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/messages')} (
CREATE TABLE IF NOT EXISTS {$this->getTableName('messages')} (
`message_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`message_owner` BIGINT UNSIGNED NOT NULL,
`message_sender` BIGINT UNSIGNED NOT NULL,
@ -326,7 +333,7 @@ SQL_EOF;
$this->query($sql);
$sql = <<<SQL_EOF
CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/multi')} (
CREATE TABLE IF NOT EXISTS {$this->getTableName('multi')} (
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`player` BIGINT UNSIGNED NOT NULL,
`sharer` BIGINT UNSIGNED NOT NULL,
@ -338,7 +345,7 @@ SQL_EOF;
$this->query($sql);
$sql = <<<SQL_EOF
CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/notes')} (
CREATE TABLE IF NOT EXISTS {$this->getTableName('notes')} (
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`owner` BIGINT UNSIGNED NOT NULL,
`time` TIMESTAMP NOT NULL,
@ -352,7 +359,7 @@ SQL_EOF;
$this->query($sql);
$sql = <<<SQL_EOF
CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/planets')} (
CREATE TABLE IF NOT EXISTS {$this->getTableName('planets')} (
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(100) NOT NULL,
`id_owner` BIGINT UNSIGNED NOT NULL,
@ -445,7 +452,7 @@ SQL_EOF;
$this->query($sql);
$sql = <<<SQL_EOF
CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/rw')} (
CREATE TABLE IF NOT EXISTS {$this->getTableName('rw')} (
`id_owner1` BIGINT UNSIGNED NOT NULL,
`id_owner2` BIGINT UNSIGNED NOT NULL,
`rid` VARCHAR(72) NOT NULL,
@ -461,7 +468,7 @@ SQL_EOF;
$this->query($sql);
$sql = <<<SQL_EOF
CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/statpoints')} (
CREATE TABLE IF NOT EXISTS {$this->getTableName('statpoints')} (
`id_owner` BIGINT UNSIGNED NOT NULL,
`id_ally` BIGINT UNSIGNED NOT NULL,
`stat_type` TINYINT UNSIGNED NOT NULL,
@ -498,7 +505,7 @@ SQL_EOF;
$this->query($sql);
$sql = <<<SQL_EOF
CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/users')} (
CREATE TABLE IF NOT EXISTS {$this->getTableName('users')} (
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`username` VARCHAR(100) NOT NULL, -- FIXME
`password` VARCHAR(64) NOT NULL, -- FIXME

View file

@ -287,20 +287,22 @@ class Wootook
self::$_response = $response;
}
private static function _loadConfig()
public static function loadConfig()
{
if (self::$_config === null) {
self::$_config = include ROOT_PATH . DIRECTORY_SEPARATOR . 'config.php';
self::$_config = include ROOT_PATH . DIRECTORY_SEPARATOR . 'config.php';
if (!is_array(self::$_config)) {
self::$_config = array();
}
if (!is_array(self::$_config)) {
self::$_config = array();
}
return self::$_config;
}
public static function getConfig($path = null)
{
self::_loadConfig();
if (self::$_config === null) {
self::loadConfig();
}
if ($path === null || !is_string($path)) {
return self::$_config;
@ -317,7 +319,9 @@ class Wootook
public static function setConfig($path, $value)
{
self::_loadConfig();
if (self::$_config === null) {
self::loadConfig();
}
if ($path === null || !is_string($path)) {
return self::$_config = $value;
@ -338,6 +342,8 @@ class Wootook
{
file_put_contents(ROOT_PATH . DIRECTORY_SEPARATOR . 'config.php',
'<' . '?p' . 'hp ' . var_export($config, true) . ';');
self::$_config = $config;
}
public static function getBaseUrl()

View file

@ -0,0 +1,7 @@
<?php
class Wootook_Core_Setup_Exception_RuntimeException
extends Wootook_Core_Exception_RuntimeException
implements Wootook_Core_Exception
{
}

View file

@ -0,0 +1,7 @@
<?php
class Wootook_Core_Setup_Exception_VersionStageError
extends Wootook_Core_Setup_Exception_RuntimeException
implements Wootook_Core_Exception
{
}

View file

@ -0,0 +1,7 @@
<?php
class Wootook_Core_Setup_Exception_VersionValueError
extends Wootook_Core_Setup_Exception_RuntimeException
implements Wootook_Core_Exception
{
}

View file

@ -29,14 +29,28 @@ class Wootook_Core_Setup_Updater
public function getSetupConnection()
{
if ($this->_setupConnection === null) {
return Wootook_Database::getSingleton();
$this->setSetupConnection('default');
}
return $this->_setupConnection;
}
public function getTable($tableName)
public function getTableName($tableName)
{
$this->getSetupConnection()->getTable($tableName);
return $this->getSetupConnection()->getTable($tableName);
}
public function query($statement)
{
try {
if (!$this->getSetupConnection()->query($statement)) {
$info = $this->getSetupConnection()->errorInfo();
throw new Wootook_Core_Setup_Exception_RuntimeException(
Wootook::__('Query failed: SQLSTATE %s: %s.', $info[1], $info[2]));
}
} catch (PDOException $e) {
Wootook_Core_ErrorProfiler::getSingleton()->exceptionManager($e);
throw new Wootook_Core_Setup_Exception_RuntimeException($e->getMessage(), null, $e);
}
}
public function grant($tableName, $connectionName, $perms = null)

View file

@ -1,6 +1,6 @@
<?php
class Wootook_Core_Setup_Model_Updater_ScriptQueue
class Wootook_Core_Setup_Updater_ScriptQueue
implements Iterator, Countable, ArrayAccess
{
const PCRE_FILE_PATTERN = '%^(?<action>install|upgrade|uninstall|downgrade)-(?<version1>[0-9]+\.[0-9]+\.[0-9]+)(?:\.(?<stage1>[a-z]+)(?<level1>[0-9]+))?(?:-(?<version2>[0-9]+\.[0-9]+\.[0-9]+)(?:\.(?<stage2>[a-z]+)(?<level2>[0-9]+))?)?$%';
@ -36,27 +36,35 @@ class Wootook_Core_Setup_Model_Updater_ScriptQueue
}
if ($fromVersion === null) {
$fromVersion = '0.0.0';
$fromVersion = array(
'version' => self::VERSION_NULL,
'stage' => self::STAGE_STABLE,
'level' => 0,
);
} else {
preg_match(self::PCRE_VERSION_PATTERN, $fromVersion, $matches);
$fromVersion = array(
'version' => isset($matches['version']) ? $matches['version'] : self::VERSION_NULL,
'stage' => isset($matches['stage']) && !empty($matches['stage']) ? $matches['stage'] : self::STAGE_STABLE,
'level' => isset($matches['level']) && !empty($matches['level']) ? (int) $matches['level'] : 0,
);
}
if ($toVersion === null) {
$toVersion = '0.0.0';
$toVersion = array(
'version' => self::VERSION_NULL,
'stage' => self::STAGE_STABLE,
'level' => 0,
);
} else {
preg_match(self::PCRE_VERSION_PATTERN, $toVersion, $matches);
$toVersion = array(
'version' => isset($matches['version']) ? $matches['version'] : self::VERSION_NULL,
'stage' => isset($matches['stage']) && !empty($matches['stage']) ? $matches['stage'] : self::STAGE_STABLE,
'level' => isset($matches['level']) && !empty($matches['level']) ? (int) $matches['level'] : 0,
);
}
preg_match(self::PCRE_VERSION_PATTERN, $fromVersion, $matches);
$fromVersion = array(
'version' => isset($matches['version']) ? $matches['version'] : self::VERSION_NULL,
'stage' => isset($matches['stage']) && !empty($matches['stage']) ? $matches['stage'] : self::STAGE_STABLE,
'level' => isset($matches['level']) && !empty($matches['level']) ? (int) $matches['level'] : 0,
);
preg_match(self::PCRE_VERSION_PATTERN, $toVersion, $matches);
$toVersion = array(
'version' => isset($matches['version']) ? $matches['version'] : self::VERSION_NULL,
'stage' => isset($matches['stage']) && !empty($matches['stage']) ? $matches['stage'] : self::STAGE_STABLE,
'level' => isset($matches['level']) && !empty($matches['level']) ? (int) $matches['level'] : 0,
);
switch (version_compare($toVersion['version'], $fromVersion['version'])) {
case 1:
$this->_upgradeToVersion($fromVersion, $toVersion);
@ -110,7 +118,7 @@ class Wootook_Core_Setup_Model_Updater_ScriptQueue
$this->_upgradeToVersion($fromVersion, $toVersion);
}
} else {
throw new Wootook_Core_Exception_RuntimeException("Invalid version stage.");
throw new Wootook_Core_Setup_Exception_VersionStageError("Invalid version stage.");
}
break;
}
@ -123,6 +131,13 @@ class Wootook_Core_Setup_Model_Updater_ScriptQueue
return $this->_finalVersion;
}
public function getCurrentVersion()
{
$current = $this->current();
return $current['version'];
}
protected function _installHighestInstaller($currentVersion, $toVersion)
{
$highestVersion = self::VERSION_NULL;
@ -143,14 +158,16 @@ class Wootook_Core_Setup_Model_Updater_ScriptQueue
return $version;
}
if (isset($this->_installVersions[$highestVersion][self::STAGE_RC])) {
if (isset($this->_installVersions[$highestVersion][self::STAGE_STABLE])) {
$stage = self::STAGE_STABLE;
} else if (isset($this->_installVersions[$highestVersion][self::STAGE_RC])) {
$stage = self::STAGE_RC;
} else if (isset($this->_installVersions[$highestVersion][self::STAGE_BETA])) {
$stage = self::STAGE_BETA;
} else if (isset($this->_installVersions[$highestVersion][self::STAGE_ALPHA])) {
$stage = self::STAGE_ALPHA;
} else {
throw new Wootook_Core_Exception_RuntimeException("Invalid version stage.");
throw new Wootook_Core_Setup_Exception_VersionStageError("Invalid version stage.");
}
$levelList = array_keys($this->_installVersions[$highestVersion][$stage]);
@ -232,7 +249,7 @@ class Wootook_Core_Setup_Model_Updater_ScriptQueue
$level = max(array_keys($versionPointer[$highestVersion][$stage]));
} else {
throw new Wootook_Core_Exception_RuntimeException("Invalid version value.");
throw new Wootook_Core_Setup_Exception_VersionValueError("Invalid version value.");
}
$currentVersion = array(

View file

@ -9,6 +9,9 @@ class Wootook_Database
protected static $_connectionAliases = array();
protected $_tablePrefix = null;
protected $_dsn = null;
protected $_username = null;
protected $_password = null;
public static $options = array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
@ -51,8 +54,9 @@ class Wootook_Database
return null;
}
if (!($port = Wootook::getConfig("global/database/{$connectionName}/params/port")) || !is_numeric($port)) {
$port = 3306;
$dsn = "mysql:dbname={$database};host={$hostname}";
if (($port = Wootook::getConfig("global/database/{$connectionName}/params/port")) && is_numeric($port)) {
$dsn .= ";port={$port}";
}
$event = Wootook::dispatchEvent('database.prepare-options', array(
@ -62,7 +66,10 @@ class Wootook_Database
$options = $event->getData('options');
$connection = new self("mysql:dbname={$database};host={$hostname};port={$port}", $username, $password, $options);
$connection = new self($dsn, $username, $password, $options);
$connection->_dsn = $dsn;
$connection->_username = $username;
$connection->_password = $password;
if (($prefix = Wootook::getConfig("global/database/{$connectionName}/table_prefix")) !== null) {
$connection->setTablePrefix($prefix);

View file

@ -0,0 +1,65 @@
<?php $session = Wootook::getSession('install')?>
<div class="install">
<h1><?php echo $this->__('Welcome to the Wootook! installer')?></h1>
<h2><?php echo $this->__('Database Config')?></h2>
<?php echo $this->getLayout()->getMessagesblock()->renderGroupedHtml()?>
<form method="post" action="?mode=install&step=2" id="form:database">
<input type="hidden" id="form_key" name="__formkey" value="<?php echo $session->getFormKey()?>" />
<p>
<label for="datbase:host"><?php echo $this->__('Database host address:')?></label>
<input type="text" id="datbase:host" name="host" value="<?php echo $this->escape($session->getFormData('host', 'localhost'))?>" />
</p>
<p>
<label for="datbase:port"><?php echo $this->__('Database host port:')?></label>
<input type="text" id="datbase:port" name="port" value="<?php echo $this->escape($session->getFormData('port', '3306'))?>" />
</p>
<p>
<label for="datbase:user"><?php echo $this->__('Database account name:')?></label>
<input type="text" id="datbase:user" name="user" value="<?php echo $this->escape($session->getFormData('user', 'u_wootook'))?>" />
</p>
<p>
<label for="datbase:password"><?php echo $this->__('Database account password:')?></label>
<input type="text" id="datbase:password" name="password" value="<?php echo $this->escape($session->getFormData('password', ''))?>" />
</p>
<p>
<label for="datbase:dbname"><?php echo $this->__('Database name:')?></label>
<input type="text" id="datbase:dbname" name="dbname" value="<?php echo $this->escape($session->getFormData('dbname', 'db_wootook'))?>" />
</p>
<p>
<label for="datbase:prefix"><?php echo $this->__('Table name prefix:')?></label>
<input type="text" id="datbase:prefix" name="prefix" value="<?php echo $this->escape($session->getFormData('prefix', 'wtk_'))?>" />
</p>
<p>
<input type="button" id="test" value="<?php echo $this->__('Test connection')?>" />
<input type="submit" value="<?php echo $this->__('Next step')?>" />
</p>
<div id="install_messages"></div>
</form>
</div>
<script type="text/javascript">
/*<![CDATA[*/
//<!--
(function($){
$('#test').click(function(e){
var formData = $('#form\\:database').serializeArray();
formData.push({name: 'test', value: 1});
$.ajax('?mode=install&step=2', {
data: formData,
type: 'post',
success: function(data){
if (!data.status) {
$('#install_messages').html('<?php echo $this->escapeJs($this->__('Ajax failure.'))?>');
} else if (data.status == 'success') {
$('#install_messages').html('<?php echo $this->escapeJs($this->__('Connection succeeded.'))?>');
} else if (data.status == 'error' && data.message) {
$('#install_messages').html('<?php echo $this->escapeJs($this->__('Connection error: '))?>' + data.message);
} else {
$('#install_messages').html('<?php echo $this->escapeJs($this->__('Ajax failure.'))?>');
}
}});
});
})(jQuery);
//-->
/*]]>*/
</script>

View file

@ -0,0 +1,30 @@
<?php $session = Wootook::getSession('install')?>
<div class="install">
<h1><?php echo $this->__('Welcome to the Wootook! installer')?></h1>
<h2><?php echo $this->__('Admin Profile Config')?></h2>
<?php echo $this->getLayout()->getMessagesblock()->renderGroupedHtml()?>
<form method="post" action="?mode=install&step=3" id="form:database">
<input type="hidden" id="form_key" name="__formkey" value="<?php echo $session->getFormKey()?>" />
<p>
<label for="account:username"><?php echo $this->__('Root admin account name:')?></label>
<input type="text" id="account:username" name="username" value="<?php echo $this->escape($session->getFormData('username', 'admin'))?>" />
</p>
<p>
<label for="account:email"><?php echo $this->__('Root admin email:')?></label>
<input type="text" id="account:email" name="email" value="<?php echo $this->escape($session->getFormData('email'))?>" />
</p>
<p>
<label for="account:email_confirm"><?php echo $this->__('Root admin email:')?></label>
<input type="text" id="account:email_confirm" name="email_confirm" value="<?php echo $this->escape($session->getFormData('email_confirm'))?>" />
</p>
<p>
<label for="account:password"><?php echo $this->__('Root admin account password:')?></label>
<input type="password" id="account:password" name="password" value="<?php echo $this->escape($session->getFormData('password'))?>" />
</p>
<p>
<label for="account:password_confirm"><?php echo $this->__('Root admin account password confirm:')?></label>
<input type="password" id="account:password_confirm" name="password_confirm" value="<?php echo $this->escape($session->getFormData('password_confirm'))?>" />
</p>
<p><input type="submit" value="<?php echo $this->__('Next step')?>" /></p>
</form>
</div>

View file

@ -7,7 +7,7 @@
<input type="hidden" id="form_key" name="__formkey" value="<?php echo $session->getFormKey()?>" />
<p>
<label for="system:url_path"><?php echo $this->__('Base URL path for the game:')?></label>
<input type="text" id="system:url_path" name="url_path" value="<?php echo $session->getFormData('url_path', Wootook::getBaseUrl())?>" />
<input type="text" id="system:url_path" name="url_path" value="<?php echo $this->escape($session->getFormData('url_path', Wootook::getBaseUrl()))?>" />
</p>
<p>
<label for="system:timezone"><?php echo $this->__('Game timezone:')?></label>

View file

@ -0,0 +1,37 @@
<?php $session = Wootook::getSession('install')?>
<div class="install">
<h1><?php echo $this->__('Welcome to the Wootook! installer')?></h1>
<h2><?php echo $this->__('Universe Config')?></h2>
<?php echo $this->getLayout()->getMessagesblock()->renderGroupedHtml()?>
<form method="post" action="?mode=install&step=3" id="form:database">
<input type="hidden" id="form_key" name="__formkey" value="<?php echo $session->getFormKey()?>" />
<p>
<label for="universe:galaxies"><?php echo $this->__('Galaxies count:')?></label>
<input type="text" id="universe:galaxies" name="galaxies" value="<?php echo $this->escape($session->getFormData('galaxies', 3))?>" />
</p>
<p>
<label for="universe:systems"><?php echo $this->__('Systems count:')?></label>
<input type="text" id="universe:systems" name="systems" value="<?php echo $this->escape($session->getFormData('systems', 100))?>" />
</p>
<p>
<label for="universe:positions"><?php echo $this->__('Positions in each system:')?></label>
<input type="text" id="universe:positions" name="positions" value="<?php echo $this->escape($session->getFormData('positions', 15))?>" />
</p>
<p>
<label for="universe:allow_spy_drone_attacks"><?php echo $this->__('Allow spy drone attacks')?></label>
<input type="checkbox" id="universe:allow_spy_drone_attacks" <?php if ($session->getFormData('allow_spy_drone_attacks', true)):?>checked="checked" <?php endif?>name="allow_spy_drone_attacks" value="1" />
</p>
<p>
<label for="universe:use_large_numbers"><?php echo $this->__('Activate large numbers handling')?></label>
<?php if (extension_loaded('bcmath')):?>
<input type="checkbox" id="universe:use_large_numbers" <?php if ($session->getFormData('use_large_numbers', true)):?>checked="checked" <?php endif?>name="use_large_numbers" value="1" />
<?php else:?>
<input type="checkbox" id="universe:use_large_numbers" <?php if ($session->getFormData('use_large_numbers', false)):?>checked="checked" <?php endif?>name="use_large_numbers" value="1" />
<span class="alert"><?php echo $this->__("'BC Math' extension is unavailable. This option will have no effect until the extension isn't active.")?></span>
<?php endif?>
</p>
<p>
<input type="submit" value="<?php echo $this->__('Next step')?>" />
</p>
</form>
</div>

View file

@ -0,0 +1,82 @@
<?php array (
'global' =>
array (
'storyline' =>
array (
'universe' => 'legacies',
'episode' => 'default',
),
'web' =>
array (
'base_url' => 'http://localhost/projects/wootook-1.5/',
),
'date' =>
array (
'timezone' => 'Europe/Paris',
),
'layout' =>
array (
'page' => 'page.php',
'admin' => 'admin.php',
'empire' => 'empire.php',
),
'locales' =>
array (
'fr' => 'fr_FR',
'fr_FR' => 'fr_FR',
'en' => 'en_US',
'en_US' => 'en_US',
),
'database' =>
array (
'default' =>
array (
'engine' => 'mysql',
'options' =>
array (
),
'params' =>
array (
'hostname' => 'localhost',
'username' => 'root',
'password' => '%J4mzdo69$',
'database' => 'db_xnova',
'port' => '3306',
),
'table_prefix' => 'wtk_',
),
'core_setup' =>
array (
'use' => 'default',
),
'core_read' =>
array (
'use' => 'default',
),
'core_write' =>
array (
'use' => 'default',
),
),
),
'default' =>
array (
'engine' =>
array (
'core' =>
array (
'use_large_numbers' => false,
),
'universe' =>
array (
'galaxies' => NULL,
'systems' => NULL,
'positions' => NULL,
),
'combat' =>
array (
'allow_spy_drone_attacks' => false,
),
),
),
);

26
install/gameplays.php Normal file
View file

@ -0,0 +1,26 @@
<?php return array(
'legacies' => array(
'label' => 'Legacies',
'description' => "Conquer planets and grow your outer space empire, fight against other space emperors and master the outer space.",
'modules' => array(
'Wootook_Core' => array(
'code_pool' => 'core',
'version' => '1.5.0'
),
'Wootook_Empire' => array(
'code_pool' => 'core',
'version' => '1.5.0'
),
'Legacies_Empire' => array(
'code_pool' => 'core',
'version' => '1.5.0'
),
/*
'Legacies_Officers' => array(
'code_pool' => 'core',
'version' => '1.5.0'
),
*/
)
)
);

View file

@ -38,16 +38,20 @@ define('STEP_UNIVERSE', 3);
define('STEP_PROFILE', 4);
define('STEP_CONFIG', 5);
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
//include(ROOT_PATH . 'includes/databaseinfos.php');
//include(ROOT_PATH . 'includes/migrateinfo.php');
require_once dirname(dirname(__FILE__)) . '/application/bootstrap.php';
$mode = isset($_GET['mode']) ? strval($_GET['mode']) : 'intro';
$step = isset($_GET['step']) ? intval($_GET['step']) : 1;
$prevStep = $step - 1;
$nextStep = $step + 1;
$modules = array(
'Wootook_Core',
'Wootook_Empire',
'Legacies_Empire',
'Legacies_Officers'
);
includeLang('install/install');
$baseUrl = (isset($_SERVER["HTTPS"]) && strtolower($_SERVER["HTTPS"]) == "on" ? 'https://' : 'http://')
@ -59,14 +63,17 @@ if (isset($_SERVER['REQUEST_URI'])) {
$baseUrl .= dirname(dirname($_SERVER['REQUEST_URI'])) . '/';
}
}
Wootook::setConfig('global/web/base_url', $baseUrl);
Wootook::setConfig('global/package', 'install');
Wootook::setConfig('global/theme', 'default');
Wootook::setconfig('global/layout', array(
'page' => 'page.php',
'install' => 'install.php'
));
if (count(Wootook::getConfig()) == 0) {
Wootook::setConfig('global/web/base_url', $baseUrl);
Wootook::setConfig('global/package', 'install');
Wootook::setConfig('global/theme', 'default');
Wootook::setconfig('global/layout', array(
'page' => 'page.php',
'install' => 'install.php'
));
}
$session = Wootook::getSession('install');
$layout = new Wootook_Core_Layout();
@ -75,6 +82,7 @@ $response = new Wootook_Core_Controller_Response_Http();
switch ($mode) {
case 'intro':
$layout->getMessagesBlock()->prepareMessages('install');
$layout->load('install.intro');
$session->setData('step', 1);
break;
@ -132,6 +140,7 @@ case 'install':
)
),
);
$session->setData('config', serialize($config));
Wootook::writeConfig($config);
@ -141,10 +150,21 @@ case 'install':
exit(0);
}
$layout->getMessagesBlock()->prepareMessages('install');
$layout->load('install.step.system');
break;
case STEP_DATABASE:
$config = unserialize($session->getData('config'));
$session->setFormData(array(
'host' => $config['global']['database']['default']['params']['hostname'],
'port' => $config['global']['database']['default']['params']['port'],
'user' => $config['global']['database']['default']['params']['username'],
'password' => $config['global']['database']['default']['params']['password'],
'dbname' => $config['global']['database']['default']['params']['database'],
'prefix' => $config['global']['database']['default']['table_prefix'],
));
if ($request->isPost()) {
$form = new Wootook_Core_Form($session, array(
'host' => 'text',
@ -196,9 +216,9 @@ case 'install':
$layout->getMessagesblock()->prepareMessages('install');
$config = Wootook::getConfig();
$config['database'] = array(
'core_setup' => array(
$config = unserialize($session->getData('config'));
$config['global']['database'] = array(
'default' => array(
'engine' => 'mysql',
'options' => array(
),
@ -211,35 +231,17 @@ case 'install':
),
'table_prefix' => $request->getPost('prefix'),
),
'core_setup' => array(
'use' => 'default'
),
'core_read' => array(
'engine' => 'mysql',
'options' => array(
),
'params' => array(
'hostname' => $request->getPost('host'),
'username' => $request->getPost('user'),
'password' => $request->getPost('password'),
'database' => $request->getPost('dbname'),
'port' => $request->getPost('port')
),
'table_prefix' => $request->getPost('prefix'),
'use' => 'default'
),
'core_write' => array(
'engine' => 'mysql',
'options' => array(
),
'params' => array(
'hostname' => $request->getPost('host'),
'username' => $request->getPost('user'),
'password' => $request->getPost('password'),
'database' => $request->getPost('dbname'),
'port' => $request->getPost('port')
),
'table_prefix' => $request->getPost('prefix'),
'use' => 'default'
),
);
Wootook::writeConfig($config);
$session->setData('config', serialize($config));
$session->setData('step', STEP_UNIVERSE);
$response->setRedirect(Wootook::getUrl('install/index.php', array('mode' => 'install', 'step' => STEP_UNIVERSE)));
@ -247,6 +249,7 @@ case 'install':
exit(0);
}
$layout->getMessagesBlock()->prepareMessages('install');
$layout->load('install.step.database');
break;
@ -271,7 +274,7 @@ case 'install':
exit(0);
}
$config = Wootook::getConfig();
$config = unserialize($session->getData('config'));
$config['default'] = array(
'engine' => array(
'core' => array(
@ -287,30 +290,56 @@ case 'install':
)
),
);
Wootook::writeConfig($config);
$scriptPath = APPLICATION_PATH . 'code' . DIRECTORY_SEPARATOR . 'core'
. 'Wootook' . DIRECTORY_SEPARATOR . 'Core' . DIRECTORY_SEPARATOR
. 'install' . DIRECTORY_SEPARATOR . 'mysql5';
$queue = new Wootook_Core_Setup_Model_Updater_ScriptQueue($scriptPath);
try {
$updater = new Wootook_Core_Setup_Model_Updater();
foreach ($queue as $installScript) {
$updater->run($installScript);
}
} catch (Exception $e) {
$session->addSuccess(Wootook::__('An error occured durong game data initialization.'));
$session->setData('step', STEP_SYSTEM);
$response->setRedirect(Wootook::getUrl('install/index.php', array('mode' => 'install', 'step' => STEP_SYSTEM)));
$response->sendHeaders();
exit(0);
$gameplays = include dirname(__FILE__) . DIRECTORY_SEPARATOR . 'gameplays.php';
$gameplayKey = $config['global']['storyline']['universe'];
if (!isset($gameplays[$gameplayKey])) {
$gameplayKey = key($gameplays);
}
$moduleList = $gameplays[$gameplayKey]['modules'];
$installedModules = array();
$updater = new Wootook_Core_Setup_Updater();
foreach ($moduleList as $module => $moduleData) {
$version = $moduleData['version'];
$codePool = $moduleData['code_pool'];
$modulePath = str_replace('_', DIRECTORY_SEPARATOR, $module);
$scriptPath = APPLICATION_PATH . 'code' . DIRECTORY_SEPARATOR . $codePool
. DIRECTORY_SEPARATOR . $modulePath . DIRECTORY_SEPARATOR . 'install'
. DIRECTORY_SEPARATOR . 'mysql5';
try {
$queue = new Wootook_Core_Setup_Updater_ScriptQueue($scriptPath, null, $version);
foreach ($queue as $installScript) {
$updater->run($installScript['script']);
$installedModules[$module] = $installScript['version']['version'];
}
} catch (Wootook_Core_Setup_Exception_VersionStageError $e) {
Wootook_Core_ErrorProfiler::getSingleton()->exceptionManager($e);
continue;
} catch (Wootook_Core_Setup_Exception_VersionValueError $e) {
Wootook_Core_ErrorProfiler::getSingleton()->exceptionManager($e);
continue;
} catch (Wootook_Core_Setup_Exception_RuntimeException $e) {
Wootook_Core_ErrorProfiler::getSingleton()->exceptionManager($e);
continue;
}
}
$path = APPLICATION_PATH . DIRECTORY_SEPARATOR . 'gamedata' . DIRECTORY_SEPARATOR
. $gameplayKey . DIRECTORY_SEPARATOR . 'version.php';
file_put_contents($path, '<' . '?p' . 'hp ' . var_export($installedModules, true) . ';');
$session->addSuccess(Wootook::__('Game data successfully initialized.'));
$session->setData('step', STEP_PROFILE);
$response->setRedirect(Wootook::getUrl('install/index.php', array('mode' => 'install', 'step' => STEP_PROFILE)));
$response->sendHeaders();
exit(0);
}
$layout->getMessagesBlock()->prepareMessages('install');
$layout->load('install.step.universe');
break;
@ -354,12 +383,13 @@ case 'install':
Wootook_Empire_Model_User::register($request->getPost('username'), $request->getPost('email'), $request->getPost('password'));
$session->setData('step', STEP_UNIVERSE);
$response->setRedirect(Wootook::getUrl('install/index.php', array('mode' => 'install', 'step' => STEP_UNIVERSE)));
$session->setData('step', STEP_CONFIG);
$response->setRedirect(Wootook::getUrl('install/index.php', array('mode' => 'install', 'step' => STEP_CONFIG)));
$response->sendHeaders();
exit(0);
}
$layout->getMessagesBlock()->prepareMessages('install');
$layout->load('install.step.profile');
break;
@ -371,6 +401,7 @@ case 'install':
exit(0);
}
$layout->getMessagesBlock()->prepareMessages('install');
$layout->load('install.config');
break;
}

View file

@ -0,0 +1,90 @@
INSERT INTO `game_galaxy` (`galaxy`, `system`, `planet`, `id_planet`, `metal`, `crystal`, `id_luna`, `luna`)
SELECT _increment.galaxy, _increment.system, 0, 0, 0, 0, 0, 0
FROM (
SELECT _galaxy.galaxy, (1 + _10e0.system + _10e1.system + _10e2.system) system
FROM (
SELECT 0 AS system
UNION ALL
SELECT 1 AS system
UNION ALL
SELECT 2 AS system
UNION ALL
SELECT 3 AS system
UNION ALL
SELECT 4 AS system
UNION ALL
SELECT 5 AS system
UNION ALL
SELECT 6 AS system
UNION ALL
SELECT 7 AS system
UNION ALL
SELECT 8 AS system
UNION ALL
SELECT 9 AS system
) _10e0
CROSS JOIN (
SELECT 0 AS system
UNION ALL
SELECT 10 AS system
UNION ALL
SELECT 20 AS system
UNION ALL
SELECT 30 AS system
UNION ALL
SELECT 40 AS system
UNION ALL
SELECT 50 AS system
UNION ALL
SELECT 60 AS system
UNION ALL
SELECT 70 AS system
UNION ALL
SELECT 80 AS system
UNION ALL
SELECT 90 AS system
) _10e1
CROSS JOIN (
SELECT 0 AS system
UNION ALL
SELECT 100 AS system
UNION ALL
SELECT 200 AS system
UNION ALL
SELECT 300 AS system
UNION ALL
SELECT 400 AS system
UNION ALL
SELECT 500 AS system
UNION ALL
SELECT 600 AS system
UNION ALL
SELECT 700 AS system
UNION ALL
SELECT 800 AS system
UNION ALL
SELECT 900 AS system
) _10e2
CROSS JOIN (
SELECT 1 AS galaxy
UNION ALL
SELECT 2 AS galaxy
UNION ALL
SELECT 3 AS galaxy
UNION ALL
SELECT 4 AS galaxy
UNION ALL
SELECT 5 AS galaxy
UNION ALL
SELECT 6 AS galaxy
UNION ALL
SELECT 7 AS galaxy
UNION ALL
SELECT 8 AS galaxy
UNION ALL
SELECT 9 AS galaxy
) _galaxy
) _increment
WHERE _increment.galaxy<=3
AND _increment.system<=100