diff --git a/.gitignore b/.gitignore index 3ca62fc..24b99ed 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,7 @@ config.php .buildpath .project .settings/ +.idea/ coverage/ +src/application/cache/* +src/application/configs/local.php diff --git a/.htaccess b/.htaccess deleted file mode 100644 index 5eb217c..0000000 --- a/.htaccess +++ /dev/null @@ -1,2 +0,0 @@ -SetEnv DEBUG On -SetEnv DEPRECATION Off \ No newline at end of file diff --git a/add_declare.php b/add_declare.php deleted file mode 100644 index c1cc82e..0000000 --- a/add_declare.php +++ /dev/null @@ -1,68 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -define('INSIDE' , true); -define('INSTALL' , false); -require_once dirname(__FILE__) .'/common.php'; - - - includeLang('admin'); - - $mode = $_POST['mode']; - - $PageTpl = gettemplate("add_declare"); - $parse = $lang; - - if ($mode == 'addit') { - $declarator = $user['id']; - $declarator_name = addslashes(htmlspecialchars($user['username'])); - $decl1 = addslashes(htmlspecialchars($_POST['dec1'])); - $decl2 = addslashes(htmlspecialchars($_POST['dec2'])); - $decl3 = addslashes(htmlspecialchars($_POST['dec3'])); - $reason1 = addslashes(htmlspecialchars($_POST['reason'])); - - $QryDeclare = "INSERT INTO {{table}} SET "; - $QryDeclare .= "`declarator` = '". $declarator ."', "; - $QryDeclare .= "`declarator_name` = '". $declarator_name ."', "; $QryDeclare .= "`declared_1` = '". $decl1 ."', "; - $QryDeclare .= "`declared_2` = '". $decl2 ."', "; - $QryDeclare .= "`declared_3` = '". $decl3 ."', "; - $QryDeclare .= "`reason` = '". $reason1 ."' "; - - doquery( $QryDeclare, "declared"); - doquery("UPDATE {{table}} SET multi_validated ='1' WHERE username='{$user['username']}'","users"); - - AdminMessage ( "Merci, votre demande a ete prise en compte. Les autres joueurs que vous avez implique doivent egalement et imperativement suivre cette procedure aussi.", "Ajout" ); - } - $Page = parsetemplate($PageTpl, $parse); - - display ($Page, "Declaration d\'IP partagee", false, '', true); - - -?> \ No newline at end of file diff --git a/admin/activeplanet.php b/admin/activeplanet.php deleted file mode 100644 index 9cd3871..0000000 --- a/admin/activeplanet.php +++ /dev/null @@ -1,66 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -define('INSIDE' , true); -define('INSTALL' , false); -define('IN_ADMIN', true); -require_once dirname(dirname(__FILE__)) .'/common.php'; - - if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) { - includeLang('admin'); - - $parse = $lang; - $parse['dpath'] = $dpath; - $parse['mf'] = $mf; - - $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'] .= ""; - $parse['online_list'] .= "
". $ActivPlanet['name'] ."
"; - $parse['online_list'] .= "
[". $ActivPlanet['galaxy'] .":". $ActivPlanet['system'] .":". $ActivPlanet['planet'] ."]
"; - $parse['online_list'] .= "
". pretty_number($ActivPlanet['points'] / 1000) ."
"; - $parse['online_list'] .= "
". pretty_time(time() - $ActivPlanet['last_update']) . "
"; - $parse['online_list'] .= ""; - $Count++; - } - $parse['online_list'] .= ""; - $parse['online_list'] .= "". $lang['adm_pl_they'] ." ". $Count ." ". $lang['adm_pl_apla'] .""; - $parse['online_list'] .= ""; - - $page = parsetemplate( $PageTPL , $parse ); - display( $page, $lang['adm_pl_title'], false, '', true ); - } else { - message( $lang['sys_noalloaw'], $lang['sys_noaccess'] ); - } - -?> \ No newline at end of file diff --git a/admin/add_fleet.php b/admin/add_fleet.php deleted file mode 100644 index dc03f9c..0000000 --- a/admin/add_fleet.php +++ /dev/null @@ -1,101 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -define('INSIDE' , true); -define('INSTALL' , false); -define('IN_ADMIN', true); -require_once dirname(dirname(__FILE__)) .'/common.php'; - - if ($user['authlevel'] >= 1) { - includeLang('admin/add_fleet'); - $mode = $_GET['mode']; - - 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']; - - } 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']; - - $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); - - } else { - message( $lang['sys_noalloaw'], $lang['sys_noaccess'] ); - } - -?> \ No newline at end of file diff --git a/admin/add_money.php b/admin/add_money.php deleted file mode 100644 index 87beb94..0000000 --- a/admin/add_money.php +++ /dev/null @@ -1,67 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -define('INSIDE' , true); -define('INSTALL' , false); -define('IN_ADMIN', true); -require_once dirname(dirname(__FILE__)) .'/common.php'; - - if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) { - includeLang('admin'); - - $mode = $_POST['mode']; - - $PageTpl = gettemplate("admin/add_money"); - $parse = $lang; - - if ($mode == 'addit') { - $id = $_POST['id']; - $metal = $_POST['metal']; - $cristal = $_POST['cristal']; - $deut = $_POST['deut']; - - $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); - } else { - AdminMessage ( $lang['sys_noalloaw'], $lang['sys_noaccess'] ); - } - -?> \ No newline at end of file diff --git a/admin/mass_message.php b/admin/mass_message.php deleted file mode 100644 index 3d22c76..0000000 --- a/admin/mass_message.php +++ /dev/null @@ -1,66 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -define('INSIDE' , true); -define('INSTALL' , false); -define('IN_ADMIN', true); - -function mass_message_run($parent){ - if($_POST["mode"] == "change"){ - if(isset($_POST["tresc"])&& $_POST["tresc"] != ''){ - $gameConfig['tresc'] = $parent->safe_get_post_var("tresc"); - } - if(isset($_POST["temat"])&& $_POST["temat"] != ''){ - $gameConfig['temat'] = $parent->safe_get_post_var("temat"); - } - $kolor = 'red'; - if($gameConfig['tresc'] !='' and $gameConfig['temat']){ - $sq = $parent->db->query("SELECT `id` FROM {{table}}","users"); - while($u = $parent->db->fetch_assoc($sq)){ - doquery("INSERT INTO {{table}} SET - `message_owner`='{$u['id']}', - `message_sender`='1' , - `message_time`='".time()."', - `message_type`='0', - `message_from`='Administracja', - `message_subject`='{$gameConfig['temat']}', - `message_text`='{$gameConfig['tresc']}' - ","messages"); - $parent->db->query("UPDATE {{table}} SET new_message=new_message+1 WHERE id='{$u['id']}'",'users'); - } - $parent->smarty->assign("message","Wys�a�e� wiadomo�� do wszystkich graczy"); - } - } - $parent->smarty->display("mass_message.tpl"); -} - -function mass_message_info(){ - return array("name" => "Send MassMessages","description"=>"Sends messagess to all players","default_weight"=>"0"); -} \ No newline at end of file diff --git a/admin/messall.php b/admin/messall.php deleted file mode 100644 index a05bb0d..0000000 --- a/admin/messall.php +++ /dev/null @@ -1,75 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -define('INSIDE' , true); -define('INSTALL' , false); -define('IN_ADMIN', true); -require_once dirname(dirname(__FILE__)) .'/common.php'; - - if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR, LEVEL_MODERATOR))) { - if ($_POST && $mode == "change") { - if (isset($_POST["tresc"]) && $_POST["tresc"] != '') { - $gameConfig['tresc'] = $_POST['tresc']; - } - if (isset($_POST["temat"]) && $_POST["temat"] != '') { - $gameConfig['temat'] = $_POST['temat']; - } - if ($user['authlevel'] == LEVEL_ADMIN) { - $kolor = 'red'; - $ranga = 'Administrator'; - } elseif ($user['authlevel'] == LEVEL_OPERATOR) { - $kolor = 'skyblue'; - $ranga = 'Operator'; - } elseif ($user['authlevel'] == LEVEL_MODERATOR) { - $kolor = 'yellow'; - $ranga = 'Moderator'; - } - if ($gameConfig['tresc'] != '' and $gameConfig['temat']) { - $sq = doquery("SELECT `id` FROM {{table}}", "users"); - $Time = time(); - $From = "". $ranga ." ".$user['username'].""; - $Subject = "". $gameConfig['temat'] .""; - $Message = "". $gameConfig['tresc'] .""; - while ($u = $sq->fetch(PDO::FETCH_BOTH)) { - SendSimpleMessage ( $u['id'], $user['id'], $Time, 97, $From, $Subject, $Message); - } - message("Wys�a�e� wiadomo�� do wszystkich graczy", "Complete", "../overview." . PHPEXT, 3); - } - } else { - $parse = $gameConfig; - $parse['dpath'] = $dpath; - $parse['debug'] = ($gameConfig['debug'] == 1) ? " checked='checked'/":''; - $page .= parsetemplate(gettemplate('admin/messall_body'), $parse); - display($page, '', false,'', true); - } - } else { - message($lang['sys_noalloaw'], $lang['sys_noaccess']); - } -?> \ No newline at end of file diff --git a/admin/overview.php b/admin/overview.php deleted file mode 100644 index f89a7ed..0000000 --- a/admin/overview.php +++ /dev/null @@ -1,116 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -define('INSIDE' , true); -define('INSTALL' , false); -define('IN_ADMIN', true); -require_once dirname(dirname(__FILE__)) .'/common.php'; - - if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR, LEVEL_MODERATOR))) { - includeLang('admin'); - - if ($_GET['cmd'] == 'sort') { - $TypeSort = $_GET['type']; - } else { - $TypeSort = "id"; - } - - $PageTPL = gettemplate('admin/overview_body'); - $RowsTPL = gettemplate('admin/overview_rows'); - - $parse = $lang; - $parse['dpath'] = $dpath; - $parse['mf'] = $mf; - $parse['adm_ov_data_yourv'] = colorRed(VERSION); - - $Last15Mins = doquery("SELECT * FROM {{table}} WHERE `onlinetime` >= '". (time() - 15 * 60) ."' ORDER BY `". $TypeSort ."` ASC;", 'users'); - $Count = 0; - $Color = "lime"; - while ( $TheUser = mysql_fetch_array($Last15Mins) ) { - if ($PrevIP != "") { - if ($PrevIP == $TheUser['user_lastip']) { - $Color = "red"; - } else { - $Color = "lime"; - } - } - - $UserPoints = doquery("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '" . $TheUser['id'] . "';", 'statpoints', true); - $Bloc['dpath'] = $dpath; - $Bloc['adm_ov_altpm'] = $lang['adm_ov_altpm']; - $Bloc['adm_ov_wrtpm'] = $lang['adm_ov_wrtpm']; - $Bloc['adm_ov_data_id'] = $TheUser['id']; - $Bloc['adm_ov_data_name'] = $TheUser['username']; - $Bloc['adm_ov_data_agen'] = $TheUser['user_agent']; - $Bloc['current_page'] = $TheUser['current_page']; - $Bloc['usr_s_id'] = $TheUser['id']; - - $Bloc['adm_ov_data_clip'] = $Color; - $Bloc['adm_ov_data_adip'] = $TheUser['user_lastip']; - $Bloc['adm_ov_data_ally'] = $TheUser['ally_name']; - $Bloc['adm_ov_data_point'] = pretty_number ( $UserPoints['total_points'] ); - $Bloc['adm_ov_data_activ'] = pretty_time ( time() - $TheUser['onlinetime'] ); - $Bloc['adm_ov_data_pict'] = "m.gif"; - $PrevIP = $TheUser['user_lastip']; - - //Tweaks vue g�n�rale - $Bloc['usr_email'] = $TheUser['email']; - $Bloc['usr_xp_raid'] = $TheUser['xpraid']; - $Bloc['usr_xp_min'] = $TheUser['xpminier']; - - if ($TheUser['urlaubs_modus'] == 1) { - $Bloc['state_vacancy'] = ""; - } else { - $Bloc['state_vacancy'] = ""; - } - - if ($TheUser['bana'] == 1) { - $Bloc['is_banned'] = ""; - } else { - $Bloc['is_banned'] = $lang['is_banned_lang']; - } - $Bloc['usr_planet_gal'] = $TheUser['galaxy']; - $Bloc['usr_planet_sys'] = $TheUser['system']; - $Bloc['usr_planet_pos'] = $TheUser['planet']; - - - $parse['adm_ov_data_table'] .= parsetemplate( $RowsTPL, $Bloc ); - $Count++; - } - - $parse['adm_ov_data_count'] = $Count; - $Page = parsetemplate($PageTPL, $parse); - - display ( $Page, $lang['sys_overview'], false, '', true); - } else { - AdminMessage ( $lang['sys_noalloaw'], $lang['sys_noaccess'] ); - } - -?> diff --git a/admin/settings.php b/admin/settings.php deleted file mode 100644 index 3c5d441..0000000 --- a/admin/settings.php +++ /dev/null @@ -1,310 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -define('INSIDE' , true); -define('INSTALL' , false); -define('IN_ADMIN', true); -require_once dirname(dirname(__FILE__)) .'/common.php'; - - -function DisplayGameSettingsPage ( $CurrentUser ) { - global $lang, $gameConfig; - - includeLang('admin/settings'); - - if (in_array((int) $CurrentUser['authlevel'], array(LEVEL_ADMIN))) { - if ($_POST['opt_save'] == "1") { - // Jeu Ouvert ou Ferm� ! - if (isset($_POST['closed']) && $_POST['closed'] == 'on') { - $gameConfig['game_disable'] = "1"; - $gameConfig['close_reason'] = addslashes( $_POST['close_reason'] ); - } else { - $gameConfig['game_disable'] = "0"; - $gameConfig['close_reason'] = ""; - } - - // Y a un News Frame ? ! - if (isset($_POST['newsframe']) && $_POST['newsframe'] == 'on') { - $gameConfig['OverviewNewsFrame'] = "1"; - $gameConfig['OverviewNewsText'] = addslashes( $_POST['NewsText'] ); - } else { - $gameConfig['OverviewNewsFrame'] = "0"; - $gameConfig['OverviewNewsText'] = ""; - } - - // Y a un TCHAT externe ?? - if (isset($_POST['chatframe']) && $_POST['chatframe'] == 'on') { - $gameConfig['OverviewExternChat'] = "1"; - $gameConfig['OverviewExternChatCmd'] = addslashes( $_POST['ExternChat'] ); - } else { - $gameConfig['OverviewExternChat'] = "0"; - $gameConfig['OverviewExternChatCmd'] = ""; - } - - if (isset($_POST['googlead']) && $_POST['googlead'] == 'on') { - $gameConfig['OverviewBanner'] = "1"; - $gameConfig['OverviewClickBanner'] = addslashes( $_POST['GoogleAds'] ); - } else { - $gameConfig['OverviewBanner'] = "0"; - $gameConfig['OverviewClickBanner'] = ""; - } - - // Y a un BANNER Frame ? - if (isset($_POST['bannerframe']) && $_POST['bannerframe'] == 'on') { - $gameConfig['ForumBannerFrame'] = "1"; - } else { - $gameConfig['ForumBannerFrame'] = "0"; - } - - // Mode Debug ou pas ! - if (isset($_POST['debug']) && $_POST['debug'] == 'on') { - $gameConfig['debug'] = "1"; - } else { - $gameConfig['debug'] = "0"; - } - - // Nom du Jeu - if (isset($_POST['game_name']) && $_POST['game_name'] != '') { - $gameConfig['game_name'] = $_POST['game_name']; - } - - // Adresse du Forum - if (isset($_POST['forum_url']) && $_POST['forum_url'] != '') { - $gameConfig['forum_url'] = $_POST['forum_url']; - } - - // Vitesse du Jeu - if (isset($_POST['game_speed']) && is_numeric($_POST['game_speed'])) { - $gameConfig['game_speed'] = $_POST['game_speed']; - } - - // Vitesse des Flottes - if (isset($_POST['fleet_speed']) && is_numeric($_POST['fleet_speed'])) { - $gameConfig['fleet_speed'] = $_POST['fleet_speed']; - } - - // Multiplicateur de Production - if (isset($_POST['resource_multiplier']) && is_numeric($_POST['resource_multiplier'])) { - $gameConfig['resource_multiplier'] = $_POST['resource_multiplier']; - } - - // Taille de la planete mère - if (isset($_POST['initial_fields']) && is_numeric($_POST['initial_fields'])) { - $gameConfig['initial_fields'] = $_POST['initial_fields']; - } - - // Revenu de base Metal - if (isset($_POST['metal_basic_income']) && is_numeric($_POST['metal_basic_income'])) { - $gameConfig['metal_basic_income'] = $_POST['metal_basic_income']; - } - - // Revenu de base Cristal - if (isset($_POST['crystal_basic_income']) && is_numeric($_POST['crystal_basic_income'])) { - $gameConfig['crystal_basic_income'] = $_POST['crystal_basic_income']; - } - - // Revenu de base Deuterium - if (isset($_POST['deuterium_basic_income']) && is_numeric($_POST['deuterium_basic_income'])) { - $gameConfig['deuterium_basic_income'] = $_POST['deuterium_basic_income']; - } - - // Revenu de base Energie - if (isset($_POST['energy_basic_income']) && is_numeric($_POST['energy_basic_income'])) { - $gameConfig['energy_basic_income'] = $_POST['energy_basic_income']; - } - - // Lien supplémentaire dans le menu - if (isset($_POST['enable_link_']) && is_numeric($_POST['enable_link_'])) { - $gameConfig['link_enable'] = $_POST['enable_link_']; - } - // Texte de ce lien... -$gameConfig['link_name'] = addslashes( $_POST['name_link_']); - - // URL de ce lien... -$gameConfig['link_url'] = $_POST['url_link_']; - // Image de la bannière -$gameConfig['banner_source_post'] = $_POST['banner_source_post']; - // 1 point = ??? Ressources ? - if (isset($_POST['stat_settings']) && is_numeric($_POST['stat_settings'])) { - $gameConfig['stat_settings'] = $_POST['stat_settings']; - } - // Activation -ou non- des annonces - if (isset($_POST['enable_announces_']) && is_numeric($_POST['enable_announces_'])) { - $gameConfig['enable_announces'] = $_POST['enable_announces_']; - } - // Activation -ou non- du marchand - if (isset($_POST['enable_marchand_']) && is_numeric($_POST['enable_marchand_'])) { - $gameConfig['enable_marchand'] = $_POST['enable_marchand_']; - } - // Activation -ou non- des notes - if (isset($_POST['enable_notes_']) && is_numeric($_POST['enable_notes_'])) { - $gameConfig['enable_notes'] = $_POST['enable_notes_']; - } - // Nom du bot antimulti - $gameConfig['bot_name'] = addslashes( $_POST['name_bot']); - - // email du bot antimulti - $gameConfig['bot_adress'] = addslashes( $_POST['adress_bot']); - - // Activation -ou non- des notes - if (isset($_POST['duration_ban']) && is_numeric($_POST['duration_ban'])) { - $gameConfig['ban_duration'] = $_POST['duration_ban']; - } - - // Activation -ou non- du bot - if (isset($_POST['bot_enable']) && is_numeric($_POST['bot_enable'])) { - $gameConfig['enable_bot'] = $_POST['bot_enable']; - } - - // BBCode ou pas ? - - if (isset($_POST['bbcode_field']) && is_numeric($_POST['bbcode_field'])) { - $gameConfig['enable_bbcode'] = $_POST['bbcode_field']; - } - - // Activation du jeu - doquery("UPDATE {{table}} SET `config_value` = '". $gameConfig['game_disable'] ."' WHERE `config_name` = 'game_disable';", 'config'); - doquery("UPDATE {{table}} SET `config_value` = '". $gameConfig['close_reason'] ."' WHERE `config_name` = 'close_reason';", 'config'); - - //Stats - - doquery("UPDATE {{table}} SET `config_value` = '". $gameConfig['stat_settings'] ."' WHERE `config_name` = 'stat_settings';", 'config'); - - - // Configuration du Jeu - doquery("UPDATE {{table}} SET `config_value` = '". $gameConfig['forum_url'] ."' WHERE `config_name` = 'forum_url';", 'config'); - doquery("UPDATE {{table}} SET `config_value` = '". $gameConfig['game_name'] ."' WHERE `config_name` = 'game_name';", 'config'); - doquery("UPDATE {{table}} SET `config_value` = '". $gameConfig['game_speed'] ."' WHERE `config_name` = 'game_speed';", 'config'); - doquery("UPDATE {{table}} SET `config_value` = '". $gameConfig['fleet_speed'] ."' WHERE `config_name` = 'fleet_speed';", 'config'); - doquery("UPDATE {{table}} SET `config_value` = '". $gameConfig['resource_multiplier'] ."' WHERE `config_name` = 'resource_multiplier';", 'config'); - - // Page Generale - doquery("UPDATE {{table}} SET `config_value` = '". $gameConfig['OverviewNewsFrame'] ."' WHERE `config_name` = 'OverviewNewsFrame';", 'config'); - doquery("UPDATE {{table}} SET `config_value` = '". $gameConfig['OverviewNewsText'] ."' WHERE `config_name` = 'OverviewNewsText';", 'config'); - doquery("UPDATE {{table}} SET `config_value` = '". $gameConfig['OverviewExternChat'] ."' WHERE `config_name` = 'OverviewExternChat';", 'config'); - doquery("UPDATE {{table}} SET `config_value` = '". $gameConfig['OverviewExternChatCmd'] ."' WHERE `config_name` = 'OverviewExternChatCmd';", 'config'); - doquery("UPDATE {{table}} SET `config_value` = '". $gameConfig['OverviewBanner'] ."' WHERE `config_name` = 'OverviewBanner';", 'config'); - doquery("UPDATE {{table}} SET `config_value` = '". $gameConfig['OverviewClickBanner'] ."' WHERE `config_name` = 'OverviewClickBanner';", 'config'); - doquery("UPDATE {{table}} SET `config_value` = '". $gameConfig['ForumBannerFrame'] ."' WHERE `config_name` = 'ForumBannerFrame';", 'config'); - - //Bannière - doquery("UPDATE {{table}} SET `config_value` = '". $gameConfig['banner_source_post'] ."' WHERE `config_name` = 'banner_source_post';", 'config'); - - // Lien supplémentaire dans le menu - doquery("UPDATE {{table}} SET `config_value` = '". $gameConfig['link_enable'] ."' WHERE `config_name` = 'link_enable';", 'config'); - doquery("UPDATE {{table}} SET `config_value` = '". $gameConfig['link_name'] ."' WHERE `config_name` = 'link_name';", 'config'); - doquery("UPDATE {{table}} SET `config_value` = '". $gameConfig['link_url'] ."' WHERE `config_name` = 'link_url';", 'config'); - - // Options Planete - doquery("UPDATE {{table}} SET `config_value` = '". $gameConfig['initial_fields'] ."' WHERE `config_name` = 'initial_fields';", 'config'); - doquery("UPDATE {{table}} SET `config_value` = '". $gameConfig['metal_basic_income'] ."' WHERE `config_name` = 'metal_basic_income';", 'config'); - doquery("UPDATE {{table}} SET `config_value` = '". $gameConfig['crystal_basic_income'] ."' WHERE `config_name` = 'crystal_basic_income';", 'config'); - doquery("UPDATE {{table}} SET `config_value` = '". $gameConfig['deuterium_basic_income'] ."' WHERE `config_name` = 'deuterium_basic_income';", 'config'); - doquery("UPDATE {{table}} SET `config_value` = '". $gameConfig['energy_basic_income'] ."' WHERE `config_name` = 'energy_basic_income';", 'config'); - - //Bot antimulti - doquery("UPDATE {{table}} SET `config_value` = '". $gameConfig['bot_name'] ."' WHERE `config_name` = 'bot_name';", 'config'); - doquery("UPDATE {{table}} SET `config_value` = '". $gameConfig['bot_adress'] ."' WHERE `config_name` = 'bot_adress';", 'config'); - doquery("UPDATE {{table}} SET `config_value` = '". $gameConfig['ban_duration'] ."' WHERE `config_name` = 'ban_duration';", 'config'); - doquery("UPDATE {{table}} SET `config_value` = '". $gameConfig['enable_bot'] ."' WHERE `config_name` = 'enable_bot';", 'config'); - - - //Réglage du BBCode - doquery("UPDATE {{table}} SET `config_value` = '". $gameConfig['enable_bbcode'] ."' WHERE `config_name` = 'enable_bbcode';", 'config'); - - - //Controle des pages - doquery("UPDATE {{table}} SET `config_value` = '". $gameConfig['enable_announces'] ."' WHERE `config_name` = 'enable_announces';", 'config'); - doquery("UPDATE {{table}} SET `config_value` = '". $gameConfig['enable_marchand'] ."' WHERE `config_name` = 'enable_marchand';", 'config'); - doquery("UPDATE {{table}} SET `config_value` = '". $gameConfig['enable_notes'] ."' WHERE `config_name` = 'enable_notes';", 'config'); - - // Mode Debug - doquery("UPDATE {{table}} SET `config_value` = '" .$gameConfig['debug'] ."' WHERE `config_name` ='debug'", 'config'); - AdminMessage ('Options changees avec succes !', 'Succes', '?'); - } else { - - $parse = $lang; - $parse['game_name'] = $gameConfig['game_name']; - $parse['game_speed'] = $gameConfig['game_speed']; - $parse['fleet_speed'] = $gameConfig['fleet_speed']; - $parse['resource_multiplier'] = $gameConfig['resource_multiplier']; - $parse['forum_url'] = $gameConfig['forum_url']; - $parse['initial_fields'] = $gameConfig['initial_fields']; - $parse['metal_basic_income'] = $gameConfig['metal_basic_income']; - $parse['crystal_basic_income'] = $gameConfig['crystal_basic_income']; - $parse['deuterium_basic_income'] = $gameConfig['deuterium_basic_income']; - $parse['energy_basic_income'] = $gameConfig['energy_basic_income']; - $parse['enable_link'] = $gameConfig['link_enable']; - $parse['name_link'] = $gameConfig['link_name']; - $parse['url_link'] = $gameConfig['link_url']; - $parse['enable_announces'] = $gameConfig['enable_announces']; - $parse['enable_marchand'] = $gameConfig['enable_marchand']; - $parse['enable_notes'] = $gameConfig['enable_notes']; - $parse['bot_name'] = stripslashes($gameConfig['bot_name']); - $parse['bot_adress'] = stripslashes($gameConfig['bot_adress']); - $parse['ban_duration'] = stripslashes($gameConfig['ban_duration']); - $parse['enable_bot'] = stripslashes($gameConfig['enable_bot']); - $parse['enable_bbcode'] = stripslashes($gameConfig['enable_bbcode']); - - $parse['banner_source_post'] = $gameConfig['banner_source_post']; - $parse['stat_settings'] = stripslashes($gameConfig['stat_settings']); - - - - $parse['closed'] = ($gameConfig['game_disable'] == 1) ? " checked = 'checked' ":""; - $parse['close_reason'] = stripslashes( $gameConfig['close_reason'] ); - - $parse['newsframe'] = ($gameConfig['OverviewNewsFrame'] == 1) ? " checked = 'checked' ":""; - $parse['NewsTextVal'] = stripslashes( $gameConfig['OverviewNewsText'] ); - - $parse['chatframe'] = ($gameConfig['OverviewExternChat'] == 1) ? " checked = 'checked' ":""; - $parse['ExtTchatVal'] = stripslashes( $gameConfig['OverviewExternChatCmd'] ); - - $parse['googlead'] = ($gameConfig['OverviewBanner'] == 1) ? " checked = 'checked' ":""; - $parse['GoogleAdVal'] = stripslashes( $gameConfig['OverviewClickBanner'] ); - - $parse['debug'] = ($gameConfig['debug'] == 1) ? " checked = 'checked' ":""; - - $parse['bannerframe'] = ($gameConfig['ForumBannerFrame'] == 1) ? " checked = 'checked' ":""; - - $PageTPL = gettemplate('admin/options_body'); - $Page .= parsetemplate( $PageTPL, $parse ); - - display ( $Page, $lang['adm_opt_title'], false, '', true ); - } - } else { - AdminMessage ( $lang['sys_noalloaw'], $lang['sys_noaccess'] ); - } - return $Page; -} - - $Page = DisplayGameSettingsPage ( $user ); - -?> diff --git a/ainfo.php b/ainfo.php deleted file mode 100644 index a1ae4f2..0000000 --- a/ainfo.php +++ /dev/null @@ -1,70 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -define('INSIDE' , true); -define('INSTALL' , false); -require_once dirname(__FILE__) .'/common.php'; - -$dpath = (!$userrow["dpath"]) ? DEFAULT_SKINPATH : $userrow["dpath"]; - - -if(!is_numeric($_GET["a"]) || !$_GET["a"] ){ message("Ungü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); - -if(!$allyrow){ message("Alliance non trouvée","Erreur");} - -$count = doquery("SELECT COUNT(DISTINCT(id)) FROM {{table}} WHERE ally_id=".$_GET["a"].";","users",true); -$ally_member_scount = $count[0]; - -$page .=""; - - if($allyrow["ally_image"] != ""){ - $page .= ""; - } - - $page .= ""; - - if($allyrow["ally_description"] != ""){ - $page .= ""; - } - - - if($allyrow["ally_web"] != ""){ - $page .=" - - - "; - } - $page .= "
Informations sur l'alliance
Tag".$allyrow["ally_tag"]."
Nom".$allyrow["ally_name"]."
Membres$ally_member_scount
".$allyrow["ally_description"]."
Site internet".$allyrow["ally_web"]."
"; - - display($page,"Information sur l'alliance [".$allyrow["ally_name"]."]",false); - -?> \ No newline at end of file diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..fe8adf3 --- /dev/null +++ b/build.xml @@ -0,0 +1,146 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/phpcs.xml b/build/phpcs.xml new file mode 100644 index 0000000..b2c5440 --- /dev/null +++ b/build/phpcs.xml @@ -0,0 +1,36 @@ + + + Default coding standard + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/phpmd.xml b/build/phpmd.xml new file mode 100644 index 0000000..6a8b260 --- /dev/null +++ b/build/phpmd.xml @@ -0,0 +1,26 @@ + + + + Default coding standard + + + + + + + + + + + + + + + + + + diff --git a/buildings.php b/buildings.php deleted file mode 100644 index ac51962..0000000 --- a/buildings.php +++ /dev/null @@ -1,151 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -define('INSIDE' , true); -define('INSTALL' , false); -require_once dirname(__FILE__) .'/common.php'; - -includeLang('buildings'); - -$user = Legacies_Empire_Model_User::getSingleton(); -$planet = $user->getCurrentPlanet(); -$mode = isset($_GET['mode']) ? $_GET['mode'] : null; - -switch ($mode) { -case 'fleet': - if ($planet->getElement(Legacies_Empire::ID_BUILDING_SHIPYARD) === null) { - $layout = new Legacies_Core_Layout(); - $layout->load('message'); - - $block = $layout->getBlock('message'); - $block['title'] = Legacies::__('Shipyard is required'); - $block['message'] = Legacies::__('In order to build ships you will need to build a shipyard building.'); - - $layout->render(); - break; - } - - /** @var Legacies_Empire_Model_Planet_Building_Shipyard $shipyard */ - $shipyard = $planet->getShipyard(); - if (isset($_POST['ship']) && is_array($_POST['ship'])) { - foreach ($_POST['ship'] as $shipId => $count) { - $shipId = intval($shipId); - $count = intval($count); - - $shipyard->appendQueue($shipId, $count); - } - $planet->save(); - } - - $layout = new Legacies_Core_Layout(); - $layout->load('planet.shipyard'); - - echo $layout->render(); - break; - -case 'research': - if ($planet->getElement(Legacies_Empire::ID_BUILDING_RESEARCH_LAB) === null) { - $layout = new Legacies_Core_Layout(); - $layout->load('message'); - - $block = $layout->getBlock('message'); - $block['title'] = Legacies::__('Research lab is required'); - $block['title'] = Legacies::__('In order to do technological researches, you will need to build a research lab building.'); - - $layout->render(); - break; - } - - if (isset($_GET['research']) && !empty($_GET['research'])) { - $data = $planet->getAllDatas(); - $planet->appendBuildingQueue(intval($_GET['research']), isset($_GET['destroy'])); - $planet->save(); - } else if (isset($_GET['cancel']) && !empty($_GET['cancel'])) { - $planet->dequeueItem($_GET['cancel']); - $planet->save(); - } - - $layout = new Legacies_Core_Layout(); - $layout->load('planet.research-lab'); - - echo $layout->render(); - break; - -case 'defense': - if ($planet->getElement(Legacies_Empire::ID_BUILDING_SHIPYARD) === null) { - $layout = new Legacies_Core_Layout(); - $layout->load('message'); - - $block = $layout->getBlock('message'); - $block['title'] = Legacies::__('Shipyard is required'); - $block['title'] = Legacies::__('In order to build ships you will need to build a shipyard building.'); - - $layout->render(); - break; - } - - /** @var Legacies_Empire_Model_Planet_Building_Shipyard $shipyard */ - $shipyard = $planet->getShipyard(); - if (isset($_POST['defense']) && is_array($_POST['defense'])) { - foreach ($_POST['defense'] as $defenseId => $count) { - $defenseId = intval($defenseId); - $count = intval($count); - - $shipyard->appendQueue($defenseId, $count); - } - $planet->save(); - } - - $layout = new Legacies_Core_Layout(); - $layout->load('planet.defense'); - - /** @var Legacies_Empire_Block_Planet_Shipyard $block */ - $block = $layout->getBlock('item-list'); - $block->setType(Legacies_Empire::TYPE_DEFENSE); - - echo $layout->render(); - break; - -default: - if (isset($_GET['building']) && !empty($_GET['building'])) { - $data = $planet->getAllDatas(); - $planet->appendBuildingQueue(intval($_GET['building']), isset($_GET['destroy'])); - $planet->save(); - } else if (isset($_GET['cancel']) && !empty($_GET['cancel'])) { - $planet->dequeueItem($_GET['cancel']); - $planet->save(); - } - - $layout = new Legacies_Core_Layout(); - $layout->load('planet.buildings'); - echo $layout->render(); - break; -} - diff --git a/config.php.default b/config.php.default deleted file mode 100644 index 85e7c1c..0000000 --- a/config.php.default +++ /dev/null @@ -1,21 +0,0 @@ - array( - 'date' => array( - 'timezone' => 'Europe/Paris' - ), - 'database' => array( - 'engine' => 'mysql', - 'options' => array( - 'hostname' => 'localhost', - 'username' => 'root', - 'password' => '', - 'database' => 'db_xnova' - ), - 'table_prefix' => 'game_', - ), - 'layout' => array( - 'page' => 'page.php', - 'empire' => 'empire.php' - ) - ) - ); \ No newline at end of file diff --git a/db/mysql.php b/db/mysql.php deleted file mode 100644 index 5b7c394..0000000 --- a/db/mysql.php +++ /dev/null @@ -1,64 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -/** - * - * Enter description here ... - * @deprecated - * @param string $query - * @param string $table - * @param bool $fetch - */ -function doquery($query, $table, $fetch = false) -{ - /** - * @var Legacies_Database $database - */ - $database = Legacies_Database::getSingleton(); - - $sql = str_replace("{{table}}", $database->getTable($table), $query); - - /** - * @var PDOStatement $statement - */ - try { - $statement = $database->prepare($sql); - - $statement->execute(array()); - } catch (PDOException $e) { - trigger_error($e->getMessage() . PHP_EOL . "
$sql

" . PHP_EOL, E_USER_WARNING); - } - - if ($fetch) { - return $statement->fetch(PDO::FETCH_BOTH); - } else { - return $statement; - } -} diff --git a/extension.inc b/extension.inc deleted file mode 100644 index 4c28188..0000000 --- a/extension.inc +++ /dev/null @@ -1 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -define('INSIDE' , true); -define('INSTALL' , false); -require_once dirname(__FILE__) .'/common.php'; - - $maxfleet = doquery("SELECT COUNT(fleet_owner) AS `actcnt` FROM {{table}} WHERE `fleet_owner` = '".$user['id']."';", 'fleets', true); - - $MaxFlyingFleets = $maxfleet['actcnt']; - - //Compteur de flotte en expéditions et nombre d'expédition maximum - $MaxExpedition = $user[$resource[124]]; - if ($MaxExpedition >= 1) { - $maxexpde = doquery("SELECT COUNT(fleet_owner) AS `expedi` FROM {{table}} WHERE `fleet_owner` = '".$user['id']."' AND `fleet_mission` = '15';", 'fleets', true); - $ExpeditionEnCours = $maxexpde['expedi']; - $EnvoiMaxExpedition = 1 + floor( $MaxExpedition / 3 ); - } - - $MaxFlottes = 1 + $user[$resource[108]]; - - CheckPlanetUsedFields($planetrow); - - includeLang('fleet'); - - $missiontype = array( - 1 => $lang['type_mission'][1], - 2 => $lang['type_mission'][2], - 3 => $lang['type_mission'][3], - 4 => $lang['type_mission'][4], - 5 => $lang['type_mission'][5], - 6 => $lang['type_mission'][6], - 7 => $lang['type_mission'][7], - 8 => $lang['type_mission'][8], - 9 => $lang['type_mission'][9], - 15 => $lang['type_mission'][15] - ); - - // Histoire de recuperer les infos passées par galaxy - $galaxy = $_GET['galaxy']; - $system = $_GET['system']; - $planet = $_GET['planet']; - $planettype = $_GET['planettype']; - $target_mission = $_GET['target_mission']; - - if (!$galaxy) { - $galaxy = $planetrow['galaxy']; - } - if (!$system) { - $system = $planetrow['system']; - } - if (!$planet) { - $planet = $planetrow['planet']; - } - if (!$planettype) { - $planettype = $planetrow['planet_type']; - } - - $page = "\n"; - $page .= "\n"; - $page .= "
"; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; -// $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - - // Gestion des flottes du joueur actif - $fq = doquery("SELECT * FROM {{table}} WHERE fleet_owner={$user[id]}", "fleets"); - $i = 0; - - - while ($f = $fq->fetch(PDO::FETCH_BOTH)) { - $i++; - $page .= ""; - // (01) Fleet ID - $page .= ""; - // (02) Fleet Mission - $page .= ""; - // (03) Fleet Mission - $page .= ""; - // (04) Fleet From (Planete d'origine) - $page .= ""; - // (05) Fleet Start Time - $page .= ""; - // (06) Fleet Target (Planete de destination) - $page .= ""; - // (07) Fleet Target Time - $page .= ""; - // (08) Fleet Back Time -// $page .= ""; - // (09) Fleet Back In - $page .= ""; - // (10) Orders - $page .= ""; - // Fin de ligne - $page .= ""; - } - - // Y a pas de flottes en vol ... on met des '-' - if ($i == 0) { - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; -// $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - } - - if ($MaxFlottes == $MaxFlyingFleets) { - $page .= ""; - } - - $page .= "
"; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= "
"; - $page .= $lang['fl_title']." ".$MaxFlyingFleets." ".$lang['fl_sur']." ".$MaxFlottes; - $page .= ""; - $page .= $ExpeditionEnCours."/".$EnvoiMaxExpedition." ".$lang['fl_expttl']; - $page .= "
"; - $page .= "
".$lang['fl_id']."".$lang['fl_mission']."".$lang['fl_count']."".$lang['fl_from']."".$lang['fl_start_t']."".$lang['fl_dest']."".$lang['fl_dest_t']."".$lang['fl_back_t']."".$lang['fl_back_in']."".$lang['fl_order']."
".$i.""; - $page .= "". $missiontype[$f[fleet_mission]] .""; - if (($f['fleet_start_time'] + 1) == $f['fleet_end_time']) { - $page .= "
".$lang['fl_back_to'].""; - } else { - $page .= "
".$lang['fl_get_to'].""; - } - $page .= "
$b) { - if ($b != '') { - $e++; - $a = explode(",", $b); - $page .= $lang['tech'][$a[0]]. ":". $a[1] ."\n"; - if ($e > 1) { - $page .= "\t"; - } - } - } - $page .= "\">". pretty_number($f[fleet_amount]) ."[".$f[fleet_start_galaxy].":".$f[fleet_start_system].":".$f[fleet_start_planet]."]". gmdate("d. M Y H:i:s", $f['fleet_start_time']) ."[".$f[fleet_end_galaxy].":".$f[fleet_end_system].":".$f[fleet_end_planet]."]". gmdate("d. M Y H:i:s", $f['fleet_end_time']) ."
". pretty_time(floor($f['fleet_end_time'] + 1 - time())) ."
". pretty_time(floor($f['fleet_end_time'] + 1 - time())) ."
"; - if ($f['fleet_mess'] == 0) { - $page .= "
"; - $page .= ""; - $page .= ""; - $page .= "
"; - if ($f[fleet_mission] == 1) { - $page .= "
"; - $page .= ""; - $page .= ""; - $page .= "
"; - } - } else { - $page .= " - "; - } - $page .= "
----------
".$lang['fl_noslotfree']."
"; - - $page .= "
"; - - // Selection d'une nouvelle mission - $page .= "
"; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - - if (!$planetrow) { - message($lang['fl_noplanetrow'], $lang['fl_error']); - } - - // Prise des coordonnées sur la ligne de commande - $galaxy = intval($_GET['galaxy']); - $system = intval($_GET['system']); - $planet = intval($_GET['planet']); - $planettype = intval($_GET['planettype']); - $target_mission = intval($_GET['target_mission']); - $ShipData = ""; - - foreach ($reslist['fleet'] as $n => $i) { - if ($planetrow[$resource[$i]] > 0) { - $page .= ""; - $page .= ""; - $page .= ""; - // Satelitte Solaire (eux ne peuvent pas bouger !) - if ($i == 212) { - $page .= ""; - } else { - $page .= ""; - $page .= ""; - } - $page .= ""; - } - $have_ships = true; - } - - $btncontinue = ""; - $page .= ""; - if (!$have_ships) { - // Il n'y a pas de vaisseaux sur cette planete - $page .= ""; - $page .= ""; - $page .= $btncontinue; - } else { - $page .= ""; - $page .= ""; - $page .= ""; - - if ($MaxFlottes > $MaxFlyingFleets) { - $page .= $btncontinue; - } - } - $page .= ""; - $page .= "
".$lang['fl_new_miss']."
".$lang['fl_fleet_typ']."".$lang['fl_fleet_disp']."--
" . $lang['tech'][$i] . "". pretty_number ($planetrow[$resource[$i]]); - $ShipData .= ""; - $ShipData .= ""; - $ShipData .= ""; - $ShipData .= ""; - $page .= "".$lang['fl_selmax']."
". $lang['fl_noships'] ."
". $lang['fl_unselectall'] ."". $lang['fl_selectall'] ."
"; - $page .= $ShipData; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= "
"; - $page .= "
"; - - display($page, $lang['fl_title']); - -?> diff --git a/fleetback.php b/fleetback.php deleted file mode 100644 index d8cc82e..0000000 --- a/fleetback.php +++ /dev/null @@ -1,73 +0,0 @@ - -Website: http://project.galacticnova.vinilox.eu/ -Last revision: 13/07/11 - -*/ - -define('INSIDE' , true); -define('INSTALL' , false); -require_once dirname(__FILE__) .'/common.php'; - includeLang('fleet'); - - $BoxTitle = $lang['fl_error']; - $TxtColor = "red"; - $BoxMessage = $lang['fl_notback']; - if ( is_numeric($_POST['fleetid']) ) { - $fleetid = intval($_POST['fleetid']); - - $FleetRow = doquery("SELECT * FROM {{table}} WHERE `fleet_id` = '". $fleetid ."';", 'fleets', true); - $i = 0; - - if ($FleetRow['fleet_owner'] == $user['id']) { - if ($FleetRow['fleet_mess'] == 0 || $FleetRow['fleet_mess'] == 2) { - if ($FleetRow['fleet_end_stay'] != 0) { - // Faut calculer le temps reel de retour - if ($FleetRow['fleet_start_time'] > time()) { - // On a pas encore entamé le stationnement - // Il faut calculer la parcelle de temps ecoulée depuis le lancement de la flotte - $CurrentFlyingTime = time() - $FleetRow['start_time']; - } else { - // On est deja en stationnement - // Il faut donc directement calculer la durée d'un vol aller ou retour - $CurrentFlyingTime = $FleetRow['fleet_start_time'] - $FleetRow['start_time']; - } - } else { - // C'est quoi le stationnement ?? - // On calcule sagement la parcelle de temps ecoulée depuis le depart - $CurrentFlyingTime = time() - $FleetRow['start_time']; - } - // Allez houste au bout du compte y a la maison !! (E.T. phone home.............) - $ReturnFlyingTime = $CurrentFlyingTime + time(); - - $QryUpdateFleet = "UPDATE {{table}} SET "; - $QryUpdateFleet .= "`fleet_start_time` = '". (time() - 1) ."', "; - $QryUpdateFleet .= "`fleet_end_stay` = '0', "; - $QryUpdateFleet .= "`fleet_end_time` = '". ($ReturnFlyingTime + 1) ."', "; - $QryUpdateFleet .= "`fleet_target_owner` = '". $user['id'] ."', "; - $QryUpdateFleet .= "`fleet_mess` = '1' "; - $QryUpdateFleet .= "WHERE "; - $QryUpdateFleet .= "`fleet_id` = '" . $fleetid . "';"; - doquery( $QryUpdateFleet, 'fleets'); - - $BoxTitle = $lang['fl_sback']; - $TxtColor = "lime"; - $BoxMessage = $lang['fl_isback']; - } elseif ($FleetRow['fleet_mess'] == 1) { - $BoxMessage = $lang['fl_notback']; - } - } else { - $BoxMessage = $lang['fl_onlyyours']; - } - } - - message ("". $BoxMessage ."", $BoxTitle, "fleet.". PHPEXT, 2); - -// ----------------------------------------------------------------------------------------------------------- -?> diff --git a/fleetshortcut.php b/fleetshortcut.php deleted file mode 100644 index 84927cd..0000000 --- a/fleetshortcut.php +++ /dev/null @@ -1,165 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -define('INSIDE' , true); -define('INSTALL' , false); -require_once dirname(__FILE__) .'/common.php'; - - -$mode = $_GET['mode']; -$a = $_GET['a']; -/* - Este script es original xD - La funcion de este script es administrar una variable del $user - Permite agregar y quitar arrays... -*/ -//Lets start! -if(isset($_GET['mode'])){ - if($_POST){ - //Pegamos el texto :P - if($_POST["n"] == ""){$_POST["n"] = "Unbenannt";} - - $r = strip_tags($_POST[n]).",".intval($_POST[g]).",".intval($_POST[s]).",".intval($_POST[p]).",".intval($_POST[t])."\r\n"; - $user['fleet_shortcut'] .= $r; - doquery("UPDATE {{table}} SET fleet_shortcut='{$user[fleet_shortcut]}' WHERE id={$user[id]}","users"); - message("Le raccourcis a été enregistré !","Enregistrment","fleetshortcut.php"); - } - $page = "
- - - - "; - $page .= '
Nom [Galaxie/Système solaire/Planète]
- - - - - -
"; - //Muestra un (L) si el destino pertenece a luna, lo mismo para escombros - $page .= "
Effacer
'; -} -elseif(isset($_GET['a'])){ - if($_POST){ - //Armamos el array... - $scarray = explode("\r\n",$user['fleet_shortcut']); - if($_POST["delete"]){ - unset($scarray[$a]); - $user['fleet_shortcut'] = implode("\r\n",$scarray); - doquery("UPDATE {{table}} SET fleet_shortcut='{$user[fleet_shortcut]}' WHERE id={$user[id]}","users"); - message("Shortcut wurde gelöscht","Gelöscht","fleetshortcut.php"); - } - else{ - $r = explode(",",$scarray[$a]); - $r[0] = strip_tags($_POST['n']); - $r[1] = intval($_POST['g']); - $r[2] = intval($_POST['s']); - $r[3] = intval($_POST['p']); - $r[4] = intval($_POST['t']); - $scarray[$a] = implode(",",$r); - $user['fleet_shortcut'] = implode("\r\n",$scarray); - doquery("UPDATE {{table}} SET fleet_shortcut='{$user[fleet_shortcut]}' WHERE id={$user[id]}","users"); - message("Le raccourcis a été édité !.","Editer","fleetshortcut.php"); - } - } - if($user['fleet_shortcut']){ - - $scarray = explode("\r\n",$user['fleet_shortcut']); - $c = explode(',',$scarray[$a]); - - $page = "
- - - "; - //if($i==0){$page .= "";} - $page .= " - "; - - }else{$page .= message("Le raccourcis a été enregistré !","Enregistrer","fleetshortcut.php");} - - $page .= '
Editer: {$c[0]} [{$c[1]}:{$c[2]}:{$c[3]}]
- - - - - - -
"; - $page .= "
Retour
'; - - -} -else{ - - $page = ' - - - '; - - if($user['fleet_shortcut']){ - /* - Dentro de fleet_shortcut, se pueden almacenar las diferentes direcciones - de acceso directo, el formato es el siguiente. - Nombre, Galaxia,Sistema,Planeta,Tipo - */ - $scarray = explode("\r\n",$user['fleet_shortcut']); - $i=$e=0; - foreach($scarray as $a => $b){ - if($b!=""){ - $c = explode(',',$b); - if($i==0){$page .= "";} - $page .= ""; - if($i==1){$page .= "";} - if($i==1){$i=0;}else{$i=1;} - } - - } - if($i==1){$page .= "";} - - }else{$page .= "";} - - $page .= '
Raccourcis(Ajout)
"; - $page .= "{$c[0]} {$c[1]}:{$c[2]}:{$c[3]}"; - //Muestra un (L) si el destino pertenece a luna, lo mismo para escombros - if($c[4]==2){$page .= " (E)";}elseif($c[4]==3){$page .= " (L)";} - $page .= "
Pas de Raccourcis
Retour
'; -} -display($page,"Shortcutmanager"); - -// Created by Perberos. All rights reversed (C) 2006 -?> diff --git a/floten1.php b/floten1.php deleted file mode 100644 index 4a61f06..0000000 --- a/floten1.php +++ /dev/null @@ -1,286 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -define('INSIDE' , true); -define('INSTALL' , false); -require_once dirname(__FILE__) .'/common.php'; - includeLang('fleet'); - - $speed = array(10 => 100, - 9 => 90, - 8 => 80, - 7 => 70, - 6 => 60, - 5 => 50, - 4 => 40, - 3 => 30, - 2 => 20, - 1 => 10, - ); - - $g = $_POST['galaxy']; - $s = $_POST['system']; - $p = $_POST['planet']; - $t = $_POST['planet_type']; - - if (!$g) { - $g = $planetrow['galaxy']; - } - if (!$s) { - $s = $planetrow['system']; - } - if (!$p) { - $p = $planetrow['planet']; - } - if (!$t) { - $t = $planetrow['planet_type']; - } - - // Verifions si nous avons bien tout ce que nous voullons envoyer - $FleetHiddenBlock = ""; - foreach ($reslist['fleet'] as $n => $i) { - if ($i > 200 && $i < 300 && $_POST["ship$i"] > "0") { - if ($_POST["ship$i"] > $planetrow[$resource[$i]]) { - $page .= $lang['fl_noenought']; - $speedalls[$i] = GetFleetMaxSpeed ( "", $i, $user ); - } else { - $fleet['fleetarray'][$i] = $_POST["ship$i"]; - // Tableau des vaisseaux avec leur nombre - $fleet['fleetlist'] .= $i . "," . $_POST["ship$i"] . ";"; - // Nombre total de vaisseaux - $fleet['amount'] += $_POST["ship$i"]; - // Tableau des vitesses - $FleetHiddenBlock .= ""; - $FleetHiddenBlock .= ""; - $FleetHiddenBlock .= ""; - $FleetHiddenBlock .= ""; - $speedalls[$i] = GetFleetMaxSpeed ( "", $i, $user ); - } - } - } - - if (!$fleet['fleetlist']) { - message($lang['fl_unselectall'], $lang['fl_error'], "fleet." . PHPEXT, 1); - } else { - $speedallsmin = min($speedalls); - } - $page .= ""; - $page .= "\n"; - $page .= "
"; - $page .= $FleetHiddenBlock; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - - $page .= "
"; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; -/* A faire assez rapidement (faut juste savoir comment) - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; -*/ - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - - // Gestion des raccourcis sur la galaxie - $page .= ""; - $page .= ""; - $page .= ""; - if ($user['fleet_shortcut']) { - $scarray = explode("\r\n", $user['fleet_shortcut']); - $i = 0; - foreach ($scarray as $a => $b) { - if ($b != "") { - $c = explode(',', $b); - if ($i == 0) { - $page .= ""; - } - $page .= ""; - $page .= ""; - } - - $page .= ""; - $page .= ""; - $page .= ""; - - // Gestion des raccourcis vers ses propres colonies ou planetes - $kolonien = SortUserPlanets ( $user ); - $currentplanet = doquery("SELECT * FROM {{table}} WHERE id = '" . $user['current_planet'] . "'", 'planets', true); - - if (mysql_num_rows($kolonien) > 1) { - $i = 0; - $w = 0; - $tr = true; - while ($row = $kolonien->fetch(PDO::FETCH_BOTH)) { - if ($w == 0 && $tr) { - $page .= ""; - $tr = false; - } - if ($w == 2) { - $page .= ""; - $w = 0; - $tr = true; - } - - if ($row['planet_type'] == 3) { - $row['name'] .= " ". $lang['fl_shrtcup3']; - } - - if ($currentplanet['galaxy'] == $row['galaxy'] && - $currentplanet['system'] == $row['system'] && - $currentplanet['planet'] == $row['planet'] && - $currentplanet['planet_type'] == $row['planet_type'] ) { -// $page .= ''; - } else { - $page .= ""; - $w++; - $i++; - } - } - - if ($i % 2 != 0) { - $page .= ""; - } elseif ($w == 2) { - $page .= ""; - } - } else { - $page .= ""; - } - - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= "
". $lang['fl_floten1_ttl'] ."
". $lang['fl_dest'] .""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= "
". $lang['fl_speed'] .""; - $page .= " %"; - $page .= "
". $lang['fl_dist'] ."
-
". $lang['fl_fltime'] ."
-
". $lang['fl_time_go'] ."
". gmdate("H:i:s") ."
". $lang['fl_time_back'] ."
". gmdate("H:i:s") ."
". $lang['fl_deute_need'] ."
-
". $lang['fl_speed_max'] ."
-
". $lang['fl_max_load'] ."
-
". $lang['fl_shortcut'] ." ". $lang['fl_shortlnk'] ."
"; - $page .= "". $lang['fl_noshortc'] ."
". $lang['fl_myplanets'] ."
'.$row['name'].' '.$row['galaxy'].':'.$row['system'].':'.$row['planet'].'". $row['name'] ." ". $row['galaxy'] .":". $row['system'] .":". $row['planet'] ." 
". $lang['fl_nocolonies'] ."
". $lang['fl_grattack'] ."
-
"; - $page .= "
"; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= "
"; - $page .= ""; - - display($page, $lang['fl_title']); - -// Updated by Chlorel. 16 Jan 2008 (String extraction, bug corrections, code uniformisation -// Created by Perberos. All rights reversed (C) 2006 -?> diff --git a/floten2.php b/floten2.php deleted file mode 100644 index a56178b..0000000 --- a/floten2.php +++ /dev/null @@ -1,281 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -define('INSIDE' , true); -define('INSTALL' , false); -require_once dirname(__FILE__) .'/common.php'; - includeLang('fleet'); - - $galaxy = intval($_POST['galaxy']); - $system = intval($_POST['system']); - $planet = intval($_POST['planet']); - $planettype = intval($_POST['planettype']); - - // Test d'existance et de proprieté de la planete - $YourPlanet = false; - $UsedPlanet = false; - $select = doquery("SELECT * FROM {{table}}", "planets"); - - while ($row = $select->fetch(PDO::FETCH_BOTH)) { - if ($galaxy == $row['galaxy'] && - $system == $row['system'] && - $planet == $row['planet'] && - $planettype == $row['planet_type']) { - if ($row['id_owner'] == $user['id']) { - $YourPlanet = true; - $UsedPlanet = true; - } else { - $UsedPlanet = true; - } - break; - } - } - - // Determinons les type de missions possibles par rapport a la planete cible - if ($_POST['planettype'] == "2") { - if ($_POST['ship209'] >= 1) { - $missiontype = array(8 => $lang['type_mission'][8]); - } else { - $missiontype = array(); - } - } elseif ($_POST['planettype'] == "1" || $_POST['planettype'] == "3") { - if ($_POST['ship208'] >= 1 && !$UsedPlanet) { - $missiontype = array(7 => $lang['type_mission'][7]); - } elseif ($_POST['ship210'] >= 1 && !$YourPlanet) { - $missiontype = array(6 => $lang['type_mission'][6]); - } - - if ($_POST['ship202'] >= 1 || - $_POST['ship203'] >= 1 || - $_POST['ship204'] >= 1 || - $_POST['ship205'] >= 1 || - $_POST['ship206'] >= 1 || - $_POST['ship207'] >= 1 || - $_POST['ship210'] >= 1 || - $_POST['ship211'] >= 1 || - $_POST['ship213'] >= 1 || - $_POST['ship214'] >= 1 || - $_POST['ship215'] >= 1 || - $_POST['ship216'] >= 1) { - if (!$YourPlanet) { - $missiontype[1] = $lang['type_mission'][1]; - $missiontype[5] = $lang['type_mission'][5]; - } - $missiontype[3] = $lang['type_mission'][3]; - } - - - } elseif ($_POST['ship209'] >= 1 || $_POST['ship208'] >= 1) { - $missiontype[3] = $lang['type_mission'][3]; - } - if ($YourPlanet) - $missiontype[4] = $lang['type_mission'][4]; - - if ( $_POST['planettype'] == 3 && - ($_POST['ship214'] || - $_POST['ship213']) && - !$YourPlanet && - $UsedPlanet) { - $missiontype[2] = $lang['type_mission'][2]; - } - if ( $_POST['planettype'] == 3 && - ($_POST['ship214'] >= 1 || $_POST['ship216'] >= 1) && - !$YourPlanet && - $UsedPlanet) { - $missiontype[9] = $lang['type_mission'][9]; - } - - $fleetarray = unserialize(base64_decode(str_rot13($_POST["usedfleet"]))); - $mission = $_POST['target_mission']; - $SpeedFactor = $_POST['speedfactor']; - $AllFleetSpeed = GetFleetMaxSpeed ($fleetarray, 0, $user); - $GenFleetSpeed = $_POST['speed']; - $MaxFleetSpeed = min($AllFleetSpeed); - - $distance = GetTargetDistance ( $_POST['thisgalaxy'], $_POST['galaxy'], $_POST['thissystem'], $_POST['system'], $_POST['thisplanet'], $_POST['planet'] ); - $duration = GetMissionDuration ( $GenFleetSpeed, $MaxFleetSpeed, $distance, $SpeedFactor ); - $consumption = GetFleetConsumption ( $fleetarray, $SpeedFactor, $duration, $distance, $MaxFleetSpeed, $user ); - - $MissionSelector = ""; - if (count($missiontype) > 0) { - if ($planet == 16) { - $MissionSelector .= ""; - $MissionSelector .= ""; - $MissionSelector .= "". $lang['type_mission'][15] ."

"; - $MissionSelector .= "". $lang['fl_expe_warning'] .""; - $MissionSelector .= ""; - $MissionSelector .= ""; - } else { - $i = 0; - foreach ($missiontype as $a => $b) { - $MissionSelector .= ""; - $MissionSelector .= ""; - $MissionSelector .= ""; - $MissionSelector .= "
"; - $MissionSelector .= ""; - $MissionSelector .= ""; - $i++; - } - } - } else { - $MissionSelector .= ""; - $MissionSelector .= ""; - $MissionSelector .= "". $lang['fl_bad_mission'] .""; - $MissionSelector .= ""; - $MissionSelector .= ""; - } - - if ($_POST['thisplanettype'] == 1) { - $TableTitle = "". $_POST['thisgalaxy'] .":". $_POST['thissystem'] .":". $_POST['thisplanet'] ." - ". $lang['fl_planet'] .""; - } elseif ($_POST['thisplanettype'] == 3) { - $TableTitle = "". $_POST['thisgalaxy'] .":". $_POST['thissystem'] .":". $_POST['thisplanet'] ." - ". $lang['fl_moon'] .""; - } - - $page = ""; - $page .= "\n"; - $page .= "
"; - $page .= "
\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - foreach ($fleetarray as $Ship => $Count) { - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - - } - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "
". $TableTitle ."
\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= $MissionSelector; - $page .= "\n"; - $page .= "
". $lang['fl_mission'] ."
\n"; - $page .= "
\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - $page .= "\n"; - if ($planet == 16) { - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - } elseif ( $missiontype[5] != '' ) { - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - } - $page .= "\n"; - $page .= "
". $lang['fl_ressources'] ."
". $lang['Metal'] ."". $lang['fl_selmax'] ."
". $lang['Crystal'] ."". $lang['fl_selmax'] ."
". $lang['Deuterium'] ."". $lang['fl_selmax'] ."
". $lang['fl_space_left'] ."
-
". $lang['fl_allressources'] ."
 
". $lang['fl_expe_staytime'] ."
"; - $page .= ""; - $page .= $lang['fl_expe_hours']; - $page .= "
". $lang['fl_expe_staytime'] ."
"; - $page .= ""; - $page .= $lang['fl_expe_hours']; - $page .= "
\n"; - $page .= "
\n"; - $page .= "
\n"; - - display($page, $lang['fl_title']); - -?> \ No newline at end of file diff --git a/floten3.php b/floten3.php deleted file mode 100644 index 17a36e8..0000000 --- a/floten3.php +++ /dev/null @@ -1,539 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -define('INSIDE' , true); -define('INSTALL' , false); -require_once dirname(__FILE__) .'/common.php'; - - $dpath = (!$user["dpath"]) ? DEFAULT_SKINPATH : $user["dpath"]; - - includeLang('fleet'); - - $CurrentPlanet = doquery("SELECT * FROM {{table}} WHERE `id` = '". $user['current_planet'] ."'", 'planets', true); - $TargetPlanet = doquery("SELECT * FROM {{table}} WHERE `galaxy` = '". $_POST['galaxy'] ."' AND `system` = '". $_POST['system'] ."' AND `planet` = '". $_POST['planet'] ."' AND `planet_type` = '". $_POST['planettype'] ."';", 'planets', true); - $MyDBRec = doquery("SELECT * FROM {{table}} WHERE `id` = '". $user['id']."';", 'users', true); - - $protection = $gameConfig['noobprotection']; - $protectiontime = $gameConfig['noobprotectiontime']; - $protectionmulti = $gameConfig['noobprotectionmulti']; - if ($protectiontime < 1) { - $protectiontime = 9999999999999999; - } - - $fleetarray = unserialize(base64_decode(str_rot13($_POST["usedfleet"]))); - - if (!is_array($fleetarray)) { - message ("". $lang['fl_fleet_err'] ."", $lang['fl_error'], "fleet." . PHPEXT, 2); - } - - // On verifie s'il y a assez de vaisseaux sur la planete ! - foreach ($fleetarray as $Ship => $Count) { - if ($Count > $CurrentPlanet[$resource[$Ship]]) { - message ("". $lang['fl_fleet_err'] ."", $lang['fl_error'], "fleet." . PHPEXT, 2); - } - } - - $error = 0; - $galaxy = intval($_POST['galaxy']); - $system = intval($_POST['system']); - $planet = intval($_POST['planet']); - $planettype = intval($_POST['planettype']); - $fleetmission = $_POST['mission']; - - if ($planettype != 1 && $planettype != 2 && $planettype != 3) { - message ("". $lang['fl_fleet_err_pl'] ."", $lang['fl_error'], "fleet." . PHPEXT, 2); - } - - if ($fleetmission == 8) { - $YourPlanet = false; - $UsedPlanet = false; - $select = doquery("SELECT * FROM {{table}} WHERE galaxy = '". $galaxy ."' AND system = '". $system ."' AND planet = '". $planet ."'", "planets"); - } else { - $YourPlanet = false; - $UsedPlanet = false; - $select = doquery("SELECT * FROM {{table}} WHERE galaxy = '". $galaxy ."' AND system = '". $system ."' AND planet = '". $planet ."' AND planet_type = '". $planettype ."'", "planets"); - } - - if ($CurrentPlanet['galaxy'] == $galaxy && - $CurrentPlanet['system'] == $system && - $CurrentPlanet['planet'] == $planet && - $CurrentPlanet['planet_type'] == $planettype) { - message ("". $lang['fl_ownpl_err'] ."", $lang['fl_error'], "fleet." . PHPEXT, 2); - } - - // Test d'existance de l'enregistrement dans la gaalxie ! - if ($_POST['mission'] != 15) { - if (mysql_num_rows($select) < 1 && $fleetmission != 7) { - message ("". $lang['fl_unknow_target'] ."", $lang['fl_error'], "fleet." . PHPEXT, 2); - } elseif ($fleetmission == 9 && mysql_num_rows($select) < 1) { - message ("". $lang['fl_used_target'] ."", $lang['fl_error'], "fleet." . PHPEXT, 2); - } - } else { - $EnvoiMaxExpedition = $_POST['maxepedition']; - $Expedition = $_POST['curepedition']; - - if ($EnvoiMaxExpedition == 0 ) { - message ("". $lang['fl_expe_notech'] ."", $lang['fl_error'], "fleet." . PHPEXT, 2); - } elseif ($Expedition >= $EnvoiMaxExpedition ) { - message ("". $lang['fl_expe_max'] ."", $lang['fl_error'], "fleet." . PHPEXT, 2); - } - } - - $select = mysql_fetch_array($select); - - if ($select['id_owner'] == $user['id']) { - $YourPlanet = true; - $UsedPlanet = true; - } elseif (!empty($select['id_owner'])) { - $YourPlanet = false; - $UsedPlanet = true; - } else { - $YourPlanet = false; - $UsedPlanet = false; - } - - // Determinons les type de missions possibles par rapport a la planete cible - if ($fleetmission == 15) { - // Gestion des Exp�ditions - $missiontype = array(15 => $lang['type_mission'][15]); - } else { - if ($_POST['planettype'] == "2") { - if ($_POST['ship209'] >= 1) { - $missiontype = array(8 => $lang['type_mission'][8]); - } else { - $missiontype = array(); - } - } elseif ($_POST['planettype'] == "1" || $_POST['planettype'] == "3") { - if ($_POST['ship208'] >= 1 && !$UsedPlanet) { - $missiontype = array(7 => $lang['type_mission'][7]); - } elseif ($_POST['ship210'] >= 1 && !$YourPlanet) { - $missiontype = array(6 => $lang['type_mission'][6]); - } - - if ($_POST['ship202'] >= 1 || - $_POST['ship203'] >= 1 || - $_POST['ship204'] >= 1 || - $_POST['ship205'] >= 1 || - $_POST['ship206'] >= 1 || - $_POST['ship207'] >= 1 || - $_POST['ship210'] >= 1 || - $_POST['ship211'] >= 1 || - $_POST['ship213'] >= 1 || - $_POST['ship214'] >= 1 || - $_POST['ship215'] >= 1 || - $_POST['ship216'] >= 1) { - if (!$YourPlanet) { - $missiontype[1] = $lang['type_mission'][1]; - $missiontype[5] = $lang['type_mission'][5]; - } - $missiontype[3] = $lang['type_mission'][3]; - } - - - } elseif ($_POST['ship209'] >= 1 || $_POST['ship208'] >= 1) { - $missiontype[3] = $lang['type_mission'][3]; - } - if ($YourPlanet) - $missiontype[4] = $lang['type_mission'][4]; - - if ( $_POST['planettype'] == 3 && - ($_POST['ship214'] || - $_POST['ship213']) && - !$YourPlanet && - $UsedPlanet) { - $missiontype[2] = $lang['type_mission'][2]; - } - if ($_POST['planettype'] == 3 && - ($_POST['ship214'] >= 1 || $_POST['ship216'] >= 1) && - !$YourPlanet && $UsedPlanet) { - $missiontype[9] = $lang['type_mission'][9]; - } - } - - if (empty($missiontype[$fleetmission])) { - message ("". $lang['fl_bad_mission'] ."", $lang['fl_error'], "fleet." . PHPEXT, 2); - } - - CheckPlanetUsedFields($CurrentPlanet); - - if ($TargetPlanet['id_owner'] == '') { - $HeDBRec = $MyDBRec; - } elseif ($TargetPlanet['id_owner'] != '') { - $HeDBRec = doquery("SELECT * FROM {{table}} WHERE `id` = '". $TargetPlanet['id_owner'] ."';", 'users', true); - } - - $UserPoints = doquery("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '". $MyDBRec['id'] ."';", 'statpoints', true); - $User2Points = doquery("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '". $HeDBRec['id'] ."';", 'statpoints', true); - - $MyGameLevel = $UserPoints['total_points']; - $HeGameLevel = $User2Points['total_points']; - $VacationMode = $HeDBRec['urlaubs_modus']; - - if ($MyGameLevel > ($HeGameLevel * $protectionmulti) AND - $TargetPlanet['id_owner'] != '' AND - $_POST['mission'] == 1 AND - $protection == 1 AND - $HeGameLevel < ($protectiontime * 1000)) { - message("".$lang['fl_noob_mess_n']."", $lang['fl_noob_title'], "fleet." . PHPEXT, 2); - } - - if ($MyGameLevel > ($HeGameLevel * $protectionmulti) AND - $TargetPlanet['id_owner'] != '' AND - $_POST['mission'] == 5 AND - $protection == 1 AND - $HeGameLevel < ($protectiontime * 1000)) { - message("".$lang['fl_noob_mess_n']."", $lang['fl_noob_title'], "fleet." . PHPEXT, 2); - } - - if ($MyGameLevel > ($HeGameLevel * $protectionmulti) AND - $TargetPlanet['id_owner'] != '' AND - $_POST['mission'] == 6 AND - $protection == 1 AND - $HeGameLevel < ($protectiontime * 1000)) { - message("".$lang['fl_noob_mess_n']."", $lang['fl_noob_title'], "fleet." . PHPEXT, 2); - } - - if (($MyGameLevel * $protectionmulti) < $HeGameLevel AND - $TargetPlanet['id_owner'] != '' AND - $_POST['mission'] == 1 AND - $protection == 1 AND - $MyGameLevel < ($protectiontime * 1000)) { - message("".$lang['fl_noob_mess_n']."", $lang['fl_noob_title'], "fleet." . PHPEXT, 2); - } - - if (($MyGameLevel * $protectionmulti) < $HeGameLevel AND - $TargetPlanet['id_owner'] != '' AND - $_POST['mission'] == 5 AND - $protection == 1 AND - $MyGameLevel < ($protectiontime * 1000)) { - message("".$lang['fl_noob_mess_n']."", $lang['fl_noob_title'], "fleet." . PHPEXT, 2); - } - - if (($MyGameLevel * $protectionmulti) < $HeGameLevel AND - $TargetPlanet['id_owner'] != '' AND - $_POST['mission'] == 6 AND - $protection == 1 AND - $MyGameLevel < ($protectiontime * 1000)) { - message("".$lang['fl_noob_mess_n']."", $lang['fl_noob_title'], "fleet." . PHPEXT, 2); - } - - if ($VacationMode AND $_POST['mission'] != 8) { - message("".$lang['fl_vacation_pla']."", $lang['fl_vacation_ttl'], "fleet." . PHPEXT, 2); - } - - $FlyingFleets = mysql_fetch_assoc(doquery("SELECT COUNT(fleet_id) as Number FROM {{table}} WHERE `fleet_owner`='{$user['id']}'", 'fleets')); - $ActualFleets = $FlyingFleets["Number"]; - if (($user[$resource[108]] + 1) <= $ActualFleets) { - message("Pas de slot disponible", "Erreur", "fleet." . PHPEXT, 1); - } - - if ($_POST['resource1'] + $_POST['resource2'] + $_POST['resource3'] < 1 AND $_POST['mission'] == 3) { - message("".$lang['fl_noenoughtgoods']."", $lang['type_mission'][3], "fleet." . PHPEXT, 1); - } - if ($_POST['mission'] != 15) { - if ($TargetPlanet['id_owner'] == '' AND $_POST['mission'] < 7) { - message ("". $lang['fl_bad_planet01'] ."", $lang['fl_error'], "fleet." . PHPEXT, 2); - } - if ($TargetPlanet['id_owner'] != '' AND $_POST['mission'] == 7) { - message ("". $lang['fl_bad_planet02'] ."", $lang['fl_error'], "fleet." . PHPEXT, 2); - } - if ($HeDBRec['ally_id'] != $MyDBRec['ally_id'] AND $_POST['mission'] == 4) { - message ("". $lang['fl_dont_stay_here'] ."", $lang['fl_error'], "fleet." . PHPEXT, 2); - } - if ($TargetPlanet['ally_deposit'] < 1 AND $HeDBRec != $MyDBRec AND $_POST['mission'] == 5) { - message ("". $lang['fl_no_allydeposit'] ."", $lang['fl_error'], "fleet." . PHPEXT, 2); - } - if (($TargetPlanet["id_owner"] == $CurrentPlanet["id_owner"]) AND ($_POST["mission"] == 1)) { - message ("". $lang['fl_no_self_attack'] ."", $lang['fl_error'], "fleet." . PHPEXT, 2); - } - if (($TargetPlanet["id_owner"] == $CurrentPlanet["id_owner"]) AND ($_POST["mission"] == 6)) { - message ("". $lang['fl_no_self_spy'] ."", $lang['fl_error'], "fleet." . PHPEXT, 2); - } - if (($TargetPlanet["id_owner"] != $CurrentPlanet["id_owner"]) AND ($_POST["mission"] == 4)) { - message ("". $lang['fl_only_stay_at_home'] ."", $lang['fl_error'], "fleet." . PHPEXT, 2); - } - } - - $missiontype = array( - 1 => $lang['type_mission'][1], - 2 => $lang['type_mission'][2], - 3 => $lang['type_mission'][3], - 4 => $lang['type_mission'][4], - 5 => $lang['type_mission'][5], - 6 => $lang['type_mission'][6], - 7 => $lang['type_mission'][7], - 8 => $lang['type_mission'][8], - 9 => $lang['type_mission'][9], - 15 => $lang['type_mission'][15], - ); - - $speed_possible = array(10, 9, 8, 7, 6, 5, 4, 3, 2, 1); - - $AllFleetSpeed = GetFleetMaxSpeed ($fleetarray, 0, $user); - $GenFleetSpeed = $_POST['speed']; - $SpeedFactor = $_POST['speedfactor']; - $MaxFleetSpeed = min($AllFleetSpeed); - - if (!in_array($GenFleetSpeed, $speed_possible)) { - message ("". $lang['fl_cheat_speed'] ."", $lang['fl_error'], "fleet." . PHPEXT, 2); - } - - $CurrentPlanet = doquery("SELECT * FROM {{table}} WHERE `id` = '".$user['current_planet']."';", 'planets', true); - - if ($MaxFleetSpeed != $_POST['speedallsmin']) { - message ("". $lang['fl_cheat_speed'] ."", $lang['fl_error'], "fleet." . PHPEXT, 2); - } - - if (!$_POST['planettype']) { - message ("". $lang['fl_no_planet_type'] ."", $lang['fl_error'], "fleet." . PHPEXT, 2); - } - - // Test de coherance de la destination (voir si elle se trouve dans les limites de l'univers connu - $error = 0; - $errorlist = ""; - if (!$_POST['galaxy'] || !is_numeric($_POST['galaxy']) || $_POST['galaxy'] > MAX_GALAXY_IN_WORLD || $_POST['galaxy'] < 1) { - $error++; - $errorlist .= $lang['fl_limit_galaxy']; - } - if (!$_POST['system'] || !is_numeric($_POST['system']) || $_POST['system'] > MAX_SYSTEM_IN_GALAXY || $_POST['system'] < 1) { - $error++; - $errorlist .= $lang['fl_limit_system']; - } - if (!$_POST['planet'] || !is_numeric($_POST['planet']) || $_POST['planet'] > MAX_PLANET_IN_SYSTEM+1 || $_POST['planet'] < 1) { - $error++; - $errorlist .= $lang['fl_limit_planet']; - } - - if ($error > 0) { - message ("
    " . $errorlist . "
", $lang['fl_error'], "fleet." . PHPEXT, 2); - } - - // La flotte part bien de la planete courrante ?? - if ($_POST['thisgalaxy'] != $CurrentPlanet['galaxy'] | - $_POST['thissystem'] != $CurrentPlanet['system'] | - $_POST['thisplanet'] != $CurrentPlanet['planet'] | - $_POST['thisplanettype'] != $CurrentPlanet['planet_type']) { - message ("". $lang['fl_cheat_origine'] ."", $lang['fl_error'], "fleet." . PHPEXT, 2); - } - - if (!isset($fleetarray)) { - message ("". $lang['fl_no_fleetarray'] ."", $lang['fl_error'], "fleet." . PHPEXT, 2); - } - - $distance = GetTargetDistance ( $_POST['thisgalaxy'], $_POST['galaxy'], $_POST['thissystem'], $_POST['system'], $_POST['thisplanet'], $_POST['planet'] ); - $duration = GetMissionDuration ( $GenFleetSpeed, $MaxFleetSpeed, $distance, $SpeedFactor ); - $consumption = GetFleetConsumption ( $fleetarray, $SpeedFactor, $duration, $distance, $MaxFleetSpeed, $user ); - - $fleet['start_time'] = $duration + time(); - if ($_POST['mission'] == 15) { - $StayDuration = $_POST['expeditiontime'] * 3600; - $StayTime = $fleet['start_time'] + $_POST['expeditiontime'] * 3600; - } elseif ($_POST['mission'] == 5) { - $StayDuration = $_POST['holdingtime'] * 3600; - $StayTime = $fleet['start_time'] + $_POST['holdingtime'] * 3600; - } else { - $StayDuration = 0; - $StayTime = 0; - } - $fleet['end_time'] = $StayDuration + (2 * $duration) + time(); - $FleetStorage = 0; - $FleetShipCount = 0; - $fleet_array = ""; - $FleetSubQRY = ""; - - foreach ($fleetarray as $Ship => $Count) { - $FleetStorage += $pricelist[$Ship]["capacity"] * $Count; - $FleetShipCount += $Count; - $fleet_array .= $Ship .",". $Count .";"; - $FleetSubQRY .= "`".$resource[$Ship] . "` = `" . $resource[$Ship] . "` - " . $Count . " , "; - } - - $FleetStorage -= $consumption; - $StorageNeeded = 0; - if ($_POST['resource1'] < 1) { - $TransMetal = 0; - } else { - $TransMetal = $_POST['resource1']; - $StorageNeeded += $TransMetal; - } - if ($_POST['resource2'] < 1) { - $TransCrystal = 0; - } else { - $TransCrystal = $_POST['resource2']; - $StorageNeeded += $TransCrystal; - } - if ($_POST['resource3'] < 1) { - $TransDeuterium = 0; - } else { - $TransDeuterium = $_POST['resource3']; - $StorageNeeded += $TransDeuterium; - } - - $StockMetal = $CurrentPlanet['metal']; - $StockCrystal = $CurrentPlanet['crystal']; - $StockDeuterium = $CurrentPlanet['deuterium']; - $StockDeuterium -= $consumption; - - $StockOk = false; - if ($StockMetal >= $TransMetal) { - if ($StockCrystal >= $TransCrystal) { - if ($StockDeuterium >= $TransDeuterium) { - $StockOk = true; - } - } - } - if ( !$StockOk ) { - message ("". $lang['fl_noressources'] . pretty_number($consumption) ."", $lang['fl_error'], "fleet." . PHPEXT, 2); - } - - if ( $StorageNeeded > $FleetStorage) { - message ("". $lang['fl_nostoragespa'] . pretty_number($StorageNeeded - $FleetStorage) ."", $lang['fl_error'], "fleet." . PHPEXT, 2); - } - - if ($TargetPlanet['id_level'] > $user['authlevel']) { - $Allowed = true; - switch ($_POST['mission']){ - case 1: - case 2: - case 6: - case 9: - $Allowed = false; - break; - case 3: - case 4: - case 5: - case 7: - case 8: - case 15: - break; - default: - } - if ($Allowed == false) { - message ("". $lang['fl_adm_attak'] ."", $lang['fl_warning'], "fleet." . PHPEXT, 2); - } - } - - // ecriture de l'enregistrement de flotte (a partir de l�, y a quelque chose qui vole et c'est toujours sur la planete d'origine) - $QryInsertFleet = "INSERT INTO {{table}} SET "; - $QryInsertFleet .= "`fleet_owner` = '". $user['id'] ."', "; - $QryInsertFleet .= "`fleet_mission` = '". $_POST['mission'] ."', "; - $QryInsertFleet .= "`fleet_amount` = '". $FleetShipCount ."', "; - $QryInsertFleet .= "`fleet_array` = '". $fleet_array ."', "; - $QryInsertFleet .= "`fleet_start_time` = '". $fleet['start_time'] ."', "; - $QryInsertFleet .= "`fleet_start_galaxy` = '". intval($_POST['thisgalaxy']) ."', "; - $QryInsertFleet .= "`fleet_start_system` = '". intval($_POST['thissystem']) ."', "; - $QryInsertFleet .= "`fleet_start_planet` = '". intval($_POST['thisplanet']) ."', "; - $QryInsertFleet .= "`fleet_start_type` = '". intval($_POST['thisplanettype']) ."', "; - $QryInsertFleet .= "`fleet_end_time` = '". $fleet['end_time'] ."', "; - $QryInsertFleet .= "`fleet_end_stay` = '". $StayTime ."', "; - $QryInsertFleet .= "`fleet_end_galaxy` = '". intval($_POST['galaxy']) ."', "; - $QryInsertFleet .= "`fleet_end_system` = '". intval($_POST['system']) ."', "; - $QryInsertFleet .= "`fleet_end_planet` = '". intval($_POST['planet']) ."', "; - $QryInsertFleet .= "`fleet_end_type` = '". intval($_POST['planettype']) ."', "; - $QryInsertFleet .= "`fleet_resource_metal` = '". intval($TransMetal) ."', "; - $QryInsertFleet .= "`fleet_resource_crystal` = '". intval($TransCrystal) ."', "; - $QryInsertFleet .= "`fleet_resource_deuterium` = '". intval($TransDeuterium) ."', "; - $QryInsertFleet .= "`fleet_target_owner` = '". $TargetPlanet['id_owner'] ."', "; - $QryInsertFleet .= "`start_time` = '". time() ."';"; - doquery( $QryInsertFleet, 'fleets'); - - - $CurrentPlanet["metal"] = $CurrentPlanet["metal"] - $TransMetal; - $CurrentPlanet["crystal"] = $CurrentPlanet["crystal"] - $TransCrystal; - $CurrentPlanet["deuterium"] = $CurrentPlanet["deuterium"] - $TransDeuterium; - $CurrentPlanet["deuterium"] = $CurrentPlanet["deuterium"] - $consumption; - - $QryUpdatePlanet = "UPDATE {{table}} SET "; - $QryUpdatePlanet .= $FleetSubQRY; - $QryUpdatePlanet .= "`metal` = '". $CurrentPlanet["metal"] ."', "; - $QryUpdatePlanet .= "`crystal` = '". $CurrentPlanet["crystal"] ."', "; - $QryUpdatePlanet .= "`deuterium` = '". $CurrentPlanet["deuterium"] ."' "; - $QryUpdatePlanet .= "WHERE "; - $QryUpdatePlanet .= "`id` = '". $CurrentPlanet['id'] ."'"; - - // Mise a jours de l'enregistrement de la planete de depart (a partir de là, y a quelque chose qui vole et ce n'est plus sur la planete de depart) - doquery("LOCK TABLE {{table}} WRITE", 'planets'); - doquery ($QryUpdatePlanet, "planets"); - doquery("UNLOCK TABLES", ''); -// doquery("FLUSH TABLES", ''); - - // Un peu de blabla pour l'utilisateur, affichage d'un joli tableau de la flotte expedi�e - $page = "
"; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - $page .= ""; - - foreach ($fleetarray as $Ship => $Count) { - $page .= ""; - $page .= ""; - $page .= ""; - } - $page .= "
". $lang['fl_fleet_send'] ."
". $lang['fl_mission'] ."". $missiontype[$_POST['mission']] ."
". $lang['fl_dist'] ."". pretty_number($distance) ."
". $lang['fl_speed'] ."". pretty_number($_POST['speedallsmin']) ."
". $lang['fl_deute_need'] ."". pretty_number($consumption) ."
". $lang['fl_from'] ."". $_POST['thisgalaxy'] .":". $_POST['thissystem']. ":". $_POST['thisplanet'] ."
". $lang['fl_dest'] ."". $_POST['galaxy'] .":". $_POST['system'] .":". $_POST['planet'] ."
". $lang['fl_time_go'] ."". date("M D d H:i:s", $fleet['start_time']) ."
". $lang['fl_time_back'] ."". date("M D d H:i:s", $fleet['end_time']) ."
". $lang['fl_title'] ."
". $lang['tech'][$Ship] ."". pretty_number($Count) ."
"; - - // Provisoire - sleep (1); - - $planetrow = doquery ("SELECT * FROM {{table}} WHERE `id` = '". $CurrentPlanet['id'] ."';", 'planets', true); - - display($page, $lang['fl_title']); - -// Updated by Chlorel. 16 Jan 2008 (String extraction, bug corrections, code uniformisation -// Updated by -= MoF =- for Deutsches Ugamela Forum -// 06.12.2007 - 08:39 -// Open Source -// (c) by MoF - -?> \ No newline at end of file diff --git a/frames.php b/frames.php deleted file mode 100644 index c6b5b8c..0000000 --- a/frames.php +++ /dev/null @@ -1,53 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -defined('DEPRECATION') || define('DEPRECATION', false); -defined('DEBUG') || define('DEBUG', false); - -require_once dirname(__FILE__) .'/common.php'; - -Legacies_Core_ErrorProfiler::unregister(true); -?> - - - - - XNova:Legacies - - - - - - <body> - <p>Votre navigateur ne gère pas les frames.</p> - </body> - - - diff --git a/galaxy.php b/galaxy.php deleted file mode 100644 index 123be8f..0000000 --- a/galaxy.php +++ /dev/null @@ -1,163 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -define('INSIDE' , true); -define('INSTALL' , false); -require_once dirname(__FILE__) .'/common.php'; - - includeLang('galaxy'); - - $CurrentPlanet = doquery("SELECT * FROM {{table}} WHERE `id` = '". $user['current_planet'] ."';", 'planets', true); - $lunarow = doquery("SELECT * FROM {{table}} WHERE `id` = '". $user['current_luna'] ."';", 'lunas', true); - $galaxyrow = doquery("SELECT * FROM {{table}} WHERE `id_planet` = '". $CurrentPlanet['id'] ."';", 'galaxy', true); - - $dpath = (!$user["dpath"]) ? DEFAULT_SKINPATH : $user["dpath"]; - $fleetmax = $user['computer_tech'] + 1; - $CurrentPlID = $CurrentPlanet['id']; - $CurrentMIP = $CurrentPlanet['interplanetary_misil']; - $CurrentRC = $CurrentPlanet['recycler']; - $CurrentSP = $CurrentPlanet['spy_sonde']; - $HavePhalanx = $CurrentPlanet['phalanx']; - $CurrentSystem = $CurrentPlanet['system']; - $CurrentGalaxy = $CurrentPlanet['galaxy']; - $CanDestroy = $CurrentPlanet[$resource[213]] + $CurrentPlanet[$resource[214]]; - - $maxfleet = doquery("SELECT * FROM {{table}} WHERE `fleet_owner` = '". $user['id'] ."';", 'fleets'); - $maxfleet_count = mysql_num_rows($maxfleet); - - CheckPlanetUsedFields($CurrentPlanet); - CheckPlanetUsedFields($lunarow); - - if (!isset($mode)) { - if (isset($_GET['mode'])) { - $mode = intval($_GET['mode']); - } else { - $mode = 0; - } - } - - $galaxy = 1; - $system = 1; - $planet = null; - - if ($mode == 0) { - $galaxy = $CurrentGalaxy; - $system = $CurrentSystem; - } elseif ($mode == 1 || $mode == 3) { - if (isset($_POST["galaxyLeft"])) { - if (!isset($_POST["galaxy"]) || $_POST["galaxy"] <= 1 || $_POST["galaxy"] > MAX_GALAXY_IN_WORLD) { - $galaxy = 1; - } else { - $galaxy = intval($_POST["galaxy"]) - 1; - } - } elseif (isset($_POST["galaxyRight"])) { - if (!isset($_POST["galaxy"]) || $_POST["galaxy"] >= MAX_GALAXY_IN_WORLD) { - $galaxy = MAX_GALAXY_IN_WORLD; - } else { - $galaxy = intval($_POST["galaxy"]) + 1; - } - } else if (!isset($_POST["galaxy"]) || $_POST["galaxy"] <= 1 || $_POST["galaxy"] > MAX_GALAXY_IN_WORLD) { - $galaxy = 1; - } else { - $galaxy = intval($_POST["galaxy"]); - } - - if (isset($_POST["systemLeft"])) { - if (!isset($_POST["system"]) || $_POST["system"] <= 1 || $_POST["system"] > MAX_SYSTEM_IN_GALAXY) { - $system = 1; - } else { - $system = intval($_POST["system"]) - 1; - } - } elseif (isset($_POST["systemRight"])) { - if (!isset($_POST["system"]) || $_POST["system"] >= MAX_SYSTEM_IN_GALAXY) { - $system = MAX_SYSTEM_IN_GALAXY; - } else { - $system = intval($_POST["system"]) + 1; - } - } else if (!isset($_POST["system"]) || $_POST["system"] <= 1 || $_POST["system"] > MAX_SYSTEM_IN_GALAXY) { - $system = 1; - } else { - $system = intval($_POST["system"]); - } - } elseif ($mode == 2) { - if (!isset($_POST["galaxy"]) || $_POST["galaxy"] <= 0) { - $galaxy = 1; - } else if ($_POST["galaxy"] >= MAX_GALAXY_IN_WORLD) { - $galaxy = MAX_GALAXY_IN_WORLD; - } else { - $galaxy = intval($_POST["galaxy"]) + 1; - } - - if (!isset($_POST["system"]) || $_POST["system"] <= 0) { - $system = 1; - } else if ($_POST["system"] >= MAX_SYSTEM_IN_GALAXY) { - $system = MAX_SYSTEM_IN_GALAXY; - } else { - $system = intval($_POST["system"]) + 1; - } - - if (!isset($_POST["planet"]) || $_POST["planet"] <= 0) { - $planet = 1; - } else if ($_POST["planet"] >= MAX_PLANET_IN_SYSTEM) { - $planet = MAX_PLANET_IN_SYSTEM; - } else { - $planet = intval($_POST["planet"]) + 1; - } - } - - $planetcount = 0; - $lunacount = 0; - - $page = InsertGalaxyScripts($CurrentPlanet); - - $page .= "

"; - $page .= ShowGalaxySelector ( $galaxy, $system ); - - if ($mode == 2) { - $page .= ShowGalaxyMISelector($galaxy, $system, $planet, $CurrentPlanet['id'], $CurrentMIP); - } - - $page .= ""; - - $page .= ShowGalaxyTitles($galaxy, $system); - $page .= ShowGalaxyRows($galaxy, $system); - $page .= ShowGalaxyFooter($galaxy, $system, $CurrentMIP, $CurrentRC, $CurrentSP); - - $page .= "
"; - - display ($page, $lang[''], false, '', false); - -// ----------------------------------------------------------------------------------------------------------- -// History version -// 1.0 - Created by Perberos -// 1.1 - Modified by -MoF- (UGamela germany) -// 1.2 - 1er Nettoyage Chlorel ... -// 1.3 - 2eme Nettoyage Chlorel ... Mise en fonction et debuging complet -?> \ No newline at end of file diff --git a/includes/application/code/core/Legacies.php b/includes/application/code/core/Legacies.php deleted file mode 100644 index ed575f7..0000000 --- a/includes/application/code/core/Legacies.php +++ /dev/null @@ -1,219 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -/** - * Bootstrap class, used to access main and global functionalities - * - * @package Legacies - * @category core - */ -class Legacies -{ - /** - * Static list of application event listeners - * - * @var array - */ - private static $_listeners = array(); - - /** - * Static list of all locale translators - * - * @var array - */ - private static $_translators = array(); - - /** - * HTTP request management object - * - * @var Legacies_Core_Controller_Request_Http - */ - protected static $_request = null; - - /** - * HTTP response management object - * - * @var Legacies_Core_Controller_Response - */ - protected static $_response = null; - - /** - * The current timestamp - * - * @var int - */ - protected static $_now = null; - - /** - * Default locale identifier - * - * @var string - */ - protected static $_defaultLocale = 'fr_FR'; - - /** - * Registers an event listener to be called later in the application. - * - * @param string $event The event identifier - * @param callback $listener The event callback to be called - */ - public static function registerListener($event, $listener) - { - if (!isset(self::$_listeners[$event])) { - self::$_listeners[$event] = array(); - } - self::$_listeners[$event][] = $listener; - } - - /** - * Clear all event listeners - */ - public static function clearAllListeners() - { - self::$_listeners = array(); - } - - /** - * Clear a specific event's listeners - * - * @param unknown_type $event - */ - public static function clearEventListeners($event) - { - if (isset(self::$_listeners[$event])) { - self::$_listeners[$event] = array(); - } - } - - /** - * Dispatches an event, calls all callbacks that were previously registered - * - * @param string $event The event identifier - * @param array $params The event params - */ - public static function dispatchEvent($event, $params) - { - $eventObject = new Legacies_Core_Event($params); - - if (!isset(self::$_listeners[$event])) { - return $eventObject; - } - - foreach (self::$_listeners[$event] as $listener) { - call_user_func($listener, $eventObject); - } - - return $eventObject; - } - - /** - * - * Enter description here ... - * @param unknown_type $namespace - * @return Legacies_Core_Model_Session - */ - public static function getSession($namespace) - { - return Legacies_Core_Model_Session::factory($namespace); - } - - public static function getTranslator($locale = null) - { - if ($locale === null) { - $locale = self::getDefaultLocale(); - } - - if (!isset($translator[$locale])) { - $path = dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'locale'; - $translator[$locale] = new Legacies_Core_Model_Translator($path, $locale); - } - return $translator[$locale]; - } - - public static function translate($locale, $message, Array $args) - { - return self::getTranslator($locale)->translateArgs($message, $args); - } - - public static function __($message, $_ = null) - { - $args = func_get_args(); - array_shift($args); - - return self::getTranslator(self::getDefaultLocale())->translateArgs($message, $args); - } - - public static function setDefaultLocale($locale) - { - $oldLocale = self::$_defaultLocale; - self::$_defaultLocale = $locale; - - return $oldLocale; - } - - public static function getDefaultLocale() - { - return self::$_defaultLocale; - } - - public static function now() - { - if (self::$_now === null) { - self::$_now = time(); - } - return self::$_now; - } - - public static function getRequest() - { - if (self::$_request === null) { - self::$_request = new Legacies_Core_Controller_Request_Http(); - } - return self::$_request; - } - - public static function setRequest($request) - { - self::$_request = $request; - } - - public static function getResponse() - { - if (self::$_response === null) { - self::$_response = new Legacies_Core_Controller_Response_Http(); - } - return self::$_response; - } - - public static function setResponse($response) - { - self::$_response = $response; - } -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Core/Block/Html/Form.php b/includes/application/code/core/Legacies/Core/Block/Html/Form.php deleted file mode 100644 index 92f0098..0000000 --- a/includes/application/code/core/Legacies/Core/Block/Html/Form.php +++ /dev/null @@ -1,11 +0,0 @@ -getFormKey(true); - } -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Core/Block/Html/Head.php b/includes/application/code/core/Legacies/Core/Block/Html/Head.php deleted file mode 100644 index 7580264..0000000 --- a/includes/application/code/core/Legacies/Core/Block/Html/Head.php +++ /dev/null @@ -1,145 +0,0 @@ -_items[$type])) { - $this->_items[$type] = array(); - } - $this->_items[$type][] = $options; - - return $this; - } - - public function addJs($script, $type = 'text/javascript', Array $options = array()) - { - $options['type'] = $type; - $options['path'] = $script; - - $this->addItem(self::TYPE_GLOBAL_JS, $options); - - return $this; - } - - public function addCss($stylesheet, $type = 'text/css', $condition = null, Array $options = array()) - { - $options['type'] = $type; - $options['path'] = $stylesheet; - $options['condition'] = $condition; - - $this->addItem(self::TYPE_SKIN_CSS, $options); - - return $this; - } - - public function addSkinJs($script, $type = 'text/javascript', Array $options = array()) - { - $options['type'] = $type; - $options['path'] = $script; - - $this->addItem(self::TYPE_SKIN_JS, $options); - - return $this; - } - - public function addInlineJs($content, $type = 'text/javascript', Array $options = array()) - { - $options['type'] = $type; - $options['content'] = $content; - - $this->addItem(self::TYPE_INLINE_JS, $options); - - return $this; - } - - public function addInlineCss($content, $type = 'text/css', Array $options = array()) - { - $options['type'] = $type; - $options['path'] = $path; - $options['content'] = $content; - - $this->addItem(self::TYPE_INLINE_CSS, $options); - - return $this; - } - - public function getCss() - { - if (isset($this->_items[self::TYPE_SKIN_CSS])) { - return $this->_items[self::TYPE_SKIN_CSS]; - } - return array(); - } - - public function getInlineCss() - { - if (isset($this->_items[self::TYPE_INLINE_CSS])) { - return $this->_items[self::TYPE_INLINE_CSS]; - } - return array(); - } - - public function getJs() - { - if (isset($this->_items[self::TYPE_GLOBAL_JS])) { - return $this->_items[self::TYPE_GLOBAL_JS]; - } - return array(); - } - - public function getSkinJs() - { - if (isset($this->_items[self::TYPE_SKIN_JS])) { - return $this->_items[self::TYPE_SKIN_JS]; - } - return array(); - } - - public function getInlineJs() - { - if (isset($this->_items[self::TYPE_INLINE_JS])) { - return $this->_items[self::TYPE_INLINE_JS]; - } - return array(); - } - - public function renderCss() - { - $render = ''; - foreach ($this->getCss() as $css) { - if (!isset($css['media'])) { - $css['media'] = 'all'; - } - $render .=<< -HTML_EOF; - } - return $render; - } - - public function renderJs() - { - $render = ''; - foreach ($this->getJs() as $js) { - if (!isset($css['media'])) { - $css['media'] = 'all'; - } - $render .=<< -HTML_EOF; - } - return $render; - } -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Core/Block/Html/Navigation.php b/includes/application/code/core/Legacies/Core/Block/Html/Navigation.php deleted file mode 100644 index 36cfe24..0000000 --- a/includes/application/code/core/Legacies/Core/Block/Html/Navigation.php +++ /dev/null @@ -1,66 +0,0 @@ -_getNode($explodedPath); - - $child = $this->getLayout() - ->createBlock('core/html.navigation.link', $this->getNameInLayout() . '.' . $baseName, array( - 'url' => array( - 'uri' => $uri, - 'params' => $params - ), - 'label' => $label, - 'title' => $title, - 'classes' => $classes - )); - $parent->setPartial($baseName, $child); - - if ($template !== null) { - $child->setTemplate($template); - } - - return $this; - } - - public function setNodeTitle($path, $title) - { - return $this->getNode($path)->setTitle($title); - } - - public function setNodeTemplate($path, $template) - { - return $this->getNode($path)->setTemplate($template); - } - - public function getNode($path) - { - return $this->_getNode(explode('/', $path)); - } - - protected function _getNode($explodedPath) - { - $name = array_shift($explodedPath); - - if ($this->hasPartial($name)) { - $child = $this->getPartial($name)->_getNode($explodedPath); - } else { - $child = $this->getLayout() - ->createBlock('core/html.navigation.node', $this->getNameInLayout() . '.' . $name); - } - - if ($child instanceof Legacies_Core_Block_Html_Navigation_Link) { - throw new RuntimeException('Node is a link. Could not append a child node to a link node.'); - } - - if (count($explodedPath) == 0) { - return $child; - } - return $child->_getNode($explodedPath); - } -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Core/Block/Html/Navigation/Link.php b/includes/application/code/core/Legacies/Core/Block/Html/Navigation/Link.php deleted file mode 100644 index f70e493..0000000 --- a/includes/application/code/core/Legacies/Core/Block/Html/Navigation/Link.php +++ /dev/null @@ -1,116 +0,0 @@ -_template !== null) { - return $this->_template; - } - return 'page/html/navigation/link.phtml'; - } - - public function setLabel($label) - { - $this->_label = $label; - - return $this; - } - - public function getLabel() - { - return $this->_label; - } - - public function setTitle($title) - { - $this->_title = $title; - - return $this; - } - - public function getTitle() - { - return $this->_title; - } - - public function setUrl($uri, $params = array()) - { - $this->_uri = $uri; - $this->_params = $params; - - return $this; - } - - public function getLinkUrl($moreParams = array()) - { - $params = array_merge($this->_params, $moreParams); - return $this->getUrl($this->_uri, $params); - } - - public function addClass($class) - { - $this->_classes[] = $class; - - return $this; - } - - public function clearClasses() - { - $this->_classes = array(); - - return $this; - } - - public function renderClasses($moreClasses) - { - $classes = array_merge($this->_classes, $moreClasses); - return implode(' ', $classes); - } - - public function __construct(Array $data = array()) - { - if (isset($data['label'])) { - $this->setLabel($data['label']); - unset($data['label']); - } - - if (isset($data['title'])) { - $this->setTitle($data['title']); - unset($data['title']); - } - - if (isset($data['url'])) { - if (is_array($data['url']) && isset($data['url']['uri'])) { - if (isset($data['url']['params'])) { - $this->setUrl($data['url']['uri'], $data['url']['params']); - } else { - $this->setUrl($data['url']['uri']); - } - } else { - $this->setUrl($data['url']); - } - unset($data['url']); - } - - if (isset($data['classes'])) { - $classes = (array) $data['classes']; - unset($data['classes']); - - foreach ($classes as $class) { - $this->set($class); - } - } - - parent::__construct($data); - - return $this; - } -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Core/Block/Template.php b/includes/application/code/core/Legacies/Core/Block/Template.php deleted file mode 100644 index 2cbf100..0000000 --- a/includes/application/code/core/Legacies/Core/Block/Template.php +++ /dev/null @@ -1,6 +0,0 @@ -setTableName($tableName); - } - if ($entityClassName != null) { - $this->setEntityClassName($entityClassName); - } - } - - protected function _init() - { - return $this; - } - - public function setTableName($tableName) - { - if (!is_array($tableName)) { - $this->_tableName = $tableName; - } else { - $this->_tableName = current($tableName); - $this->_tableAlias = key($tableName); - } - - return $this; - } - - public function getTableName() - { - return $this->_tableName; - } - - public function setEntityClassName($entityClassName) - { - $this->_entityClassName = $entityClassName; - - return $this; - } - - public function getEntityClassName() - { - return $this->_entityClassName; - } - - public function quote($data) - { - static $database = null; - - if ($database === null) { - $database = Legacies_Database::getSingleton(); - } - - return $database->quote($data); - } - - public function column($column = '*', $alias = null) - { - if (is_array($column)) { - foreach ($column as $alias => $field) { - if (is_int($alias)) { - $this->_columns[] = array($field); - } else { - $this->_columns[] = array($alias => $field); - } - } - } else if ($alias === null || is_int($alias)) { - $this->_columns[] = array($column); - } else { - $this->_columns[] = array($alias => $column); - } - - return $this; - } - - public function where($condition) - { - $this->_where[] = $condition; - - return $this; - } - - public function join($table, $condition, $fields = array('*'), $mode = 'INNER') - { - static $database = null; - - if ($database === null) { - $database = Legacies_Database::getSingleton(); - } - - if (is_array($table)) { - $alias = key($table); - $table = current($table); - - foreach ($fields as $fieldAlias => $fieldName) { - $this->column("{$alias}.{$field}", $fieldAlias); - } - - $this->_join[] = "{$mode} JOIN {$database->getTable($table)} AS {$alias} ON {$condition}"; - } else { - foreach ($fields as $field) { - $this->column("{$field}"); - } - - $this->_join[] = "{$mode} JOIN {$database->getTable($table)} ON {$condition}"; - } - - return $this; - } - - public function order($field, $direction = 'ASC') - { - $this->_order[] = "{$field} {$direction}"; - - return $this; - } - - public function union($collection) - { - $this->_union[] = $collection; - - return $this; - } - - public function limit($limit, $offset = null) - { - $this->_limit = intval($limit); - $this->_offset = $offset; - - return $this; - } - - public function group($groupField) - { - $this->_group[] = $groupField; - - return $this; - } - - protected function _prepareSql() - { - if (empty($this->_union)) { - $database = Legacies_Database::getSingleton(); - - $fields = array(); - foreach ($this->_columns as $field) { - $fieldName = current($field); - $fieldAlias = key($field); - if (is_string($fieldAlias)) { - $fields[] = "{$fieldName} AS {$fieldAlias}"; - } else { - $fields[] = $fieldName; - } - } - if (!empty($fields)) { - $fields = implode(", ", $fields); - } else { - $fields = '*'; - } - if (!empty($this->_where)) { - $where = 'WHERE (' . implode(") AND (", $this->_where) . ')'; - } else { - $where = ''; - } - $joinedTables = implode("\n ", $this->_join); - - $order = ''; - if (!empty($this->_order)) { - $order = 'ORDER BY ' . implode(", ", $this->_order); - } - $alias = ''; - if ($this->_tableAlias !== null) { - $alias = " AS {$this->_tableAlias}"; - } - $limit = ''; - if ($this->_limit) { - if ($this->_offset) { - $limit = "LIMIT {$this->_limit}, {$this->_offset}"; - } else { - $limit = "LIMIT {$this->_limit}"; - } - } - $group = ''; - if (!empty($this->_group)) { - $group = 'GROUP BY ' . implode(', ', $this->_group); - } - - return <<getTable($this->getTableName())}{$alias} - {$joinedTables} - {$where} - {$group} - {$order} - {$limit} -SQL_EOF; - } else { - $statements = array(); - foreach ($this->_union as $statement) { - $statements[] = $statement->_prepareSql(); - } - - $statements = '(' . implode(') UNION (', $statements) . ')'; - if (!empty($where)) { - $where = 'WHERE ' . implode(" AND ", $this->_where); - } else { - $where = ''; - } - $where = implode(" AND ", $this->_where); - - $limit = ''; - if ($this->_limit) { - if ($this->_offset) { - $limit = "LIMIT {$this->_limit}, {$this->_offset}"; - } else { - $limit = "LIMIT {$this->_limit}"; - } - } - - return <<_prepareSql(); - } - - protected function _load() - { - $sql = $this->_prepareSql(); - - $database = Legacies_Database::getSingleton(); - $statement = $database->prepare($sql); - - $args = func_get_args(); - $statement->execute(array_shift($args)); - - $this->_items = array(); - if (func_num_args() > 1) { - $reflection = new ReflectionClass(array_shift($args)); - } else { - $reflection = new ReflectionClass($this->getEntityClassName()); - } - - while ($row = $statement->fetch(PDO::FETCH_ASSOC)) { - $params = array_merge(array($row), $args); - $this->_items[] = $reflection->newInstanceArgs($params); - } - - return $this; - } - - protected function _save() - { - foreach ($this->_items as $child) { - $child->save(); - } - - return $this; - } - - protected function _delete() - { - foreach ($this->_items as $child) { - $child->delete(); - } - - return $this; - } - - public function getSize() - { - $clone = clone $this; - $clone->_fields = array(); - $clone->column('COUNT(*)'); - - $sql = $clone->_prepareSql(); - - $database = Legacies_Database::getSingleton(); - $statement = $database->prepare($sql); - - $args = func_get_args(); - $statement->execute(array_shift($args)); - return $statement->fetch(PDO::FETCH_COLUMN, 0); - } - - public function count() - { - return count($this->_items); - } - - public function current() - { - return current($this->_items); - } - - public function next() - { - next($this->_items); - - return $this; - } - - public function rewind() - { - reset($this->_items); - - return $this; - } - - public function key() - { - return key($this->_items); - } - - public function valid() - { - return current($this->_items) !== false; - } -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Core/Controller/Action.php b/includes/application/code/core/Legacies/Core/Controller/Action.php deleted file mode 100644 index 4bf9f30..0000000 --- a/includes/application/code/core/Legacies/Core/Controller/Action.php +++ /dev/null @@ -1,54 +0,0 @@ -_request; - } - - public function getResponse() - { - return $this->_response; - } - - protected function _forward($action, $controller = null, $module = null) - { - $request = $this->getRequest(); - - $request->setAction($action); - if ($controller !== null) { - $request->setController($controller); - if ($module != null) { - $request->setModule($module); - } - } - $request->setIsDispatched(false); - } - - protected function _redirect($url) - { - $this->getResponse() - ->setRawHeader('HTTP/1.1 302 Found') - ->setHeader('Location', $url) - ->setIsRedirect(true) - ; - - return $this; - } -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Core/Controller/Request/Http.php b/includes/application/code/core/Legacies/Core/Controller/Request/Http.php deleted file mode 100644 index bf9a879..0000000 --- a/includes/application/code/core/Legacies/Core/Controller/Request/Http.php +++ /dev/null @@ -1,86 +0,0 @@ -setData($key, $value); - } - - public function getParam($key, $default = null) - { - if ($this->hasData($key)) { - return $this->getData($key); - } - if (isset($_POST[$key])) { - return $_POST[$key]; - } - if (isset($_GET[$key])) { - return $_GET[$key]; - } - if (isset($_FILES[$key])) { - return $_FILES[$key]; - } - if (isset($_COOKIE[$key])) { - return $_COOKIE[$key]; - } - if (isset($_SERVER[$key])) { - return $_SERVER[$key]; - } - return $default; - } - - public function getQuery($key, $default = null) - { - if (!isset($_GET[$key])) { - return $default; - } - return $_GET[$key]; - } - - public function getFile($key, $default = null) - { - if (!isset($_FILES[$key])) { - return $default; - } - return $_FILES[$key]; - } - - public function getCookie($key, $default = null) - { - if (!isset($_COOKIE[$key])) { - return $default; - } - return unserialize(stripslashes($_COOKIE[$key])); - } - - public function getRawCookie($key, $default = null) - { - if (!isset($_COOKIE[$key])) { - return $default; - } - return $_COOKIE[$key]; - } - - public function getPost($key, $default = null) - { - if (!isset($_POST[$key])) { - return $default; - } - return $_POST[$key]; - } - - public function getServer($key, $default = null) - { - if (!isset($_SERVER[$key])) { - return $default; - } - return $_SERVER[$key]; - } -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Core/Email.php b/includes/application/code/core/Legacies/Core/Email.php deleted file mode 100644 index 8241c60..0000000 --- a/includes/application/code/core/Legacies/Core/Email.php +++ /dev/null @@ -1,32 +0,0 @@ -_prepareHeaders($headers); - } - - public function setHeader($name, $value) - { - $this->_headers[$name] = $value; - } - - protected function _prepareHeaders($headers) - { - foreach ($headers as $name => $value) { - $this->setHeader($name, $value); - } - - $this->addHeader('X-Mailer', 'PHP/' . PHP_VERSION . ' Legacies/' . VERSION); - $this->addHeader('Content-Transfer-Encoding', '7bit'); - $this->addHeader('Content-Type', 'text/plain; charset=utf-8'); - - return $this; - } -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Core/Entity.php b/includes/application/code/core/Legacies/Core/Entity.php deleted file mode 100644 index 2378c75..0000000 --- a/includes/application/code/core/Legacies/Core/Entity.php +++ /dev/null @@ -1,155 +0,0 @@ -_idFieldName = $fieldName; - - return $this; - } - - public function getIdFieldName() - { - return $this->_idFieldName; - } - - public function setTableName($tableName) - { - $this->_tableName = $tableName; - - return $this; - } - - public function getTableName() - { - return $this->_tableName; - } - - public function setId($id) - { - $this->setData($this->getIdFieldName(), $id); - - return $this; - } - - public function getId() - { - return $this->getData($this->getIdFieldName()); - } - - protected function _load() - { - $id = func_get_arg(0); - - $idFieldName = self::getIdFieldName(); - $database = Legacies_Database::getSingleton(); - - $sql =<<getTable(self::getTableName())} - WHERE {$idFieldName}=:id - LIMIT 1 -SQL_EOF; - $statement = $database->prepare($sql); - $statement->execute(array( - 'id' => $id - )); - - $datas = $statement->fetch(PDO::FETCH_ASSOC); - if (!is_array($datas) || empty($datas)) { - throw new Legacies_Core_Model_Exception('Could not load data: this id could not be found.'); - } - unset($datas[self::getIdFieldName()]); - - $this->_data = $datas; - $this->setId($id); - - return $this; - } - - protected function _save() - { - if ($this->getId() !== null) { - $fields = array(); - $values = array(); - foreach ($this->getAllDatas() as $field => $value) { - if ($field == self::getIdFieldName()) { - continue; - } - $fields[] = "{$field}=:{$field}"; - $values[$field] = $value; - } - - $fieldsImploded = implode(', ', $fields); - $idFieldName = self::getIdFieldName(); - $values[$idFieldName] = $this->getId(); - - $database = Legacies_Database::getSingleton(); - $sql =<<getTable(self::getTableName())} - SET {$fieldsImploded} - WHERE {$idFieldName}=:{$idFieldName} -SQL_EOF; - $statement = $database->prepare($sql); - - $statement->execute($values); - } else { - $datas = $this->getAllDatas(); - $fieldsImploded = implode(', ', array_keys($datas)); - - $tokens = array(); - $values = array(); - foreach ($datas as $field => $value) { - if ($field == self::getIdFieldName()) { - continue; - } - $tokens[] = ":{$field}"; - $values[$field] = $value; - } - $tokensImploded = implode(', ', $tokens); - - $database = Legacies_Database::getSingleton(); - $sql =<<getTable(self::getTableName())} ($fieldsImploded) - VALUES ({$tokensImploded}) -SQL_EOF; - $statement = $database->prepare($sql); - - $statement->execute($values); - - $this->setId($database->lastInsertId()); - } - - return $this; - } - - protected function _delete() - { - $fields = array(); - foreach ($this->getAllDatas() as $field => $value) { - if ($field == self::getIdFieldName()) { - continue; - } - $fields[] = "{$field}=:{$field}"; - } - - $fieldsImploded = implod(', ', $fields); - $idFieldName = self::getIdFieldName(); - $database = Legacies_Database::getSingleton(); - $sql =<<getTable(self::getTableName())} - WHERE {$idFieldName}=:{$idFieldName} -SQL_EOF; - - $statement->execute($this->getAllDatas()); - - return $this; - } -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Core/EntityInterface.php b/includes/application/code/core/Legacies/Core/EntityInterface.php deleted file mode 100644 index cc4e0ee..0000000 --- a/includes/application/code/core/Legacies/Core/EntityInterface.php +++ /dev/null @@ -1,13 +0,0 @@ -_errors[] = array( - 'time' => explode(' ', microtime()), - 'code' => $errno, - 'message' => $errstr, - 'file' => $errfile, - 'line' => $errline, - 'context' => $errcontext - ); - break; - - case E_USER_WARNING: - case E_WARNING: - $this->_warnings[] = array( - 'time' => explode(' ', microtime()), - 'code' => $errno, - 'message' => $errstr, - 'file' => $errfile, - 'line' => $errline, - 'context' => $errcontext - ); - break; - - case E_USER_NOTICE: - case E_NOTICE: - $this->_notices[] = array( - 'time' => explode(' ', microtime()), - 'code' => $errno, - 'message' => $errstr, - 'file' => $errfile, - 'line' => $errline, - 'context' => $errcontext - ); - break; - - default: - if (!isset($this->_otherErrors[$errno])) { - $this->_otherErrors[$errno] = array(); - } - - $this->_otherErrors[$errno][] = array( - 'time' => explode(' ', microtime()), - 'code' => $errno, - 'message' => $errstr, - 'file' => $errfile, - 'line' => $errline, - 'context' => $errcontext - ); - break; - } - - return true; - } - - public function exceptionManager($exception) - { - $this->_exceptions[] = $exception; - } - - protected function _renderError($error) - { - $types = array( - 0x0001 => 'E_ERROR', - 0x0002 => 'E_WARNING', - 0x0004 => 'E_PARSE', - 0x0008 => 'E_NOTICE', - 0x0010 => 'E_CORE_ERROR', - 0x0020 => 'E_CORE_WARNING', - 0x0040 => 'E_COMPILE_ERROR', - 0x0080 => 'E_COMPILE_WARNING', - 0x0100 => 'E_USER_ERROR', - 0x0200 => 'E_USER_WARNING', - 0x0400 => 'E_USER_NOTICE', - 0x0800 => 'E_STRICT', - 0x1000 => 'E_RECOVERABLE_ERROR', - 0x2000 => 'E_DEPRECATED', - 0x4000 => 'E_USER_DEPRECATED', - ); - - if (isset($error['code']) && isset($types[$error['code']])) { - $code = $types[$error['code']]; - } else { - $code = "Unknown ({$error['code']})"; - } - - $date = date('Y-m-d H:i:s', (int) $error['time'][1]); - $microsec = (int) ($error['time'][0] * 1000000); - - return <<'; - echo '

Debug profiler

'; - if (count($this->_errors) <= 0 && count($this->_warnings) <= 0 && - count($this->_notices) <= 0 && count($this->_otherErrors) <= 0 && - count($this->_exceptions) <= 0) { - echo '

Profiler was empty.

'; - } else { - echo '
';
-            foreach ($this->_errors as $error) {
-                echo $this->_renderError($error);
-            }
-            foreach ($this->_warnings as $error) {
-                echo $this->_renderError($error);
-            }
-            foreach ($this->_notices as $error) {
-                echo $this->_renderError($error);
-            }
-            foreach ($this->_otherErrors as $errorList) {
-                foreach ($errorList as $error) {
-                    echo $this->_renderError($error);
-                }
-            }
-            foreach ($this->_exceptions as $exception) {
-                echo $exception->getMessage() . PHP_EOL;
-                echo $exception->getTraceAsString();
-            }
-            echo '
'; - } - echo ''; - } - - public static function register() - { - set_error_handler(array(self::getSingleton(), 'errorManager')); - set_exception_handler(array(self::getSingleton(), 'exceptionManager')); - - if (self::$_isTraceRegistered === false && defined('DEBUG')) { - self::$_isTraceRegistered = true; - register_shutdown_function(array(self::getSingleton(), 'shutdownManager')); - } - } - - public static function unregister($force = false) - { - restore_error_handler(); - restore_exception_handler(); - - if ((self::$_isTraceRegistered && defined('DEBUG')) || $force) { - self::$_isTraceRegistered = false; - register_shutdown_function(array(self::getSingleton(), 'shutdownManager')); - } - } -} diff --git a/includes/application/code/core/Legacies/Core/Event.php b/includes/application/code/core/Legacies/Core/Event.php deleted file mode 100644 index 3031032..0000000 --- a/includes/application/code/core/Legacies/Core/Event.php +++ /dev/null @@ -1,6 +0,0 @@ - $layoutConfig) { - if ($this->hasData($layoutId)) { - $declared = $this->getData($layoutId); - - $layoutConfig = array_merge($declared, $layoutConfig); - } - - $this->setData($layoutId, $layoutConfig); - } - } - - return $this; - } - - public function _load() - { - $layoutId = func_get_arg(0); - - if (!$this->hasData($layoutId)) { - return $this; - } - - $layoutConfigs = array($this->getData($layoutId)); - if (isset($layoutConfigs[0]['update'])) { - $parent = $layoutConfigs[0]['update']; - - $i = 0; - while (true) { - $layoutConfigs[++$i] = $this->getData($parent); - - if (!isset($layoutConfigs[$i]['update'])) { - break; - } - $parent = $layoutConfigs[$i]['update']; - } - } - - $layoutUpdates = array(); - $layoutConfig = array(); - foreach (array_reverse($layoutConfigs) as $config) { - $layoutConfig = array_merge($layoutConfig, $config); - - if (isset($layoutConfig['reference'])) { - foreach ($layoutConfig['reference'] as $name => $update) { - if (!isset($layoutUpdates[$name])) { - $layoutUpdates[$name] = array(); - } - $layoutUpdates[$name][] = $update; - } - unset($layoutConfig['reference']); - } - } - unset($layoutConfigs, $layoutConfig['update']); - - $type = $layoutConfig['type']; - $name = isset($layoutConfig['name']) ? $layoutConfig['name'] : 'root'; - - $this->_view = $this->_createBlock($type, $name, $layoutConfig); - - foreach ($layoutUpdates as $block => $updates) { - if (!isset($this->_blocks[$block])) { - continue; - } - - $parent = $this->_blocks[$block]; - foreach ($updates as $update) { - if (isset($update['children'])) { - foreach ($update['children'] as $childName => $childConfig) { - $type = $childConfig['type']; - $alias = isset($childConfig['alias']) ? $childConfig['alias'] : $childName; - - $parent->$alias = $this->_createBlock($type, $childName, $childConfig); - } - } - } - } - - foreach ($layoutUpdates as $block => $updates) { - if (!isset($this->_blocks[$block])) { - continue; - } - - foreach ($updates as $update) { - if (isset($update['actions'])) { - $this->_callActions($this->_blocks[$block], $update['actions']); - } - } - } - - foreach ($this->_blocks as $block) { - $block->prepareLayout(); - } - } - - public function _save() - { - } - - public function _delete() - { - } - - protected function _resolveBlockClassType($type) - { - $offset = strpos($type, '/'); - if ($offset === false) { - return null; - } - - $module = substr($type, 0, $offset); - $block = substr($type, $offset + 1); - - $module = str_replace(' ', '', ucwords(str_replace('-', ' ', $module))); - $module = str_replace(' ', '_', ucwords(str_replace('.', ' ', $module))); - $block = str_replace(' ', '', ucwords(str_replace('-', ' ', $block))); - $block = str_replace(' ', '_', ucwords(str_replace('.', ' ', $block))); - - return 'Legacies_' . $module . '_Block_' . $block; - } - - public function createBlock($type, $name, $config = array()) - { - $instance = $this->_createBlock($type, $name, $config); - - $instance->prepareLayout(); - - return $instance; - } - - protected function _createBlock($type, $name, $config = array()) - { - $className = $this->_resolveBlockClassType($type); - - $children = array(); - if (isset($config['children'])) { - $children = $config['children']; - unset($config['children']); - } - $actions = array(); - if (isset($config['actions'])) { - $actions = $config['actions']; - unset($config['actions']); - } - - try { - $reflectionClass = new ReflectionClass($className); - - $instance = $reflectionClass->newInstance($config); - $this->_blocks[$name] = $instance; - $instance->setNameInLayout($name); - - $instance->setLayout($this); - - foreach ($children as $name => $config) { - if (isset($config['alias'])) { - $alias = $config['alias']; - } else { - $alias = $name; - } - - if (!isset($config['type'])) { - $instance->$alias = new Legacies_Core_View($config); - } else { - $instance->$alias = $this->_createBlock($config['type'], $name, $config); - } - } - } catch (ReflectionException $e) { - var_dump($e); - return null; - } - - $this->_callActions($instance, $actions); - - return $instance; - } - - protected function _callActions($block, $actions) - { - $reflectionClass = new ReflectionClass($block); - - foreach ($actions as $action) { - if (!isset($action['method'])) { - continue; - } - $method = $action['method']; - - $params = array(); - if (isset($action['params'])) { - $params = $action['params']; - } - - try { - $reflectionMethod = $reflectionClass->getMethod($method); - $requiredParameterCount = $reflectionMethod->getNumberOfRequiredParameters(); - $callParamaters = array(); - foreach ($reflectionMethod->getParameters() as $parameter) { - $paramterName = $parameter->getName(); - $paramterPosition = $parameter->getPosition(); - - if (isset($params[$paramterName])) { - $callParamaters[$paramterPosition] = $params[$paramterName]; - } else if ($parameter->isDefaultValueAvailable()) { - $callParamaters[$paramterPosition] = $parameter->getDefaultValue(); - //} else if (!$parameter->isOptionnal()) { - } else if ($paramterPosition <= $requiredParameterCount) { - throw new RuntimeException(); - } - } - - $reflectionMethod->invokeArgs($block, $callParamaters); - } catch (ReflectionException $e) { - continue; - } catch (RuntimeException $e) { - continue; - } - } - } - - public function getBlock($code) - { - if (isset($this->_blocks[$code])) { - return $this->_blocks[$code]; - } - return null; - } - - public function render() - { - foreach ($this->_blocks as $block) { - $block->beforeToHtml(); - } - unset($block); - - return $this->_view->render(); - } -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Core/Model.php b/includes/application/code/core/Legacies/Core/Model.php deleted file mode 100644 index 06f7bab..0000000 --- a/includes/application/code/core/Legacies/Core/Model.php +++ /dev/null @@ -1,158 +0,0 @@ -_data = $data; - - $this->_init(); - $this->_setOriginalData($this->_data); - } - - abstract protected function _init(); - - protected function _setOriginalData(Array $data) - { - $this->_originalData = $data; - } - - final public function save() - { - try { - $params = func_get_args(); - call_user_func_array(array($this, '_beforeSave'), $params); - call_user_func_array(array($this, '_save'), $params); - call_user_func_array(array($this, '_afterSave'), $params); - $this->_setOriginalData($this->_data); - } catch (PDOException $e) { - throw new Legacies_Core_Model_Exception('Could not save data: ' . $e->getMessage(), 0); - } - return $this; - } - - abstract protected function _save(); - - protected function _beforeSave() - { - Legacies::dispatchEvent('model.before-save', array('model' => $this)); - - if ($this->_eventPrefix !== null && $this->_eventObject !== null) { - Legacies::dispatchEvent($this->_eventPrefix . '.before-save', array($this->_eventObject => $this)); - } - - return $this; - } - - protected function _afterSave() - { - Legacies::dispatchEvent('model.after-save', array('model' => $this)); - - if ($this->_eventPrefix !== null && $this->_eventObject !== null) { - Legacies::dispatchEvent($this->_eventPrefix . '.after-save', array($this->_eventObject => $this)); - } - - return $this; - } - - final public function load() - { - try { - $params = func_get_args(); - call_user_func_array(array($this, '_beforeLoad'), $params); - call_user_func_array(array($this, '_load'), $params); - call_user_func_array(array($this, '_afterLoad'), $params); - $this->_setOriginalData($this->_data); - } catch (PDOException $e) { - throw new Legacies_Core_Model_Exception('Could not load data: ' . $e->getMessage(), 0); - } - return $this; - } - - abstract protected function _load(); - - protected function _beforeLoad() - { - Legacies::dispatchEvent('model.before-load', array('model' => $this)); - - if ($this->_eventPrefix !== null && $this->_eventObject !== null) { - Legacies::dispatchEvent($this->_eventPrefix . '.before-load', array($this->_eventObject => $this)); - } - - return $this; - } - - protected function _afterLoad() - { - Legacies::dispatchEvent('model.after-load', array('model' => $this)); - - if ($this->_eventPrefix !== null && $this->_eventObject !== null) { - Legacies::dispatchEvent($this->_eventPrefix . '.after-load', array($this->_eventObject => $this)); - } - - return $this; - } - - final public function delete() - { - try { - $params = func_get_args(); - call_user_func_array(array($this, '_beforeDelete'), $params); - call_user_func_array(array($this, '_delete'), $params); - call_user_func_array(array($this, '_afterDelete'), $params); - } catch (PDOException $e) { - throw new Legacies_Core_Model_Exception('Could not delete entity: ' . $e->getMessage(), 0); - } - return $this; - } - - abstract protected function _delete(); - - protected function _beforeDelete() - { - Legacies::dispatchEvent('model.before-delete', array('model' => $this)); - - if ($this->_eventPrefix !== null && $this->_eventObject !== null) { - Legacies::dispatchEvent($this->_eventPrefix . '.before-delete', array($this->_eventObject => $this)); - } - - return $this; - } - - protected function _afterDelete() - { - Legacies::dispatchEvent('model.after-delete', array('model' => $this)); - - if ($this->_eventPrefix !== null && $this->_eventObject !== null) { - Legacies::dispatchEvent($this->_eventPrefix . '.after-delete', array($this->_eventObject => $this)); - } - - return $this; - } - - public function __set($key, $value) - { - return $this->setData($key, $value); - } - - public function __get($key) - { - return $this->getData($key); - } - - public function __unset($key) - { - return $this->unsetData($key); - } - - public function __isset($key) - { - return $this->hasData($key); - } -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Core/Model/Config.php b/includes/application/code/core/Legacies/Core/Model/Config.php deleted file mode 100644 index 6f365e3..0000000 --- a/includes/application/code/core/Legacies/Core/Model/Config.php +++ /dev/null @@ -1,88 +0,0 @@ -load(); - } - - protected function _load() - { - $database = Legacies_Database::getSingleton(); - - $sql =<<getTable('config')} AS config -SQL_EOF; - - $attributeName = null; - $attributeValue = null; - - $statement = $database->prepare($sql); - $statement->execute(); - - $statement->bindColumn('attribute', $attributeName, PDO::PARAM_STR); - $statement->bindColumn('value', $attributeValue, PDO::PARAM_STR); - - while ($statement->fetch(PDO::FETCH_BOUND)) { - $this->setData($attributeName, $attributeValue); - } - return $this; - } - - protected function _save() - { - $database = Legacies_Database::getSingleton(); - $fields = array(); - - $sql =<<prepare($sql); - - foreach ($this->getAllDatas() as $attributeName => $attributeValue) { - $statement->execute(array( - 'name' => $attributeName, - 'value' => $attributeValue - )); - } - - return $this; - } - - protected function _delete() - { - // NOP - return $this; - } - - public function isEnabled() - { - return (bool) $this->getData('game_disable'); - } -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Core/Model/Exception.php b/includes/application/code/core/Legacies/Core/Model/Exception.php deleted file mode 100644 index 674808b..0000000 --- a/includes/application/code/core/Legacies/Core/Model/Exception.php +++ /dev/null @@ -1,7 +0,0 @@ -getConstants()); - } - - self::$_instances[$namespace] = new self($namespace); - } - return self::$_instances[$namespace]; - } - - public static function destroy() - { - session_destroy(); - } - - public function __construct($namespace) - { - if (session_id() == '') { - session_start(); - } - - if (!isset($_SESSION[$namespace])) { - $_SESSION[$namespace] = array(); - } - - $this->_data = &$_SESSION[$namespace]; - $this->_data['messages'] = array(); - } - - public function getMessages($clear = true) - { - $messages = $this->_data['messages']; - if ($clear == true) { - $this->_data['messages'] = array(); - } - return $messages; - } - - public function addMessage($message, $type = self::DEBUG) - { - if (!isset(self::$_levels[$type])) { - $type = self::DEBUG; - } - - if (!isset($this->_data['messages'])) { - $this->_data['messages'] = array(); - } - if (!isset($this->_data['messages'][self::$_levels[$type]])) { - $this->_data['messages'][self::$_levels[$type]] = array(); - } - $this->_data['messages'][self::$_levels[$type]][] = $message; - - return $this; - } - - public function addCritical($message, $_ = null) - { - $args = func_get_args(); - array_shift($args); - - return $this->addMessage(vsprintf($message, $args), self::CRIT); - } - - public function addError($message, $_ = null) - { - $args = func_get_args(); - array_shift($args); - - return $this->addMessage(vsprintf($message, $args), self::ERROR); - } - - public function addWarning($message, $_ = null) - { - $args = func_get_args(); - array_shift($args); - - return $this->addMessage(vsprintf($message, $args), self::WARN); - } - - public function addSuccess($message, $_ = null) - { - $args = func_get_args(); - array_shift($args); - - return $this->addMessage(vsprintf($message, $args), self::SUCCESS); - } - - public function addInfo($message, $_ = null) - { - $args = func_get_args(); - array_shift($args); - - return $this->addMessage(vsprintf($message, $args), self::INFO); - } - - public function addDebug($message, $_ = null) - { - $args = func_get_args(); - array_shift($args); - - return $this->addMessage(vsprintf($message, $args), self::DEBUG); - } - - public function getFormKey($reset = false) - { - if (!$this->getData('form_key')) { - $this->setData('form_key', uniqid()); - return $this->getData('form_key'); - } - - $key = $this->getData('form_key'); - if ($reset == true) { - $this->setData('form_key', uniqid()); - } - - return $key; - } -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Core/Singleton.php b/includes/application/code/core/Legacies/Core/Singleton.php deleted file mode 100644 index c90e01f..0000000 --- a/includes/application/code/core/Legacies/Core/Singleton.php +++ /dev/null @@ -1,6 +0,0 @@ -_template = $data['template']; - unset($data['template']); - } - - parent::__construct($data); - } - - protected function _prepareRender() - { - return $this; - } - - public function renderNumber($number) - { - return Math::render($number); - } - - public function renderTime($time, $unique = false) - { - if ($time >= 10) { - $seconds = $time % 60; - $minutes = (int) (($time - $seconds) / 60) % 60; - $hours = (int) ((($time - $seconds) / 60) - $minutes) / 60; - - if ($hours > 24) { - $dayHours = (int) $hours % 24; - $days = (int) ($hours - $dayHours) / 24; - - return $this->__('%1$d day(s) and %2$d hour(s)', $days, $dayHours); - } else if ($hours > 0) { - return $this->__('%1$d hour(s), %2$d minute(s) and %3$d second(s)', $hours, $minutes, $seconds); - } else if ($minutes > 0) { - return $this->__('%1$d minute(s) and %2$d second(s)', $minutes, $seconds); - } else { - return $this->__('%1$d second(s)', $seconds); - } - } else if (!$unique && $time > 0) { - return $this->__('%1$d per minute', 60 / $time); - } else { - return $this->__('instantaneous'); - } - } - - protected function escape($unescaped) - { - return htmlspecialchars($unescaped, ENT_QUOTES, 'UTF-8'); - } - - public function __($message, $_ = null) - { - $args = func_get_args(); - array_shift($args); - - return Legacies::translate(Legacies::getDefaultLocale(), $message, $args); - } - - public function translate($message, $_ = null) - { - $args = func_get_args(); - array_shift($args); - - return Legacies::translate(Legacies::getLocale(), $message, $args); - } - - public function renderScript($file) - { - $this->_prepareRender(); - - $path = APPLICATION_PATH . DIRECTORY_SEPARATOR . 'design' . DIRECTORY_SEPARATOR . 'scripts'; - - ob_start(); - include $path . DIRECTORY_SEPARATOR . $file; - $contents = ob_get_contents(); - ob_end_clean(); - - return $contents; - } - - public function render() - { - $template = $this->getTemplate(); - if (empty($template)) { - return null; - } - return $this->renderScript($template); - } - - public function setTemplate($template) - { - $this->_template = $template; - - return $this; - } - - public function getTemplate() - { - return $this->_template; - } - - public function getUrl($uri, Array $params = array()) - { - // TODO: base path integration - $serializedParams = array(); - foreach ($params as $paramKey => $paramValue) { - if ($paramValue) { - $serializedParams[] = "{$paramKey}={$paramValue}"; - } - } - - if (count($serializedParams) > 0) { - return $uri . '?' . implode('&', $serializedParams); - } - return $uri; - } - - public function getSkinUrl($uri) - { - static $baseUrl = null; - if ($baseUrl === null) { - $user = Legacies_Empire_Model_User::getSingleton(); - if ($user !== null && $user->getId()) { - $baseUrl = $user->getSkinPath(); - } - if ($baseUrl == '') { - $baseUrl = DEFAULT_SKINPATH; - } - } - - return $this->getUrl($baseUrl . $uri); - } - - public function setPartial($name, $content) - { - if (!is_string($content) && !$content instanceof self) { - return $this; - } - - $this->_partials[$name] = $content; - - return $this; - } - - public function getPartial($name) - { - return $this->_partials[$name]; - } - - public function getAllPartials() - { - return $this->_partials; - } - - public function unsetPartial($name) - { - if (isset($this->_partials[$name])) { - unset($this->_partials[$name]); - } - - return $this; - } - - public function hasPartial($name) - { - return isset($this->_partials[$name]) && (is_string($this->_partials[$name]) || $this->_partials[$name] instanceof self); - } - - public function __set($name, $content) - { - return $this->setPartial($name, $content); - } - - public function __get($name) - { - $name = str_replace(' ', '', ucwords(str_replace('-', ' ', $name))); - $name[0] = strtolower($name[0]); - return $this->getPartial($name); - } - - public function __unset($name) - { - return $this->unsetPartial($name); - } - - public function __isset($name) - { - return $this->hasPartial($name); - } - - public function setLayout($layout) - { - $this->_layout = $layout; - - return $this; - } - - /** - * - * @return Legacies_Core_Layout - */ - public function getLayout() - { - return $this->_layout; - } - - public function prepareLayout() - { - } - - public function beforeToHtml() - { - } - - public function setNameInLayout($name) - { - $this->_nameInLayout = $name; - - return $this; - } - - public function getNameInLayout() - { - return $this->_nameInLayout; - } -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Database.php b/includes/application/code/core/Legacies/Database.php deleted file mode 100644 index 76bc26b..0000000 --- a/includes/application/code/core/Legacies/Database.php +++ /dev/null @@ -1,51 +0,0 @@ - PDO::ERRMODE_EXCEPTION - ); - - public static function getSingleton() - { - if (self::$_singleton === null) { - $config = include ROOT_PATH . 'config.php'; - $hostname = $config['global']['database']['options']['hostname']; - $username = $config['global']['database']['options']['username']; - $password = $config['global']['database']['options']['password']; - $database = $config['global']['database']['options']['database']; - $port = 3306; - - if (isset($config['global']['database']['options']['port'])) { - $port = $config['global']['database']['options']['port']; - } - - $event = Legacies::dispatchEvent('database.prepare-options', array( - 'options' => self::$options - )); - - self::$options = $event->getData('options'); - - self::$_singleton = new self("mysql:dbname={$database};host={$hostname};port={$port}", $username, $password, self::$options); - - Legacies::dispatchEvent('database.init', array( - 'handler' => self::$_singleton - )); - } - return self::$_singleton; - } - - public function getTable($name) - { - if (self::$_prefix === null) { - $config = include ROOT_PATH . 'config.php'; - self::$_prefix = $config['global']['database']['table_prefix']; - } - return self::$_prefix . $name; - } -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Empire/Block/Overview.php b/includes/application/code/core/Legacies/Empire/Block/Overview.php deleted file mode 100644 index 3466417..0000000 --- a/includes/application/code/core/Legacies/Empire/Block/Overview.php +++ /dev/null @@ -1,7 +0,0 @@ -_user = $user; - - return $this; - } - - public function getUser() - { - if ($this->_user === null) { - $this->_user = Legacies_Empire_Model_User::getSingleton(); - } - - return $this->_user; - } - - public function setPlanet(Legacies_Empire_Model_Planet $planet) - { - $this->_planet = $planet; - - return $this; - } - - public function getPlanet() - { - if ($this->_planet === null) { - $this->_planet = $this->getUser()->getCurrentPlanet(); - } - - return $this->_planet; - } - - public function setItemId($itemId) - { - $this->_itemId = $itemId; - - return $this; - } - - public function getItemId() - { - return $this->_itemId; - } - - public function getItemInfoUrl() - { - return $this->getUrl('infos.php', array('gid' => $this->getItemId())); - } - - public function getItemImageUrl() - { - // TODO : Upgrade theme - return $this->getSkinUrl('graphics/gebaeude/' . $this->getItemId() . '.gif'); - } - - public function getName() - { - static $lang = null; - if ($lang === null) { - // FIXME: implement a cleaner way to get names - $lang = includeLang('tech'); - } - - if (isset($lang['tech']) && isset($lang['tech'][$this->getItemId()])) { - return $this->__($lang['tech'][$this->getItemId()]); - } - return ''; - } - - public function getDescription() - { - static $lang = null; - if ($lang === null) { - // FIXME: implement a cleaner way to get names - $lang = includeLang('tech'); - } - - if (isset($lang['res']) && isset($lang['res']['descriptions']) && isset($lang['res']['descriptions'][$this->getItemId()])) { - return $this->__($lang['res']['descriptions'][$this->getItemId()]); - } - return ''; - } - - public function getResourceName($resourceId) - { - static $lang = null; - if ($lang === null) { - // FIXME: implement a cleaner way to get names - $lang = includeLang('imperium'); - } - if ($resourceId == 'cristal') { - $resourceId = 'crystal'; - } - - if (isset($lang[$resourceId])) { - return $this->__($lang[$resourceId]); - } - return ''; - } - - public function getNextLevel() - { - return $this->getQueuedLevel() + 1; - } - - abstract public function getResourcesNeeded($level); - - abstract public function getBuildingTime($level); -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Empire/Block/Planet/ResearchLab.php b/includes/application/code/core/Legacies/Empire/Block/Planet/ResearchLab.php deleted file mode 100644 index 97758c6..0000000 --- a/includes/application/code/core/Legacies/Empire/Block/Planet/ResearchLab.php +++ /dev/null @@ -1,42 +0,0 @@ -_planet = $planet; - - return $this; - } - - public function getPlanet() - { - if ($this->_planet === null) { - $this->_planet = Legacies_Empire_Model_User::getSingleton() - ->getCurrentPlanet() - ; - } - return $this->_planet; - } - - public function _initChildBlocks() - { - $types = Legacies_Empire_Model_Game_Types::getSingleton(); - - /** @var Legacies_Core_Block_Concat $parentBlock */ - $parentBlock = $this->getLayout()->getBlock('item-list.items'); - foreach ($types->getData(Legacies_Empire::TYPE_RESEARCH) as $itemId) { - if (!$this->getPlanet()->getResearchLab()->checkAvailability($itemId)) { - continue; - } - - $block = $this->getItemBlock($itemId); - $parentBlock->setPartial($block->getName(), $block); - } - - return $this; - } -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Empire/Block/Planet/ResearchLab/Queue.php b/includes/application/code/core/Legacies/Empire/Block/Planet/ResearchLab/Queue.php deleted file mode 100644 index c7094d9..0000000 --- a/includes/application/code/core/Legacies/Empire/Block/Planet/ResearchLab/Queue.php +++ /dev/null @@ -1,15 +0,0 @@ -getPlanet()->getResearchLab()->getBuilder(); - } - - public function isEmpty() - { - return $this->getQueue()->count() == 0; - } -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Empire/Block/Planet/ResearchLab/Queue/Item.php b/includes/application/code/core/Legacies/Empire/Block/Planet/ResearchLab/Queue/Item.php deleted file mode 100644 index 463fbf2..0000000 --- a/includes/application/code/core/Legacies/Empire/Block/Planet/ResearchLab/Queue/Item.php +++ /dev/null @@ -1,63 +0,0 @@ -getUser()->getElement($this->getItemId()); - } - - public function getResourcesNeeded($level) - { - return $this->getPlanet()->getResearchLab()->getResourcesNeeded($this->getItemId(), $this->getQueuedLevel() + 1); - } - - public function getItemQueuedLevel() - { - return $this->getItem()->getData('level'); - } - - public function getQueuedLevel() - { - return $this->getPlanet()->getResearchLab()->getResearchLevelQueued($this->getItemId()); - } - - public function getBuildingTime($level) - { - return $this->getPlanet()->getResearchLab()->getBuildingTime($this->getItemId(), $level); - } - - public function getResourcesConfigForLevel($level) - { - $resources = $this->getResourcesNeeded($level); - - $resourceConfig = array(); - foreach ($resources as $resourceId => $resourceValue) { - $resourceConfig[$resourceId] = new Legacies_Object(array( - 'resource_id' => $resourceId, - 'value' => $resourceValue - )); - - $amount = $this->getPlanet()->getResourceAmount($resourceId); - if (Math::comp($amount, $resourceValue) < 0) { - $resourceConfig[$resourceId]->setData('requirement', Math::sub($amount, $resourceValue)); - } else { - $resourceConfig[$resourceId]->setData('overflow', Math::sub($amount, $resourceValue)); - } - } - return $resourceConfig; - } - - public function getResourcesConfigForNextLevel() - { - return $this->getResourcesConfigForLevel($this->getNextLevel()); - } - - public function getBuildingTimeForNextLevel() - { - return $this->getBuildingTime($this->getNextLevel()); - } -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Empire/Block/Planet/Shipyard.php b/includes/application/code/core/Legacies/Empire/Block/Planet/Shipyard.php deleted file mode 100644 index dfcf5df..0000000 --- a/includes/application/code/core/Legacies/Empire/Block/Planet/Shipyard.php +++ /dev/null @@ -1,82 +0,0 @@ -_planet = $planet; - - return $this; - } - - public function getPlanet() - { - if ($this->_planet === null) { - $this->_planet = Legacies_Empire_Model_User::getSingleton() - ->getCurrentPlanet() - ; - } - return $this->_planet; - } - - public function setAllowedTypes($types) - { - if (is_array($types)) { - $this->_allowedTypes = $types; - } - return $this; - } - - public function addAllowedType($type) - { - if (!in_array($type, $this->_allowedTypes)) { - $this->_allowedTypes[] = $type; - } - return $this; - } - - public function getAllowedTypes() - { - return $this->_allowedTypes; - } - - public function setType($type) - { - if (in_array($type, $this->_allowedTypes)) { - $this->_type = $type; - } - return $this; - } - - public function getType() - { - return $this->_type; - } - - public function _initChildBlocks() - { - $types = Legacies_Empire_Model_Game_Types::getSingleton(); - - /** @var Legacies_Core_Block_Concat $parentBlock */ - $parentBlock = $this->getLayout()->getBlock('item-list.items'); - foreach ($types->getData($this->getType()) as $itemId) { - if (!$this->getPlanet()->getShipyard()->checkAvailability($itemId)) { - continue; - } - - $block = $this->getItemBlock($itemId); - $parentBlock->setPartial($block->getName(), $block); - } - - return $this; - } -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Empire/Block/Planet/Shipyard/Item.php b/includes/application/code/core/Legacies/Empire/Block/Planet/Shipyard/Item.php deleted file mode 100644 index 6c8085c..0000000 --- a/includes/application/code/core/Legacies/Empire/Block/Planet/Shipyard/Item.php +++ /dev/null @@ -1,46 +0,0 @@ -getPlanet()->getElement($this->getItemId()); - } - - public function getResourcesNeeded($qty) - { - return $this->getPlanet()->getShipyard()->getResourcesNeeded($this->getItemId(), $qty); - } - - public function getBuildingTime($qty) - { - return $this->getPlanet()->getShipyard()->getBuildingTime($this->getItemId(), $qty); - } - - public function getMaximumBuildableElementsCount() - { - return $this->getPlanet()->getShipyard()->getMaximumBuildableElementsCount($this->getItemId()); - } - - public function getResourcesConfigForQty($qty) - { - $resources = $this->getResourcesNeeded($qty); - - $resourceConfig = array(); - foreach ($resources as $resourceId => $resourceValue) { - $resourceConfig[$resourceId] = new Legacies_Object(array( - 'resource_id' => $resourceId, - 'value' => $resourceValue - )); - - $amount = $this->getPlanet()->getResourceAmount($resourceId); - if (Math::comp($amount, $resourceValue) < 0) { - $resourceConfig[$resourceId]->setData('requirement', Math::sub($amount, $resourceValue)); - } else { - $resourceConfig[$resourceId]->setData('overflow', Math::sub($amount, $resourceValue)); - } - } - return $resourceConfig; - } -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Empire/Block/Planet/Shipyard/Queue.php b/includes/application/code/core/Legacies/Empire/Block/Planet/Shipyard/Queue.php deleted file mode 100644 index d43af80..0000000 --- a/includes/application/code/core/Legacies/Empire/Block/Planet/Shipyard/Queue.php +++ /dev/null @@ -1,15 +0,0 @@ -getPlanet()->getShipyard()->getQueue(); - } - - public function isEmpty() - { - return $this->getQueue()->count() == 0; - } -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Empire/Block/PlanetList.php b/includes/application/code/core/Legacies/Empire/Block/PlanetList.php deleted file mode 100644 index d1bd171..0000000 --- a/includes/application/code/core/Legacies/Empire/Block/PlanetList.php +++ /dev/null @@ -1,7 +0,0 @@ -getCurrentUser()->getCurrentPlanet(); - } - - /** - * - * @return Legacies_Core_Collection - */ - public function getPlanetCollection() - { - return $this->getCurrentUser()->getPlanetCollection(); - } -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Empire/Exception.php b/includes/application/code/core/Legacies/Empire/Exception.php deleted file mode 100644 index 73de227..0000000 --- a/includes/application/code/core/Legacies/Empire/Exception.php +++ /dev/null @@ -1,3 +0,0 @@ -setIdFieldName('fleet_id'); - $this->setTableName('fleets'); - } - - public static function planetListener($eventData) - { - } - - public function isOwnedBy(Legacies_Empire_Model_User $user) - { - if ($this->getData('fleet_owner') == $user->getId()) { - return true; - } - return false; - } - - public function isMission($missionType) - { - if ($this->getData('fleet_mission') == $missionType) { - return true; - } - return false; - } - - public function getRowClass() - { - if ($this->isMission(Legacies_Empire::ID_MISSION_ATTACK) || $this->isMission(Legacies_Empire::ID_MISSION_GROUP_ATTACK)) { - return 'attack'; - } else if ($this->isMission(Legacies_Empire::ID_MISSION_TRANSPORT)) { - return 'transport'; - } else if ($this->isMission(Legacies_Empire::ID_MISSION_STATION) || $this->isMission(Legacies_Empire::ID_MISSION_STATION_ALLY)) { - return 'station'; - } else if ($this->isMission(Legacies_Empire::ID_MISSION_SETTLE_COLONY)) { - return 'settle'; - } else if ($this->isMission(Legacies_Empire::ID_MISSION_RECYCLE)) { - return 'recycle'; - } else if ($this->isMission(Legacies_Empire::ID_MISSION_DESTROY)) { - return 'destroy'; - } else if ($this->isMission(Legacies_Empire::ID_MISSION_MISSILES)) { - return 'missiles'; - } else if ($this->isMission(Legacies_Empire::ID_MISSION_EXPEDITION)) { - return 'expedition'; - } - } -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Empire/Model/Galaxy/Position.php b/includes/application/code/core/Legacies/Empire/Model/Galaxy/Position.php deleted file mode 100644 index a7e4a97..0000000 --- a/includes/application/code/core/Legacies/Empire/Model/Galaxy/Position.php +++ /dev/null @@ -1,32 +0,0 @@ -_tableName = 'galaxy'; - $this->_idFieldNames = array('id_planet'); - } - - static function initPlanetListerner($eventData) - { - if (!isset($eventData['planet'])) { - return; - } - - $planet = $eventData['planet']; - if (!$planet->isPlanet()) { - return; - } - - $galaxy = new self(); - $galaxy - ->setData('galaxy', $planet->getGalaxy()) - ->setData('system', $planet->getSystem()) - ->setData('planet', $planet->getPosition()) - ->setData('id_planet', $planet->getId()) - ->save() - ; - } -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Empire/Model/Game/Abstract.php b/includes/application/code/core/Legacies/Empire/Model/Game/Abstract.php deleted file mode 100644 index b288971..0000000 --- a/includes/application/code/core/Legacies/Empire/Model/Game/Abstract.php +++ /dev/null @@ -1,36 +0,0 @@ -_data); - } - - public function current() - { - return current($this->_data); - } - - public function next() - { - return next($this->_data); - } - - public function key() - { - return key($this->_data); - } - - public function valid() - { - return $this->current() !== false; - } - - public function rewind() - { - reset($this->_data); - } -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Empire/Model/Game/Requirements.php b/includes/application/code/core/Legacies/Empire/Model/Game/Requirements.php deleted file mode 100644 index b2fa004..0000000 --- a/includes/application/code/core/Legacies/Empire/Model/Game/Requirements.php +++ /dev/null @@ -1,49 +0,0 @@ - $fieldName) { - $this->setData($elementId, $fieldName); - } - return $this; - } - - protected function _load() - { - // NOP - return $this; - } - - protected function _save() - { - // NOP - return $this; - } - - protected function _delete() - { - // NOP - return $this; - } -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Empire/Model/Planet/Builder/Item.php b/includes/application/code/core/Legacies/Empire/Model/Planet/Builder/Item.php deleted file mode 100644 index 8f52b5f..0000000 --- a/includes/application/code/core/Legacies/Empire/Model/Planet/Builder/Item.php +++ /dev/null @@ -1,6 +0,0 @@ - 10 + 20 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio), - Legacies_Empire::RESOURCE_ENERGY => -10 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio) - ); - } -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Empire/Model/Planet/Building/DeuteriumSynthetiser.php b/includes/application/code/core/Legacies/Empire/Model/Planet/Building/DeuteriumSynthetiser.php deleted file mode 100644 index 51541e0..0000000 --- a/includes/application/code/core/Legacies/Empire/Model/Planet/Building/DeuteriumSynthetiser.php +++ /dev/null @@ -1,13 +0,0 @@ - 10 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio), - Legacies_Empire::RESOURCE_ENERGY => -30 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio) - ); - } -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Empire/Model/Planet/Building/FusionReactor.php b/includes/application/code/core/Legacies/Empire/Model/Planet/Building/FusionReactor.php deleted file mode 100644 index 060edbc..0000000 --- a/includes/application/code/core/Legacies/Empire/Model/Planet/Building/FusionReactor.php +++ /dev/null @@ -1,13 +0,0 @@ - -10 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio), - Legacies_Empire::RESOURCE_ENERGY => 50 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio) - ); - } -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Empire/Model/Planet/Building/MetalMine.php b/includes/application/code/core/Legacies/Empire/Model/Planet/Building/MetalMine.php deleted file mode 100644 index 6bff798..0000000 --- a/includes/application/code/core/Legacies/Empire/Model/Planet/Building/MetalMine.php +++ /dev/null @@ -1,13 +0,0 @@ - 20 + 30 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio), - Legacies_Empire::RESOURCE_ENERGY => -10 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio) - ); - } -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Empire/Model/Planet/Building/NaniteFactory.php b/includes/application/code/core/Legacies/Empire/Model/Planet/Building/NaniteFactory.php deleted file mode 100644 index 8a1362f..0000000 --- a/includes/application/code/core/Legacies/Empire/Model/Planet/Building/NaniteFactory.php +++ /dev/null @@ -1,19 +0,0 @@ -getData('planet'); - - if (!$planet->getId() || ($level = $planet->getElement(Legacies_Empire::ID_BUILDING_NANITE_FACTORY)) <= 0) { - return; - } - - $time = $event->getData('time'); - - $speedFactor = pow(2, $level); - $event->setData('time', $time / $speedFactor); - } -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Empire/Model/Planet/Building/ResearchLab/Builder.php b/includes/application/code/core/Legacies/Empire/Model/Planet/Building/ResearchLab/Builder.php deleted file mode 100644 index 71175a3..0000000 --- a/includes/application/code/core/Legacies/Empire/Model/Planet/Building/ResearchLab/Builder.php +++ /dev/null @@ -1,219 +0,0 @@ -_unserializeQueue($this->_currentUser->getData('b_laboratory_id')); - } - - /** - * @param int $buildingId - * @param int $level - * @param int $time - */ - protected function _initItem(Array $params) - { - if (!isset($params['technology_id']) || !isset($params['level'])) { - return null; - } - - $technologyId = $params['technology_id']; - $level = $params['level']; - if (!isset($params['created_at'])) { - $createdAt = time(); - } else { - $createdAt = $params['created_at']; - } - if (!isset($params['updated_at'])) { - $updatedAt = $createdAt; - } else { - $updatedAt = $params['updated_at']; - } - - return new Legacies_Empire_Model_Planet_Building_ResearchLab_Item(array( - 'technology_id' => $technologyId, - 'level' => $level, - 'created_at' => $createdAt, - 'updated_at' => $updatedAt - )); - } - - /** - * Check if a technology type is actually buildable on the current - * planet, depending on the technology and buildings requirements. - * - * @param int $technologyId - * @return bool - */ - public function checkAvailability($technologyId) - { - $types = Legacies_Empire_Model_Game_Types::getSingleton(); - - if (!$types->is($technologyId, Legacies_Empire::TYPE_RESEARCH)) { - return false; - } - - parent::checkAvailability($technologyId); - - return true; - } - - /** - * Returns the time needed to build $level of $technologyId - * - * @param int $technologyId - * @param int $level - */ - public function getBuildingTime($technologyId, $level) - { - $prices = Legacies_Empire_Model_Game_Prices::getSingleton(); - $types = Legacies_Empire_Model_Game_Types::getSingleton(); - $gameConfig = Legacies_Core_Model_Config::getSingleton(); - - Math::setPrecision(50); - - // FIXME: Resource dependency - $totalCost = Math::mul(Math::add($prices[$technologyId][Legacies_Empire::RESOURCE_METAL], $prices[$technologyId][Legacies_Empire::RESOURCE_CRISTAL]), $level); - $speedFactor = $gameConfig->getData('game_speed'); - - // FIXME: Building & Technology dependency - $extraLaboratoriesLevels = 0; - $researchNetworkLevel = $this->_currentUser->getElement(Legacies_Empire::ID_RESEARCH_INTERGALACTIC_RESEARCH_NETWORK); - if ($researchNetworkLevel > 0) { - $laboratoriesLevels = array(); - foreach ($this->_currentUser->getPlanetCollection() as $planet) { - if ($this->_currentPlanet->getId() == $planet->getId()) { - continue; - } - $level = $planet->getElement(Legacies_Empire::ID_BUILDING_RESEARCH_LAB); - if ($level > 0) { - $laboratoriesLevels[] = (int) $level; - } - } - sort($laboratoriesLevels, SORT_NUMERIC); - $extraLaboratoriesLevels = array_sum(array_slice(array_reverse($laboratoriesLevels), 0, $researchNetworkLevel)); - } - - $laboratorySpeedup = Math::div($totalCost, ($this->_currentPlanet->getElement(Legacies_Empire::ID_BUILDING_RESEARCH_LAB) + 1 + $extraLaboratoriesLevels)); - - Math::setPrecision(); - - $baseTime = ($totalCost / $speedFactor) * $laboratorySpeedup; - - return (int) Math::floor($baseTime * 3600); - } - - /** - * (non-PHPdoc) - * @see Legacies_Empire_Model_BuilderAbstract::getResourcesNeeded() - */ - public function getResourcesNeeded($technologyId, $level) - { - $prices = Legacies_Empire_Model_Game_Prices::getSingleton(); - $resources = Legacies_Empire_Model_Game_Resources::getSingleton(); - - if (!isset($prices[$technologyId])) { - return array(); - } - $resourcesNeeded = array(); - foreach ($resources as $resourceId => $resourceConfig) { - if (!isset($prices[$technologyId][$resourceId])) { - continue; - } - if (Math::isPositive($prices[$technologyId][$resourceId])) { - $firstLevelCost = $prices[$technologyId][$resourceId]; - $partialLevelCost = Math::mul($firstLevelCost, Math::pow($prices[$technologyId][Legacies_Empire::RESOURCE_MULTIPLIER], $level)); - $resourcesNeeded[$resourceId] = Math::sub($partialLevelCost, $firstLevelCost); - } - } - - return $resourcesNeeded; - } - - /** - * Update the contruction queue. - * - * @return Legacies_Empire_Model_Planet_Building_ResearchLab - */ - public function updateQueue($time) - { - $fields = Legacies_Empire_Model_Game_FieldsAlias::getSingleton(); - - $elapsedTime = $time - $this->_currentUser->getData('b_laboratory'); - - foreach ($this->getQueue() as $element) { - $technologyId = $element->getData('research_id'); - $level = $element->getData('level'); - $buildTime = $this->getBuildingTime($technologyId, $level); - - if ($elapsedTime >= $buildTime) { - $this->_currentUser[$fields[$technologyId]] = Math::add($this->_currentUser[$fields[$technologyId]], $level); - $elapsedTime -= $buildTime; - $this->dequeue($element); - continue; - } - - $timeRatio = $elapsedTime / $buildTime; - $itemsBuilt = Math::mul($timeRatio, $level); - - $element->setData('updated_at', $time); - $element->setData('level', Math::sub($level, $itemsBuilt)); - $this->_currentUser->setData($fields[$technologyId], Math::add($this->_currentUser->getData($fields[$technologyId]), $itemsBuilt)); - break; - } - - $this->_currentUser->setData('b_laboratory_id', $this->serialize()); - $this->_currentUser->setData('b_laboratory', $time); - - return $this; - } - - /** - * Append items to build to the construction list - * - * @param int $technologyId - * @param int|string $level - * @return Legacies_Empire_Model_Planet_Building_ResearchLab - */ - public function appendQueue($technologyId, $level, $time) - { - if ($this->_maxLength > 0 && $this->count() >= $this->_maxLength) { - return $this; - } - - if (!Math::isPositive($level)) { - return $this; - } - - $types = Legacies_Empire_Model_Game_Types::getSingleton(); - if (!$types->is($technologyId, Legacies_Empire::TYPE_RESEARCH)) { - return $this; - } - - if (!$this->checkAvailability($technologyId)) { - return $this; - } - - $resourcesNeeded = $this->getResourcesNeeded($technologyId, $level); - $remainingAmounts = $this->_calculateResourceRemainingAmounts($resourcesNeeded); - if ($remainingAmounts === false) { - return $this; - } - - $this->enqueue($technologyId, $level, $time); - $this->_currentUser->setData('b_laboratory_id', $this->serialize()); - - foreach ($remainingAmounts as $resourceId => $resourceAmount) { - $this->_currentPlanet[$resourceId] = $resourceAmount; - } - - return $this; - } -}; \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Empire/Model/Planet/Building/ResearchLab/Item.php b/includes/application/code/core/Legacies/Empire/Model/Planet/Building/ResearchLab/Item.php deleted file mode 100644 index eafe814..0000000 --- a/includes/application/code/core/Legacies/Empire/Model/Planet/Building/ResearchLab/Item.php +++ /dev/null @@ -1,6 +0,0 @@ -getData('planet'); - - if (!$planet->getId() || ($level = $planet->getElement(Legacies_Empire::ID_BUILDING_ROBOTIC_FACTORY)) <= 0) { - return; - } - - $time = $event->getData('time'); - - $speedFactor = 1 + $level; - $event->setData('time', $time / $speedFactor); - } -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Empire/Model/Planet/Building/Shipyard/Item.php b/includes/application/code/core/Legacies/Empire/Model/Planet/Building/Shipyard/Item.php deleted file mode 100644 index 83ad74a..0000000 --- a/includes/application/code/core/Legacies/Empire/Model/Planet/Building/Shipyard/Item.php +++ /dev/null @@ -1,6 +0,0 @@ - 20 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio) - ); - } -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Empire/Model/Planet/BuildingInterface.php b/includes/application/code/core/Legacies/Empire/Model/Planet/BuildingInterface.php deleted file mode 100644 index feb3ab4..0000000 --- a/includes/application/code/core/Legacies/Empire/Model/Planet/BuildingInterface.php +++ /dev/null @@ -1,5 +0,0 @@ -getElement(Legacies_Empire::ID_RESEARCH_COMBUSTION_DRIVE)); - } -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Empire/Model/Planet/Ship/LightTransport.php b/includes/application/code/core/Legacies/Empire/Model/Planet/Ship/LightTransport.php deleted file mode 100644 index 8ec8aaa..0000000 --- a/includes/application/code/core/Legacies/Empire/Model/Planet/Ship/LightTransport.php +++ /dev/null @@ -1,27 +0,0 @@ -getElement(Legacies_Empire::ID_RESEARCH_IMPULSE_DRIVE) < self::REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_IMPULSE_DRIVE) { - return $prices[Legacies_Empire::ID_SHIP_LIGHT_TRANSPORT][Legacies_Empire::SHIPS_CELERITY_PRIMARY]; - } else { - return $prices[Legacies_Empire::ID_SHIP_LIGHT_TRANSPORT][Legacies_Empire::SHIPS_CELERITY_SECONDARY]; - } - } - - public function getSpeedMultiplier(Legacies_Empire_Model_User $user) - { - if ($user->getElement(Legacies_Empire::ID_RESEARCH_HYPERSPACE_DRIVE) < self::REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_IMPULSE_DRIVE) { - return pow(1.1, $user->getElement(Legacies_Empire::ID_RESEARCH_COMBUSTION_DRIVE)); - } else { - return pow(1.2, $user->getElement(Legacies_Empire::ID_RESEARCH_IMPULSE_DRIVE)); - } - } -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Empire/Model/Planet/Ship/SolarSatellite.php b/includes/application/code/core/Legacies/Empire/Model/Planet/Ship/SolarSatellite.php deleted file mode 100644 index e402af2..0000000 --- a/includes/application/code/core/Legacies/Empire/Model/Planet/Ship/SolarSatellite.php +++ /dev/null @@ -1,33 +0,0 @@ - ((floatval($planet->getData('temp_max')) / 4) + 20) * (0.1 * $produtionRatio) * floatval($quantity) - ); - } - - public function getBaseSpeed(Legacies_Empire_Model_User $user) - { - return 0; - } - - public function getSpeedMultiplier(Legacies_Empire_Model_User $user) - { - return 0; - } - - public function getActualSpeed(Legacies_Empire_Model_User $user) - { - return 0; - } - - public function getBaseConsumption(Legacies_Empire_Model_User $user) - { - return 0; - } -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Empire/Model/Planet/Ship/Supernova.php b/includes/application/code/core/Legacies/Empire/Model/Planet/Ship/Supernova.php deleted file mode 100644 index 4adcbf2..0000000 --- a/includes/application/code/core/Legacies/Empire/Model/Planet/Ship/Supernova.php +++ /dev/null @@ -1,39 +0,0 @@ - ((floatval($planet->getData('temp_max')) / 4) + 20) * (0.1 * $produtionRatio) * floatval($quantity) * -1250 - ); - } - - public function getBaseSpeed(Legacies_Empire_Model_User $user) - { - $prices = Legacies_Empire_Model_Game_Prices::getSingleton(); - - if ($user->getElement(Legacies_Empire::ID_RESEARCH_HYPERSPACE_DRIVE) < self::REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_HYPERSPACE_DRIVE && - $user->getElement(Legacies_Empire::ID_RESEARCH_HYPERSPACE_TECHNOLOGY) < self::REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_HYPERSPACE_TECHNOLOGY) { - return $prices[Legacies_Empire::ID_SHIP_SUPERNOVA][Legacies_Empire::SHIPS_CELERITY_PRIMARY]; - } else { - return $prices[Legacies_Empire::ID_SHIP_SUPERNOVA][Legacies_Empire::SHIPS_CELERITY_SECONDARY]; - } - } - - public function getSpeedMultiplier(Legacies_Empire_Model_User $user) - { - if ($user->getElement(Legacies_Empire::ID_RESEARCH_HYPERSPACE_DRIVE) < self::REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_HYPERSPACE_DRIVE && - $user->getElement(Legacies_Empire::ID_RESEARCH_HYPERSPACE_TECHNOLOGY) < self::REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_HYPERSPACE_TECHNOLOGY) { - return pow(1.2, $user->getElement(Legacies_Empire::ID_RESEARCH_IMPULSE_DRIVE)); - } else { - return pow(1.3, $user->getElement(Legacies_Empire::ID_RESEARCH_HYPERSPACE_DRIVE)) * - pow(1.1, $user->getElement(Legacies_Empire::ID_RESEARCH_HYPERSPACE_TECHNOLOGY)); - } - } -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Empire/Model/Planet/ShipAbstract.php b/includes/application/code/core/Legacies/Empire/Model/Planet/ShipAbstract.php deleted file mode 100644 index 8fb0c39..0000000 --- a/includes/application/code/core/Legacies/Empire/Model/Planet/ShipAbstract.php +++ /dev/null @@ -1,27 +0,0 @@ -getElement(Legacies_Empire::ID_RESEARCH_COMBUSTION_DRIVE)); - } - - public function getActualSpeed(Legacies_Empire_Model_User $user) - { - return $this->getBaseSpeed($user) * $this->getSpeedMultiplier($user); - } - - public function getActualConsumption(Legacies_Empire_Model_User $user, $speed) - { - return $this->getBaseConsumption($user) * ($speed / 100) * $this->getSpeedMultiplier($user); - } -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Empire/Model/Planet/ShipInterface.php b/includes/application/code/core/Legacies/Empire/Model/Planet/ShipInterface.php deleted file mode 100644 index 250c808..0000000 --- a/includes/application/code/core/Legacies/Empire/Model/Planet/ShipInterface.php +++ /dev/null @@ -1,11 +0,0 @@ -hasData('user_id')) { - $id = intval($session->getData('user_id')); - } else if (Legacies::getRequest() !== null && ($cookie = Legacies::getRequest()->getCookie(self::$_cookieName)) !== null) { - $cookieData = unserialize(stripslashes($cookie)); - if (is_array($cookieData)) { - $collection = new Legacies_Core_Collection(array('user' => 'users')); - $cookieData = array( - 'id' => (isset($cookieData['id']) ? intval($cookieData['id']) : 0), - 'key' => (isset($cookieData['key']) ? $collection->quote($cookieData['key']) : null) - ); - - $collection - ->column('id') - ->where('user.id=:id') - ->where(':key=CONCAT((@salt:=MID(:key, 0, 4)), SHA1(CONCAT(user.username, user.password, @salt)))') - ->load($cookieData) - ; - - if ($collection->count() > 0) { - $session->setData(self::SESSION_KEY, $cookieData['id']); - } else { - $session->addError('Your session has expired, please login.'); - return null; - } - } - } else { - $session->addError('Your session has expired, please login.'); - return null; - } - - try { - self::$_singleton = self::factory($id); - } catch (Legacies_Core_Model_Exception $e) { - $session->addError('Session error.'); - return null; - } - self::$_singleton->_updateActivity(); - } - return self::$_singleton; - } - - public static function hash($password, $salt = null) - { - if ($salt === null) { - return call_user_func(self::$hashCallback, ($password)); - } - - return call_user_func(self::$hashCallback, ($password . $salt)); - } - - protected function _init() - { - $this->setIdFieldName('id'); - $this->setTableName('users'); - } - - protected function _updateActivity() - { - $this - ->setData('current_page', $_SERVER['REQUEST_URI']) - ->setData('user_lastip', $_SERVER['REMOTE_ADDR']) - ->setData('user_agent', $_SERVER['HTTP_USER_AGENT']) - ->setData('onlinetime', time()) - ->save() - ; - return $this; - } - - public function logout() - { - Legacies::getResponse()->unsetCookie(self::$_cookieName); - Legacies_Core_Model_Session::destroy(); - } - - public static function login($username, $password, $remember = false) - { - $session = Legacies::getSession(self::SESSION_KEY); - - try { - $collection = new Legacies_Core_Collection(array('user' => 'users')); - - $passwordHash = md5($password); - $collection - ->column('user.id') - ->column('user.username') - ->column('user.password') - ->column('user.banaday') - ->column('CONCAT((@salt:=MID(MD5(RAND()), 0, 4)), SHA1(CONCAT(user.username, user.password, @salt))) AS login_rememberme') - ->column('(CASE WHEN user.password="' . $passwordHash . '" THEN 1 ELSE 0 END) AS login_success') - ->where('user.username=:username') - ->load(array( - 'username' => $username - )) - ; - } catch (Legacies_Core_Model_Exception $e) { - Legacies_Core_ErrorProfiler::getSingleton()->exceptionManager($e); - $session->addError('No such user.'); - return null; - } - - if ($collection->count() <= 0) { - $session->addError('No such user.'); - return null; - } - $login = $collection->current(); - - if (intval($login['login_success']) == 1) { - if ($login['banaday'] != 0) { - if($login['banaday'] <= time()) { - $user->setData('banaday', 0) - ->setData('bana', 0) - ->setData('urlaubs_modus', 0) - ->save() - ; - } else { - $session->addError('You were banned, please contact admin for more information.'); - return null; - } - } - - if (isset($_POST["rememberme"]) && Legacies::getRequest() !== null) { - Legacies::$response->setCookie(self::$_cookieName, array('id' => $login['id'], 'key' => $login['login_rememberme']), self::COOKIE_LIFETIME); - } - - self::$_singleton = self::factory($login['id']); - self::$_singleton->_updateActivity(); - - $session->setData('user_id', intval($login['id'])); - - return self::$_singleton; - } - - $session->addError('Your username or credential is invalid, please check your input.'); - return null; - } - - public static function register($username, $email, $password) - { - try { - $request = Legacies::getRequest(); - $user = new self(array( - 'username' => $username, - 'password' => md5($password), - 'email' => $email, - 'email_2' => $email, - - 'register_time' => Legacies::now(), - 'onlinetime' => Legacies::now(), - 'ip_at_reg' => $request->getServer('REMOTE_ADDR'), - 'user_lastip' => $request->getServer('REMOTE_ADDR'), - 'user_agent' => $request->getServer('HTTP_USER_AGENT') - )); - - $user->save(); - - Legacies::dispatchEvent('user.init', array( - 'user' => $user - )); - - $user->save(); - } catch (Legacies_Core_Model_Exception $e) { - echo $e->getTraceAsString(); - $session->addError($e->getMessage()); - return null; - } - - return $user; - } - - /** - * - * Enter description here ... - * @param int|Legacies_Empire_Model_Planet $planet - */ - public function updateCurrentPlanet($planet) - { - if (!$planetId instanceof Legacies_Empire_Model_Planet) { - $planetCollection = $this->_preparePlanetCollection()->where('id=:id'); - - $planetCollection->load(array( - 'id' => $planet, - 'user' => $this->getId() - )); - - if ($planetCollection->count() !== 1) { - return $this; - } - - $planet = $planetCollection->current(); - } - - if ($planet->getUserId() != $this->getId() || $planet->isDestroyed()) { - return $this; - } - - $this->setData('current_planet', $planet->getId())->save(); - - return $this; - } - - /** - * - * Enter description here ... - * @param Legacies_Empire_Model_Planet $planet - */ - public function setHomePlanet(Legacies_Empire_Model_Planet $planet) - { - if ($planet->getUserId() != $this->getId() || $planet->isDestroyed()) { - return $this; - } - - $this->setData('id_planet', $planet->getId()); - $this->_homePlanet = $planet; - - return $this; - } - - /** - * - * Enter description here ... - * @param Legacies_Empire_Model_Planet $planet - */ - public function setCurrentPlanet(Legacies_Empire_Model_Planet $planet) - { - if ($planet->getUserId() != $this->getId() || $planet->isDestroyed()) { - return $this; - } - - $this->setData('current_planet', $planet->getId()); - $this->_currentPlanet = $planet; - - return $this; - } - - /** - * - * Enter description here ... - * @return Legacies_Empire_Model_Planet - */ - public function getHomePlanet() - { - if ($this->_homePlanet === null) { - $planetId = $this->getData('id_planet'); - if (!$planetId) { - return null; - } - - $planet = Legacies_Empire_Model_Planet::factory($planetId); - - if ($planet->getUserId() != $this->getId() || $planet->isDestroyed()) { - return null; - } - - $this->_homePlanet = $planet; - } - - return $planet; - } - - /** - * - * Enter description here ... - * @return Legacies_Empire_Model_Planet - */ - public function getCurrentPlanet() - { - if ($this->_currentPlanet === null) { - $planetId = $this->getData('current_planet'); - - if (!$planetId) { - $this->_currentPlanet = $this->getHomePlanet(); - $this->setData('current_planet', $this->_currentPlanet->getId())->save(); - - return $this->_currentPlanet; - } - - $planet = Legacies_Empire_Model_Planet::factory($planetId); - - if ($planet->getUserId() != $this->getId() || $planet->isDestroyed()) { - $this->_currentPlanet = $this->getHomePlanet(); - $this->setData('current_planet', $this->_currentPlanet->getId())->save(); - - return $this->_currentPlanet; - } - - $this->_currentPlanet = $planet; - } - - return $this->_currentPlanet; - } - - protected function _preparePlanetCollection() - { - $planetCollection = new Legacies_Core_Collection(array('planet' => 'planets'), 'Legacies_Empire_Model_Planet'); - $planetCollection->where('id_owner=:user'); - - $order = ($this->getData('planet_sort_order') == 1) ? 'DESC' : 'ASC'; - - switch ($this->getData('planet_sort')) { - case self::PLANET_SORT_POSITION: - $planetCollection - ->order('planet.galaxy', $order) - ->order('planet.system', $order) - ->order('planet.planet', $order) - ->order('planet.planet_type', $order) - ; - break; - - case self::PLANET_SORT_NAME: - $planetCollection->order('planet.name', $order); - break; - - case self::PLANET_SORT_DATE: - default: - $planetCollection->order('planet.id', $order); - break; - } - return $planetCollection; - } - - public function getPlanetCollection() - { - $planetCollection = $this->_preparePlanetCollection(); - - $planetCollection->load(array( - 'user' => $this->getId() - )); - - return $planetCollection; - } - - public function getFleets() - { - $collection = new Legacies_Core_Collection(array('fleet' => 'fleets')); - $collection - ->setEntityClassName('Legacies_Empire_Model_Fleet') - ->where('fleet_owner <= :user_id') - ->load(array('user_id' => $this->getId())) - ; - - return $collection; - } - - public function getVisibleFleets() - { - - $user = Legacies_Empire_Model_User::getSingleton(); - $firstCollection = new Legacies_Core_Collection(array('fleet' => 'fleets')); - $firstCollection -// ->column('*') - ->column('fleet.fleet_start_galaxy', 'galaxy') - ->column('fleet.fleet_start_system', 'system') - ->column('fleet.fleet_start_planet', 'planet') - ->column('fleet.fleet_start_type', 'planet_type') - ->where('fleet_end_time <= :now') - ; - $backCollection = new Legacies_Core_Collection(array('fleet' => 'fleets')); - $backCollection -// ->column('*') - ->column('fleet.fleet_end_galaxy', 'galaxy') - ->column('fleet.fleet_end_system', 'system') - ->column('fleet.fleet_end_planet', 'planet') - ->column('fleet.fleet_end_type', 'planet_type') - ->where('fleet_end_time <= :now') - ; - $collection = new Legacies_Core_Collection(); - $collection - ->setEntityClassName('Legacies_Empire_Model_Fleet') - ->union($firstCollection) - ->union($backCollection) - ->load(array('now' => time())); - - return $collection; - } - - public function getElement($elementId) - { - $fields = Legacies_Empire_Model_Game_FieldsAlias::getSingleton(); - - return $this->getData($fields[$elementId]); - } - - public function setElement($elementId, $level) - { - $fields = Legacies_Empire_Model_Game_FieldsAlias::getSingleton(); - - return $this->setData($fields[$elementId], $level); - } - - public function hasElement($elementId, $levelRequired = 0) - { - $fields = Legacies_Empire_Model_Game_FieldsAlias::getSingleton(); - - return $this->hasData($fields[$elementId]) && Math::comp($this->getElement($elementId), $levelRequired) > 0; - } - - public function getSkinPath($default = null) - { - if ($path = $this->getData('dpath')) { - return $path; - } - return $default; - } - - public function setSkinPath($path) - { - $this->setData('dpath', $path); - - return $this; - } - - public function checkPassword($password) - { - if (self::hash($password) == $this->getData('password')) { - return true; - } - return false; - } - - public function getFleetCollection($time = null) - { - $firstCollection = new Legacies_Core_Collection(array('fleet' => 'fleets')); - $firstCollection - ->column('*') - ->where('fleet.fleet_owner = :user') - ; - $backCollection = new Legacies_Core_Collection(array('fleet' => 'fleets')); - $backCollection - ->column('*') - ->where('fleet.fleet_target_owner = :user') - ; - - $options = array( - 'user' => $this->getId() - ); - - if ($time !== null) { - $options['now'] = $time; - $firstCollection->where('fleet_start_time <= :now'); - $backCollection->where('fleet_end_time <= :now'); - } - - $collection = new Legacies_Core_Collection(); - $collection - ->setEntityClassName('Legacies_Empire_Model_Fleet') - ->union($firstCollection) - ->union($backCollection) - ->load($options) - ; - - return $collection; - } - - public function getNewMessagesCount() - { - $messageCollection = new Legacies_Core_Collection('messages'); - $messageCollection->where('message_owner=:user'); - $messageCollection->where('message_read_at<=0'); - - $newMessages = null; - if (($count = $messageCollection->getSize(array('user' => $this->getId()))) > 0) { - return $count; - } - return null; - } -} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Exception.php b/includes/application/code/core/Legacies/Exception.php deleted file mode 100644 index 0590c2b..0000000 --- a/includes/application/code/core/Legacies/Exception.php +++ /dev/null @@ -1,3 +0,0 @@ -getUser(); - - $level = floor(sqrt($user->getData('xpminier') / 500)); - if ($user->getData('lvl_minier') < $level) { - $difference = $level - $user->getData('lvl_minier'); - if ($difference == 1) { - Legacies::getSession(Legacies_Empire_Model_User::SESSION_KEY) - ->addInfo('You gained 1 miner level.'); - } else { - Legacies::getSession(Legacies_Empire_Model_User::SESSION_KEY) - ->addInfo('You gained %1$d miner level.', (int) $difference); - } - } - - $level = floor(sqrt($user->getData('xpraid'))); - if ($user->getData('lvl_raid') < $level) { - $difference = $level - $user->getData('lvl_raid'); - if ($difference == 1) { - Legacies::getSession(Legacies_Empire_Model_User::SESSION_KEY) - ->addInfo('You gained 1 raider level.'); - } else { - Legacies::getSession(Legacies_Empire_Model_User::SESSION_KEY) - ->addInfo('You gained %1$d raider level.', (int) $difference); - } - } - } - } -} \ No newline at end of file diff --git a/includes/application/code/libraries/Math/Native.php b/includes/application/code/libraries/Math/Native.php deleted file mode 100644 index 80e9c96..0000000 --- a/includes/application/code/libraries/Math/Native.php +++ /dev/null @@ -1,63 +0,0 @@ - $b) ? 1 : (($a < $b) ? -1 : 0); - } - - public function ceil($x) - { - return ceil($x); - } - - public function floor($x) - { - return floor($x); - } - - public function round($range = 0) - { - return round($x, $range); - } - - public function render($a) - { - return number_format($a, 0, ',', '.'); - } -} \ No newline at end of file diff --git a/includes/application/design/layouts/empire.php b/includes/application/design/layouts/empire.php deleted file mode 100644 index 10ad3d5..0000000 --- a/includes/application/design/layouts/empire.php +++ /dev/null @@ -1,300 +0,0 @@ - array( - 'update' => '2columns-left', - 'reference' => array( - 'navigation' => array( - 'actions' => array( - array( - 'method' => 'setNodeTitle', - 'params' => array( - 'path' => 'development', - 'title' => 'Development' - ) - ), - array( - 'method' => 'addLink', - 'params' => array( - 'name' => 'development/overview', - 'label' => 'Overview', - 'title' => 'Overview', - 'uri' => 'overview.php' - ) - ), - array( - 'method' => 'addLink', - 'params' => array( - 'name' => 'development/buildings', - 'label' => 'Buildings', - 'title' => 'Buildings', - 'uri' => 'overview.php' - ) - ), - array( - 'method' => 'addLink', - 'params' => array( - 'name' => 'development/research-lab', - 'label' => 'Research Lab', - 'title' => 'Research Lab', - 'uri' => 'overview.php', - 'params' => array( - 'mode' => 'research' - ) - ) - ), - array( - 'method' => 'addLink', - 'params' => array( - 'name' => 'development/shipyard', - 'label' => 'Shipyard', - 'title' => 'Shipyard', - 'uri' => 'overview.php', - 'params' => array( - 'mode' => 'fleet' - ) - ) - ), - array( - 'method' => 'addLink', - 'params' => array( - 'name' => 'development/defenses', - 'label' => 'Defenses', - 'title' => 'Defenses', - 'uri' => 'overview.php', - 'params' => array( - 'mode' => 'defense' - ) - ) - ) - ) - ) - ) - ), - - 'overview' => array( - 'update' => 'empire', - 'reference' => array( - 'content' => array( - 'children' => array( - 'overview.forms' => array( - 'type' => 'core/concat' - ), - 'overview' => array( - 'type' => 'empire/overview', - 'template' => 'empire/overview.phtml' - ), - ) - ), - 'left' => array( - ) - ) - ), - - 'overview.rename-planet' => array( - 'update' => 'overview', - 'reference' => array( - 'overview.forms' => array( - 'children' => array( - 'rename-planet' => array( - 'type' => 'empire/overview.rename-planet', - 'template' => 'empire/overview/form/rename-planet.phtml' - ), - ) - ) - ) - ), - - 'overview.destroy-planet' => array( - 'update' => 'overview', - 'reference' => array( - 'overview.forms' => array( - 'children' => array( - 'destroy-planet' => array( - 'type' => 'empire/overview.destroy-planet', - 'template' => 'empire/overview/form/destroy-planet.phtml' - ), - ) - ) - ) - ), - - 'planet.buildings' => array( - 'update' => 'empire', - 'reference' => array( - 'content' => array( - 'children' => array( - 'topnav' => array( - 'type' => 'empire/topnav', - 'template' => 'empire/topnav.phtml', - ), - 'queue' => array( - 'type' => 'empire/planet.buildings.queue', - 'template' => 'empire/planet/buildings/queue.phtml', - 'actions' => array( - array( - 'method' => 'setItemTemplate', - 'params' => array( - 'template' => 'empire/planet/buildings/queue/item.phtml' - ) - ), - array( - 'method' => 'setItemBlockType', - 'params' => array( - 'blockType' => 'empire/planet.buildings.queue.item' - ) - ) - ) - ), - 'item-list' => array( - 'type' => 'empire/planet.buildings', - 'template' => 'empire/planet/buildings.phtml', - 'children' => array( - 'item-list.items' => array( - 'type' => 'core/concat' - ), - ), - 'actions' => array( - array( - 'method' => 'setItemTemplate', - 'params' => array( - 'template' => 'empire/planet/buildings/item.phtml' - ) - ), - array( - 'method' => 'setItemBlockType', - 'params' => array( - 'blockType' => 'empire/planet.buildings.item' - ) - ) - ) - ), - ) - ) - ) - ), - - 'planet.shipyard' => array( - 'update' => 'empire', - 'reference' => array( - 'content' => array( - 'children' => array( - 'topnav' => array( - 'type' => 'empire/topnav', - 'template' => 'empire/topnav.phtml', - ), - 'item-list' => array( - 'type' => 'empire/planet.shipyard', - 'template' => 'empire/planet/shipyard.phtml', - 'children' => array( - 'item-list.items' => array( - 'type' => 'core/concat' - ), - ), - 'actions' => array( - array( - 'method' => 'setItemTemplate', - 'params' => array( - 'template' => 'empire/planet/shipyard/item.phtml' - ) - ), - array( - 'method' => 'setItemBlockType', - 'params' => array( - 'blockType' => 'empire/planet.shipyard.item' - ) - ), - ) - ), - 'queue' => array( - 'type' => 'empire/planet.shipyard.queue', - 'template' => 'empire/planet/shipyard/queue.phtml', - 'actions' => array( - array( - 'method' => 'setItemTemplate', - 'params' => array( - 'template' => 'empire/planet/shipyard/queue/item.phtml' - ) - ), - array( - 'method' => 'setItemBlockType', - 'params' => array( - 'blockType' => 'empire/planet.shipyard.queue.item' - ) - ) - ) - ), - ) - ) - ) - ), - - 'planet.defense' => array( - 'update' => 'planet.shipyard', - 'reference' => array( - 'item-list' => array( - 'actions' => array( - array( - 'method' => 'setType', - 'params' => array( - 'type' => Legacies_Empire::TYPE_DEFENSE - ) - ) - ) - ) - ) - ), - - 'planet.research-lab' => array( - 'update' => 'empire', - 'reference' => array( - 'content' => array( - 'children' => array( - 'topnav' => array( - 'type' => 'empire/topnav', - 'template' => 'empire/topnav.phtml', - ), - 'item-list' => array( - 'type' => 'empire/planet.research-lab', - 'template' => 'empire/planet/research-lab.phtml', - 'children' => array( - 'item-list.items' => array( - 'type' => 'core/concat' - ), - ), - 'actions' => array( - array( - 'method' => 'setItemTemplate', - 'params' => array( - 'template' => 'empire/planet/research-lab/item.phtml' - ) - ), - array( - 'method' => 'setItemBlockType', - 'params' => array( - 'blockType' => 'empire/planet.research-lab.item' - ) - ), - ) - ), - 'queue' => array( - 'type' => 'empire/planet.research-lab.queue', - 'template' => 'empire/planet/research-lab/queue.phtml', - 'actions' => array( - array( - 'method' => 'setItemTemplate', - 'params' => array( - 'template' => 'empire/planet/research-lab/queue/item.phtml' - ) - ), - array( - 'method' => 'setItemBlockType', - 'params' => array( - 'blockType' => 'empire/planet.research-lab.queue.item' - ) - ) - ) - ) - ) - ) - ) - ) - ); diff --git a/includes/application/design/layouts/page.php b/includes/application/design/layouts/page.php deleted file mode 100644 index df732a1..0000000 --- a/includes/application/design/layouts/page.php +++ /dev/null @@ -1,206 +0,0 @@ - array( - 'update' => 'default' - ), - - '2columns-left' => array( - 'update' => 'default', - 'template' => 'page/2columns-left.phtml', - 'reference' => array( - 'root' => array( - 'children' => array( - 'left' => array( - 'type' => 'core/concat', - 'children' => array( - 'navigation' => array( - 'type' => 'core/html.navigation', - 'template' => 'page/html/navigation.phtml' - ) - ) - ) - ) - ) - ) - ), - - '2columns-right' => array( - 'update' => 'default', - 'template' => 'page/2columns-right.phtml', - 'reference' => array( - 'root' => array( - 'children' => array( - 'right' => array( - 'type' => 'core/concat' - ), - ) - ) - ) - ), - - '3columns' => array( - 'update' => 'default', - 'template' => 'page/3columns.phtml', - 'reference' => array( - 'root' => array( - 'children' => array( - 'left' => array( - 'type' => 'core/concat' - ), - 'right' => array( - 'type' => 'core/concat' - ), - ) - ) - ) - ), - - 'default' => array( - 'type' => 'core/html.page', - 'template' => 'page/1column.phtml', - 'children' => array( - 'head' => array( - 'type' => 'core/html.head', - 'template' => 'page/html/head.phtml', - 'actions' => array( - array( - 'method' => 'addCss', - 'params' => array( - 'stylesheet' => 'css/deprecated/default.css' - ) - ), - array( - 'method' => 'addCss', - 'params' => array( - 'stylesheet' => 'css/deprecated/formate.css' - ) - ), - array( - 'method' => 'addCss', - 'params' => array( - 'stylesheet' => 'css/legacies.css' - ) - ) - ) - ), - 'header' => array( - 'type' => 'core/template', - 'template' => 'page/html/header.phtml', - 'children' => array( - 'menu' => array( - 'type' => 'core/html.navigation', - 'template' => 'page/html/navigation.phtml', - ), - 'planet-list' => array( - 'type' => 'empire/planet-list', - 'template' => 'empire/planet-list.phtml', - ) - ) - ), - 'footer' => array( - 'type' => 'core/template', - 'template' => 'page/html/footer.phtml' - ), - 'content' => array( - 'type' => 'core/concat' - ) - ) - ), - - 'ajax' => array( - 'type' => 'core/html.page', - 'template' => 'page/empty.phtml', - 'children' => array( - 'content' => array( - 'type' => 'core/concat' - ) - ) - ), - - 'empty' => array( - 'type' => 'core/html.page', - 'template' => 'page/empty.phtml', - 'children' => array( - 'head' => array( - 'type' => 'core/html.head', - 'template' => 'page/html/head.phtml' - ), - 'content' => array( - 'type' => 'core/concat' - ) - ) - ), - - 'message' => array( - 'update' => 'default', - 'reference' => array( - 'content' => array( - 'children' => array( - 'message' => array( - 'type' => 'core/template', - 'template' => 'page/html/message.phtml' - ), - ) - ) - ) - ), - - 'login' => array( - 'update' => '1column', - 'reference' => array( - 'content' => array( - 'children' => array( - 'login' => array( - 'type' => 'core/template', - 'template' => 'user/login.phtml' - ), - ) - ), - 'head' => array( - 'actions' => array( - array( - 'method' => 'addCss', - 'params' => array( - 'stylesheet' => 'css/deprecated/styles.css' - ) - ), - array( - 'method' => 'addCss', - 'params' => array( - 'stylesheet' => 'css/deprecated/about.css' - ) - ) - ) - ) - ) - ), - - 'registration' => array( - 'update' => '1column', - 'reference' => array( - 'content' => array( - 'children' => array( - 'registration' => array( - 'type' => 'core/template', - 'template' => 'user/registration.phtml' - ), - ) - ), - 'head' => array( - 'actions' => array( - array( - 'method' => 'addCss', - 'params' => array( - 'stylesheet' => 'css/deprecated/styles.css' - ) - ), - array( - 'method' => 'addCss', - 'params' => array( - 'stylesheet' => 'css/deprecated/about.css' - ) - ) - ) - ) - ) - ) - ); diff --git a/includes/application/design/scripts/deprecated/admin/overview_body.tpl b/includes/application/design/scripts/deprecated/admin/overview_body.tpl deleted file mode 100644 index bcc3642..0000000 --- a/includes/application/design/scripts/deprecated/admin/overview_body.tpl +++ /dev/null @@ -1,35 +0,0 @@ -

-

getData('adm_ov_title')?>

- - - - - - - -
getData('adm_ov_infos')?>
getData('adm_ov_yourv')?>: getData('adm_ov_data_yourv')?>getData('adm_ov_lastv')?>: getData('adm_ov_here')?>
-
- - - - - - - - - - - - - - - - - - - - getData('adm_ov_data_table')?> - - - -
getData('adm_ov_onlin')?>
getData('adm_ul_id')?>getData('adm_ul_name')?>getData('adm_ul_adip')?>getData('adm_ov_ally')?>getData('adm_ov_point')?>getData('adm_ov_activ')?>getData('usr_email')?>getData('xp_raid')?>getData('xp_min')?>getData('lang_vacancy')?>getData('banned_lang')?>getData('usr_current_planet')?>getData('usr_current_page')?>
getData('adm_ov_count')?>: getData('adm_ov_data_count')?>
\ No newline at end of file diff --git a/includes/application/design/scripts/deprecated/agreement.tpl b/includes/application/design/scripts/deprecated/agreement.tpl deleted file mode 100644 index 44c2012..0000000 --- a/includes/application/design/scripts/deprecated/agreement.tpl +++ /dev/null @@ -1 +0,0 @@ -N/A \ No newline at end of file diff --git a/includes/application/design/scripts/deprecated/alliance_admin_laws.tpl b/includes/application/design/scripts/deprecated/alliance_admin_laws.tpl deleted file mode 100644 index 2935d69..0000000 --- a/includes/application/design/scripts/deprecated/alliance_admin_laws.tpl +++ /dev/null @@ -1,70 +0,0 @@ -
- - -getData('list')?> - - -
getData('Configure_laws')?>
- -
- -
- - - - - - - - - - - - -
getData('Range_make')?>
getData('Range_name')?>
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
getData('Law_leyends')?>
getData('Alliance_dissolve')?>
getData('Expel_users')?>
getData('See_the_requests')?>
getData('See_the_list_members')?>
getData('Check_the_requests')?>
getData('Alliance_admin')?>
getData('See_the_online_list_member')?>
getData('Make_a_circular_message')?>
getData('Left_hand_text')?>
getData('Return_to_overview')?>
- \ No newline at end of file diff --git a/includes/application/design/scripts/deprecated/alliance_admin_laws_head.tpl b/includes/application/design/scripts/deprecated/alliance_admin_laws_head.tpl deleted file mode 100644 index 131303d..0000000 --- a/includes/application/design/scripts/deprecated/alliance_admin_laws_head.tpl +++ /dev/null @@ -1,15 +0,0 @@ -
-
- - - getData('Range_name')?> - - - - - - - - - - diff --git a/includes/application/design/scripts/deprecated/alliance_admin_laws_row.tpl b/includes/application/design/scripts/deprecated/alliance_admin_laws_row.tpl deleted file mode 100644 index 014a5c6..0000000 --- a/includes/application/design/scripts/deprecated/alliance_admin_laws_row.tpl +++ /dev/null @@ -1,16 +0,0 @@ -
- - getData('delete')?> -  getData('r0')?>  - - getData('r1')?> - getData('r2')?> - getData('r3')?> - getData('r4')?> - getData('r5')?> - getData('r6')?> - getData('r7')?> - getData('r8')?> - getData('r9')?> - - \ No newline at end of file diff --git a/includes/application/design/scripts/deprecated/buildings_builds.tpl b/includes/application/design/scripts/deprecated/buildings_builds.tpl deleted file mode 100644 index d6085b8..0000000 --- a/includes/application/design/scripts/deprecated/buildings_builds.tpl +++ /dev/null @@ -1,15 +0,0 @@ -
-
-getData('BuildListScript')?> - - getData('BuildList')?> - - - - - getData('BuildingsList')?> -
getData('bld_usedcells')?> - getData('planet_field_current')?> / getData('planet_field_max')?> getData('bld_theyare')?> getData('field_libre')?> getData('bld_cellfree')?> -
-
-
\ No newline at end of file diff --git a/includes/application/design/scripts/deprecated/buildings_builds_queue_script.tpl b/includes/application/design/scripts/deprecated/buildings_builds_queue_script.tpl deleted file mode 100644 index 7d042ac..0000000 --- a/includes/application/design/scripts/deprecated/buildings_builds_queue_script.tpl +++ /dev/null @@ -1,107 +0,0 @@ - -
- - -
-
- - - - - - - - - - -
getData('work_todo')?>
- -getData('total_left_time')?> - -getData('pretty_time_b_hangar')?> -
-
\ No newline at end of file diff --git a/includes/application/design/scripts/deprecated/buildings_builds_row.tpl b/includes/application/design/scripts/deprecated/buildings_builds_row.tpl deleted file mode 100644 index 86c0f05..0000000 --- a/includes/application/design/scripts/deprecated/buildings_builds_row.tpl +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - getData('n')?>getData('nivel')?>
- getData('descriptions')?>
- getData('price')?> - getData('time')?> - getData('rest_price')?> - - getData('click')?> - \ No newline at end of file diff --git a/includes/application/design/scripts/deprecated/buildings_builds_script.tpl b/includes/application/design/scripts/deprecated/buildings_builds_script.tpl deleted file mode 100644 index 480c5dd..0000000 --- a/includes/application/design/scripts/deprecated/buildings_builds_script.tpl +++ /dev/null @@ -1,8 +0,0 @@ - -
\ No newline at end of file diff --git a/includes/application/design/scripts/deprecated/buildings_defense.tpl b/includes/application/design/scripts/deprecated/buildings_defense.tpl deleted file mode 100644 index ee402c5..0000000 --- a/includes/application/design/scripts/deprecated/buildings_defense.tpl +++ /dev/null @@ -1,19 +0,0 @@ -
-
- - - - - -
-
- - getData('buildlist')?> - - - -
-
-
-getData('buildinglist')?> -
\ No newline at end of file diff --git a/includes/application/design/scripts/deprecated/buildings_fleet.tpl b/includes/application/design/scripts/deprecated/buildings_fleet.tpl deleted file mode 100644 index 0ab1b2f..0000000 --- a/includes/application/design/scripts/deprecated/buildings_fleet.tpl +++ /dev/null @@ -1,19 +0,0 @@ -
-
- - - - - -
-
- - getData('buildlist')?> - - - -
-
-
-getData('buildinglist')?> -
\ No newline at end of file diff --git a/includes/application/design/scripts/deprecated/buildings_research.tpl b/includes/application/design/scripts/deprecated/buildings_research.tpl deleted file mode 100644 index 080cc49..0000000 --- a/includes/application/design/scripts/deprecated/buildings_research.tpl +++ /dev/null @@ -1,15 +0,0 @@ -
-getData('noresearch')?> -
- - - - -
- - - getData('technolist')?> - -
-
-
\ No newline at end of file diff --git a/includes/application/design/scripts/deprecated/buildings_research_row.tpl b/includes/application/design/scripts/deprecated/buildings_research_row.tpl deleted file mode 100644 index a7247a3..0000000 --- a/includes/application/design/scripts/deprecated/buildings_research_row.tpl +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - getData('tech_name')?> getData('tech_level')?>
getData('tech_descr')?>
- getData('tech_price')?> - getData('search_time')?> - getData('tech_restp')?> - - - getData('tech_link')?> - - \ No newline at end of file diff --git a/includes/application/design/scripts/deprecated/buildings_research_script.tpl b/includes/application/design/scripts/deprecated/buildings_research_script.tpl deleted file mode 100644 index af1cb87..0000000 --- a/includes/application/design/scripts/deprecated/buildings_research_script.tpl +++ /dev/null @@ -1,23 +0,0 @@ -
- \ No newline at end of file diff --git a/includes/application/design/scripts/deprecated/buildings_script.tpl b/includes/application/design/scripts/deprecated/buildings_script.tpl deleted file mode 100644 index 9e251a6..0000000 --- a/includes/application/design/scripts/deprecated/buildings_script.tpl +++ /dev/null @@ -1,39 +0,0 @@ -
Production Actuelle: - -
- \ No newline at end of file diff --git a/includes/application/design/scripts/deprecated/install/ins_acc.tpl b/includes/application/design/scripts/deprecated/install/ins_acc.tpl deleted file mode 100644 index 990f8db..0000000 --- a/includes/application/design/scripts/deprecated/install/ins_acc.tpl +++ /dev/null @@ -1,44 +0,0 @@ - - -
getData('ins_tx_acc1')?>
-getData('ins_tx_acc2')?>

- - - - - - - - - - - - - - - - - - - - - -
getData('ins_acc_user')?>:
getData('ins_acc_pass')?>:
getData('ins_acc_email')?>:
getData('ins_acc_planet')?>:
getData('ins_acc_sex')?>:
-
- - - - - \ No newline at end of file diff --git a/includes/application/design/scripts/deprecated/install/ins_acc_done.tpl b/includes/application/design/scripts/deprecated/install/ins_acc_done.tpl deleted file mode 100644 index 2e14361..0000000 --- a/includes/application/design/scripts/deprecated/install/ins_acc_done.tpl +++ /dev/null @@ -1,9 +0,0 @@ - - -
getData('ins_tx_done2')?>
-getData('ins_tx_done3')?>

- - - - - \ No newline at end of file diff --git a/includes/application/design/scripts/deprecated/install/ins_body.tpl b/includes/application/design/scripts/deprecated/install/ins_body.tpl deleted file mode 100644 index 295e294..0000000 --- a/includes/application/design/scripts/deprecated/install/ins_body.tpl +++ /dev/null @@ -1,28 +0,0 @@ -

- - - - - - - - -getData('ins_page')?> - -
getData('ins_appname')?>getData('ins_tx_sys')?>
getData('ins_tx_state')?> getData('ins_state')?>
- - - - - - - - - - - - - - - -
getData('ins_mnu_intro')?>
getData('ins_mnu_inst')?>
getData('ins_mnu_goto')?>
getData('ins_mnu_upgr')?>
getData('ins_mnu_quit')?>
\ No newline at end of file diff --git a/includes/application/design/scripts/deprecated/install/ins_form.tpl b/includes/application/design/scripts/deprecated/install/ins_form.tpl deleted file mode 100644 index 9b3b364..0000000 --- a/includes/application/design/scripts/deprecated/install/ins_form.tpl +++ /dev/null @@ -1,33 +0,0 @@ - - -
getData('ins_tx_inst1')?>
-getData('ins_tx_inst2')?>
-getData('ins_tx_inst3')?>

- - - - - - - - - - - - - - - - - - - - - -
getData('ins_form_server')?>:
getData('ins_form_db')?>:
getData('ins_form_prefix')?>:
getData('ins_form_login')?>:
getData('ins_form_pass')?>:
-
- - - - - \ No newline at end of file diff --git a/includes/application/design/scripts/deprecated/install/ins_form_done.tpl b/includes/application/design/scripts/deprecated/install/ins_form_done.tpl deleted file mode 100644 index 3d9426d..0000000 --- a/includes/application/design/scripts/deprecated/install/ins_form_done.tpl +++ /dev/null @@ -1,8 +0,0 @@ - - -

getData('ins_tx_done1')?>

- - - - - \ No newline at end of file diff --git a/includes/application/design/scripts/deprecated/install/ins_goto_done.tpl b/includes/application/design/scripts/deprecated/install/ins_goto_done.tpl deleted file mode 100644 index 55d1b13..0000000 --- a/includes/application/design/scripts/deprecated/install/ins_goto_done.tpl +++ /dev/null @@ -1,9 +0,0 @@ - - -
getData('ins_tx_done4')?>
-getData('ins_tx_done3')?>

- - - - - \ No newline at end of file diff --git a/includes/application/design/scripts/deprecated/install/ins_goto_form.tpl b/includes/application/design/scripts/deprecated/install/ins_goto_form.tpl deleted file mode 100644 index 0539d11..0000000 --- a/includes/application/design/scripts/deprecated/install/ins_goto_form.tpl +++ /dev/null @@ -1,33 +0,0 @@ - - -
getData('ins_tx_inst1')?>
-getData('ins_tx_goto4')?>
-getData('ins_tx_goto5')?>

- - - - - - - - - - - - - - - - - - - - - -
getData('ins_form_server')?>:
getData('ins_form_db')?>:
getData('ins_form_prefix')?>:
getData('ins_form_login')?>:
getData('ins_form_pass')?>:
-
- - - - - \ No newline at end of file diff --git a/includes/application/design/scripts/deprecated/install/ins_goto_intro.tpl b/includes/application/design/scripts/deprecated/install/ins_goto_intro.tpl deleted file mode 100644 index 16c01e9..0000000 --- a/includes/application/design/scripts/deprecated/install/ins_goto_intro.tpl +++ /dev/null @@ -1,10 +0,0 @@ - - -
getData('ins_tx_goto1')?>
-getData('ins_tx_goto2')?>
-getData('ins_tx_goto3')?>

- - - - - \ No newline at end of file diff --git a/includes/application/design/scripts/deprecated/install/ins_intro.tpl b/includes/application/design/scripts/deprecated/install/ins_intro.tpl deleted file mode 100644 index fe25771..0000000 --- a/includes/application/design/scripts/deprecated/install/ins_intro.tpl +++ /dev/null @@ -1,11 +0,0 @@ - - -
getData('ins_tx_welco')?>
-getData('ins_tx_intr1')?>
-getData('ins_tx_intr2')?>
-getData('ins_tx_intr3')?>

- - - - - \ No newline at end of file diff --git a/includes/application/design/scripts/deprecated/left_menu.tpl b/includes/application/design/scripts/deprecated/left_menu.tpl deleted file mode 100644 index 1a5a0be..0000000 --- a/includes/application/design/scripts/deprecated/left_menu.tpl +++ /dev/null @@ -1,97 +0,0 @@ -
- - -
- -
- -
\ No newline at end of file diff --git a/includes/application/design/scripts/empire/overview/form/rename-planet.phtml b/includes/application/design/scripts/empire/overview/form/rename-planet.phtml deleted file mode 100644 index 45ba7da..0000000 --- a/includes/application/design/scripts/empire/overview/form/rename-planet.phtml +++ /dev/null @@ -1,10 +0,0 @@ -
-
- - - - - - -
-
\ No newline at end of file diff --git a/includes/application/design/scripts/empire/overview/planet/list/item.phtml b/includes/application/design/scripts/empire/overview/planet/list/item.phtml deleted file mode 100644 index 7d778ea..0000000 --- a/includes/application/design/scripts/empire/overview/planet/list/item.phtml +++ /dev/null @@ -1,10 +0,0 @@ - -

escape($this['planet']->getData('name'))?>

-

- -

- count() > 0):?> -

escape($this['queue_item']->getData('building_id'))?>

- -

__('Idle.')?>

- \ No newline at end of file diff --git a/includes/application/design/scripts/empire/overview/planet/view.phtml b/includes/application/design/scripts/empire/overview/planet/view.phtml deleted file mode 100644 index 8230a16..0000000 --- a/includes/application/design/scripts/empire/overview/planet/view.phtml +++ /dev/null @@ -1 +0,0 @@ -planetList->render() ?> diff --git a/includes/application/design/scripts/empire/planet/buildings.phtml b/includes/application/design/scripts/empire/planet/buildings.phtml deleted file mode 100644 index c8e4fd9..0000000 --- a/includes/application/design/scripts/empire/planet/buildings.phtml +++ /dev/null @@ -1,4 +0,0 @@ -
-

__('Buildings')?>

- getPartial('item-list.items')->render()?> -
\ No newline at end of file diff --git a/includes/application/design/scripts/empire/planet/buildings/item.phtml b/includes/application/design/scripts/empire/planet/buildings/item.phtml deleted file mode 100644 index 30c6f33..0000000 --- a/includes/application/design/scripts/empire/planet/buildings/item.phtml +++ /dev/null @@ -1,27 +0,0 @@ - -
-

escape($this->getName())?> (renderNumber($this->getLevel())?>)

-
-
- -
-

getDescription()?>

-
    - getResourcesConfigForNextLevel() as $resourceId => $resourceConfig):?> -
  • - getResourceName($resourceId)?> - renderNumber($resourceConfig->getData('value'))?> - hasData('requirement')):?> - (renderNumber($resourceConfig->getData('requirement'))?>) - - (renderNumber($resourceConfig->getData('overflow'))?>) - -
  • - -
-

__('Building time: %s', $this->renderTime($this->getBuildingTimeForNextLevel(), true))?> -

- -
\ No newline at end of file diff --git a/includes/application/design/scripts/empire/planet/buildings/queue/item.phtml b/includes/application/design/scripts/empire/planet/buildings/queue/item.phtml deleted file mode 100644 index 0825de3..0000000 --- a/includes/application/design/scripts/empire/planet/buildings/queue/item.phtml +++ /dev/null @@ -1,8 +0,0 @@ - -
- - escape($this->getName())?> (renderNumber($this->getItemQueuedLevel())?>) - -
\ No newline at end of file diff --git a/includes/application/design/scripts/empire/planet/research-lab.phtml b/includes/application/design/scripts/empire/planet/research-lab.phtml deleted file mode 100644 index 78be4c0..0000000 --- a/includes/application/design/scripts/empire/planet/research-lab.phtml +++ /dev/null @@ -1,4 +0,0 @@ -
-

__('Research Laboratory')?>

- getPartial('item-list.items')->render()?> -
\ No newline at end of file diff --git a/includes/application/design/scripts/empire/planet/research-lab/item.phtml b/includes/application/design/scripts/empire/planet/research-lab/item.phtml deleted file mode 100644 index 9fd2017..0000000 --- a/includes/application/design/scripts/empire/planet/research-lab/item.phtml +++ /dev/null @@ -1,27 +0,0 @@ - -
-

escape($this->getName())?> (renderNumber($this->getLevel())?>)

-
-
- -
-

getDescription()?>

-
    - getResourcesConfigForNextLevel() as $resourceId => $resourceConfig):?> -
  • - getResourceName($resourceId)?> - renderNumber($resourceConfig->getData('value'))?> - hasData('requirement')):?> - (renderNumber($resourceConfig->getData('requirement'))?>) - - (renderNumber($resourceConfig->getData('overflow'))?>) - -
  • - -
-

__('Building time: %s', $this->renderTime($this->getBuildingTime(1), false))?> -

- -
\ No newline at end of file diff --git a/includes/application/design/scripts/empire/planet/research-lab/queue/item.phtml b/includes/application/design/scripts/empire/planet/research-lab/queue/item.phtml deleted file mode 100644 index 0825de3..0000000 --- a/includes/application/design/scripts/empire/planet/research-lab/queue/item.phtml +++ /dev/null @@ -1,8 +0,0 @@ - -
- - escape($this->getName())?> (renderNumber($this->getItemQueuedLevel())?>) - -
\ No newline at end of file diff --git a/includes/application/design/scripts/empire/planet/shipyard.phtml b/includes/application/design/scripts/empire/planet/shipyard.phtml deleted file mode 100644 index 9a7d684..0000000 --- a/includes/application/design/scripts/empire/planet/shipyard.phtml +++ /dev/null @@ -1,20 +0,0 @@ -
-

__('Shipyard')?>

-
-
- getPartial('item-list.items')->render()?> -
- -
- -
\ No newline at end of file diff --git a/includes/application/design/scripts/empire/planet/shipyard/item.phtml b/includes/application/design/scripts/empire/planet/shipyard/item.phtml deleted file mode 100644 index 184683e..0000000 --- a/includes/application/design/scripts/empire/planet/shipyard/item.phtml +++ /dev/null @@ -1,29 +0,0 @@ - -
-

escape($this->getName())?> (renderNumber($this->getQty())?>)

-
-
- -
-

getDescription()?>

-
    - getResourcesConfigForQty(1) as $resourceId => $resourceConfig):?> -
  • - getResourceName($resourceId)?> - renderNumber($resourceConfig->getData('value'))?> - hasData('requirement')):?> - (renderNumber($resourceConfig->getData('requirement'))?>) - - (renderNumber($resourceConfig->getData('overflow'))?>) - -
  • - -
-

__('Building time: %s', $this->renderTime($this->getBuildingTime(1), false))?> -

- -
\ No newline at end of file diff --git a/includes/application/design/scripts/empire/planet/shipyard/queue.phtml b/includes/application/design/scripts/empire/planet/shipyard/queue.phtml deleted file mode 100644 index b3d9bbc..0000000 --- a/includes/application/design/scripts/empire/planet/shipyard/queue.phtml +++ /dev/null @@ -1 +0,0 @@ -getResourceIds() as $resourceId):?> -
-getResourceBlock($resourceId)->render()?> -
- \ No newline at end of file diff --git a/includes/application/design/scripts/empire/topnav.phtml b/includes/application/design/scripts/empire/topnav.phtml deleted file mode 100644 index 8a4f2e4..0000000 --- a/includes/application/design/scripts/empire/topnav.phtml +++ /dev/null @@ -1,65 +0,0 @@ -
-getPlanetCollection() as $planet):?> -
- getId() != $this->getCurrentPlanet()->getId()):?> - escape($planet->getName())?> [escape($planet->getCoords())?>] - - escape($planet->getName())?> [escape($planet->getCoords())?>] - -
- -
-
-
- <?php echo $this->__('Metal')?> -

- getCurrentPlanet()->isResourceCapped(Legacies_Empire::RESOURCE_METAL)):?> - renderNumber($this->getCurrentPlanet()->getResourceAmount(Legacies_Empire::RESOURCE_METAL))?> - - renderNumber($this->getCurrentPlanet()->getResourceAmount(Legacies_Empire::RESOURCE_METAL))?> - -

-
-
- <?php echo $this->__('Cristal')?> -

- getCurrentPlanet()->isResourceCapped(Legacies_Empire::RESOURCE_CRISTAL)):?> - renderNumber($this->getCurrentPlanet()->getResourceAmount(Legacies_Empire::RESOURCE_CRISTAL))?> - - renderNumber($this->getCurrentPlanet()->getResourceAmount(Legacies_Empire::RESOURCE_CRISTAL))?> - -

-
-
- <?php echo $this->__('Deuterium')?> -

- getCurrentPlanet()->isResourceCapped(Legacies_Empire::RESOURCE_DEUTERIUM)):?> - renderNumber($this->getCurrentPlanet()->getResourceAmount(Legacies_Empire::RESOURCE_DEUTERIUM))?> - - renderNumber($this->getCurrentPlanet()->getResourceAmount(Legacies_Empire::RESOURCE_DEUTERIUM))?> - -

-
-
- <?php echo $this->__('Energy')?> -

- getCurrentPlanet()->isResourceCapped(Legacies_Empire::RESOURCE_ENERGY)):?> - renderNumber($this->getCurrentPlanet()->getResourceAmount(Legacies_Empire::RESOURCE_ENERGY))?> / renderNumber($this->getCurrentPlanet()->getResourceCap(Legacies_Empire::RESOURCE_ENERGY))?> - - renderNumber($this->getCurrentPlanet()->getResourceAmount(Legacies_Empire::RESOURCE_ENERGY))?> / renderNumber($this->getCurrentPlanet()->getResourceCap(Legacies_Empire::RESOURCE_ENERGY))?> - -

-
-
- <?php echo $this->__('Messages')?> -

- getCurrentUser()->getNewMessagesCount()) > 1):?> - __('%1$d messages.', $count)?> - - __('1 message.')?> - - __('No message.')?> - -

-
-
diff --git a/includes/application/design/scripts/page/html/navigation.phtml b/includes/application/design/scripts/page/html/navigation.phtml deleted file mode 100644 index 7552419..0000000 --- a/includes/application/design/scripts/page/html/navigation.phtml +++ /dev/null @@ -1,5 +0,0 @@ - diff --git a/includes/application/design/scripts/page/html/navigation/link.phtml b/includes/application/design/scripts/page/html/navigation/link.phtml deleted file mode 100644 index 8e44687..0000000 --- a/includes/application/design/scripts/page/html/navigation/link.phtml +++ /dev/null @@ -1 +0,0 @@ -escape($link->getLabel())?> diff --git a/includes/application/design/scripts/page/html/navigation/node.phtml b/includes/application/design/scripts/page/html/navigation/node.phtml deleted file mode 100644 index adebdab..0000000 --- a/includes/application/design/scripts/page/html/navigation/node.phtml +++ /dev/null @@ -1,5 +0,0 @@ - \ No newline at end of file diff --git a/includes/application/design/scripts/user/login.phtml b/includes/application/design/scripts/user/login.phtml deleted file mode 100644 index 4e51e00..0000000 --- a/includes/application/design/scripts/user/login.phtml +++ /dev/null @@ -1,54 +0,0 @@ -
-
-
-
- - - - - - - - - - -
- __('Username')?> - __('Password')?> -
- __('Remember me')?> - -
- __('I have lost my password.')?> -
-
-
-
- -
-
__('Welcome on %s!', $this->escape($this->getData('server_name')))?>
-
-
-
-
__('%1$s make you an emperor. Conquer outer space and master other players on %1$s.', $this->getData('server_name'))?>
-
-
__('Register now!')?>
-
-
-
- - __('Player count: ')?>getData('user_count')?> - - __('Latest player: ')?>getData('latest_player')?> - - __('Online players: ')?> getData('online_players')?> - -
-
-
-
-
-
-
\ No newline at end of file diff --git a/includes/application/scripts/legacies/client.js b/includes/application/scripts/legacies/client.js deleted file mode 100644 index f4b6bd0..0000000 --- a/includes/application/scripts/legacies/client.js +++ /dev/null @@ -1,265 +0,0 @@ -/** - * This file is part of XNova:Legacies - * - * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.xnova-ng.org/ - * - * Copyright (c) 2009-Present, XNova Support Team - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ -/** - * Main application script execution class - * - * @param string responder - * @param int messageOffset - */ - -function Legacies_Client(responder, messageOffset) { - if (!document.querySelectorAll) { - alert("Your browser is not compatible with CSS selectors API.\n\nCould not continue."); - return; - } - this.responder = responder; - this.messages = []; - this.messageId = messageOffset || 1; - this.callbacks = {}; - this.recurrentMessages = []; - - this.send = (function() { - if (this.messages.length == 0) { - return this; - } - var request = new XMLHttpRequest(); - request.open('POST', this.responder, false); - request.send(JSON.stringify(this.messages)); - this.messages = []; - for (var i in this.recurrentMessages) { - this.enqueue(this.recurrentMessages[i].action, this.recurrentMessages[i].params, this.recurrentMessages[i].callback); - } - if(request.status == 404) { - alert('Request failed, responder not found.'); - return this; - } - try { - var response = JSON.parse(request.responseText); - } catch (e) { - alert('Invalid response.'); - return this; - } - if(request.status == 200) { - for (var i in response) { - this._callback(response[i]); - } - } - return this; - }).bind(this); - - this.main = (function(interval) { - setInterval(this.send, interval || 30000); - }).bind(this); - - this.enqueue = (function(action, params){ - this.messages.push({'uid':this.messageId++,'action':action,'params':params}); - return this; - }).bind(this); - - this.enqueueRecurrent = (function(action, params, callback) { - this.recurrentMessages.push({'callback':callback,'action':action,'params':params}); - this.enqueue(action, params, callback); - }).bind(this); - - this._callback = (function(message){ - if (message.error === undefined || message.payload === undefined) { - return this; - } - if (message.error === true) { - if (typeof(message.payload.messages) == 'string') { - alert(message.payload.messages); - } else { - var info = ''; - for (var i in message.payload.messages) { - info = info + "\n[" + i + "]:\n" + message.payload.messages[i].join("\n") + "\n"; - } - alert("Errors were returned:\n" + info); - } - return this; - } - if (message.callback && this.CallbackType[message.callback]) { - (this.CallbackType[message.callback]).bind(this)(message.payload); - } - return this; - }).bind(this); - - this.login = (function(username, password, rememberme) { - var params = { - 'username': username, - 'password': password, - 'rememberme': rememberme || false - }; - this.enqueue('user.account.login', params).send(); - return this; - }).bind(this); - - this.logout = (function() { - this.enqueue('user.account.logout', {}).send(); - return this; - }).bind(this); - - this.form = (function(event) { - event.preventDefault(); - var form = event.target; - var params = {}; - for (var i = 0; i < form.length; i++) { - if (!form[i].name || !form[i].type) { - continue; - } - if (form[i].type == 'checkbox') { - if (form[i].checked) { - params[form[i].name] = true; - } else { - params[form[i].name] = false; - } - } else if (form[i].type == 'radio') { - params[form[i].name] = form[i].value; - } else if (form[i].value !== undefined) { - params[form[i].name] = form[i].value; - } - } - var action = form.action.slice(form.action.indexOf('#') + 1); - this.enqueue(action, params, this.CallbackType.updater).send(); - }).bind(this); - - this.CallbackType = { - redirector: function(payload) { - if (payload.redirect) { - document.location.href = payload.redirect; - } - }, - updater: function(payload) { - if (payload.html && payload.selector) { - var parent = $$(payload.selector); - var handler = document.createElement("div"); - handler.innerHTML = payload.html; - - var fragment = document.createDocumentFragment(); - for (var i = 0; i < handler.childNodes.length; i++) { - fragment.appendChild(handler.childNodes[i]); - } - - for (var i = 0; i < parent.length; i++) { - parent[i].appendChild(fragment.cloneNode(true)); - } - } - }, - script: function(payload) { - if (payload.script) { - eval(payload.script); - } - }, - error: function(payload) { - if (payload.messages) { - alert(payload.messages.join(', ')); - } - }, - show: function(payload) { - if (payload.selector) { - var elementList = $$(payload.selector); - for (var i = 0; i < elementList.length; i++) { - elementList[i].style.display = 'block'; - } - } - }, - hide: function(payload) { - if (payload.selector) { - var elementList = $$(payload.selector); - for (var i = 0; i < elementList.length; i++) { - elementList[i].style.display = 'none'; - } - } - }, - callback: function(payload) { - if (payload.callback) { - payload.callback.apply(this, payload.params); - } - }, - enqueueRecurrent: function(payload) { - if (payload.action && payload.params && payload.callback) { - this.enqueueRecurrent(payload.action, payload.params, payload.callback); - } - } - }; -} - -function Legacies_Element(object) { - object.listen = (function(event, callback) { - this.addEventListener(event, callback, false); - return this; - }).bind(object); - - return object; -} - -function Legacies_List(object) { - object.listen = (function(event, callback) { - for (var i in this) { - Legacies_Element(Legacies_Element[i]); - this[i].listen(event, callback); - } - return this; - }).bind(object); - - return object; -} - -function $A(object) { - return Array.prototype.slice.call(object); -} - -function $(element) { - if (typeof(element) == 'string') { - element = document.getElementById(element); - } - Legacies_Element(element); - return element; -} - -function $$(selector, context) { - context = context || document; - var nodeList = context.querySelectorAll(selector); - Legacies_List(nodeList); - return nodeList; -} - -function $E(element, methods) { - for (var i in methods) { - if (methods[i] === undefined) { - continue; - } - element[i] = function(){ - var args = $A(arguments); - args.unshift(element); - methods[i].apply(element, args); - } - element[i].bind(element); - } - return element; -} \ No newline at end of file diff --git a/includes/application/scripts/sizzle.js b/includes/application/scripts/sizzle.js deleted file mode 100644 index 07654d5..0000000 --- a/includes/application/scripts/sizzle.js +++ /dev/null @@ -1,1413 +0,0 @@ -/*! - * Sizzle CSS Selector Engine - * Copyright 2011, The Dojo Foundation - * Released under the MIT, BSD, and GPL Licenses. - * More information: http://sizzlejs.com/ - */ -(function(){ - -var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g, - done = 0, - toString = Object.prototype.toString, - hasDuplicate = false, - baseHasDuplicate = true, - rBackslash = /\\/g, - rNonWord = /\W/; - -// Here we check if the JavaScript engine is using some sort of -// optimization where it does not always call our comparision -// function. If that is the case, discard the hasDuplicate value. -// Thus far that includes Google Chrome. -[0, 0].sort(function() { - baseHasDuplicate = false; - return 0; -}); - -var Sizzle = function( selector, context, results, seed ) { - results = results || []; - context = context || document; - - var origContext = context; - - if ( context.nodeType !== 1 && context.nodeType !== 9 ) { - return []; - } - - if ( !selector || typeof selector !== "string" ) { - return results; - } - - var m, set, checkSet, extra, ret, cur, pop, i, - prune = true, - contextXML = Sizzle.isXML( context ), - parts = [], - soFar = selector; - - // Reset the position of the chunker regexp (start from head) - do { - chunker.exec( "" ); - m = chunker.exec( soFar ); - - if ( m ) { - soFar = m[3]; - - parts.push( m[1] ); - - if ( m[2] ) { - extra = m[3]; - break; - } - } - } while ( m ); - - if ( parts.length > 1 && origPOS.exec( selector ) ) { - - if ( parts.length === 2 && Expr.relative[ parts[0] ] ) { - set = posProcess( parts[0] + parts[1], context ); - - } else { - set = Expr.relative[ parts[0] ] ? - [ context ] : - Sizzle( parts.shift(), context ); - - while ( parts.length ) { - selector = parts.shift(); - - if ( Expr.relative[ selector ] ) { - selector += parts.shift(); - } - - set = posProcess( selector, set ); - } - } - - } else { - // Take a shortcut and set the context if the root selector is an ID - // (but not if it'll be faster if the inner selector is an ID) - if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML && - Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) { - - ret = Sizzle.find( parts.shift(), context, contextXML ); - context = ret.expr ? - Sizzle.filter( ret.expr, ret.set )[0] : - ret.set[0]; - } - - if ( context ) { - ret = seed ? - { expr: parts.pop(), set: makeArray(seed) } : - Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML ); - - set = ret.expr ? - Sizzle.filter( ret.expr, ret.set ) : - ret.set; - - if ( parts.length > 0 ) { - checkSet = makeArray( set ); - - } else { - prune = false; - } - - while ( parts.length ) { - cur = parts.pop(); - pop = cur; - - if ( !Expr.relative[ cur ] ) { - cur = ""; - } else { - pop = parts.pop(); - } - - if ( pop == null ) { - pop = context; - } - - Expr.relative[ cur ]( checkSet, pop, contextXML ); - } - - } else { - checkSet = parts = []; - } - } - - if ( !checkSet ) { - checkSet = set; - } - - if ( !checkSet ) { - Sizzle.error( cur || selector ); - } - - if ( toString.call(checkSet) === "[object Array]" ) { - if ( !prune ) { - results.push.apply( results, checkSet ); - - } else if ( context && context.nodeType === 1 ) { - for ( i = 0; checkSet[i] != null; i++ ) { - if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) { - results.push( set[i] ); - } - } - - } else { - for ( i = 0; checkSet[i] != null; i++ ) { - if ( checkSet[i] && checkSet[i].nodeType === 1 ) { - results.push( set[i] ); - } - } - } - - } else { - makeArray( checkSet, results ); - } - - if ( extra ) { - Sizzle( extra, origContext, results, seed ); - Sizzle.uniqueSort( results ); - } - - return results; -}; - -Sizzle.uniqueSort = function( results ) { - if ( sortOrder ) { - hasDuplicate = baseHasDuplicate; - results.sort( sortOrder ); - - if ( hasDuplicate ) { - for ( var i = 1; i < results.length; i++ ) { - if ( results[i] === results[ i - 1 ] ) { - results.splice( i--, 1 ); - } - } - } - } - - return results; -}; - -Sizzle.matches = function( expr, set ) { - return Sizzle( expr, null, null, set ); -}; - -Sizzle.matchesSelector = function( node, expr ) { - return Sizzle( expr, null, null, [node] ).length > 0; -}; - -Sizzle.find = function( expr, context, isXML ) { - var set; - - if ( !expr ) { - return []; - } - - for ( var i = 0, l = Expr.order.length; i < l; i++ ) { - var match, - type = Expr.order[i]; - - if ( (match = Expr.leftMatch[ type ].exec( expr )) ) { - var left = match[1]; - match.splice( 1, 1 ); - - if ( left.substr( left.length - 1 ) !== "\\" ) { - match[1] = (match[1] || "").replace( rBackslash, "" ); - set = Expr.find[ type ]( match, context, isXML ); - - if ( set != null ) { - expr = expr.replace( Expr.match[ type ], "" ); - break; - } - } - } - } - - if ( !set ) { - set = typeof context.getElementsByTagName !== "undefined" ? - context.getElementsByTagName( "*" ) : - []; - } - - return { set: set, expr: expr }; -}; - -Sizzle.filter = function( expr, set, inplace, not ) { - var match, anyFound, - old = expr, - result = [], - curLoop = set, - isXMLFilter = set && set[0] && Sizzle.isXML( set[0] ); - - while ( expr && set.length ) { - for ( var type in Expr.filter ) { - if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) { - var found, item, - filter = Expr.filter[ type ], - left = match[1]; - - anyFound = false; - - match.splice(1,1); - - if ( left.substr( left.length - 1 ) === "\\" ) { - continue; - } - - if ( curLoop === result ) { - result = []; - } - - if ( Expr.preFilter[ type ] ) { - match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter ); - - if ( !match ) { - anyFound = found = true; - - } else if ( match === true ) { - continue; - } - } - - if ( match ) { - for ( var i = 0; (item = curLoop[i]) != null; i++ ) { - if ( item ) { - found = filter( item, match, i, curLoop ); - var pass = not ^ !!found; - - if ( inplace && found != null ) { - if ( pass ) { - anyFound = true; - - } else { - curLoop[i] = false; - } - - } else if ( pass ) { - result.push( item ); - anyFound = true; - } - } - } - } - - if ( found !== undefined ) { - if ( !inplace ) { - curLoop = result; - } - - expr = expr.replace( Expr.match[ type ], "" ); - - if ( !anyFound ) { - return []; - } - - break; - } - } - } - - // Improper expression - if ( expr === old ) { - if ( anyFound == null ) { - Sizzle.error( expr ); - - } else { - break; - } - } - - old = expr; - } - - return curLoop; -}; - -Sizzle.error = function( msg ) { - throw "Syntax error, unrecognized expression: " + msg; -}; - -var Expr = Sizzle.selectors = { - order: [ "ID", "NAME", "TAG" ], - - match: { - ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, - CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, - NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/, - ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/, - TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/, - CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/, - POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/, - PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/ - }, - - leftMatch: {}, - - attrMap: { - "class": "className", - "for": "htmlFor" - }, - - attrHandle: { - href: function( elem ) { - return elem.getAttribute( "href" ); - }, - type: function( elem ) { - return elem.getAttribute( "type" ); - } - }, - - relative: { - "+": function(checkSet, part){ - var isPartStr = typeof part === "string", - isTag = isPartStr && !rNonWord.test( part ), - isPartStrNotTag = isPartStr && !isTag; - - if ( isTag ) { - part = part.toLowerCase(); - } - - for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) { - if ( (elem = checkSet[i]) ) { - while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {} - - checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ? - elem || false : - elem === part; - } - } - - if ( isPartStrNotTag ) { - Sizzle.filter( part, checkSet, true ); - } - }, - - ">": function( checkSet, part ) { - var elem, - isPartStr = typeof part === "string", - i = 0, - l = checkSet.length; - - if ( isPartStr && !rNonWord.test( part ) ) { - part = part.toLowerCase(); - - for ( ; i < l; i++ ) { - elem = checkSet[i]; - - if ( elem ) { - var parent = elem.parentNode; - checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false; - } - } - - } else { - for ( ; i < l; i++ ) { - elem = checkSet[i]; - - if ( elem ) { - checkSet[i] = isPartStr ? - elem.parentNode : - elem.parentNode === part; - } - } - - if ( isPartStr ) { - Sizzle.filter( part, checkSet, true ); - } - } - }, - - "": function(checkSet, part, isXML){ - var nodeCheck, - doneName = done++, - checkFn = dirCheck; - - if ( typeof part === "string" && !rNonWord.test( part ) ) { - part = part.toLowerCase(); - nodeCheck = part; - checkFn = dirNodeCheck; - } - - checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML ); - }, - - "~": function( checkSet, part, isXML ) { - var nodeCheck, - doneName = done++, - checkFn = dirCheck; - - if ( typeof part === "string" && !rNonWord.test( part ) ) { - part = part.toLowerCase(); - nodeCheck = part; - checkFn = dirNodeCheck; - } - - checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML ); - } - }, - - find: { - ID: function( match, context, isXML ) { - if ( typeof context.getElementById !== "undefined" && !isXML ) { - var m = context.getElementById(match[1]); - // Check parentNode to catch when Blackberry 4.6 returns - // nodes that are no longer in the document #6963 - return m && m.parentNode ? [m] : []; - } - }, - - NAME: function( match, context ) { - if ( typeof context.getElementsByName !== "undefined" ) { - var ret = [], - results = context.getElementsByName( match[1] ); - - for ( var i = 0, l = results.length; i < l; i++ ) { - if ( results[i].getAttribute("name") === match[1] ) { - ret.push( results[i] ); - } - } - - return ret.length === 0 ? null : ret; - } - }, - - TAG: function( match, context ) { - if ( typeof context.getElementsByTagName !== "undefined" ) { - return context.getElementsByTagName( match[1] ); - } - } - }, - preFilter: { - CLASS: function( match, curLoop, inplace, result, not, isXML ) { - match = " " + match[1].replace( rBackslash, "" ) + " "; - - if ( isXML ) { - return match; - } - - for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) { - if ( elem ) { - if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) { - if ( !inplace ) { - result.push( elem ); - } - - } else if ( inplace ) { - curLoop[i] = false; - } - } - } - - return false; - }, - - ID: function( match ) { - return match[1].replace( rBackslash, "" ); - }, - - TAG: function( match, curLoop ) { - return match[1].replace( rBackslash, "" ).toLowerCase(); - }, - - CHILD: function( match ) { - if ( match[1] === "nth" ) { - if ( !match[2] ) { - Sizzle.error( match[0] ); - } - - match[2] = match[2].replace(/^\+|\s*/g, ''); - - // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6' - var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec( - match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" || - !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]); - - // calculate the numbers (first)n+(last) including if they are negative - match[2] = (test[1] + (test[2] || 1)) - 0; - match[3] = test[3] - 0; - } - else if ( match[2] ) { - Sizzle.error( match[0] ); - } - - // TODO: Move to normal caching system - match[0] = done++; - - return match; - }, - - ATTR: function( match, curLoop, inplace, result, not, isXML ) { - var name = match[1] = match[1].replace( rBackslash, "" ); - - if ( !isXML && Expr.attrMap[name] ) { - match[1] = Expr.attrMap[name]; - } - - // Handle if an un-quoted value was used - match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" ); - - if ( match[2] === "~=" ) { - match[4] = " " + match[4] + " "; - } - - return match; - }, - - PSEUDO: function( match, curLoop, inplace, result, not ) { - if ( match[1] === "not" ) { - // If we're dealing with a complex expression, or a simple one - if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) { - match[3] = Sizzle(match[3], null, null, curLoop); - - } else { - var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not); - - if ( !inplace ) { - result.push.apply( result, ret ); - } - - return false; - } - - } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) { - return true; - } - - return match; - }, - - POS: function( match ) { - match.unshift( true ); - - return match; - } - }, - - filters: { - enabled: function( elem ) { - return elem.disabled === false && elem.type !== "hidden"; - }, - - disabled: function( elem ) { - return elem.disabled === true; - }, - - checked: function( elem ) { - return elem.checked === true; - }, - - selected: function( elem ) { - // Accessing this property makes selected-by-default - // options in Safari work properly - if ( elem.parentNode ) { - elem.parentNode.selectedIndex; - } - - return elem.selected === true; - }, - - parent: function( elem ) { - return !!elem.firstChild; - }, - - empty: function( elem ) { - return !elem.firstChild; - }, - - has: function( elem, i, match ) { - return !!Sizzle( match[3], elem ).length; - }, - - header: function( elem ) { - return (/h\d/i).test( elem.nodeName ); - }, - - text: function( elem ) { - var attr = elem.getAttribute( "type" ), type = elem.type; - // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) - // use getAttribute instead to test this case - return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null ); - }, - - radio: function( elem ) { - return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type; - }, - - checkbox: function( elem ) { - return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type; - }, - - file: function( elem ) { - return elem.nodeName.toLowerCase() === "input" && "file" === elem.type; - }, - - password: function( elem ) { - return elem.nodeName.toLowerCase() === "input" && "password" === elem.type; - }, - - submit: function( elem ) { - var name = elem.nodeName.toLowerCase(); - return (name === "input" || name === "button") && "submit" === elem.type; - }, - - image: function( elem ) { - return elem.nodeName.toLowerCase() === "input" && "image" === elem.type; - }, - - reset: function( elem ) { - var name = elem.nodeName.toLowerCase(); - return (name === "input" || name === "button") && "reset" === elem.type; - }, - - button: function( elem ) { - var name = elem.nodeName.toLowerCase(); - return name === "input" && "button" === elem.type || name === "button"; - }, - - input: function( elem ) { - return (/input|select|textarea|button/i).test( elem.nodeName ); - }, - - focus: function( elem ) { - return elem === elem.ownerDocument.activeElement; - } - }, - setFilters: { - first: function( elem, i ) { - return i === 0; - }, - - last: function( elem, i, match, array ) { - return i === array.length - 1; - }, - - even: function( elem, i ) { - return i % 2 === 0; - }, - - odd: function( elem, i ) { - return i % 2 === 1; - }, - - lt: function( elem, i, match ) { - return i < match[3] - 0; - }, - - gt: function( elem, i, match ) { - return i > match[3] - 0; - }, - - nth: function( elem, i, match ) { - return match[3] - 0 === i; - }, - - eq: function( elem, i, match ) { - return match[3] - 0 === i; - } - }, - filter: { - PSEUDO: function( elem, match, i, array ) { - var name = match[1], - filter = Expr.filters[ name ]; - - if ( filter ) { - return filter( elem, i, match, array ); - - } else if ( name === "contains" ) { - return (elem.textContent || elem.innerText || Sizzle.getText([ elem ]) || "").indexOf(match[3]) >= 0; - - } else if ( name === "not" ) { - var not = match[3]; - - for ( var j = 0, l = not.length; j < l; j++ ) { - if ( not[j] === elem ) { - return false; - } - } - - return true; - - } else { - Sizzle.error( name ); - } - }, - - CHILD: function( elem, match ) { - var type = match[1], - node = elem; - - switch ( type ) { - case "only": - case "first": - while ( (node = node.previousSibling) ) { - if ( node.nodeType === 1 ) { - return false; - } - } - - if ( type === "first" ) { - return true; - } - - node = elem; - - case "last": - while ( (node = node.nextSibling) ) { - if ( node.nodeType === 1 ) { - return false; - } - } - - return true; - - case "nth": - var first = match[2], - last = match[3]; - - if ( first === 1 && last === 0 ) { - return true; - } - - var doneName = match[0], - parent = elem.parentNode; - - if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) { - var count = 0; - - for ( node = parent.firstChild; node; node = node.nextSibling ) { - if ( node.nodeType === 1 ) { - node.nodeIndex = ++count; - } - } - - parent.sizcache = doneName; - } - - var diff = elem.nodeIndex - last; - - if ( first === 0 ) { - return diff === 0; - - } else { - return ( diff % first === 0 && diff / first >= 0 ); - } - } - }, - - ID: function( elem, match ) { - return elem.nodeType === 1 && elem.getAttribute("id") === match; - }, - - TAG: function( elem, match ) { - return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match; - }, - - CLASS: function( elem, match ) { - return (" " + (elem.className || elem.getAttribute("class")) + " ") - .indexOf( match ) > -1; - }, - - ATTR: function( elem, match ) { - var name = match[1], - result = Expr.attrHandle[ name ] ? - Expr.attrHandle[ name ]( elem ) : - elem[ name ] != null ? - elem[ name ] : - elem.getAttribute( name ), - value = result + "", - type = match[2], - check = match[4]; - - return result == null ? - type === "!=" : - type === "=" ? - value === check : - type === "*=" ? - value.indexOf(check) >= 0 : - type === "~=" ? - (" " + value + " ").indexOf(check) >= 0 : - !check ? - value && result !== false : - type === "!=" ? - value !== check : - type === "^=" ? - value.indexOf(check) === 0 : - type === "$=" ? - value.substr(value.length - check.length) === check : - type === "|=" ? - value === check || value.substr(0, check.length + 1) === check + "-" : - false; - }, - - POS: function( elem, match, i, array ) { - var name = match[2], - filter = Expr.setFilters[ name ]; - - if ( filter ) { - return filter( elem, i, match, array ); - } - } - } -}; - -var origPOS = Expr.match.POS, - fescape = function(all, num){ - return "\\" + (num - 0 + 1); - }; - -for ( var type in Expr.match ) { - Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) ); - Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) ); -} - -var makeArray = function( array, results ) { - array = Array.prototype.slice.call( array, 0 ); - - if ( results ) { - results.push.apply( results, array ); - return results; - } - - return array; -}; - -// Perform a simple check to determine if the browser is capable of -// converting a NodeList to an array using builtin methods. -// Also verifies that the returned array holds DOM nodes -// (which is not the case in the Blackberry browser) -try { - Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType; - -// Provide a fallback method if it does not work -} catch( e ) { - makeArray = function( array, results ) { - var i = 0, - ret = results || []; - - if ( toString.call(array) === "[object Array]" ) { - Array.prototype.push.apply( ret, array ); - - } else { - if ( typeof array.length === "number" ) { - for ( var l = array.length; i < l; i++ ) { - ret.push( array[i] ); - } - - } else { - for ( ; array[i]; i++ ) { - ret.push( array[i] ); - } - } - } - - return ret; - }; -} - -var sortOrder, siblingCheck; - -if ( document.documentElement.compareDocumentPosition ) { - sortOrder = function( a, b ) { - if ( a === b ) { - hasDuplicate = true; - return 0; - } - - if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) { - return a.compareDocumentPosition ? -1 : 1; - } - - return a.compareDocumentPosition(b) & 4 ? -1 : 1; - }; - -} else { - sortOrder = function( a, b ) { - // The nodes are identical, we can exit early - if ( a === b ) { - hasDuplicate = true; - return 0; - - // Fallback to using sourceIndex (in IE) if it's available on both nodes - } else if ( a.sourceIndex && b.sourceIndex ) { - return a.sourceIndex - b.sourceIndex; - } - - var al, bl, - ap = [], - bp = [], - aup = a.parentNode, - bup = b.parentNode, - cur = aup; - - // If the nodes are siblings (or identical) we can do a quick check - if ( aup === bup ) { - return siblingCheck( a, b ); - - // If no parents were found then the nodes are disconnected - } else if ( !aup ) { - return -1; - - } else if ( !bup ) { - return 1; - } - - // Otherwise they're somewhere else in the tree so we need - // to build up a full list of the parentNodes for comparison - while ( cur ) { - ap.unshift( cur ); - cur = cur.parentNode; - } - - cur = bup; - - while ( cur ) { - bp.unshift( cur ); - cur = cur.parentNode; - } - - al = ap.length; - bl = bp.length; - - // Start walking down the tree looking for a discrepancy - for ( var i = 0; i < al && i < bl; i++ ) { - if ( ap[i] !== bp[i] ) { - return siblingCheck( ap[i], bp[i] ); - } - } - - // We ended someplace up the tree so do a sibling check - return i === al ? - siblingCheck( a, bp[i], -1 ) : - siblingCheck( ap[i], b, 1 ); - }; - - siblingCheck = function( a, b, ret ) { - if ( a === b ) { - return ret; - } - - var cur = a.nextSibling; - - while ( cur ) { - if ( cur === b ) { - return -1; - } - - cur = cur.nextSibling; - } - - return 1; - }; -} - -// Utility function for retreiving the text value of an array of DOM nodes -Sizzle.getText = function( elems ) { - var ret = "", elem; - - for ( var i = 0; elems[i]; i++ ) { - elem = elems[i]; - - // Get the text from text nodes and CDATA nodes - if ( elem.nodeType === 3 || elem.nodeType === 4 ) { - ret += elem.nodeValue; - - // Traverse everything else, except comment nodes - } else if ( elem.nodeType !== 8 ) { - ret += Sizzle.getText( elem.childNodes ); - } - } - - return ret; -}; - -// Check to see if the browser returns elements by name when -// querying by getElementById (and provide a workaround) -(function(){ - // We're going to inject a fake input element with a specified name - var form = document.createElement("div"), - id = "script" + (new Date()).getTime(), - root = document.documentElement; - - form.innerHTML = ""; - - // Inject it into the root element, check its status, and remove it quickly - root.insertBefore( form, root.firstChild ); - - // The workaround has to do additional checks after a getElementById - // Which slows things down for other browsers (hence the branching) - if ( document.getElementById( id ) ) { - Expr.find.ID = function( match, context, isXML ) { - if ( typeof context.getElementById !== "undefined" && !isXML ) { - var m = context.getElementById(match[1]); - - return m ? - m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? - [m] : - undefined : - []; - } - }; - - Expr.filter.ID = function( elem, match ) { - var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); - - return elem.nodeType === 1 && node && node.nodeValue === match; - }; - } - - root.removeChild( form ); - - // release memory in IE - root = form = null; -})(); - -(function(){ - // Check to see if the browser returns only elements - // when doing getElementsByTagName("*") - - // Create a fake element - var div = document.createElement("div"); - div.appendChild( document.createComment("") ); - - // Make sure no comments are found - if ( div.getElementsByTagName("*").length > 0 ) { - Expr.find.TAG = function( match, context ) { - var results = context.getElementsByTagName( match[1] ); - - // Filter out possible comments - if ( match[1] === "*" ) { - var tmp = []; - - for ( var i = 0; results[i]; i++ ) { - if ( results[i].nodeType === 1 ) { - tmp.push( results[i] ); - } - } - - results = tmp; - } - - return results; - }; - } - - // Check to see if an attribute returns normalized href attributes - div.innerHTML = ""; - - if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" && - div.firstChild.getAttribute("href") !== "#" ) { - - Expr.attrHandle.href = function( elem ) { - return elem.getAttribute( "href", 2 ); - }; - } - - // release memory in IE - div = null; -})(); - -if ( document.querySelectorAll ) { - (function(){ - var oldSizzle = Sizzle, - div = document.createElement("div"), - id = "__sizzle__"; - - div.innerHTML = "

"; - - // Safari can't handle uppercase or unicode characters when - // in quirks mode. - if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { - return; - } - - Sizzle = function( query, context, extra, seed ) { - context = context || document; - - // Only use querySelectorAll on non-XML documents - // (ID selectors don't work in non-HTML documents) - if ( !seed && !Sizzle.isXML(context) ) { - // See if we find a selector to speed up - var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query ); - - if ( match && (context.nodeType === 1 || context.nodeType === 9) ) { - // Speed-up: Sizzle("TAG") - if ( match[1] ) { - return makeArray( context.getElementsByTagName( query ), extra ); - - // Speed-up: Sizzle(".CLASS") - } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) { - return makeArray( context.getElementsByClassName( match[2] ), extra ); - } - } - - if ( context.nodeType === 9 ) { - // Speed-up: Sizzle("body") - // The body element only exists once, optimize finding it - if ( query === "body" && context.body ) { - return makeArray( [ context.body ], extra ); - - // Speed-up: Sizzle("#ID") - } else if ( match && match[3] ) { - var elem = context.getElementById( match[3] ); - - // Check parentNode to catch when Blackberry 4.6 returns - // nodes that are no longer in the document #6963 - if ( elem && elem.parentNode ) { - // Handle the case where IE and Opera return items - // by name instead of ID - if ( elem.id === match[3] ) { - return makeArray( [ elem ], extra ); - } - - } else { - return makeArray( [], extra ); - } - } - - try { - return makeArray( context.querySelectorAll(query), extra ); - } catch(qsaError) {} - - // qSA works strangely on Element-rooted queries - // We can work around this by specifying an extra ID on the root - // and working up from there (Thanks to Andrew Dupont for the technique) - // IE 8 doesn't work on object elements - } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { - var oldContext = context, - old = context.getAttribute( "id" ), - nid = old || id, - hasParent = context.parentNode, - relativeHierarchySelector = /^\s*[+~]/.test( query ); - - if ( !old ) { - context.setAttribute( "id", nid ); - } else { - nid = nid.replace( /'/g, "\\$&" ); - } - if ( relativeHierarchySelector && hasParent ) { - context = context.parentNode; - } - - try { - if ( !relativeHierarchySelector || hasParent ) { - return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra ); - } - - } catch(pseudoError) { - } finally { - if ( !old ) { - oldContext.removeAttribute( "id" ); - } - } - } - } - - return oldSizzle(query, context, extra, seed); - }; - - for ( var prop in oldSizzle ) { - Sizzle[ prop ] = oldSizzle[ prop ]; - } - - // release memory in IE - div = null; - })(); -} - -(function(){ - var html = document.documentElement, - matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector; - - if ( matches ) { - // Check to see if it's possible to do matchesSelector - // on a disconnected node (IE 9 fails this) - var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ), - pseudoWorks = false; - - try { - // This should fail with an exception - // Gecko does not error, returns false instead - matches.call( document.documentElement, "[test!='']:sizzle" ); - - } catch( pseudoError ) { - pseudoWorks = true; - } - - Sizzle.matchesSelector = function( node, expr ) { - // Make sure that attribute selectors are quoted - expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']"); - - if ( !Sizzle.isXML( node ) ) { - try { - if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) { - var ret = matches.call( node, expr ); - - // IE 9's matchesSelector returns false on disconnected nodes - if ( ret || !disconnectedMatch || - // As well, disconnected nodes are said to be in a document - // fragment in IE 9, so check for that - node.document && node.document.nodeType !== 11 ) { - return ret; - } - } - } catch(e) {} - } - - return Sizzle(expr, null, null, [node]).length > 0; - }; - } -})(); - -(function(){ - var div = document.createElement("div"); - - div.innerHTML = "
"; - - // Opera can't find a second classname (in 9.6) - // Also, make sure that getElementsByClassName actually exists - if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) { - return; - } - - // Safari caches class attributes, doesn't catch changes (in 3.2) - div.lastChild.className = "e"; - - if ( div.getElementsByClassName("e").length === 1 ) { - return; - } - - Expr.order.splice(1, 0, "CLASS"); - Expr.find.CLASS = function( match, context, isXML ) { - if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { - return context.getElementsByClassName(match[1]); - } - }; - - // release memory in IE - div = null; -})(); - -function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { - for ( var i = 0, l = checkSet.length; i < l; i++ ) { - var elem = checkSet[i]; - - if ( elem ) { - var match = false; - - elem = elem[dir]; - - while ( elem ) { - if ( elem.sizcache === doneName ) { - match = checkSet[elem.sizset]; - break; - } - - if ( elem.nodeType === 1 && !isXML ){ - elem.sizcache = doneName; - elem.sizset = i; - } - - if ( elem.nodeName.toLowerCase() === cur ) { - match = elem; - break; - } - - elem = elem[dir]; - } - - checkSet[i] = match; - } - } -} - -function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { - for ( var i = 0, l = checkSet.length; i < l; i++ ) { - var elem = checkSet[i]; - - if ( elem ) { - var match = false; - - elem = elem[dir]; - - while ( elem ) { - if ( elem.sizcache === doneName ) { - match = checkSet[elem.sizset]; - break; - } - - if ( elem.nodeType === 1 ) { - if ( !isXML ) { - elem.sizcache = doneName; - elem.sizset = i; - } - - if ( typeof cur !== "string" ) { - if ( elem === cur ) { - match = true; - break; - } - - } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) { - match = elem; - break; - } - } - - elem = elem[dir]; - } - - checkSet[i] = match; - } - } -} - -if ( document.documentElement.contains ) { - Sizzle.contains = function( a, b ) { - return a !== b && (a.contains ? a.contains(b) : true); - }; - -} else if ( document.documentElement.compareDocumentPosition ) { - Sizzle.contains = function( a, b ) { - return !!(a.compareDocumentPosition(b) & 16); - }; - -} else { - Sizzle.contains = function() { - return false; - }; -} - -Sizzle.isXML = function( elem ) { - // documentElement is verified for cases where it doesn't yet exist - // (such as loading iframes in IE - #4833) - var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement; - - return documentElement ? documentElement.nodeName !== "HTML" : false; -}; - -var posProcess = function( selector, context ) { - var match, - tmpSet = [], - later = "", - root = context.nodeType ? [context] : context; - - // Position selectors must be done after the filter - // And so must :not(positional) so we move all PSEUDOs to the end - while ( (match = Expr.match.PSEUDO.exec( selector )) ) { - later += match[0]; - selector = selector.replace( Expr.match.PSEUDO, "" ); - } - - selector = Expr.relative[selector] ? selector + "*" : selector; - - for ( var i = 0, l = root.length; i < l; i++ ) { - Sizzle( selector, root[i], tmpSet ); - } - - return Sizzle.filter( later, tmpSet ); -}; - -// EXPOSE - -window.Sizzle = Sizzle; - -})(); diff --git a/includes/application/test/UpdatePlanet.php b/includes/application/test/UpdatePlanet.php deleted file mode 100644 index 9cdec3f..0000000 --- a/includes/application/test/UpdatePlanet.php +++ /dev/null @@ -1,163 +0,0 @@ - 0, - - 'b_laboratory' => 0, - 'b_laboratory_id' => serialize(array()), - - "spy_tech" => 12, - "computer_tech" => 8, - "military_tech" => 10, - "defence_tech" => 10, - "shield_tech" => 10, - "energy_tech" => 8, - "hyperspace_tech" => 8, - "combustion_tech" => 6, - "impulse_motor_tech" => 6, - "hyperspace_motor_tech" => 6, - "laser_tech" => 6, - "ionic_tech" => 6, - "buster_tech" => 6, - "intergalactic_tech" => 0, - "expedition_tech" => 0, - "graviton_tech" => 0, - )); - -$data = array( - 'last_update' => 0, - 'planet_type' => 1, - - 'b_building_id' => '', - 'b_hangar_id' => serialize(array(/*array( - 'ship_id' => Legacies_Empire::ID_SHIP_LIGHT_TRANSPORT, - 'qty' => 10, - 'created_at' => 0, - 'updated_at' => 0 - ), array( - 'ship_id' => Legacies_Empire::ID_SHIP_LARGE_TRANSPORT, - 'qty' => 20, - 'created_at' => 600, - 'updated_at' => 600 - ), array( - 'ship_id' => Legacies_Empire::ID_SHIP_LARGE_TRANSPORT, - 'qty' => 30, - 'created_at' => 650, - 'updated_at' => 650 - ), array( - 'ship_id' => Legacies_Empire::ID_SHIP_LARGE_TRANSPORT, - 'qty' => 40, - 'created_at' => 700, - 'updated_at' => 700 - )*/)), - - 'metal' => 500000, - 'metal_perhour' => 20, - 'cristal' => 500000, - 'cristal_perhour' => 10, - 'deuterium' => 300000, - 'deuterium_perhour' => 0, - 'energy_max' => 0, - 'energy_used' => 0, - - 'metal_mine_porcent' => 10, - 'cristal_mine_porcent' => 10, - 'solar_plant_porcent' => 10, - 'fusion_plant_porcent' => 10, - 'solar_satelit_porcent' => 10, - 'deuterium_sintetizer_porcent' => 10, - - 'metal_mine' => 20, - 'cristal_mine' => 19, - 'deuterium_sintetizer' => 0, - 'solar_plant' => 20, - 'fusion_plant' => 0, - 'robot_factory' => 0, - 'nano_factory' => 0, - 'hangar' => 12, - 'metal_store' => 10, - 'cristal_store' => 10, - 'deuterium_store' => 10, - - 'rpg_stockeur' => 0 - ); -$planet = new Legacies_Empire_Model_Planet($data); - -$planet->setUser($user); -//var_dump(array('$planet->setUser($user)', array_diff($planet->getAllDatas(), $data))); -$data = $planet->getAllDatas(); - -$planet->updateStorages(0); -//var_dump(array('$planet->updateStorages(0)', array_diff($planet->getAllDatas(), $data))); -$data = $planet->getAllDatas(); - -$planet->updateResourceProduction(0); -//var_dump(array('$planet->updateResourceProduction(0)', array_diff($planet->getAllDatas(), $data))); -$data = $planet->getAllDatas(); - -$planet->getShipyard()->appendQueue(Legacies_Empire::ID_SHIP_LIGHT_FIGHTER, 10, 0); -//var_dump(array('$planet->getShipyard()->appendQueue(Legacies_Empire::ID_SHIP_LIGHT_FIGHTER, 10, 0)', array_diff($planet->getAllDatas(), $data))); -$data = $planet->getAllDatas(); - -$planet->appendBuildingQueue(Legacies_Empire::ID_BUILDING_CRISTAL_MINE, false, 0); -//var_dump(array('$planet->appendBuildingQueue(Legacies_Empire::ID_BUILDING_CRISTAL_MINE, false, 0)', array_diff($planet->getAllDatas(), $data))); -$data = $planet->getAllDatas(); - -$userData = $user->getAllDatas(); -$planet->getResearchLab()->appendQueue(Legacies_Empire::ID_RESEARCH_ENERGY_TECHNOLOGY, false, 0); -var_dump(array('$planet->getResearchLab()->appendQueue(Legacies_Empire::ID_RESEARCH_ENERGY_TECHNOLOGY, false, 0)', array_diff($planet->getAllDatas(), $data), array_diff($user->getAllDatas(), $userData))); -$data = $planet->getAllDatas(); - -var_dump(array_diff($planet->getAllDatas(), $data)); -$data = $planet->getAllDatas(); - -Legacies::dispatchEvent('planet.update', array( - 'planet' => $planet, - 'time' => 5400 - )); - -var_dump(array_diff($planet->getAllDatas(), $data)); -$data = $planet->getAllDatas(); - -Legacies::dispatchEvent('planet.update', array( - 'planet' => $planet, - 'time' => (3600 * 20) - )); - -$planet->appendBuildingQueue(Legacies_Empire::ID_BUILDING_CRISTAL_MINE, false, 3600); - -var_dump(array_diff($planet->getAllDatas(), $data)); -$data = $planet->getAllDatas(); - -Legacies::dispatchEvent('planet.update', array( - 'planet' => $planet, - 'time' => (3600 * 30) - )); - -var_dump(array_diff($planet->getAllDatas(), $data)); -$data = $planet->getAllDatas(); - -Legacies::dispatchEvent('planet.update', array( - 'planet' => $planet, - 'time' => (3600 * 5000) - )); - -var_dump(array_diff($planet->getAllDatas(), $data)); -$data = $planet->getAllDatas(); - -$planet->appendBuildingQueue(Legacies_Empire::ID_BUILDING_CRISTAL_MINE, false, 0); -$planet->appendBuildingQueue(Legacies_Empire::ID_BUILDING_SOLAR_PLANT, false, 0); - -Legacies::dispatchEvent('planet.update', array( - 'planet' => $planet, - 'time' => (3600 * 10000) - )); - -var_dump(array_diff($planet->getAllDatas(), $data)); -$data = $planet->getAllDatas(); \ No newline at end of file diff --git a/includes/application/test/bootstrap.php b/includes/application/test/bootstrap.php deleted file mode 100644 index 4171bf9..0000000 --- a/includes/application/test/bootstrap.php +++ /dev/null @@ -1,46 +0,0 @@ - $listenerList) { - foreach ($listenerList as $listener) { - Legacies::registerListener($event, $listener); - } -} - -include ROOT_PATH . 'includes/constants.php'; \ No newline at end of file diff --git a/includes/bb.class.php b/includes/bb.class.php deleted file mode 100644 index 53aab63..0000000 --- a/includes/bb.class.php +++ /dev/null @@ -1,247 +0,0 @@ -$1", - //soulignement - "$1", - //mise en italique - "$1", - //mise en couleur - "$2", - //liste � puce 1 - "
    $1
", - //liste � puce 2 - "
  • $1
  • ", - // Lien nomm� - "$2", - //afficher les images - "", - // Lien - "$1", - // Email nomm� - "$2", - // Email - "$1", - //Size H1 - "

    $1

    ", - //Size H2 - "

    $1

    ", - //Size H3 - "

    $1

    ", - //Size H4 - "

    $1

    ", - //Size H5 - "
    $1
    ", - //Size Tres Petit - "

    $1

    ", - //Size Petit - "

    $1

    ", - //Size Normal - "

    $1

    ", - //Size Moyen - "
    $1
    ", - //Size Grand - "$1", - // Size 18 - "
    $1
    ", - // Quote - "
    Citation :
    $1


    ", - // Quote nomm� - "
    $1 :
    $2


    ", - // Code - "
    Code :
    $1


    ", - - ); - - $texte = preg_replace($bbcode,$html,$texte); - - return $texte ; - - } - ############################################################################################################## - function div_page($nb_s,$d,$id,$cat,$nb_ep) - { - if($nb_s > $nb_ep) - { - $nb_p = ceil($nb_s / $nb_ep); - $p_suiv = $d+1; - $p_prec = $d-1; - - if($d > 1) - { - echo '<< '; - echo '< '; - } - - echo ' Page n� '.$d.' / '.$nb_p.''; - - if($d < $nb_p) - { - echo ' >'; - echo ' >>'; - } - echo '

    '; - } - } - - function div_page_l($nb_s,$d,$id,$p,$s) - { - - if(strlen($s) > 1) - { - $s_lien = "&s=".$s; - } - else - { - $s_lien = ""; - } - - if($nb_s > 10) - { - echo'
    '; - $nb_p = ceil($nb_s / 10); - $p_suiv = $p+1; - $p_prec = $p-1; - - if($p > 1) - { - echo '<< '; - echo '< '; - } - - echo ' Page n� '.$p.' / '.$nb_p.''; - - if($p < $nb_p) - { - echo ' >'; - echo ' >>'; - } - echo '
    '; - - - } - - } - - ############################################################################################################## - function smileys($chaine) - { - global $userrow; - - $chaine = str_replace(":D", "", $chaine); - $chaine = str_replace(";)", "", $chaine); - $chaine = str_replace(":(", "", $chaine); - $chaine = str_replace(":surpris:", "", $chaine); - $chaine = str_replace(":o", "", $chaine); - $chaine = str_replace(":confus:", "", $chaine); - $chaine = str_replace(":lol:", "", $chaine); - $chaine = str_replace(":fire:", " ", $chaine); - $chaine = str_replace(":splif:", "", $chaine); - $chaine = str_replace(":bigsmile:", "", $chaine); - $chaine = str_replace(":x", "", $chaine); - $chaine = str_replace(":roll:", "", $chaine); - $chaine = str_replace(":bigcry:", "", $chaine); - $chaine = str_replace(":colere:", "", $chaine); - $chaine = str_replace(":P", "", $chaine); - $chaine = str_replace("8)", "", $chaine); - $chaine = str_replace(":)", "", $chaine); - $chaine = str_replace("^^oops:", "", $chaine); - - return($chaine); - - } - - - -} - -?> \ No newline at end of file diff --git a/includes/data/events.php b/includes/data/events.php deleted file mode 100644 index 8fe24c8..0000000 --- a/includes/data/events.php +++ /dev/null @@ -1,33 +0,0 @@ - array(), - 'login.success' => array(), - 'logout.success' => array(), - 'register.before' => array(), - 'register.failure' => array(), - 'register.success' => array( - array('Legacies_Empire_Model_Planet', 'registrationListener') - ), - 'planet.update' => array( - array('Legacies_Empire_Model_Planet', 'planetUpdateListener'), - array('Legacies_Empire_Model_Planet_Building_Shipyard', 'planetUpdateListener') - ), - 'user.init' => array( - array('Legacies_Empire_Model_Planet', 'registrationListener') - ), - 'planet.init' => array( - array('Legacies_Empire_Model_Galaxy_Position', 'initPlanetListerner') - ), - 'planet.shipyard.check-availability' => array(), - 'planet.shipyard.update-queue.before' => array(), - 'planet.shipyard.update-queue.after' => array(), - 'planet.shipyard.append-queue.before' => array(), - 'planet.shipyard.append-queue.after' => array(), - 'planet.building.building-time' => array( - array('Legacies_Empire_Model_Planet_Building_NaniteFactory', 'buildingTimeListener'), - array('Legacies_Empire_Model_Planet_Building_RoboticFactory', 'buildingTimeListener') - ), - 'planet.shipyard.building-time' => array( - array('Legacies_Empire_Model_Planet_Building_NaniteFactory', 'buildingTimeListener'), - array('Legacies_Empire_Model_Planet_Building_RoboticFactory', 'buildingTimeListener') - ) - ); diff --git a/includes/data/production.php b/includes/data/production.php deleted file mode 100644 index 291f492..0000000 --- a/includes/data/production.php +++ /dev/null @@ -1,113 +0,0 @@ - array( - Legacies_Empire::RESOURCE_METAL => 40, - Legacies_Empire::RESOURCE_CRISTAL => 10, - Legacies_Empire::RESOURCE_DEUTERIUM => 0, - Legacies_Empire::RESOURCE_ENERGY => 0, - Legacies_Empire::RESOURCE_MULTIPLIER => 1.5, - Legacies_Empire::RESOURCE_FORMULA => array( - Legacies_Empire::RESOURCE_METAL => 'return (30 * $BuildLevel * pow((1.1), $BuildLevel)) * (0.1 * $BuildLevelFactor);', - Legacies_Empire::RESOURCE_CRISTAL => 'return "0";', - Legacies_Empire::RESOURCE_DEUTERIUM => 'return "0";', - Legacies_Empire::RESOURCE_ENERGY => 'return -(10 * $BuildLevel * pow((1.1), $BuildLevel)) * (0.1 * $BuildLevelFactor);' - ), - Legacies_Empire::RESOURCE_CLASS => 'Legacies_Empire_Model_Planet_Building_MetalMine' - ), - - Legacies_Empire::ID_BUILDING_CRISTAL_MINE => array( - Legacies_Empire::RESOURCE_METAL => 30, - Legacies_Empire::RESOURCE_CRISTAL => 15, - Legacies_Empire::RESOURCE_DEUTERIUM => 0, - Legacies_Empire::RESOURCE_ENERGY => 0, - Legacies_Empire::RESOURCE_MULTIPLIER => 1.6, - Legacies_Empire::RESOURCE_FORMULA => array( - Legacies_Empire::RESOURCE_METAL => 'return "0";', - Legacies_Empire::RESOURCE_CRISTAL => 'return (20 * $BuildLevel * pow((1.1), $BuildLevel)) * (0.1 * $BuildLevelFactor);', - Legacies_Empire::RESOURCE_DEUTERIUM => 'return "0";', - Legacies_Empire::RESOURCE_ENERGY => 'return -(10 * $BuildLevel * pow((1.1), $BuildLevel)) * (0.1 * $BuildLevelFactor);' - ), - Legacies_Empire::RESOURCE_CLASS => 'Legacies_Empire_Model_Planet_Building_CristalMine' - ), - - Legacies_Empire::ID_BUILDING_DEUTERIUM_SYNTHETISER => array( - Legacies_Empire::RESOURCE_METAL => 150, - Legacies_Empire::RESOURCE_CRISTAL => 50, - Legacies_Empire::RESOURCE_DEUTERIUM => 0, - Legacies_Empire::RESOURCE_ENERGY => 0, - Legacies_Empire::RESOURCE_MULTIPLIER => 1.5, - Legacies_Empire::RESOURCE_FORMULA => array( - Legacies_Empire::RESOURCE_METAL => 'return "0";', - Legacies_Empire::RESOURCE_CRISTAL => 'return "0";', - Legacies_Empire::RESOURCE_DEUTERIUM => 'return ((10 * $BuildLevel * pow((1.1), $BuildLevel)) * (-0.002 * $BuildTemp + 1.28)) * (0.1 * $BuildLevelFactor);', - Legacies_Empire::RESOURCE_ENERGY => 'return -(30 * $BuildLevel * pow((1.1), $BuildLevel)) * (0.1 * $BuildLevelFactor);' - ), - Legacies_Empire::RESOURCE_CLASS => 'Legacies_Empire_Model_Planet_Building_DeuteriumSynthetiser' - ), - - Legacies_Empire::ID_BUILDING_SOLAR_PLANT => array( - Legacies_Empire::RESOURCE_METAL => 50, - Legacies_Empire::RESOURCE_CRISTAL => 20, - Legacies_Empire::RESOURCE_DEUTERIUM => 0, - Legacies_Empire::RESOURCE_ENERGY => 0, - Legacies_Empire::RESOURCE_MULTIPLIER => 1.5, - Legacies_Empire::RESOURCE_FORMULA => array( - Legacies_Empire::RESOURCE_METAL => 'return "0";', - Legacies_Empire::RESOURCE_CRISTAL => 'return "0";', - Legacies_Empire::RESOURCE_DEUTERIUM => 'return "0";', - Legacies_Empire::RESOURCE_ENERGY => 'return (20 * $BuildLevel * pow((1.1), $BuildLevel)) * (0.1 * $BuildLevelFactor);' - ), - Legacies_Empire::RESOURCE_CLASS => 'Legacies_Empire_Model_Planet_Building_SolarPlant' - ), - - Legacies_Empire::ID_BUILDING_FUSION_REACTOR => array( - Legacies_Empire::RESOURCE_METAL => 500, - Legacies_Empire::RESOURCE_CRISTAL => 200, - Legacies_Empire::RESOURCE_DEUTERIUM => 100, - Legacies_Empire::RESOURCE_ENERGY => 0, - Legacies_Empire::RESOURCE_MULTIPLIER => 1.8, - Legacies_Empire::RESOURCE_FORMULA => array( - Legacies_Empire::RESOURCE_METAL => 'return "0";', - Legacies_Empire::RESOURCE_CRISTAL => 'return "0";', - Legacies_Empire::RESOURCE_DEUTERIUM => 'return -(10 * $BuildLevel * pow((1.1), $BuildLevel)) * (0.1 * $BuildLevelFactor);', - Legacies_Empire::RESOURCE_ENERGY => 'return (50 * $BuildLevel * pow((1.1), $BuildLevel)) * (0.1 * $BuildLevelFactor);' - ), - Legacies_Empire::RESOURCE_CLASS => 'Legacies_Empire_Model_Planet_Building_FusionReactor' - ), -// }}} - -// -// Ships production -// {{{ - Legacies_Empire::ID_SHIP_SOLAR_SATELLITE => array( - Legacies_Empire::RESOURCE_METAL => 0, - Legacies_Empire::RESOURCE_CRISTAL => 2000, - Legacies_Empire::RESOURCE_DEUTERIUM => 500, - Legacies_Empire::RESOURCE_ENERGY => 0, - Legacies_Empire::RESOURCE_MULTIPLIER => 0.5, - Legacies_Empire::RESOURCE_FORMULA => array( - Legacies_Empire::RESOURCE_METAL => 'return "0";', - Legacies_Empire::RESOURCE_CRISTAL => 'return "0";', - Legacies_Empire::RESOURCE_DEUTERIUM => 'return "0";', - Legacies_Empire::RESOURCE_ENERGY => 'return (($BuildTemp / 4) + 20) * $BuildLevel * (0.1 * $BuildLevelFactor);' - ), - Legacies_Empire::RESOURCE_CLASS => 'Legacies_Empire_Model_Planet_Ship_SolarSatellite' - ), - Legacies_Empire::ID_SHIP_SUPERNOVA => array( - Legacies_Empire::RESOURCE_METAL => 0, - Legacies_Empire::RESOURCE_CRISTAL => 2000, - Legacies_Empire::RESOURCE_DEUTERIUM => 500, - Legacies_Empire::RESOURCE_ENERGY => 0, - Legacies_Empire::RESOURCE_MULTIPLIER => 0.5, - Legacies_Empire::RESOURCE_FORMULA => array( - Legacies_Empire::RESOURCE_METAL => 'return "0";', - Legacies_Empire::RESOURCE_CRISTAL => 'return "0";', - Legacies_Empire::RESOURCE_DEUTERIUM => 'return "0";', - Legacies_Empire::RESOURCE_ENERGY => 'return -(12500 * ($BuildTemp / 4) + 20) * $BuildLevel * (0.1 * $BuildLevelFactor);' - ), - Legacies_Empire::RESOURCE_CLASS => 'Legacies_Empire_Model_Planet_Ship_Supernova' - ) -// }}} - ); diff --git a/includes/databaseinfos.php b/includes/databaseinfos.php deleted file mode 100644 index 6a64d7c..0000000 --- a/includes/databaseinfos.php +++ /dev/null @@ -1,551 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - - $QryTableAks = "CREATE TABLE `{{table}}` ( "; - $QryTableAks .= "`id` bigint(20) unsigned NOT NULL auto_increment, "; - $QryTableAks .= "`name` varchar(50) collate latin1_general_ci default NULL, "; - $QryTableAks .= "`teilnehmer` text collate latin1_general_ci, "; - $QryTableAks .= "`flotten` text collate latin1_general_ci, "; - $QryTableAks .= "`ankunft` int(32) default NULL, "; - $QryTableAks .= "`galaxy` int(2) default NULL, "; - $QryTableAks .= "`system` int(4) default NULL, "; - $QryTableAks .= "`planet` int(2) default NULL, "; - $QryTableAks .= "`eingeladen` int(11) default NULL, "; - $QryTableAks .= "PRIMARY KEY (`id`) "; - $QryTableAks .= ") ENGINE=MyISAM;"; - - // Table annonce - $QryTableAnnonce = "CREATE TABLE `{{table}}` ( "; - $QryTableAnnonce .= "`id` int(11) NOT NULL auto_increment, "; - $QryTableAnnonce .= "`user` text collate latin1_general_ci NOT NULL, "; - $QryTableAnnonce .= "`galaxie` int(11) NOT NULL, "; - $QryTableAnnonce .= "`systeme` int(11) NOT NULL, "; - $QryTableAnnonce .= "`metala` bigint(11) NOT NULL, "; - $QryTableAnnonce .= "`cristala` bigint(11) NOT NULL, "; - $QryTableAnnonce .= "`deuta` bigint(11) NOT NULL, "; - $QryTableAnnonce .= "`metals` bigint(11) NOT NULL, "; - $QryTableAnnonce .= "`cristals` bigint(11) NOT NULL, "; - $QryTableAnnonce .= "`deuts` bigint(11) NOT NULL, "; - $QryTableAnnonce .= "PRIMARY KEY (`id`) "; - $QryTableAnnonce .= ") ENGINE=MyISAM;"; - - // Table alliance - $QryTableAlliance = "CREATE TABLE `{{table}}` ( "; - $QryTableAlliance .= "`id` bigint(11) NOT NULL auto_increment, "; - $QryTableAlliance .= "`ally_name` varchar(32) character set latin1 default '', "; - $QryTableAlliance .= "`ally_tag` varchar(8) character set latin1 default '', "; - $QryTableAlliance .= "`ally_owner` int(11) NOT NULL default '0', "; - $QryTableAlliance .= "`ally_register_time` int(11) NOT NULL default '0', "; - $QryTableAlliance .= "`ally_description` text character set latin1, "; - $QryTableAlliance .= "`ally_web` varchar(255) character set latin1 default '', "; - $QryTableAlliance .= "`ally_text` text character set latin1, "; - $QryTableAlliance .= "`ally_image` varchar(255) character set latin1 default '', "; - $QryTableAlliance .= "`ally_request` text character set latin1, "; - $QryTableAlliance .= "`ally_request_waiting` text character set latin1, "; - $QryTableAlliance .= "`ally_request_notallow` tinyint(4) NOT NULL default '0', "; - $QryTableAlliance .= "`ally_owner_range` varchar(32) character set latin1 default '', "; - $QryTableAlliance .= "`ally_ranks` text character set latin1, "; - $QryTableAlliance .= "`ally_members` int(11) NOT NULL default '0', "; - $QryTableAlliance .= "PRIMARY KEY (`id`) "; - $QryTableAlliance .= ") ENGINE=MyISAM;"; - - // Table banned - $QryTableBanned = "CREATE TABLE `{{table}}` ( "; - $QryTableBanned .= "`id` bigint(11) NOT NULL auto_increment, "; - $QryTableBanned .= "`who` varchar(11) character set latin1 NOT NULL default '', "; - $QryTableBanned .= "`theme` text character set latin1 NOT NULL, "; - $QryTableBanned .= "`who2` varchar(11) character set latin1 NOT NULL default '', "; - $QryTableBanned .= "`time` int(11) NOT NULL default '0', "; - $QryTableBanned .= "`longer` int(11) NOT NULL default '0', "; - $QryTableBanned .= "`author` varchar(11) character set latin1 NOT NULL default '', "; - $QryTableBanned .= "`email` varchar(20) character set latin1 NOT NULL default '', "; - $QryTableBanned .= "KEY `ID` (`id`) "; - $QryTableBanned .= ") ENGINE=MyISAM;"; - - // Table buddy - $QryTableBuddy = "CREATE TABLE `{{table}}` ( "; - $QryTableBuddy .= "`id` bigint(11) NOT NULL auto_increment, "; - $QryTableBuddy .= "`sender` int(11) NOT NULL default '0', "; - $QryTableBuddy .= "`owner` int(11) NOT NULL default '0', "; - $QryTableBuddy .= "`active` tinyint(3) NOT NULL default '0', "; - $QryTableBuddy .= "`text` text character set latin1, "; - $QryTableBuddy .= "PRIMARY KEY (`id`) "; - $QryTableBuddy .= ") ENGINE=MyISAM;"; - - // Table chat - $QryTableChat = "CREATE TABLE `{{table}}` ( "; - $QryTableChat .= "`messageid` int(5) unsigned NOT NULL auto_increment, "; - $QryTableChat .= "`user` varchar(255) NOT NULL default '', "; - $QryTableChat .= "`message` text NOT NULL, "; - $QryTableChat .= "`timestamp` int(11) NOT NULL default '0', "; - $QryTableChat .= "PRIMARY KEY (`messageid`) "; - $QryTableChat .= ") ENGINE=MyISAM;"; - - // Table config - $QryTableConfig = "CREATE TABLE `{{table}}` ( "; - $QryTableConfig .= "`config_name` varchar(64) character set latin1 NOT NULL default '', "; - $QryTableConfig .= "`config_value` text character set latin1 NOT NULL "; - $QryTableConfig .= ") ENGINE=MyISAM;"; - - // Valeurs de base de la config - $QryInsertConfig = "INSERT INTO `{{table}}` "; - $QryInsertConfig .= "(`config_name` , `config_value`) VALUES "; - $QryInsertConfig .= "('users_amount' , '0'), "; - $QryInsertConfig .= "('game_speed' , '2500'), "; - $QryInsertConfig .= "('fleet_speed' , '2500'), "; - $QryInsertConfig .= "('resource_multiplier' , '1'), "; - $QryInsertConfig .= "('Fleet_Cdr' , '30'), "; - $QryInsertConfig .= "('Defs_Cdr' , '30'), "; - $QryInsertConfig .= "('initial_fields' , '163'), "; - $QryInsertConfig .= "('COOKIE_NAME' , 'XNova Legacies'), "; - $QryInsertConfig .= "('game_name' , 'XNova Legacies'), "; - $QryInsertConfig .= "('game_disable' , '1'), "; - $QryInsertConfig .= "('close_reason' , 'Le jeu est clos pour le moment!'), "; - $QryInsertConfig .= "('metal_basic_income' , '20'), "; - $QryInsertConfig .= "('crystal_basic_income' , '10'), "; - $QryInsertConfig .= "('deuterium_basic_income', '0'), "; - $QryInsertConfig .= "('energy_basic_income' , '0'), "; - $QryInsertConfig .= "('BuildLabWhileRun' , '0'), "; - $QryInsertConfig .= "('LastSettedGalaxyPos' , '1'), "; - $QryInsertConfig .= "('LastSettedSystemPos' , '8'), "; - $QryInsertConfig .= "('LastSettedPlanetPos' , '3'), "; - $QryInsertConfig .= "('urlaubs_modus_erz' , '1'), "; - $QryInsertConfig .= "('noobprotection' , '1'), "; - $QryInsertConfig .= "('noobprotectiontime' , '5000'), "; - $QryInsertConfig .= "('noobprotectionmulti' , '5'), "; - $QryInsertConfig .= "('forum_url' , 'http://board.xnova-ng.org/' ), "; - $QryInsertConfig .= "('OverviewNewsFrame' , '1' ), "; - $QryInsertConfig .= "('OverviewNewsText' , 'Bienvenue sur le nouveau serveur XNova Legacies' ), "; - $QryInsertConfig .= "('OverviewExternChat' , '0' ), "; - $QryInsertConfig .= "('OverviewExternChatCmd' , '' ), "; - $QryInsertConfig .= "('OverviewBanner' , '0' ), "; - $QryInsertConfig .= "('OverviewClickBanner' , '' ), "; - $QryInsertConfig .= "('ExtCopyFrame' , '0' ), "; - $QryInsertConfig .= "('ExtCopyOwner' , '' ), "; - $QryInsertConfig .= "('ExtCopyFunct' , '' ), "; - $QryInsertConfig .= "('ForumBannerFrame' , '0' ), "; - $QryInsertConfig .= "('stat_settings' , '1000' ), "; - $QryInsertConfig .= "('link_enable' , '0' ), "; - $QryInsertConfig .= "('link_name' , '' ), "; - $QryInsertConfig .= "('link_url' , '' ), "; - $QryInsertConfig .= "('enable_announces' , '1' ), "; - $QryInsertConfig .= "('enable_marchand' , '1'), "; - $QryInsertConfig .= "('enable_notes' , '1'), "; - $QryInsertConfig .= "('bot_name' , 'XNoviana Reali'), "; - $QryInsertConfig .= "('bot_adress' , 'xnova@xnova-ng.org' ), "; - $QryInsertConfig .= "('banner_source_post' , '../images/bann.png' ), "; - $QryInsertConfig .= "('ban_duration' , '30' ), "; - $QryInsertConfig .= "('enable_bot' , '0' ), "; - $QryInsertConfig .= "('enable_bbcode' , '1' ), "; - $QryInsertConfig .= "('debug' , '0') "; - $QryInsertConfig .= ";"; - - - // Table declared (multicomptes) - $QryTabledeclared = "CREATE TABLE `{{table}}` ( "; - $QryTabledeclared .= "`declarator`TEXT NOT NULL, "; - $QryTabledeclared .= "`declared_1`TEXT NOT NULL, "; - $QryTabledeclared .= "`declared_2`TEXT NOT NULL, "; - $QryTabledeclared .= "`declared_3`TEXT NOT NULL, "; - $QryTabledeclared .= "`reason`TEXT NOT NULL, "; - $QryTabledeclared .= "`declarator_name`TEXT NOT NULL "; - - $QryTabledeclared .= ") ENGINE=MyISAM;"; - - // Table errors - $QryTableErrors = "CREATE TABLE `{{table}}` ( "; - $QryTableErrors .= "`error_id` bigint(11) NOT NULL auto_increment, "; - $QryTableErrors .= "`error_sender` varchar(32) character set latin1 NOT NULL default '0', "; - $QryTableErrors .= "`error_time` int(11) NOT NULL default '0', "; - $QryTableErrors .= "`error_type` varchar(32) character set latin1 NOT NULL default 'unknown', "; - $QryTableErrors .= "`error_text` text character set latin1, "; - $QryTableErrors .= "PRIMARY KEY (`error_id`) "; - $QryTableErrors .= ") ENGINE=MyISAM;"; - - // Table fleets - $QryTableFleets = "CREATE TABLE `{{table}}` ( "; - $QryTableFleets .= "`fleet_id` bigint(11) NOT NULL auto_increment, "; - $QryTableFleets .= "`fleet_owner` int(11) NOT NULL default '0', "; - $QryTableFleets .= "`fleet_mission` int(11) NOT NULL default '0', "; - $QryTableFleets .= "`fleet_amount` bigint(11) NOT NULL default '0', "; - $QryTableFleets .= "`fleet_array` text character set latin1, "; - $QryTableFleets .= "`fleet_start_time` int(11) NOT NULL default '0', "; - $QryTableFleets .= "`fleet_start_galaxy` int(11) NOT NULL default '0', "; - $QryTableFleets .= "`fleet_start_system` int(11) NOT NULL default '0', "; - $QryTableFleets .= "`fleet_start_planet` int(11) NOT NULL default '0', "; - $QryTableFleets .= "`fleet_start_type` int(11) NOT NULL default '0', "; - $QryTableFleets .= "`fleet_end_time` int(11) NOT NULL default '0', "; - $QryTableFleets .= "`fleet_end_stay` int(11) NOT NULL default '0', "; - $QryTableFleets .= "`fleet_end_galaxy` int(11) NOT NULL default '0', "; - $QryTableFleets .= "`fleet_end_system` int(11) NOT NULL default '0', "; - $QryTableFleets .= "`fleet_end_planet` int(11) NOT NULL default '0', "; - $QryTableFleets .= "`fleet_end_type` int(11) NOT NULL default '0', "; - $QryTableFleets .= "`fleet_taget_owner` int(11) NOT NULL default '0', "; - $QryTableFleets .= "`fleet_resource_metal` bigint(11) NOT NULL default '0', "; - $QryTableFleets .= "`fleet_resource_crystal` bigint(11) NOT NULL default '0', "; - $QryTableFleets .= "`fleet_resource_deuterium` bigint(11) NOT NULL default '0', "; - $QryTableFleets .= "`fleet_target_owner` int(11) NOT NULL default '0', "; - $QryTableFleets .= "`fleet_group` int (11) NOT NULL DEFAULT '0', "; - $QryTableFleets .= "`fleet_mess` int(11) NOT NULL default '0', "; - $QryTableFleets .= "`start_time` int(11) default NULL, "; - $QryTableFleets .= "PRIMARY KEY (`fleet_id`) "; - $QryTableFleets .= ") ENGINE=MyISAM;"; - - // Table galaxy - $QryTableGalaxy = "CREATE TABLE `{{table}}` ( "; - $QryTableGalaxy .= "`galaxy` int(2) NOT NULL default '0', "; - $QryTableGalaxy .= "`system` int(3) NOT NULL default '0', "; - $QryTableGalaxy .= "`planet` int(2) NOT NULL default '0', "; - $QryTableGalaxy .= "`id_planet` int(11) NOT NULL default '0', "; - $QryTableGalaxy .= "`metal` bigint(11) NOT NULL default '0', "; - $QryTableGalaxy .= "`crystal` bigint(11) NOT NULL default '0', "; - $QryTableGalaxy .= "`id_luna` int(11) NOT NULL default '0', "; - $QryTableGalaxy .= "`luna` int(2) NOT NULL default '0', "; - $QryTableGalaxy .= "KEY `galaxy` (`galaxy`), "; - $QryTableGalaxy .= "KEY `system` (`system`), "; - $QryTableGalaxy .= "KEY `planet` (`planet`) "; - $QryTableGalaxy .= ") ENGINE=MyISAM;"; - - // Table iraks - $QryTableIraks = "CREATE TABLE `{{table}}` ( "; - $QryTableIraks .= "`id` bigint(20) unsigned NOT NULL auto_increment, "; - $QryTableIraks .= "`zeit` int(32) default NULL, "; - $QryTableIraks .= "`galaxy` int(2) default NULL, "; - $QryTableIraks .= "`system` int(4) default NULL, "; - $QryTableIraks .= "`planet` int(2) default NULL, "; - $QryTableIraks .= "`galaxy_angreifer` int(2) default NULL, "; - $QryTableIraks .= "`system_angreifer` int(4) default NULL, "; - $QryTableIraks .= "`planet_angreifer` int(2) default NULL, "; - $QryTableIraks .= "`owner` int(32) default NULL, "; - $QryTableIraks .= "`zielid` int(32) default NULL, "; - $QryTableIraks .= "`anzahl` int(32) default NULL, "; - $QryTableIraks .= "`primaer` int(32) default NULL, "; - $QryTableIraks .= "PRIMARY KEY (`id`) "; - $QryTableIraks .= ") ENGINE=MyISAM;"; - - // Table lunas - $QryTableLunas = "CREATE TABLE `{{table}}` ( "; - $QryTableLunas .= "`id` bigint(11) NOT NULL auto_increment, "; - $QryTableLunas .= "`id_luna` int(11) NOT NULL default '0', "; - $QryTableLunas .= "`name` varchar(11) character set latin1 NOT NULL default 'Lune', "; - $QryTableLunas .= "`image` varchar(11) character set latin1 NOT NULL default 'mond', "; - $QryTableLunas .= "`destruyed` int(11) NOT NULL default '0', "; - $QryTableLunas .= "`id_owner` int(11) default NULL, "; - $QryTableLunas .= "`galaxy` int(11) default NULL, "; - $QryTableLunas .= "`system` int(11) default NULL, "; - $QryTableLunas .= "`lunapos` int(11) default NULL, "; - $QryTableLunas .= "`temp_min` int(11) NOT NULL default '0', "; - $QryTableLunas .= "`temp_max` int(11) NOT NULL default '0', "; - $QryTableLunas .= "`diameter` int(11) NOT NULL default '0', "; - $QryTableLunas .= "PRIMARY KEY (`id`) "; - $QryTableLunas .= ") ENGINE=MyISAM;"; - - // Table messages - $QryTableMessages = "CREATE TABLE `{{table}}` ( "; - $QryTableMessages .= "`message_id` bigint(11) NOT NULL auto_increment, "; - $QryTableMessages .= "`message_owner` int(11) NOT NULL default '0', "; - $QryTableMessages .= "`message_sender` int(11) NOT NULL default '0', "; - $QryTableMessages .= "`message_time` int(11) NOT NULL default '0', "; - $QryTableMessages .= "`message_type` int(11) NOT NULL default '0', "; - $QryTableMessages .= "`message_from` varchar(48) character set latin1 default NULL, "; - $QryTableMessages .= "`message_subject` varchar(48) character set latin1 default NULL, "; - $QryTableMessages .= "`message_text` text character set latin1, "; - $QryTableMessages .= "PRIMARY KEY (`message_id`) "; - $QryTableMessages .= ") ENGINE=MyISAM;"; - - // Table notes - $QryTableNotes = "CREATE TABLE `{{table}}` ( "; - $QryTableNotes .= "`id` bigint(11) NOT NULL auto_increment, "; - $QryTableNotes .= "`owner` int(11) default NULL, "; - $QryTableNotes .= "`time` int(11) default NULL, "; - $QryTableNotes .= "`priority` tinyint(1) default NULL, "; - $QryTableNotes .= "`title` varchar(32) character set latin1 default NULL, "; - $QryTableNotes .= "`text` text character set latin1, "; - $QryTableNotes .= "PRIMARY KEY (`id`) "; - $QryTableNotes .= ") ENGINE=MyISAM;"; - - // Table planets - $QryTablePlanets = "CREATE TABLE `{{table}}` ( "; - $QryTablePlanets .= "`id` bigint(11) NOT NULL auto_increment, "; - $QryTablePlanets .= "`name` varchar(255) character set latin1 default NULL, "; - $QryTablePlanets .= "`id_owner` int(11) default NULL, "; - $QryTablePlanets .= "`id_level` int(11) default NULL, "; - $QryTablePlanets .= "`galaxy` int(11) NOT NULL default '0', "; - $QryTablePlanets .= "`system` int(11) NOT NULL default '0', "; - $QryTablePlanets .= "`planet` int(11) NOT NULL default '0', "; - $QryTablePlanets .= "`last_update` int(11) default NULL, "; - $QryTablePlanets .= "`planet_type` int(11) NOT NULL default '1', "; - $QryTablePlanets .= "`destruyed` int(11) NOT NULL default '0', "; - $QryTablePlanets .= "`b_building` int(11) NOT NULL default '0', "; - $QryTablePlanets .= "`b_building_id` text character set latin1 NOT NULL, "; - $QryTablePlanets .= "`b_tech` int(11) NOT NULL default '0', "; - $QryTablePlanets .= "`b_tech_id` int(11) NOT NULL default '0', "; - $QryTablePlanets .= "`b_hangar` int(11) NOT NULL default '0', "; - $QryTablePlanets .= "`b_hangar_id` text character set latin1 NOT NULL, "; - $QryTablePlanets .= "`b_hangar_plus` int(11) NOT NULL default '0', "; - $QryTablePlanets .= "`image` varchar(32) character set latin1 NOT NULL default 'normaltempplanet01', "; - $QryTablePlanets .= "`diameter` int(11) NOT NULL default '12800', "; - $QryTablePlanets .= "`points` bigint(20) default '0', "; - $QryTablePlanets .= "`ranks` bigint(20) default '0', "; - $QryTablePlanets .= "`field_current` int(11) NOT NULL default '0', "; - $QryTablePlanets .= "`field_max` int(11) NOT NULL default '163', "; - $QryTablePlanets .= "`temp_min` int(3) NOT NULL default '-17', "; - $QryTablePlanets .= "`temp_max` int(3) NOT NULL default '23', "; - $QryTablePlanets .= "`metal` double(132,8) NOT NULL default '0.00000000', "; - $QryTablePlanets .= "`metal_perhour` int(11) NOT NULL default '0', "; - $QryTablePlanets .= "`metal_max` bigint(20) default '100000', "; - $QryTablePlanets .= "`crystal` double(132,8) NOT NULL default '0.00000000', "; - $QryTablePlanets .= "`crystal_perhour` int(11) NOT NULL default '0', "; - $QryTablePlanets .= "`crystal_max` bigint(20) default '100000', "; - $QryTablePlanets .= "`deuterium` double(132,8) NOT NULL default '0.00000000', "; - $QryTablePlanets .= "`deuterium_perhour` int(11) NOT NULL default '0', "; - $QryTablePlanets .= "`deuterium_max` bigint(20) default '100000', "; - $QryTablePlanets .= "`energy_used` int(11) NOT NULL default '0', "; - $QryTablePlanets .= "`energy_max` int(11) NOT NULL default '0', "; - $QryTablePlanets .= "`metal_mine` int(11) NOT NULL default '0', "; - $QryTablePlanets .= "`crystal_mine` int(11) NOT NULL default '0', "; - $QryTablePlanets .= "`deuterium_sintetizer` int(11) NOT NULL default '0', "; - $QryTablePlanets .= "`solar_plant` int(11) NOT NULL default '0', "; - $QryTablePlanets .= "`fusion_plant` int(11) NOT NULL default '0', "; - $QryTablePlanets .= "`robot_factory` int(11) NOT NULL default '0', "; - $QryTablePlanets .= "`nano_factory` int(11) NOT NULL default '0', "; - $QryTablePlanets .= "`hangar` int(11) NOT NULL default '0', "; - $QryTablePlanets .= "`metal_store` int(11) NOT NULL default '0', "; - $QryTablePlanets .= "`crystal_store` int(11) NOT NULL default '0', "; - $QryTablePlanets .= "`deuterium_store` int(11) NOT NULL default '0', "; - $QryTablePlanets .= "`laboratory` int(11) NOT NULL default '0', "; - $QryTablePlanets .= "`terraformer` int(11) NOT NULL default '0', "; - $QryTablePlanets .= "`ally_deposit` int(11) NOT NULL default '0', "; - $QryTablePlanets .= "`silo` int(11) NOT NULL default '0', "; - $QryTablePlanets .= "`small_ship_cargo` bigint(11) NOT NULL default '0', "; - $QryTablePlanets .= "`big_ship_cargo` bigint(11) NOT NULL default '0', "; - $QryTablePlanets .= "`light_hunter` bigint(11) NOT NULL default '0', "; - $QryTablePlanets .= "`heavy_hunter` bigint(11) NOT NULL default '0', "; - $QryTablePlanets .= "`crusher` bigint(11) NOT NULL default '0', "; - $QryTablePlanets .= "`battle_ship` bigint(11) NOT NULL default '0', "; - $QryTablePlanets .= "`colonizer` bigint(11) NOT NULL default '0', "; - $QryTablePlanets .= "`recycler` bigint(11) NOT NULL default '0', "; - $QryTablePlanets .= "`spy_sonde` bigint(11) NOT NULL default '0', "; - $QryTablePlanets .= "`bomber_ship` bigint(11) NOT NULL default '0', "; - $QryTablePlanets .= "`solar_satelit` bigint(11) NOT NULL default '0', "; - $QryTablePlanets .= "`destructor` bigint(11) NOT NULL default '0', "; - $QryTablePlanets .= "`dearth_star` bigint(11) NOT NULL default '0', "; - $QryTablePlanets .= "`battleship` bigint(11) NOT NULL default '0', "; - $QryTablePlanets .= "`supernova` bigint(11) NOT NULL default '0', "; - $QryTablePlanets .= "`misil_launcher` bigint(11) NOT NULL default '0', "; - $QryTablePlanets .= "`small_laser` bigint(11) NOT NULL default '0', "; - $QryTablePlanets .= "`big_laser` bigint(11) NOT NULL default '0', "; - $QryTablePlanets .= "`gauss_canyon` bigint(11) NOT NULL default '0', "; - $QryTablePlanets .= "`ionic_canyon` bigint(11) NOT NULL default '0', "; - $QryTablePlanets .= "`buster_canyon` bigint(11) NOT NULL default '0', "; - $QryTablePlanets .= "`small_protection_shield` enum('0', '1') NOT NULL default '0', "; - $QryTablePlanets .= "`big_protection_shield` enum('0', '1') NOT NULL default '0', "; - $QryTablePlanets .= "`interceptor_misil` int(11) NOT NULL default '0', "; - $QryTablePlanets .= "`interplanetary_misil` int(11) NOT NULL default '0', "; - $QryTablePlanets .= "`metal_mine_porcent` int(11) NOT NULL default '10', "; - $QryTablePlanets .= "`crystal_mine_porcent` int(11) NOT NULL default '10', "; - $QryTablePlanets .= "`deuterium_sintetizer_porcent` int(11) NOT NULL default '10', "; - $QryTablePlanets .= "`solar_plant_porcent` int(11) NOT NULL default '10', "; - $QryTablePlanets .= "`fusion_plant_porcent` int(11) NOT NULL default '10', "; - $QryTablePlanets .= "`solar_satelit_porcent` int(11) NOT NULL default '10', "; - $QryTablePlanets .= "`mondbasis` bigint(11) NOT NULL default '0', "; - $QryTablePlanets .= "`phalanx` bigint(11) NOT NULL default '0', "; - $QryTablePlanets .= "`sprungtor` bigint(11) NOT NULL default '0', "; - $QryTablePlanets .= "`last_jump_time` int(11) NOT NULL default '0', "; - $QryTablePlanets .= "PRIMARY KEY (`id`) "; - $QryTablePlanets .= ") ENGINE=MyISAM;"; - - // Table rw - $QryTableRw = "CREATE TABLE `{{table}}` ( "; - $QryTableRw .= "`id_owner1` int(11) NOT NULL default '0', "; - $QryTableRw .= "`id_owner2` int(11) NOT NULL default '0', "; - $QryTableRw .= "`rid` varchar(72) character set latin1 NOT NULL, "; - $QryTableRw .= "`raport` text character set latin1 NOT NULL, "; - $QryTableRw .= "`a_zestrzelona` tinyint(3) unsigned NOT NULL default '0', "; - $QryTableRw .= "`time` int(10) unsigned NOT NULL default '0', "; - $QryTableRw .= "UNIQUE KEY `rid` (`rid`), "; - $QryTableRw .= "KEY `id_owner1` (`id_owner1`,`rid`), "; - $QryTableRw .= "KEY `id_owner2` (`id_owner2`,`rid`), "; - $QryTableRw .= "KEY `time` (`time`), "; - $QryTableRw .= "FULLTEXT KEY `raport` (`raport`) "; - $QryTableRw .= ") ENGINE=MyISAM;"; - - // Table statpoints - $QryTableStatPoints = "CREATE TABLE `{{table}}` ( "; - $QryTableStatPoints .= "`id_owner` int(11) NOT NULL, "; - $QryTableStatPoints .= "`id_ally` int(11) NOT NULL, "; - $QryTableStatPoints .= "`stat_type` int(2) NOT NULL, "; - $QryTableStatPoints .= "`stat_code` int(11) NOT NULL, "; - $QryTableStatPoints .= "`tech_rank` int(11) NOT NULL, "; - $QryTableStatPoints .= "`tech_old_rank` int(11) NOT NULL, "; - $QryTableStatPoints .= "`tech_points` bigint(20) NOT NULL, "; - $QryTableStatPoints .= "`tech_count` int(11) NOT NULL, "; - $QryTableStatPoints .= "`build_rank` int(11) NOT NULL, "; - $QryTableStatPoints .= "`build_old_rank` int(11) NOT NULL, "; - $QryTableStatPoints .= "`build_points` bigint(20) NOT NULL, "; - $QryTableStatPoints .= "`build_count` int(11) NOT NULL, "; - $QryTableStatPoints .= "`defs_rank` int(11) NOT NULL, "; - $QryTableStatPoints .= "`defs_old_rank` int(11) NOT NULL, "; - $QryTableStatPoints .= "`defs_points` bigint(20) NOT NULL, "; - $QryTableStatPoints .= "`defs_count` int(11) NOT NULL, "; - $QryTableStatPoints .= "`fleet_rank` int(11) NOT NULL, "; - $QryTableStatPoints .= "`fleet_old_rank` int(11) NOT NULL, "; - $QryTableStatPoints .= "`fleet_points` bigint(20) NOT NULL, "; - $QryTableStatPoints .= "`fleet_count` int(11) NOT NULL, "; - $QryTableStatPoints .= "`total_rank` int(11) NOT NULL, "; - $QryTableStatPoints .= "`total_old_rank` int(11) NOT NULL, "; - $QryTableStatPoints .= "`total_points` bigint(20) NOT NULL, "; - $QryTableStatPoints .= "`total_count` int(11) NOT NULL, "; - $QryTableStatPoints .= "`stat_date` int(11) NOT NULL, "; - $QryTableStatPoints .= "KEY `TECH` (`tech_points`), "; - $QryTableStatPoints .= "KEY `BUILDS` (`build_points`), "; - $QryTableStatPoints .= "KEY `DEFS` (`defs_points`), "; - $QryTableStatPoints .= "KEY `FLEET` (`fleet_points`), "; - $QryTableStatPoints .= "KEY `TOTAL` (`total_points`) "; - $QryTableStatPoints .= ") ENGINE=MyISAM;"; - - // Table users - $QryTableUsers = "CREATE TABLE `{{table}}` ( "; - $QryTableUsers .= "`id` bigint(11) unsigned NOT NULL auto_increment PRIMARY KEY, "; - $QryTableUsers .= "`username` varchar(64) character set latin1 NOT NULL default '', "; - $QryTableUsers .= "`password` varchar(64) character set latin1 NOT NULL default '', "; - $QryTableUsers .= "`email` varchar(64) character set latin1 NOT NULL default '', "; - $QryTableUsers .= "`email_2` varchar(64) character set latin1 NOT NULL default '', "; - $QryTableUsers .= "`lang` varchar(8) character set latin1 NOT NULL default 'fr', "; - $QryTableUsers .= "`authlevel` tinyint(4) NOT NULL default '0', "; - $QryTableUsers .= "`sex` char(1) character set latin1 default NULL, "; - $QryTableUsers .= "`avatar` varchar(255) character set latin1 NOT NULL default '', "; - $QryTableUsers .= "`sign` text character set latin1, "; - $QryTableUsers .= "`id_planet` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`galaxy` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`system` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`planet` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`current_planet` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`user_lastip` varchar(16) character set latin1 NOT NULL default '', "; - $QryTableUsers .= "`ip_at_reg` varchar(16) character set latin1 NOT NULL default '', "; - $QryTableUsers .= "`user_agent` text character set latin1 NOT NULL, "; - $QryTableUsers .= "`current_page` text character set latin1 NOT NULL, "; - $QryTableUsers .= "`register_time` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`onlinetime` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`dpath` varchar(255) character set latin1 NOT NULL default '', "; - $QryTableUsers .= "`design` tinyint(4) NOT NULL default '1', "; - $QryTableUsers .= "`noipcheck` tinyint(4) NOT NULL default '1', "; - $QryTableUsers .= "`planet_sort` tinyint(1) NOT NULL default '0', "; - $QryTableUsers .= "`planet_sort_order` tinyint(1) NOT NULL default '0', "; - $QryTableUsers .= "`spio_anz` tinyint(4) NOT NULL default '1', "; - $QryTableUsers .= "`settings_tooltiptime` tinyint(4) NOT NULL default '5', "; - $QryTableUsers .= "`settings_fleetactions` tinyint(4) NOT NULL default '0', "; - $QryTableUsers .= "`settings_allylogo` tinyint(4) NOT NULL default '0', "; - $QryTableUsers .= "`settings_esp` tinyint(4) NOT NULL default '1', "; - $QryTableUsers .= "`settings_wri` tinyint(4) NOT NULL default '1', "; - $QryTableUsers .= "`settings_bud` tinyint(4) NOT NULL default '1', "; - $QryTableUsers .= "`settings_mis` tinyint(4) NOT NULL default '1', "; - $QryTableUsers .= "`settings_rep` tinyint(4) NOT NULL default '0', "; - $QryTableUsers .= "`urlaubs_modus` tinyint(4) NOT NULL default '0', "; - $QryTableUsers .= "`urlaubs_until` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`db_deaktjava` tinyint(4) NOT NULL default '0', "; - $QryTableUsers .= "`new_message` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`fleet_shortcut` text character set latin1, "; - $QryTableUsers .= "`b_tech_planet` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`spy_tech` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`computer_tech` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`military_tech` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`defence_tech` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`shield_tech` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`energy_tech` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`hyperspace_tech` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`combustion_tech` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`impulse_motor_tech` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`hyperspace_motor_tech` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`laser_tech` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`ionic_tech` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`buster_tech` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`intergalactic_tech` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`expedition_tech` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`graviton_tech` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`ally_id` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`ally_name` varchar(32) character set latin1 default '', "; - $QryTableUsers .= "`ally_request` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`ally_request_text` text character set latin1, "; - $QryTableUsers .= "`ally_register_time` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`ally_rank_id` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`current_luna` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`kolorminus` varchar(11) character set latin1 NOT NULL default 'red', "; - $QryTableUsers .= "`kolorplus` varchar(11) character set latin1 NOT NULL default '#00FF00', "; - $QryTableUsers .= "`kolorpoziom` varchar(11) character set latin1 NOT NULL default 'yellow', "; - $QryTableUsers .= "`rpg_geologue` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`rpg_amiral` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`rpg_ingenieur` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`rpg_technocrate` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`rpg_espion` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`rpg_constructeur` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`rpg_scientifique` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`rpg_commandant` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`rpg_points` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`rpg_stockeur` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`rpg_defenseur` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`rpg_destructeur` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`rpg_general` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`rpg_bunker` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`rpg_raideur` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`rpg_empereur` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`lvl_minier` int(11) NOT NULL default '1', "; - $QryTableUsers .= "`lvl_raid` int(11) NOT NULL default '1', "; - $QryTableUsers .= "`xpraid` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`xpminier` int(11) NOT NULL default '0', "; - $QryTableUsers .= "`raids` bigint(20) NOT NULL default '0', "; - $QryTableUsers .= "`p_infligees` bigint(20) NOT NULL default '0', "; - $QryTableUsers .= "`mnl_alliance` INT( 11 ) NOT NULL , "; - $QryTableUsers .= "`mnl_joueur` INT( 11 ) NOT NULL , "; - $QryTableUsers .= "`mnl_attaque` INT( 11 ) NOT NULL , "; - $QryTableUsers .= "`mnl_spy` INT( 11 ) NOT NULL , "; - $QryTableUsers .= "`mnl_exploit` INT( 11 ) NOT NULL , "; - $QryTableUsers .= "`mnl_transport` INT( 11 ) NOT NULL , "; - $QryTableUsers .= "`mnl_expedition` INT( 11 ) NOT NULL , "; - $QryTableUsers .= "`mnl_general` INT( 11 ) NOT NULL , "; - $QryTableUsers .= "`mnl_buildlist` INT (11) NOT NULL , "; - $QryTableUsers .= "`bana` int(11) default NULL , "; - $QryTableUsers .= "`multi_validated` int(11) default NULL , "; - $QryTableUsers .= "`banaday` int(11) default NULL , "; - $QryTableUsers .= "`raids1` int(11) default NULL , "; - $QryTableUsers .= "`raidswin` int(11) default NULL , "; - $QryTableUsers .= "`raidsloose` int(11) default NULL "; - $QryTableUsers .= ") ENGINE=MyISAM;"; - - // Multi - $QryTableMulti = "CREATE TABLE `{{table}}` ( "; - $QryTableMulti .= "`id` int(11) NOT NULL auto_increment, "; - $QryTableMulti .= "`player` bigint(11) unsigned NOT NULL, "; - $QryTableMulti .= "`sharer` bigint(11) unsigned NOT NULL, "; - $QryTableMulti .= "`reason` text character set latin1 NOT NULL, "; - $QryTableMulti .= "PRIMARY KEY (`id`) "; - $QryTableMulti .= ") ENGINE=MyISAM;"; - -?> \ No newline at end of file diff --git a/includes/debug.class.php b/includes/debug.class.php deleted file mode 100644 index 669066a..0000000 --- a/includes/debug.class.php +++ /dev/null @@ -1,157 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -/** - * Debug class - * - * @todo Clean up source code - */ -class Nova_Core_Debug -{ - const CRITICAL = 0x80; - const ERROR = 0x40; - const WARNING = 0x20; - const INFO = 0x10; - const MESSAGE = 0x08; - const AUDIT_FAILED = 0x04; - const AUDIT_SUCCESS = 0x02; - const DEBUG = 0x01; - - const DEFAULT_LOGFILE = 'var/log/system.log'; - - protected $_logLevelNames = array( - self::CRITICAL => 'CRITICAL', - self::ERROR => 'ERROR', - self::WARNING => 'WARNING', - self::INFO => 'INFO', - self::MESSAGE => 'MESSAGE', - self::AUDIT_FAILED => 'AUDIT_FAILED', - self::AUDIT_SUCCESS => 'AUDIT_SUCCESS', - self::DEBUG => 'DEBUG' - ); - - /** - * Clean logging method - * - * @param string $message - * @param string $resource - * @param int $level - * @return unknown_type - */ - public function log($message, $resource = self::DEFAULT_LOGFILE, $level = self::DEBUG) - { - if(!($fp = fopen($resource, 'a'))) { - trigger_error('Unable to open logs.', E_USER_ERROR); - trigger_error($message, E_USER_ERROR); - return false; - } - fprintf($fp, '[%s] | %s - %s', $this->_logLevelNames[$level], date('r'), $message); - fclose($fp); - return true; - } -} - -/** - * @deprecated - * @todo Clean up source code - */ -class Debug - extends Nova_Core_Debug -{ - protected $_logMessages = array(); - - /** - * @deprecated - * @param string $message - * @return void - */ - function add($message) - { - $this->log($message); - $this->_logMessages[] = $message; - } - - /** - * @deprecated - * @return void - */ - function echo_log() - { - $messages = implode(PHP_EOL, $this->_logMessages); - echo << -
    - Debug Log: -
    -
    -
    {$messages}
    -
    - -EOF; - die(); - } - - /** - * @deprecated - * @todo Clean up source code - * @param $message - * @param $title - * @return unknown_type - */ - function error($message, $title) - { - global $link, $gameConfig; - - if($gameConfig['debug']==1){ - echo "

    $title


    $message

    "; - echo "".$this->log."
    "; - } - - global $user; - $config = include ROOT_PATH . 'config.' . PHPEXT; - if(!$link) die('La base de donnee n est pas disponible pour le moment, desole pour la gene occasionnee...'); - $query = "INSERT INTO {{table}} SET - `error_sender` = '{$user['id']}' , - `error_time` = '".time()."' , - `error_type` = '{$title}' , - `error_text` = '".mysql_escape_string($message)."';"; - $sqlquery = mysql_query(str_replace("{{table}}", $dbsettings["prefix"].'errors',$query)) - or die('error fatal'); - $query = "explain select * from {{table}}"; - $q = mysql_fetch_array(mysql_query(str_replace("{{table}}", $dbsettings["prefix"]. - 'errors', $query))) or die('error fatal: '); - - if (!function_exists('message')) { - echo "Erreur, merci de contacter l'admin. Erreur n�: ".$q['rows'].""; - } else { - message("Erreur, merci de contacter l'admin. Erreur n�: ".$q['rows']."", "Erreur"); - } - } -} diff --git a/includes/deprecated.php b/includes/deprecated.php deleted file mode 100644 index f86f9ed..0000000 --- a/includes/deprecated.php +++ /dev/null @@ -1,591 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -/** - * Deprecated method used to add a building to the planet building list. - * - * @deprecated - * @param Legacies_Empire_Model_Planet|array $currentPlanet - * @param Legacies_Empire_Model_User|array $currentUser - * @param int $buildingId - * @param bool $AddMode - */ -function AddBuildingToQueue($currentPlanet, $currentUser, $buildingId, $AddMode = true) -{ - defined('DEPRECATION') || trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED); - - if (!$currentPlanet instanceof Legacies_Empire_Model_Planet) { - trigger_error('$currentPlanet should be an instance of Legacies_Empire_Model_Planet', E_USER_WARNING); - $currentPlanet = Legacies_Empire_Model_Planet::factory($currentPlanet['id']); - } - - $currentPlanet->appendBuildingQueue($buildingId, !$AddMode); - - return $currentPlanet->getBuildingQueue()->count(); -} - -/** - * Deprecaed function used to save the planet record - * - * @deprecated - * @param Legacies_Empire_Model_Planet|array $currentPlanet - */ -function BuildingSavePlanetRecord($currentPlanet) -{ - defined('DEPRECATION') || trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED); - - if (!$currentPlanet instanceof Legacies_Empire_Model_Planet) { - trigger_error('$currentPlanet should be an instance of Legacies_Empire_Model_Planet', E_USER_WARNING); - $currentPlanet = Legacies_Empire_Model_Planet::factory($currentPlanet['id']); - } - - $currentPlanet->save(); -} - -/** - * Deprecaed function used to save the user record - * - * @deprecated - * @param Legacies_Empire_Model_User|array $currentUser - */ -function BuildingSaveUserRecord($currentUser) -{ - defined('DEPRECATION') || trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED); - - if (!$currentUser instanceof Legacies_Empire_Model_User) { - trigger_error('$currentUser should be an instance of Legacies_Empire_Model_User', E_USER_WARNING); - $currentUser = Legacies_Empire_Model_User::factory($currentUser['id']); - } - - $currentUser->save(); -} - -/** - * @deprecated - * @param Legacies_Empire_Model_Planet|array $currentPlanet - * @param Legacies_Empire_Model_User|array $currentUser - */ -function CheckPlanetBuildingQueue($currentPlanet, $currentUser) -{ - defined('DEPRECATION') || trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED); - - if (!$currentPlanet instanceof Legacies_Empire_Model_Planet) { - trigger_error('$currentPlanet should be an instance of Legacies_Empire_Model_Planet', E_USER_WARNING); - $currentPlanet = Legacies_Empire_Model_Planet::factory($currentPlanet['id']); - } - - if (!$currentUser instanceof Legacies_Empire_Model_User) { - trigger_error('$currentUser should be an instance of Legacies_Empire_Model_User', E_USER_WARNING); - $currentUser = Legacies_Empire_Model_User::factory($currentUser['id']); - } - - $currentPlanet->updateBuildingQueue(); -} - -/** - * - * @deprecated - * @param Legacies_Empire_Model_Planet|array $currentPlanet - */ -function CheckPlanetUsedFields($currentPlanet) -{ - defined('DEPRECATION') || trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED); - - if (!$currentPlanet instanceof Legacies_Empire_Model_Planet) { - trigger_error('$currentPlanet should be an instance of Legacies_Empire_Model_Planet', E_USER_WARNING); - $currentPlanet = Legacies_Empire_Model_Planet::factory($currentUser['id']); - } - - $currentPlanet->updateStorages()->save(); -} - -/** - * - * @deprecated - * @param Legacies_Empire_Model_User|array $currentUser - * @param Legacies_Empire_Model_Planet|array $currentPlanet - * @param int $buildingId - * @param bool $incremental - * @param bool $destroy - */ -function GetBuildingPrice($currentUser, $currentPlanet, $buildingId, $incremental = true, $destroy = false) -{ - defined('DEPRECATION') || trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED); - - if (!$currentPlanet instanceof Legacies_Empire_Model_Planet) { - trigger_error('$currentPlanet should be an instance of Legacies_Empire_Model_Planet', E_USER_WARNING); - $currentPlanet = Legacies_Empire_Model_Planet::factory($currentPlanet['id']); - } - - if (!$currentUser instanceof Legacies_Empire_Model_User) { - trigger_error('$currentUser should be an instance of Legacies_Empire_Model_User', E_USER_WARNING); - $currentUser = Legacies_Empire_Model_User::factory($currentUser['id']); - } - - $types = Legacies_Empire_Model_Game_Types::getSingleton(); - - if ($types->is($buildingId, Legacies_Empire::TYPE_BUILDING)) { - $level = $currentPlanet->getElement($buildingId); - - if ($incremental) { - if (!$destroy) { - $level++; - } else { - $level--; - } - } - - $resources = $currentPlanet->getResourcesNeeded($buildingId, $level); - return array( - 'metal' => $resources[Legacies_Empire::RESOURCE_METAL], - 'crystal' => $resources[Legacies_Empire::RESOURCE_CRISTAL], - 'deuterium' => $resources[Legacies_Empire::RESOURCE_DEUTERIUM], - 'energy_max' => $resources[Legacies_Empire::RESOURCE_ENERGY] - ); - } else if ($types->is($buildingId, Legacies_Empire::TYPE_RESEARCH)) { - // TODO - } - - return array( - 'metal' => 0, - 'crystal' => 0, - 'deuterium' => 0, - 'energy_max' => 0 - ); -} - -/** - * - * @deprecated - * @param Legacies_Empire_Model_User|array $currentUser - * @param Legacies_Empire_Model_Planet|array $currentPlanet - * @param int $buildingId - */ -function GetBuildingTime($currentUser, $currentPlanet, $buildingId) -{ - defined('DEPRECATION') || trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED); - - if (!$currentPlanet instanceof Legacies_Empire_Model_Planet) { - trigger_error('$currentPlanet should be an instance of Legacies_Empire_Model_Planet', E_USER_WARNING); - $currentPlanet = Legacies_Empire_Model_Planet::factory($currentPlanet['id']); - } - - if (!$currentUser instanceof Legacies_Empire_Model_User) { - trigger_error('$currentUser should be an instance of Legacies_Empire_Model_User', E_USER_WARNING); - $currentUser = Legacies_Empire_Model_User::factory($currentUser['id']); - } - - $types = Legacies_Empire_Model_Game_Types::getSingleton(); - - if ($types->is($buildingId, Legacies_Empire::TYPE_BUILDING)) { - return $currentPlanet->getBuildingTime($buildingId, 1); - } else if ($types->is($buildingId, Legacies_Empire::TYPE_RESEARCH)) { - return $currentPlanet->getResearchLab()->getBuildingTime($buildingId, 1); - } else if ($types->is($buildingId, Legacies_Empire::TYPE_SHIP) || $types->is($buildingId, Legacies_Empire::TYPE_DEFENSE)) { - return $currentPlanet->getShipyard()->getBuildingTime($buildingId, 1); - } - - return 0; -} - -/** - * - * @deprecated - * @param Legacies_Empire_Model_User|array $currentUser - * @param Legacies_Empire_Model_Planet|array $currentPlanet - * @param int $Element - * @param int|string $level - */ -function GetBuildingTimeLevel($currentUser, $currentPlanet, $buildingId, $level) -{ - defined('DEPRECATION') || trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED); - - if (!$currentPlanet instanceof Legacies_Empire_Model_Planet) { - trigger_error('$currentPlanet should be an instance of Legacies_Empire_Model_Planet', E_USER_WARNING); - $currentPlanet = Legacies_Empire_Model_Planet::factory($currentPlanet['id']); - } - - if (!$currentUser instanceof Legacies_Empire_Model_User) { - trigger_error('$currentUser should be an instance of Legacies_Empire_Model_User', E_USER_WARNING); - $currentUser = Legacies_Empire_Model_User::factory($currentUser['id']); - } - - $types = Legacies_Empire_Model_Game_Types::getSingleton(); - - if ($types->is($buildingId, Legacies_Empire::TYPE_BUILDING)) { - return $currentPlanet->getBuildingTime($buildingId, $level); - } else if ($types->is($buildingId, Legacies_Empire::TYPE_RESEARCH)) { - return $currentPlanet->getLaboratory()->getBuildingTime($buildingId, $level); - } else if ($types->is($buildingId, Legacies_Empire::TYPE_SHIP) || $types->is($buildingId, Legacies_Empire::TYPE_DEFENSE)) { - return $currentPlanet->getShipyard()->getBuildingTime($buildingId, $level); - } - - return 0; -} - -/** - * - * @deprecated - * @param Legacies_Empire_Model_User|array $currentUser - * @param Legacies_Empire_Model_Planet|array $currentPlanet - * @param int $buildingId - * @param unknown_type $userfactor - */ -function GetElementPrice($currentUser, $currentPlanet, $buildingId, $userfactor = true) -{ - defined('DEPRECATION') || trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED); - - if (!$currentPlanet instanceof Legacies_Empire_Model_Planet) { - trigger_error('$currentPlanet should be an instance of Legacies_Empire_Model_Planet', E_USER_WARNING); - $currentPlanet = Legacies_Empire_Model_Planet::factory($currentPlanet['id']); - } - - if (!$currentUser instanceof Legacies_Empire_Model_User) { - trigger_error('$currentUser should be an instance of Legacies_Empire_Model_User', E_USER_WARNING); - $currentUser = Legacies_Empire_Model_User::factory($currentUser['id']); - } - - global $lang; - - $prices = Legacies_Empire_Model_Game_Prices::getSingleton(); - $types = Legacies_Empire_Model_Game_Types::getSingleton(); - - $array = array( - Legacies_Empire::RESOURCE_METAL => $lang["Metal"], - Legacies_Empire::RESOURCE_CRISTAL => $lang["Crystal"], - Legacies_Empire::RESOURCE_DEUTERIUM => $lang["Deuterium"], - Legacies_Empire::RESOURCE_ENERGY => $lang["Energy"] - ); - - if ($types->is($buildingId, Legacies_Empire::TYPE_BUILDING)) { - $cost = $currentPlanet->getResourcesNeeded($buildingId, $currentPlanet->getElement($buildingId) + 1); - } else if ($types->is($buildingId, Legacies_Empire::TYPE_RESEARCH)) { - // TODO - } else if ($types->is($buildingId, Legacies_Empire::TYPE_SHIP) || $types->is($buildingId, Legacies_Empire::TYPE_DEFENSE)) { - $cost = $currentPlanet->getShipyard()->getResourcesNeeded($buildingId, 1); - } else { - return null; - } - - $output = $lang['Requires'] . ": "; - foreach ($array as $resourceId => $resourceLabel) { - if (Math::isPositive($prices[$buildingId][$resourceId])) { - $output .= $resourceLabel . ": "; - - if (Math::comp($cost[$resourceId], $currentPlanet->getData($resourceId)) > 0) { - $text .= ''; - $text .= '' . Math::render($cost[$resourceId]) . ''; - } else { - $text .= ' ' . Math::render($cost[$resourceId]) . ''; - } - } - } - return $text; -} - -/** - * - * @deprecated - * @param int $elementId - * @param int|string $count - */ -function GetElementRessources($elementId, $count) -{ - defined('DEPRECATION') || trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED); - - $currentUser = Legacies_Empire_Model_User::getSingleton(); - $currentPlanet = $currentUser->getCurrentPlanet(); - - return $currentPlanet->getShipyard()->getResourcesNeeded($buildingId, $count); -} - -/** - * - * @deprecated - * @param Legacies_Empire_Model_User|array $currentUser - * @param Legacies_Empire_Model_Planet|array $currentPlanet - * @param int $productionTime - * - * @see Lagecies_Empire_Model_Planet::updateBuildingQueue() - */ -function HandleElementBuildingQueue($currentUser, $currentPlanet, $productionTime) -{ - defined('DEPRECATION') || trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED); - - return array(); -} - -/** - * - * @deprecated - * @param bool $isUserChecked - * - * @see Legacies_Empire_Model_User::getSingleton() - */ -function CheckCookies($isUserChecked) -{ - defined('DEPRECATION') || trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED); - - $user = Legacies_Empire_Model_User::getSingleton(); - - if ($user instanceof Legacies_Empire_Model_User) { - return array( - 'state' => true, - 'record' => $user - ); - } else { - return array( - 'state' => false, - 'record' => array() - ); - } -} - -/** - * - * @deprecated - * @param bool $isUserChecked - * - * @see Legacies_Empire_Model_User::getSingleton() - */ -function CheckTheUser($isUserChecked) -{ - defined('DEPRECATION') || trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED); - - $result = CheckCookies($isUserChecked); - - if ($result['record'] instanceof Legacies_Empire_Model_User && $result['record']['bana']) { - die(parsetemplate(gettemplate('usr_banned'), $lang)); - } - - return $result; -} - -/** - * - * @deprecated - * @param Legacies_Empire_Model_Planet|array $currentPlanet - * @param Legacies_Empire_Model_User|array $currentUser - * - * @see Legacies_Empire_Model_Planet::updateBuildingQueue() - */ -function UpdatePlanetBatimentQueueList($currentPlanet, $currentUser) -{ - defined('DEPRECATION') || trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED); - - if (!$currentPlanet instanceof Legacies_Empire_Model_Planet) { - trigger_error('$currentPlanet should be an instance of Legacies_Empire_Model_Planet', E_USER_WARNING); - $currentPlanet = Legacies_Empire_Model_Planet::factory($currentPlanet['id']); - } - - $currentPlanet->updateBuildingQueue(Legacies::now()); - - return true; -} - -/** - * - * @deprecated - * @param Legacies_Empire_Model_Planet|array $currentPlanet - */ -function CalculateMaxPlanetFields($currentPlanet) -{ - defined('DEPRECATION') || trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED); - - if (!$currentPlanet instanceof Legacies_Empire_Model_Planet) { - trigger_error('$currentPlanet should be an instance of Legacies_Empire_Model_Planet', E_USER_WARNING); - $currentPlanet = Legacies_Empire_Model_Planet::factory($currentPlanet['id']); - } - - return max(1, $currentPlanet['field_max'] + ($currentPlanet->getElement(Legacies_Empire::ID_BUILDING_TERRAFORMER) * 5)); -} - - -/** - * - * @deprecated - * @param Legacies_Empire_Model_User|array $currentUser - * @param Legacies_Empire_Model_Planet|array $currentPlanet - */ -function AbandonColony($currentUser, $currentPlanet) -{ - defined('DEPRECATION') || trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED); - - if (!$currentPlanet instanceof Legacies_Empire_Model_Planet) { - trigger_error('$currentPlanet should be an instance of Legacies_Empire_Model_Planet', E_USER_WARNING); - $currentPlanet = Legacies_Empire_Model_Planet::factory($currentPlanet['id']); - } - - try { - $currentPlanet->destroy(); - } catch (Legacies_Core_Model_Exception $e) { - Legacies_Core_Model_Session::factory('empire')->addCritical($e->getMessage()); - } catch (Legacies_Empire_Model_Planet_Exception $e) { - Legacies_Core_Model_Session::factory('empire')->addError($e->getMessage()); - } -} - -/** - * - * @deprecated - * @param Legacies_Empire_Model_Planet|array $currentPlanet - */ -function CheckFleets($currentPlanet) -{ - defined('DEPRECATION') || trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED); - - if (!$currentPlanet instanceof Legacies_Empire_Model_Planet) { - trigger_error('$currentPlanet should be an instance of Legacies_Empire_Model_Planet', E_USER_WARNING); - $currentPlanet = Legacies_Empire_Model_Planet::factory($currentPlanet['id']); - } - - return (bool) ($currentPlanet->getFleetCollection()->count() > 0); -} - -/** - * - * @deprecated - * @param Legacies_Empire_Model_User|array $currentUser - * @param Legacies_Empire_Model_Planet|array $currentPlanet - */ -function CancelBuildingFromQueue($currentPlanet, $currentUser) -{ - defined('DEPRECATION') || trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED); - - if (!$currentPlanet instanceof Legacies_Empire_Model_Planet) { - trigger_error('$currentPlanet should be an instance of Legacies_Empire_Model_Planet', E_USER_WARNING); - $currentPlanet = Legacies_Empire_Model_Planet::factory($currentPlanet['id']); - } - - if ($currentPlanet->getBuildingQueue()->count() <= 0) { - return false; - } - - $currentPlanet->dequeueBuilding(); - - return true; -} - -/** - * - * @deprecated - * @param string $page The page content - * @param string $title The page title - * @param bool $topnav Wether we show the top navigation or not - * @param null $metatags Extra meta tags - * @param bool $AdminPage unused - */ -function display($page, $title = '', $topnav = true, $metatags = '', $AdminPage = false) -{ - defined('DEPRECATION') || trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED); - - // TODO: implement extra meta tags - $layout = new Legacies_Core_Layout(); - $layout->load('2columns-left'); - $content = $layout->getBlock('content'); - - if ($topnav) { - $topnav = $layout->createBlock('empire/topnav', 'topnav'); - $topnav->setTemplate('empire/topnav.phtml'); - $content->topnav = $topnav; - } - - $pageContent = $layout->createBlock('core/text', 'content'); - $pageContent->setContent($page); - $content->page = $pageContent; - - echo $layout->render(); - exit(0); -} - -/** - * - * @deprecated - * @param string $template The page template - * @param array $array The view data - */ -function parsetemplate($template, $array) -{ - defined('DEPRECATION') || trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED); - - static $baseUrl = null; - if ($baseUrl === null) { - $user = Legacies_Empire_Model_User::getSingleton(); - if ($user !== null && $user->getId() && ($baseUrl = $user->getSkinPath()) == '') { - $baseUrl = DEFAULT_SKINPATH; - } - } - $array['dpath'] = $baseUrl; - - $view = new Legacies_Core_View($array); - $view->setTemplate('deprecated/' .$template . '.tpl'); - - return $view->render(); -} - -/** - * - * @deprecated - * @param string $filename - * @return string - */ -function ReadFromFile($filename) -{ - defined('DEPRECATION') || trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED); - - return file_get_contents($filename); -} - -/** - * - * @deprecated - * @param string $filename - * @param string $content - * @return void - */ -function saveToFile($filename, $content) -{ - defined('DEPRECATION') || trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED); - - file_put_contents($filename, $content); -} - -/** - * - * @deprecated - * @param string $templateName - * @return string - */ -function getTemplate($templateName) -{ - defined('DEPRECATION') || trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED); - - return $templateName; -} \ No newline at end of file diff --git a/includes/functions/CreateOneMoonRecord.php b/includes/functions/CreateOneMoonRecord.php deleted file mode 100644 index a014010..0000000 --- a/includes/functions/CreateOneMoonRecord.php +++ /dev/null @@ -1,129 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -/** - * - * @deprecated - * @param unknown_type $Galaxy - * @param unknown_type $System - * @param unknown_type $Planet - * @param unknown_type $Owner - * @param unknown_type $MoonID - * @param unknown_type $MoonName - * @param unknown_type $Chance - */ -function CreateOneMoonRecord ( $Galaxy, $System, $Planet, $Owner, $MoonID, $MoonName, $Chance ) { - global $lang; - - $PlanetName = ""; - - $QryGetMoonPlanetData = "SELECT * FROM {{table}} "; - $QryGetMoonPlanetData .= "WHERE "; - $QryGetMoonPlanetData .= "`galaxy` = '". $Galaxy ."' AND "; - $QryGetMoonPlanetData .= "`system` = '". $System ."' AND "; - $QryGetMoonPlanetData .= "`planet` = '". $Planet ."';"; - $MoonPlanet = doquery ( $QryGetMoonPlanetData, 'planets', true); - - $QryGetMoonGalaxyData = "SELECT * FROM {{table}} "; - $QryGetMoonGalaxyData .= "WHERE "; - $QryGetMoonGalaxyData .= "`galaxy` = '". $Galaxy ."' AND "; - $QryGetMoonGalaxyData .= "`system` = '". $System ."' AND "; - $QryGetMoonGalaxyData .= "`planet` = '". $Planet ."';"; - $MoonGalaxy = doquery ( $QryGetMoonGalaxyData, 'galaxy', true); - - if ($MoonGalaxy['id_luna'] == 0) { - if ($MoonPlanet['id'] != 0) { - $SizeMin = 2000 + ( $Chance * 100 ); - $SizeMax = 6000 + ( $Chance * 200 ); - - $PlanetName = $MoonPlanet['name']; - - $maxtemp = $MoonPlanet['temp_max'] - rand(10, 45); - $mintemp = $MoonPlanet['temp_min'] - rand(10, 45); - $size = rand ($SizeMin, $SizeMax); - - $QryInsertMoonInLunas = "INSERT INTO {{table}} SET "; - $QryInsertMoonInLunas .= "`name` = '". ( ($MoonName == '') ? $lang['sys_moon'] : $MoonName ) ."', "; - $QryInsertMoonInLunas .= "`galaxy` = '". $Galaxy ."', "; - $QryInsertMoonInLunas .= "`system` = '". $System ."', "; - $QryInsertMoonInLunas .= "`lunapos` = '". $Planet ."', "; - $QryInsertMoonInLunas .= "`id_owner` = '". $Owner ."', "; - $QryInsertMoonInLunas .= "`temp_max` = '". $maxtemp ."', "; - $QryInsertMoonInLunas .= "`temp_min` = '". $mintemp ."', "; - $QryInsertMoonInLunas .= "`diameter` = '". $size ."', "; - $QryInsertMoonInLunas .= "`id_luna` = '". $MoonID ."';"; - doquery( $QryInsertMoonInLunas , 'lunas' ); - - $QryGetMoonIdFromLunas = "SELECT * FROM {{table}} "; - $QryGetMoonIdFromLunas .= "WHERE "; - $QryGetMoonIdFromLunas .= "`galaxy` = '". $Galaxy ."' AND "; - $QryGetMoonIdFromLunas .= "`system` = '". $System ."' AND "; - $QryGetMoonIdFromLunas .= "`lunapos` = '". $Planet ."';"; - $lunarow = doquery( $QryGetMoonIdFromLunas , 'lunas', true); - - $QryUpdateMoonInGalaxy = "UPDATE {{table}} SET "; - $QryUpdateMoonInGalaxy .= "`id_luna` = '". $lunarow['id'] ."', "; - $QryUpdateMoonInGalaxy .= "`luna` = '0' "; - $QryUpdateMoonInGalaxy .= "WHERE "; - $QryUpdateMoonInGalaxy .= "`galaxy` = '". $Galaxy ."' AND "; - $QryUpdateMoonInGalaxy .= "`system` = '". $System ."' AND "; - $QryUpdateMoonInGalaxy .= "`planet` = '". $Planet ."';"; - doquery( $QryUpdateMoonInGalaxy , 'galaxy'); - - $QryInsertMoonInPlanet = "INSERT INTO {{table}} SET "; - $QryInsertMoonInPlanet .= "`name` = '" .$lang['sys_moon'] ."', "; - $QryInsertMoonInPlanet .= "`id_owner` = '". $Owner ."', "; - $QryInsertMoonInPlanet .= "`galaxy` = '". $Galaxy ."', "; - $QryInsertMoonInPlanet .= "`system` = '". $System ."', "; - $QryInsertMoonInPlanet .= "`planet` = '". $Planet ."', "; - $QryInsertMoonInPlanet .= "`last_update` = '". time() ."', "; - $QryInsertMoonInPlanet .= "`planet_type` = '3', "; - $QryInsertMoonInPlanet .= "`image` = 'mond', "; - $QryInsertMoonInPlanet .= "`diameter` = '". $size ."', "; - $QryInsertMoonInPlanet .= "`field_max` = '1', "; - $QryInsertMoonInPlanet .= "`temp_min` = '". $maxtemp ."', "; - $QryInsertMoonInPlanet .= "`temp_max` = '". $mintemp ."', "; - $QryInsertMoonInPlanet .= "`metal` = '0', "; - $QryInsertMoonInPlanet .= "`metal_perhour` = '0', "; - $QryInsertMoonInPlanet .= "`metal_max` = '".BASE_STORAGE_SIZE."', "; - $QryInsertMoonInPlanet .= "`crystal` = '0', "; - $QryInsertMoonInPlanet .= "`crystal_perhour` = '0', "; - $QryInsertMoonInPlanet .= "`crystal_max` = '".BASE_STORAGE_SIZE."', "; - $QryInsertMoonInPlanet .= "`deuterium` = '0', "; - $QryInsertMoonInPlanet .= "`deuterium_perhour` = '0', "; - $QryInsertMoonInPlanet .= "`deuterium_max` = '".BASE_STORAGE_SIZE."';"; - doquery( $QryInsertMoonInPlanet , 'planets'); - } - } - - return $PlanetName; -} - -?> \ No newline at end of file diff --git a/includes/functions/CreateOnePlanetRecord.php b/includes/functions/CreateOnePlanetRecord.php deleted file mode 100644 index d7cef08..0000000 --- a/includes/functions/CreateOnePlanetRecord.php +++ /dev/null @@ -1,227 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -/** - * - * @deprecated - * @param unknown_type $Position - * @param unknown_type $HomeWorld - */ -function PlanetSizeRandomiser ($Position, $HomeWorld = false) { - global $gameConfig; - - if (!$HomeWorld) { - $ClassicBase = 163; - $SettingSize = $gameConfig['initial_fields']; - $PlanetRatio = floor ( ($ClassicBase / $SettingSize) * 10000 ) / 100; - $RandomMin = array ( 40, 50, 55, 100, 95, 80, 115, 120, 125, 75, 80, 85, 60, 40, 50); - $RandomMax = array ( 90, 95, 95, 240, 240, 230, 180, 180, 190, 125, 120, 130, 160, 300, 150); - $CalculMin = floor ( $RandomMin[$Position - 1] + ( $RandomMin[$Position - 1] * $PlanetRatio ) / 100 ); - $CalculMax = floor ( $RandomMax[$Position - 1] + ( $RandomMax[$Position - 1] * $PlanetRatio ) / 100 ); - $RandomSize = mt_rand($CalculMin, $CalculMax); - $MaxAddon = mt_rand(0, 110); - $MinAddon = mt_rand(0, 100); - $Addon = ($MaxAddon - $MinAddon); - $PlanetFields = ($RandomSize + $abweichung); - } else { - $PlanetFields = $gameConfig['initial_fields']; - } - $PlanetSize = ($PlanetFields ^ (14 / 1.5)) * 75; - - $return['diameter'] = $PlanetSize; - $return['field_max'] = $PlanetFields; - return $return; -} - -/** - * - * @deprecated - * @param unknown_type $Galaxy - * @param unknown_type $System - * @param unknown_type $Position - * @param unknown_type $PlanetOwnerID - * @param unknown_type $PlanetName - * @param unknown_type $HomeWorld - */ -function CreateOnePlanetRecord($Galaxy, $System, $Position, $PlanetOwnerID, $PlanetName = '', $HomeWorld = false) { - global $lang; - - // Avant tout, on verifie s'il existe deja une planete a cet endroit - $QrySelectPlanet = "SELECT `id` "; - $QrySelectPlanet .= "FROM {{table}} "; - $QrySelectPlanet .= "WHERE "; - $QrySelectPlanet .= "`galaxy` = '". $Galaxy ."' AND "; - $QrySelectPlanet .= "`system` = '". $System ."' AND "; - $QrySelectPlanet .= "`planet` = '". $Position ."';"; - $PlanetExist = doquery( $QrySelectPlanet, 'planets', true); - - // Si $PlanetExist est autre chose que false ... c'est qu'il y a quelque chose l� bas ... - // C'est donc aussi que je ne peux pas m'y poser !! - if (!$PlanetExist) { - $planet = PlanetSizeRandomiser ($Position, $HomeWorld); - $planet['diameter'] = ($planet['field_max'] ^ (14 / 1.5)) * 75 ; - $planet['metal'] = BUILD_METAL; - $planet['crystal'] = BUILD_CRISTAL; - $planet['deuterium'] = BUILD_DEUTERIUM; - $planet['metal_perhour'] = $gameConfig['metal_basic_income']; - $planet['crystal_perhour'] = $gameConfig['crystal_basic_income']; - $planet['deuterium_perhour'] = $gameConfig['deuterium_basic_income']; - $planet['metal_max'] = BASE_STORAGE_SIZE; - $planet['crystal_max'] = BASE_STORAGE_SIZE; - $planet['deuterium_max'] = BASE_STORAGE_SIZE; - - // Posistion 1 - 3: 80% entre 40 et 70 Cases ( 55+ / -15 ) - // Posistion 4 - 6: 80% entre 120 et 310 Cases ( 215+ / -95 ) - // Posistion 7 - 9: 80% entre 105 et 195 Cases ( 150+ / -45 ) - // Posistion 10 - 12: 80% entre 75 et 125 Cases ( 100+ / -25 ) - // Posistion 13 - 15: 80% entre 60 et 190 Cases ( 125+ / -65 ) - - $planet['galaxy'] = $Galaxy; - $planet['system'] = $System; - $planet['planet'] = $Position; - - if ($Position == 1 || $Position == 2 || $Position == 3) { - $PlanetType = array('trocken'); - $PlanetClass = array('planet'); - $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10'); - $planet['temp_min'] = rand(0, 100); - $planet['temp_max'] = $planet['temp_min'] + 40; - } elseif ($Position == 4 || $Position == 5 || $Position == 6) { - $PlanetType = array('dschjungel'); - $PlanetClass = array('planet'); - $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10'); - $planet['temp_min'] = rand(-25, 75); - $planet['temp_max'] = $planet['temp_min'] + 40; - } elseif ($Position == 7 || $Position == 8 || $Position == 9) { - $PlanetType = array('normaltemp'); - $PlanetClass = array('planet'); - $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07'); - $planet['temp_min'] = rand(-50, 50); - $planet['temp_max'] = $planet['temp_min'] + 40; - } elseif ($Position == 10 || $Position == 11 || $Position == 12) { - $PlanetType = array('wasser'); - $PlanetClass = array('planet'); - $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09'); - $planet['temp_min'] = rand(-75, 25); - $planet['temp_max'] = $planet['temp_min'] + 40; - } elseif ($Position == 13 || $Position == 14 || $Position == 15) { - $PlanetType = array('eis'); - $PlanetClass = array('planet'); - $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10'); - $planet['temp_min'] = rand(-100, 10); - $planet['temp_max'] = $planet['temp_min'] + 40; - } else { - $PlanetType = array('dschjungel', 'gas', 'normaltemp', 'trocken', 'wasser', 'wuesten', 'eis'); - $PlanetClass = array('planet'); - $PlanetDesign = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '00',); - $planet['temp_min'] = rand(-120, 10); - $planet['temp_max'] = $planet['temp_min'] + 40; - } - - $planet['image'] = $PlanetType[ rand( 0, count( $PlanetType ) -1 ) ]; - $planet['image'] .= $PlanetClass[ rand( 0, count( $PlanetClass ) - 1 ) ]; - $planet['image'] .= $PlanetDesign[ rand( 0, count( $PlanetDesign ) - 1 ) ]; - $planet['planet_type'] = 1; - $planet['id_owner'] = $PlanetOwnerID; - $planet['last_update'] = time(); - $planet['name'] = ($PlanetName == '') ? $lang['sys_colo_defaultname'] : $PlanetName; - - $QryInsertPlanet = "INSERT INTO {{table}} SET "; - $QryInsertPlanet .= "`name` = '". $planet['name'] ."', "; - $QryInsertPlanet .= "`id_owner` = '". $planet['id_owner'] ."', "; - $QryInsertPlanet .= "`galaxy` = '". $planet['galaxy'] ."', "; - $QryInsertPlanet .= "`system` = '". $planet['system'] ."', "; - $QryInsertPlanet .= "`planet` = '". $planet['planet'] ."', "; - $QryInsertPlanet .= "`last_update` = '". $planet['last_update'] ."', "; - $QryInsertPlanet .= "`planet_type` = '". $planet['planet_type'] ."', "; - $QryInsertPlanet .= "`image` = '". $planet['image'] ."', "; - $QryInsertPlanet .= "`diameter` = '". $planet['diameter'] ."', "; - $QryInsertPlanet .= "`field_max` = '". $planet['field_max'] ."', "; - $QryInsertPlanet .= "`temp_min` = '". $planet['temp_min'] ."', "; - $QryInsertPlanet .= "`temp_max` = '". $planet['temp_max'] ."', "; - $QryInsertPlanet .= "`metal` = '". $planet['metal'] ."', "; - $QryInsertPlanet .= "`metal_perhour` = '". $planet['metal_perhour'] ."', "; - $QryInsertPlanet .= "`metal_max` = '". $planet['metal_max'] ."', "; - $QryInsertPlanet .= "`crystal` = '". $planet['crystal'] ."', "; - $QryInsertPlanet .= "`crystal_perhour` = '". $planet['crystal_perhour'] ."', "; - $QryInsertPlanet .= "`crystal_max` = '". $planet['crystal_max'] ."', "; - $QryInsertPlanet .= "`deuterium` = '". $planet['deuterium'] ."', "; - $QryInsertPlanet .= "`deuterium_perhour` = '". $planet['deuterium_perhour'] ."', "; - $QryInsertPlanet .= "`deuterium_max` = '". $planet['deuterium_max'] ."';"; - doquery( $QryInsertPlanet, 'planets'); - - // On recupere l'id de planete nouvellement cr�� - $QrySelectPlanet = "SELECT `id` "; - $QrySelectPlanet .= "FROM {{table}} "; - $QrySelectPlanet .= "WHERE "; - $QrySelectPlanet .= "`galaxy` = '". $planet['galaxy'] ."' AND "; - $QrySelectPlanet .= "`system` = '". $planet['system'] ."' AND "; - $QrySelectPlanet .= "`planet` = '". $planet['planet'] ."' AND "; - $QrySelectPlanet .= "`id_owner` = '". $planet['id_owner'] ."';"; - $GetPlanetID = doquery( $QrySelectPlanet , 'planets', true); - - // Testons s'il y a deja eu une planete ici - $QrySelectGalaxy = "SELECT * "; - $QrySelectGalaxy .= "FROM {{table}} "; - $QrySelectGalaxy .= "WHERE "; - $QrySelectGalaxy .= "`galaxy` = '". $planet['galaxy'] ."' AND "; - $QrySelectGalaxy .= "`system` = '". $planet['system'] ."' AND "; - $QrySelectGalaxy .= "`planet` = '". $planet['planet'] ."';"; - $GetGalaxyID = doquery( $QrySelectGalaxy, 'galaxy', true); - - if ($GetGalaxyID) { - // Ah ... Ce secteur de ce vaste monde a deja ete occup� - $QryUpdateGalaxy = "UPDATE {{table}} SET "; - $QryUpdateGalaxy .= "`id_planet` = '". $GetPlanetID['id'] ."' "; - $QryUpdateGalaxy .= "WHERE "; - $QryUpdateGalaxy .= "`galaxy` = '". $planet['galaxy'] ."' AND "; - $QryUpdateGalaxy .= "`system` = '". $planet['system'] ."' AND "; - $QryUpdateGalaxy .= "`planet` = '". $planet['planet'] ."';"; - doquery( $QryUpdateGalaxy, 'galaxy'); - } else { - // C'est tout vide ... y a que dalle ... j'm'y pose !! - $QryInsertGalaxy = "INSERT INTO {{table}} SET "; - $QryInsertGalaxy .= "`galaxy` = '". $planet['galaxy'] ."', "; - $QryInsertGalaxy .= "`system` = '". $planet['system'] ."', "; - $QryInsertGalaxy .= "`planet` = '". $planet['planet'] ."', "; - $QryInsertGalaxy .= "`id_planet` = '". $GetPlanetID['id'] ."';"; - doquery( $QryInsertGalaxy, 'galaxy'); - } - - $RetValue = true; - } else { - - $RetValue = false; - } - - return $RetValue; -} - -?> \ No newline at end of file diff --git a/includes/functions/DeleteSelectedUser.php b/includes/functions/DeleteSelectedUser.php deleted file mode 100644 index 42b0b0b..0000000 --- a/includes/functions/DeleteSelectedUser.php +++ /dev/null @@ -1,74 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -/** - * - * @deprecated - * @param unknown_type $UserID - */ -function DeleteSelectedUser ( $UserID ) { - - trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED); - $TheUser = doquery ( "SELECT * FROM {{table}} WHERE `id` = '" . $UserID . "';", 'users', true ); - if ( $TheUser['ally_id'] != 0 ) { - $TheAlly = doquery ( "SELECT * FROM {{table}} WHERE `id` = '" . $TheUser['ally_id'] . "';", 'alliance', true ); - $TheAlly['ally_members'] -= 1; - if ( $TheAlly['ally_members'] > 0 ) { - doquery ( "UPDATE {{table}} SET `ally_members` = '" . $TheAlly['ally_members'] . "' WHERE `id` = '" . $TheAlly['id'] . "';", 'alliance' ); - } else { - doquery ( "DELETE FROM {{table}} WHERE `id` = '" . $TheAlly['id'] . "';", 'alliance' ); - doquery ( "DELETE FROM {{table}} WHERE `stat_type` = '2' AND `id_owner` = '" . $TheAlly['id'] . "';", 'statpoints' ); - } - } - doquery ( "DELETE FROM {{table}} WHERE `stat_type` = '1' AND `id_owner` = '" . $UserID . "';", 'statpoints' ); - - $ThePlanets = doquery ( "SELECT * FROM {{table}} WHERE `id_owner` = '" . $UserID . "';", 'planets' ); - while ( $OnePlanet = mysql_fetch_assoc ( $ThePlanets ) ) { - if ( $OnePlanet['planet_type'] == 1 ) { - doquery ( "DELETE FROM {{table}} WHERE `galaxy` = '" . $OnePlanet['galaxy'] . "' AND `system` = '" . $OnePlanet['system'] . "' AND `planet` = '" . $OnePlanet['planet'] . "';", 'galaxy' ); - } elseif ( $OnePlanet['planet_type'] == 3 ) { - doquery ( "DELETE FROM {{table}} WHERE `galaxy` = '" . $OnePlanet['galaxy'] . "' AND `system` = '" . $OnePlanet['system'] . "' AND `lunapos` = '" . $OnePlanet['planet'] . "';", 'lunas' ); - } - doquery ( "DELETE FROM {{table}} WHERE `id` = '" . $OnePlanet['id'] . "';", 'planets' ); - } - doquery ( "DELETE FROM {{table}} WHERE `message_sender` = '" . $UserID . "';", 'messages' ); - doquery ( "DELETE FROM {{table}} WHERE `message_owner` = '" . $UserID . "';", 'messages' ); - doquery ( "DELETE FROM {{table}} WHERE `owner` = '" . $UserID . "';", 'notes' ); - doquery ( "DELETE FROM {{table}} WHERE `fleet_owner` = '" . $UserID . "';", 'fleets' ); - doquery ( "DELETE FROM {{table}} WHERE `id_owner1` = '" . $UserID . "';", 'rw' ); - doquery ( "DELETE FROM {{table}} WHERE `id_owner2` = '" . $UserID . "';", 'rw' ); - doquery ( "DELETE FROM {{table}} WHERE `sender` = '" . $UserID . "';", 'buddy' ); - doquery ( "DELETE FROM {{table}} WHERE `owner` = '" . $UserID . "';", 'buddy' ); - doquery ( "DELETE FROM {{table}} WHERE `user` = '" . $UserID . "';", 'annonce' ); - doquery ( "DELETE FROM {{table}} WHERE `id` = '" . $UserID . "';", 'users' ); - -} - -?> \ No newline at end of file diff --git a/includes/functions/ElementBuildListBox.php b/includes/functions/ElementBuildListBox.php deleted file mode 100644 index 0351cbf..0000000 --- a/includes/functions/ElementBuildListBox.php +++ /dev/null @@ -1,71 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -/** - * - * @deprecated - * @param unknown_type $CurrentUser - * @param unknown_type $CurrentPlanet - */ -function ElementBuildListBox ( $CurrentUser, $CurrentPlanet ) { - global $lang, $pricelist; - - trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED); -// // Array del b_hangar_id -// $ElementQueue = explode(';', $CurrentPlanet['b_hangar_id']); -// $NbrePerType = ""; -// $NamePerType = ""; -// $TimePerType = ""; -// -// foreach($ElementQueue as $ElementLine => $Element) { -// if ($Element != '') { -// $Element = explode(',', $Element); -// $ElementTime = GetBuildingTime( $CurrentUser, $CurrentPlanet, $Element[0] ); -// $QueueTime += $ElementTime * $Element[1]; -// $TimePerType .= "".$ElementTime.","; -// $NamePerType .= "'". html_entity_decode($lang['tech'][$Element[0]]) ."',"; -// $NbrePerType .= "".$Element[1].","; -// } -// } -// -// $parse = $lang; -// $parse['a'] = $NbrePerType; -// $parse['b'] = $NamePerType; -// $parse['c'] = $TimePerType; -// $parse['b_hangar_id_plus'] = $CurrentPlanet['b_hangar']; -// -// $parse['pretty_time_b_hangar'] = pretty_time($QueueTime - $CurrentPlanet['b_hangar']); -// -// $text .= parsetemplate(gettemplate('buildings_script'), $parse); -// -// return $text; -} - -?> \ No newline at end of file diff --git a/includes/functions/FlyingFleetHandler.php b/includes/functions/FlyingFleetHandler.php deleted file mode 100644 index cc2b852..0000000 --- a/includes/functions/FlyingFleetHandler.php +++ /dev/null @@ -1,108 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -/** - * - * @deprecated - * @param unknown_type $planet - */ -function FlyingFleetHandler($planet) { - global $resource; - - $sql =<<getFleetCollection(Legacies::now()) as $CurrentFleet) { - switch ($CurrentFleet["fleet_mission"]) { - case Legacies_Empire::ID_MISSION_ATTACK: - // Attaquer - MissionCaseAttack ( $CurrentFleet ); - break; - - case Legacies_Empire::ID_MISSION_TRANSPORT: - // Transporter - MissionCaseTransport ( $CurrentFleet ); - break; - - case Legacies_Empire::ID_MISSION_STATION: - // Stationner - MissionCaseStay ( $CurrentFleet ); - break; - - case Legacies_Empire::ID_MISSION_STATION_ALLY: - // Stationner chez un Allié - MissionCaseStayAlly ( $CurrentFleet ); - break; - - case Legacies_Empire::ID_MISSION_SPY: - // Flotte d'espionnage - MissionCaseSpy ( $CurrentFleet ); - break; - - case Legacies_Empire::ID_MISSION_SETTLE_COLONY: - // Coloniser - MissionCaseColonisation ( $CurrentFleet ); - break; - - case Legacies_Empire::ID_MISSION_RECYCLE: - // Recyclage - MissionCaseRecycling ( $CurrentFleet ); - break; - - case Legacies_Empire::ID_MISSION_DESTROY: - // Detruire ??? dans le code ogame c'est 9 !! - MissionCaseDestruction ( $CurrentFleet ); - break; - - case Legacies_Empire::ID_MISSION_EXPEDITION: - // Expeditions - MissionCaseExpedition ( $CurrentFleet ); - break; - - case Legacies_Empire::ID_MISSION_GROUP_ATTACK: // TODO: implement mission type - case Legacies_Empire::ID_MISSION_MISSILES: // TODO: implement mission type - default: - $CurrentFleet->delete(); - break; - } - } - - //doquery("UNLOCK TABLES", ""); // FIXME: use transactions -} \ No newline at end of file diff --git a/includes/functions/GalaxyRowUser.php b/includes/functions/GalaxyRowUser.php deleted file mode 100644 index 88745f2..0000000 --- a/includes/functions/GalaxyRowUser.php +++ /dev/null @@ -1,141 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -/** - * - * @deprecated - * @param unknown_type $GalaxyRow - * @param unknown_type $GalaxyRowPlanet - * @param unknown_type $GalaxyRowUser - * @param unknown_type $Galaxy - * @param unknown_type $System - * @param unknown_type $Planet - * @param unknown_type $PlanetType - */ -function GalaxyRowUser ( $GalaxyRow, $GalaxyRowPlanet, $GalaxyRowUser, $Galaxy, $System, $Planet, $PlanetType ) { - global $lang, $user; - - // Joueur - $Result = ""; - if ($GalaxyRowUser && $GalaxyRowPlanet["destruyed"] == 0) { - $NoobProt = doquery("SELECT * FROM {{table}} WHERE `config_name` = 'noobprotection';", 'config', true); - $NoobTime = doquery("SELECT * FROM {{table}} WHERE `config_name` = 'noobprotectiontime';", 'config', true); - $NoobMulti = doquery("SELECT * FROM {{table}} WHERE `config_name` = 'noobprotectionmulti';", 'config', true); - $UserPoints = doquery("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '". $user['id'] ."';", 'statpoints', true); - $User2Points = doquery("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '". $GalaxyRowUser['id'] ."';", 'statpoints', true); - $CurrentPoints = $UserPoints['total_points']; - $RowUserPoints = $User2Points['total_points']; - $CurrentLevel = $CurrentPoints * $NoobMulti['config_value']; - $RowUserLevel = $RowUserPoints * $NoobMulti['config_value']; - if ($GalaxyRowUser['bana'] == 1 AND - $GalaxyRowUser['urlaubs_modus'] == 1) { - $Systemtatus2 = $lang['vacation_shortcut']." ".$lang['banned_shortcut'].""; - $Systemtatus = ""; - } elseif ($GalaxyRowUser['bana'] == 1) { - $Systemtatus2 = "".$lang['banned_shortcut'].""; - $Systemtatus = ""; - } elseif ($GalaxyRowUser['urlaubs_modus'] == 1) { - $Systemtatus2 = "".$lang['vacation_shortcut'].""; - $Systemtatus = ""; - } elseif ($GalaxyRowUser['onlinetime'] < (time()-60 * 60 * 24 * 7) AND - $GalaxyRowUser['onlinetime'] > (time()-60 * 60 * 24 * 28)) { - $Systemtatus2 = "".$lang['inactif_7_shortcut'].""; - $Systemtatus = ""; - } elseif ($GalaxyRowUser['onlinetime'] < (time()-60 * 60 * 24 * 28)) { - $Systemtatus2 = "".$lang['inactif_7_shortcut']." ".$lang['inactif_28_shortcut'].""; - $Systemtatus = ""; - } elseif ($RowUserLevel < $CurrentPoints AND - $NoobProt['config_value'] == 1 AND - $NoobTime['config_value'] * 1000 > $RowUserPoints) { - $Systemtatus2 = "".$lang['weak_player_shortcut'].""; - $Systemtatus = ""; - } elseif ($RowUserPoints > $CurrentLevel AND - $NoobProt['config_value'] == 1 AND - $NoobTime['config_value'] * 1000 > $CurrentPoints) { - $Systemtatus2 = $lang['strong_player_shortcut']; - $Systemtatus = ""; - } else { - $Systemtatus2 = ""; - $Systemtatus = ""; - } - $Systemtatus4 = $User2Points['total_rank']; - if ($Systemtatus2 != '') { - $Systemtatus6 = "("; - $Systemtatus7 = ")"; - } - if ($Systemtatus2 == '') { - $Systemtatus6 = ""; - $Systemtatus7 = ""; - } - $admin = ""; - if ($GalaxyRowUser['authlevel'] == LEVEL_ADMIN) { - $admin = "A"; - } else if ($GalaxyRowUser['authlevel'] == LEVEL_OPERATOR) { - $admin = "O"; - } else if ($GalaxyRowUser['authlevel'] == LEVEL_MODERATOR) { - $admin = "M"; - } - $Systemtart = $User2Points['total_rank']; - if (strlen($Systemtart) < 3) { - $Systemtart = 1; - } else { - $Systemtart = (floor( $User2Points['total_rank'] / 100 ) * 100) + 1; - } - $Result .= ""; - $Result .= ""; - if ($GalaxyRowUser['id'] != $user['id']) { - $Result .= "".$lang['gl_sendmess'].""; - $Result .= ""; - $Result .= "".$lang['gl_buddyreq'].""; - $Result .= ""; - } - $Result .= "".$lang['gl_stats'].""; - $Result .= ""; - $Result .= "\""; - $Result .= ", STICKY, MOUSEOFF, DELAY, 750, CENTER, OFFSETX, -40, OFFSETY, -40 );'"; - $Result .= " onmouseout='return nd();'>"; - $Result .= $Systemtatus; - $Result .= $GalaxyRowUser["username"].""; - $Result .= $Systemtatus6; - $Result .= $Systemtatus; - $Result .= $Systemtatus2; - $Result .= $Systemtatus7." ".$admin; - $Result .= ""; - } - $Result .= ""; - - return $Result; -} - -?> \ No newline at end of file diff --git a/includes/functions/GetMaxConstructibleElements.php b/includes/functions/GetMaxConstructibleElements.php deleted file mode 100644 index 616b4d5..0000000 --- a/includes/functions/GetMaxConstructibleElements.php +++ /dev/null @@ -1,80 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -/** - * - * @deprecated - * @param unknown_type $Element - * @param unknown_type $Ressources - */ -function GetMaxConstructibleElements ($Element, $Ressources) { - global $pricelist; - // On test les 4 Type de ressource pour voir si au moins on sait en construire 1 - if ($pricelist[$Element]['metal'] != 0) { - $ResType_1_Needed = $pricelist[$Element]['metal']; - $Buildable = floor($Ressources["metal"] / $ResType_1_Needed); - $MaxElements = $Buildable; - } - - if ($pricelist[$Element]['crystal'] != 0) { - $ResType_2_Needed = $pricelist[$Element]['crystal']; - $Buildable = floor($Ressources["crystal"] / $ResType_2_Needed); - } - if (!isset($MaxElements)) { - $MaxElements = $Buildable; - } elseif ($MaxElements > $Buildable) { - $MaxElements = $Buildable; - } - - if ($pricelist[$Element]['deuterium'] != 0) { - $ResType_3_Needed = $pricelist[$Element]['deuterium']; - $Buildable = floor($Ressources["deuterium"] / $ResType_3_Needed); - } - if (!isset($MaxElements)) { - $MaxElements = $Buildable; - } elseif ($MaxElements > $Buildable) { - $MaxElements = $Buildable; - } - - if ($pricelist[$Element]['energy'] != 0) { - $ResType_4_Needed = $pricelist[$Element]['energy']; - $Buildable = floor($Ressources["energy_max"] / $ResType_4_Needed); - } - if ($Buildable < 1) { - $MaxElements = 0; - } - - return $MaxElements; -} -// Verion History -// - 1.0 Version initiale (creation) -// - 1.1 Correction bug ressources n�gatives ... -// - 1.2 Correction bug quand pas de m�tal -?> \ No newline at end of file diff --git a/includes/functions/GetRestPrice.php b/includes/functions/GetRestPrice.php deleted file mode 100644 index 1ab38df..0000000 --- a/includes/functions/GetRestPrice.php +++ /dev/null @@ -1,75 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -/** - * - * @deprecated - * @param unknown_type $user - * @param unknown_type $planet - * @param unknown_type $Element - * @param unknown_type $userfactor - */ -function GetRestPrice ($user, $planet, $Element, $userfactor = true) { - global $pricelist, $resource, $lang; - trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED); - - if ($userfactor) { - $level = ($planet[$resource[$Element]]) ? $planet[$resource[$Element]] : $user[$resource[$Element]]; - } - - $array = array( - 'metal' => $lang["Metal"], - 'crystal' => $lang["Crystal"], - 'deuterium' => $lang["Deuterium"], - 'energy_max' => $lang["Energy"] - ); - - $text = "
    ". $lang['Rest_ress'] .": "; - foreach ($array as $ResType => $ResTitle) { - if ($pricelist[$Element][$ResType] != 0) { - $text .= $ResTitle . ": "; - if ($userfactor) { - $cost = floor($pricelist[$Element][$ResType] * pow($pricelist[$Element]['factor'], $level)); - } else { - $cost = floor($pricelist[$Element][$ResType]); - } - if ($cost > $planet[$ResType]) { - $text .= "". pretty_number($planet[$ResType] - $cost) ." "; - } else { - $text .= "". pretty_number($planet[$ResType] - $cost) ." "; - } - } - } - $text .= ""; - - return $text; -} - -?> \ No newline at end of file diff --git a/includes/functions/IsElementBuyable.php b/includes/functions/IsElementBuyable.php deleted file mode 100644 index 4c90bcb..0000000 --- a/includes/functions/IsElementBuyable.php +++ /dev/null @@ -1,78 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -/** - * - * @deprecated - * @param unknown_type $CurrentUser - * @param unknown_type $CurrentPlanet - * @param unknown_type $Element - * @param unknown_type $Incremental - * @param unknown_type $ForDestroy - */ -function IsElementBuyable ($CurrentUser, $CurrentPlanet, $Element, $Incremental = true, $ForDestroy = false) { - global $pricelist, $resource; - trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED); - - if (IsVacationMode($CurrentUser)) { - return false; - } - - if ($Incremental) { - $level = ($CurrentPlanet[$resource[$Element]]) ? $CurrentPlanet[$resource[$Element]] : $CurrentUser[$resource[$Element]]; - } - - $array = array( - Legacies_Empire::RESOURCE_METAL, - Legacies_Empire::RESOURCE_CRISTAL, - Legacies_Empire::RESOURCE_DEUTERIUM, - 'energy_max' - ); - - $cost = array(); - foreach ($array as $ResType) { - if ($pricelist[$Element][$ResType] != 0) { - if ($Incremental) { - $cost[$ResType] = bcmul($pricelist[$Element][$ResType], bcpow($pricelist[$Element]['factor'], $level), 0); - } else { - $cost[$ResType] = $pricelist[$Element][$ResType]; - } - - if ($ForDestroy) { - $cost[$ResType] = bcdiv($cost[$ResType], 2, 0); - } - - if (bccomp($cost[$ResType], $CurrentPlanet[$ResType]) > 0) { - return false; - } - } - } - return true; -} diff --git a/includes/functions/IsTechnologieAccessible.php b/includes/functions/IsTechnologieAccessible.php deleted file mode 100644 index ddbb69b..0000000 --- a/includes/functions/IsTechnologieAccessible.php +++ /dev/null @@ -1,58 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -/** - * - * @deprecated - * @param unknown_type $user - * @param unknown_type $planet - * @param unknown_type $element - */ -function IsTechnologieAccessible($user, $planet, $element) -{ - trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED); - global $requirements, $resource; - - if (isset($requirements[$element])) { - $enabled = true; - foreach($requirements[$element] as $ReqElement => $EleLevel) { - if (@$user[$resource[$ReqElement]] && $user[$resource[$ReqElement]] >= $EleLevel) { - // break; - } elseif ($planet[$resource[$ReqElement]] && $planet[$resource[$ReqElement]] >= $EleLevel) { - $enabled = true; - } else { - return false; - } - } - return $enabled; - } else { - return true; - } -} \ No newline at end of file diff --git a/includes/functions/IsVacationMode.php b/includes/functions/IsVacationMode.php deleted file mode 100644 index cf87614..0000000 --- a/includes/functions/IsVacationMode.php +++ /dev/null @@ -1,59 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -/** - * - * @deprecated - * @param unknown_type $CurrentUser - */ - function IsVacationMode($CurrentUser){ - global $gameConfig; - trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED); - - if($CurrentUser['urlaubs_modus'] == 1){ - $query = doquery("SELECT * FROM {{table}} WHERE id_owner = '{$CurrentUser['id']}'", 'planets'); - while ($id = $query->fetch(PDO::FETCH_BOTH)){ - doquery("UPDATE {{table}} SET - metal_perhour = '".$gameConfig['metal_basic_income']."', - crystal_perhour = '".$gameConfig['crystal_basic_income']."', - deuterium_perhour = '".$gameConfig['deuterium_basic_income']."', - metal_mine_porcent = '0', - crystal_mine_porcent = '0', - deuterium_sintetizer_porcent = '0', - solar_plant_porcent = '0', - fusion_plant_porcent = '0', - solar_satelit_porcent = '0' - WHERE id = '{$id['id']}' AND `planet_type` = '1' ", 'planets'); - } - return true; - } - return false; - } - ?> diff --git a/includes/functions/MissionCaseAttack.php b/includes/functions/MissionCaseAttack.php deleted file mode 100644 index d696fe8..0000000 --- a/includes/functions/MissionCaseAttack.php +++ /dev/null @@ -1,464 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -/** - * @deprecated - * @param unknown_type $FleetRow - */ -function MissionCaseAttack($FleetRow) -{ - global $lang; - - $pricelist = Legacies_Empire_Model_Game_Prices::getSingleton(); - $resource = Legacies_Empire_Model_Game_FieldsAlias::getSingleton(); - $CombatCaps = Legacies_Empire_Model_Game_Combat::getSingleton(); - - if ($FleetRow['fleet_start_time'] <= time()) { - if ($FleetRow['fleet_mess'] == 0) { - if (!isset($CombatCaps[Legacies_Empire::ID_SHIP_LIGHT_TRANSPORT]['sd'])) { - message("" . $lang['sys_no_vars'] . "", $lang['sys_error'], "fleet.php", 2); - } -// refactored parts -// {{{ - $planetCollection = new Legacies_Core_Collection(array('planet' => 'planets'), 'Legacies_Empire_Model_Planet'); - $planetCollection - ->where('galaxy=:galaxy') - ->where('system=:system') - ->where('planet=:planet') - ->where('type=:type') - ->limit(1) - ->load(array( - 'galaxy' => $FleetRow['fleet_end_galaxy'], - 'system' => $FleetRow['fleet_end_system'], - 'planet' => $FleetRow['fleet_end_planet'], - 'planet_type' => $FleetRow['fleet_end_type'] - )) - ; - $TargetPlanet = $planetCollection->current(); - - /* - * Update planet resources and constructions - */ - Legacies::dispatchEvent('planet.update', array( - 'planet' => $TargetPlanet - )); - $TargetPlanet->save(); - - $TargetUser = $targetPlanet->getUser(); - $CurrentUser = Legacies_Empire_Model_User::factory($FleetRow['fleet_owner']); - - $TargetUserID = $TargetUser->getId(); - $CurrentUserID = $CurrentUser->getId(); - - $TargetTechno = array( - 'military_tech' => $TargetUser->getData('military_tech'), - 'defence_tech' => $TargetUser->getData('defence_tech'), - 'shield_tech' => $TargetUser->getData('shield_tech') - ); - - $CurrentTechno = array( - 'military_tech' => $CurrentUser->getData('military_tech'), - 'defence_tech' => $CurrentUser->getData('defence_tech'), - 'shield_tech' => $CurrentUser->getData('shield_tech') - ); -// }}} - for ($SetItem = 200; $SetItem < 500; $SetItem++) { - if ($TargetPlanet[$resource[$SetItem]] > 0) { - $TargetSet[$SetItem]['count'] = $TargetPlanet[$resource[$SetItem]]; - } - } - - $TheFleet = explode(";", $FleetRow['fleet_array']); - foreach($TheFleet as $a => $b) { - if ($b != '') { - $a = explode(",", $b); - $CurrentSet[$a[0]]['count'] = $a[1]; - } - } - - include_once($xnova_root_path . 'includes/ataki.' . PHPEXT); - // Calcul de la duree de traitement (initialisation) - $mtime = microtime(); - $mtime = explode(" ", $mtime); - $mtime = $mtime[1] + $mtime[0]; - $starttime = $mtime; - - $walka = walka($CurrentSet, $TargetSet, $CurrentTechno, $TargetTechno); - // Calcul de la duree de traitement (calcul) - $mtime = microtime(); - $mtime = explode(" ", $mtime); - $mtime = $mtime[1] + $mtime[0]; - $endtime = $mtime; - $totaltime = ($endtime - $starttime); - // Ce qu'il reste de l'attaquant - $CurrentSet = $walka["atakujacy"]; - // Ce qu'il reste de l'attaqué - $TargetSet = $walka["wrog"]; - // Le resultat de la bataille - $FleetResult = $walka["wygrana"]; - // Rapport long (rapport de bataille detaillé) - $dane_do_rw = $walka["dane_do_rw"]; - // Rapport court (cdr + unitées perdues) - $zlom = $walka["zlom"]; - - $FleetArray = ""; - $FleetAmount = 0; - $FleetStorage = 0; - foreach ($CurrentSet as $Ship => $Count) { - $FleetStorage += $pricelist[$Ship]["capacity"] * $Count['count']; - $FleetArray .= $Ship . "," . $Count['count'] . ";"; - $FleetAmount += $Count['count']; - } - // Au cas ou le p'tit rigolo qu'a envoyé la flotte y avait mis des ressources ... - $FleetStorage -= $FleetRow["fleet_resource_metal"]; - $FleetStorage -= $FleetRow["fleet_resource_crystal"]; - $FleetStorage -= $FleetRow["fleet_resource_deuterium"]; - - $TargetPlanetUpd = ""; - if (!is_null($TargetSet)) { - foreach($TargetSet as $Ship => $Count) { - $TargetPlanetUpd .= "`" . $resource[$Ship] . "` = '" . $Count['count'] . "', "; - } - } - // Determination des ressources pillées - $Mining['metal'] = 0; - $Mining['crystal'] = 0; - $Mining['deuter'] = 0; - if ($FleetResult == "a") { - if ($FleetStorage > 0) { - $metal = $TargetPlanet['metal'] / 2; - $crystal = $TargetPlanet['crystal'] / 2; - $deuter = $TargetPlanet["deuterium"] / 2; - if (($metal) > $FleetStorage / 3) { - $Mining['metal'] = $FleetStorage / 3; - $FleetStorage = $FleetStorage - $Mining['metal']; - } else { - $Mining['metal'] = $metal; - $FleetStorage = $FleetStorage - $Mining['metal']; - } - - if (($crystal) > $FleetStorage / 2) { - $Mining['crystal'] = $FleetStorage / 2; - $FleetStorage = $FleetStorage - $Mining['crystal']; - } else { - $Mining['crystal'] = $crystal; - $FleetStorage = $FleetStorage - $Mining['crystal']; - } - - if (($deuter) > $FleetStorage) { - $Mining['deuter'] = $FleetStorage; - $FleetStorage = $FleetStorage - $Mining['deuter']; - } else { - $Mining['deuter'] = $deuter; - $FleetStorage = $FleetStorage - $Mining['deuter']; - } - } - } - $Mining['metal'] = round($Mining['metal']); - $Mining['crystal'] = round($Mining['crystal']); - $Mining['deuter'] = round($Mining['deuter']); - // Mise a jour de l'enregistrement de la planete attaquée - $QryUpdateTarget = "UPDATE {{table}} SET "; - $QryUpdateTarget .= $TargetPlanetUpd; - $QryUpdateTarget .= "`metal` = `metal` - '" . $Mining['metal'] . "', "; - $QryUpdateTarget .= "`crystal` = `crystal` - '" . $Mining['crystal'] . "', "; - $QryUpdateTarget .= "`deuterium` = `deuterium` - '" . $Mining['deuter'] . "' "; - $QryUpdateTarget .= "WHERE "; - $QryUpdateTarget .= "`galaxy` = '" . $FleetRow['fleet_end_galaxy'] . "' AND "; - $QryUpdateTarget .= "`system` = '" . $FleetRow['fleet_end_system'] . "' AND "; - $QryUpdateTarget .= "`planet` = '" . $FleetRow['fleet_end_planet'] . "' AND "; - $QryUpdateTarget .= "`planet_type` = '" . $FleetRow['fleet_end_type'] . "' "; - $QryUpdateTarget .= "LIMIT 1;"; - doquery($QryUpdateTarget , 'planets'); - // Mise a jour du champ de ruine devant la planete attaquée - $QryUpdateGalaxy = "UPDATE {{table}} SET "; - $QryUpdateGalaxy .= "`metal` = `metal` + '" . $zlom['metal'] . "', "; - $QryUpdateGalaxy .= "`crystal` = `crystal` + '" . $zlom['crystal'] . "' "; - $QryUpdateGalaxy .= "WHERE "; - $QryUpdateGalaxy .= "`galaxy` = '" . $FleetRow['fleet_end_galaxy'] . "' AND "; - $QryUpdateGalaxy .= "`system` = '" . $FleetRow['fleet_end_system'] . "' AND "; - $QryUpdateGalaxy .= "`planet` = '" . $FleetRow['fleet_end_planet'] . "' "; - $QryUpdateGalaxy .= "LIMIT 1;"; - doquery($QryUpdateGalaxy , 'galaxy'); - // Là on va discuter le bout de gras pour voir s'il y a moyen d'avoir une Lune ! - $FleetDebris = $zlom['metal'] + $zlom['crystal']; - $StrAttackerUnits = sprintf ($lang['sys_attacker_lostunits'], pretty_number ($zlom["atakujacy"])); - $StrDefenderUnits = sprintf ($lang['sys_defender_lostunits'], pretty_number ($zlom["wrog"])); - $StrRuins = sprintf ($lang['sys_gcdrunits'], pretty_number ($zlom["metal"]), $lang['Metal'], pretty_number ($zlom['crystal']), $lang['Crystal']); - $DebrisField = $StrAttackerUnits . "
    " . $StrDefenderUnits . "
    " . $StrRuins; - $MoonChance = $FleetDebris / 100000; - if ($FleetDebris > 2000000) { - $MoonChance = 20; - } - if ($FleetDebris < 100000) { - $UserChance = 0; - $ChanceMoon = ""; - } elseif ($FleetDebris >= 100000) { - $UserChance = mt_rand(1, 100); - $ChanceMoon = sprintf ($lang['sys_moonproba'], $MoonChance); - } - - if (($UserChance > 0) and ($UserChance <= $MoonChance) and $galenemyrow['id_luna'] == 0) { - $TargetPlanetName = CreateOneMoonRecord ($FleetRow['fleet_end_galaxy'], $FleetRow['fleet_end_system'], $FleetRow['fleet_end_planet'], $TargetUserID, $FleetRow['fleet_start_time'], '', $MoonChance); - $GottenMoon = sprintf ($lang['sys_moonbuilt'], $TargetPlanetName, $FleetRow['fleet_end_galaxy'], $FleetRow['fleet_end_system'], $FleetRow['fleet_end_planet']); - } elseif ($UserChance = 0 or $UserChance > $MoonChance) { - $GottenMoon = ""; - } - - $AttackDate = date("r", $FleetRow["fleet_start_time"]); - $title = sprintf ($lang['sys_attack_title'], $AttackDate); - $raport = "
    " . $title . "
    "; - $zniszczony = false; - $a_zestrzelona = 0; - $AttackTechon['A'] = $CurrentTechno["military_tech"] * 10; - $AttackTechon['B'] = $CurrentTechno["defence_tech"] * 10; - $AttackTechon['C'] = $CurrentTechno["shield_tech"] * 10; - $AttackerData = sprintf ($lang['sys_attack_attacker_pos'], $CurrentUser["username"], $FleetRow['fleet_start_galaxy'], $FleetRow['fleet_start_system'], $FleetRow['fleet_start_planet']); - $AttackerTech = sprintf ($lang['sys_attack_techologies'], $AttackTechon['A'], $AttackTechon['B'], $AttackTechon['C']); - - $DefendTechon['A'] = $TargetTechno["military_tech"] * 10; - $DefendTechon['B'] = $TargetTechno["defence_tech"] * 10; - $DefendTechon['C'] = $TargetTechno["shield_tech"] * 10; - $DefenderData = sprintf ($lang['sys_attack_defender_pos'], $TargetUser["username"], $FleetRow['fleet_end_galaxy'], $FleetRow['fleet_end_system'], $FleetRow['fleet_end_planet']); - $DefenderTech = sprintf ($lang['sys_attack_techologies'], $DefendTechon['A'], $DefendTechon['B'], $DefendTechon['C']); - - foreach ($dane_do_rw as $a => $b) { - $raport .= "

    " . $AttackerData . "
    " . $AttackerTech . ""; - if ($b["atakujacy"]['count'] > 0) { - $raport1 = ""; - $raport2 = ""; - $raport3 = ""; - $raport4 = ""; - $raport5 = ""; - foreach ($b["atakujacy"] as $Ship => $Data) { - if (is_numeric($Ship)) { - if ($Data['count'] > 0) { - $raport1 .= ""; - $raport2 .= ""; - $raport3 .= ""; - $raport4 .= ""; - $raport5 .= ""; - } - } - } - $raport1 .= ""; - $raport2 .= ""; - $raport3 .= ""; - $raport4 .= ""; - $raport5 .= ""; - $raport .= $raport1 . $raport2 . $raport3 . $raport4 . $raport5; - } else { - if ($a == 2) { - $a_zestrzelona = 1; - } - $zniszczony = true; - $raport .= "
    " . $lang['sys_destroyed']; - } - - $raport .= "
    " . $lang['sys_ship_type'] . "
    " . $lang['sys_ship_count'] . "
    " . $lang['sys_ship_weapon'] . "
    " . $lang['sys_ship_shield'] . "
    " . $lang['sys_ship_armour'] . "" . $lang["tech_rc"][$Ship] . "" . pretty_number ($Data['count']) . "" . pretty_number (round($Data["atak"] / $Data['count'])) . "" . pretty_number (round($Data["tarcza"] / $Data['count'])) . "" . pretty_number (round($Data["obrona"] / $Data['count'])) . "
    "; - $raport .= "

    " . $DefenderData . "
    " . $DefenderTech . ""; - if ($b["wrog"]['count'] > 0) { - $raport1 = ""; - $raport2 = ""; - $raport3 = ""; - $raport4 = ""; - $raport5 = ""; - foreach ($b["wrog"] as $Ship => $Data) { - if (is_numeric($Ship)) { - if ($Data['count'] > 0) { - $raport1 .= ""; - $raport2 .= ""; - $raport3 .= ""; - $raport4 .= ""; - $raport5 .= ""; - } - } - } - $raport1 .= ""; - $raport2 .= ""; - $raport3 .= ""; - $raport4 .= ""; - $raport5 .= ""; - $raport .= $raport1 . $raport2 . $raport3 . $raport4 . $raport5; - } else { - $zniszczony = true; - $raport .= "
    " . $lang['sys_destroyed']; - } - $raport .= "
    " . $lang['sys_ship_type'] . "
    " . $lang['sys_ship_count'] . "
    " . $lang['sys_ship_weapon'] . "
    " . $lang['sys_ship_shield'] . "
    " . $lang['sys_ship_armour'] . "" . $lang["tech_rc"][$Ship] . "" . pretty_number ($Data['count']) . "" . pretty_number (round($Data["atak"] / $Data['count'])) . "" . pretty_number (round($Data["tarcza"] / $Data['count'])) . "" . pretty_number (round($Data["obrona"] / $Data['count'])) . "
    "; - - if (($zniszczony == false) and !($a == 8)) { - $AttackWaveStat = sprintf ($lang['sys_attack_attack_wave'], pretty_number (floor($b["atakujacy"]["atak"])), pretty_number (floor($b["wrog"]["tarcza"]))); - $DefendWavaStat = sprintf ($lang['sys_attack_defend_wave'], pretty_number (floor($b["wrog"]["atak"])), pretty_number (floor($b["atakujacy"]["tarcza"]))); - $raport .= "
    " . $AttackWaveStat . "
    " . $DefendWavaStat . "
    "; - } - } - switch ($FleetResult) { - case "a": - $Pillage = sprintf ($lang['sys_stealed_ressources'], pretty_number ($Mining['metal']), $lang['metal'], pretty_number ($Mining['crystal']), $lang['crystal'], pretty_number ($Mining['deuter']), $lang['Deuterium']); - $raport .= $lang['sys_attacker_won'] . "
    " . $Pillage . "
    "; - $raport .= $DebrisField . "
    "; - $raport .= $ChanceMoon . "
    "; - $raport .= $GottenMoon . "
    "; - break; - case "r": - $raport .= $lang['sys_both_won'] . "
    "; - $raport .= $DebrisField . "
    "; - $raport .= $ChanceMoon . "
    "; - $raport .= $GottenMoon . "
    "; - break; - case "w": - $raport .= $lang['sys_defender_won'] . "
    "; - $raport .= $DebrisField . "
    "; - $raport .= $ChanceMoon . "
    "; - $raport .= $GottenMoon . "
    "; - doquery("DELETE FROM {{table}} WHERE `fleet_id` = '" . $FleetRow["fleet_id"] . "';", 'fleets'); - break; - default: - break; - } - $SimMessage = sprintf ($lang['sys_rapport_build_time'], $totaltime); - $raport .= $SimMessage . "
    "; - - $rid = md5($raport); - $QryInsertRapport = "INSERT INTO {{table}} SET "; - $QryInsertRapport .= "`time` = UNIX_TIMESTAMP(), "; - $QryInsertRapport .= "`id_owner1` = '" . $FleetRow['fleet_owner'] . "', "; - $QryInsertRapport .= "`id_owner2` = '" . $TargetUserID . "', "; - $QryInsertRapport .= "`rid` = '" . $rid . "', "; - $QryInsertRapport .= "`a_zestrzelona` = '" . $a_zestrzelona . "', "; - $QryInsertRapport .= "`raport` = '" . addslashes ($raport) . "';"; - doquery($QryInsertRapport , 'rw'); - // Colorisation du résumé de rapport pour l'attaquant - $raport = ""; - $raport .= "
    "; - if ($FleetResult == "a") { - $raport .= ""; - } elseif ($FleetResult == "r") { - $raport .= ""; - } elseif ($FleetResult == "w") { - $raport .= ""; - } - $raport .= $lang['sys_mess_attack_report'] . " [" . $FleetRow['fleet_end_galaxy'] . ":" . $FleetRow['fleet_end_system'] . ":" . $FleetRow['fleet_end_planet'] . "]

    "; - $raport .= "" . $lang['sys_perte_attaquant'] . ": " . pretty_number ($zlom["atakujacy"]) . ""; - $raport .= " " . $lang['sys_perte_defenseur'] . ":" . pretty_number ($zlom["wrog"]) . "
    " ; - $raport .= $lang['sys_gain'] . " " . $lang['Metal'] . ":" . pretty_number ($Mining['metal']) . " " . $lang['Crystal'] . ":" . pretty_number ($Mining['crystal']) . " " . $lang['Deuterium'] . ":" . pretty_number ($Mining['deuter']) . "
    "; - $raport .= $lang['sys_debris'] . " " . $lang['Metal'] . ":" . pretty_number ($zlom['metal']) . " " . $lang['Crystal'] . ":" . pretty_number ($zlom['crystal']) . "
    "; - - $Mining['metal'] = $Mining['metal'] + $FleetRow["fleet_resource_metal"]; - $Mining['crystal'] = $Mining['crystal'] + $FleetRow["fleet_resource_crystal"]; - $Mining['deuter'] = $Mining['deuter'] + $FleetRow["fleet_resource_deuterium"]; - - $QryUpdateFleet = "UPDATE {{table}} SET "; - $QryUpdateFleet .= "`fleet_amount` = '" . $FleetAmount . "', "; - $QryUpdateFleet .= "`fleet_array` = '" . $FleetArray . "', "; - $QryUpdateFleet .= "`fleet_mess` = '1', "; - $QryUpdateFleet .= "`fleet_resource_metal` = '" . $Mining['metal'] . "', "; - $QryUpdateFleet .= "`fleet_resource_crystal` = '" . $Mining['crystal'] . "', "; - $QryUpdateFleet .= "`fleet_resource_deuterium` = '" . $Mining['deuter'] . "' "; - $QryUpdateFleet .= "WHERE fleet_id = '" . $FleetRow['fleet_id'] . "' "; - $QryUpdateFleet .= "LIMIT 1 ;"; - doquery($QryUpdateFleet , 'fleets'); - - SendSimpleMessage ($CurrentUserID, '', $FleetRow['fleet_start_time'], 3, $lang['sys_mess_tower'], $lang['sys_mess_attack_report'], $raport); - // Ajout du petit point raideur - $AddPoint = $CurrentUser['xpraid'] + 1; - - $QryUpdateOfficier = "UPDATE {{table}} SET "; - $QryUpdateOfficier .= "`xpraid` = '" . $AddPoint . "' "; - $QryUpdateOfficier .= "WHERE id = '" . $CurrentUserID . "' "; - $QryUpdateOfficier .= "LIMIT 1 ;"; - doquery($QryUpdateOfficier, 'users'); - // Ajout d'un point au compteur de raids - $RaidsTotal = $CurrentUser['raids'] + 1; - if ($FleetResult == "a") { - $RaidsWin = $CurrentUser['raidswin'] + 1; - $QryUpdateRaidsCompteur = "UPDATE {{table}} SET "; - $QryUpdateRaidsCompteur .= "`raidswin` ='" . $RaidsWin . "', "; - $QryUpdateRaidsCompteur .= "`raids` ='" . $RaidsTotal . "' "; - $QryUpdateRaidsCompteur .= "WHERE id = '" . $CurrentUserID . "' "; - $QryUpdateRaidsCompteur .= "LIMIT 1 ;"; - doquery($QryUpdateRaidsCompteur, 'users'); - } elseif ($FleetResult == "r" || $FleetResult == "w") { - $RaidsLoose = $CurrentUser['raidsloose'] + 1; - $QryUpdateRaidsCompteur = "UPDATE {{table}} SET "; - $QryUpdateRaidsCompteur .= "`raidswin` ='" . $RaidsLoose . "', "; - $QryUpdateRaidsCompteur .= "`raids` ='" . $RaidsTotal . "' "; - $QryUpdateRaidsCompteur .= "WHERE id = '" . $CurrentUserID . "' "; - $QryUpdateRaidsCompteur .= "LIMIT 1 ;"; - doquery($QryUpdateRaidsCompteur, 'users'); - } - // Colorisation du résumé de rapport pour l'attaquant - $raport2 = ""; - $raport2 .= "
    "; - if ($FleetResult == "a") { - $raport2 .= ""; - } elseif ($FleetResult == "r") { - $raport2 .= ""; - } elseif ($FleetResult == "w") { - $raport2 .= ""; - } - $raport2 .= $lang['sys_mess_attack_report'] . " [" . $FleetRow['fleet_end_galaxy'] . ":" . $FleetRow['fleet_end_system'] . ":" . $FleetRow['fleet_end_planet'] . "]

    "; - - SendSimpleMessage ($TargetUserID, '', $FleetRow['fleet_start_time'], 3, $lang['sys_mess_tower'], $lang['sys_mess_attack_report'], $raport2); - } - // Retour de flotte (s'il en reste) - $fquery = ""; - if ($FleetRow['fleet_end_time'] <= time()) { - if (!is_null($CurrentSet)) { - foreach($CurrentSet as $Ship => $Count) { - $fquery .= "`" . $resource[$Ship] . "` = `" . $resource[$Ship] . "` + '" . $Count['count'] . "', "; - } - } else { - $fleet = explode(";", $FleetRow['fleet_array']); - foreach($fleet as $a => $b) { - if ($b != '') { - $a = explode(",", $b); - $fquery .= "{$resource[$a[0]]}={$resource[$a[0]]} + {$a[1]}, \n"; - } - } - } - - doquery ("DELETE FROM {{table}} WHERE `fleet_id` = " . $FleetRow["fleet_id"], 'fleets'); - if (!($FleetResult == "w")) { - $QryUpdatePlanet = "UPDATE {{table}} SET "; - $QryUpdatePlanet .= $fquery; - $QryUpdatePlanet .= "`metal` = `metal` + " . $FleetRow['fleet_resource_metal'] . ", "; - $QryUpdatePlanet .= "`crystal` = `crystal` + " . $FleetRow['fleet_resource_crystal'] . ", "; - $QryUpdatePlanet .= "`deuterium` = `deuterium` + " . $FleetRow['fleet_resource_deuterium'] . " "; - $QryUpdatePlanet .= "WHERE "; - $QryUpdatePlanet .= "`galaxy` = " . $FleetRow['fleet_start_galaxy'] . " AND "; - $QryUpdatePlanet .= "`system` = " . $FleetRow['fleet_start_system'] . " AND "; - $QryUpdatePlanet .= "`planet` = " . $FleetRow['fleet_start_planet'] . " AND "; - $QryUpdatePlanet .= "`planet_type` = " . $FleetRow['fleet_start_type'] . " LIMIT 1 ;"; - doquery($QryUpdatePlanet, 'planets'); - } - } - } -} diff --git a/includes/functions/MissionCaseColonisation.php b/includes/functions/MissionCaseColonisation.php deleted file mode 100644 index de8145a..0000000 --- a/includes/functions/MissionCaseColonisation.php +++ /dev/null @@ -1,105 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -/** - * - * @deprecated - * @param unknown_type $FleetRow - */ -function MissionCaseColonisation ( $FleetRow ) { - global $lang, $resource; - - $iPlanetCount = mysql_result(doquery ("SELECT count(*) FROM {{table}} WHERE `id_owner` = '". $FleetRow['fleet_owner'] ."' AND `planet_type` = '1'", 'planets'), 0); - if ($FleetRow['fleet_mess'] == 0) { - // Déjà, sommes nous a l'aller ?? - $iGalaxyPlace = mysql_result(doquery ("SELECT count(*) FROM {{table}} WHERE `galaxy` = '". $FleetRow['fleet_end_galaxy']."' AND `system` = '". $FleetRow['fleet_end_system']."' AND `planet` = '". $FleetRow['fleet_end_planet']."';", 'galaxy'), 0); - $TargetAdress = sprintf ($lang['sys_adress_planet'], $FleetRow['fleet_end_galaxy'], $FleetRow['fleet_end_system'], $FleetRow['fleet_end_planet']); - if ($iGalaxyPlace == 0) { - // Y a personne qui s'y est mis avant que je ne debarque ! - if ($iPlanetCount >= MAX_PLAYER_PLANETS && $user['authlevel'] != LEVEL_ADMIN) { - $TheMessage = $lang['sys_colo_arrival'] . $TargetAdress . $lang['sys_colo_maxcolo'] . MAX_PLAYER_PLANETS . $lang['sys_colo_planet']; - SendSimpleMessage ( $FleetRow['fleet_owner'], '', $FleetRow['fleet_start_time'], 0, $lang['sys_colo_mess_from'], $lang['sys_colo_mess_report'], $TheMessage); - doquery("UPDATE {{table}} SET `fleet_mess` = '1' WHERE `fleet_id` = ". $FleetRow["fleet_id"], 'fleets'); - } else { - $NewOwnerPlanet = CreateOnePlanetRecord($FleetRow['fleet_end_galaxy'], $FleetRow['fleet_end_system'], $FleetRow['fleet_end_planet'], $FleetRow['fleet_owner'], $lang['sys_colo_defaultname'], false); - if ( $NewOwnerPlanet == true ) { - $TheMessage = $lang['sys_colo_arrival'] . $TargetAdress . $lang['sys_colo_allisok']; - SendSimpleMessage ( $FleetRow['fleet_owner'], '', $FleetRow['fleet_start_time'], 0, $lang['sys_colo_mess_from'], $lang['sys_colo_mess_report'], $TheMessage); - // Verifier ce que contient fleet_array (et le cas et cheant retirer un element '208' - if ($FleetRow['fleet_amount'] == 1) { - doquery("DELETE FROM {{table}} WHERE fleet_id=" . $FleetRow["fleet_id"], 'fleets'); - } else { - $CurrentFleet = explode(";", $FleetRow['fleet_array']); - $NewFleet = ""; - foreach ($CurrentFleet as $Item => $Group) { - if ($Group != '') { - $Class = explode (",", $Group); - if ($Class[0] == 208) { - if ($Class[1] > 1) { - $NewFleet .= $Class[0].",".($Class[1] - 1).";"; - } - } else { - if ($Class[1] <> 0) { - $NewFleet .= $Class[0].",".$Class[1].";"; - } - } - } - } - $QryUpdateFleet = "UPDATE {{table}} SET "; - $QryUpdateFleet .= "`fleet_array` = '". $NewFleet ."', "; - $QryUpdateFleet .= "`fleet_amount` = `fleet_amount` - 1, "; - $QryUpdateFleet .= "`fleet_mess` = '1' "; - $QryUpdateFleet .= "WHERE `fleet_id` = '". $FleetRow["fleet_id"] ."';"; - doquery( $QryUpdateFleet, 'fleets'); - } - } else { - $TheMessage = $lang['sys_colo_arrival'] . $TargetAdress . $lang['sys_colo_badpos']; - SendSimpleMessage ( $FleetRow['fleet_owner'], '', $FleetRow['fleet_start_time'], 0, $lang['sys_colo_mess_from'], $lang['sys_colo_mess_report'], $TheMessage); - doquery("UPDATE {{table}} SET `fleet_mess` = '1' WHERE `fleet_id` = ". $FleetRow["fleet_id"], 'fleets'); - } - } - } else { - // Pas de bol coiffé sur le poteau ! - $TheMessage = $lang['sys_colo_arrival'] . $TargetAdress . $lang['sys_colo_notfree']; - SendSimpleMessage ( $FleetRow['fleet_owner'], '', $FleetRow['fleet_end_time'], 0, $lang['sys_colo_mess_from'], $lang['sys_colo_mess_report'], $TheMessage); - // Mettre a jour la flotte pour qu'effectivement elle revienne ! - doquery("UPDATE {{table}} SET `fleet_mess` = '1' WHERE `fleet_id` = ". $FleetRow["fleet_id"], 'fleets'); - - } - } else { - if ($FleetRow['fleet_end_time'] <= time()) { - // Retour de flotte - RestoreFleetToPlanet ( $FleetRow, true ); - doquery("DELETE FROM {{table}} WHERE fleet_id=" . $FleetRow["fleet_id"], 'fleets'); - } - } -} - -?> \ No newline at end of file diff --git a/includes/functions/PlanetResourceUpdate.php b/includes/functions/PlanetResourceUpdate.php deleted file mode 100644 index a774ee3..0000000 --- a/includes/functions/PlanetResourceUpdate.php +++ /dev/null @@ -1,51 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -/** - * - * @deprecated - * @param array $CurrentUser - * @param array $CurrentPlanet - * @param int $UpdateTime - */ -function PlanetResourceUpdate($CurrentUser, &$CurrentPlanet, $UpdateTime) -{ - trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED); - $planet = Legacies_Empire_Model_User::factory($CurrentPlanet['id']); - - /* - * Update planet resources and constructions - */ - Legacies::dispatchEvent('planet.update', array( - 'planet' => $planet, - 'time' => $UpdateTime - )); - $planet->save(); -} diff --git a/includes/functions/ResetThisFuckingCheater.php b/includes/functions/ResetThisFuckingCheater.php deleted file mode 100644 index a849e15..0000000 --- a/includes/functions/ResetThisFuckingCheater.php +++ /dev/null @@ -1,78 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -/** - * - * @deprecated - * @param unknown_type $UserID - */ -function ResetThisFuckingCheater ( $UserID ) { - trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED); - $TheUser = doquery ("SELECT * FROM {{table}} WHERE `id` = '". $UserID ."';", 'users', true); - $UserPlanet = doquery ("SELECT `name` FROM {{table}} WHERE `id` = '". $TheUser['id_planet']."';", 'planets', true); - DeleteSelectedUser ( $UserID ); - if ($UserPlanet['name'] != "") { - // Creation de l'utilisateur - $QryInsertUser = "INSERT INTO {{table}} SET "; - $QryInsertUser .= "`id` = '". $TheUser['id'] ."', "; - $QryInsertUser .= "`username` = '". $TheUser['username'] ."', "; - $QryInsertUser .= "`email` = '". $TheUser['email'] ."', "; - $QryInsertUser .= "`email_2` = '". $TheUser['email_2'] ."', "; - $QryInsertUser .= "`sex` = '". $TheUser['sex'] ."', "; - $QryInsertUser .= "`id_planet` = '0', "; - $QryInsertUser .= "`authlevel` = '". $TheUser['authlevel'] ."', "; - $QryInsertUser .= "`dpath` = '". $TheUser['dpath'] ."', "; - $QryInsertUser .= "`galaxy` = '". $TheUser['galaxy'] ."', "; - $QryInsertUser .= "`system` = '". $TheUser['system'] ."', "; - $QryInsertUser .= "`planet` = '". $TheUser['planet'] ."', "; - $QryInsertUser .= "`register_time` = '". $TheUser['register_time'] ."', "; - $QryInsertUser .= "`password` = '". $TheUser['password'] ."';"; - doquery( $QryInsertUser, 'users'); - - // On cherche le numero d'enregistrement de l'utilisateur fraichement cr?? - $NewUser = doquery("SELECT `id` FROM {{table}} WHERE `username` = '". $TheUser['username'] ."' LIMIT 1;", 'users', true); - - CreateOnePlanetRecord ($TheUser['galaxy'], $TheUser['system'], $TheUser['planet'], $NewUser['id'], $UserPlanet['name'], true); - // Recherche de la reference de la nouvelle planete (qui est unique normalement ! - $PlanetID = doquery("SELECT `id` FROM {{table}} WHERE `id_owner` = '". $NewUser['id'] ."' LIMIT 1;", 'planets', true); - - // Mise a jour de l'enregistrement utilisateur avec les infos de sa planete mere - $QryUpdateUser = "UPDATE {{table}} SET "; - $QryUpdateUser .= "`id_planet` = '". $PlanetID['id'] ."', "; - $QryUpdateUser .= "`current_planet` = '". $PlanetID['id'] ."' "; - $QryUpdateUser .= "WHERE "; - $QryUpdateUser .= "`id` = '". $NewUser['id'] ."';"; - doquery( $QryUpdateUser, 'users'); - } - - return; -} - -?> \ No newline at end of file diff --git a/includes/functions/SendNewPassword.php b/includes/functions/SendNewPassword.php deleted file mode 100644 index a2de340..0000000 --- a/includes/functions/SendNewPassword.php +++ /dev/null @@ -1,92 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -/** - * - * @deprecated - * @param unknown_type $mail - */ - function sendnewpassword($mail){ - trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED); - - $ExistMail = doquery("SELECT `email` FROM {{table}} WHERE `email` = '". $mail ."' LIMIT 1;", 'users', true); - - if (empty($ExistMail['email'])) { - message('L\'adresse n\'existe pas !','Erreur'); - } - - else{ - //Caractere qui seront contenus dans le nouveau mot de passe - $Caracters="aazertyuiopqsdfghjklmwxcvbnAZERTYUIOPQSDFGHJKLMWXCVBN1234567890"; - - $Count=strlen($Caracters); - - $NewPass=""; - $Taille=6; - - - srand((double)microtime()*1000000); - - for($i=0;$i<$Taille;$i++){ - - $CaracterBoucle=rand(0,$Count-1); - - $NewPass=$NewPass.substr($Caracters,$CaracterBoucle,1); - } - - //Et un nouveau mot de passe tout chaud ^^ - - //On va maintenant l'envoyer au destinataire - $Title = "XNova : Nouveau mot de passe"; - $Body = "Voici votre nouveau mot de passe : "; - $Body .= $NewPass; - - mail($mail,$Title,$Body); - - //Email envoy�, maintenant place au changement dans la BDD - - $NewPassSql = md5($NewPass); - - $QryPassChange = "UPDATE {{table}} SET "; - $QryPassChange .= "`password` ='". $NewPassSql ."' "; - $QryPassChange .= "WHERE `email`='". $mail ."' LIMIT 1;"; - - doquery( $QryPassChange, 'users'); - - - } - - - - } - - - -?> \ No newline at end of file diff --git a/includes/functions/ShowGalaxyRows.php b/includes/functions/ShowGalaxyRows.php deleted file mode 100644 index 88734e4..0000000 --- a/includes/functions/ShowGalaxyRows.php +++ /dev/null @@ -1,102 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -/** - * - * @deprecated - * @param unknown_type $Galaxy - * @param unknown_type $System - */ -function ShowGalaxyRows ($Galaxy, $System) { - global $lang, $planetcount, $CurrentRC, $dpath, $user; - - $Result = ""; - for ($Planet = 1; $Planet <= MAX_PLANET_IN_SYSTEM; $Planet++) { - unset($GalaxyRowPlanet); - unset($GalaxyRowMoon); - unset($GalaxyRowPlayer); - unset($GalaxyRowAlly); - - $GalaxyRow = doquery("SELECT * FROM {{table}} WHERE `galaxy` = '".$Galaxy."' AND `system` = '".$System."' AND `planet` = '".$Planet."';", 'galaxy', true); - - $Result .= "\n"; - $Result .= ""; // Depart de ligne - if ($GalaxyRow) { - // Il existe des choses sur cette ligne de planete - if ($GalaxyRow["id_planet"] != 0) { - $GalaxyRowPlanet = doquery("SELECT * FROM {{table}} WHERE `id` = '". $GalaxyRow["id_planet"] ."';", 'planets', true); - - if ($GalaxyRowPlanet['destruyed'] != 0 AND - $GalaxyRowPlanet['id_owner'] != '' AND - $GalaxyRow["id_planet"] != '') { - CheckAbandonPlanetState ($GalaxyRowPlanet); - } else { - $planetcount++; - $GalaxyRowPlayer = doquery("SELECT * FROM {{table}} WHERE `id` = '". $GalaxyRowPlanet["id_owner"] ."';", 'users', true); - } - - if ($GalaxyRow["id_luna"] != 0) { - $GalaxyRowMoon = doquery("SELECT * FROM {{table}} WHERE `id` = '". $GalaxyRow["id_luna"] ."';", 'lunas', true); - if ($GalaxyRowMoon["destruyed"] != 0) { - CheckAbandonMoonState ($GalaxyRowMoon); - } - } - $GalaxyRowPlanet = doquery("SELECT * FROM {{table}} WHERE `id` = '". $GalaxyRow["id_planet"] ."';", 'planets', true); - if ($GalaxyRowPlanet['id_owner'] <> 0) { - $GalaxyRowUser = doquery("SELECT * FROM {{table}} WHERE `id` = '". $GalaxyRowPlanet['id_owner'] ."';", 'users', true); - } else { - $GalaxyRowUser = array(); - } - } - } - $Result .= "\n"; - $Result .= GalaxyRowPos ( $Planet, $GalaxyRow ); - $Result .= "\n"; - $Result .= GalaxyRowPlanet ( $GalaxyRow, $GalaxyRowPlanet, $GalaxyRowPlayer, $Galaxy, $System, $Planet, 1 ); - $Result .= "\n"; - $Result .= GalaxyRowPlanetName ( $GalaxyRow, $GalaxyRowPlanet, $GalaxyRowPlayer, $Galaxy, $System, $Planet, 1 ); - $Result .= "\n"; - $Result .= GalaxyRowMoon ( $GalaxyRow, $GalaxyRowMoon , $GalaxyRowPlayer, $Galaxy, $System, $Planet, 3 ); - $Result .= "\n"; - $Result .= GalaxyRowDebris ( $GalaxyRow, $GalaxyRowPlanet, $GalaxyRowPlayer, $Galaxy, $System, $Planet, 2 ); - $Result .= "\n"; - $Result .= GalaxyRowUser ( $GalaxyRow, $GalaxyRowPlanet, $GalaxyRowPlayer, $Galaxy, $System, $Planet, 0 ); - $Result .= "\n"; - $Result .= GalaxyRowAlly ( $GalaxyRow, $GalaxyRowPlanet, $GalaxyRowPlayer, $Galaxy, $System, $Planet, 0 ); - $Result .= "\n"; - $Result .= GalaxyRowActions ( $GalaxyRow, $GalaxyRowPlanet, $GalaxyRowPlayer, $Galaxy, $System, $Planet, 0 ); - $Result .= "\n"; - $Result .= ""; - } - - return $Result; -} - -?> \ No newline at end of file diff --git a/includes/functions/SortUserPlanets.php b/includes/functions/SortUserPlanets.php deleted file mode 100644 index a8ee9ca..0000000 --- a/includes/functions/SortUserPlanets.php +++ /dev/null @@ -1,52 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -/** - * - * @deprecated - * @param unknown_type $CurrentUser - */ -function SortUserPlanets ( $CurrentUser ) { - $Order = ( $CurrentUser['planet_sort_order'] == 1 ) ? "DESC" : "ASC" ; - $Sort = $CurrentUser['planet_sort']; - - $QryPlanets = "SELECT `id`, `name`, `galaxy`, `system`, `planet`, `planet_type` FROM {{table}} WHERE `id_owner` = '". $CurrentUser['id'] ."' ORDER BY "; - if ( $Sort == 0 ) { - $QryPlanets .= "`id` ". $Order; - } elseif ( $Sort == 1 ) { - $QryPlanets .= "`galaxy`, `system`, `planet`, `planet_type` ". $Order; - } elseif ( $Sort == 2 ) { - $QryPlanets .= "`name` ". $Order; - } - $Planets = doquery ( $QryPlanets, 'planets'); - - return $Planets; -} -?> \ No newline at end of file diff --git a/includes/functions/UpdatePlanetBatimentQueueList.php b/includes/functions/UpdatePlanetBatimentQueueList.php deleted file mode 100644 index 44b651e..0000000 --- a/includes/functions/UpdatePlanetBatimentQueueList.php +++ /dev/null @@ -1,62 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -/** - * - * @deprecated - * @param unknown_type $CurrentPlanet - * @param unknown_type $CurrentUser - */ -function UpdatePlanetBatimentQueueList ( &$CurrentPlanet, &$CurrentUser ) { - trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED); - $RetValue = false; - if ( $CurrentPlanet['b_building_id'] != 0 ) { - while ( $CurrentPlanet['b_building_id'] != 0 ) { - if ( $CurrentPlanet['b_building'] <= time() ) { - PlanetResourceUpdate ( $CurrentUser, $CurrentPlanet, $CurrentPlanet['b_building'], false ); - $IsDone = CheckPlanetBuildingQueue( $CurrentPlanet, $CurrentUser ); - if ( $IsDone == true ) { - SetNextQueueElementOnTop ( $CurrentPlanet, $CurrentUser ); - } - } else { - $RetValue = true; - break; - } - } - } - return $RetValue; -} - -// Revision History -// - 1.0 Mise en module initiale -// - 1.1 Mise a jour des ressources sur la planete verifi�e (pour prendre en compte les ressources produites -// pendant la construction et avant l'evolution evantuel d'une mine ou d'en batiment - -?> \ No newline at end of file diff --git a/includes/migrateinfo.php b/includes/migrateinfo.php deleted file mode 100644 index 416d2d7..0000000 --- a/includes/migrateinfo.php +++ /dev/null @@ -1,157 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -$QryMigrate = array( -"ALTER TABLE `{{prefix}}fleets` ADD COLUMN `fleet_end_stay` int(11) NOT NULL default '0';", -"ALTER TABLE `{{prefix}}fleets` ADD COLUMN `fleet_target_owner` int(11) NOT NULL default '0';", -"ALTER TABLE `{{prefix}}fleets` ADD COLUMN `fleet_group` int (11) NOT NULL DEFAULT '0';", - -"ALTER TABLE `{{prefix}}messages` MODIFY `message_from` varchar(48) character set latin1 default NULL;", -"ALTER TABLE `{{prefix}}messages` MODIFY `message_subject` varchar(48) character set latin1 default NULL;", - -"ALTER TABLE `{{prefix}}users` ADD COLUMN `mnl_buildlist` INT (11) NOT NULL;", -"ALTER TABLE `{{prefix}}users` ADD COLUMN `expedition_tech` int(11) NOT NULL default '0';", -"ALTER TABLE `{{prefix}}users` ADD COLUMN `mnl_expedition` INT( 11 ) NOT NULL;", -"ALTER TABLE `{{prefix}}users` ADD COLUMN `rpg_geologue` int(11) NOT NULL default '0';", -"ALTER TABLE `{{prefix}}users` ADD COLUMN `rpg_amiral` int(11) NOT NULL default '0';", -"ALTER TABLE `{{prefix}}users` ADD COLUMN `rpg_ingenieur` int(11) NOT NULL default '0';", -"ALTER TABLE `{{prefix}}users` ADD COLUMN `rpg_technocrate` int(11) NOT NULL default '0';", -"ALTER TABLE `{{prefix}}users` ADD COLUMN `rpg_espion` int(11) NOT NULL default '0';", -"ALTER TABLE `{{prefix}}users` ADD COLUMN `rpg_constructeur` int(11) NOT NULL default '0';", -"ALTER TABLE `{{prefix}}users` ADD COLUMN `rpg_scientifique` int(11) NOT NULL default '0';", -"ALTER TABLE `{{prefix}}users` ADD COLUMN `rpg_commandant` int(11) NOT NULL default '0';", -"ALTER TABLE `{{prefix}}users` ADD COLUMN `rpg_stockeur` int(11) NOT NULL default '0';", -"ALTER TABLE `{{prefix}}users` ADD COLUMN `rpg_defenseur` int(11) NOT NULL default '0';", -"ALTER TABLE `{{prefix}}users` ADD COLUMN `rpg_destructeur` int(11) NOT NULL default '0';", -"ALTER TABLE `{{prefix}}users` ADD COLUMN `rpg_general` int(11) NOT NULL default '0';", -"ALTER TABLE `{{prefix}}users` ADD COLUMN `rpg_bunker` int(11) NOT NULL default '0';", -"ALTER TABLE `{{prefix}}users` ADD COLUMN `rpg_raideur` int(11) NOT NULL default '0';", -"ALTER TABLE `{{prefix}}users` ADD COLUMN `rpg_empereur` int(11) NOT NULL default '0';", -"ALTER TABLE `{{prefix}}users` ADD COLUMN `rpg_points` int(11) NOT NULL default '0';", -"ALTER TABLE `{{prefix}}users` ADD COLUMN `lvl_minier` int(11) NOT NULL default '1';", -"ALTER TABLE `{{prefix}}users` ADD COLUMN `lvl_raid` int(11) NOT NULL default '1';", -"ALTER TABLE `{{prefix}}users` ADD COLUMN `xpraid` int(11) NOT NULL default '0';", -"ALTER TABLE `{{prefix}}users` ADD COLUMN `xpminier` int(11) NOT NULL default '0';", -"ALTER TABLE `{{prefix}}users` ADD COLUMN `banaday` int(11) default NULL;", -"ALTER TABLE `{{prefix}}users` ADD COLUMN `user_agent` text character set latin1 NOT NULL;", -"ALTER TABLE `{{prefix}}users` MODIFY `lang` varchar(8) character set latin1 NOT NULL default 'fr';", - -"CREATE TABLE `{{prefix}}annonce` ( -`id` int(11) NOT NULL auto_increment, -`user` text collate latin1_general_ci NOT NULL, -`galaxie` int(11) NOT NULL, -`systeme` int(11) NOT NULL, -`metala` bigint(11) NOT NULL, -`cristala` bigint(11) NOT NULL, -`deuta` bigint(11) NOT NULL, -`metals` bigint(11) NOT NULL, -`cristals` bigint(11) NOT NULL, -`deuts` bigint(11) NOT NULL, -PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german1_ci AUTO_INCREMENT=5;", - -"ALTER TABLE `{{prefix}}planets` ADD COLUMN `last_jump_time` int(11) NOT NULL default '0';", -"ALTER TABLE `{{prefix}}planets` ADD COLUMN `id_level` int(11) default NULL;", -"ALTER TABLE `{{prefix}}planets` MODIFY `b_building_id` text character set latin1 NOT NULL;", - -"CREATE TABLE `{{prefix}}statpoints` ( -`id_owner` int(11) NOT NULL, -`id_ally` int(11) NOT NULL, -`stat_type` int(2) NOT NULL, -`stat_code` int(11) NOT NULL, -`tech_rank` int(11) NOT NULL, -`tech_old_rank` int(11) NOT NULL, -`tech_points` bigint(20) NOT NULL, -`tech_count` int(11) NOT NULL, -`build_rank` int(11) NOT NULL, -`build_old_rank` int(11) NOT NULL, -`build_points` bigint(20) NOT NULL, -`build_count` int(11) NOT NULL, -`defs_rank` int(11) NOT NULL, -`defs_old_rank` int(11) NOT NULL, -`defs_points` bigint(20) NOT NULL, -`defs_count` int(11) NOT NULL, -`fleet_rank` int(11) NOT NULL, -`fleet_old_rank` int(11) NOT NULL, -`fleet_points` bigint(20) NOT NULL, -`fleet_count` int(11) NOT NULL, -`total_rank` int(11) NOT NULL, -`total_old_rank` int(11) NOT NULL, -`total_points` bigint(20) NOT NULL, -`total_count` int(11) NOT NULL, -`stat_date` int(11) NOT NULL, -KEY `TECH` (`tech_points`), -KEY `BUILDS` (`build_points`), -KEY `DEFS` (`defs_points`), -KEY `FLEET` (`fleet_points`), -KEY `TOTAL` (`total_points`) -) ENGINE=MyISAM;", - -"CREATE TABLE `{{prefix}}chat` ( -`messageid` int(5) unsigned NOT NULL auto_increment, -`user` varchar(255) NOT NULL default '', -`message` text NOT NULL, -`timestamp` int(11) NOT NULL default '0', -PRIMARY KEY (`messageid`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8;", - -"INSERT INTO `{{prefix}}config` (`config_name`, `config_value`) VALUES -('Fleet_Cdr', '30'), -('Defs_Cdr', '30'), -('game_disable', '0'), -('close_reason', ''), -('BuildLabWhileRun', '0'), -('LastSettedGalaxyPos', '1'), -('LastSettedSystemPos', '9'), -('LastSettedPlanetPos', '1'), -('urlaubs_modus_erz', '1'), -('forum_url', 'http://board.xnova-ng.org/'), -('OverviewNewsFrame', '1'), -('OverviewNewsText', 'Vous avez correctement mis votre serveur UGamela sous XNova!'), -('OverviewExternChat', '0'), -('OverviewExternChatCmd', ''), -('OverviewBanner', '0'), -('OverviewClickBanner', ''), -('ExtCopyFrame', '0'), -('ExtCopyOwner', ''), -('ExtCopyFunct', ''), -('ForumBannerFrame', '0');", -"UPDATE `{{prefix}}config` SET `config_value`='XNova' WHERE `config_name`='COOKIE_NAME';", -"UPDATE `{{prefix}}config` SET `config_value`='XNova' WHERE `config_name`='game_name';", - -"CREATE TABLE `{{prefix}}multi` ( -`id` int(11) NOT NULL auto_increment, -`player` bigint(11) unsigned NOT NULL default '0', -`sharer` bigint(11) unsigned NOT NULL default '0', -`reason` text character set latin1 NOT NULL, -PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8;"); - -?> \ No newline at end of file diff --git a/includes/todofleetcontrol.php b/includes/todofleetcontrol.php deleted file mode 100644 index 87634bd..0000000 --- a/includes/todofleetcontrol.php +++ /dev/null @@ -1,117 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -require_once ROOT_PATH . 'includes/deprecated.php'; - -/** - * @deprecated - * {{{ - */ -include(ROOT_PATH . 'includes/functions/FlyingFleetHandler.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/MissionCaseAttack.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/MissionCaseStay.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/MissionCaseStayAlly.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/MissionCaseTransport.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/MissionCaseSpy.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/MissionCaseRecycling.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/MissionCaseDestruction.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/MissionCaseColonisation.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/MissionCaseExpedition.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/SendSimpleMessage.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/SpyTarget.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/RestoreFleetToPlanet.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/StoreGoodsToPlanet.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/CheckPlanetBuildingQueue.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/CheckPlanetUsedFields.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/CreateOneMoonRecord.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/CreateOnePlanetRecord.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/InsertJavaScriptChronoApplet.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/IsTechnologieAccessible.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/GetBuildingTime.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/GetBuildingTimeLevel.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/GetRestPrice.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/GetElementPrice.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/GetBuildingPrice.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/IsElementBuyable.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/CheckCookies.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/ChekUser.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/InsertGalaxyScripts.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/GalaxyCheckFunctions.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/ShowGalaxyRows.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/GetPhalanxRange.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/GetMissileRange.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/GalaxyRowPos.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/GalaxyRowPlanet.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/GalaxyRowPlanetName.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/GalaxyRowMoon.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/GalaxyRowDebris.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/GalaxyRowUser.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/GalaxyRowAlly.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/GalaxyRowActions.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/ShowGalaxySelector.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/ShowGalaxyMISelector.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/ShowGalaxyTitles.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/GalaxyLegendPopup.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/ShowGalaxyFooter.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/GetMaxConstructibleElements.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/GetElementRessources.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/ElementBuildListBox.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/ElementBuildListQueue.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/FleetBuildingPage.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/DefensesBuildingPage.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/ResearchBuildingPage.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/BatimentBuildingPage.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/CheckLabSettingsInQueue.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/InsertBuildListScript.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/AddBuildingToQueue.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/ShowBuildingQueue.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/HandleTechnologieBuild.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/BuildingSavePlanetRecord.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/BuildingSaveUserRecord.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/RemoveBuildingFromQueue.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/CancelBuildingFromQueue.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/SetNextQueueElementOnTop.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/ShowTopNavigationBar.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/SetSelectedPlanet.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/MessageForm.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/BuildFlyingFleetTable.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/SendNewPassword.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/UpdatePlanetBatimentQueueList.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/IsOfficierAccessible.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/CheckInputStrings.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/MipCombatEngine.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/DeleteSelectedUser.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/SortUserPlanets.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/BuildFleetEventTable.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/ResetThisFuckingCheater.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/IsVacationMode.'.PHPEXT); -/** - * }}} - */ \ No newline at end of file diff --git a/install/index.php b/install/index.php deleted file mode 100644 index 2fa9c2d..0000000 --- a/install/index.php +++ /dev/null @@ -1,356 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -define('INSIDE' , true); -define('INSTALL', false); -define('IN_INSTALL', true); - -define('ROOT_PATH', dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR); -define('PHPEXT', include ROOT_PATH . 'extension.inc'); - -define('DEFAULT_SKINPATH', '../skins/xnova/'); -define('TEMPLATE_DIR', realpath(ROOT_PATH . '/templates/')); -define('TEMPLATE_NAME', 'OpenGame'); -define('DEFAULT_LANG', 'fr'); -$dpath = DEFAULT_SKINPATH; - -include(ROOT_PATH . 'includes/debug.class.'.PHPEXT); -$debug = new debug(); - -include(ROOT_PATH . 'includes/constants.' . PHPEXT); -include(ROOT_PATH . 'includes/functions.' . PHPEXT); -include(ROOT_PATH . 'includes/unlocalised.' . PHPEXT); -include(ROOT_PATH . 'includes/todofleetcontrol.' . PHPEXT); -include(ROOT_PATH . 'language/' . DEFAULT_LANG . '/lang_info.cfg'); -include(ROOT_PATH . 'includes/vars.' . PHPEXT); -include(ROOT_PATH . 'includes/db.' . PHPEXT); -include(ROOT_PATH . 'includes/strings.' . PHPEXT); - -include(ROOT_PATH . 'includes/databaseinfos.php'); -include(ROOT_PATH . 'includes/migrateinfo.php'); - -$mode = isset($_GET['mode']) ? strval($_GET['mode']) : 'intro'; -$page = isset($_GET['page']) ? intval($_GET['page']) : 1; -$nextPage = $page + 1; - -$mainTpl = gettemplate('install/ins_body'); -includeLang('install/install'); - -switch ($mode) { - case 'intro': - $subTpl = gettemplate('install/ins_intro'); - $bloc = $lang; - $bloc['dpath'] = $dpath; - $frame = parsetemplate($subTpl, $bloc); - break; - - case 'ins': - if ($page == 1) { - if (isset($_GET['error']) && intval($_GET['error']) == 1) { - adminMessage ($lang['ins_error1'], $lang['ins_error']); - } - elseif (isset($_GET['error']) && intval($_GET['error']) == 2) { - adminMessage ($lang['ins_error2'], $lang['ins_error']); - } - - $subTpl = gettemplate('install/ins_form'); - $bloc = $lang; - $bloc['dpath'] = $dpath; - $frame = parsetemplate($subTpl, $bloc); - } else if ($page == 2) { - $host = $_POST['host']; - $user = $_POST['user']; - $pass = $_POST['passwort']; - $prefix = $_POST['prefix']; - $db = $_POST['db']; - - $connection = @mysql_connect($host, $user, $pass); - if (!$connection) { - header("Location: ?mode=ins&page=1&error=1"); - exit(); - } - - $dbselect = @mysql_select_db($db); - if (!$dbselect) { - header("Location: ?mode=ins&page=1&error=1"); - exit(); - } - - $dz = fopen("../config.php", "w"); - if (!$dz) { - header("Location: ?mode=ins&page=1&error=2"); - exit(); - } - $fileData =<< array( - 'database' => array( - 'engine' => 'mysql', - 'options' => array( - 'hostname' => '{$host}', - 'username' => '{$user}', - 'password' => '{$pass}', - 'database' => '{$db}' - ), - 'table_prefix' => '{$prefix}', - ) - ) - ); -EOF; - fwrite($dz, $fileData); - fclose($dz); - - doquery ( $QryTableAks , 'aks' ); - doquery ( $QryTableAnnonce , 'annonce' ); - doquery ( $QryTableAlliance , 'alliance' ); - doquery ( $QryTableBanned , 'banned' ); - doquery ( $QryTableBuddy , 'buddy' ); - doquery ( $QryTableChat , 'chat' ); - doquery ( $QryTableConfig , 'config' ); - doquery ( $QryInsertConfig , 'config' ); - doquery ( $QryTabledeclared , 'declared' ); - doquery ( $QryTableErrors , 'errors' ); - doquery ( $QryTableFleets , 'fleets' ); - doquery ( $QryTableGalaxy , 'galaxy' ); - doquery ( $QryTableIraks , 'iraks' ); - doquery ( $QryTableLunas , 'lunas' ); - doquery ( $QryTableMessages , 'messages' ); - doquery ( $QryTableNotes , 'notes' ); - doquery ( $QryTablePlanets , 'planets' ); - doquery ( $QryTableRw , 'rw' ); - doquery ( $QryTableStatPoints , 'statpoints' ); - doquery ( $QryTableUsers , 'users' ); - doquery ( $QryTableMulti , 'multi' ); - - $subTpl = gettemplate ('install/ins_form_done'); - $bloc = $lang; - $bloc['dpath'] = $dpath; - $frame = parsetemplate ( $subTpl, $bloc ); - } elseif ($page == 3) { - if (isset($_GET['error']) && intval($_GET['error']) == 3) { - adminMessage($lang['ins_error3'], $lang['ins_error']); - } - - $subTpl = gettemplate ('install/ins_acc'); - $bloc = $lang; - $bloc['dpath'] = $dpath; - $frame = parsetemplate ( $subTpl, $bloc ); - } elseif ($page == 4) { - $adm_user = $_POST['adm_user']; - $adm_pass = $_POST['adm_pass']; - $adm_email = $_POST['adm_email']; - $adm_planet = $_POST['adm_planet']; - $adm_sex = $_POST['adm_sex']; - $md5pass = md5($adm_pass); - - if (!isset($_POST['adm_user'])) { - header("Location: ?mode=ins&page=3&error=3"); - exit(); - } - if (!isset($_POST['adm_pass'])) { - header("Location: ?mode=ins&page=3&error=3"); - exit(); - } - if (!isset($_POST['adm_email'])) { - header("Location: ?mode=ins&page=3&error=3"); - exit(); - } - if (!isset($_POST['adm_planet'])) { - header("Location: ?mode=ins&page=3&error=3"); - exit(); - } - - $config = include(ROOT_PATH . 'config.php'); - $db_host = $config['global']['database']['options']['hostname']; - $db_user = $config['global']['database']['options']['username']; - $db_pass = $config['global']['database']['options']['password']; - $db_db = $config['global']['database']['options']['database']; - $db_prefix = $config['global']['database']['table_prefix']; - - $connection = @mysql_connect($db_host, $db_user, $db_pass); - if (!$connection) { - header("Location: ?mode=ins&page=1&error=1"); - exit(); - } - - $dbselect = @mysql_select_db($db_db); - if (!$dbselect) { - header("Location: ?mode=ins&page=1&error=1"); - exit(); - } - - $QryInsertAdm = "INSERT INTO {{table}} SET "; - $QryInsertAdm .= "`id` = '1', "; - $QryInsertAdm .= "`username` = '". $adm_user ."', "; - $QryInsertAdm .= "`email` = '". $adm_email ."', "; - $QryInsertAdm .= "`email_2` = '". $adm_email ."', "; - $QryInsertAdm .= "`authlevel` = '3', "; - $QryInsertAdm .= "`sex` = '". $adm_sex ."', "; - $QryInsertAdm .= "`id_planet` = '1', "; - $QryInsertAdm .= "`galaxy` = '1', "; - $QryInsertAdm .= "`system` = '1', "; - $QryInsertAdm .= "`planet` = '1', "; - $QryInsertAdm .= "`current_planet` = '1', "; - $QryInsertAdm .= "`register_time` = '". time() ."', "; - $QryInsertAdm .= "`password` = '". $md5pass ."';"; - doquery($QryInsertAdm, 'users'); - - $QryAddAdmPlt = "INSERT INTO {{table}} SET "; - $QryAddAdmPlt .= "`name` = '". $adm_planet ."', "; - $QryAddAdmPlt .= "`id_owner` = '1', "; - $QryAddAdmPlt .= "`galaxy` = '1', "; - $QryAddAdmPlt .= "`system` = '1', "; - $QryAddAdmPlt .= "`planet` = '1', "; - $QryAddAdmPlt .= "`last_update` = '". time() ."', "; - $QryAddAdmPlt .= "`planet_type` = '1', "; - $QryAddAdmPlt .= "`image` = 'normaltempplanet02', "; - $QryAddAdmPlt .= "`diameter` = '12750', "; - $QryAddAdmPlt .= "`field_max` = '163', "; - $QryAddAdmPlt .= "`temp_min` = '47', "; - $QryAddAdmPlt .= "`temp_max` = '87', "; - $QryAddAdmPlt .= "`metal` = '500', "; - $QryAddAdmPlt .= "`metal_perhour` = '0', "; - $QryAddAdmPlt .= "`metal_max` = '1000000', "; - $QryAddAdmPlt .= "`crystal` = '500', "; - $QryAddAdmPlt .= "`crystal_perhour` = '0', "; - $QryAddAdmPlt .= "`crystal_max` = '1000000', "; - $QryAddAdmPlt .= "`deuterium` = '500', "; - $QryAddAdmPlt .= "`deuterium_perhour` = '0', "; - $QryAddAdmPlt .= "`deuterium_max` = '1000000';"; - doquery($QryAddAdmPlt, 'planets'); - - $QryAddAdmGlx = "INSERT INTO {{table}} SET "; - $QryAddAdmGlx .= "`galaxy` = '1', "; - $QryAddAdmGlx .= "`system` = '1', "; - $QryAddAdmGlx .= "`planet` = '1', "; - $QryAddAdmGlx .= "`id_planet` = '1'; "; - doquery($QryAddAdmGlx, 'galaxy'); - - doquery("UPDATE {{table}} SET `config_value` = '1' WHERE `config_name` = 'LastSettedGalaxyPos';", 'config'); - doquery("UPDATE {{table}} SET `config_value` = '1' WHERE `config_name` = 'LastSettedSystemPos';", 'config'); - doquery("UPDATE {{table}} SET `config_value` = '1' WHERE `config_name` = 'LastSettedPlanetPos';", 'config'); - doquery("UPDATE {{table}} SET `config_value` = `config_value` + '1' WHERE `config_name` = 'users_amount' LIMIT 1;", 'config'); - - $subTpl = gettemplate ('install/ins_acc_done'); - $bloc = $lang; - $bloc['dpath'] = $dpath; - $frame = parsetemplate ( $subTpl, $bloc ); - } - break; - - case 'goto': - if ($page == 1) { - $subTpl = gettemplate ('install/ins_goto_intro'); - $bloc = $lang; - $bloc['dpath'] = $dpath; - $frame = parsetemplate ( $subTpl, $bloc ); - } elseif ($page == 2) { - if ($_GET['error'] == 1) { - adminMessage ($lang['ins_error1'], $lang['ins_error']); - } - elseif ($_GET['error'] == 2) { - adminMessage ($lang['ins_error2'], $lang['ins_error']); - } - - $subTpl = gettemplate ('install/ins_goto_form'); - $bloc = $lang; - $bloc['dpath'] = $dpath; - $frame = parsetemplate ( $subTpl, $bloc ); - } elseif ($page == 3) { - $host = $_POST['host']; - $user = $_POST['user']; - $pass = $_POST['passwort']; - $prefix = $_POST['prefix']; - $db = $_POST['db']; - - if (!mysql_connect($host, $user, $pass)) { - header("Location: ?mode=goto&page=2&error=1"); - exit(); - } - - if (!mysql_select_db($db)) { - header("Location: ?mode=goto&page=2&error=1"); - exit(); - } - - $dz = fopen("../config.php", "w"); - if (!$dz) { - header("Location: ?mode=ins&page=1&error=2"); - exit(); - } - - $fileData =<< array( - 'database' => array( - 'engine' => 'mysql', - 'options' => array( - 'hostname' => '{$host}', - 'username' => '{$user}', - 'password' => '{$pass}', - 'database' => '{$db}' - ), - 'table_prefix' => '{$prefix}', - ) - ) - ); -EOF; - fwrite($dz, $fileData); - fclose($dz); - - foreach ($QryMigrate as $query) { - doquery($query, $prefix); - } - - $subTpl = gettemplate('install/ins_goto_done'); - $bloc = $lang; - $bloc['dpath'] = $dpath; - $frame = parsetemplate($subTpl, $bloc); - } - break; - - case 'bye': - header("Location: ../"); - break; - - default: - header('Location: ?mode=intro'); - die(); -} - - -$parse = $lang; -$parse['ins_state'] = $page; -$parse['ins_page'] = $frame; -$parse['dis_ins_btn'] = "?mode=$mode&page=$nextPage"; -$parse['dpath'] = $dpath; -$data = parsetemplate($mainTpl, $parse); - -display($data, "Installeur", false, '', true); diff --git a/language/en/admin/banned.mo b/language/en/admin/banned.mo deleted file mode 100644 index 2b4388c..0000000 --- a/language/en/admin/banned.mo +++ /dev/null @@ -1,18 +0,0 @@ - \ No newline at end of file diff --git a/language/en/admin/server.mo b/language/en/admin/server.mo deleted file mode 100644 index ee4e5fa..0000000 --- a/language/en/admin/server.mo +++ /dev/null @@ -1,7 +0,0 @@ - diff --git a/language/en/announce.mo b/language/en/announce.mo deleted file mode 100644 index ab1983a..0000000 --- a/language/en/announce.mo +++ /dev/null @@ -1,23 +0,0 @@ - diff --git a/language/en/supp.mo b/language/en/supp.mo deleted file mode 100644 index d267938..0000000 --- a/language/en/supp.mo +++ /dev/null @@ -1,22 +0,0 @@ - diff --git a/leftmenu.php b/leftmenu.php deleted file mode 100644 index c2aa459..0000000 --- a/leftmenu.php +++ /dev/null @@ -1,111 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -define('INSIDE' , true); -define('INSTALL' , false); -require_once dirname(__FILE__) .'/common.php'; - -function ShowLeftMenu ( $Level , $Template = 'left_menu') { - global $lang, $user, $dpath, $gameConfig; - - includeLang('leftmenu'); - - $MenuTPL = gettemplate( $Template ); - $InfoTPL = gettemplate( 'serv_infos' ); - $parse = $lang; - $parse['lm_tx_serv'] = $gameConfig['resource_multiplier']; - $parse['lm_tx_game'] = $gameConfig['game_speed'] / 2500; - $parse['lm_tx_fleet'] = $gameConfig['fleet_speed'] / 2500; - $parse['lm_tx_queue'] = MAX_FLEET_OR_DEFS_PER_ROW; - $SubFrame = parsetemplate( $InfoTPL, $parse ); - $parse['server_info'] = $SubFrame; - $parse['XNovaRelease'] = VERSION; - $parse['dpath'] = $dpath; - $parse['forum_url'] = $gameConfig['forum_url']; - $parse['mf'] = "Hauptframe"; - $rank = doquery("SELECT `total_rank` FROM {{table}} WHERE `stat_code` = '1' AND `stat_type` = '1' AND `id_owner` = '". $user['id'] ."';",'statpoints',true); - $parse['user_rank'] = $rank['total_rank']; - if ($Level > 0) { - $parse['ADMIN_LINK'] = " - - - "; - } else { - $parse['ADMIN_LINK'] = ""; - } - //Lien suppl�mentaire d�termin� dans le panel admin - if ($gameConfig['link_enable'] == 1) { - $parse['added_link'] = " - - - "; - } else { - $parse['added_link'] = ""; - } - - //Maintenant on v�rifie si les annonces sont activ�es ou non - if ($gameConfig['enable_announces'] == 1) { - $parse['announce_link'] = " - - - "; - } else { - $parse['announce_link'] = ""; - } - - //Maintenant le marchand - if ($gameConfig['enable_marchand'] == 1) { - $parse['marchand_link'] = " - "; - } else { - $parse['marchand_link'] = ""; - } - //Maintenant les notes - if ($gameConfig['enable_notes'] == 1) { - $parse['notes_link'] = " - - - "; - } else { - $parse['notes_link'] = ""; - } - $parse['servername'] = $gameConfig['game_name']; - $Menu = parsetemplate( $MenuTPL, $parse); - - return $Menu; -} - $Menu = ShowLeftMenu ( $user['authlevel'] ); - display ( $Menu, "Menu", '', false ); - -// ----------------------------------------------------------------------------------------------------------- -// History version -// 1.0 - Passage en fonction pour XNova version future -// 1.1 - Modification pour gestion Admin / Game OP / Modo -?> diff --git a/login.php b/login.php deleted file mode 100644 index cda7f2e..0000000 --- a/login.php +++ /dev/null @@ -1,82 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -define('INSIDE', true); -define('INSTALL', false); -define('DISABLE_IDENTITY_CHECK', true); -require_once dirname(__FILE__) . '/common.php'; - -includeLang('login'); - -if (!empty($_POST) && isset($_POST['username']) && isset($_POST['password'])) { - $user = Legacies_Empire_Model_User::login($_POST['username'], $_POST['password'], isset($_POST['rememberme']) && !empty($_POST['rememberme'])); - - $session = Legacies::getSession(Legacies_Empire_Model_User::SESSION_KEY); - if ($user !== null && $user->getId()) { - header("Location: frames.php"); - } else { - header("Location: login.php"); - } - Legacies_Core_ErrorProfiler::unregister(true); - exit(0); -} - -$db = Legacies_Database::getSingleton(); -$displayedPlayerLevels = implode(',', array( - //LEVEL_ADMIN, - LEVEL_OPERATOR, - LEVEL_MODERATOR, - LEVEL_PLAYER - )); -$userCountStatement = $db->prepare("SELECT COUNT(DISTINCT user.id) AS `user_count` FROM {$db->getTable('users')} AS user WHERE user.authlevel IN({$displayedPlayerLevels})"); -$userCountStatement->execute(); -$userCount = $userCountStatement->fetch(Legacies_Database::FETCH_COLUMN, 0); - -$latestPlayerStatement = $db->prepare("SELECT user.username AS `latest_player` FROM {$db->getTable('users')} AS user WHERE user.authlevel IN({$displayedPlayerLevels}) ORDER BY user.`register_time` DESC LIMIT 1"); -$latestPlayerStatement->execute(); -$latestPlayer = $latestPlayerStatement->fetch(Legacies_Database::FETCH_COLUMN, 0); - -$onlinePlayersStatement = $db->prepare("SELECT COUNT(DISTINCT user.id) AS `online_players` FROM {$db->getTable('users')} AS user WHERE user.authlevel IN({$displayedPlayerLevels}) AND user.`onlinetime` > (UNIX_TIMESTAMP() - 900)"); -$onlinePlayersStatement->execute(); -$onlinePlayers = $onlinePlayersStatement->fetch(Legacies_Database::FETCH_COLUMN, 0); - -$layout = new Legacies_Core_Layout(); -$layout->load('login'); -$block = $layout->getBlock('login'); - -$block['user_count'] = $userCount; -$block['latest_player'] = $latestPlayer; -$block['online_players'] = $onlinePlayers; - -$block['server_name'] = $gameConfig['game_name']; -$block['board_url'] = $gameConfig['forum_url']; - -echo $layout->render(); - diff --git a/logout.php b/logout.php deleted file mode 100644 index b0edf1a..0000000 --- a/logout.php +++ /dev/null @@ -1,39 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -define('INSIDE' , true); -define('INSTALL' , false); -require_once dirname(__FILE__) . '/common.php'; - -includeLang('logout'); - -Legacies_Empire_Model_User::getSingleton()->logout(); - -message($lang['see_you'], $lang['session_closed'], 'login.php'); diff --git a/officier.php b/officier.php deleted file mode 100644 index f80a6ec..0000000 --- a/officier.php +++ /dev/null @@ -1,118 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -define('INSIDE' , true); -define('INSTALL' , false); -require_once dirname(__FILE__) .'/common.php'; - -function ShowOfficierPage ( &$CurrentUser ) { - global $lang, $resource, $reslist, $_GET; - - includeLang('officier'); - - // Vérification que le joueur n'a pas un nombre de points négatif - if ($CurrentUser['rpg_points'] < 0) { - doquery("UPDATE {{table}} SET `rpg_points` = '0' WHERE `id` = '". $CurrentUser['id'] ."';", 'users'); - } - - // Si recrutement d'un officier - if ($_GET['mode'] == 2) { - if ($CurrentUser['rpg_points'] > 0) { - $Selected = $_GET['offi']; - if ( in_array($Selected, $reslist['officier']) ) { - $Result = IsOfficierAccessible ( $CurrentUser, $Selected ); - if ( $Result == 1 ) { - $CurrentUser[$resource[$Selected]] += 1; - $CurrentUser['rpg_points'] -= 1; - if ($Selected == 610) { - $CurrentUser['spy_tech'] += 5; - } elseif ($Selected == 611) { - $CurrentUser['computer_tech'] += 3; - } - - $QryUpdateUser = "UPDATE {{table}} SET "; - $QryUpdateUser .= "`rpg_points` = '". $CurrentUser['rpg_points'] ."', "; - $QryUpdateUser .= "`spy_tech` = '". $CurrentUser['spy_tech'] ."', "; - $QryUpdateUser .= "`computer_tech` = '". $CurrentUser['computer_tech'] ."', "; - $QryUpdateUser .= "`".$resource[$Selected]."` = '". $CurrentUser[$resource[$Selected]] ."' "; - $QryUpdateUser .= "WHERE "; - $QryUpdateUser .= "`id` = '". $CurrentUser['id'] ."';"; - doquery( $QryUpdateUser, 'users' ); - $Message = $lang['OffiRecrute']; - } elseif ( $Result == -1 ) { - $Message = $lang['Maxlvl']; - } elseif ( $Result == 0 ) { - $Message = $lang['Noob']; - } - } - } else { - $Message = $lang['NoPoints']; - } - $MessTPL = gettemplate('message_body'); - $parse['title'] = $lang['Officier']; - $parse['mes'] = $Message; - - $page = parsetemplate( $MessTPL, $parse); - } else { - // Pas de recrutement d'officier - $PageTPL = gettemplate('officier_body'); - $RowsTPL = gettemplate('officier_rows'); - $parse['off_points'] = $lang['off_points']; - $parse['alv_points'] = $CurrentUser['rpg_points']; - $parse['disp_off_tbl'] = ""; - for ( $Officier = 601; $Officier <= 615; $Officier++ ) { - $Result = IsOfficierAccessible ( $CurrentUser, $Officier ); - if ( $Result != 0 ) { - $bloc['off_id'] = $Officier; - $bloc['off_tx_lvl'] = $lang['off_tx_lvl']; - $bloc['off_lvl'] = $CurrentUser[$resource[$Officier]]; - $bloc['off_desc'] = $lang['Desc'][$Officier]; - if ($Result == 1) { - $bloc['off_link'] = "". $lang['link'][$Officier].""; - } else { - $bloc['off_link'] = $lang['Maxlvl']; - } - $parse['disp_off_tbl'] .= parsetemplate( $RowsTPL, $bloc ); - } - } - $page = parsetemplate( $PageTPL, $parse); - } - - return $page; -} - - $page = ShowOfficierPage ( $user ); - display($page, $lang['officier']); - -// ----------------------------------------------------------------------------------------------------------- -// History version -// 1.0 - Version originelle (Tom1991) -// 1.1 - Réécriture Chlorel pour integration complete dans XNova -?> \ No newline at end of file diff --git a/overview.php b/overview.php deleted file mode 100644 index db3e6ff..0000000 --- a/overview.php +++ /dev/null @@ -1,365 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -define('INSTALL' , false); -require_once dirname(__FILE__) .'/common.php'; - -$user = Legacies_Empire_Model_User::getSingleton(); -$planet = $user->getCurrentPlanet(); -$moon = $planet->getMoon(); - -$action = isset($_GET['action']) ? $_GET['action'] : null; - -if (isset($_POST) && !empty($_POST)) { - $action = isset($_POST['action']) && !empty($_POST['action']) ? $_POST['action'] : $action; - $formKey = isset($_POST['form_key']) && !empty($_POST['form_key']) ? $_POST['form_key'] : null; - - if ($formKey == Legacies::getSession('security')->getData('form_key')) { - if ($action == 'rename' && isset($_POST['name']) && !empty($_POST['name'])) { - $planet->setData('name', $_POST['name'])->save(); - - header('302 Found'); - header('Location: ' . basename(__FILE__)); - exit(0); - } else if ($action == 'destroy' && isset($_POST['password']) && !empty($_POST['password']) && isset($_POST['confirm'])) { - if (!$user->checkPassword($_POST['password'])) { - Legacies::getSession('user') - ->addError(Legacies::__('Password was not correct.')); - - header('302 Found'); - header('Location: ' . basename(__FILE__)); - exit(0); - } - - try { - $user->getCurrentPlanet()->destroy(); - - Legacies::getSession('user') - ->addSucces(Legacies::__('Planet has been successfully destroyed.')); - } catch (Legacies_Empire_Model_Planet_Exception $e) { - Legacies::getSession('user') - ->addError($e->getMessage()); - } - - header('302 Found'); - header('Location: ' . basename(__FILE__)); - exit(0); - } - } else { - Legacies::getSession('user') - ->addError(Legacies::__('Invalid security key.')); - } -} else if ($action == 'rename') { - $layout = new Legacies_Core_Layout(); - $layout->load('overview.rename-planet'); - - echo $layout->render(); - exit(0); -} else if ($action == 'destroy') { - $layout = new Legacies_Core_Layout(); - $layout->load('overview.destroy-planet'); - - echo $layout->render(); - exit(0); -} else { - includeLang('resources'); - includeLang('overview'); - - if ($user->getId()) { - $planetCollection = $user->getPlanetCollection(); - $planetBlock = new Legacies_Core_Block_Template(); - $planetBlock->setTemplate('empire/overview/planet/view.phtml'); - - $planetList = new Legacies_Core_Block_Concat(); - $planetBlock->planetList = $planetList; - - foreach ($planetCollection as $userPlanet) { - if ($userPlanet->getId() == $planet->getId()) { - continue; - } - - /* - * Update planet resources and constructions - */ - Legacies::dispatchEvent('planet.update', array( - 'planet' => $userPlanet - )); - $userPlanet->save(); - - if ($userPlanet->getId() != $user->getCurrentPlanet()->getId() && $userPlanet->isPlanet()) { - $block = new Legacies_Core_Block_Template(); - $block->setTemplate('empire/overview/planet/list/item.phtml'); - $block['planet'] = $userPlanet; - - $buildingQueue = $userPlanet->getBuildingQueue(); - $buildingQueue->rewind(); - $currentItem = $buildingQueue->current(); - $block['queue_item'] = $currentItem; - } - } - - /** - * Missile attack management - * Refactoring needed - * {{{ - */ - $iraks_query = doquery("SELECT * FROM {{table}} WHERE owner = '" . $user['id'] . "'", 'iraks'); - $Record = 4000; - while ($irak = $iraks_query->fetch(PDO::FETCH_ASSOC)) { - $Record++; - $fpage[$irak['zeit']] = ''; - - if ($irak['zeit'] > time()) { - $time = $irak['zeit'] - time(); - - $fpage[$irak['zeit']] .= InsertJavaScriptChronoApplet ("fm", $Record, $time, true); - - $planet_start = doquery("SELECT * FROM {{table}} WHERE - galaxy = '" . $irak['galaxy'] . "' AND - system = '" . $irak['system'] . "' AND - planet = '" . $irak['planet'] . "' AND - planet_type = '1'", 'planets'); - - $user_planet = doquery("SELECT * FROM {{table}} WHERE - galaxy = '" . $irak['galaxy_angreifer'] . "' AND - system = '" . $irak['system_angreifer'] . "' AND - planet = '" . $irak['planet_angreifer'] . "' AND - planet_type = '1'", 'planets', true); - - if (mysql_num_rows($planet_start) == 1) { - $planet = mysql_fetch_array($planet_start); - } - - $fpage[$irak['zeit']] .= "
    " . gmdate("H:i:s", $irak['zeit'] + 1 * 60 * 60) . " Une attaque de missiles (" . $irak['anzahl'] . ") de " . $user_planet['name'] . " "; - $fpage[$irak['zeit']] .= '
    [' . $irak["galaxy_angreifer"] . ':' . $irak["system_angreifer"] . ':' . $irak["planet_angreifer"] . ']'; - $fpage[$irak['zeit']] .= ' arrive sur la planète' . $planet["name"] . ' '; - $fpage[$irak['zeit']] .= '[' . $irak["galaxy"] . ':' . $irak["system"] . ':' . $irak["planet"] . ']'; - $fpage[$irak['zeit']] .= ''; - $fpage[$irak['zeit']] .= InsertJavaScriptChronoApplet ("fm", $Record, $time, false); - $fpage[$irak['zeit']] .= ""; - } - } - /** - * }}} - */ - - /* - * Update fleet list - */ - Legacies::dispatchEvent('fleet.update', array( - 'user' => $user - )); - - $fleetList = new Legacies_Core_Block_Concat(); - $fleetCollection = $user->getFleetCollection(); - foreach ($fleetCollection as $fleet) { - $block = new Legacies_Core_Block_Template(); - $block->setTemplate('empire/overview/fleets/item.phtml'); - - $block['class'] = $fleet->getRowClass(); - $block['fleet'] = $fleet; - - $fleetList->setPartial(uniqid(), $block); - } - - $messageCollection = new Legacies_Core_Collection('messages'); - $messageCollection->where('message_owner=:user'); - $messageCollection->where('message_read_at<=0'); - - $count = $messageCollection->getSize(array('user' => $user->getId())); - $newMessages = new Legacies_Core_View(); - $newMessages->setTemplate('empire/overview/messages.phtml'); - $newMessages['count'] = (int) $count; - - /** Gestion des officiers - * Update miner and raider level - * - */ - $Xp_Next_Level_Miner = $user->getData('lvl_minier') * 5000; - $Xp_Next_Level_Raider = $user->getData('lvl_raid') * 10; - $Xp_Miner = $user->getData('xpminier'); - $Xp_Raider = $user->getData('xpraid'); - if ($Xp_Miner >= $Xp_Next_Level_Miner) { - $HaveNewLevelMineur = ""; - $HaveNewLevelMineur .= "" . $lang['Have_new_level_mineur'] . ""; - $user->setData('lvl_minier', $user->getData('lvl_minier') + 1); - $user->setData('rpg_points', $user->getData('rpg_points')+1); - $user->save(); - } - if ($Xp_Raider >= $Xp_Next_Level_Raider) { - $HaveNewLevelRaider = ""; - $HaveNewLevelRaider .= "". $lang['Have_new_level_raid'] . ""; - $user->setData('lvl_raid', $user->getData('lvl_raid') + 1); - $user->setData('rpg_points', $user->getData('rpg_points') +1); - $user->save(); - } - - /** - * Page display - * Refactoring needed - * {{{ - */ - // ----------------------------------------------------------------------------------------------- - $parse = $lang; - // ----------------------------------------------------------------------------------------------- - // News Frame ... - // External Chat Frame ... - // Banner ADS Google (meme si je suis contre cela) - if ($gameConfig['OverviewNewsFrame'] == '1') { - $parse['NewsFrame'] = "" . $lang['ov_news_title'] . "" . stripslashes($gameConfig['OverviewNewsText']) . ""; - } - if ($gameConfig['OverviewExternChat'] == '1') { - $parse['ExternalTchatFrame'] = "" . stripslashes($gameConfig['OverviewExternChatCmd']) . ""; - } - if ($gameConfig['OverviewClickBanner'] != '') { - $parse['ClickBanner'] = stripslashes($gameConfig['OverviewClickBanner']); - } - if ($gameConfig['ForumBannerFrame'] == '1') { - - $BannerURL = "scripts/createbanner.php?id=".$user['id'].""; - - $parse['bannerframe'] = "
    ".$lang['InfoBanner']."
    "; - } - // --- Gestion de l'affichage d'une lune --------------------------------------------------------- - if ($moon['id'] <> 0) { - if ($planet['planet_type'] == 1) { - $lune = doquery ("SELECT * FROM {{table}} WHERE `galaxy` = '" . $planet['galaxy'] . "' AND `system` = '" . $planet['system'] . "' AND `planet` = '" . $planet['planet'] . "' AND `planet_type` = '3'", 'planets', true); - $parse['moon_img'] = ""; - $parse['moon'] = $lune['name']; - } else { - $parse['moon_img'] = ""; - $parse['moon'] = ""; - } - } else { - $parse['moon_img'] = ""; - $parse['moon'] = ""; - } - // Moon END - $parse['planet_name'] = $planet['name']; - $parse['planet_diameter'] = Math::render($planet['diameter']); - $parse['planet_field_current'] = Math::render($planet->getUsedFields()); - $parse['planet_field_max'] = Math::render($planet->getBuildingFields()); - $parse['planet_temp_min'] = $planet['temp_min']; - $parse['planet_temp_max'] = $planet['temp_max']; - $parse['galaxy_galaxy'] = $planet['galaxy']; - $parse['galaxy_planet'] = $planet['planet']; - $parse['galaxy_system'] = $planet['system']; - $StatRecord = doquery("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '" . $user['id'] . "';", 'statpoints', true); - - $parse['user_points'] = Math::render($StatRecord['build_points']); - $parse['user_fleet'] = Math::render($StatRecord['fleet_points']); - $parse['player_points_tech'] = Math::render($StatRecord['tech_points']); - $parse['total_points'] = Math::render($StatRecord['total_points']);; - - $parse['user_rank'] = $StatRecord['total_rank']; - $ile = $StatRecord['total_old_rank'] - $StatRecord['total_rank']; - if ($ile >= 1) { - $parse['ile'] = "+" . $ile . ""; - } elseif ($ile < 0) { - $parse['ile'] = "-" . $ile . ""; - } elseif ($ile == 0) { - $parse['ile'] = "" . $ile . ""; - } - $parse['u_user_rank'] = $StatRecord['total_rank']; - $parse['user_username'] = $user['username']; - - $parse['fleet_list'] = $fleetList->render(); - $parse['energy_used'] = $planet["energy_max"] - $planet["energy_used"]; - - $parse['Have_new_message'] = $newMessages->render(); - $parse['time'] = "
    "; - $parse['planet_image'] = $planet['image']; - $parse['anothers_planets'] = $planetBlock->render(); - $parse['max_users'] = $gameConfig['users_amount']; - - $galaxyData = $planet->getGalaxyData(); - $parse['metal_debris'] = Math::render($galaxyData['metal']); - $parse['crystal_debris'] = Math::render($galaxyData['crystal']); - if (($galaxyData['metal'] != 0 || $galaxyData['crystal'] != 0) && Math::isPositive($planet->getElement(Legacies_Empire::ID_SHIP_RECYCLER))) { - $parse['get_link'] = " (" . $lang['type_mission'][Legacies_Empire::ID_MISSION_RECYCLE] . ")"; - } else { - $parse['get_link'] = ''; - } - - $query = doquery('SELECT username FROM {{table}} ORDER BY register_time DESC', 'users', true); - $parse['last_user'] = $query['username']; - $query = doquery("SELECT COUNT(DISTINCT(id)) FROM {{table}} WHERE onlinetime>" . (time()-900), 'users', true); - $parse['online_users'] = $query[0]; - // $count = doquery(","users",true); - $parse['users_amount'] = $gameConfig['users_amount']; - - // Rajout d'une barre pourcentage - // Calcul du pourcentage de remplissage - // Barre de remplissage - $size = Math::floor(Math::div($planet->getUsedFields(), $planet->getBuildingFields()) * 100); - // Couleur de la barre de remplissage - $parse['case_pourcentage'] = $size . $lang['o/o']; - if (Math::comp($size, 100) > 0) { - $size = 100; - $parse['case_barre_barcolor'] = '#C00000'; - } elseif (Math::comp($size, 80) > 0) { - $parse['case_barre_barcolor'] = '#C0C000'; - } else { - $parse['case_barre_barcolor'] = '#00C000'; - } - $parse['case_barre'] = $size; - - // Mode Améliorations - $parse['xpminier'] = $user['xpminier']; - $parse['xpraid'] = $user['xpraid']; - $parse['lvl_minier'] = $user['lvl_minier']; - $parse['lvl_raid'] = $user['lvl_raid']; - - $LvlMinier = $user['lvl_minier']; - $LvlRaid = $user['lvl_raid']; - - $parse['lvl_up_minier'] = $LvlMinier * 5000; - $parse['lvl_up_raid'] = $LvlRaid * 10; - // Nombre de raids, pertes, etc ... - $parse['Raids'] = $lang['Raids']; - $parse['NumberOfRaids'] = $lang['NumberOfRaids']; - $parse['RaidsWin'] = $lang['RaidsWin']; - $parse['RaidsLoose'] = $lang['RaidsLoose']; - - $parse['raids'] = $user['raids']; - $parse['raidswin'] = $user['raidswin']; - $parse['raidsloose'] = $user['raidsloose']; - // Compteur de Membres en ligne - $OnlineUsers = doquery("SELECT COUNT(*) FROM {{table}} WHERE onlinetime>='" . (time()-15 * 60) . "'", 'users', 'true'); - $parse['NumberMembersOnline'] = $OnlineUsers[0]; - - $page = parsetemplate(gettemplate('overview_body'), $parse); - - display($page); - /** - * }}} - */ - } -} \ No newline at end of file diff --git a/reg.php b/reg.php deleted file mode 100644 index 6070fc9..0000000 --- a/reg.php +++ /dev/null @@ -1,107 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -define('INSIDE', true); -define('INSTALL', false); -define('DISABLE_IDENTITY_CHECK', true); -require_once dirname(__FILE__) .'/common.php'; - -includeLang('reg'); - -if (!empty($_POST) && isset($_POST['username']) && isset($_POST['planet_name']) && isset($_POST['email']) && isset($_POST['email_confirm']) && isset($_POST['password']) && isset($_POST['password_confirm'])) { - $session = Legacies::getSession(Legacies_Empire_Model_User::SESSION_KEY); - if ($_POST['password'] !== $_POST['password_confirm']) { - $session->addError('Password and password confirmation does not match.'); - } - if ($_POST['email'] !== $_POST['email_confirm']) { - $session->addError('Email and email confirmation does not match.'); - } - - $user = null; - if (true || count($session->getMessages(false)) === 0) { - $user = Legacies_Empire_Model_User::register($_POST['username'], $_POST['email'], $_POST['password']); - - $user->getHomePlanet()->setName($_POST['planet_name'])->save(); - } - - if ($user !== null && $user->getId()) { - header("HTTP/1.1 302 Found"); - header("Location: welcome.php"); - } else { - header("HTTP/1.1 302 Found"); - header("Location: reg.php"); - } - Legacies_Core_ErrorProfiler::unregister(true); - exit(0); -} - -$layout = new Legacies_Core_Layout(); -$layout->load('registration'); -$block = $layout->getBlock('registration'); - -echo $layout->render(); -/* -function sendpassemail($emailaddress, $password) -{ - global $lang; - - $parse['gameurl'] = GAMEURL; - $parse['password'] = $password; - $email = parsetemplate($lang['mail_welcome'], $parse); - $status = mymail($emailaddress, $lang['mail_title'], $email); - return $status; -} - -function mymail($to, $title, $body, $from = '') -{ - $from = trim($from); - - if (!$from) { - $from = ADMINEMAIL; - } - - $rp = ADMINEMAIL; - - $head = ''; - $head .= "Content-Type: text/plain \r\n"; - $head .= "Date: " . date('r') . " \r\n"; - $head .= "Return-Path: $rp \r\n"; - $head .= "From: $from \r\n"; - $head .= "Sender: $from \r\n"; - $head .= "Reply-To: $from \r\n"; - $head .= "Organization: $org \r\n"; - $head .= "X-Sender: $from \r\n"; - $head .= "X-Priority: 3 \r\n"; - $body = str_replace("\r\n", "\n", $body); - $body = str_replace("\n", "\r\n", $body); - - return mail($to, $title, $body, $head); -} -*/ diff --git a/resources.php b/resources.php deleted file mode 100644 index 6f6241b..0000000 --- a/resources.php +++ /dev/null @@ -1,278 +0,0 @@ - - * All rights reserved. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License - * along with this program. If not, see . - * - * --> 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 XNova. - * - */ - -define('INSIDE' , true); -define('INSTALL' , false); -require_once dirname(__FILE__) .'/common.php'; - - -function BuildRessourcePage ( $CurrentUser, $CurrentPlanet ) { - global $lang, $ProdGrid, $resource, $reslist, $gameConfig, $_POST; - - includeLang('resources'); - - $RessBodyTPL = gettemplate('resources'); - $RessRowTPL = gettemplate('resources_row'); - - // Si c'est une lune ... pas de ressources produites - if ($CurrentPlanet['planet_type'] == 3) { - $gameConfig['metal_basic_income'] = 0; - $gameConfig['crystal_basic_income'] = 0; - $gameConfig['deuterium_basic_income'] = 0; - } - - $ValidList['percent'] = array ( 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 ); - $SubQry = ""; - if ($_POST) { - foreach($_POST as $Field => $Value) { - $FieldName = $Field."_porcent"; - if ( isset( $CurrentPlanet[ $FieldName ] ) ) { - if ( ! in_array( $Value, $ValidList['percent']) ) { - header("Location: overview.php"); - exit; - } - - $Value = $Value / 10; - $CurrentPlanet[ $FieldName ] = $Value; - $SubQry .= ", `".$FieldName."` = '".$Value."'"; - } - } - } - - $parse = $lang; - - $parse['production_level'] = 100; - if ($CurrentPlanet['energy_max'] == 0 && - $CurrentPlanet['energy_used'] > 0) { - $post_porcent = 0; - } elseif ($CurrentPlanet['energy_max'] > 0 && - ($CurrentPlanet['energy_used'] + $CurrentPlanet['energy_max']) < 0 ) { - $post_porcent = floor(($CurrentPlanet['energy_max']) / $CurrentPlanet['energy_used'] * 100); - } else { - $post_porcent = 100; - } - if ($post_porcent > 100) { - $post_porcent = 100; - } - - // ------------------------------------------------------------------------------------------------------- - // Mise a jour de l'espace de stockage - $CurrentPlanet['metal_max'] = (floor (BASE_STORAGE_SIZE * pow (1.5, $CurrentPlanet[ $resource[22] ] ))) * (1 + ($CurrentUser['rpg_stockeur'] * 0.5)); - $CurrentPlanet['crystal_max'] = (floor (BASE_STORAGE_SIZE * pow (1.5, $CurrentPlanet[ $resource[23] ] ))) * (1 + ($CurrentUser['rpg_stockeur'] * 0.5)); - $CurrentPlanet['deuterium_max'] = (floor (BASE_STORAGE_SIZE * pow (1.5, $CurrentPlanet[ $resource[24] ] ))) * (1 + ($CurrentUser['rpg_stockeur'] * 0.5)); - - // ------------------------------------------------------------------------------------------------------- - $parse['resource_row'] = ""; - $CurrentPlanet['metal_perhour'] = 0; - $CurrentPlanet['crystal_perhour'] = 0; - $CurrentPlanet['deuterium_perhour'] = 0; - $CurrentPlanet['energy_max'] = 0; - $CurrentPlanet['energy_used'] = 0; - $BuildTemp = $CurrentPlanet[ 'temp_max' ]; - foreach($reslist['prod'] as $ProdID) { - if ($CurrentPlanet[$resource[$ProdID]] > 0 && isset($ProdGrid[$ProdID])) { - $BuildLevelFactor = $CurrentPlanet[ $resource[$ProdID]."_porcent" ]; - $BuildLevel = $CurrentPlanet[ $resource[$ProdID] ]; - $metal = floor( eval ( $ProdGrid[$ProdID]['formule']['metal'] ) * ( $gameConfig['resource_multiplier'] ) * ( 1 + ( $CurrentUser['rpg_geologue'] * 0.05 ) ) ); - $crystal = floor( eval ( $ProdGrid[$ProdID]['formule']['crystal'] ) * ( $gameConfig['resource_multiplier'] ) * ( 1 + ( $CurrentUser['rpg_geologue'] * 0.05 ) ) ); - $deuterium = floor( eval ( $ProdGrid[$ProdID]['formule']['deuterium'] ) * ( $gameConfig['resource_multiplier'] ) * ( 1 + ( $CurrentUser['rpg_geologue'] * 0.05 ) ) ); - $energy = floor( eval ( $ProdGrid[$ProdID]['formule']['energy'] ) * ( $gameConfig['resource_multiplier'] ) * ( 1 + ( $CurrentUser['rpg_ingenieur'] * 0.05 ) ) ); - if ($energy > 0) { - $CurrentPlanet['energy_max'] += $energy; - } else { - $CurrentPlanet['energy_used'] += $energy; - } - $CurrentPlanet['metal_perhour'] += $metal; - $CurrentPlanet['crystal_perhour'] += $crystal; - $CurrentPlanet['deuterium_perhour'] += $deuterium; - - $metal = $metal * 0.01 * $post_porcent; - $crystal = $crystal * 0.01 * $post_porcent; - $deuterium = $deuterium * 0.01 * $post_porcent; - $energy = $energy * 0.01 * $post_porcent; - $Field = $resource[$ProdID] ."_porcent"; - $CurrRow = array(); - $CurrRow['name'] = $resource[$ProdID]; - $CurrRow['porcent'] = $CurrentPlanet[$Field]; - for ($Option = 10; $Option >= 0; $Option--) { - $OptValue = $Option * 10; - if ($Option == $CurrRow['porcent']) { - $OptSelected = " selected=selected"; - } else { - $OptSelected = ""; - } - $CurrRow['option'] .= ""; - } - $CurrRow['type'] = $lang['tech'][$ProdID]; - $CurrRow['level'] = ($ProdID > 200) ? $lang['quantity'] : $lang['level']; - $CurrRow['level_type'] = $CurrentPlanet[ $resource[$ProdID] ]; - $CurrRow['metal_type'] = pretty_number ( $metal ); - $CurrRow['crystal_type'] = pretty_number ( $crystal ); - $CurrRow['deuterium_type'] = pretty_number ( $deuterium ); - $CurrRow['energy_type'] = pretty_number ( $energy ); - $CurrRow['metal_type'] = colorNumber ( $CurrRow['metal_type'] ); - $CurrRow['crystal_type'] = colorNumber ( $CurrRow['crystal_type'] ); - $CurrRow['deuterium_type'] = colorNumber ( $CurrRow['deuterium_type'] ); - $CurrRow['energy_type'] = colorNumber ( $CurrRow['energy_type'] ); - - $parse['resource_row'] .= parsetemplate ( $RessRowTPL, $CurrRow ); - } - } - - $parse['Production_of_resources_in_the_planet'] = - str_replace('%s', $CurrentPlanet['name'], $lang['Production_of_resources_in_the_planet']); - if ($CurrentPlanet['energy_max'] == 0 && - $CurrentPlanet['energy_used'] > 0) { - $parse['production_level'] = 0; - } elseif ($CurrentPlanet['energy_max'] > 0 && - abs($CurrentPlanet['energy_used']) > $CurrentPlanet['energy_max']) { - $parse['production_level'] = floor(($CurrentPlanet['energy_max']) / $CurrentPlanet['energy_used'] * 100); - } elseif ($CurrentPlanet['energy_max'] == 0 && - abs($CurrentPlanet['energy_used']) > $CurrentPlanet['energy_max']) { - $parse['production_level'] = 0; - } else { - $parse['production_level'] = 100; - } - if ($parse['production_level'] > 100) { - $parse['production_level'] = 100; - } - - $parse['metal_basic_income'] = $gameConfig['metal_basic_income'] * $gameConfig['resource_multiplier']; - $parse['crystal_basic_income'] = $gameConfig['crystal_basic_income'] * $gameConfig['resource_multiplier']; - $parse['deuterium_basic_income'] = $gameConfig['deuterium_basic_income'] * $gameConfig['resource_multiplier']; - $parse['energy_basic_income'] = $gameConfig['energy_basic_income'] * $gameConfig['resource_multiplier']; - - if ($CurrentPlanet['metal_max'] < $CurrentPlanet['metal']) { - $parse['metal_max'] = ""; - } else { - $parse['metal_max'] = ""; - } - $parse['metal_max'] .= pretty_number($CurrentPlanet['metal_max'] / 1000) ." ". $lang['k'].""; - - if ($CurrentPlanet['crystal_max'] < $CurrentPlanet['crystal']) { - $parse['crystal_max'] = ""; - } else { - $parse['crystal_max'] = ""; - } - $parse['crystal_max'] .= pretty_number($CurrentPlanet['crystal_max'] / 1000) ." ". $lang['k'].""; - - if ($CurrentPlanet['deuterium_max'] < $CurrentPlanet['deuterium']) { - $parse['deuterium_max'] = ""; - } else { - $parse['deuterium_max'] = ""; - } - $parse['deuterium_max'] .= pretty_number($CurrentPlanet['deuterium_max'] / 1000) ." ". $lang['k'].""; - - $parse['metal_total'] = colorNumber( pretty_number( floor( ( $CurrentPlanet['metal_perhour'] * 0.01 * $parse['production_level'] ) + $parse['metal_basic_income']))); - $parse['crystal_total'] = colorNumber( pretty_number( floor( ( $CurrentPlanet['crystal_perhour'] * 0.01 * $parse['production_level'] ) + $parse['crystal_basic_income']))); - $parse['deuterium_total'] = colorNumber( pretty_number( floor( ( $CurrentPlanet['deuterium_perhour'] * 0.01 * $parse['production_level'] ) + $parse['deuterium_basic_income']))); - $parse['energy_total'] = colorNumber( pretty_number( floor( ( $CurrentPlanet['energy_max'] + $parse['energy_basic_income'] ) + $CurrentPlanet['energy_used'] ) ) ); - - $parse['daily_metal'] = floor($CurrentPlanet['metal_perhour'] * 24 * 0.01 * $parse['production_level'] + $parse['metal_basic_income'] * 24 ); - $parse['weekly_metal'] = floor($CurrentPlanet['metal_perhour'] * 24 * 7 * 0.01 * $parse['production_level'] + $parse['metal_basic_income'] * 24 * 7 ); - $parse['monthly_metal'] = floor($CurrentPlanet['metal_perhour'] * 24 * 30 * 0.01 * $parse['production_level'] + $parse['metal_basic_income'] * 24 * 30 ); - - $parse['daily_crystal'] = floor($CurrentPlanet['crystal_perhour'] * 24 * 0.01 * $parse['production_level'] + $parse['crystal_basic_income'] * 24 ); - $parse['weekly_crystal'] = floor($CurrentPlanet['crystal_perhour'] * 24 * 7 * 0.01 * $parse['production_level'] + $parse['crystal_basic_income'] * 24 * 7 ); - $parse['monthly_crystal'] = floor($CurrentPlanet['crystal_perhour'] * 24 * 30 * 0.01 * $parse['production_level'] + $parse['crystal_basic_income'] * 24 * 30 ); - - $parse['daily_deuterium'] = floor($CurrentPlanet['deuterium_perhour'] * 24 * 0.01 * $parse['production_level'] + $parse['deuterium_basic_income'] * 24 ); - $parse['weekly_deuterium'] = floor($CurrentPlanet['deuterium_perhour'] * 24 * 7 * 0.01 * $parse['production_level'] + $parse['deuterium_basic_income'] * 24 * 7 ); - $parse['monthly_deuterium'] = floor($CurrentPlanet['deuterium_perhour'] * 24 * 30 * 0.01 * $parse['production_level'] + $parse['deuterium_basic_income'] * 24 * 30 ); - - $parse['daily_metal'] = colorNumber(pretty_number($parse['daily_metal'])); - $parse['weekly_metal'] = colorNumber(pretty_number($parse['weekly_metal'])); - $parse['monthly_metal'] = colorNumber(pretty_number($parse['monthly_metal'])); - - $parse['daily_crystal'] = colorNumber(pretty_number($parse['daily_crystal'])); - $parse['weekly_crystal'] = colorNumber(pretty_number($parse['weekly_crystal'])); - $parse['monthly_crystal'] = colorNumber(pretty_number($parse['monthly_crystal'])); - - $parse['daily_deuterium'] = colorNumber(pretty_number($parse['daily_deuterium'])); - $parse['weekly_deuterium'] = colorNumber(pretty_number($parse['weekly_deuterium'])); - $parse['monthly_deuterium'] = colorNumber(pretty_number($parse['monthly_deuterium'])); - - $parse['metal_storage'] = floor($CurrentPlanet['metal'] / $CurrentPlanet['metal_max'] * 100) . $lang['o/o']; - $parse['crystal_storage'] = floor($CurrentPlanet['crystal'] / $CurrentPlanet['crystal_max'] * 100) . $lang['o/o']; - $parse['deuterium_storage'] = floor($CurrentPlanet['deuterium'] / $CurrentPlanet['deuterium_max'] * 100) . $lang['o/o']; - $parse['metal_storage_bar'] = floor(($CurrentPlanet['metal'] / $CurrentPlanet['metal_max'] * 100) * 2.5); - $parse['crystal_storage_bar'] = floor(($CurrentPlanet['crystal'] / $CurrentPlanet['crystal_max'] * 100) * 2.5); - $parse['deuterium_storage_bar'] = floor(($CurrentPlanet['deuterium'] / $CurrentPlanet['deuterium_max'] * 100) * 2.5); - - if ($parse['metal_storage_bar'] > (100 * 2.5)) { - $parse['metal_storage_bar'] = 250; - $parse['metal_storage_barcolor'] = '#C00000'; - } elseif ($parse['metal_storage_bar'] > (80 * 2.5)) { - $parse['metal_storage_barcolor'] = '#C0C000'; - } else { - $parse['metal_storage_barcolor'] = '#00C000'; - } - - if ($parse['crystal_storage_bar'] > (100 * 2.5)) { - $parse['crystal_storage_bar'] = 250; - $parse['crystal_storage_barcolor'] = '#C00000'; - } elseif ($parse['crystal_storage_bar'] > (80 * 2.5)) { - $parse['crystal_storage_barcolor'] = '#C0C000'; - } else { - $parse['crystal_storage_barcolor'] = '#00C000'; - } - - if ($parse['deuterium_storage_bar'] > (100 * 2.5)) { - $parse['deuterium_storage_bar'] = 250; - $parse['deuterium_storage_barcolor'] = '#C00000'; - } elseif ($parse['deuterium_storage_bar'] > (80 * 2.5)) { - $parse['deuterium_storage_barcolor'] = '#C0C000'; - } else { - $parse['deuterium_storage_barcolor'] = '#00C000'; - } - - $parse['production_level_bar'] = $parse['production_level'] * 2.5; - $parse['production_level'] = "{$parse['production_level']}%"; - $parse['production_level_barcolor'] = '#00ff00'; - - $QryUpdatePlanet = "UPDATE {{table}} SET "; - $QryUpdatePlanet .= "`id` = '". $CurrentPlanet['id'] ."' "; - $QryUpdatePlanet .= $SubQry; - $QryUpdatePlanet .= "WHERE "; - $QryUpdatePlanet .= "`id` = '". $CurrentPlanet['id'] ."';"; - doquery( $QryUpdatePlanet, 'planets'); - - $page = parsetemplate( $RessBodyTPL, $parse ); - - return $page; -} - - $Page = BuildRessourcePage ( $user, $planetrow ); - display( $Page, $lang['Resources'] ); - -// ----------------------------------------------------------------------------------------------------------- -// History version -// 1.0 - Passage en fonction pour utilisation XNova -?> diff --git a/skin/default/css/legacies.css b/skin/default/css/legacies.css deleted file mode 100644 index 45b6f6a..0000000 --- a/skin/default/css/legacies.css +++ /dev/null @@ -1,22 +0,0 @@ -@CHARSET "UTF-8"; -.global .content .resources-display {width:770px;height:40px;margin:0 auto 30px;padding:0 50px;color:#000;background:#FFF;box-shadow:0 -4px 6px #156 inset;border:1px solid #FFF;border-top:none;border-radius: 0 0 20px 20px;} -.global .content .resources-display .resource,.global .content .resources-display .messages {height:22px;float:left;width:140px;margin:7px 0;} -.global .content .resources-display .resource img,.global .content .resources-display .messages img {float:left;} -.global .content .resources-display .resource p,.global .content .resources-display .messages p {font-weight:bold;font-size:12px;margin:2px 0 2px 47px;} -.global .content .resources-display .resource a,.global .content .resources-display .messages a {color:#000;text-decoration:underline;} -.global .content .resources-display .resource .resource-capped {color:red;} -.global .content .resources-display .messages {height:22px;float:left;width:160px;} -.global .content .resources-display .energy {width:190px;} - - -.global .content .queue {width:600px;margin:10px auto 0;background:#FFF;color:#000;border:1px solid #FFF;border-radius:5px;border-top-left-radius:20px;border-top-right-radius:20px;box-shadow:0 4px 6px #156 inset;} -.global .content .queue h1 {color:#000;margin:10px 15px;width:570px;text-align:center;border-bottom:5px solid #9BC;} - -.global .content .queue .item {width:580px;margin:0 10px;border:0;box-shadow:none;border-radius:0;} -.global .content .queue .item,.global .content .queue .item * {color:#000;} - -.global .content .item-list {width:800px; margin:10px auto 0;background:#FFF;color:#000;border:1px solid #FFF;border-radius:5px;border-top-left-radius:20px;border-top-right-radius:20px;box-shadow:0 4px 6px #156 inset;} -.global .content .item-list h1 {color:#000;margin:10px 15px;width:770px;text-align:center;border-bottom:5px solid #9BC;} - -.global .content .item-list .item {width:780px;margin:0 10px;border:0;box-shadow:none;border-radius:0;} -.global .content .item-list .item,.global .content .item-list .item * {color:#000;} \ No newline at end of file diff --git a/src/.htaccess b/src/.htaccess new file mode 100644 index 0000000..ca113c2 --- /dev/null +++ b/src/.htaccess @@ -0,0 +1,18 @@ +SetEnv DEBUG On +SetEnv DEPRECATION On + + + Options +FollowSymLinks + RewriteEngine On + + RewriteBase / + +## workaround for HTTP authorization in CGI environment + #RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] + + RewriteCond %{REQUEST_URI} !^/(skin|js)/ + RewriteCond %{REQUEST_FILENAME} !-f + RewriteCond %{REQUEST_FILENAME} !-d + RewriteCond %{REQUEST_FILENAME} !-l + RewriteRule .* index.php [L] + diff --git a/LICENCE b/src/LICENCE similarity index 100% rename from LICENCE rename to src/LICENCE diff --git a/src/add_declare.php b/src/add_declare.php new file mode 100644 index 0000000..b2d6eaf --- /dev/null +++ b/src/add_declare.php @@ -0,0 +1,62 @@ + + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License + * along with this program. If not, see . + * + * --> 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. + * + */ + +define('INSIDE' , true); +define('INSTALL' , false); +require_once dirname(__FILE__) .'/application/bootstrap.php'; + +$mode = Wootook::getRequest()->getPost('mode'); + +if ($mode == 'addit') { + $adapter = Wootook_Core_Database_ConnectionManager::getSingleton()->getConnection('core_write'); + $adapter->insert() + ->into($adapter->getTable('declared')) + ->set('declarator', $user->getId()) + ->set('declarator_name', $user->getUsername()) + ->set('declared_1', Wootook::getRequest()->getPost('dec1')) + ->set('declared_2', Wootook::getRequest()->getPost('dec2')) + ->set('declared_3', Wootook::getRequest()->getPost('dec2')) + ->set('reason', Wootook::getRequest()->getPost('reason')) + ->execute() + ; + + $adapter->update() + ->into($adapter->getTable('users')) + ->set('multi_validated', 1) + ; + + message("Merci, votre demande a ete prise en compte. Les autres joueurs que vous avez implique doivent egalement et imperativement suivre cette procedure aussi.", "Ajout"); +} + +includeLang('admin'); +$Page = parsetemplate(gettemplate("add_declare"), $lang); + +display($Page, "Declaration d\'IP partagee", false, '', true); + diff --git a/admin/ElementQueueFixer.php b/src/admin/ElementQueueFixer.php similarity index 90% rename from admin/ElementQueueFixer.php rename to src/admin/ElementQueueFixer.php index 4411b89..be19843 100644 --- a/admin/ElementQueueFixer.php +++ b/src/admin/ElementQueueFixer.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,14 +24,14 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); define('IN_ADMIN', true); -require_once dirname(dirname(__FILE__)) .'/common.php'; +require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php'; if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR, LEVEL_MODERATOR))) { includeLang('admin'); diff --git a/admin/QueryExecute.php b/src/admin/QueryExecute.php similarity index 84% rename from admin/QueryExecute.php rename to src/admin/QueryExecute.php index 1ef16cb..9e75ebf 100644 --- a/admin/QueryExecute.php +++ b/src/admin/QueryExecute.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,14 +24,14 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); define('IN_ADMIN', true); -require_once dirname(dirname(__FILE__)) .'/common.php'; +require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php'; if (in_array($user['authlevel'], array(LEVEL_ADMIN))) { includeLang('admin/Queries'); diff --git a/admin/autounban.php b/src/admin/ShowFlyingFleets.php similarity index 56% rename from admin/autounban.php rename to src/admin/ShowFlyingFleets.php index fae8ef9..c41270d 100644 --- a/admin/autounban.php +++ b/src/admin/ShowFlyingFleets.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,25 +24,27 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); define('IN_ADMIN', true); -require_once dirname(dirname(__FILE__)) .'/common.php'; +require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php'; - if (in_array($user['authlevel'], array(LEVEL_ADMIN))) { - $lang['PHP_SELF'] = 'options.'.PHPEXT; - doquery("UPDATE {{table}} SET `banaday` =` banaday` - '1' WHERE `banaday` != '0';",'users'); - doquery("UPDATE {{table}} SET `bana` = '0' WHERE `banaday` < '1';",'users'); - $parse = $gameConfig; - $parse['dpath'] = $dpath; - $parse['debug'] = ($gameConfig['debug'] == 1) ? " checked='checked'/":''; - } else { - message ( $lang['sys_noalloaw'], $lang['sys_noaccess'] ); - } +include(ROOT_PATH . 'includes/functions/BuildFlyingFleetTable.'.PHPEXT); -?> +if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR, LEVEL_MODERATOR))) { + includeLang('admin/fleets'); + $PageTPL = gettemplate('admin/fleet_body'); + $parse = $lang; + $parse['flt_table'] = BuildFlyingFleetTable (); + + $page = parsetemplate( $PageTPL, $parse ); + display ( $page, $lang['flt_title'], false, '', true); + +} else { + AdminMessage ( $lang['sys_noalloaw'], $lang['sys_noaccess'] ); +} diff --git a/admin/XNovaResetUnivers.php b/src/admin/XNovaResetUnivers.php similarity index 94% rename from admin/XNovaResetUnivers.php rename to src/admin/XNovaResetUnivers.php index bf64d50..e789d4d 100644 --- a/admin/XNovaResetUnivers.php +++ b/src/admin/XNovaResetUnivers.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,18 +24,18 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); define('IN_ADMIN', true); -require_once dirname(dirname(__FILE__)) .'/common.php'; +require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php'; includeLang('admin'); -function XNovaResetUnivers ( $CurrentUser ) { +function WootookResetUnivers ( $CurrentUser ) { global $lang; if (in_array($CurrentUser['authlevel'], array(LEVEL_ADMIN))) { @@ -129,7 +129,7 @@ function XNovaResetUnivers ( $CurrentUser ) { $parse = $lang; if ($mode == 'reset') { - XNovaResetUnivers ( $user ); + WootookResetUnivers ( $user ); } else { $Page = parsetemplate($PageTpl, $parse); display ($Page, $lang['Reset'], false, '', true); diff --git a/src/admin/activeplanet.php b/src/admin/activeplanet.php new file mode 100644 index 0000000..8a5b941 --- /dev/null +++ b/src/admin/activeplanet.php @@ -0,0 +1,67 @@ + + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License + * along with this program. If not, see . + * + * --> 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. + * + */ + +define('INSIDE' , true); +define('INSTALL' , false); +define('IN_ADMIN', true); +require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php'; + +$user = Wootook_Player_Model_Session::getSingleton()->getPlayer(); + +if (!in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) { + message( $lang['sys_noalloaw'], $lang['sys_noaccess'] ); + exit(0); +} + +includeLang('admin'); + +$parse = $lang; +$parse['dpath'] = $dpath; +$parse['mf'] = $mf; + +$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'] .= ""; + $parse['online_list'] .= "
    ". $ActivPlanet['name'] ."
    "; + $parse['online_list'] .= "
    [". $ActivPlanet['galaxy'] .":". $ActivPlanet['system'] .":". $ActivPlanet['planet'] ."]
    "; + $parse['online_list'] .= "
    ". pretty_number($ActivPlanet['points'] / 1000) ."
    "; + $parse['online_list'] .= "
    ". pretty_time(time() - $ActivPlanet['last_update']) . "
    "; + $parse['online_list'] .= ""; + $Count++; +} +$parse['online_list'] .= ""; +$parse['online_list'] .= "". $lang['adm_pl_they'] ." ". $Count ." ". $lang['adm_pl_apla'] .""; +$parse['online_list'] .= ""; + +$page = parsetemplate( $PageTPL , $parse ); +display( $page, $lang['adm_pl_title'], false, '', true ); diff --git a/src/admin/add_fleet.php b/src/admin/add_fleet.php new file mode 100644 index 0000000..ca6be77 --- /dev/null +++ b/src/admin/add_fleet.php @@ -0,0 +1,103 @@ + + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License + * along with this program. If not, see . + * + * --> 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. + * + */ + +define('INSIDE' , true); +define('INSTALL' , false); +define('IN_ADMIN', true); + +require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php'; + +$user = Wootook_Player_Model_Session::getSingleton()->getPlayer(); + +if (!in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) { + message( $lang['sys_noalloaw'], $lang['sys_noaccess'] ); + exit(0); +} + +includeLang('admin/add_fleet'); +$mode = $_GET['mode']; + +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']; + +} 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']; + + $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); + diff --git a/src/admin/add_money.php b/src/admin/add_money.php new file mode 100644 index 0000000..7bca4b4 --- /dev/null +++ b/src/admin/add_money.php @@ -0,0 +1,68 @@ + + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License + * along with this program. If not, see . + * + * --> 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. + * + */ + +define('INSIDE' , true); +define('INSTALL' , false); +define('IN_ADMIN', true); +require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php'; + +$user = Wootook_Player_Model_Session::getSingleton()->getPlayer(); + +if (!in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) { + message( $lang['sys_noalloaw'], $lang['sys_noaccess'] ); + exit(0); +} + +includeLang('admin'); + +$mode = $_POST['mode']; + +$PageTpl = gettemplate("admin/add_money"); +$parse = $lang; + +if ($mode == 'addit') { + $id = $_POST['id']; + $metal = $_POST['metal']; + $cristal = $_POST['cristal']; + $deut = $_POST['deut']; + + $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); diff --git a/admin/add_moon.php b/src/admin/add_moon.php similarity index 88% rename from admin/add_moon.php rename to src/admin/add_moon.php index f2f220f..63c2851 100644 --- a/admin/add_moon.php +++ b/src/admin/add_moon.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,14 +24,14 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); define('IN_ADMIN', true); -require_once dirname(dirname(__FILE__)) .'/common.php'; +require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php'; if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) { includeLang('admin/addmoon'); diff --git a/admin/ShowFlyingFleets.php b/src/admin/autounban.php similarity index 58% rename from admin/ShowFlyingFleets.php rename to src/admin/autounban.php index 9d66c27..5d9a6a9 100644 --- a/admin/ShowFlyingFleets.php +++ b/src/admin/autounban.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,27 +24,24 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); define('IN_ADMIN', true); -require_once dirname(dirname(__FILE__)) .'/common.php'; +require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php'; - if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR, LEVEL_MODERATOR))) { - includeLang('admin/fleets'); - $PageTPL = gettemplate('admin/fleet_body'); +if (in_array($user['authlevel'], array(LEVEL_ADMIN))) { + doquery("UPDATE {{table}} SET `banaday` =` banaday` - '1' WHERE `banaday` != '0';",'users'); + doquery("UPDATE {{table}} SET `bana` = '0' WHERE `banaday` < '1';",'users'); - $parse = $lang; - $parse['flt_table'] = BuildFlyingFleetTable (); + $response = Wootook::getResponse() + ->setRedirect(Wootook::getStaticUrl('admin/overview.php')) + ->sendHeaders(); + exit(0); +} else { + message ( $lang['sys_noalloaw'], $lang['sys_noaccess'] ); +} - $page = parsetemplate( $PageTPL, $parse ); - display ( $page, $lang['flt_title'], false, '', true); - - } else { - AdminMessage ( $lang['sys_noalloaw'], $lang['sys_noaccess'] ); - } - -?> \ No newline at end of file diff --git a/admin/banned.php b/src/admin/banned.php similarity index 91% rename from admin/banned.php rename to src/admin/banned.php index 9867ced..89b6f01 100644 --- a/admin/banned.php +++ b/src/admin/banned.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,14 +24,14 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); define('IN_ADMIN', true); -require_once dirname(dirname(__FILE__)) .'/common.php'; +require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php'; if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR, LEVEL_MODERATOR))) { includeLang('admin'); diff --git a/admin/changelog.php b/src/admin/changelog.php similarity index 83% rename from admin/changelog.php rename to src/admin/changelog.php index abca21c..6ef7ced 100644 --- a/admin/changelog.php +++ b/src/admin/changelog.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,14 +24,14 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); define('IN_ADMIN', true); -require_once dirname(dirname(__FILE__)) .'/common.php'; +require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php'; includeLang('changelog'); $template = gettemplate('changelog_table'); diff --git a/admin/chat.php b/src/admin/chat.php similarity index 88% rename from admin/chat.php rename to src/admin/chat.php index 860ae00..b6ca379 100644 --- a/admin/chat.php +++ b/src/admin/chat.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,14 +24,14 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); define('IN_ADMIN', true); -require_once dirname(dirname(__FILE__)) .'/common.php'; +require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php'; includeLang('admin'); $parse = $lang; diff --git a/admin/credit.php b/src/admin/credit.php similarity index 90% rename from admin/credit.php rename to src/admin/credit.php index 8eef023..00c282d 100644 --- a/admin/credit.php +++ b/src/admin/credit.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,14 +24,14 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); define('IN_ADMIN', true); -require_once dirname(dirname(__FILE__)) .'/common.php'; +require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php'; includeLang('credit'); $parse = $lang; diff --git a/admin/declare_list.php b/src/admin/declare_list.php similarity index 82% rename from admin/declare_list.php rename to src/admin/declare_list.php index 973f7df..6ecc761 100644 --- a/admin/declare_list.php +++ b/src/admin/declare_list.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,19 +24,23 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); define('IN_ADMIN', true); -require_once dirname(dirname(__FILE__)) .'/common.php'; +require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php'; if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) { includeLang('admin'); if ($_GET['cmd'] == 'dele') { - DeleteSelectedUser ( $_GET['user'] ); + $player = new Wootook_Player_Model_Entity(); + $player->load(intval($_GET['user'])); + if ($player->getId()) { + $player->delete(); + } } if ($_GET['cmd'] == 'sort') { $TypeSort = $_GET['type']; @@ -53,7 +57,7 @@ require_once dirname(dirname(__FILE__)) .'/common.php'; $parse['adm_ul_table'] = ""; $i = 0; $Color = "lime"; - while ($u = mysql_fetch_assoc ($query) ) { + while ($u = $query->fetch(PDO::FETCH_ASSOC) ) { if ($PrevIP != "") { if ($PrevIP == $u['declarator']) { $Color = "red"; diff --git a/admin/deletuser.php b/src/admin/deletuser.php similarity index 84% rename from admin/deletuser.php rename to src/admin/deletuser.php index 5bbfecd..370ddcb 100644 --- a/admin/deletuser.php +++ b/src/admin/deletuser.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,14 +24,14 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); define('IN_ADMIN', true); -require_once dirname(dirname(__FILE__)) .'/common.php'; +require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php'; if (in_array($CurrentUser['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) { $PageTpl = gettemplate( "admin/deletuser" ); diff --git a/admin/errors.php b/src/admin/errors.php similarity index 89% rename from admin/errors.php rename to src/admin/errors.php index a99f1e0..0ff6a7b 100644 --- a/admin/errors.php +++ b/src/admin/errors.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,14 +24,14 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); define('IN_ADMIN', true); -require_once dirname(dirname(__FILE__)) .'/common.php'; +require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php'; includeLang('admin'); $parse = $lang; diff --git a/admin/leftmenu.php b/src/admin/leftmenu.php similarity index 67% rename from admin/leftmenu.php rename to src/admin/leftmenu.php index 4b41251..cce8699 100644 --- a/admin/leftmenu.php +++ b/src/admin/leftmenu.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,25 +24,25 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); define('IN_ADMIN', true); -require_once dirname(dirname(__FILE__)) .'/common.php'; +require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php'; includeLang('leftmenu'); if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR, LEVEL_MODERATOR))) { - $parse = $lang; - $parse['mf'] = "Hauptframe"; - $parse['dpath'] = $dpath; - $parse['XNovaRelease'] = VERSION; - $parse['servername'] = XNova; - $Page = parsetemplate(gettemplate('admin/left_menu'), $parse); - display( $Page, "", false, '', true); + $parse = $lang; + $parse['mf'] = "Hauptframe"; + $parse['dpath'] = $dpath; + $parse['WootookRelease'] = VERSION; + $parse['servername'] = 'Wootook'; + $Page = parsetemplate(gettemplate('admin/left_menu'), $parse); + display($Page, "", false, '', true); } else { message( $lang['sys_noalloaw'], $lang['sys_noaccess'] ); } diff --git a/admin/md5changepass.php b/src/admin/md5changepass.php similarity index 87% rename from admin/md5changepass.php rename to src/admin/md5changepass.php index 72ca6c4..71bf636 100644 --- a/admin/md5changepass.php +++ b/src/admin/md5changepass.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,14 +24,14 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); define('IN_ADMIN', true); -require_once dirname(dirname(__FILE__)) .'/common.php'; +require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php'; if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR, LEVEL_MODERATOR))) { includeLang('admin/changepass'); diff --git a/admin/md5enc.php b/src/admin/md5enc.php similarity index 85% rename from admin/md5enc.php rename to src/admin/md5enc.php index 20f3c2a..ba3c4e5 100644 --- a/admin/md5enc.php +++ b/src/admin/md5enc.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,14 +24,14 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); define('IN_ADMIN', true); -require_once dirname(dirname(__FILE__)) .'/common.php'; +require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php'; if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR, LEVEL_MODERATOR))) { includeLang('admin/md5enc'); diff --git a/admin/messagelist.php b/src/admin/messagelist.php similarity index 96% rename from admin/messagelist.php rename to src/admin/messagelist.php index c6d31d0..a4c75cf 100644 --- a/admin/messagelist.php +++ b/src/admin/messagelist.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,14 +24,14 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); define('IN_ADMIN', true); -require_once dirname(dirname(__FILE__)) .'/common.php'; +require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php'; if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) { includeLang('admin/messagelist'); diff --git a/src/admin/messall.php b/src/admin/messall.php new file mode 100644 index 0000000..7aebd2b --- /dev/null +++ b/src/admin/messall.php @@ -0,0 +1,75 @@ + + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License + * along with this program. If not, see . + * + * --> 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. + * + */ + +define('INSIDE' , true); +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, LEVEL_MODERATOR))) { + if (!empty($_POST)) { + if (isset($_POST["tresc"]) && $_POST["tresc"] != '') { + $tresc = $_POST['tresc']; + } + if (isset($_POST["temat"]) && $_POST["temat"] != '') { + $temat = $_POST['temat']; + } + if ($user['authlevel'] == LEVEL_ADMIN) { + $kolor = 'red'; + $ranga = 'Administrator'; + } elseif ($user['authlevel'] == LEVEL_OPERATOR) { + $kolor = 'skyblue'; + $ranga = 'Operator'; + } elseif ($user['authlevel'] == LEVEL_MODERATOR) { + $kolor = 'yellow'; + $ranga = 'Moderator'; + } + if (isset($tresc) && isset($temat)) { + $sq = doquery("SELECT `id` FROM {{table}}", "users"); + $Time = time(); + $From = "". $ranga ." ".$user['username'].""; + $Subject = "". $temat .""; + $Message = "". $tresc .""; + while ($u = $sq->fetch(PDO::FETCH_BOTH)) { + SendSimpleMessage($u['id'], $user['id'], $Time, 97, $From, $Subject, $Message); + } + message("Wys�a�e� wiadomo�� do wszystkich graczy", "Complete", "../overview." . PHPEXT, 3); + } + } else { + $parse = array(); + $parse['dpath'] = $dpath; + $parse['debug'] = (defined('DEBUG')) ? " checked='checked'/":''; + $page .= parsetemplate(gettemplate('admin/messall_body'), $parse); + display($page, '', false,'', true); + } +} else { + message($lang['sys_noalloaw'], $lang['sys_noaccess']); +} \ No newline at end of file diff --git a/admin/moonlist.php b/src/admin/moonlist.php similarity index 88% rename from admin/moonlist.php rename to src/admin/moonlist.php index 02b64b6..932e607 100644 --- a/admin/moonlist.php +++ b/src/admin/moonlist.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,14 +24,14 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); define('IN_ADMIN', true); -require_once dirname(dirname(__FILE__)) .'/common.php'; +require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php'; if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) { includeLang('overview'); diff --git a/admin/multi.php b/src/admin/multi.php similarity index 87% rename from admin/multi.php rename to src/admin/multi.php index 46af676..4b41308 100644 --- a/admin/multi.php +++ b/src/admin/multi.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,14 +24,14 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); define('IN_ADMIN', true); -require_once dirname(dirname(__FILE__)) .'/common.php'; +require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php'; if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR, LEVEL_MODERATOR))) { includeLang('admin/multi'); diff --git a/src/admin/overview.php b/src/admin/overview.php new file mode 100644 index 0000000..2fc17a3 --- /dev/null +++ b/src/admin/overview.php @@ -0,0 +1,114 @@ + + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License + * along with this program. If not, see . + * + * --> 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. + * + */ + +define('INSIDE' , true); +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, LEVEL_MODERATOR))) { + includeLang('admin'); + + if (isset($_GET['cmd']) && isset($_GET['type']) && $_GET['cmd'] == 'sort') { + $TypeSort = $_GET['type']; + } else { + $TypeSort = "id"; + } + + $PageTPL = gettemplate('admin/overview_body'); + $RowsTPL = gettemplate('admin/overview_rows'); + + $parse = $lang; + $parse['version'] = VERSION; + + $Last15Mins = doquery("SELECT * FROM {{table}} WHERE `onlinetime` >= '". (time() - 15 * 60) ."' ORDER BY `". $TypeSort ."` ASC;", 'users'); + $Count = 0; + $Color = "lime"; + $PrevIP = ''; + $parse['adm_ov_data_table'] = ''; + while ($TheUser = $Last15Mins->fetch(PDO::FETCH_ASSOC) ) { + if ($PrevIP != "") { + if ($PrevIP == $TheUser['user_lastip']) { + $Color = "red"; + } else { + $Color = "lime"; + } + } + + $UserPoints = doquery("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '" . $TheUser['id'] . "';", 'statpoints', true); + $Bloc['adm_ov_altpm'] = $lang['adm_ov_altpm']; + $Bloc['adm_ov_wrtpm'] = $lang['adm_ov_wrtpm']; + $Bloc['adm_ov_data_id'] = $TheUser['id']; + $Bloc['adm_ov_data_name'] = $TheUser['username']; + $Bloc['adm_ov_data_agen'] = $TheUser['user_agent']; + $Bloc['current_page'] = $TheUser['current_page']; + $Bloc['usr_s_id'] = $TheUser['id']; + + $Bloc['adm_ov_data_clip'] = $Color; + $Bloc['adm_ov_data_adip'] = $TheUser['user_lastip']; + $Bloc['adm_ov_data_ally'] = $TheUser['ally_name']; + $Bloc['adm_ov_data_point'] = pretty_number ( $UserPoints['total_points'] ); + $Bloc['adm_ov_data_activ'] = pretty_time ( time() - $TheUser['onlinetime'] ); + $Bloc['adm_ov_data_pict'] = "m.gif"; + $PrevIP = $TheUser['user_lastip']; + + //Tweaks vue g�n�rale + $Bloc['usr_email'] = $TheUser['email']; + $Bloc['usr_xp_raid'] = $TheUser['xpraid']; + $Bloc['usr_xp_min'] = $TheUser['xpminier']; + + if ($TheUser['urlaubs_modus'] == 1) { + $Bloc['state_vacancy'] = ""; + } else { + $Bloc['state_vacancy'] = ""; + } + + if ($TheUser['bana'] == 1) { + $Bloc['is_banned'] = ""; + } else { + $Bloc['is_banned'] = $lang['is_banned_lang']; + } + $Bloc['usr_planet_gal'] = $TheUser['galaxy']; + $Bloc['usr_planet_sys'] = $TheUser['system']; + $Bloc['usr_planet_pos'] = $TheUser['planet']; + + + $parse['adm_ov_data_table'] .= parsetemplate( $RowsTPL, $Bloc ); + $Count++; + } + + $parse['adm_ov_data_count'] = $Count; + $Page = parsetemplate($PageTPL, $parse); + + display( $Page, $lang['sys_overview'], false, '', true); +} else { + AdminMessage ( $lang['sys_noalloaw'], $lang['sys_noaccess'] ); +} + diff --git a/admin/paneladmina.php b/src/admin/paneladmina.php similarity index 72% rename from admin/paneladmina.php rename to src/admin/paneladmina.php index 86793a2..1ea59d8 100644 --- a/admin/paneladmina.php +++ b/src/admin/paneladmina.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ @@ -32,7 +32,7 @@ define('INSIDE' , true); define('INSTALL' , false); define('IN_ADMIN', true); -require_once dirname(dirname(__FILE__)) .'/common.php'; +require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php'; if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR, LEVEL_MODERATOR))) { @@ -50,37 +50,79 @@ require_once dirname(dirname(__FILE__)) .'/common.php'; switch ($_GET['result']){ case 'usr_search': - $pattern = mysql_real_escape_string($_GET['player']); - $SelUser = doquery("SELECT * FROM {{table}} WHERE `username` LIKE '%". $pattern ."%' LIMIT 1;", 'users', true); - $UsrMain = doquery("SELECT `name` FROM {{table}} WHERE `id` = '". $SelUser['id_planet'] ."';", 'planets', true); + $db = Legacies_Database::getSingleton(); + $sql =<<quote('%' . str_replace('*', '%', str_replace('%', '%%', $_GET['player'])) . '%')}" +SQL_EOF; + $statement = $db->prepare($sql); + $statement->execute(); + $data = $statement->fetch(PDO::FETCH_ASSOC); $bloc = $lang; - $bloc['answer1'] = $SelUser['id']; - $bloc['answer2'] = $SelUser['username']; - $bloc['answer3'] = $SelUser['user_lastip']; - $bloc['answer4'] = $SelUser['email']; - $bloc['answer5'] = $lang['adm_usr_level'][ $SelUser['authlevel'] ]; - $bloc['answer6'] = $lang['adm_usr_genre'][ $SelUser['sex'] ]; - $bloc['answer7'] = "[".$SelUser['id_planet']."] ".$UsrMain['name']; - $bloc['answer8'] = "[".$SelUser['galaxy'].":".$SelUser['system'].":".$SelUser['planet']."] "; + $bloc['answer1'] = $data['user_id']; + $bloc['answer2'] = $data['username']; + $bloc['answer3'] = $data['user_lastip']; + $bloc['answer4'] = $data['email']; + $bloc['answer5'] = $lang['adm_usr_level'][$data['authlevel']]; + $bloc['answer6'] = $lang['adm_usr_genre'][$data['sex']]; + $bloc['answer7'] = "[".$data['planet_id']."] {$data['planet_name']}"; + $bloc['answer8'] = "[".$SelUser['planet_galaxy'].":".$SelUser['planet_system'].":".$SelUser['planet_position']."] "; $SubPanelTPL = gettemplate('admin/admin_panel_asw1'); - $parse['adm_sub_form2'] = parsetemplate( $SubPanelTPL, $bloc ); + $parse['adm_sub_form2'] = parsetemplate($SubPanelTPL, $bloc); break; case 'usr_data': + $db = Legacies_Database::getSingleton(); + $sql =<<quote('%' . str_replace('*', '%', str_replace('%', '%%', $_GET['player'])) . '%')}" +SQL_EOF; + $statement = $db->prepare($sql); + $statement->execute(); + $data = $statement->fetch(PDO::FETCH_ASSOC); + $pattern = mysql_real_escape_string($_GET['player']); $SelUser = doquery("SELECT * FROM {{table}} WHERE `username` LIKE '%". $pattern ."%' LIMIT 1;", 'users', true); $UsrMain = doquery("SELECT `name` FROM {{table}} WHERE `id` = '". $SelUser['id_planet'] ."';", 'planets', true); $bloc = $lang; - $bloc['answer1'] = $SelUser['id']; - $bloc['answer2'] = $SelUser['username']; - $bloc['answer3'] = $SelUser['user_lastip']; - $bloc['answer4'] = $SelUser['email']; - $bloc['answer5'] = $lang['adm_usr_level'][ $SelUser['authlevel'] ]; - $bloc['answer6'] = $lang['adm_usr_genre'][ $SelUser['sex'] ]; - $bloc['answer7'] = "[".$SelUser['id_planet']."] ".$UsrMain['name']; - $bloc['answer8'] = "[".$SelUser['galaxy'].":".$SelUser['system'].":".$SelUser['planet']."] "; + $bloc['answer1'] = $data['user_id']; + $bloc['answer2'] = $data['username']; + $bloc['answer3'] = $data['user_lastip']; + $bloc['answer4'] = $data['email']; + $bloc['answer5'] = $lang['adm_usr_level'][$data['authlevel']]; + $bloc['answer6'] = $lang['adm_usr_genre'][$data['sex']]; + $bloc['answer7'] = "[".$data['planet_id']."] {$data['planet_name']}"; + $bloc['answer8'] = "[".$SelUser['planet_galaxy'].":".$SelUser['planet_system'].":".$SelUser['planet_position']."] "; $SubPanelTPL = gettemplate('admin/admin_panel_asw1'); $parse['adm_sub_form1'] = parsetemplate( $SubPanelTPL, $bloc ); diff --git a/admin/planetlist.php b/src/admin/planetlist.php similarity index 85% rename from admin/planetlist.php rename to src/admin/planetlist.php index 954600c..4a154a5 100644 --- a/admin/planetlist.php +++ b/src/admin/planetlist.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,14 +24,14 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); define('IN_ADMIN', true); -require_once dirname(dirname(__FILE__)) .'/common.php'; +require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php'; if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) { @@ -59,5 +59,5 @@ require_once dirname(dirname(__FILE__)) .'/common.php'; message($lang['sys_noalloaw'], $lang['sys_noaccess']); } -// Created by e-Zobar. All rights reversed (C) XNova Team 2008 +// Created by e-Zobar. All rights reversed (C) Wootook Team 2008 ?> \ No newline at end of file diff --git a/src/admin/settings.php b/src/admin/settings.php new file mode 100644 index 0000000..88fc5d1 --- /dev/null +++ b/src/admin/settings.php @@ -0,0 +1,242 @@ + + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License + * along with this program. If not, see . + * + * --> 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. + * + */ + +define('INSIDE' , true); +define('INSTALL' , false); +define('IN_ADMIN', true); +require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php'; + + +function DisplayGameSettingsPage($CurrentUser) { + global $lang; + + includeLang('admin/settings'); + + if (in_array((int) $CurrentUser['authlevel'], array(LEVEL_ADMIN))) { + if (isset($_POST['opt_save']) && $_POST['opt_save'] == "1") { + // Jeu Ouvert ou Ferm� ! + if (isset($_POST['closed']) && $_POST['closed'] == 'on') { + Wootook::setConfig('game/general/active', true, 1, 1); + } else { + Wootook::setConfig('game/general/active', false, 1, 1); + } + + if (isset($_POST['close_reason'])) { + Wootook::setConfig('game/general/closing-message', $_POST['close_reason'], 1, 1); + } + + // Y a un News Frame ? ! + if (isset($_POST['newsframe']) && $_POST['newsframe'] == 'on') { + Wootook::setConfig('game/news/active', true, 1, 1); + } else { + Wootook::setConfig('game/news/active', false, 1, 1); + } + + if (isset($_POST['NewsText'])) { + Wootook::setConfig('game/news/content', $_POST['NewsText'], 1, 1); + } + + // Y a un TCHAT externe ?? + if (isset($_POST['chatframe']) && $_POST['chatframe'] == 'on') { + Wootook::setConfig('engine/options/chat', true, 1, 1); + } else { + Wootook::setConfig('engine/options/chat', false, 1, 1); + } + + if (isset($_POST['ga']) && $_POST['ga'] == 'on') { + Wootook::setConfig('engine/options/ga', true, 1, 1); + } else { + Wootook::setConfig('engine/options/ga', false, 1, 1); + } + if (isset($_POST['ga_id']) && !empty($_POST['ga_id'])) { + Wootook::setConfig('engine/options/ga-id', $_POST['ga_id'], 1, 1); + } + + // Y a un BANNER Frame ? + if (isset($_POST['bannerframe']) && $_POST['bannerframe'] == 'on') { + Wootook::setConfig('engine/options/banner', true, 1, 1); + } else { + Wootook::setConfig('engine/options/banner', false, 1, 1); + } + + // Nom du Jeu + if (isset($_POST['game_name']) && !empty($_POST['game_name'])) { + Wootook::setConfig('game/general/name', $_POST['game_name'], 1, 1); + } + + // Adresse du Forum + if (isset($_POST['forum_url']) && !empty($_POST['forum_url'])) { + Wootook::setConfig('game/general/boards-url', $_POST['forum_url'], 1, 1); + } + + // Vitesse du Jeu + if (isset($_POST['game_speed']) && is_numeric($_POST['game_speed'])) { + Wootook::setConfig('game/speed/general', $_POST['game_speed'], 1, 1); + } + + // Vitesse des Flottes + if (isset($_POST['fleet_speed']) && is_numeric($_POST['fleet_speed'])) { + Wootook::setConfig('game/speed/fleet', $_POST['fleet_speed'], 1, 1); + } + + // Multiplicateur de Production + if (isset($_POST['resource_multiplier']) && is_numeric($_POST['resource_multiplier'])) { + Wootook::setConfig('game/resource/multiplier', $_POST['resource_multiplier'], 1, 1); + } + + // Taille de la planete mère + if (isset($_POST['initial_fields']) && is_numeric($_POST['initial_fields'])) { + Wootook::setConfig('resource/initial/fields', $_POST['initial_fields'], 1, 1); + } + + // Revenu de base Metal + if (isset($_POST['metal_basic_income']) && is_numeric($_POST['metal_basic_income'])) { + Wootook::setConfig('resource/initial/metal', $_POST['metal_basic_income'], 1, 1); + } + + // Revenu de base Cristal + if (isset($_POST['crystal_basic_income']) && is_numeric($_POST['crystal_basic_income'])) { + Wootook::setConfig('resource/initial/cristal', $_POST['crystal_basic_income'], 1, 1); + } + + // Revenu de base Deuterium + if (isset($_POST['deuterium_basic_income']) && is_numeric($_POST['deuterium_basic_income'])) { + Wootook::setConfig('resource/initial/deuterium', $_POST['deuterium_basic_income'], 1, 1); + } + + // Revenu de base Energie + if (isset($_POST['energy_basic_income']) && is_numeric($_POST['energy_basic_income'])) { + Wootook::setConfig('resource/initial/energy', $_POST['energy_basic_income'], 1, 1); + } + + // Lien supplémentaire dans le menu + if (isset($_POST['url_link_']) && is_numeric($_POST['url_link_'])) { + Wootook::setConfig('game/general/boards-url', $_POST['url_link_'], 1, 1); + } + + // Image de la bannière + if (isset($_POST['banner_source_post'])) { + Wootook::setConfig('engine/options/banner', $_POST['banner_source_post'], 1, 1); + } + // 1 point = ??? Ressources ? + if (isset($_POST['stat_settings']) && is_numeric($_POST['stat_settings'])) { + Wootook::setConfig('game/resource/multiplier', $_POST['stat_settings'], 1, 1); + } + // Activation -ou non- des annonces + if (isset($_POST['enable_announces_']) && is_numeric($_POST['enable_announces_'])) { + Wootook::setConfig('engine/options/announces', $_POST['enable_announces_'], 1, 1); + } + // Activation -ou non- du marchand + if (isset($_POST['enable_marchand_']) && is_numeric($_POST['enable_marchand_'])) { + Wootook::setConfig('engine/options/retailer', $_POST['enable_marchand_'], 1, 1); + } + // Activation -ou non- des notes + if (isset($_POST['enable_notes_']) && is_numeric($_POST['enable_notes_'])) { + Wootook::setConfig('engine/options/notes', $_POST['enable_notes_'], 1, 1); + } + // Nom du bot antimulti + if (isset($_POST['name_bot'])) { + Wootook::setConfig('engine/bot/name', $_POST['name_bot'], 1, 1); + } + // email du bot antimulti + if (isset($_POST['adress_bot'])) { + Wootook::setConfig('engine/bot/email', $_POST['adress_bot'], 1, 1); + } + + // Activation -ou non- des notes + if (isset($_POST['duration_ban']) && is_numeric($_POST['duration_ban'])) { + Wootook::setConfig('engine/ban/duration', $_POST['duration_ban'], 1, 1); + } + + // Activation -ou non- du bot + if (isset($_POST['bot_enable']) && is_numeric($_POST['bot_enable'])) { + Wootook::setConfig('engine/bot/active', $_POST['bot_enable'], 1, 1); + } + + // BBCode ou pas ? + if (isset($_POST['bbcode_field']) && is_numeric($_POST['bbcode_field'])) { + Wootook::setConfig('engine/options/bbcode', $_POST['bbcode_field'], 1, 1); + } + + AdminMessage('Options changees avec succes !', 'Succes', '?'); + } else { + $parse = $lang; + $parse['game_name'] = Wootook::getGameConfig('game/general/name'); + $parse['game_speed'] = Wootook::getGameConfig('game/speed/general'); + $parse['fleet_speed'] = Wootook::getGameConfig('game/speed/fleet'); + $parse['resource_multiplier'] = Wootook::getGameConfig('game/resource/multiplier'); + $parse['forum_url'] = Wootook::getGameConfig('game/general/boards-url'); + $parse['initial_fields'] = Wootook::getGameConfig('resource/initial/fields'); + $parse['metal_basic_income'] = Wootook::getGameConfig('resource/initial/metal'); + $parse['crystal_basic_income'] = Wootook::getGameConfig('resource/initial/cristal'); + $parse['deuterium_basic_income'] = Wootook::getGameConfig('resource/initial/deuterium'); + $parse['energy_basic_income'] = Wootook::getGameConfig('resource/initial/energy'); + $parse['enable_link'] = $gameConfig['link_enable']; + $parse['name_link'] = Wootook::getGameConfig('game/general/extra-url-title'); + $parse['url_link'] = Wootook::getGameConfig('game/general/extra-url'); + $parse['enable_announces'] = Wootook::getGameConfig('engine/options/announces'); + $parse['enable_marchand'] = Wootook::getGameConfig('engine/options/retailer'); + $parse['enable_notes'] = Wootook::getGameConfig('engine/options/notes'); + $parse['bot_name'] = Wootook::getGameConfig('engine/bot/name'); + $parse['bot_adress'] = Wootook::getGameConfig('engine/bot/email'); + $parse['ban_duration'] = Wootook::getGameConfig('engine/ban/duration'); + $parse['enable_bot'] = Wootook::getGameConfig('engine/bot/active'); + $parse['enable_bbcode'] = Wootook::getGameConfig('engine/options/bbcode'); + + $parse['banner_source_post'] = Wootook::getGameConfig('engine/options/banner'); + $parse['stat_settings'] = Wootook::getGameConfig('game/resource/multiplier'); + + $parse['closed'] = (!Wootook::getGameConfig('game/general/active')) ? " checked = 'checked' ":""; + $parse['close_reason'] = Wootook::getGameConfig('game/general/closing-message'); + + $parse['newsframe'] = (Wootook::getGameConfig('game/news/active')) ? " checked = 'checked' ":""; + $parse['NewsTextVal'] = Wootook::getGameConfig('game/news/content'); + + $parse['chatframe'] = ($gameConfig['OverviewExternChat'] == 1) ? " checked = 'checked' ":""; + $parse['ExtTchatVal'] = stripslashes( $gameConfig['OverviewExternChatCmd'] ); + + $parse['ga'] = (Wootook::getGameConfig('engine/options/ga')) ? " checked = 'checked' ":""; + $parse['ga_id'] = Wootook::getGameConfig('engine/options/ga-id'); + + $parse['bannerframe'] = ($gameConfig['ForumBannerFrame'] == 1) ? " checked = 'checked' ":""; + + $PageTPL = gettemplate('admin/options_body'); + $Page = parsetemplate($PageTPL, $parse); + + display($Page, $lang['adm_opt_title'], false, '', true); + } + } else { + AdminMessage($lang['sys_noalloaw'], $lang['sys_noaccess']); + } + return $Page; +} + +$Page = DisplayGameSettingsPage($user); + diff --git a/admin/statbuilder.php b/src/admin/statbuilder.php similarity index 89% rename from admin/statbuilder.php rename to src/admin/statbuilder.php index 4784fee..97caec7 100644 --- a/admin/statbuilder.php +++ b/src/admin/statbuilder.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ @@ -32,7 +32,7 @@ define('INSIDE' , true); define('INSTALL' , false); define('IN_ADMIN', true); -require_once dirname(dirname(__FILE__)) .'/common.php'; +require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php'; include(ROOT_PATH . 'admin/statfunctions.' . PHPEXT); @@ -42,14 +42,16 @@ if (strtolower(substr(PHP_SAPI, 0, 3)) == 'cli' || in_array($user['authlevel'], $StatDate = time(); // Rotation des statistiques - doquery ( "DELETE FROM {{table}} WHERE `stat_code` = '2';" , 'statpoints'); + doquery ( "DELETE FROM {{table}} WHERE `stat_code` >= '10';" , 'statpoints'); doquery ( "UPDATE {{table}} SET `stat_code` = `stat_code` + '1';" , 'statpoints'); $GameUsers = doquery("SELECT * FROM {{table}} WHERE authlevel<3", 'users'); + $resourceMultiplier = Wootook::getGameConfig('game/resource/multiplier'); + while ($CurUser = $GameUsers->fetch(PDO::FETCH_ASSOC)) { // Recuperation des anciennes statistiques - $OldStatRecord = doquery ("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `id_owner` = '".$CurUser['id']."';",'statpoints'); + $OldStatRecord = doquery ("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `id_owner` = '".$CurUser['id']."';", 'statpoints', true); if ($OldStatRecord) { $OldTotalRank = $OldStatRecord['total_rank']; $OldTechRank = $OldStatRecord['tech_rank']; @@ -69,7 +71,7 @@ if (strtolower(substr(PHP_SAPI, 0, 3)) == 'cli' || in_array($user['authlevel'], // Total des unitées consommée pour la recherche $Points = GetTechnoPoints ( $CurUser ); $TTechCount = $Points['TechCount']; - $TTechPoints = ($Points['TechPoint'] / $gameConfig['stat_settings']); + $TTechPoints = ($Points['TechPoint'] / $resourceMultiplier); // Totalisation des points accumulés par planete $TBuildCount = 0; @@ -81,24 +83,24 @@ if (strtolower(substr(PHP_SAPI, 0, 3)) == 'cli' || in_array($user['authlevel'], $GCount = $TTechCount; $GPoints = $TTechPoints; $UsrPlanets = doquery("SELECT * FROM {{table}} WHERE `id_owner` = '". $CurUser['id'] ."';", 'planets'); - while ($CurPlanet = mysql_fetch_assoc($UsrPlanets) ) { + while ($CurPlanet = $UsrPlanets->fetch(PDO::FETCH_ASSOC)) { $Points = GetBuildPoints ( $CurPlanet ); $TBuildCount += $Points['BuildCount']; $GCount += $Points['BuildCount']; - $PlanetPoints = ($Points['BuildPoint'] / $gameConfig['stat_settings']); - $TBuildPoints += ($Points['BuildPoint'] / $gameConfig['stat_settings']); + $PlanetPoints = ($Points['BuildPoint'] / $resourceMultiplier); + $TBuildPoints += ($Points['BuildPoint'] / $resourceMultiplier); $Points = GetDefensePoints ( $CurPlanet ); $TDefsCount += $Points['DefenseCount'];; $GCount += $Points['DefenseCount']; - $PlanetPoints += ($Points['DefensePoint'] / $gameConfig['stat_settings']); - $TDefsPoints += ($Points['DefensePoint'] / $gameConfig['stat_settings']); + $PlanetPoints += ($Points['DefensePoint'] / $resourceMultiplier); + $TDefsPoints += ($Points['DefensePoint'] / $resourceMultiplier); $Points = GetFleetPoints ( $CurPlanet ); $TFleetCount += $Points['FleetCount']; $GCount += $Points['FleetCount']; - $PlanetPoints += ($Points['FleetPoint'] / $gameConfig['stat_settings']); - $TFleetPoints += ($Points['FleetPoint'] / $gameConfig['stat_settings']); + $PlanetPoints += ($Points['FleetPoint'] / $resourceMultiplier); + $TFleetPoints += ($Points['FleetPoint'] / $resourceMultiplier); $GPoints += $PlanetPoints; $QryUpdatePlanet = "UPDATE {{table}} SET "; @@ -134,7 +136,7 @@ if (strtolower(substr(PHP_SAPI, 0, 3)) == 'cli' || in_array($user['authlevel'], $Rank = 1; $RankQry = doquery("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' ORDER BY `tech_points` DESC;", 'statpoints'); - while ($TheRank = mysql_fetch_assoc($RankQry) ) { + while ($TheRank = $RankQry->fetch(PDO::FETCH_ASSOC)) { $QryUpdateStats = "UPDATE {{table}} SET "; $QryUpdateStats .= "`tech_rank` = '". $Rank ."' "; $QryUpdateStats .= "WHERE "; @@ -145,7 +147,7 @@ if (strtolower(substr(PHP_SAPI, 0, 3)) == 'cli' || in_array($user['authlevel'], $Rank = 1; $RankQry = doquery("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' ORDER BY `build_points` DESC;", 'statpoints'); - while ($TheRank = mysql_fetch_assoc($RankQry) ) { + while ($TheRank = $RankQry->fetch(PDO::FETCH_ASSOC) ) { $QryUpdateStats = "UPDATE {{table}} SET "; $QryUpdateStats .= "`build_rank` = '". $Rank ."' "; $QryUpdateStats .= "WHERE "; @@ -156,7 +158,7 @@ if (strtolower(substr(PHP_SAPI, 0, 3)) == 'cli' || in_array($user['authlevel'], $Rank = 1; $RankQry = doquery("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' ORDER BY `defs_points` DESC;", 'statpoints'); - while ($TheRank = mysql_fetch_assoc($RankQry) ) { + while ($TheRank = $RankQry->fetch(PDO::FETCH_ASSOC)) { $QryUpdateStats = "UPDATE {{table}} SET "; $QryUpdateStats .= "`defs_rank` = '". $Rank ."' "; $QryUpdateStats .= "WHERE "; @@ -167,7 +169,7 @@ if (strtolower(substr(PHP_SAPI, 0, 3)) == 'cli' || in_array($user['authlevel'], $Rank = 1; $RankQry = doquery("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' ORDER BY `fleet_points` DESC;", 'statpoints'); - while ($TheRank = mysql_fetch_assoc($RankQry) ) { + while ($TheRank = $RankQry->fetch(PDO::FETCH_ASSOC)) { $QryUpdateStats = "UPDATE {{table}} SET "; $QryUpdateStats .= "`fleet_rank` = '". $Rank ."' "; $QryUpdateStats .= "WHERE "; @@ -178,7 +180,7 @@ if (strtolower(substr(PHP_SAPI, 0, 3)) == 'cli' || in_array($user['authlevel'], $Rank = 1; $RankQry = doquery("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' ORDER BY `total_points` DESC;", 'statpoints'); - while ($TheRank = mysql_fetch_assoc($RankQry) ) { + while ($TheRank = $RankQry->fetch(PDO::FETCH_ASSOC)) { $QryUpdateStats = "UPDATE {{table}} SET "; $QryUpdateStats .= "`total_rank` = '". $Rank ."' "; $QryUpdateStats .= "WHERE "; @@ -192,7 +194,7 @@ if (strtolower(substr(PHP_SAPI, 0, 3)) == 'cli' || in_array($user['authlevel'], while ($CurAlly = $GameAllys->fetch(PDO::FETCH_ASSOC)) { // Recuperation des anciennes statistiques - $OldStatRecord = doquery ("SELECT * FROM {{table}} WHERE `stat_type` = '2' AND `id_owner` = '".$CurAlly['id']."';",'statpoints'); + $OldStatRecord = doquery ("SELECT * FROM {{table}} WHERE `stat_type` = '2' AND `id_owner` = '".$CurAlly['id']."';",'statpoints', true); if ($OldStatRecord) { $OldTotalRank = $OldStatRecord['total_rank']; $OldTechRank = $OldStatRecord['tech_rank']; diff --git a/admin/statfunctions.php b/src/admin/statfunctions.php similarity index 87% rename from admin/statfunctions.php rename to src/admin/statfunctions.php index 0e1ea28..db1a760 100644 --- a/admin/statfunctions.php +++ b/src/admin/statfunctions.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ @@ -36,7 +36,7 @@ function GetTechnoPoints ( $CurrentUser ) { foreach ( $reslist['tech'] as $n => $Techno ) { if ( $CurrentUser[ $resource[ $Techno ] ] > 0 ) { for ( $Level = 1; $Level < $CurrentUser[ $resource[ $Techno ] ]; $Level++ ) { - $Units = $pricelist[ $Techno ]['metal'] + $pricelist[ $Techno ]['crystal'] + $pricelist[ $Techno ]['deuterium']; + $Units = $pricelist[ $Techno ]['metal'] + $pricelist[ $Techno ]['cristal'] + $pricelist[ $Techno ]['deuterium']; $LevelMul = pow( $pricelist[ $Techno ]['factor'], $Level ); $TechPoints += ($Units * $LevelMul); $TechCounts += 1; @@ -57,7 +57,7 @@ function GetBuildPoints ( $CurrentPlanet ) { foreach($reslist['build'] as $n => $Building) { if ( $CurrentPlanet[ $resource[ $Building ] ] > 0 ) { for ( $Level = 1; $Level < $CurrentPlanet[ $resource[ $Building ] ]; $Level++ ) { - $Units = $pricelist[ $Building ]['metal'] + $pricelist[ $Building ]['crystal'] + $pricelist[ $Building ]['deuterium']; + $Units = $pricelist[ $Building ]['metal'] + $pricelist[ $Building ]['cristal'] + $pricelist[ $Building ]['deuterium']; $LevelMul = pow( $pricelist[ $Building ]['factor'], $Level ); $BuildPoints += ($Units * $LevelMul); $BuildCounts += 1; @@ -77,7 +77,7 @@ function GetDefensePoints ( $CurrentPlanet ) { $DefensePoints = 0; foreach($reslist['defense'] as $n => $Defense) { if ($CurrentPlanet[ $resource[ $Defense ] ] > 0) { - $Units = $pricelist[ $Defense ]['metal'] + $pricelist[ $Defense ]['crystal'] + $pricelist[ $Defense ]['deuterium']; + $Units = $pricelist[ $Defense ]['metal'] + $pricelist[ $Defense ]['cristal'] + $pricelist[ $Defense ]['deuterium']; $DefensePoints += ($Units * $CurrentPlanet[ $resource[ $Defense ] ]); $DefenseCounts += $CurrentPlanet[ $resource[ $Defense ] ]; } @@ -95,7 +95,7 @@ function GetFleetPoints ( $CurrentPlanet ) { $FleetPoints = 0; foreach($reslist['fleet'] as $n => $Fleet) { if ($CurrentPlanet[ $resource[ $Fleet ] ] > 0) { - $Units = $pricelist[ $Fleet ]['metal'] + $pricelist[ $Fleet ]['crystal'] + $pricelist[ $Fleet ]['deuterium']; + $Units = $pricelist[ $Fleet ]['metal'] + $pricelist[ $Fleet ]['cristal'] + $pricelist[ $Fleet ]['deuterium']; $FleetPoints += ($Units * $CurrentPlanet[ $resource[ $Fleet ] ]); $FleetCounts += $CurrentPlanet[ $resource[ $Fleet ] ]; } diff --git a/admin/unbanned.php b/src/admin/unbanned.php similarity index 86% rename from admin/unbanned.php rename to src/admin/unbanned.php index 8636506..8b0967d 100644 --- a/admin/unbanned.php +++ b/src/admin/unbanned.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,14 +24,14 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); define('IN_ADMIN', true); -require_once dirname(dirname(__FILE__)) .'/common.php'; +require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php'; if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) { diff --git a/admin/userlist.php b/src/admin/userlist.php similarity index 86% rename from admin/userlist.php rename to src/admin/userlist.php index 922b23a..84fb74f 100644 --- a/admin/userlist.php +++ b/src/admin/userlist.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,19 +24,23 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); define('IN_ADMIN', true); -require_once dirname(dirname(__FILE__)) .'/common.php'; +require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php'; if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) { includeLang('admin'); if ($_GET['cmd'] == 'dele') { - DeleteSelectedUser ( $_GET['user'] ); + $player = new Wootook_Player_Model_Entity(); + $player->load(intval($_GET['user'])); + if ($player->getId()) { + $player->delete(); + } } if ($_GET['cmd'] == 'sort') { $TypeSort = $_GET['type']; diff --git a/admin/variables.php b/src/admin/variables.php similarity index 83% rename from admin/variables.php rename to src/admin/variables.php index 10599ea..bcc6642 100644 --- a/admin/variables.php +++ b/src/admin/variables.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,14 +24,14 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); define('IN_ADMIN', true); -require_once dirname(dirname(__FILE__)) .'/common.php'; +require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php'; if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR, LEVEL_MODERATOR))) { diff --git a/alliance.php b/src/alliance.php similarity index 88% rename from alliance.php rename to src/alliance.php index b3b716f..6b815fd 100644 --- a/alliance.php +++ b/src/alliance.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,16 +24,16 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSTALL' , false); define('INSIDE' , true); -require_once dirname(__FILE__) .'/common.php'; +require_once dirname(__FILE__) .'/application/bootstrap.php'; -$user = Legacies_Empire_Model_User::getSingleton(); -$db = Legacies_Database::getSingleton(); +$user = Wootook_Player_Model_Session::getSingleton()->getPlayer(); +$db = Wootook_Core_Database_ConnectionManager::getSingleton()->getConnection(Wootook_Core_Database_ConnectionManager::DEFAULT_CONNECTION_NAME); if(!$user->getId()){ echo ''; } -$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 && $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; @@ -671,7 +672,6 @@ elseif ($user->getData('ally_id') != 0 && $user->getData('ally_request') == 0) { foreach($ally_ranks as $a => $b) { if ($ally['ally_owner'] == $user->getId()) { $lang['id'] = $a; - $lang['delete'] = "\"{$lang['Delete_range']}\""; $lang['r0'] = $b['name']; $lang['a'] = $a; $lang['r1'] = ""; //{$b[1]} @@ -688,7 +688,6 @@ elseif ($user->getData('ally_id') != 0 && $user->getData('ally_request') == 0) { } else { $lang['id'] = $a; $lang['r0'] = $b['name']; - $lang['delete'] = "\"{$lang['Delete_range']}\""; $lang['a'] = $a; $lang['r1'] = "-"; $lang['r2'] = ""; @@ -721,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; } @@ -748,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']) . " @@ -808,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=''; @@ -848,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_Player_Model_Entity::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(); } } @@ -861,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`"; @@ -930,7 +923,7 @@ elseif ($user->getData('ally_id') != 0 && $user->getData('ally_request') == 0) { $lang['Set_range'] = 'Set rang'; $f['Set_range'] = $lang['Set_range']; $f['Expel_user'] = $lang['Expel_user']; - + $f['You_are_sure_want_kick_to'] = str_replace("%s", $u['username'], $lang['You_are_sure_want_kick_to']); $f['id'] = $u['id']; $u["functions"] = parsetemplate($f_template, $f); @@ -999,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 @@ -1017,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,
    L'Alliance {$ally['ally_name']} a accepté votre candidature.
    Charte:
    {$_POST['text']}"; + $message = "Bonjour,
    L'Alliance {$ally['ally_name']} a accepté votre candidature.
    Charte:
    {$request->getPost('text')}"; // Send a message to the new member of the alliance doquery("INSERT INTO {{table}} SET `message_owner`=" .$db->quote($show).", @@ -1031,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,
    L'Alliance {$ally['ally_name']} a refusé votre candidature.
    Raison:
    {$_POST['text']}"; + $message = "Bonjour,
    L'Alliance {$ally['ally_name']} a refusé votre candidature.
    Raison:
    {$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).", @@ -1104,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'); } @@ -1132,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'); } diff --git a/annonce.php b/src/annonce.php similarity index 63% rename from annonce.php rename to src/annonce.php index bfa6b9f..9c0b506 100644 --- a/annonce.php +++ b/src/annonce.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,42 +24,33 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); -require_once dirname(__FILE__) .'/common.php'; -$users = doquery("SELECT * FROM {{table}} WHERE id='".$user['id']."';", 'users'); -$annonce = doquery("SELECT * FROM {{table}} ", 'annonce'); -$action = $_GET['action']; +require_once dirname(__FILE__) .'/application/bootstrap.php'; + +$readAdapter = Wootook_Core_Database_ConnectionManager::getSingleton()->getConnection('core_read'); +$writeAdapter = Wootook_Core_Database_ConnectionManager::getSingleton()->getConnection('core_write'); + +$action = isset($_GET['action']) ? $_GET['action'] : null; if ($action == 5) { - $metalvendre = $_POST['metalvendre']; - $cristalvendre = $_POST['cristalvendre']; - $deutvendre = $_POST['deutvendre']; - - $metalsouhait = $_POST['metalsouhait']; - $cristalsouhait = $_POST['cristalsouhait']; - $deutsouhait = $_POST['deutsouhait']; - - while ($v_annonce = $users->fetch(PDO::FETCH_BOTH)) { - $user = $v_annonce['username']; - $galaxie = $v_annonce['galaxy']; - $systeme = $v_annonce['system']; - } - - doquery("INSERT INTO {{table}} SET -user='{$user}', -galaxie='{$galaxie}', -systeme='{$systeme}', -metala='{$metalvendre}', -cristala='{$cristalvendre}', -deuta='{$deutvendre}', -metals='{$metalsouhait}', -cristals='{$cristalsouhait}', -deuts='{$deutsouhait}'" , "annonce"); + $writeAdapter->insert() + ->into($writeAdapter->getTable('annonce')) + ->set('user', $user->getUsername()) + ->set('galaxie', $planet->getGalaxy()) + ->set('systeme', $planet->getSystem()) + ->set('metala', Wootook::getRequest()->getParam('metalvendre')) + ->set('cristala', Wootook::getRequest()->getParam('cristalvendre')) + ->set('deuta', Wootook::getRequest()->getParam('deutvendre')) + ->set('metals', Wootook::getRequest()->getParam('metalsouhait')) + ->set('cristals', Wootook::getRequest()->getParam('cristalsouhait')) + ->set('deuts', Wootook::getRequest()->getParam('deutsouhait')) + ->execute() + ; $page2 .= << @@ -73,7 +64,7 @@ HTML; } if ($action != 5) { - $annonce = doquery("SELECT * FROM {{table}} ORDER BY `id` DESC ", "annonce"); + $statement = $readAdapter->select()->from(array('annonce' => $readAdapter->getTable('annonce')))->order('id', 'DESC')->prepare(); $page2 = "
    @@ -82,12 +73,9 @@ if ($action != 5) { Petites Annonces Infos de livraisonRessources à vendreRessources souhaitéesAction VendeurGalaxieSystèmeMétalCristalDeuteriumMétalCristalDeuteriumDelet - - - - "; - while ($b = $annonce->fetch(PDO::FETCH_BOTH)) { + + foreach ($statement as $b) { $page2 .= ' '; $page2 .= $b["user"] ; $page2 .= ''; @@ -119,4 +107,3 @@ if ($action != 5) { display($page2); } -?> \ No newline at end of file diff --git a/annonce2.php b/src/annonce2.php similarity index 89% rename from annonce2.php rename to src/annonce2.php index 9c4a631..29baec1 100644 --- a/annonce2.php +++ b/src/annonce2.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,13 +24,13 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); -require_once dirname(__FILE__) .'/common.php'; +require_once dirname(__FILE__) .'/application/bootstrap.php'; $actions = $_GET['action']; diff --git a/common.php b/src/application/bootstrap.php similarity index 60% rename from common.php rename to src/application/bootstrap.php index d7aadaa..b0b3c9c 100644 --- a/common.php +++ b/src/application/bootstrap.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,13 +24,15 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ -defined('BCNUMBERS') || define('BCNUMBERS', true); -defined('DEPRECATION') || define('DEPRECATION', true); -defined('DEBUG') || define('DEBUG', true); +if (!defined('PHP_VERSION_ID')) { + $version = explode('.',PHP_VERSION); + define('PHP_VERSION_ID', (((int)$version[0]) * 10000 + ((int)$version[1]) * 100 + ((int)$version[2]))); + unset($version); +} if (!defined('DEBUG') && ($env = getenv('DEBUG')) !== false && in_array(strtolower($env), array('1', 'on', 'true'))) { define('DEBUG', true); @@ -57,12 +59,12 @@ if (!defined('DEBUG')) { @error_reporting(E_ALL | E_STRICT); } -defined('ROOT_PATH') || define('ROOT_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR); -defined('APPLICATION_PATH') || define('APPLICATION_PATH', ROOT_PATH . 'includes' . DIRECTORY_SEPARATOR . 'application' . DIRECTORY_SEPARATOR); +defined('ROOT_PATH') || define('ROOT_PATH', dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR); +defined('APPLICATION_PATH') || define('APPLICATION_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR); -defined('PHPEXT') || define('PHPEXT', require 'extension.inc'); +defined('PHPEXT') || define('PHPEXT', 'php'); -defined('VERSION') || define('VERSION', '2011.1'); +defined('VERSION') || define('VERSION', '1.5.0-beta2'); set_include_path(implode(PATH_SEPARATOR, array( APPLICATION_PATH . DIRECTORY_SEPARATOR . 'code' . DIRECTORY_SEPARATOR . 'libraries', @@ -76,52 +78,63 @@ function __autoload($class) { include_once str_replace('_', '/', $class) . '.php'; } -Legacies_Core_Time::init(); -Legacies_Core_ErrorProfiler::register(); +if (defined('IN_ADMIN')) { + $website = new Wootook_Core_Model_Website(); + $website->setId(0)->setData('code', 'admin'); + Wootook::addWebsite($website); + Wootook::setDefaultWebsite($website); -if (0 === filesize(ROOT_PATH . 'config.php')) { - header('Location: install/'); - die(); + $game = new Wootook_Core_Model_Game(); + $game->setId(0)->setData('code', 'admin')->setData('website_id', $website->getId()); + Wootook::addGame($game); + Wootook::setDefaultGame($game); } -foreach (include ROOT_PATH . 'includes/data/events.php' as $event => $listenerList) { - foreach ($listenerList as $listener) { - Legacies::registerListener($event, $listener); - } +include ROOT_PATH . 'includes/constants.php'; + +if (defined('DEBUG')) { + Wootook_Core_ErrorProfiler::register(); +} +Wootook_Core_Helper_Config_Events::registerEvents(); + +if (!Wootook::$isInstalled) { + Wootook::getResponse() + ->setRedirect(Wootook::getStaticUrl('install/'), Wootook_Core_Mvc_Controller_Response_Http::REDIRECT_TEMPORARY) + ->sendHeaders(); + exit(0); } $lang = array(); -define('TEMPLATE_DIR', realpath(ROOT_PATH . '/templates/')); -define('TEMPLATE_NAME', 'OpenGame'); define('DEFAULT_LANG', 'fr'); -include(ROOT_PATH . 'includes/debug.class.'.PHPEXT); -$debug = new Debug(); - -include(ROOT_PATH . 'includes/constants.' . PHPEXT); include(ROOT_PATH . 'includes/functions.' . PHPEXT); include(ROOT_PATH . 'includes/unlocalised.' . PHPEXT); include(ROOT_PATH . 'includes/todofleetcontrol.' . PHPEXT); include(ROOT_PATH . 'language/' . DEFAULT_LANG . '/lang_info.cfg'); include(ROOT_PATH . 'includes/vars.' . PHPEXT); -include(ROOT_PATH . 'db/mysql.' . PHPEXT); include(ROOT_PATH . 'includes/strings.' . PHPEXT); -$gameConfig = Legacies_Core_Model_Config::getSingleton(); -if (isset($gameConfig['cookie_name']) && !empty($gameConfig['cookie_name'])) { - Legacies_Empire_Model_User::setCookieName($gameConfig['cookie_name']); -} -$user = Legacies_Empire_Model_User::getSingleton(); +$user = Wootook_Player_Model_Session::getSingleton()->getPlayer(); if (!defined('DISABLE_IDENTITY_CHECK')) { - if (($user === null || !$user->getId())) { - header('Location: login.php'); + if ($user === null || !$user->getId()) { + Wootook::getResponse() + ->setRedirect(Wootook::getUrl('player/account/login')) + ->sendHeaders(); exit(0); } - if ($gameConfig->isEnabled() && $user !== null && !in_array($user->getData('authlevel'), array(LEVEL_ADMIN, LEVEL_MODERATOR, LEVEL_OPERATOR))) { - message(stripslashes($gameConfig->getData('close_reason')), $gameConfig->getData('game_name')); + //var_dump(Wootook::getGameConfig('game/general/active')); + if (!Wootook::getGameConfig('game/general/active')/* && !in_array($user->getData('authlevel'), array(LEVEL_ADMIN, LEVEL_MODERATOR, LEVEL_OPERATOR))*/) { + $layout = new Wootook_Core_Model_Layout(Wootook_Core_Model_Layout::DOMAIN_FRONTEND); + $layout->load('message'); + + $block = $layout->getBlock('message'); + $block['title'] = Wootook::__('Game is disabled.'); + $block['message'] = Wootook::getGameConfig('game/general/closing-message'); + + echo $layout->render(); exit(0); } } @@ -143,8 +156,8 @@ if (($user !== null && $user->getId())) { /* * Update planet resources and constructions */ - Legacies::dispatchEvent('planet.update', array( + Wootook::dispatchEvent('planet.update', array( 'planet' => $planet )); $planet->save(); -} \ No newline at end of file +} diff --git a/includes/application/code/community/.placeholder b/src/application/cache/.placeholder similarity index 100% rename from includes/application/code/community/.placeholder rename to src/application/cache/.placeholder diff --git a/includes/application/code/local/.placeholder b/src/application/code/community/.placeholder similarity index 100% rename from includes/application/code/local/.placeholder rename to src/application/code/community/.placeholder diff --git a/src/application/code/core/Legacies/Core/Unit.php b/src/application/code/core/Legacies/Core/Unit.php new file mode 100644 index 0000000..8633e2d --- /dev/null +++ b/src/application/code/core/Legacies/Core/Unit.php @@ -0,0 +1,36 @@ + + * Copyright (c) 2011-Present, Grégory PLANCHAT * All rights reserved. * * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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. * @@ -18,13 +18,13 @@ * 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 General Public License + * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ @@ -99,6 +99,7 @@ class Legacies_Empire const ID_RESEARCH_INTERGALACTIC_RESEARCH_NETWORK = 123; const ID_RESEARCH_EXPEDITION_TECHNOLOGY = 124; const ID_RESEARCH_ASTROPHYSICS = 124; + const ID_RESEARCH_ORE_MINING = 125; const ID_RESEARCH_GRAVITON_TECHNOLOGY = 199; const ID_SHIP_LIGHT_TRANSPORT = 202; @@ -116,6 +117,7 @@ class Legacies_Empire const ID_SHIP_DEATH_STAR = 214; const ID_SHIP_BATTLECRUISER = 215; const ID_SHIP_SUPERNOVA = 216; + const ID_SHIP_ORE_MININER = 217; const ID_DEFENSE_ROCKET_LAUNCHER = 401; const ID_DEFENSE_LIGHT_LASER = 402; @@ -144,10 +146,11 @@ class Legacies_Empire const ID_MISSION_DESTROY = 9; const ID_MISSION_MISSILES = 10; const ID_MISSION_EXPEDITION = 15; + const ID_MISSION_ORE_MINING = 16; public static function getFieldName($id) { - $fieldsAlias = Legacies_Empire_Model_Game_FieldsAlias::getSingleton(); + $fieldsAlias = Wootook_Empire_Helper_Config_FieldsAlias::getSingleton(); if (!isset($fieldsAlias[$id])) { return null; @@ -155,4 +158,4 @@ class Legacies_Empire return $fieldsAlias[$id]; } -} \ No newline at end of file +} diff --git a/src/application/code/core/Legacies/Empire/Block/Planet/ResearchLab.php b/src/application/code/core/Legacies/Empire/Block/Planet/ResearchLab.php new file mode 100644 index 0000000..1c995b4 --- /dev/null +++ b/src/application/code/core/Legacies/Empire/Block/Planet/ResearchLab.php @@ -0,0 +1,76 @@ + + * 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 . + * + * --> 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 Legacies_Empire_Block_Planet_ResearchLab + extends Wootook_Empire_Block_Planet_BuilderAbstract +{ + protected $_planet = null; + + public function setPlanet(Wootook_Empire_Model_Planet $planet) + { + $this->_planet = $planet; + + return $this; + } + + public function getPlanet() + { + if ($this->_planet === null) { + $this->_planet = Wootook_Player_Model_Session::getSingleton()->getPlayer() + ->getCurrentPlanet() + ; + } + return $this->_planet; + } + + public function _initChildBlocks() + { + $types = Wootook_Empire_Helper_Config_Types::getSingleton(); + + /** @var Wootook_Core_Block_Concat $parentBlock */ + $parentBlock = $this->getLayout()->getBlock('item-list.items'); + foreach ($types->getData(Legacies_Empire::TYPE_RESEARCH) as $itemId) { + if (!$this->getPlanet()->getResearchLab()->checkAvailability($itemId)) { + continue; + } + + $block = $this->getItemBlock($itemId); + $parentBlock->setPartial($block->getName(), $block); + } + + return $this; + } +} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Empire/Block/Planet/ResearchLab/Item.php b/src/application/code/core/Legacies/Empire/Block/Planet/ResearchLab/Item.php similarity index 52% rename from includes/application/code/core/Legacies/Empire/Block/Planet/ResearchLab/Item.php rename to src/application/code/core/Legacies/Empire/Block/Planet/ResearchLab/Item.php index c4d126d..8d5e448 100644 --- a/includes/application/code/core/Legacies/Empire/Block/Planet/ResearchLab/Item.php +++ b/src/application/code/core/Legacies/Empire/Block/Planet/ResearchLab/Item.php @@ -1,11 +1,45 @@ + * 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 . + * + * --> 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 Legacies_Empire_Block_Planet_ResearchLab_Item - extends Legacies_Empire_Block_Planet_Builder_ItemAbstract + extends Wootook_Empire_Block_Planet_Builder_ItemAbstract { public function getLevel() { - return $this->getUser()->getElement($this->getItemId()); + return $this->getPlayer()->getElement($this->getItemId()); } public function getResourcesNeeded($level) @@ -29,7 +63,7 @@ class Legacies_Empire_Block_Planet_ResearchLab_Item $resourceConfig = array(); foreach ($resources as $resourceId => $resourceValue) { - $resourceConfig[$resourceId] = new Legacies_Object(array( + $resourceConfig[$resourceId] = new Wootook_Object(array( 'resource_id' => $resourceId, 'value' => $resourceValue )); diff --git a/src/application/code/core/Legacies/Empire/Block/Planet/ResearchLab/Queue.php b/src/application/code/core/Legacies/Empire/Block/Planet/ResearchLab/Queue.php new file mode 100644 index 0000000..a880688 --- /dev/null +++ b/src/application/code/core/Legacies/Empire/Block/Planet/ResearchLab/Queue.php @@ -0,0 +1,48 @@ + + * 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 . + * + * --> 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 Legacies_Empire_Block_Planet_ResearchLab_Queue + extends Wootook_Empire_Block_Planet_Builder_QueueAbstract +{ + public function getQueue() + { + return $this->getPlanet()->getResearchLab()->getBuilder(); + } + + public function isEmpty() + { + return $this->getQueue()->count() == 0; + } +} \ No newline at end of file diff --git a/src/application/code/core/Legacies/Empire/Block/Planet/ResearchLab/Queue/Item.php b/src/application/code/core/Legacies/Empire/Block/Planet/ResearchLab/Queue/Item.php new file mode 100644 index 0000000..a825cfa --- /dev/null +++ b/src/application/code/core/Legacies/Empire/Block/Planet/ResearchLab/Queue/Item.php @@ -0,0 +1,101 @@ + + * 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 . + * + * --> 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 Legacies_Empire_Block_Planet_ResearchLab_Queue_Item + extends Wootook_Empire_Block_Planet_Builder_Queue_ItemAbstract +{ + protected $_itemIdField = 'technology_id'; + + public function getLevel() + { + return $this->getPlayer()->getElement($this->getItemId()); + } + + public function getResourcesNeeded($level) + { + return $this->getPlanet()->getResearchLab()->getResourcesNeeded($this->getItemId(), $this->getQueuedLevel() + 1); + } + + public function getQueuedLevel() + { + return $this->getPlanet()->getResearchLab()->getResearchLevelQueued($this->getItemId()); + } + + public function getBuildingTime($level) + { + return $this->getPlanet()->getResearchLab()->getBuildingTime($this->getItemId(), $level); + } + + public function getBuildingRemainingTime() + { + $totalTime = $this->getPlanet()->getResearchLab() + ->getResearchTime($this->getItemId(), $this->getItemQueuedLevel()); + $item = $this->getItem(); + + return $totalTime - ($item->getData('created_at') - $item->getData('updated_at')); + } + + public function getResourcesConfigForLevel($level) + { + $resources = $this->getResourcesNeeded($level); + + $resourceConfig = array(); + foreach ($resources as $resourceId => $resourceValue) { + $resourceConfig[$resourceId] = new Wootook_Object(array( + 'resource_id' => $resourceId, + 'value' => $resourceValue + )); + + $amount = $this->getPlanet()->getResourceAmount($resourceId); + if (Math::comp($amount, $resourceValue) < 0) { + $resourceConfig[$resourceId]->setData('requirement', Math::sub($amount, $resourceValue)); + } else { + $resourceConfig[$resourceId]->setData('overflow', Math::sub($amount, $resourceValue)); + } + } + return $resourceConfig; + } + + public function getResourcesConfigForNextLevel() + { + return $this->getResourcesConfigForLevel($this->getNextLevel()); + } + + public function getBuildingTimeForNextLevel() + { + return $this->getBuildingTime($this->getNextLevel()); + } +} diff --git a/src/application/code/core/Legacies/Empire/Block/Planet/Shipyard.php b/src/application/code/core/Legacies/Empire/Block/Planet/Shipyard.php new file mode 100644 index 0000000..c33a6e4 --- /dev/null +++ b/src/application/code/core/Legacies/Empire/Block/Planet/Shipyard.php @@ -0,0 +1,119 @@ + + * 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 . + * + * --> 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 Legacies_Empire_Block_Planet_Shipyard + extends Wootook_Empire_Block_Planet_BuilderAbstract +{ + protected $_planet = null; + protected $_type = Legacies_Empire::TYPE_SHIP; + + protected $_allowedTypes = array( + Legacies_Empire::TYPE_SHIP, + Legacies_Empire::TYPE_DEFENSE + ); + + public function setPlanet(Wootook_Empire_Model_Planet $planet) + { + $this->_planet = $planet; + + return $this; + } + + public function getPlanet() + { + if ($this->_planet === null) { + $this->_planet = Wootook_Player_Model_Session::getSingleton()->getPlayer() + ->getCurrentPlanet() + ; + } + return $this->_planet; + } + + public function setAllowedTypes($types) + { + if (is_array($types)) { + $this->_allowedTypes = $types; + } + return $this; + } + + public function addAllowedType($type) + { + if (!in_array($type, $this->_allowedTypes)) { + $this->_allowedTypes[] = $type; + } + return $this; + } + + public function getAllowedTypes() + { + return $this->_allowedTypes; + } + + public function setType($type) + { + if (in_array($type, $this->_allowedTypes)) { + $this->_type = $type; + } + return $this; + } + + public function getType() + { + return $this->_type; + } + + public function _initChildBlocks() + { + $types = Wootook_Empire_Helper_Config_Types::getSingleton(); + + if (!$this->getPlanet() || !$this->getPlanet()->getShipyard()) { + return $this; + } + + /** @var Wootook_Core_Block_Concat $parentBlock */ + $parentBlock = $this->getLayout()->getBlock('item-list.items'); + foreach ($types->getData($this->getType()) as $itemId) { + if (!$this->getPlanet()->getShipyard()->checkAvailability($itemId)) { + continue; + } + + $block = $this->getItemBlock($itemId); + $parentBlock->setPartial($block->getName(), $block); + } + + return $this; + } +} diff --git a/src/application/code/core/Legacies/Empire/Block/Planet/Shipyard/Item.php b/src/application/code/core/Legacies/Empire/Block/Planet/Shipyard/Item.php new file mode 100644 index 0000000..0b42ac2 --- /dev/null +++ b/src/application/code/core/Legacies/Empire/Block/Planet/Shipyard/Item.php @@ -0,0 +1,85 @@ + + * 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 . + * + * --> 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 Legacies_Empire_Block_Planet_Shipyard_Item + extends Wootook_Empire_Block_Planet_Builder_ItemAbstract +{ + public function getQty() + { + return $this->getPlanet()->getElement($this->getItemId()); + } + + public function getClass() + { + return $this->getLabel('class'); + } + + public function getResourcesNeeded($qty) + { + return $this->getPlanet()->getShipyard()->getResourcesNeeded($this->getItemId(), $qty); + } + + public function getBuildingTime($qty) + { + return $this->getPlanet()->getShipyard()->getBuildingTime($this->getItemId(), $qty); + } + + public function getMaximumBuildableElementsCount() + { + return $this->getPlanet()->getShipyard()->getMaximumBuildableElementsCount($this->getItemId()); + } + + public function getResourcesConfigForQty($qty) + { + $resources = $this->getResourcesNeeded($qty); + + $resourceConfig = array(); + foreach ($resources as $resourceId => $resourceValue) { + $resourceConfig[$resourceId] = new Wootook_Object(array( + 'resource_id' => $resourceId, + 'value' => $resourceValue + )); + + $amount = $this->getPlanet()->getResourceAmount($resourceId); + if (Math::comp($amount, $resourceValue) < 0) { + $resourceConfig[$resourceId]->setData('requirement', Math::sub($amount, $resourceValue)); + } else { + $resourceConfig[$resourceId]->setData('overflow', Math::sub($amount, $resourceValue)); + } + } + return $resourceConfig; + } +} diff --git a/src/application/code/core/Legacies/Empire/Block/Planet/Shipyard/Queue.php b/src/application/code/core/Legacies/Empire/Block/Planet/Shipyard/Queue.php new file mode 100644 index 0000000..ea621fa --- /dev/null +++ b/src/application/code/core/Legacies/Empire/Block/Planet/Shipyard/Queue.php @@ -0,0 +1,49 @@ + + * 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 . + * + * --> 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 Legacies_Empire_Block_Planet_Shipyard_Queue + extends Wootook_Empire_Block_Planet_Builder_QueueAbstract +{ + public function getQueue() + { + return $this->getPlanet()->getShipyard()->getBuilder(); + } + + public function isEmpty() + { + return $this->getQueue()->count() == 0; + } +} \ No newline at end of file diff --git a/src/application/code/core/Legacies/Empire/Block/Planet/Shipyard/Queue/Item.php b/src/application/code/core/Legacies/Empire/Block/Planet/Shipyard/Queue/Item.php new file mode 100644 index 0000000..64eec1d --- /dev/null +++ b/src/application/code/core/Legacies/Empire/Block/Planet/Shipyard/Queue/Item.php @@ -0,0 +1,101 @@ + + * 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 . + * + * --> 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 Legacies_Empire_Block_Planet_Shipyard_Queue_Item + extends Wootook_Empire_Block_Planet_Builder_Queue_ItemAbstract +{ + protected $_itemIdField = 'ship_id'; + + public function getQty() + { + return $this->getPlanet()->getElement($this->getItemId()); + } + + public function getResourcesNeeded($level) + { + return $this->getPlanet()->getShipyard()->getResourcesNeeded($this->getItemId(), 1); + } + + public function getItemQueuedQty() + { + return $this->getItem()->getData('qty'); + } + + public function getBuildingTime($qty) + { + return $this->getPlanet()->getShipyard()->getBuildingTime($this->getItemId(), $qty); + } + + public function getBuildingRemainingTime() + { + $totalTime = $this->getPlanet()->getShipyard() + ->getBuildingTime($this->getItemId(), $this->getItemQueuedQty()); + $item = $this->getItem(); + + return $totalTime - ($item->getData('created_at') - $item->getData('updated_at')); + } + + public function getResourcesConfigForQty($qty) + { + $resources = $this->getResourcesNeeded($qty); + + $resourceConfig = array(); + foreach ($resources as $resourceId => $resourceValue) { + $resourceConfig[$resourceId] = new Wootook_Object(array( + 'resource_id' => $resourceId, + 'value' => $resourceValue + )); + + $amount = $this->getPlanet()->getResourceAmount($resourceId); + if (Math::comp($amount, $resourceValue) < 0) { + $resourceConfig[$resourceId]->setData('requirement', Math::sub($amount, $resourceValue)); + } else { + $resourceConfig[$resourceId]->setData('overflow', Math::sub($amount, $resourceValue)); + } + } + return $resourceConfig; + } + + public function getResourcesConfigForNextLevel() + { + return $this->getResourcesConfigForLevel($this->getNextLevel()); + } + + public function getBuildingTimeForNextLevel() + { + return $this->getBuildingTime($this->getNextLevel()); + } +} diff --git a/src/application/code/core/Legacies/Empire/Controller/DefenseController.php b/src/application/code/core/Legacies/Empire/Controller/DefenseController.php new file mode 100644 index 0000000..b04103d --- /dev/null +++ b/src/application/code/core/Legacies/Empire/Controller/DefenseController.php @@ -0,0 +1,56 @@ +getCurrentPlanet(); + + if ($planet->getElement(Legacies_Empire::ID_BUILDING_SHIPYARD) < 1) { + $this->getSession() + ->addError(Wootook::__('In order to build defenses you will need to build a shipyard building.')); + + $this->_redirect('player/overview'); + return; + } + } + + public function indexAction() + { + $this->loadLayout('planet.defense'); + + /** @var Legacies_Empire_Block_Planet_Shipyard $block */ + $block = $this->getLayout()->getBlock('item-list'); + $block->setType(Legacies_Empire::TYPE_DEFENSE); + + $this->renderLayout(); + } + + public function buildAction() + { + if (!$this->getRequest()->isPost() || !is_array($defenseList = $this->getRequest()->getPost('id'))) { + $this->_redirect('*/*/view'); + return; + } + + $shipyard = $this->getCurrentPlanet()->getShipyard(); + foreach ($defenseList as $defenseId => $count) { + $defenseId = intval($defenseId); + $count = intval($count); + + $shipyard->appendQueue($defenseId, $count); + } + $this->getCurrentPlanet()->save(); + + $this->_redirect('*/*/'); + } +} diff --git a/src/application/code/core/Legacies/Empire/Controller/ResearchLabController.php b/src/application/code/core/Legacies/Empire/Controller/ResearchLabController.php new file mode 100644 index 0000000..0650172 --- /dev/null +++ b/src/application/code/core/Legacies/Empire/Controller/ResearchLabController.php @@ -0,0 +1,60 @@ +getCurrentPlanet(); + + if ($planet->getElement(Legacies_Empire::ID_BUILDING_SHIPYARD) < 1) { + $this->getSession() + ->addError(Wootook::__('In order to do technological researches, you will need to build a research lab building.')); + + $this->_redirect('player/overview'); + return; + } + } + + public function indexAction() + { + $this->loadLayout('planet.research-lab'); + $this->renderLayout(); + } + + public function buildAction() + { + if (!is_numeric($researchId = $this->getRequest()->getParam('id'))) { + $this->_redirect('*/*/view'); + return; + } + + $this->getCurrentPlanet()->getResearchLab()->appendQueue($researchId); + $this->getCurrentPlanet()->save(); + $this->getPlayer()->save(); + + $this->_redirect('*/*/'); + } + + public function cancelAction() + { + if (!is_numeric($researchId = $this->getRequest()->getParam('id'))) { + $this->_redirect('*/*/view'); + return; + } + + $this->getCurrentPlanet()->getResearchLab()->dequeueItem($researchId); + $this->getCurrentPlanet()->save(); + $this->getPlayer()->save(); + + $this->_redirect('*/*/'); + } +} diff --git a/src/application/code/core/Legacies/Empire/Controller/ShipyardController.php b/src/application/code/core/Legacies/Empire/Controller/ShipyardController.php new file mode 100644 index 0000000..ebf7b90 --- /dev/null +++ b/src/application/code/core/Legacies/Empire/Controller/ShipyardController.php @@ -0,0 +1,51 @@ +getCurrentPlanet(); + + if ($planet->getElement(Legacies_Empire::ID_BUILDING_SHIPYARD) < 1) { + $this->getSession() + ->addError(Wootook::__('In order to build ships you will need to build a shipyard building.')); + + $this->_redirect('player/overview'); + return; + } + } + + public function indexAction() + { + $this->loadLayout('planet.shipyard'); + $this->renderLayout(); + } + + public function buildAction() + { + if (!$this->getRequest()->isPost() || !is_array($shipList = $this->getRequest()->getPost('id'))) { + $this->_redirect('*/*/'); + return; + } + + $shipyard = $this->getCurrentPlanet()->getShipyard(); + foreach ($shipList as $shipId => $count) { + $shipId = intval($shipId); + $count = intval($count); + + $shipyard->appendQueue($shipId, $count); + } + $this->getCurrentPlanet()->save(); + + $this->_redirect('*/*/'); + } +} diff --git a/src/application/code/core/Legacies/Empire/Exception.php b/src/application/code/core/Legacies/Empire/Exception.php new file mode 100644 index 0000000..6527b43 --- /dev/null +++ b/src/application/code/core/Legacies/Empire/Exception.php @@ -0,0 +1,37 @@ + + * 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 . + * + * --> 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 + * + */ + +interface Legacies_Empire_Exception {} \ No newline at end of file diff --git a/src/application/code/core/Legacies/Empire/Model/Planet/Building/CristalMine.php b/src/application/code/core/Legacies/Empire/Model/Planet/Building/CristalMine.php new file mode 100644 index 0000000..ef720df --- /dev/null +++ b/src/application/code/core/Legacies/Empire/Model/Planet/Building/CristalMine.php @@ -0,0 +1,46 @@ + + * 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 . + * + * --> 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 Legacies_Empire_Model_Planet_Building_CristalMine + implements Wootook_Empire_Model_Planet_ResourceProductionInterface, Wootook_Empire_Model_Planet_BuildingInterface +{ + public function getProductionRatios($level, $produtionRatio, $planet, $player) + { + return array( + Legacies_Empire::RESOURCE_CRISTAL => 10 + 20 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio), + Legacies_Empire::RESOURCE_ENERGY => -10 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio) + ); + } +} \ No newline at end of file diff --git a/src/application/code/core/Legacies/Empire/Model/Planet/Building/DeuteriumSynthetiser.php b/src/application/code/core/Legacies/Empire/Model/Planet/Building/DeuteriumSynthetiser.php new file mode 100644 index 0000000..5556a4c --- /dev/null +++ b/src/application/code/core/Legacies/Empire/Model/Planet/Building/DeuteriumSynthetiser.php @@ -0,0 +1,46 @@ + + * 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 . + * + * --> 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 Legacies_Empire_Model_Planet_Building_DeuteriumSynthetiser + implements Wootook_Empire_Model_Planet_ResourceProductionInterface, Wootook_Empire_Model_Planet_BuildingInterface +{ + public function getProductionRatios($level, $produtionRatio, $planet, $player) + { + return array( + Legacies_Empire::RESOURCE_DEUTERIUM => 10 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio), + Legacies_Empire::RESOURCE_ENERGY => -30 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio) + ); + } +} \ No newline at end of file diff --git a/src/application/code/core/Legacies/Empire/Model/Planet/Building/FusionReactor.php b/src/application/code/core/Legacies/Empire/Model/Planet/Building/FusionReactor.php new file mode 100644 index 0000000..e3d32aa --- /dev/null +++ b/src/application/code/core/Legacies/Empire/Model/Planet/Building/FusionReactor.php @@ -0,0 +1,46 @@ + + * 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 . + * + * --> 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 Legacies_Empire_Model_Planet_Building_FusionReactor + implements Wootook_Empire_Model_Planet_ResourceProductionInterface, Wootook_Empire_Model_Planet_BuildingInterface +{ + public function getProductionRatios($level, $produtionRatio, $planet, $player) + { + return array( + Legacies_Empire::RESOURCE_DEUTERIUM => -10 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio), + Legacies_Empire::RESOURCE_ENERGY => 50 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio) + ); + } +} \ No newline at end of file diff --git a/src/application/code/core/Legacies/Empire/Model/Planet/Building/MetalMine.php b/src/application/code/core/Legacies/Empire/Model/Planet/Building/MetalMine.php new file mode 100644 index 0000000..e67f459 --- /dev/null +++ b/src/application/code/core/Legacies/Empire/Model/Planet/Building/MetalMine.php @@ -0,0 +1,47 @@ + + * 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 . + * + * --> 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 Legacies_Empire_Model_Planet_Building_MetalMine + implements Wootook_Empire_Model_Planet_ResourceProductionInterface, Wootook_Empire_Model_Planet_BuildingInterface +{ + public function getProductionRatios($level, $produtionRatio, $planet, $player) + { + return array( + Legacies_Empire::RESOURCE_METAL => 20 + 30 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio), + Legacies_Empire::RESOURCE_ENERGY => -10 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio) + ); + } +} \ No newline at end of file diff --git a/src/application/code/core/Legacies/Empire/Model/Planet/Building/NaniteFactory.php b/src/application/code/core/Legacies/Empire/Model/Planet/Building/NaniteFactory.php new file mode 100644 index 0000000..05f1163 --- /dev/null +++ b/src/application/code/core/Legacies/Empire/Model/Planet/Building/NaniteFactory.php @@ -0,0 +1,51 @@ + + * 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 . + * + * --> 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 Legacies_Empire_Model_Planet_Building_NaniteFactory + implements Wootook_Empire_Model_Planet_BuildingInterface +{ + public static function buildingEnhancementListener(Wootook_Core_Event $event) + { + /** @var float $enhancement */ + $enhancement = $event->getData('enhancement'); + + /** @var Wootook_Empire_Model_Planet $planet */ + $planet = $event->getData('planet'); + + $level = $planet->getElement(Legacies_Empire::ID_BUILDING_NANITE_FACTORY); + + $event->setData('enhancement', $enhancement * pow(.5, $level)); + } +} diff --git a/includes/application/code/core/Legacies/Empire/Model/Planet/Building/ResearchLab.php b/src/application/code/core/Legacies/Empire/Model/Planet/Building/ResearchLab.php similarity index 69% rename from includes/application/code/core/Legacies/Empire/Model/Planet/Building/ResearchLab.php rename to src/application/code/core/Legacies/Empire/Model/Planet/Building/ResearchLab.php index 51e0422..6c5ff41 100644 --- a/includes/application/code/core/Legacies/Empire/Model/Planet/Building/ResearchLab.php +++ b/src/application/code/core/Legacies/Empire/Model/Planet/Building/ResearchLab.php @@ -1,15 +1,15 @@ + * Copyright (c) 2011-Present, Grégory PLANCHAT * All rights reserved. * * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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. * @@ -18,13 +18,13 @@ * 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 General Public License + * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ @@ -38,7 +38,8 @@ * @subpackage Legacies_Empire */ class Legacies_Empire_Model_Planet_Building_ResearchLab - implements Legacies_Empire_Model_Planet_BuildingInterface + implements Wootook_Empire_Model_Planet_BuildingInterface, + Wootook_Empire_Model_Planet_QueueInterface { private $_eventPrefix = 'planet.laboratory.'; @@ -49,14 +50,14 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab protected $_currentPlanet = null; /** - * User instance - * @var Legacies_Empire_Model_User + * Player instance + * @var Woootook_Player_Model_Entity */ - protected $_currentUser = null; + protected $_currentPlayer = null; /** * construction queue - * @var array + * @var Legacies_Empire_Model_Planet_Building_ResearchLab_Builder */ protected $_builder = null; @@ -71,17 +72,17 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab * it doesn't yet exist. * * @param Legacies_Empire_Model_Planet $currentPlanet - * @param Legacies_Empire_Model_User $currentUser + * @param Woootook_Player_Model_Entity $currentPlayer * @return Legacies_Empire_Model_Planet_Building_ResearchLab */ - public static function factory($currentPlanet, $currentUser) + public static function factory($currentPlanet, $currentPlayer) { if ($currentPlanet->getId()) { return null; } if (!isset(self::$_instances[$currentPlanet->getId()])) { - self::$_instances[$currentPlanet->getId()] = new self($currentPlanet, $currentUser); + self::$_instances[$currentPlanet->getId()] = new self($currentPlanet, $currentPlayer); } return self::$_instances[$currentPlanet->getId()]; } @@ -92,14 +93,14 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab * @see Legacies_Empire_Model_Planet_Building_ResearchLab::factory() * * @param Legacies_Empire_Model_Planet $currentPlanet - * @param Legacies_Empire_Model_User $currentUser + * @param Woootook_Player_Model_Entity $currentPlayer */ - public function __construct($currentPlanet, $currentUser) + public function __construct($currentPlanet, $currentPlayer) { $this->_currentPlanet = $currentPlanet; - $this->_currentUser = $currentUser; + $this->_currentPlayer = $currentPlayer; - $this->_builder = new Legacies_Empire_Model_Planet_Building_ResearchLab_Builder($currentPlanet, $currentUser); + $this->_builder = new Legacies_Empire_Model_Planet_Building_ResearchLab_Builder($currentPlanet, $currentPlayer); } /** @@ -119,38 +120,36 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab * @param int|string $level * @return Legacies_Empire_Model_Planet_Building_ResearchLab */ - public function appendQueue($researchId, $destroy = false, $time = null) + public function appendQueue($researchId, $level = null, Wootook_Core_DateTime $time = null) { if ($time === null) { - $time = Legacies::now(); + $time = new Wootook_Core_DateTime(); } - if ($destroy === false) { - $level = $this->_currentUser->getElement($researchId) + 1; - } else { - $level = max($this->_currentUser->getElement($researchId) - 1, 0); + if ($level === null) { + $level = $this->_currentPlayer->getElement($researchId) + 1; } // Dispatch event - Legacies::dispatchEvent($this->_eventPrefix . 'append-queue.before', array( + Wootook::dispatchEvent($this->_eventPrefix . 'append-queue.before', array( 'research_id' => $researchId, 'level' => &$level, 'time' => &$time, 'laboratory' => $this, 'planet' => $this->_currentPlanet, - 'user' => $this->_currentUser + 'player' => $this->_currentPlayer )); $this->_builder->appendQueue($researchId, $level, $time); // Dispatch event - Legacies::dispatchEvent($this->_eventPrefix . 'append-queue.after', array( + Wootook::dispatchEvent($this->_eventPrefix . 'append-queue.after', array( 'research_id' => $researchId, 'level' => $level, 'time' => $time, 'laboratory' => $this, 'planet' => $this->_currentPlanet, - 'user' => $this->_currentUser + 'player' => $this->_currentPlayer )); return $this; @@ -161,28 +160,28 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab * * @return Legacies_Empire_Model_Planet_Building_ResearchLab */ - public function updateQueue($time = null) + public function updateQueue(Wootook_Core_DateTime $time = null) { if ($time === null) { - $time = Legacies::now(); + $time = new Wootook_Core_DateTime(); } // Dispatch event - Legacies::dispatchEvent($this->_eventPrefix . 'update-queue.before', array( + Wootook::dispatchEvent($this->_eventPrefix . 'update-queue.before', array( 'time' => &$time, 'laboratory' => $this, 'planet' => $this->_currentPlanet, - 'user' => $this->_currentUser + 'player' => $this->_currentPlayer )); $this->_builder->updateQueue($time); // Dispatch event - Legacies::dispatchEvent($this->_eventPrefix . 'update-queue.after', array( + Wootook::dispatchEvent($this->_eventPrefix . 'update-queue.after', array( 'time' => $time, 'laboratory' => $this, 'planet' => $this->_currentPlanet, - 'user' => $this->_currentUser + 'player' => $this->_currentPlayer )); return $this; @@ -209,18 +208,22 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab public function checkAvailability($researchId) { try { + if (!$this->_builder->checkAvailability($researchId)) { + return false; + } + // Dispatch event - Legacies::dispatchEvent($this->_eventPrefix . 'check-availability', array( + Wootook::dispatchEvent($this->_eventPrefix . 'check-availability', array( 'research_id' => $researchId, 'laboratory' => $this, 'planet' => $this->_currentPlanet, - 'user' => $this->_currentUser + 'player' => $this->_currentPlayer )); } catch (Legacies_Core_Event_Break $e) { return false; } - return $this->_builder->checkAvailability($researchId); + return true; } public function getResourcesNeeded($researchId, $level) @@ -230,12 +233,12 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab public function getResearchTime($researchId, $level) { - $this->_builder->getBuildingTime($researchId, $level); + return $this->_builder->getBuildingTime($researchId, $level); } public function getResearchLevelQueued($researchId) { - $level = $this->_currentUser->getElement($researchId); + $level = $this->_currentPlayer->getElement($researchId); foreach ($this->_builder as $item) { if ($item->getData('research_id') != $researchId) { continue; @@ -260,9 +263,9 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab $time = $eventData['time']; } - $shipyard = $planet->getResearchLab(); - if ($shipyard !== null) { - $shipyard->updateQueue(); + $researchLab = $planet->getResearchLab(); + if ($researchLab !== null) { + $researchLab->updateQueue(); } } } diff --git a/src/application/code/core/Legacies/Empire/Model/Planet/Building/ResearchLab/Builder.php b/src/application/code/core/Legacies/Empire/Model/Planet/Building/ResearchLab/Builder.php new file mode 100644 index 0000000..467dcde --- /dev/null +++ b/src/application/code/core/Legacies/Empire/Model/Planet/Building/ResearchLab/Builder.php @@ -0,0 +1,358 @@ + + * 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 . + * + * --> 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 Legacies_Empire_Model_Planet_Building_ResearchLab_Builder + extends Wootook_Empire_Model_BuilderAbstract +{ + const FIELD_SERIALIZED = 'b_tech_id'; + const FIELD_DATETIME = 'b_tech'; + + /** + * @var int + */ + protected $_maxLength = 0; + + /** + * @var float + */ + protected $_speedEnhancement = null; + + public function init() + { + $this->_unserializeQueue($this->_currentPlanet->getData(self::FIELD_SERIALIZED)); + + $this->_maxLength = Wootook::getGameConfig('engine/core/lab_queue_size'); + } + + /** + * @param array $params + */ + protected function _initItem(Array $params) + { + if (!isset($params['technology_id']) || !isset($params['level'])) { + return null; + } + + $technologyId = $params['technology_id']; + $level = $params['level']; + + if (!isset($params['created_at'])) { + $createdAt = new Wootook_Core_DateTime(); + } else { + $createdAt = $params['created_at']; + } + + if (!isset($params['started_at'])) { + $startedAt = null; + } else { + $startedAt = $params['started_at']; + } + + if (!isset($params['updated_at'])) { + $updatedAt = $createdAt; + } else { + $updatedAt = $params['updated_at']; + } + + return new Legacies_Empire_Model_Planet_Building_ResearchLab_Item(array( + 'technology_id' => $technologyId, + 'level' => $level, + 'created_at' => $createdAt, + 'started_at' => $startedAt, + 'updated_at' => $updatedAt + )); + } + + public function getSpeedEnhancement() + { + if ($this->_speedEnhancement === null) { + $event = Wootook::dispatchEvent('planet.research-lab.technology.speed-enhancement', array( + 'player' => $this->_currentPlanet, + 'planet' => $this->_currentPlanet, + 'enhancement' => 1 + )); + + $this->_speedEnhancement = $event->getData('enhancement'); + } + + return $this->_speedEnhancement; + } + + /** + * Check if a technology type is actually buildable on the current + * planet, depending on the technology and buildings requirements. + * + * @param int|string $technologyId + * @return bool + */ + public function checkAvailability($technologyId) + { + $types = Wootook_Empire_Helper_Config_Types::getSingleton(); + + if (!$types->is($technologyId, Legacies_Empire::TYPE_RESEARCH)) { + return false; + } + + return parent::checkAvailability($technologyId); + } + + /** + * Returns the time needed to build $level of $technologyId + * + * @param int|string $technologyId + * @param int $level + */ + public function getBuildingTime($technologyId, $level) + { + $prices = Wootook_Empire_Helper_Config_Prices::getSingleton(); + + Math::setPrecision(50); + $firstLevelTime = $prices[$technologyId][Legacies_Empire::BASE_BUILDING_TIME]; + $partialLevelTime = Math::mul($firstLevelTime, Math::pow($prices[$technologyId][Legacies_Empire::RESOURCE_MULTIPLIER], $level)); + $levelTime = Math::sub($partialLevelTime, $firstLevelTime); + + $speedFactor = Wootook::getGameConfig('game/speed/general'); + if ($speedFactor == null) { + $speedFactor = 1; + } + + $baseTime = ($levelTime * 3600 / $speedFactor) / $this->getSpeedEnhancement(); + + Math::setPrecision(); + + $event = Wootook::dispatchEvent('planet.research-lab.technology.building-time', array( + 'time' => $baseTime, + 'base_time' => $baseTime, + 'planet' => $this->_currentPlanet, + 'player' => $this->_currentPlayer, + 'technology_id' => $technologyId, + 'level' => $level + )); + + return $event->getData('time'); + } + + /** + * (non-PHPdoc) + * @see Legacies_Empire_Model_BuilderAbstract::getResourcesNeeded() + */ + public function getResourcesNeeded($technologyId, $level) + { + $prices = Wootook_Empire_Helper_Config_Prices::getSingleton(); + $resources = Wootook_Empire_Helper_Config_Resources::getSingleton(); + + if (!isset($prices[$technologyId])) { + return array(); + } + $resourcesNeeded = array(); + foreach ($resources as $resourceId => $resourceConfig) { + if (!isset($prices[$technologyId][$resourceId])) { + continue; + } + if (Math::isPositive($prices[$technologyId][$resourceId])) { + $firstLevelCost = $prices[$technologyId][$resourceId]; + $partialLevelCost = Math::mul($firstLevelCost, Math::pow($prices[$technologyId][Legacies_Empire::RESOURCE_MULTIPLIER], $level)); + $resourcesNeeded[$resourceId] = Math::sub($partialLevelCost, $firstLevelCost); + } + } + + return $resourcesNeeded; + } + + /** + * Update the contruction queue. + * + * @return Legacies_Empire_Model_Planet_Building_ResearchLab + */ + public function updateQueue(Wootook_Core_DateTime $time) + { + $fields = Wootook_Empire_Helper_Config_FieldsAlias::getSingleton(); + + $startingTime = clone $this->_currentPlanet->getData(self::FIELD_DATETIME); + + $elapsedTime = $time->getTimestamp() - $this->_currentPlanet->getData(self::FIELD_DATETIME)->getTimestamp(); + + foreach ($this->getQueue() as $element) { + $elementTime = $element->getData('started_at'); + + if ($elementTime === null) { + $element->setData('started_at', $startingTime->getTimestamp()); + $elementTime = $startingTime->getTimestamp(); + } + + $level = $element->getData('level'); + $technologyId = $element->getData('technology_id'); + $buildTime = $this->getBuildingTime($technologyId, $level); + $elapsedTime = $time->getTimestamp() - $elementTime; + + if ($elapsedTime >= $buildTime) { + $this->dequeue($element); + + $currentTime = clone $startingTime; + $currentTime->add($elapsedTime); + + $this->_currentPlayer->setElement($technologyId, $level); + $this->_currentPlanet->updateStorages($currentTime); + $this->_currentPlanet->updateResourceProduction($currentTime); + $this->_currentPlanet->updateBuildingFields(); + + Wootook::dispatchEvent('planet.research-lab.technology.level-update', array( + 'time' => $currentTime, + 'planet' => $this->_currentPlanet, + 'player' => $this->_currentPlayer, + 'technology_id' => $technologyId, + 'level' => $level + )); + + $startingTime->set($elementTime + $buildTime); + continue; + } + + break; + } + + $this->_currentPlanet->setData(self::FIELD_SERIALIZED, $this->serialize()); + $this->_currentPlanet->setData(self::FIELD_DATETIME, $startingTime->now()); + + return $this; + } + + /** + * Append items to build to the construction list + * + * @param int|string $technologyId + * @param int $level + * @return Legacies_Empire_Model_Planet_Building_ResearchLab + */ + public function appendQueue($technologyId, $level, Wootook_Core_DateTime $time) + { + if ($this->_maxLength > 0 && $this->count() >= $this->_maxLength) { + return $this; + } + + $types = Wootook_Empire_Helper_Config_Types::getSingleton(); + + if (!Math::isPositive($level)) { + return $this; + } + + if (!$types->is($technologyId, Legacies_Empire::TYPE_RESEARCH)) { + return $this; + } + + if (!$this->checkAvailability($technologyId)) { + return $this; + } + + $resourcesNeeded = $this->getResourcesNeeded($technologyId, $level); + $remainingAmounts = $this->_calculateResourceRemainingAmounts($resourcesNeeded); + if ($remainingAmounts === false) { + return $this; + } + + if ($this->count() == 0) { + $this->_currentPlanet->setData(self::FIELD_DATETIME, $time); + } + + $this->enqueue(array( + 'technology_id' => $technologyId, + 'level' => $level, + 'created_at' => $time->getTimestamp() + )); + + $this->_currentPlanet->setData(self::FIELD_SERIALIZED, $this->serialize()); + $this->_currentPlayer->setdata('b_tech_planet', $this->_currentPlanet->getId()); + + foreach ($remainingAmounts as $resourceId => $resourceAmount) { + $this->_currentPlanet[$resourceId] = $resourceAmount; + } + + return $this; + } + + /** + * Dequeues the first item to build to the construction list and removes all + * its successors of the same type. + * + * @return Legacies_Empire_Model_Planet_Building_ResearchLab + */ + public function dequeueFirstItem() + { + $this->rewind(); + $item = $this->current(); + + return $this->dequeueItem($item->getIndex()); + } + + /** + * Dequeues an item to build to the construction list and removes all its + * successors of the same type. + * + * @param string $itemId + * @return Legacies_Empire_Model_Planet_Building_ResearchLab + */ + public function dequeueItem($itemId) + { + $item = $this->getItem($itemId); + if (!$item) { + return $this; + } + $technologyId = $item->getData('technology_id'); + + $keys = array_keys($this->_queue); + $size = count($keys); + $start = array_search($item->getIndex(), $keys); + for ($i = $start; $i < $size; $i++) { + $index = $keys[$i]; + if ($this->_queue[$index]->getData('technology_id') != $technologyId) { + continue; + } + + $resourcesNeeded = $this->getResourcesNeeded($technologyId, $this->_queue[$index]->getData('level')); + $reclaimedAmounts = $this->_calculateResourceReclaimedAmounts($resourcesNeeded); + + $this->dequeue($this->_queue[$index]); + + foreach ($reclaimedAmounts as $resourceId => $resourceAmount) { + $this->_currentPlanet[$resourceId] = $resourceAmount; + } + } + + $this->_currentPlanet->setData(self::FIELD_SERIALIZED, $this->serialize()); + + return $this; + } +} diff --git a/src/application/code/core/Legacies/Empire/Model/Planet/Building/ResearchLab/Item.php b/src/application/code/core/Legacies/Empire/Model/Planet/Building/ResearchLab/Item.php new file mode 100644 index 0000000..c70a8fa --- /dev/null +++ b/src/application/code/core/Legacies/Empire/Model/Planet/Building/ResearchLab/Item.php @@ -0,0 +1,39 @@ + + * 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 . + * + * --> 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 Legacies_Empire_Model_Planet_Building_ResearchLab_Item + extends Wootook_Empire_Model_Builder_Item +{ +} \ No newline at end of file diff --git a/src/application/code/core/Legacies/Empire/Model/Planet/Building/RoboticFactory.php b/src/application/code/core/Legacies/Empire/Model/Planet/Building/RoboticFactory.php new file mode 100644 index 0000000..5e6b3c8 --- /dev/null +++ b/src/application/code/core/Legacies/Empire/Model/Planet/Building/RoboticFactory.php @@ -0,0 +1,51 @@ + + * 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 . + * + * --> 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 Legacies_Empire_Model_Planet_Building_RoboticFactory + implements Wootook_Empire_Model_Planet_BuildingInterface +{ + public static function buildingEnhancementListener(Wootook_Core_Event $event) + { + /** @var float $enhancement */ + $enhancement = $event->getData('enhancement'); + + /** @var Wootook_Empire_Model_Planet $planet */ + $planet = $event->getData('planet'); + + $level = $planet->getElement(Legacies_Empire::ID_BUILDING_ROBOTIC_FACTORY); + + $event->setData('enhancement', $enhancement * (2 / (1 + $level))); + } +} diff --git a/includes/application/code/core/Legacies/Empire/Model/Planet/Building/Shipyard.php b/src/application/code/core/Legacies/Empire/Model/Planet/Building/Shipyard.php similarity index 75% rename from includes/application/code/core/Legacies/Empire/Model/Planet/Building/Shipyard.php rename to src/application/code/core/Legacies/Empire/Model/Planet/Building/Shipyard.php index 363af94..b8c93b9 100644 --- a/includes/application/code/core/Legacies/Empire/Model/Planet/Building/Shipyard.php +++ b/src/application/code/core/Legacies/Empire/Model/Planet/Building/Shipyard.php @@ -1,15 +1,15 @@ + * Copyright (c) 2011-Present, Grégory PLANCHAT * All rights reserved. * * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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. * @@ -18,13 +18,13 @@ * 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 General Public License + * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ @@ -38,7 +38,8 @@ * @subpackage Legacies_Empire */ class Legacies_Empire_Model_Planet_Building_Shipyard - implements Legacies_Empire_Model_Planet_BuildingInterface + implements Wootook_Empire_Model_Planet_BuildingInterface, + Wootook_Empire_Model_Planet_QueueInterface { private $_eventPrefix = 'planet.shipyard.'; @@ -49,10 +50,10 @@ class Legacies_Empire_Model_Planet_Building_Shipyard protected $_currentPlanet = null; /** - * User instance - * @var Legacies_Empire_Model_User + * Player instance + * @var Woootook_Player_Model_Entity */ - protected $_currentUser = null; + protected $_currentPlayer = null; /** * construction queue @@ -83,17 +84,17 @@ class Legacies_Empire_Model_Planet_Building_Shipyard * it doesn't yet exist. * * @param Legacies_Empire_Model_Planet $currentPlanet - * @param Legacies_Empire_Model_User $currentUser + * @param Woootook_Player_Model_Entity $currentPlayer * @return Legacies_Empire_Model_Planet_Building_Shipyard */ - public static function factory($currentPlanet, $currentUser) + public static function factory($currentPlanet, $currentPlayer) { if ($currentPlanet->getId()) { return null; } if (!isset(self::$_instances[$currentPlanet->getId()])) { - self::$_instances[$currentPlanet->getId()] = new self($currentPlanet, $currentUser); + self::$_instances[$currentPlanet->getId()] = new self($currentPlanet, $currentPlayer); } return self::$_instances[$currentPlanet->getId()]; } @@ -104,25 +105,14 @@ class Legacies_Empire_Model_Planet_Building_Shipyard * @see Legacies_Empire_Model_Planet_Building_Shipyard::factory() * * @param Legacies_Empire_Model_Planet $currentPlanet - * @param Legacies_Empire_Model_User $currentUser + * @param Woootook_Player_Model_Entity $currentPlayer */ - public function __construct($currentPlanet, $currentUser) + public function __construct($currentPlanet, $currentPlayer) { $this->_currentPlanet = $currentPlanet; - $this->_currentUser = $currentUser; + $this->_currentPlayer = $currentPlayer; - $this->_builder = new Legacies_Empire_Model_Planet_Building_Shipyard_Builder($currentPlanet, $currentUser); - } - - /** - * Returns the timestamp at the instance creation. - * - * @deprecated - * @return int - */ - protected function _now() - { - return Legacies::now(); + $this->_builder = new Legacies_Empire_Model_Planet_Building_Shipyard_Builder($currentPlanet, $currentPlayer); } /** @@ -142,32 +132,32 @@ class Legacies_Empire_Model_Planet_Building_Shipyard * @param int|string $qty * @return Legacies_Empire_Model_Planet_Building_Shipyard */ - public function appendQueue($shipId, $qty, $time = null) + public function appendQueue($shipId, $qty, Wootook_Core_DateTime $time = null) { if ($time === null) { - $time = Legacies::now(); + $time = new Wootook_Core_DateTime(); } // Dispatch event - Legacies::dispatchEvent($this->_eventPrefix . 'append-queue.before', array( + Wootook::dispatchEvent($this->_eventPrefix . 'append-queue.before', array( 'ship_id' => $shipId, 'qty' => &$qty, 'time' => &$time, 'shipyard' => $this, 'planet' => $this->_currentPlanet, - 'user' => $this->_currentUser + 'player' => $this->_currentPlayer )); $this->_builder->appendQueue($shipId, $qty, $time); // Dispatch event - Legacies::dispatchEvent($this->_eventPrefix . 'append-queue.before', array( + Wootook::dispatchEvent($this->_eventPrefix . 'append-queue.before', array( 'ship_id' => $shipId, 'qty' => $qty, 'time' => $time, 'shipyard' => $this, 'planet' => $this->_currentPlanet, - 'user' => $this->_currentUser + 'player' => $this->_currentPlayer )); return $this; @@ -178,28 +168,28 @@ class Legacies_Empire_Model_Planet_Building_Shipyard * * @return Legacies_Empire_Model_Planet_Building_Shipyard */ - public function updateQueue($time = null) + public function updateQueue(Wootook_Core_DateTime $time = null) { if ($time === null) { - $time = Legacies::now(); + $time = new Wootook_Core_DateTime(); } // Dispatch event - Legacies::dispatchEvent($this->_eventPrefix . 'update-queue.before', array( + Wootook::dispatchEvent($this->_eventPrefix . 'update-queue.before', array( 'time' => &$time, 'shipyard' => $this, 'planet' => $this->_currentPlanet, - 'user' => $this->_currentUser + 'player' => $this->_currentPlayer )); $this->_builder->updateQueue($time); // Dispatch event - Legacies::dispatchEvent($this->_eventPrefix . 'update-queue.after', array( + Wootook::dispatchEvent($this->_eventPrefix . 'update-queue.after', array( 'time' => $time, 'shipyard' => $this, 'planet' => $this->_currentPlanet, - 'user' => $this->_currentUser + 'player' => $this->_currentPlayer )); return $this; @@ -227,11 +217,11 @@ class Legacies_Empire_Model_Planet_Building_Shipyard { try { // Dispatch event - Legacies::dispatchEvent($this->_eventPrefix . 'check-availability', array( + Wootook::dispatchEvent($this->_eventPrefix . 'check-availability', array( 'ship_id' => $shipId, 'shipyard' => $this, 'planet' => $this->_currentPlanet, - 'user' => $this->_currentUser + 'player' => $this->_currentPlayer )); } catch (Legacies_Core_Event_Break $e) { return false; @@ -276,7 +266,7 @@ class Legacies_Empire_Model_Planet_Building_Shipyard $time = $eventData['time']; } - $shipyard = self::factory($planet, $planet->getUser()); + $shipyard = self::factory($planet, $planet->getPlayer()); if ($shipyard !== null) { $shipyard->updateQueue(); } diff --git a/includes/application/code/core/Legacies/Empire/Model/Planet/Building/Shipyard/Builder.php b/src/application/code/core/Legacies/Empire/Model/Planet/Building/Shipyard/Builder.php similarity index 72% rename from includes/application/code/core/Legacies/Empire/Model/Planet/Building/Shipyard/Builder.php rename to src/application/code/core/Legacies/Empire/Model/Planet/Building/Shipyard/Builder.php index cbbe3ac..a9bee0b 100644 --- a/includes/application/code/core/Legacies/Empire/Model/Planet/Building/Shipyard/Builder.php +++ b/src/application/code/core/Legacies/Empire/Model/Planet/Building/Shipyard/Builder.php @@ -1,13 +1,52 @@ + * 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 . + * + * --> 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 Legacies_Empire_Model_Planet_Building_Shipyard_Builder - extends Legacies_Empire_Model_BuilderAbstract + extends Wootook_Empire_Model_BuilderAbstract { /** * @var int */ protected $_maxLength = 0; + /** + * @var float + */ + protected $_speedEnhancement = null; + public function init() { $this->_unserializeQueue($this->_currentPlanet->getData('b_hangar_id')); @@ -27,7 +66,7 @@ class Legacies_Empire_Model_Planet_Building_Shipyard_Builder $shipId = $params['ship_id']; $qty = $params['qty']; if (!isset($params['created_at'])) { - $createdAt = time(); + $createdAt = new Wootook_Core_DateTime(); } else { $createdAt = $params['created_at']; } @@ -45,6 +84,21 @@ class Legacies_Empire_Model_Planet_Building_Shipyard_Builder )); } + public function getSpeedEnhancement() + { + if ($this->_speedEnhancement === null) { + $event = Wootook::dispatchEvent('planet.shipyard.speed-enhancement', array( + 'player' => $this->_currentPlanet, + 'planet' => $this->_currentPlanet, + 'enhancement' => 1 + )); + + $this->_speedEnhancement = $event->getData('enhancement'); + } + + return $this->_speedEnhancement; + } + /** * Check if a ship or defense type is actually buildable on the current * planet, depending on the technology and buildings requirements. @@ -54,15 +108,13 @@ class Legacies_Empire_Model_Planet_Building_Shipyard_Builder */ public function checkAvailability($shipId) { - $types = Legacies_Empire_Model_Game_Types::getSingleton(); + $types = Wootook_Empire_Helper_Config_Types::getSingleton(); if (!$types->is($shipId, Legacies_Empire::TYPE_SHIP) && !$types->is($shipId, Legacies_Empire::TYPE_DEFENSE)) { return false; } - parent::checkAvailability($shipId); - - return true; + return parent::checkAvailability($shipId); } /** @@ -74,9 +126,9 @@ class Legacies_Empire_Model_Planet_Building_Shipyard_Builder */ public function getMaximumBuildableElementsCount($shipId) { - $prices = Legacies_Empire_Model_Game_Prices::getSingleton(); - $fields = Legacies_Empire_Model_Game_FieldsAlias::getSingleton(); - $resources = Legacies_Empire_Model_Game_Resources::getSingleton(); + $prices = Wootook_Empire_Helper_Config_Prices::getSingleton(); + $fields = Wootook_Empire_Helper_Config_FieldsAlias::getSingleton(); + $resources = Wootook_Empire_Helper_Config_Resources::getSingleton(); $qty = 0; foreach ($resources as $resourceId => $_) { @@ -150,22 +202,20 @@ class Legacies_Empire_Model_Planet_Building_Shipyard_Builder */ public function getBuildingTime($shipId, $qty) { - $prices = Legacies_Empire_Model_Game_Prices::getSingleton(); - $gameConfig = Legacies_Core_Model_Config::getSingleton(); + $prices = Wootook_Empire_Helper_Config_Prices::getSingleton(); Math::setPrecision(50); - $buildingTime = Math::mul($prices[$shipId][Legacies_Empire::BASE_BUILDING_TIME], $qty); - - $speedFactor = $gameConfig->getData('game_speed'); - $baseTime = Math::div($buildingTime, $speedFactor); + $buildingTime = Math::mul($prices[$shipId][Legacies_Empire::BASE_BUILDING_TIME], intval($qty)); + $speedFactor = Wootook::getGameConfig('game/speed/general') / 1000; + $baseTime = Math::mul(Math::div($buildingTime, 5000), Math::mul($speedFactor, $this->getSpeedEnhancement())); Math::setPrecision(); - $event = Legacies::dispatchEvent('planet.shipyard.building-time', array( + $event = Wootook::dispatchEvent('planet.shipyard.building-time', array( 'time' => $baseTime, 'base_time' => $baseTime, 'planet' => $this->_currentPlanet, - 'user' => $this->_currentUser, + 'player' => $this->_currentPlayer, 'ship_id' => $shipId, 'qty' => $qty )); @@ -179,8 +229,8 @@ class Legacies_Empire_Model_Planet_Building_Shipyard_Builder */ public function getResourcesNeeded($shipId, $qty) { - $prices = Legacies_Empire_Model_Game_Prices::getSingleton(); - $resources = Legacies_Empire_Model_Game_Resources::getSingleton(); + $prices = Wootook_Empire_Helper_Config_Prices::getSingleton(); + $resources = Wootook_Empire_Helper_Config_Resources::getSingleton(); if (!isset($prices[$shipId])) { return array(); @@ -216,11 +266,11 @@ class Legacies_Empire_Model_Planet_Building_Shipyard_Builder * * @return Legacies_Empire_Model_Planet_Building_Shipyard */ - public function updateQueue($time) + public function updateQueue(Wootook_Core_DateTime $time) { - $fields = Legacies_Empire_Model_Game_FieldsAlias::getSingleton(); + $fields = Wootook_Empire_Helper_Config_FieldsAlias::getSingleton(); - $elapsedTime = $time - $this->_currentPlanet->getData('b_hangar'); + $elapsedTime = $time->getTimestamp() - $this->_currentPlanet->getData('b_hangar')->getTimestamp(); foreach ($this->getQueue() as $element) { $shipId = $element->getData('ship_id'); @@ -237,7 +287,7 @@ class Legacies_Empire_Model_Planet_Building_Shipyard_Builder $timeRatio = $elapsedTime / $buildTime; $itemsBuilt = Math::mul($timeRatio, $qty); - $element->setData('updated_at', $time); + $element->setData('updated_at', $time->getTimestamp()); $element->setData('qty', Math::sub($qty, $itemsBuilt)); $this->_currentPlanet->setData($fields[$shipId], Math::add($this->_currentPlanet->getData($fields[$shipId]), $itemsBuilt)); break; @@ -256,7 +306,7 @@ class Legacies_Empire_Model_Planet_Building_Shipyard_Builder * @param int|string $qty * @return Legacies_Empire_Model_Planet_Building_Shipyard */ - public function appendQueue($shipId, $qty, $time) + public function appendQueue($shipId, $qty, Wootook_Core_DateTime $time) { if ($this->_maxLength > 0 && $this->count() >= $this->_maxLength) { return $this; @@ -266,7 +316,7 @@ class Legacies_Empire_Model_Planet_Building_Shipyard_Builder return $this; } - $types = Legacies_Empire_Model_Game_Types::getSingleton(); + $types = Wootook_Empire_Helper_Config_Types::getSingleton(); if (!$types->is($shipId, Legacies_Empire::TYPE_SHIP) && !$types->is($shipId, Legacies_Empire::TYPE_DEFENSE)) { return $this; } @@ -291,7 +341,12 @@ class Legacies_Empire_Model_Planet_Building_Shipyard_Builder return $this; } - $this->enqueue($shipId, $qty, $time); + $this->enqueue(array( + 'ship_id' => $shipId, + 'qty' => $qty, + 'created_at' => $time->getTimestamp(), + 'updated_at' => $time->getTimestamp() + )); $this->_currentPlanet->setData('b_hangar_id', $this->serialize()); foreach ($remainingAmounts as $resourceId => $resourceAmount) { @@ -300,4 +355,4 @@ class Legacies_Empire_Model_Planet_Building_Shipyard_Builder return $this; } -} \ No newline at end of file +} diff --git a/src/application/code/core/Legacies/Empire/Model/Planet/Building/Shipyard/Item.php b/src/application/code/core/Legacies/Empire/Model/Planet/Building/Shipyard/Item.php new file mode 100644 index 0000000..6dac60d --- /dev/null +++ b/src/application/code/core/Legacies/Empire/Model/Planet/Building/Shipyard/Item.php @@ -0,0 +1,40 @@ + + * 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 . + * + * --> 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 Legacies_Empire_Model_Planet_Building_Shipyard_Item + extends Wootook_Empire_Model_Builder_Item +{ +} \ No newline at end of file diff --git a/src/application/code/core/Legacies/Empire/Model/Planet/Building/SolarPlant.php b/src/application/code/core/Legacies/Empire/Model/Planet/Building/SolarPlant.php new file mode 100644 index 0000000..e4cab3b --- /dev/null +++ b/src/application/code/core/Legacies/Empire/Model/Planet/Building/SolarPlant.php @@ -0,0 +1,40 @@ + + * 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 . + * + * --> 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. + * + */ + +class Legacies_Empire_Model_Planet_Building_SolarPlant + implements Wootook_Empire_Model_Planet_ResourceProductionInterface, Wootook_Empire_Model_Planet_BuildingInterface +{ + public function getProductionRatios($level, $produtionRatio, $planet, $player) + { + return array( + Legacies_Empire::RESOURCE_ENERGY => 20 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio) + ); + } +} \ No newline at end of file diff --git a/src/application/code/core/Legacies/Empire/Model/Planet/Ship/LargeTransport.php b/src/application/code/core/Legacies/Empire/Model/Planet/Ship/LargeTransport.php new file mode 100644 index 0000000..f0d31e4 --- /dev/null +++ b/src/application/code/core/Legacies/Empire/Model/Planet/Ship/LargeTransport.php @@ -0,0 +1,53 @@ + + * 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 . + * + * --> 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 Legacies_Empire_Model_Planet_Ship_LargeTransport + extends Wootook_Empire_Model_Planet_ShipAbstract +{ + const REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_IMPULSE_DRIVE = 4; + + public function getBaseSpeed(Wootook_Player_Model_Entity $player) + { + $prices = Wootook_Empire_Helper_Config_Prices::getSingleton(); + + return $prices[Legacies_Empire::ID_SHIP_LARGE_TRANSPORT][Legacies_Empire::SHIPS_CELERITY_PRIMARY]; + } + + public function getSpeedMultiplier(Wootook_Player_Model_Entity $player) + { + return pow(1.1, $player->getElement(Legacies_Empire::ID_RESEARCH_COMBUSTION_DRIVE)); + } +} \ No newline at end of file diff --git a/src/application/code/core/Legacies/Empire/Model/Planet/Ship/LightTransport.php b/src/application/code/core/Legacies/Empire/Model/Planet/Ship/LightTransport.php new file mode 100644 index 0000000..15be57f --- /dev/null +++ b/src/application/code/core/Legacies/Empire/Model/Planet/Ship/LightTransport.php @@ -0,0 +1,61 @@ + + * 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 . + * + * --> 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 Legacies_Empire_Model_Planet_Ship_LightTransport + extends Wootook_Empire_Model_Planet_ShipAbstract +{ + const REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_IMPULSE_DRIVE = 4; + + public function getBaseSpeed(Wootook_Player_Model_Entity $player) + { + $prices = Wootook_Empire_Helper_Config_Prices::getSingleton(); + + if ($player->getElement(Legacies_Empire::ID_RESEARCH_IMPULSE_DRIVE) < self::REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_IMPULSE_DRIVE) { + return $prices[Legacies_Empire::ID_SHIP_LIGHT_TRANSPORT][Legacies_Empire::SHIPS_CELERITY_PRIMARY]; + } else { + return $prices[Legacies_Empire::ID_SHIP_LIGHT_TRANSPORT][Legacies_Empire::SHIPS_CELERITY_SECONDARY]; + } + } + + public function getSpeedMultiplier(Wootook_Player_Model_Entity $player) + { + if ($player->getElement(Legacies_Empire::ID_RESEARCH_HYPERSPACE_DRIVE) < self::REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_IMPULSE_DRIVE) { + return pow(1.1, $player->getElement(Legacies_Empire::ID_RESEARCH_COMBUSTION_DRIVE)); + } else { + return pow(1.2, $player->getElement(Legacies_Empire::ID_RESEARCH_IMPULSE_DRIVE)); + } + } +} \ No newline at end of file diff --git a/src/application/code/core/Legacies/Empire/Model/Planet/Ship/SolarSatellite.php b/src/application/code/core/Legacies/Empire/Model/Planet/Ship/SolarSatellite.php new file mode 100644 index 0000000..b6f132c --- /dev/null +++ b/src/application/code/core/Legacies/Empire/Model/Planet/Ship/SolarSatellite.php @@ -0,0 +1,66 @@ + + * 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 . + * + * --> 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 Legacies_Empire_Model_Planet_Ship_SolarSatellite + extends Wootook_Empire_Model_Planet_ShipAbstract + implements Wootook_Empire_Model_Planet_ResourceProductionInterface +{ + public function getProductionRatios($quantity, $produtionRatio, $planet, $player) + { + return array( + Legacies_Empire::RESOURCE_ENERGY => ((floatval($planet->getData('temp_max')) / 4) + 20) * (0.1 * $produtionRatio) * floatval($quantity) + ); + } + + public function getBaseSpeed(Wootook_Player_Model_Entity $player) + { + return 0; + } + + public function getSpeedMultiplier(Wootook_Player_Model_Entity $player) + { + return 0; + } + + public function getActualSpeed(Wootook_Player_Model_Entity $player) + { + return 0; + } + + public function getBaseConsumption(Wootook_Player_Model_Entity $player) + { + return 0; + } +} \ No newline at end of file diff --git a/src/application/code/core/Legacies/Empire/Model/Planet/Ship/Supernova.php b/src/application/code/core/Legacies/Empire/Model/Planet/Ship/Supernova.php new file mode 100644 index 0000000..7025166 --- /dev/null +++ b/src/application/code/core/Legacies/Empire/Model/Planet/Ship/Supernova.php @@ -0,0 +1,77 @@ + + * 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 . + * + * --> 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 Legacies_Empire_Model_Planet_Ship_Supernova + extends Wootook_Empire_Model_Planet_ShipAbstract + implements Wootook_Empire_Model_Planet_ResourceProductionInterface +{ + const REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_HYPERSPACE_DRIVE = 20; + const REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_HYPERSPACE_TECHNOLOGY = 15; + + public function getProductionRatios($quantity, $produtionRatio, $planet, $player) + { + return array( + Legacies_Empire::RESOURCE_ENERGY => ((floatval($planet->getData('temp_max')) / 4) + 20) * (0.1 * $produtionRatio) * floatval($quantity) * -1250 + ); + } + + public function getBaseSpeed(Wootook_Player_Model_Entity $player) + { + $prices = Wootook_Empire_Helper_Config_Prices::getSingleton(); + + if ($player->getElement(Legacies_Empire::ID_RESEARCH_HYPERSPACE_DRIVE) < self::REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_HYPERSPACE_DRIVE && + $player->getElement(Legacies_Empire::ID_RESEARCH_HYPERSPACE_TECHNOLOGY) < self::REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_HYPERSPACE_TECHNOLOGY) { + return $prices[Legacies_Empire::ID_SHIP_SUPERNOVA][Legacies_Empire::SHIPS_CELERITY_PRIMARY]; + } else { + return $prices[Legacies_Empire::ID_SHIP_SUPERNOVA][Legacies_Empire::SHIPS_CELERITY_SECONDARY]; + } + } + + public function getSpeedMultiplier(Wootook_Player_Model_Entity $player) + { + if ($player->getElement(Legacies_Empire::ID_RESEARCH_HYPERSPACE_DRIVE) < self::REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_HYPERSPACE_DRIVE && + $player->getElement(Legacies_Empire::ID_RESEARCH_HYPERSPACE_TECHNOLOGY) < self::REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_HYPERSPACE_TECHNOLOGY) { + return pow(1.2, $player->getElement(Legacies_Empire::ID_RESEARCH_IMPULSE_DRIVE)); + } else { + return pow(1.3, $player->getElement(Legacies_Empire::ID_RESEARCH_HYPERSPACE_DRIVE)) * + pow(1.1, $player->getElement(Legacies_Empire::ID_RESEARCH_HYPERSPACE_TECHNOLOGY)); + } + } + + public function getBaseConsumption(Wootook_Player_Model_Entity $player) + { + return 0; + } +} \ No newline at end of file diff --git a/src/application/code/core/Legacies/Empire/Model/Player/Technology/IntergalacticResearchNetwork.php b/src/application/code/core/Legacies/Empire/Model/Player/Technology/IntergalacticResearchNetwork.php new file mode 100644 index 0000000..3e5507f --- /dev/null +++ b/src/application/code/core/Legacies/Empire/Model/Player/Technology/IntergalacticResearchNetwork.php @@ -0,0 +1,46 @@ +getData('enhancement'); + + /** @var Wootook_Empire_Model_Planet $planet */ + $planet = $event->getData('planet'); + + /** @var Wootook_Player_Model_Entity $player */ + $player = $event->getData('player'); + + + $virtualLevel = 1 + $planet->getElement(Legacies_Empire::ID_BUILDING_RESEARCH_LAB); + + if (($network = $player->getElement(Legacies_Empire::ID_RESEARCH_INTERGALACTIC_RESEARCH_NETWORK)) > 0) { + $planetCollection = $player->getPlanetCollection(Wootook_Empire_Model_Planet::TYPE_PLANET); + + $fields = Wootook_Empire_Helper_Config_FieldsAlias::getSingleton(); + $planetCollection->addFieldToFilter('id', array(array('nin' => $planet->getId()))) + ->addOrderBy($fields[Legacies_Empire::ID_BUILDING_RESEARCH_LAB], 'DESC') + ->setPageSize($network) + ; + + $select = $planetCollection->getSelect(); + $select->reset(Wootook_Core_Database_Sql_Select::COLUMNS); + $select->column(array('count' => new Wootook_Core_Database_Sql_Placeholder_Expression( + "COUNT({$select->quote($fields[Legacies_Empire::ID_BUILDING_RESEARCH_LAB])})"))); + + $statement = $select->prepare(); + $virtualLevel += $statement->fetchColumn(); + } + + $event->setData('enhancement', $enhancement * $virtualLevel); + } +} diff --git a/includes/application/code/core/Legacies/Core/install/mysql5/install-2011.1.0.php b/src/application/code/core/Legacies/Empire/install/mysql5/install-1.5.0.php similarity index 62% rename from includes/application/code/core/Legacies/Core/install/mysql5/install-2011.1.0.php rename to src/application/code/core/Legacies/Empire/install/mysql5/install-1.5.0.php index 03253cd..ba30531 100644 --- a/includes/application/code/core/Legacies/Core/install/mysql5/install-2011.1.0.php +++ b/src/application/code/core/Legacies/Empire/install/mysql5/install-1.5.0.php @@ -1,49 +1,37 @@ + * Copyright (c) 2011-Present, Grégory PLANCHAT * All rights reserved. * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: + * 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. * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. + * 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. * - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * - Neither the name of Grégory PLANCHAT nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . * * --> 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 One.Platform. + * documentation for further information about customizing Wootook. * */ -$this->setSetupConnection('legacies_setup'); +$this->setSetupConnection('core_setup'); $sql = <<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, @@ -59,14 +47,8 @@ SQL_EOF; $this->query($sql); -$this - ->grant('legacies/aks', 'legacies_read', array('SELECT')) - ->grant('legacies/aks', 'legacies_write', array('SELECT', 'CREATE', 'UPDATE', 'DELETE')) - ->grant('legacies/aks', 'legacies_setup') -; - $sql = <<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, @@ -88,14 +70,8 @@ SQL_EOF; $this->query($sql); -$this - ->grant('legacies/alliance', 'legacies_read', array('SELECT')) - ->grant('legacies/alliance', 'legacies_write', array('SELECT', 'CREATE', 'UPDATE', 'DELETE')) - ->grant('legacies/alliance', 'legacies_setup') -; - $sql = <<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, @@ -112,14 +88,8 @@ SQL_EOF; $this->query($sql); -$this - ->grant('legacies/annonce', 'legacies_read', array('SELECT')) - ->grant('legacies/annonce', 'legacies_write', array('SELECT', 'CREATE', 'UPDATE', 'DELETE')) - ->grant('legacies/annonce', 'legacies_setup') -; - $sql = <<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, @@ -134,14 +104,8 @@ SQL_EOF; $this->query($sql); -$this - ->grant('legacies/banned', 'legacies_read', array('SELECT')) - ->grant('legacies/banned', 'legacies_write', array('SELECT', 'CREATE', 'UPDATE', 'DELETE')) - ->grant('legacies/banned', 'legacies_setup') -; - $sql = <<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, @@ -153,14 +117,8 @@ SQL_EOF; $this->query($sql); -$this - ->grant('legacies/buddy', 'legacies_read', array('SELECT')) - ->grant('legacies/buddy', 'legacies_write', array('SELECT', 'CREATE', 'UPDATE', 'DELETE')) - ->grant('legacies/buddy', 'legacies_setup') -; - $sql = <<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, @@ -171,83 +129,8 @@ SQL_EOF; $this->query($sql); -$this - ->grant('legacies/chat', 'legacies_read', array('SELECT')) - ->grant('legacies/chat', 'legacies_write', array('SELECT', 'CREATE', 'UPDATE', 'DELETE')) - ->grant('legacies/chat', 'legacies_setup') -; - $sql = <<getTableName('legacies/config')} ( - `config_name` VARCHAR(64) NOT NULL, - `config_value` TEXT NOT NULL, - UNIQUE KEY (`config_name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; -SQL_EOF; - -$this->query($sql); - -$this - ->grant('legacies/config', 'legacies_read', array('SELECT')) - ->grant('legacies/config', 'legacies_write', array('SELECT', 'CREATE', 'UPDATE', 'DELETE')) - ->grant('legacies/config', 'legacies_setup') -; - -$sql = <<getTableName('legacies/config')} (`config_name`, `config_value`) VALUES - ('game_speed', '2500'), - ('fleet_speed', '2500'), - ('resource_multiplier', '1000'), - ('Fleet_Cdr', '30'), - ('Defs_Cdr', '30'), - ('initial_fields', '5000'), - ('COOKIE_NAME', 'xnova-legacies'), - ('game_name', 'XNova:Legacies'), - ('game_disable', '1'), - ('close_reason', 'Le jeu est clos pour le moment!'), - ('metal_basic_income', '20'), - ('crystal_basic_income', '10'), - ('deuterium_basic_income', '0'), - ('energy_basic_income', '0'), - ('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 XNova Legacies'), - ('OverviewExternChat', '0'), - ('OverviewExternChatCmd', ''), - ('OverviewBanner', '0'), - ('OverviewClickBanner', ''), - ('ExtCopyFrame', '0'), - ('ExtCopyOwner', ''), - ('ExtCopyFunct', ''), - ('ForumBannerFrame', '0'), - ('stat_settings', '1000'), - ('link_enable', '0'), - ('link_name', ''), - ('link_url', ''), - ('enable_announces', '1'), - ('enable_marchand', '1'), - ('enable_notes', '1'), - ('bot_name', 'XNoviana Reali'), - ('bot_adress', 'xnova@xnova.fr'), - ('banner_source_post', '../images/bann.png'), - ('ban_duration', '30'), - ('enable_bot', '0'), - ('enable_bbcode', '1'), - ('debug', '0'); -SQL_EOF; - -$this->query($sql); - -$sql = <<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, @@ -259,33 +142,8 @@ SQL_EOF; $this->query($sql); -$this - ->grant('legacies/declared', 'legacies_read', array('SELECT')) - ->grant('legacies/declared', 'legacies_write', array('SELECT', 'CREATE', 'UPDATE', 'DELETE')) - ->grant('legacies/declared', 'legacies_setup') -; - $sql = <<getTableName('legacies/errors')} ( - `error_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, - `error_sender` VARCHAR(32) NOT NULL, - `error_time` TIMESTAMP NOT NULL, - `error_type` VARCHAR(32) NOT NULL DEFAULT 'unknown', - `error_text` TEXT, - PRIMARY KEY (`error_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; -SQL_EOF; - -$this->query($sql); - -$this - ->grant('legacies/errors', 'legacies_read', array('SELECT')) - ->grant('legacies/errors', 'legacies_write', array('SELECT', 'CREATE', 'UPDATE', 'DELETE')) - ->grant('legacies/errors', 'legacies_setup') -; - -$sql = <<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, @@ -302,29 +160,22 @@ CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/fleets')} ( `fleet_end_system` SMALLINT UNSIGNED NOT NULL, `fleet_end_planet` TINYINT UNSIGNED NOT NULL, `fleet_end_type` TINYINT UNSIGNED NOT NULL, - `fleet_taget_owner` BIGINT UNSIGNED NOT NULL, + `fleet_target_owner` BIGINT UNSIGNED NOT NULL, `fleet_resource_metal` DECIMAL(65,0) NOT NULL DEFAULT 0, `fleet_resource_crystal` DECIMAL(65,0) NOT NULL DEFAULT 0, `fleet_resource_deuterium` DECIMAL(65,0) NOT NULL DEFAULT 0, - `fleet_target_owner` BIGINT UNSIGNED NOT NULL, `fleet_group` BIGINT UNSIGNED NOT NULL, `fleet_mess` BIGINT UNSIGNED NOT NULL, - `start_time` INT, + `start_time` TIMESTAMP NOT NULL, PRIMARY KEY (`fleet_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; SQL_EOF; $this->query($sql); -$this - ->grant('legacies/fleets', 'legacies_read', array('SELECT')) - ->grant('legacies/fleets', 'legacies_write', array('SELECT', 'CREATE', 'UPDATE', 'DELETE')) - ->grant('legacies/fleets', 'legacies_setup') -; - $sql = <<getTableName('legacies/galaxy')} ( - `galaxy` TINYINT UNSIGNED NOT NULL, +CREATE TABLE IF NOT EXISTS {$this->getTableName('galaxy')} ( + `galaxy` SMALLINT UNSIGNED NOT NULL, `system` SMALLINT UNSIGNED NOT NULL, `planet` TINYINT UNSIGNED NOT NULL, `id_planet` BIGINT UNSIGNED NOT NULL, @@ -341,14 +192,8 @@ SQL_EOF; $this->query($sql); -$this - ->grant('legacies/galaxy', 'legacies_read', array('SELECT')) - ->grant('legacies/galaxy', 'legacies_write', array('SELECT', 'CREATE', 'UPDATE', 'DELETE')) - ->grant('legacies/galaxy', 'legacies_setup') -; - $sql = <<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, @@ -367,14 +212,8 @@ SQL_EOF; $this->query($sql); -$this - ->grant('legacies/iraks', 'legacies_read', array('SELECT')) - ->grant('legacies/iraks', 'legacies_write', array('SELECT', 'CREATE', 'UPDATE', 'DELETE')) - ->grant('legacies/iraks', 'legacies_setup') -; - $sql = <<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', @@ -393,14 +232,8 @@ SQL_EOF; $this->query($sql); -$this - ->grant('legacies/lunas', 'legacies_read', array('SELECT')) - ->grant('legacies/lunas', 'legacies_write', array('SELECT', 'CREATE', 'UPDATE', 'DELETE')) - ->grant('legacies/lunas', 'legacies_setup') -; - $sql = <<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, @@ -415,14 +248,8 @@ SQL_EOF; $this->query($sql); -$this - ->grant('legacies/messages', 'legacies_read', array('SELECT')) - ->grant('legacies/messages', 'legacies_write', array('SELECT', 'CREATE', 'UPDATE', 'DELETE')) - ->grant('legacies/messages', 'legacies_setup') -; - $sql = <<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, @@ -433,14 +260,8 @@ SQL_EOF; $this->query($sql); -$this - ->grant('legacies/multi', 'legacies_read', array('SELECT')) - ->grant('legacies/multi', 'legacies_write', array('SELECT', 'CREATE', 'UPDATE', 'DELETE')) - ->grant('legacies/multi', 'legacies_setup') -; - $sql = <<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, @@ -453,14 +274,8 @@ SQL_EOF; $this->query($sql); -$this - ->grant('legacies/notes', 'legacies_read', array('SELECT')) - ->grant('legacies/notes', 'legacies_write', array('SELECT', 'CREATE', 'UPDATE', 'DELETE')) - ->grant('legacies/notes', 'legacies_setup') -; - $sql = <<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, @@ -468,37 +283,36 @@ CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/planets')} ( `galaxy` TINYINT UNSIGNED NOT NULL, `system` SMALLINT UNSIGNED NOT NULL, `planet` TINYINT UNSIGNED NOT NULL, - `last_update` TIMESTAMP NOT NULL, + `last_update` DATETIME NOT NULL, `planet_type` TINYINT UNSIGNED NOT NULL, - `destruyed` BOOL NOT NULL DEFAULT FALSE, - `b_building` SMALLINT UNSIGNED NOT NULL, + `destruyed` INT UNSIGNED NOT NULL DEFAULT FALSE, + `b_building` DATETIME NOT NULL, `b_building_id` TEXT NOT NULL, - `b_tech` SMALLINT UNSIGNED NOT NULL, - `b_tech_id` SMALLINT UNSIGNED NOT NULL, - `b_hangar` SMALLINT UNSIGNED NOT NULL, + `b_tech` DATETIME NOT NULL, + `b_tech_id` TEXT NOT NULL, + `b_hangar` DATETIME NOT NULL, `b_hangar_id` TEXT NOT NULL, - `b_hangar_plus` SMALLINT UNSIGNED NOT NULL, `image` VARCHAR(50) NOT NULL DEFAULT 'normaltempplanet01', `diameter` INT UNSIGNED NOT NULL DEFAULT 12800, `points` DECIMAL(65,0) NOT NULL DEFAULT 0, `ranks` BIGINT UNSIGNED NOT NULL, - `field_current` INT UNSIGNED NOT NULL DEFAULT 163, - `field_max` INT UNSIGNED NOT NULL DEFAULT 163, - `temp_min` INT NOT NULL DEFAULT 0, - `temp_max` INT NOT NULL DEFAULT 0, + `field_current` SMALLINT UNSIGNED NOT NULL DEFAULT 0, + `field_max` SMALLINT UNSIGNED NOT NULL DEFAULT 163, + `temp_min` SMALLINT NOT NULL DEFAULT 0, + `temp_max` SMALLINT NOT NULL DEFAULT 0, `metal` DECIMAL(65,0) NOT NULL DEFAULT 0, `metal_perhour` DECIMAL(65,0) NOT NULL DEFAULT 0, `metal_max` DECIMAL(65,0) NOT NULL DEFAULT 0, - `crystal` DECIMAL(65,0) NOT NULL DEFAULT 0, - `crystal_perhour` DECIMAL(65,0) NOT NULL DEFAULT 0, - `crystal_max` DECIMAL(65,0) NOT NULL DEFAULT 0, + `cristal` DECIMAL(65,0) NOT NULL DEFAULT 0, + `cristal_perhour` DECIMAL(65,0) NOT NULL DEFAULT 0, + `cristal_max` DECIMAL(65,0) NOT NULL DEFAULT 0, `deuterium` DECIMAL(65,0) NOT NULL DEFAULT 0, `deuterium_perhour` DECIMAL(65,0) NOT NULL DEFAULT 0, `deuterium_max` DECIMAL(65,0) NOT NULL DEFAULT 0, `energy_used` DECIMAL(65,0) NOT NULL DEFAULT 0, `energy_max` DECIMAL(65,0) NOT NULL DEFAULT 0, `metal_mine` SMALLINT UNSIGNED NOT NULL DEFAULT 0, - `crystal_mine` SMALLINT UNSIGNED NOT NULL DEFAULT 0, + `cristal_mine` SMALLINT UNSIGNED NOT NULL DEFAULT 0, `deuterium_sintetizer` SMALLINT UNSIGNED NOT NULL DEFAULT 0, `solar_plant` SMALLINT UNSIGNED NOT NULL DEFAULT 0, `fusion_plant` SMALLINT UNSIGNED NOT NULL DEFAULT 0, @@ -506,7 +320,7 @@ CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/planets')} ( `nano_factory` SMALLINT UNSIGNED NOT NULL DEFAULT 0, `hangar` SMALLINT UNSIGNED NOT NULL DEFAULT 0, `metal_store` SMALLINT UNSIGNED NOT NULL DEFAULT 0, - `crystal_store` SMALLINT UNSIGNED NOT NULL DEFAULT 0, + `cristal_store` SMALLINT UNSIGNED NOT NULL DEFAULT 0, `deuterium_store` SMALLINT UNSIGNED NOT NULL DEFAULT 0, `laboratory` SMALLINT UNSIGNED NOT NULL DEFAULT 0, `terraformer` SMALLINT UNSIGNED NOT NULL DEFAULT 0, @@ -529,18 +343,20 @@ CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/planets')} ( `destructor` DECIMAL(65,0) NOT NULL DEFAULT 0, `dearth_star` DECIMAL(65,0) NOT NULL DEFAULT 0, `battleship` DECIMAL(65,0) NOT NULL DEFAULT 0, + `supernova` DECIMAL(65,0) NOT NULL DEFAULT 0, + `ore_miner` DECIMAL(65,0) NOT NULL DEFAULT 0, `misil_launcher` DECIMAL(65,0) NOT NULL DEFAULT 0, `small_laser` DECIMAL(65,0) NOT NULL DEFAULT 0, `big_laser` DECIMAL(65,0) NOT NULL DEFAULT 0, `gauss_canyon` DECIMAL(65,0) NOT NULL DEFAULT 0, `ionic_canyon` DECIMAL(65,0) NOT NULL DEFAULT 0, `buster_canyon` DECIMAL(65,0) NOT NULL DEFAULT 0, - `small_protection_shield` ENUM('0','1') NOT NULL DEFAULT 0, - `big_protection_shield` ENUM('0','1') NOT NULL DEFAULT 0, + `small_protection_shield` ENUM('0','1') NOT NULL DEFAULT '0', + `big_protection_shield` ENUM('0','1') NOT NULL DEFAULT '0', `interceptor_misil` SMALLINT NOT NULL DEFAULT 0, `interplanetary_misil` SMALLINT NOT NULL DEFAULT 0, `metal_mine_porcent` TINYINT NOT NULL DEFAULT 10, - `crystal_mine_porcent` TINYINT NOT NULL DEFAULT 10, + `cristal_mine_porcent` TINYINT NOT NULL DEFAULT 10, `deuterium_sintetizer_porcent` TINYINT NOT NULL DEFAULT 10, `solar_plant_porcent` TINYINT NOT NULL DEFAULT 10, `fusion_plant_porcent` TINYINT NOT NULL DEFAULT 10, @@ -552,14 +368,8 @@ SQL_EOF; $this->query($sql); -$this - ->grant('legacies/planets', 'legacies_read', array('SELECT')) - ->grant('legacies/planets', 'legacies_write', array('SELECT', 'CREATE', 'UPDATE', 'DELETE')) - ->grant('legacies/planets', 'legacies_setup') -; - $sql = <<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, @@ -574,14 +384,8 @@ SQL_EOF; $this->query($sql); -$this - ->grant('legacies/rw', 'legacies_read', array('SELECT')) - ->grant('legacies/rw', 'legacies_write', array('SELECT', 'CREATE', 'UPDATE', 'DELETE')) - ->grant('legacies/rw', 'legacies_setup') -; - $sql = <<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, @@ -617,14 +421,8 @@ SQL_EOF; $this->query($sql); -$this - ->grant('legacies/statpoints', 'legacies_read', array('SELECT')) - ->grant('legacies/statpoints', 'legacies_write', array('SELECT', 'CREATE', 'UPDATE', 'DELETE')) - ->grant('legacies/statpoints', 'legacies_setup') -; - $sql = <<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 @@ -682,6 +480,7 @@ CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/users')} ( `intergalactic_tech` TINYINT UNSIGNED NOT NULL, -- FIXME `expedition_tech` TINYINT UNSIGNED NOT NULL, -- FIXME `graviton_tech` TINYINT UNSIGNED NOT NULL, -- FIXME + `ore_mining_tech` TINYINT UNSIGNED NOT NULL, -- FIXME `ally_id` BIGINT UNSIGNED NOT NULL, `ally_name` VARCHAR(32) NULL, -- FIXME `ally_request` BOOL NOT NULL DEFAULT FALSE, -- FIXME @@ -689,25 +488,9 @@ CREATE TABLE IF NOT EXISTS {$this->getTableName('legacies/users')} ( `ally_register_time` TIMESTAMP NOT NULL, -- FIXME `ally_rank_id` BIGINT UNSIGNED NOT NULL, -- FIXME `current_luna` INT NOT NULL, -- FIXME - `kolorminus` VARCHAR(11) NOT NULL DEFAULT 'red', - `kolorplus` VARCHAR(11) NOT NULL DEFAULT '#00FF00', - `kolorpoziom` VARCHAR(11) NOT NULL DEFAULT 'yellow', - `rpg_geologue` TINYINT UNSIGNED NOT NULL, -- FIXME - `rpg_amiral` TINYINT UNSIGNED NOT NULL, -- FIXME - `rpg_ingenieur` TINYINT UNSIGNED NOT NULL, -- FIXME - `rpg_technocrate` TINYINT UNSIGNED NOT NULL, -- FIXME - `rpg_espion` TINYINT UNSIGNED NOT NULL, -- FIXME - `rpg_constructeur` TINYINT UNSIGNED NOT NULL, -- FIXME - `rpg_scientifique` TINYINT UNSIGNED NOT NULL, -- FIXME - `rpg_commandant` TINYINT UNSIGNED NOT NULL, -- FIXME - `rpg_points` TINYINT UNSIGNED NOT NULL, -- FIXME - `rpg_stockeur` TINYINT UNSIGNED NOT NULL, -- FIXME - `rpg_defenseur` TINYINT UNSIGNED NOT NULL, -- FIXME - `rpg_destructeur` TINYINT UNSIGNED NOT NULL, -- FIXME - `rpg_general` TINYINT UNSIGNED NOT NULL, -- FIXME - `rpg_bunker` TINYINT UNSIGNED NOT NULL, -- FIXME - `rpg_raideur` TINYINT UNSIGNED NOT NULL, -- FIXME - `rpg_empereur` TINYINT UNSIGNED NOT NULL, -- FIXME + `kolorminus` VARCHAR(11) NOT NULL DEFAULT 'red', + `kolorplus` VARCHAR(11) NOT NULL DEFAULT '#00FF00', + `kolorpoziom` VARCHAR(11) NOT NULL DEFAULT 'yellow', `lvl_minier` BIGINT UNSIGNED NOT NULL, -- FIXME `lvl_raid` BIGINT UNSIGNED NOT NULL, -- FIXME `xpraid` BIGINT UNSIGNED NOT NULL, -- FIXME @@ -736,57 +519,320 @@ SQL_EOF; $this->query($sql); -$this - ->grant('legacies/users', 'legacies_read', array('SELECT')) - ->grant('legacies/users', 'legacies_write', array('SELECT', 'CREATE', 'UPDATE', 'DELETE')) - ->grant('legacies/users', 'legacies_setup') -; +/* + * Galaxy positions generation + */ +$galaxyCount = Wootook::getConfig('engine/universe/galaxies'); +$systemCount = Wootook::getConfig('engine/universe/systems'); $sql = <<getTableName('legacies/alliance')} ( - `id`, `ally_name`, `ally_tag`, `ally_owner`, `ally_register_time`, `ally_description`, - `ally_web`, `ally_text`, `ally_image`, `ally_request`, `ally_request_waiting`, - `ally_request_notallow`, `ally_owner_range`, `ally_ranks`, `ally_members` - ) - VALUES - ('1', 'Admin', 'Admin', 1, NOW(), 'Administrator alliance', 'http://www.xnova-ng.org/', - '', '', '', '', '', '', '', '') -SQL_EOF; - -$this->query($sql); - -$sql = <<getTableName('legacies/users')} ( - `id`, `username`, `password`, `email`, `email_2`, `lang`, `authlevel`, `sex`, - `avatar`, `sign`, `id_planet`, `galaxy`, `system`, `planet`, `current_planet`, - `user_lastip`, `ip_at_reg`, `user_agent`, `current_page`, `register_time`, - `onlinetime`, `dpath`, `design`, `noipcheck`, `planet_sort`, `planet_sort_order`, - `spio_anz`, `settings_tooltiptime`, `settings_fleetactions`, `settings_allylogo`, - `settings_esp`, `settings_wri`, `settings_bud`, `settings_mis`, `settings_rep`, - `urlaubs_modus`, `urlaubs_until`, `db_deaktjava`, `new_message`, `fleet_shortcut`, - `b_tech_planet`, `spy_tech`, `computer_tech`, `military_tech`, `defence_tech`, - `shield_tech`, `energy_tech`, `hyperspace_tech`, `combustion_tech`, - `impulse_motor_tech`, `hyperspace_motor_tech`, `laser_tech`, `ionic_tech`, - `buster_tech`, `intergalactic_tech`, `expedition_tech`, `graviton_tech`, - `ally_id`, `ally_name`, `ally_request`, `ally_request_text`, `ally_register_time`, - `ally_rank_id`, `current_luna`, `kolorminus`, `kolorplus`, `kolorpoziom`, - `rpg_geologue`, `rpg_amiral`, `rpg_ingenieur`, `rpg_technocrate`, `rpg_espion`, - `rpg_constructeur`, `rpg_scientifique`, `rpg_commandant`, `rpg_points`, `rpg_stockeur`, - `rpg_defenseur`, `rpg_destructeur`, `rpg_general`, `rpg_bunker`, `rpg_raideur`, - `rpg_empereur`, `lvl_minier`, `lvl_raid`, `xpraid`, `xpminier`, `raids`, - `p_infligees`, `mnl_alliance`, `mnl_joueur`, `mnl_attaque`, `mnl_spy`, - `mnl_exploit`, `mnl_transport`, `mnl_expedition`, `mnl_general`, `mnl_buildlist`, - `bana`, `multi_validated`, `banaday`, `raids1`, `raidswin`, `raidsloose` - ) - VALUES - ('1', 'Admin', '', '', '', 'fr', '3', NULL, '', '', '1', '1', '1', '1', - '1', '127.0.0.1', '', '', '', '1254743313', '1269391977', '', '1', '1', '0', - '0', '1', '5', '0', '0', '1', '1', '1', '1', '0', '0', '0', '0', '0', '', '0', - '16', '20', '11', '11', '11', '12', '10', '14', '10', '9', '0', '0', '0', '0', - '0', '1', 1, 'Admin', '0', '', NOW(), '0', '0', 'red', '#00FF00', 'yellow', '20', - '20', '10', '10', '0', '3', '3', '0', '27', '2', '2', '0', '0', '0', '0', '0', - '98', '1', '0', '1133583738', '0', '0', '0', '0', '0', '0', '0', '0', '0', - '0', '0', '0', '0', '0', '0', '0', '0') +INSERT INTO {$this->getTableName('galaxy')} + (`galaxy`, `system`, `planet`, `id_planet`, `metal`, `crystal`, `id_luna`, `luna`) + SELECT + _increment.galaxy AS `galaxy`, + _increment.system AS `system`, + 0 AS `planet`, + 0 AS `id_planet`, + 0 AS `metal`, + 0 AS `crystal`, + 0 AS `id_luna`, + 0 AS `luna` + FROM ( + SELECT + (1 + _galaxy_10e0.galaxy + _galaxy_10e1.galaxy + _galaxy_10e2.galaxy + _galaxy_10e3.galaxy + _galaxy_10e4.galaxy) AS galaxy, + (1 + _system_10e0.system + _system_10e1.system + _system_10e2.system + _system_10e3.system + _system_10e4.system) AS 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 + ) AS _system_10e0 +SQL_EOF; + +if ($systemCount > 10) { + $sql .= << 100) { +$sql .= << 1000) { + $sql .= << 10000) { + $sql .= << 10) { + $sql .= << 100) { + $sql .= << 1000) { + $sql .= << 10000) { +$sql .= <<query($sql); diff --git a/includes/application/code/core/Legacies/Core/install/mysql5/uninstall-2011.1.0.php b/src/application/code/core/Legacies/Empire/install/mysql5/uninstall-1.5.0.php similarity index 70% rename from includes/application/code/core/Legacies/Core/install/mysql5/uninstall-2011.1.0.php rename to src/application/code/core/Legacies/Empire/install/mysql5/uninstall-1.5.0.php index 73bca1b..040f676 100644 --- a/includes/application/code/core/Legacies/Core/install/mysql5/uninstall-2011.1.0.php +++ b/src/application/code/core/Legacies/Empire/install/mysql5/uninstall-1.5.0.php @@ -1,6 +1,6 @@ setSetupConnection('legacies_setup'); +$this->setSetupConnection('core_setup'); $sql = <<getTableName('legacies/aks')}; +DROP TABLE {$this->getTableName('aks')}; SQL_EOF; $this->query($sql); $sql = <<getTableName('legacies/alliance')}; +DROP TABLE {$this->getTableName('alliance')}; SQL_EOF; $this->query($sql); $sql = <<getTableName('legacies/annonce')}; +DROP TABLE {$this->getTableName('annonce')}; SQL_EOF; $this->query($sql); $sql = <<getTableName('legacies/banned')}; +DROP TABLE {$this->getTableName('banned')}; SQL_EOF; $this->query($sql); $sql = <<getTableName('legacies/buddy')}; +DROP TABLE {$this->getTableName('buddy')}; SQL_EOF; $this->query($sql); $sql = <<getTableName('legacies/chat')}; +DROP TABLE {$this->getTableName('chat')}; SQL_EOF; $this->query($sql); $sql = <<getTableName('legacies/config')}; +DROP TABLE {$this->getTableName('declared')}; SQL_EOF; $this->query($sql); $sql = <<getTableName('legacies/declared')}; +DROP TABLE {$this->getTableName('fleets')}; SQL_EOF; $this->query($sql); $sql = <<getTableName('legacies/errors')}; +DROP TABLE {$this->getTableName('galaxy')}; SQL_EOF; $this->query($sql); $sql = <<getTableName('legacies/fleets')}; +DROP TABLE {$this->getTableName('iraks')}; SQL_EOF; $this->query($sql); $sql = <<getTableName('legacies/galaxy')}; +DROP TABLE {$this->getTableName('lunas')}; SQL_EOF; $this->query($sql); $sql = <<getTableName('legacies/iraks')}; +DROP TABLE {$this->getTableName('messages')}; SQL_EOF; $this->query($sql); $sql = <<getTableName('legacies/lunas')}; +DROP TABLE {$this->getTableName('multi')}; SQL_EOF; $this->query($sql); $sql = <<getTableName('legacies/messages')}; +DROP TABLE {$this->getTableName('notes')}; SQL_EOF; $this->query($sql); $sql = <<getTableName('legacies/multi')}; +DROP TABLE {$this->getTableName('planets')}; SQL_EOF; $this->query($sql); $sql = <<getTableName('legacies/notes')}; +DROP TABLE {$this->getTableName('rw')}; SQL_EOF; $this->query($sql); $sql = <<getTableName('legacies/planets')}; +DROP TABLE {$this->getTableName('statpoints')}; SQL_EOF; $this->query($sql); $sql = <<getTableName('legacies/rw')}; -SQL_EOF; - -$this->query($sql); - -$sql = <<getTableName('legacies/statpoints')}; -SQL_EOF; - -$this->query($sql); - -$sql = <<getTableName('legacies/users')}; +DROP TABLE {$this->getTableName('users')}; SQL_EOF; $this->query($sql); diff --git a/src/application/code/core/Legacies/Exception.php b/src/application/code/core/Legacies/Exception.php new file mode 100644 index 0000000..a86c60b --- /dev/null +++ b/src/application/code/core/Legacies/Exception.php @@ -0,0 +1,37 @@ + + * 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 . + * + * --> 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 + * + */ + +interface Legacies_Exception {} \ No newline at end of file diff --git a/src/application/code/core/Legacies/Stats/Block/View.php b/src/application/code/core/Legacies/Stats/Block/View.php new file mode 100644 index 0000000..d966318 --- /dev/null +++ b/src/application/code/core/Legacies/Stats/Block/View.php @@ -0,0 +1,43 @@ +_statData)) { + $readAdapter = Wootook_Core_Database_ConnectionManager::getSingleton()->getConnection('core_read'); + + $statement = $readAdapter->select() + ->from($readAdapter->getTable('statpoints')) + ->where('stat_type', $type) + ->prepare() + ; + + $statement->execute(); + $this->_statData = $statement->fetchAll(); + } + return $this->_statData; + } + + public function getPlayerStatData() + { + if (empty($this->_statData)) { + $playerId = Wootook_Player_Model_Session::getSingleton()->getPlayerId(); + + $readAdapter = Wootook_Core_Database_ConnectionManager::getSingleton()->getConnection('core_read'); + + $statement = $readAdapter->select() + ->from($readAdapter->getTable('statpoints')) + ->where('id_owner', $playerId) + ->prepare() + ; + + $statement->execute(); + $this->_statData = $statement->fetchAll(); + } + return $this->_statData; + } +} diff --git a/src/application/code/core/Wootook.php b/src/application/code/core/Wootook.php new file mode 100644 index 0000000..0515ab1 --- /dev/null +++ b/src/application/code/core/Wootook.php @@ -0,0 +1,843 @@ + + * 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 . + * + * --> 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. + * + */ + +/** + * Bootstrap class, used to access main and global functionalities + * + * @package Wootook + * @category core + */ +class Wootook +{ + /** + * Static list of application event listeners + * + * @var array + */ + private static $_listeners = array(); + + /** + * Static list of all locale translators + * + * @var array + */ + private static $_translators = array(); + + /** + * HTTP request management object + * + * @var Legacies_Core_Controller_Request_Http + */ + private static $_request = null; + + /** + * HTTP response management object + * + * @var Legacies_Core_Controller_Response + */ + private static $_response = null; + + /** + * The current timestamp + * + * @var int + */ + private static $_now = null; + + /** + * Default locale identifier + * + * @var string + */ + private static $_defaultLocale = 'fr_FR'; + + /** + * + * Enter description here ... + * @var Wootook_Core_Helper_Config_ConfigHandler + */ + private static $_config = null; + + /** + * + * Enter description here ... + * @var Wootook_Core_Helper_Config_ConfigHandler + */ + private static $_globalConfig = null; + + /** + * + * Enter description here ... + * @var array + */ + private static $_websiteConfigs = array(); + + /** + * + * Enter description here ... + * @var array + */ + private static $_gameConfigs = array(); + + /** + * + * Enter description here ... + * @var array + */ + private static $_ignoreDatabaseConfig = false; + + private static $_defaultWebsite = null; + private static $_defaultGame = null; + + private static $_websitesById = array(); + private static $_websitesByCode = array(); + private static $_gamesById = array(); + private static $_gamesByCode = array(); + + public static $isInstalled = true; + + /** + * Registers an event listener to be called later in the application. + * + * @param string $event The event identifier + * @param callback $listener The event callback to be called + */ + public static function registerListener($event, $listener) + { + if (!isset(self::$_listeners[$event])) { + self::$_listeners[$event] = array(); + } + self::$_listeners[$event][] = $listener; + } + + /** + * Clear all event listeners + */ + public static function clearAllListeners() + { + self::$_listeners = array(); + } + + /** + * Clear a specific event's listeners + * + * @param unknown_type $event + */ + public static function clearEventListeners($event) + { + if (isset(self::$_listeners[$event])) { + self::$_listeners[$event] = array(); + } + } + + /** + * Dispatches an event, calls all callbacks that were previously registered + * + * @param string $event The event identifier + * @param array $params The event params + */ + public static function dispatchEvent($event, $params) + { + $eventObject = new Wootook_Core_Event($params); + + if (!isset(self::$_listeners[$event])) { + return $eventObject; + } + + foreach (self::$_listeners[$event] as $listener) { + call_user_func($listener, $eventObject); + } + + return $eventObject; + } + + /** + * + * Enter description here ... + * @param unknown_type $namespace + * @return Wootook_Core_Model_Session + */ + public static function getSession($namespace) + { + return Wootook_Core_Model_Session::factory($namespace); + } + + /** + * @static + * @param string|null $locale + * @return Wootook_Core_Model_Translator + */ + public static function getTranslator($locale = null) + { + if ($locale === null) { + $locale = self::getLocale(); + } + + if (!isset($translator[$locale])) { + $path = dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'locale'; + $translator[$locale] = new Wootook_Core_Model_Translator($path, $locale); + } + return $translator[$locale]; + } + + public static function translate($locale, $message, Array $args) + { + return self::getTranslator($locale)->translateArgs($message, $args); + } + + public static function __($message, $_ = null) + { + $args = func_get_args(); + array_shift($args); + + return self::getTranslator(self::getLocale())->translateArgs($message, $args); + } + + public static function getLocale() + { + $availableLocales = self::getWebsiteConfig('locales'); + if ($availableLocales !== null) { + return self::getPreferredLocale($availableLocales->toArray()); + } + return self::getPreferredLocale(); + } + + public static function setDefaultLocale($locale) + { + $oldLocale = self::$_defaultLocale; + self::$_defaultLocale = $locale; + + return $oldLocale; + } + + public static function getDefaultLocale() + { + return self::$_defaultLocale; + } + + public static function getPreferredLocale($availableLocales = array()) + { + if (empty($availableLocales)) { + return self::getDefaultLocale(); + } + + $userLocale = Wootook_Player_Model_Session::getSingleton()->getData('locale'); + if ($userLocale !== null && in_array($userLocale, $availableLocales)) { + return $userLocale; + } + + $locales = array(); + + if (($accept = self::getRequest()->getServer('HTTP_ACCEPT_LANGUAGE')) !== null) { + // break up string into pieces (languages and q factors) + preg_match_all('/([a-z]{1,8}(?:-([a-z]{1,8}))?)\s*(?:;\s*q\s*=\s*(1|0\.[0-9]+))?/i', $accept, $matches); + + $length = count($matches[1]); + for ($i = 0; $i < $length; $i++) { + $locale = $matches[1][$i]; + if (!empty($matches[2][$i])) { + $locale .= '_' . strtoupper($matches[2][$i]); + } + $locales[$locale] = !empty($matches[3][$i]) ? min(max(floatval($matches[3][$i]), 0), 1) : 1; + } + + arsort($locales, SORT_NUMERIC); + } + + if (empty($locales)) { + return self::getDefaultLocale(); + } + + $preferredLocale = current($availableLocales); + $preferredPriority = 0; + foreach ($locales as $locale => $piority) { + if (!in_array($locale, $availableLocales)) { + continue; + } + if ($preferredPriority < $piority) { + $preferredPriority = $piority; + $preferredLocale = $locale; + } + } + + Wootook_Player_Model_Session::getSingleton()->setData('locale', $preferredLocale); + + return $preferredLocale; + } + + /** + * @static + * @return Wootook_Core_DateTime + */ + public static function now() + { + if (self::$_now === null) { + self::$_now = time(); + } + return new Wootook_Core_DateTime(self::$_now); + } + + /** + * @return Wootook_Core_Mvc_Controller_Request_Http + */ + public static function getRequest() + { + if (self::$_request === null) { + self::$_request = new Wootook_Core_Mvc_Controller_Request_Http(); + } + return self::$_request; + } + + public static function setRequest($request) + { + self::$_request = $request; + } + + /** + * @return Wootook_Core_Mvc_Controller_Response_Http + */ + public static function getResponse() + { + if (self::$_response === null) { + self::$_response = new Wootook_Core_Mvc_Controller_Response_Http(); + } + return self::$_response; + } + + public static function setResponse($response) + { + self::$_response = $response; + } + + public static function loadConfig($filename = null) + { + self::$_websiteConfigs = array(); + self::$_gameConfigs = array(); + + self::$_config = new Wootook_Core_Config_Adapter_Array(); + try { + self::$_config->load(APPLICATION_PATH . 'configs' . DIRECTORY_SEPARATOR . 'system.php'); + + if ($filename === null) { + $filename = APPLICATION_PATH . 'configs' . DIRECTORY_SEPARATOR . 'local.php'; + } + + if (is_string($filename)) { + if (!self::$isInstalled) { + throw new Wootook_Core_Exception_DataAccessException(); + } + $localConfig = new Wootook_Core_Config_Adapter_Array($filename); + self::$_config->merge($localConfig); + } else if (is_array($filename)) { + $localConfig = new Wootook_Core_Config_Node($filename); + self::$_config->merge($localConfig); + } else if ($filename instanceof Wootook_Core_Config_Node) { + self::$_config->merge($filename); + } else { + throw new Wootook_Core_Exception_DataAccessException(); + } + } catch (Wootook_Core_Exception_DataAccessException $e) { + self::$_globalConfig = new Wootook_Core_Config_Node(array(), self::$_config); + self::$_ignoreDatabaseConfig = true; + return self::$_config; + } + + self::$_globalConfig = clone self::$_config['default']; + if (isset(self::$_config['global'])) { + self::$_globalConfig->merge(self::$_config['global']); + } + + self::_appendDatabaseConfig(self::$_globalConfig); + + return self::$_config; + } + + private static function _appendDatabaseConfig(Wootook_Core_Config_Node $config, $type = 'global', $model = null) + { + if (self::$_ignoreDatabaseConfig || !self::$isInstalled) { + return $config; + } + + try { + $adapter = Wootook_Core_Database_ConnectionManager::getSingleton() + ->getConnection('core_read'); + } catch (Wootook_Core_Exception_Database_AdapterError $e) { + // This may also occur when the pdo_sqlite driver isn't loaded + self::$isInstalled = false; + Wootook_Core_ErrorProfiler::getSingleton()->addException($e); + return $config; + } + + $select = $adapter->select($adapter->getTable('core_config')); + + switch ($type) { + case 'website': + $select->where(new Wootook_Core_Database_Sql_Placeholder_Expression('website_id = :website_id', array('website_id' => $model->getId()))); + break; + + case 'game': + $select->where(new Wootook_Core_Database_Sql_Placeholder_Expression('game_id = :game_id', array('game_id' => $model->getId()))); + break; + + default: + $select->where('website_id', 0); + $select->where('game_id', 0); + break; + } + + $statement = $select->prepare(); + $statement->execute(); + + foreach ($statement as $row) { + $config->setConfig($row['config_path'], $row['config_value']); + } + + return $config; + } + + public static function getWebsite($websiteId) + { + if (is_numeric($websiteId)) { + if (isset(self::$_websitesById[$websiteId])) { + return self::$_websitesById[$websiteId]; + } + $website = new Wootook_Core_Model_Website(); + try { + $website->load($websiteId); + $websiteCode = $website->getData('code'); + + self::$_websitesById[$websiteId] = $website; + self::$_websitesByCode[$websiteCode] = $website; + } catch (Wootook_Core_Exception_DataAccessException $e) { + throw new Wootook_Core_Exception_WebsiteError('Could not load website entity.', null, $e); + } + + return $website; + } else { + if (isset(self::$_websitesByCode[$websiteId])) { + return self::$_websitesByCode[$websiteId]; + } + $website = new Wootook_Core_Model_Website(); + try { + $website->load($websiteId, 'code'); + $websiteId = $website->getId(); + $websiteCode = $website->getData('code'); + + self::$_websitesById[$websiteId] = $website; + self::$_websitesByCode[$websiteCode] = $website; + } catch (Wootook_Core_Exception_DataAccessException $e) { + throw new Wootook_Core_Exception_WebsiteError('Could not load website entity.', null, $e); + } + + return $website; + } + } + + public static function getGame($gameId) + { + if (is_numeric($gameId)) { + if (isset(self::$_gamesById[$gameId])) { + return self::$_gamesById[$gameId]; + } + $game = new Wootook_Core_Model_Game(); + try { + $game->load($gameId); + $gameCode = $game->getData('code'); + + self::$_gamesById[$gameId] = $game; + self::$_gamesByCode[$gameCode] = $game; + } catch (Wootook_Core_Exception_DataAccessException $e) { + throw new Wootook_Core_Exception_GameError('Could not load game entity.', null, $e); + } + + return $game; + } else { + if (isset(self::$_gamesByCode[$gameId])) { + return self::$_gamesByCode[$gameId]; + } + $game = new Wootook_Core_Model_Game(); + try { + $game->load($gameId, 'code'); + $gameId = $game->getId(); + $gameCode = $game->getData('code'); + + self::$_gamesById[$gameId] = $game; + self::$_gamesByCode[$gameCode] = $game; + } catch (Wootook_Core_Exception_DataAccessException $e) { + throw new Wootook_Core_Exception_GameError('Could not load game entity.', null, $e); + } + + return $game; + } + } + + public static function addWebsite(Wootook_Core_Model_Website $website) + { + $websiteId = $website->getId(); + $websiteKey = $website->getData('code'); + self::$_websitesById[$websiteId] = $website; + self::$_websitesByCode[$websiteKey] = $website; + } + + public static function addGame(Wootook_Core_Model_Game $game) + { + $gameId = $game->getId(); + $gameKey = $game->getData('code'); + self::$_gamesById[$gameId] = $game; + self::$_gamesByCode[$gameKey] = $game; + } + + public static function setDefaultWebsite(Wootook_Core_Model_Website $website) + { + self::$_defaultWebsite = $website; + } + + public static function getDefaultWebsite() + { + if (self::$_defaultWebsite === null) { + self::$_defaultWebsite = new Wootook_Core_Model_Website(); + self::$_defaultWebsite->setId(1)->setData('code', Wootook_Core_Model_Website::DEFAULT_CODE); + } + return self::$_defaultWebsite; + } + + public static function getDefaultGame() + { + if (self::$_defaultGame === null) { + self::$_defaultGame = new Wootook_Core_Model_Game(); + self::$_defaultGame->setId(1)->setData('code', Wootook_Core_Model_Game::DEFAULT_CODE); + } + return self::$_defaultGame; + } + + public static function setDefaultGame(Wootook_Core_Model_Game $game) + { + self::$_defaultGame = $game; + } + + private static function _initWebsiteConfig($websiteId) + { + if (self::$_config === null) { + self::loadConfig(); + } + if (!self::$isInstalled) { + if (isset(self::$_config['default'])) { + self::$_websiteConfigs[Wootook_Core_Model_Website::DEFAULT_CODE] = clone self::$_config['default']; + } else { + self::$_websiteConfigs[Wootook_Core_Model_Website::DEFAULT_CODE] = new Wootook_Core_Config_Node(array(), self::$_config); + } + if (isset(self::$_config['install'])) { + self::$_websiteConfigs[Wootook_Core_Model_Website::DEFAULT_CODE]->merge(self::$_config['install']); + } + + return self::$_websiteConfigs[Wootook_Core_Model_Website::DEFAULT_CODE]; + } + + try { + $website = self::getWebsite($websiteId); + } catch (Wootook_Core_Exception_WebsiteError $e) { + self::$isInstalled = false; + Wootook_Core_ErrorProfiler::getSingleton()->addException($e); + + $website = new Wootook_Core_Model_Website(); + $website->setId(0)->setData('code', 'install'); + self::addWebsite($website); + self::setDefaultWebsite($website); + } catch (Wootook_Core_Exception_RuntimeException $e) { + Wootook_Core_ErrorProfiler::getSingleton()->exceptionManager($e); + return null; + } + $websiteKey = $website->getData('code'); + $websiteId = $website->getId(); + + if (!isset(self::$_websiteConfigs[$websiteKey])) { + self::$_websiteConfigs[$websiteKey] = clone self::$_config['default']; + if ($websiteId != 0 && isset(self::$_config['frontend'])) { + self::$_websiteConfigs[$websiteKey]->merge(self::$_config['frontend']); + } else if ($websiteId == 0 && isset(self::$_config['backend'])) { + self::$_websiteConfigs[$websiteKey]->merge(self::$_config['backend']); + } + + $websiteConfig = self::$_config->getConfig("website/{$websiteKey}"); + if ($websiteConfig !== null) { + self::$_websiteConfigs[$websiteKey]->merge($websiteConfig); + } + + self::_appendDatabaseConfig(self::$_websiteConfigs[$websiteKey], 'website', $website); + } + + return self::$_websiteConfigs[$websiteKey]; + } + + private static function _initGameConfig($gameId) + { + if (self::$_config === null) { + self::loadConfig(); + } + + if (!self::$isInstalled) { + if (isset(self::$_config['default'])) { + self::$_gameConfigs[Wootook_Core_Model_Game::DEFAULT_CODE] = clone self::$_config['default']; + } else { + self::$_gameConfigs[Wootook_Core_Model_Game::DEFAULT_CODE] = new Wootook_Core_Config_Node(array(), self::$_config); + } + if (isset(self::$_config['install'])) { + self::$_gameConfigs[Wootook_Core_Model_Game::DEFAULT_CODE]->merge(self::$_config['install']); + } + + return self::$_gameConfigs[Wootook_Core_Model_Game::DEFAULT_CODE]; + } + + try { + $game = self::getGame($gameId); + } catch (Wootook_Core_Exception_GameError $e) { + self::$isInstalled = false; + Wootook_Core_ErrorProfiler::getSingleton()->addException($e); + + $game = new Wootook_Core_Model_Game(); + $game->setId(0)->setData('code', 'install')->setData('website_id', self::getDefaultWebsite()->getId()); + self::addGame($game); + self::setDefaultGame($game); + } catch (Wootook_Core_Exception_RuntimeException $e) { + Wootook_Core_ErrorProfiler::getSingleton()->exceptionManager($e); + return null; + } + + $gameKey = $game->getData('code'); + $gameId = $game->getId(); + $websiteId = $game->getData('website_id'); + + if (!isset(self::$_gameConfigs[$gameKey])) { + $websiteConfig = self::_initWebsiteConfig($websiteId); + if ($websiteConfig === null) { + return null; + } + self::$_gameConfigs[$gameKey] = clone $websiteConfig; + + $gameConfig = self::$_config->getConfig("game/{$gameKey}"); + if ($gameConfig !== null) { + self::$_gameConfigs[$gameKey]->merge($gameConfig); + } + + self::_appendDatabaseConfig(self::$_gameConfigs[$gameKey], 'game', $game); + } + + return self::$_gameConfigs[$gameKey]; + } + + public static function getConfig($path = null) + { + if (self::$_config === null) { + self::loadConfig(); + } + + if ($path !== null) { + return self::$_globalConfig->getConfig($path); + } + return self::$_globalConfig; + } + + /** + * @static + * @param null $path + * @param null $gameKey + * @return Wootook_Core_Config_Node + */ + public static function getWebsiteConfig($path = null, $websiteKey = null) + { + if (self::$_config === null) { + self::loadConfig(); + } + + if ($websiteKey === null) { + //$websiteKey = Wootook_Core_Model_Website::DEFAULT_CODE; + $websiteKey = self::getDefaultWebsite()->getData('code'); + } + + $config = self::_initWebsiteConfig($websiteKey); + if ($config === null) { + return null; + } + + if ($path !== null) { + return $config->getConfig($path); + } + return $config; + } + + /** + * @static + * @param null $path + * @param null $gameKey + * @return Wootook_Core_Config_Node + */ + public static function getGameConfig($path = null, $gameKey = null) + { + if (self::$_config === null) { + self::loadConfig(); + } + + if ($gameKey === null) { + //$gameKey = Wootook_Core_Model_Game::DEFAULT_CODE; + $gameKey = self::getDefaultGame()->getData('code'); + } + + $config = self::_initGameConfig($gameKey); + if ($config === null) { + return null; + } + + if ($path !== null) { + return $config->getConfig($path); + } + return $config; + } + + public static function setConfig($path, $value, $websiteId = null, $gameId = null) + { + if (self::$_config === null) { + self::loadConfig(); + } + + if (!self::$_ignoreDatabaseConfig) { + $updater = new Wootook_Core_Model_Config(); + $updater->setPath($path)->setValue($value); + if ($websiteId !== null) { + $updater->setWebsiteId($websiteId); + if ($gameId !== null) { + $updater->setGameId($gameId); + self::$_gameConfigs[$gameId]->setConfig($path, $value); + } else { + self::$_websiteConfigs[$websiteId]->setConfig($path, $value); + } + } else { + self::$_globalConfig->setConfig($path, $value); + } + $updater->save(); + } else if ($websiteId !== null) { + if ($gameId !== null) { + self::$_gameConfigs[$gameId]->setConfig($path, $value); + } else { + self::$_websiteConfigs[$websiteId]->setConfig($path, $value); + } + } else { + self::$_globalConfig->setConfig($path, $value); + } + + return true; + } + + public static function getBaseUrl($domain = 'base') + { + $urlConfig = self::getGameConfig('web/url'); + if (!$urlConfig instanceof Wootook_Core_Config_Node) { + return null; + } + if (!is_string($domain) || !isset($urlConfig->$domain)) { + return $urlConfig->base; + } + return $urlConfig->$domain; + } + + public static function getBasePath($domain = 'base') + { + $pathConfig = self::getGameConfig('system/path'); + if (!$pathConfig instanceof Wootook_Core_Config_Node) { + return null; + } + if (!is_string($domain) || !isset($pathConfig->$domain)) { + return $pathConfig->base; + } + return $pathConfig->$domain; + } + + public static function getUrl($uri, Array $params = array()) + { + $baseUrl = self::getBaseUrl(); + + $queryParams = array(); + if (isset($params['_query'])) { + $queryParams = $params['_query']; + unset($params['_query']); + } + + $serializedParams = array(); + foreach ($params as $paramKey => $paramValue) { + if ($paramValue) { + $serializedParams[] = "{$paramKey}/{$paramValue}"; + } + } + + $serializedQueryParams = array(); + foreach ($queryParams as $paramKey => $paramValue) { + if ($paramValue) { + $serializedQueryParams[] = "{$paramKey}={$paramValue}"; + } + } + + if (count($serializedQueryParams) > 0) { + return $baseUrl . $uri . '/' . implode('/', $serializedParams) . '?' . implode('&', $serializedQueryParams); + } + return $baseUrl . $uri . '/' . implode('/', $serializedParams); + } + + public static function getStaticUrl($uri, Array $params = array()) + { + $baseUrl = self::getBaseUrl('static'); + + $serializedParams = array(); + foreach ($params as $paramKey => $paramValue) { + if ($paramValue) { + $serializedParams[] = "{$paramKey}={$paramValue}"; + } + } + + if (count($serializedParams) > 0) { + return $baseUrl . $uri . '?' . implode('&', $serializedParams); + } + return $baseUrl . $uri; + } + + public static function fileExists($path) + { + if ($path === null || empty($path)) { + return false; + } + + Wootook_Core_ErrorProfiler::getSingleton()->sleep(); + if (($fp = @fopen($path, 'r', true)) === false) { + Wootook_Core_ErrorProfiler::getSingleton()->wakeup(); + return false; + } + fclose($fp); + Wootook_Core_ErrorProfiler::getSingleton()->wakeup(); + return true; + } +} diff --git a/src/application/code/core/Wootook/Core/App.php b/src/application/code/core/Wootook/Core/App.php new file mode 100644 index 0000000..e21368a --- /dev/null +++ b/src/application/code/core/Wootook/Core/App.php @@ -0,0 +1,155 @@ +_globalConfig = Wootook::getConfig(); + } + + protected function _resolveClassType(&$namespaces, $module, $class) + { + $class = str_replace(' ', '', ucwords(str_replace('-', ' ', $class))); + $class = str_replace(' ', '_', ucwords(str_replace('.', ' ', $class))); + + if (isset($namespaces[$module])) { + foreach ($namespaces[$module] as $namespace => $path) { + $className = $namespace . $class; + $fileName = $path . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php'; + + Wootook_Core_ErrorProfiler::getSingleton()->sleep(); + if (!($fp = @fopen($fileName, 'r', true))) { + Wootook_Core_ErrorProfiler::getSingleton()->wakeup(); + continue; + } + Wootook_Core_ErrorProfiler::getSingleton()->wakeup(); + fclose($fp); + + if (!class_exists($className, true)) { + continue; + } + + return $className; + } + } + + Wootook_Core_ErrorProfiler::getSingleton() + ->addException(new Wootook_Core_Exception_LayoutException(sprintf('Class type "%s" could not be resolved.', $type))); + return null; + } + + protected function _newInstance($className, Array $constructorParams) + { + if ($className === null) { + return null; + } + + if (empty($constructorParams)) { + return new $className; + } else { + $reflection = new ReflectionClass($className); + return $reflection->newInstanceArgs($constructorParams); + } + } + + protected function _parseIdentifier($identifier, &$module, &$class) + { + $offset = strpos($identifier, '/'); + if ($offset === false) { + $module = $identifier; + $class = null; + + return; + } + + $module = substr($type, 0, $offset); + $class = substr($type, $offset + 1); + } + + public function block($identifier) + { + $this->_parseIdentifier($identifier, $module, $class); + + return $this->getBlock($module, $class); + } + + public function model($identifier) + { + $this->_parseIdentifier($identifier, $module, $class); + + return $this->getModel($module, $class); + } + + public function resource($identifier) + { + $this->_parseIdentifier($identifier, $module, $class); + + return $this->getResource($module, $class); + } + + public function helper($identifier) + { + $this->_parseIdentifier($identifier, $module, $class); + + if ($class === null) { + $class = 'data'; + } + + return $this->getResource($module, $class); + } + + public function getBlock($module, $class, Array $constructorParams = array()) + { + $className = $this->_resolveClassType($this->_globalConfig->blocks, $module, $class); + + return $this->_newInstance($className, $constructorParams); + } + + public function getModel($module, $class, Array $constructorParams = array()) + { + $className = $this->_resolveClassType($this->_globalConfig->models, $module, $class); + + return $this->_newInstance($className, $constructorParams); + } + + public function getResource($module, $class, Array $constructorParams = array()) + { + $className = $this->_resolveClassType($this->_globalConfig->resources, $module, $class); + + return $this->_newInstance($className, $constructorParams); + } + + public function getHelper($module, $class, Array $constructorParams = array()) + { + $className = $this->_resolveClassType($this->_globalConfig->helpers, $module, $class); + + return $this->_newInstance($className, $constructorParams); + } + + public function getBlockSingleton($module, $class, Array $constructorParams = array()) + { + + } + + public function getModelSingleton($module, $class, Array $constructorParams = array()) + { + + } + + public function getResourceSingleton($module, $class, Array $constructorParams = array()) + { + + } + + public function getHelperSingleton($module, $class, Array $constructorParams = array()) + { + + } +} diff --git a/includes/application/code/core/Legacies/Core/Block/Concat.php b/src/application/code/core/Wootook/Core/Block/Concat.php similarity index 73% rename from includes/application/code/core/Legacies/Core/Block/Concat.php rename to src/application/code/core/Wootook/Core/Block/Concat.php index 5e3cfb5..cb8dc89 100644 --- a/includes/application/code/core/Legacies/Core/Block/Concat.php +++ b/src/application/code/core/Wootook/Core/Block/Concat.php @@ -1,7 +1,7 @@ getLayout()->getScriptPath(); + } +} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Core/Block/Html/Form.php b/src/application/code/core/Wootook/Core/Block/Html/Form.php new file mode 100644 index 0000000..299983a --- /dev/null +++ b/src/application/code/core/Wootook/Core/Block/Html/Form.php @@ -0,0 +1,11 @@ +getFormKey(true); + } +} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Core/Block/Html/Head.php b/src/application/code/core/Wootook/Core/Block/Html/Head.php new file mode 100644 index 0000000..c404045 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Block/Html/Head.php @@ -0,0 +1,287 @@ +_titleSeparator = $separator; + + return $this; + } + + public function getTitleSeparator() + { + return $this->_titleSeparator; + } + + public function setTitleDefaultConcat($defaultConcat) + { + if (in_array($concatType, $this->_titleConcatTypes)) { + $this->_titleDefaultConcat = $defaultConcat; + } + + return $this; + } + + public function getTitleDefaultConcat() + { + return $this->_titleDefaultConcat; + } + + public function setTitle($title, $concatType = self::TITLE_CONCAT_AFTER) + { + if (!in_array($concatType, $this->_titleConcatTypes)) { + $concatType = $this->getTitleDefaultConcat(); + } + + if ($concatType == self::TITLE_OVERWRITE || $this->_title === null) { + $this->_title = $title; + } else if ($concatType == self::TITLE_CONCAT_BEFORE) { + $this->_title = $title . $this->getTitleSeparator() . $this->_title; + } else if ($concatType == self::TITLE_CONCAT_AFTER) { + $this->_title .= $this->getTitleSeparator() . $title; + } + + return $this; + } + + public function getTitle() + { + return $this->_title; + } + + public function addItem($type, Array $options = array()) + { + if (!isset($this->_items[$type])) { + $this->_items[$type] = array(); + } + $this->_items[$type][] = $options; + + return $this; + } + + public function addJs($script, $type = 'text/javascript', Array $options = array(), $theme = null, $package = null) + { + $options['type'] = $type; + $options['path'] = $script; + $options['theme'] = $theme; + $options['package'] = $package; + + $this->addItem(self::TYPE_GLOBAL_JS, $options); + + return $this; + } + + public function addCss($stylesheet, $type = 'text/css', $condition = null, Array $options = array(), $theme = null, $package = null) + { + $options['type'] = $type; + $options['path'] = $stylesheet; + $options['condition'] = $condition; + $options['theme'] = $theme; + $options['package'] = $package; + + $this->addItem(self::TYPE_GLOBAL_CSS, $options); + + return $this; + } + + public function addSkinJs($script, $type = 'text/javascript', Array $options = array(), $theme = null, $package = null) + { + $options['type'] = $type; + $options['path'] = $script; + $options['theme'] = $theme; + $options['package'] = $package; + + $this->addItem(self::TYPE_SKIN_JS, $options); + + return $this; + } + + public function addSkinCss($stylesheet, $type = 'text/css', $condition = null, Array $options = array(), $theme = null, $package = null) + { + $options['type'] = $type; + $options['path'] = $stylesheet; + $options['condition'] = $condition; + $options['theme'] = $theme; + $options['package'] = $package; + + $this->addItem(self::TYPE_SKIN_CSS, $options); + + return $this; + } + + public function addInlineJs($content, $type = 'text/javascript', Array $options = array()) + { + $options['type'] = $type; + $options['content'] = $content; + + $this->addItem(self::TYPE_INLINE_JS, $options); + + return $this; + } + + public function addInlineCss($content, $type = 'text/css', Array $options = array()) + { + $options['type'] = $type; + $options['content'] = $content; + + $this->addItem(self::TYPE_INLINE_CSS, $options); + + return $this; + } + + public function getCss() + { + if (isset($this->_items[self::TYPE_GLOBAL_CSS])) { + return $this->_items[self::TYPE_GLOBAL_CSS]; + } + return array(); + } + + public function getSkinCss() + { + if (isset($this->_items[self::TYPE_SKIN_CSS])) { + return $this->_items[self::TYPE_SKIN_CSS]; + } + return array(); + } + + public function getInlineCss() + { + if (isset($this->_items[self::TYPE_INLINE_CSS])) { + return $this->_items[self::TYPE_INLINE_CSS]; + } + return array(); + } + + public function getJs() + { + if (isset($this->_items[self::TYPE_GLOBAL_JS])) { + return $this->_items[self::TYPE_GLOBAL_JS]; + } + return array(); + } + + public function getSkinJs() + { + if (isset($this->_items[self::TYPE_SKIN_JS])) { + return $this->_items[self::TYPE_SKIN_JS]; + } + return array(); + } + + public function getInlineJs() + { + if (isset($this->_items[self::TYPE_INLINE_JS])) { + return $this->_items[self::TYPE_INLINE_JS]; + } + return array(); + } + + public function renderCss() + { + $render = ''; + foreach ($this->getCss() as $css) { + if (!isset($css['media'])) { + $css['media'] = 'all'; + } + $url = $this->getStaticUrl($css['path'], array()); + $render .=<< +HTML_EOF; + } + } + + public function renderSkinCss() + { + $render = ''; + foreach ($this->getSkinCss() as $css) { + if (!isset($css['media'])) { + $css['media'] = 'all'; + } + $url = $this->getSkinUrl($css['path'], array(), $css['theme'], $css['package']); + $render .=<< +HTML_EOF; + } + } + + public function renderInlineCss() + { + foreach ($this->getInlineCss() as $css) { + if (!isset($css['media'])) { + $css['media'] = 'all'; + } + $render .=<</**/ +HTML_EOF; + } + return $render; + } + + public function renderJs() + { + $render = ''; + foreach ($this->getJs() as $js) { + if (!isset($js['type'])) { + $js['type'] = 'text/javascript'; + } + $url = $this->getStaticUrl($js['path']); + $render .=<< +HTML_EOF; + } + return $render; + } + + public function renderSkinJs() + { + $render = ''; + foreach ($this->getJs() as $js) { + if (!isset($js['type'])) { + $js['type'] = 'text/javascript'; + } + $url = $this->getSkinUrl($js['path'], array(), $js['theme'], $js['package']); + $render .=<< +HTML_EOF; + } + return $render; + } + + public function renderInlineJs() + { + foreach ($this->getInlineJs() as $js) { + $render .=<</**/ +HTML_EOF; + } + return $render; + } +} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Core/Block/Html/Home.php b/src/application/code/core/Wootook/Core/Block/Html/Home.php new file mode 100644 index 0000000..ac43612 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Block/Html/Home.php @@ -0,0 +1,22 @@ +_getNode($explodedPath); + + $child = $this->getLayout() + ->createBlock('core/html.navigation.link', $this->getNameInLayout() . '.' . $baseName, array( + 'url' => array( + 'uri' => $uri, + 'params' => $params + ), + 'label' => $label, + 'title' => $title, + 'classes' => $classes, + 'attributes' => $attributes + )); + $parent->setPartial($baseName, $child); + + if ($template !== null) { + $child->setTemplate($template); + } + + return $this; + } + public function addStaticLink($name, $label, $title, $uri, Array $params = array(), Array $classes = array(), $template = null, Array $attributes = array()) + { + $explodedPath = explode('/', $name); + $baseName = array_pop($explodedPath); + $parent = $this->_getNode($explodedPath); + + $child = $this->getLayout() + ->createBlock('core/html.navigation.link', $this->getNameInLayout() . '.' . $baseName, array( + 'url' => array( + 'uri' => $uri, + 'params' => $params, + 'static' => true + ), + 'label' => $label, + 'title' => $title, + 'classes' => $classes, + 'attributes' => $attributes + )); + $parent->setPartial($baseName, $child); + + if ($template !== null) { + $child->setTemplate($template); + } + + return $this; + } + + public function addExternalLink($name, $label, $title, $url, Array $classes = array(), $template = null, Array $attributes = array()) + { + $explodedPath = explode('/', $name); + $baseName = array_pop($explodedPath); + $parent = $this->_getNode($explodedPath); + + $child = $this->getLayout() + ->createBlock('core/html.navigation.link', $this->getNameInLayout() . '.' . $baseName, array( + 'url' => $url, + 'label' => $label, + 'title' => $title, + 'classes' => $classes, + 'attributes' => $attributes + )); + $parent->setPartial($baseName, $child); + + if ($template !== null) { + $child->setTemplate($template); + } + + return $this; + } + + public function addPopupLink($name, $label, $title, $uri, Array $params = array(), Array $classes = array(), $template = null, Array $attributes = array()) + { + $uri = $this->getStaticUrl($uri, $params); + + $attributes['onclick'] = "f('{$params}', '{$label}');return false;"; + + return $this->addLink($name, $label, $title, null, array(), $classes, $template, $attributes); + } + + public function setNodeTitle($path, $title) + { + return $this->getNode($path)->setTitle($title); + } + + public function setNodeTemplate($path, $template) + { + return $this->getNode($path)->setTemplate($template); + } + + public function getNode($path) + { + return $this->_getNode(explode('/', $path)); + } + + protected function _getNode($explodedPath) + { + $name = array_shift($explodedPath); + + if ($this->hasPartial($name)) { + $child = $this->getPartial($name); + } else { + $child = $this->getLayout() + ->createBlock('core/html.navigation.node', $this->getNameInLayout() . '.' . $name); + + $this->setPartial($name, $child); + } + + if ($child instanceof Wootook_Core_Block_Html_Navigation_Link) { + throw new Wootook_Core_Exception_RuntimeException('Node is a link. Could not append a child node to a link node.'); + } + + if (count($explodedPath) == 0) { + return $child; + } + return $child->_getNode($explodedPath); + } +} diff --git a/src/application/code/core/Wootook/Core/Block/Html/Navigation/Link.php b/src/application/code/core/Wootook/Core/Block/Html/Navigation/Link.php new file mode 100644 index 0000000..82a09fa --- /dev/null +++ b/src/application/code/core/Wootook/Core/Block/Html/Navigation/Link.php @@ -0,0 +1,201 @@ +_template !== null) { + return $this->_template; + } + return 'page/html/navigation/link.phtml'; + } + + public function setLabel($label) + { + $this->_label = $label; + + return $this; + } + + public function getLabel() + { + return $this->_label; + } + + public function setTitle($title) + { + $this->_title = $title; + + return $this; + } + + public function getTitle() + { + return $this->_title; + } + + public function setStaticUrl($uri, $params = array()) + { + if ($uri === null) { + return $this; + } + + $this->_uri = $uri; + $this->_params = $params; + $this->_url = $this->getStaticUrl($uri, $params); + + return $this; + } + + public function setUrl($uri, $params = array()) + { + if ($uri === null) { + return $this; + } + + $this->_uri = $uri; + $this->_params = $params; + $this->_url = $this->getUrl($uri, $params); + + return $this; + } + + public function setExternalUrl($url) + { + $this->_url = $url; + $this->_uri = null; + $this->_params = array(); + + return $this; + } + + public function getLinkUrl($moreParams = array()) + { + if (empty($moreParams) || $this->_uri === null) { + return $this->_url; + } + $params = array_merge($this->_params, $moreParams); + return $this->getStaticUrl($this->_uri, $params); + } + + public function setAttribute($attributeName, $attributeValue) + { + $this->_attributes[$attributeName] = $attributeValue; + + return $this; + } + + public function getAttribute($attributeName) + { + if ($this->hasAttribute($attributeName)) { + return $this->_attributes[$attributeName]; + } + return null; + } + + public function hasAttribute($attributeName) + { + if (isset($this->_attributes[$attributeName])) { + return true; + } + return false; + } + + public function unsetAttribute($attributeName) + { + if ($this->hasAttribute($attributeName)) { + unset($this->_attributes[$attributeName]); + } + return $this; + } + + public function getAttributes() + { + return $this->_attributes; + } + + public function addClass($class) + { + $this->_classes[] = $class; + + return $this; + } + + public function clearClasses() + { + $this->_classes = array(); + + return $this; + } + + public function renderClasses(Array $moreClasses = array()) + { + $classes = array_merge($this->_classes, $moreClasses); + return implode(' ', $classes); + } + + public function __construct(Array $data = array()) + { + if (isset($data['label'])) { + $this->setLabel($data['label']); + unset($data['label']); + } + + if (isset($data['title'])) { + $this->setTitle($data['title']); + unset($data['title']); + } + + if (isset($data['url'])) { + if (is_array($data['url']) && isset($data['url']['uri'])) { + if (isset($data['url']['static']) && $data['url']['static']) { + if (isset($data['url']['params'])) { + $this->setStaticUrl($data['url']['uri'], $data['url']['params']); + } else { + $this->setStaticUrl($data['url']['uri']); + } + } else { + if (isset($data['url']['params'])) { + $this->setUrl($data['url']['uri'], $data['url']['params']); + } else { + $this->setUrl($data['url']['uri']); + } + } + } else { + $this->setExternalUrl($data['url']); + } + unset($data['url']); + } + + if (isset($data['classes'])) { + $classes = (array) $data['classes']; + unset($data['classes']); + + foreach ($classes as $class) { + $this->addClass(trim($class)); + } + } + + if (isset($data['attributes'])) { + $attributes = (array) $data['attributes']; + unset($data['attributes']); + + foreach ($attributes as $attributeName => $attributeValue) { + $this->setAttribute($attributeName, $attributeValue); + } + } + + parent::__construct($data); + + return $this; + } +} diff --git a/includes/application/code/core/Legacies/Core/Block/Html/Navigation/Node.php b/src/application/code/core/Wootook/Core/Block/Html/Navigation/Node.php similarity index 80% rename from includes/application/code/core/Legacies/Core/Block/Html/Navigation/Node.php rename to src/application/code/core/Wootook/Core/Block/Html/Navigation/Node.php index b1b8463..20e9ac7 100644 --- a/includes/application/code/core/Legacies/Core/Block/Html/Navigation/Node.php +++ b/src/application/code/core/Wootook/Core/Block/Html/Navigation/Node.php @@ -1,7 +1,7 @@ _storages[] = $namespace; + } + + public function renderGroupedHtml() + { + $messages = array(); + + foreach ($this->_storages as $namespace) { + $session = Wootook::getSession($namespace); + + $messageList = $session->getMessages(); + if (!is_array($messageList)) { + continue; + } + foreach ($messageList as $messageLevel => $messageList) { + if (!isset($messages[$messageLevel])) { + $messages[$messageLevel] = $messageList; + } else { + $messages[$messageLevel] += $messageList; + } + } + } + + rsort($messages, SORT_NUMERIC); + + $output = '
    '; + foreach ($messages as $messageLevel => $messageList) { + $output .= "
      "; + foreach ($messageList as $message) { + $output .= "
    • {$message}
    • "; + } + $output .= '
    '; + } + $output .= '
    '; + + return $output; + } +} diff --git a/src/application/code/core/Wootook/Core/Block/Template.php b/src/application/code/core/Wootook/Core/Block/Template.php new file mode 100644 index 0000000..1383a4e --- /dev/null +++ b/src/application/code/core/Wootook/Core/Block/Template.php @@ -0,0 +1,46 @@ +getScriptPath() == '') { + Wootook_Core_ErrorProfiler::getSingleton() + ->addException(new Wootook_Core_Exception_RuntimeException("No script path defined in block {$this->getNameInLayout()}.")); + return null; + } + + $pattern = "{$this->getScriptPath()}/%s/%s/scripts/{$file}"; + if (($layout = $this->getLayout()) !== null) { + $package = $this->getLayout()->getPackage(); + $theme = $this->getLayout()->getTheme(); + + if ($package !== Wootook_Core_Model_Layout::DEFAULT_PACKAGE) { + if ($theme !== Wootook_Core_Model_Layout::DEFAULT_THEME) { + $path = sprintf($pattern, $package, $theme); + if (Wootook::fileExists($path)) { + return $path; + } + } + + $path = sprintf($pattern, $package, Wootook_Core_Model_Layout::DEFAULT_THEME); + if (Wootook::fileExists($path)) { + return $path; + } + } + } else { + Wootook_Core_ErrorProfiler::getSingleton() + ->addException(new Wootook_Core_Exception_RuntimeException("No layout defined.")); + } + + $path = sprintf($pattern, Wootook_Core_Model_Layout::DEFAULT_PACKAGE, Wootook_Core_Model_Layout::DEFAULT_THEME); + if (Wootook::fileExists($path)) { + return $path; + } + + Wootook_Core_ErrorProfiler::getSingleton() + ->addException(new Wootook_Core_Exception_RuntimeException("Template '{$file}' could not be found.")); + return null; + } +} diff --git a/includes/application/code/core/Legacies/Core/Block/Text.php b/src/application/code/core/Wootook/Core/Block/Text.php similarity index 85% rename from includes/application/code/core/Legacies/Core/Block/Text.php rename to src/application/code/core/Wootook/Core/Block/Text.php index 6890ac2..dabe336 100644 --- a/includes/application/code/core/Legacies/Core/Block/Text.php +++ b/src/application/code/core/Wootook/Core/Block/Text.php @@ -1,7 +1,7 @@ load($filename); + } + } + + public function load($filename) + { + if (!file_exists($filename)) { + throw new Wootook_Core_Exception_DataAccessException(sprintf('Could not load config file "%s"', $filename)); + } + $data = include $filename; + + if (!is_array($data)) { + throw new Wootook_Core_Exception_DataAccessException('Configuration file could not be loaded.'); + } + + $this->_init($data); + + return $this; + } + + public function save($filename) + { + file_put_contents($filename, '<' . '?p' . 'hp return ' . var_export($this->toArray(), true) . ';'); + + return $this; + } +} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Core/Config/Node.php b/src/application/code/core/Wootook/Core/Config/Node.php new file mode 100644 index 0000000..309c1cf --- /dev/null +++ b/src/application/code/core/Wootook/Core/Config/Node.php @@ -0,0 +1,247 @@ +_init($data, $parent); + } + + public function setData(Array $data = array()) + { + $this->_init($data); + + return $this; + } + + protected function _init(Array $data, $parent = null) + { + if ($parent !== null) { + $this->_parent = $parent; + } + + $this->_children = array(); + + foreach ($data as $key => $value) { + if (is_array($value)) { + $this->offsetSet($key, new self($value, $this)); + } else { + $this->offsetSet($key, $value); + } + } + + return $this; + } + + public function getParent() + { + return $this->_parent; + } + + public function setConfig($path, $value) + { + $explodedPath = explode('/', $path); + + $length = count($explodedPath); + $currentNode = $this; + for ($i = 0; $i < $length; $i++) { + if ($i < ($length - 1)) { + if (!$currentNode->offsetExists($explodedPath[$i])) { + $newNode = new Wootook_Core_Config_Node(array(), $currentNode); + $currentNode->offsetSet($explodedPath[$i], $newNode); + } + } else if (is_array($value)) { + $currentNode->offsetSet($explodedPath[$i], new self($value, $this)); + break; + } else { + $currentNode->offsetSet($explodedPath[$i], $value); + break; + } + + $currentNode = $currentNode->offsetGet($explodedPath[$i]); + + if (!$currentNode instanceof Wootook_Core_Config_Node) { + throw new Wootook_Core_Exception_RuntimeException(); + } + } + + return $this; + } + + public function getConfig($path) + { + $explodedPath = explode('/', $path); + + $length = count($explodedPath); + $currentNode = $this; + for ($i = 0; $i < $length; $i++) { + if (!$currentNode instanceof Wootook_Core_Config_Node) { + throw new Wootook_Core_Exception_RuntimeException(); + } + if (!$currentNode->offsetExists($explodedPath[$i])) { + return null; + } + + $currentNode = $currentNode->offsetGet($explodedPath[$i]); + } + + return $currentNode; + } + + public function toArray() + { + $result = array(); + foreach ($this->_children as $key => $child) { + if ($child instanceof self) { + $result[$key] = $child->toArray(); + } else if ($child instanceof Wootook_Core_Config_Leaf) { + $result[$key] = $child->getValue(); + } else { + $result[$key] = $child; + } + } + return $result; + } + + public function reset() + { + $this->_children = array(); + $this->_parent = null; + + return $this; + } + + public function merge(self $node) + { + foreach ($node->_children as $offset => $value) { + if ($value instanceof self) { + if (!$this->offsetExists($offset)) { + $this->offsetSet($offset, new self(array(), $this)); + } + $this->offsetGet($offset)->merge($value); + } else { + $this->offsetSet($offset, $value); + } + } + + return $this; + } + + private function _resolveAttributeName($key) + { + if (is_numeric($key)) { + return $key; + } + if (!isset(self::$_attributeNameCache[$key])) { + self::$_attributeNameCache[$key] = strtolower(preg_replace('#([A-Z])#', '-\\1', $key)); + } + return self::$_attributeNameCache[$key]; + } + + public function __get($offset) + { + return $this->offsetGet($this->_resolveAttributeName($offset)); + } + + public function __set($offset, $value) + { + return $this->offsetSet($this->_resolveAttributeName($offset), $value); + } + + public function __isset($offset) + { + return $this->offsetExists($this->_resolveAttributeName($offset)); + } + + public function __unset($offset) + { + return $this->offsetUnset($this->_resolveAttributeName($offset)); + } + + public function __clone() + { + $clone = new self(); + + foreach ($this->_children as $childName => $childNode) { + if ($childNode instanceof self) { + $childNode = clone $childNode; + $childNode->_parent = $clone; + } + + $clone->offsetSet($childName, $childNode); + } + + return $clone; + } + + public function offsetGet($offset) + { + if ($this->offsetExists($offset)) { + return $this->_children[$offset]; + } + return null; + } + + public function offsetSet($offset, $value) + { + if ($offset === null) { + $this->_children[] = $value; + } else { + $this->_children[$offset] = $value; + } + + return $value; + } + + public function offsetExists($offset) + { + if (isset($this->_children[$offset])) { + return true; + } + return false; + } + + public function offsetUnset($offset) + { + if ($this->offsetExists($offset)) { + unset($this->_children[$offset]); + } + } + + public function valid() + { + return key($this->_children); + } + + public function next() + { + next($this->_children); + } + + public function current() + { + return current($this->_children); + } + + public function rewind() + { + reset($this->_children); + } + + public function key() + { + return key($this->_children); + } + + public function count() + { + return count($this->_children); + } +} diff --git a/src/application/code/core/Wootook/Core/Controller/ErrorController.php b/src/application/code/core/Wootook/Core/Controller/ErrorController.php new file mode 100644 index 0000000..0a2e348 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Controller/ErrorController.php @@ -0,0 +1,11 @@ +loadLayout('no-route'); + $this->renderLayout(); + } +} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Core/Controller/IndexController.php b/src/application/code/core/Wootook/Core/Controller/IndexController.php new file mode 100644 index 0000000..c77c6f0 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Controller/IndexController.php @@ -0,0 +1,11 @@ +loadLayout('home'); + $this->renderLayout(); + } +} diff --git a/src/application/code/core/Wootook/Core/Database/Adapter/Adapter.php b/src/application/code/core/Wootook/Core/Database/Adapter/Adapter.php new file mode 100644 index 0000000..41d8bdb --- /dev/null +++ b/src/application/code/core/Wootook/Core/Database/Adapter/Adapter.php @@ -0,0 +1,199 @@ +_handler; + } + + public function getDataMapper() + { + return new Wootook_Core_Database_Orm_DataMapper(); + } + + /** + * + * @param string $prefix + * @return Wootook_Core_Database_Adapter_Pdo_Mysql + */ + public function setTablePrefix($prefix) + { + $this->_tablePrefix = $prefix; + + return $this; + } + + /** + * @return string + */ + public function getTablePrefix() + { + return $this->_tablePrefix; + } + + /** + * @return string + */ + public function getTable($table) + { + return $this->getTablePrefix() . $table; + } + + /** + * @return Wootook_Core_Database_Sql_Select + */ + public function select() + { + return new Wootook_Core_Database_Sql_Select($this); + } + + /** + * @return Wootook_Core_Database_Sql_Insert + */ + public function insert() + { + return new Wootook_Core_Database_Sql_Insert($this); + } + + /** + * @return Wootook_Core_Database_Sql_Update + */ + public function update() + { + return new Wootook_Core_Database_Sql_Update($this); + } + + /** + * @return Wootook_Core_Database_Sql_Delete + */ + public function delete() + { + return new Wootook_Core_Database_Sql_Delete($this); + } + + /** + * @param string $data + * @return string + */ + abstract public function quote($data); + + /** + * @param string $identifier + * @return string + */ + abstract public function quoteIdentifier($identifier); + + /** + * @param string $identifier + * @return string + */ + public function quoteInto($string, $values) + { + $parts = preg_split('#(:[\w_]+|[?])#', $string, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); + + $result = ''; + if (is_array($values)) { + $index = 0; + foreach ($parts as $part) { + if ($part == '?') { + $result .= $this->quote($values[$index++]); + } else if (!empty($part) && $part[0] == ':') { + $key = substr($part, 1); + + if (isset($values[$key])) { + $result .= $this->quote($values[$key]); + } else if (isset($values[$part])) { + $result .= $this->quote($values[$part]); + } else { + $result .= $part; + } + } else { + $result .= $part; + } + } + } else { + foreach ($parts as $part) { + if ($part == '?' || $part[0] == ':') { + $result .= $this->quote($values); + } else { + $result .= $part; + } + } + } + + return $result; + } + + /** + * @return Wootook_Core_Database_Statement_Statement + */ + public function query($sql, Array $params = null) + { + $statement = $this->prepare($sql, $params); + if (!$statement->execute()) { + $message = sprintf('[SQLSTATE %s] Could not execute query: %s', $statement->errorState(), $statement->errorMessage()); + throw new Wootook_Core_Exception_Database_StatementError($statement, $message); + } + + return $statement; + } + + /** + * @return bool + */ + public function execute($sql, Array $params = null) + { + $statement = $this->prepare($sql); + return $statement->execute($params); + } + + /** + * @return Wootook_Core_Database_Statement_Statement + */ + abstract public function prepare($sql, Array $params = null); + + /** + * @return bool + */ + abstract public function beginTransaction(); + + /** + * @return bool + */ + abstract public function commit(); + + /** + * @return bool + */ + abstract public function rollback(); + + /** + * @return bool + */ + abstract public function lastInsertId(); + + /** + * @return string + */ + abstract public function errorCode(); + + /** + * @return string + */ + abstract public function errorMessage(); + + /** + * @return array + */ + abstract public function errorInfo(); + + /** + * @return string + */ + abstract public function errorState(); +} diff --git a/src/application/code/core/Wootook/Core/Database/Adapter/Pdo/Mysql.php b/src/application/code/core/Wootook/Core/Database/Adapter/Pdo/Mysql.php new file mode 100644 index 0000000..5270cf2 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Database/Adapter/Pdo/Mysql.php @@ -0,0 +1,170 @@ +hostname};dbname={$config->database}"; + if (is_numeric($config->port)) { + $dsn .= ";port={$config->database}"; + } + + if (!isset($options[Wootook_Core_Database_ConnectionManager::ATTR_ERRMODE])) { + $options[Wootook_Core_Database_ConnectionManager::ATTR_ERRMODE] = Wootook_Core_Database_ConnectionManager::ERRMODE_EXCEPTION; + } + + try { + $this->_handler = new PDO($dsn, $config->username, $config->password, $options); + } catch (PDOException $e) { + throw new Wootook_Core_Exception_Database_AdapterError($this, $e->getMessage(), null, $e); + } + } + + /** + * (non-PHPdoc) + * @see Wootook_Core_Database_Adapter_Adapter::quoteIdentifier() + */ + public function quoteIdentifier($identifier) + { + return "`$identifier`"; + } + + public function quote($data) + { + try { + return $this->_handler->quote($data); + } catch (PDOException $e) { + throw new Wootook_Core_Exception_Database_AdapterError($this, $e->getMessage(), null, $e); + } + return null; + } + + /** + * + * @param string $name + * @return string + */ + public function getTable($name) + { + return $this->getTablePrefix() . $name; + } + + /** + * @see Wootook_Core_Database_Adapter_Adapter::select() + */ + public function select($tableName = null) + { + return new Wootook_Core_Database_Sql_Mysql_Select($this, $tableName); + } + + /** + * @return Wootook_Core_Database_Statement_Statement + */ + public function prepare($sql, Array $params = null) + { + $statement = new Wootook_Core_Database_Statement_Pdo_Mysql($this, $sql); + + if ($params !== null) { + foreach ($params as $paramKey => $paramValue) { + $statement->bindValue($paramKey, $paramValue, $statement->getParamType($paramValue)); + } + } + + return $statement; + } + + /** + * @return bool + */ + public function beginTransaction() + { + try { + return $this->_handler->beginTransaction(); + } catch (PDOException $e) { + throw new Wootook_Core_Exception_Database_AdapterError($this, $e->getMessage(), null, $e); + } + return false; + } + + /** + * @return bool + */ + public function commit() + { + try { + return $this->_handler->commit(); + } catch (PDOException $e) { + throw new Wootook_Core_Exception_Database_AdapterError($this, $e->getMessage(), null, $e); + } + return false; + } + + /** + * @return bool + */ + public function rollback() + { + try { + return $this->_handler->rollback(); + } catch (PDOException $e) { + throw new Wootook_Core_Exception_Database_AdapterError($this, $e->getMessage(), null, $e); + } + return false; + } + + /** + * @return int + */ + public function lastInsertId() + { + try { + return $this->_handler->lastInsertId(); + } catch (PDOException $e) { + throw new Wootook_Core_Exception_Database_AdapterError($this, $e->getMessage(), null, $e); + } + return false; + } + + /** + * @return string + */ + public function errorCode() + { + return $this->_handler->errorCode(); + } + + /** + * @return array + */ + public function errorInfo() + { + return $this->_handler->errorInfo(); + } + + /** + * @return string + */ + public function errorMessage() + { + $info = $this->_handler->errorInfo(); + + return $info[2]; + } + + /** + * @return string + */ + public function errorState() + { + $info = $this->_handler->errorInfo(); + + return $info[0]; + } +} diff --git a/src/application/code/core/Wootook/Core/Database/ConnectionManager.php b/src/application/code/core/Wootook/Core/Database/ConnectionManager.php new file mode 100644 index 0000000..4ba8289 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Database/ConnectionManager.php @@ -0,0 +1,202 @@ +registerNamespace('Wootook_Core_Database_Adapter_'); + } + + /** + * @return Wootook_Core_Database_ConnectionManager + */ + public static function getSingleton() + { + if (self::$_singleton === null) { + self::$_singleton = new self(); + } + return self::$_singleton; + } + + protected $_defaultOptions = array( + self::ATTR_ERRMODE => self::ERRMODE_EXCEPTION + ); + + /** + * @param $connectionName + * @return Wootook_Core_Database_Adapter_Adapter + */ + public function getConnection($connectionName) + { + if (empty($connectionName) || $connectionName === null) { + return null; + } + + if (!isset($this->_connections[$connectionName])) { + if (isset($this->_connectionAliases[$connectionName])) { + return $this->_connectionAliases[$connectionName]; + } + + $connectionConfig = Wootook::getConfig("resource/database/{$connectionName}"); + if ($connectionConfig === null) { + return null; + } + if ($alias = $connectionConfig->use) { + $this->_connectionAliases[$connectionName] = self::getConnection($alias); + + return $this->_connectionAliases[$connectionName]; + } + + $this->_connections[$connectionName] = self::_initConnection($connectionName, + $connectionConfig->engine, $connectionConfig->params, $connectionConfig->options); + } + + return $this->_connections[$connectionName]; + } + + private function _initConnection($connectionName, $engine, $params, $options = array()) + { + if (is_array($params)) { + $params = new Wootook_Core_Config_Node($params); + } else if (!$params instanceof Wootook_Core_Config_Node) { + $params = new Wootook_Core_Config_Node(array()); + } + + if ($options instanceof Wootook_Core_Config_Node) { + $options = $options->toArray(); + } else if (!is_array($options)) { + $options = array(); + } + + if (empty($params->hostname) || empty($params->username) || empty($params->database)) { + return null; + } + + $event = Wootook::dispatchEvent('database.prepare-options', array( + 'name' => $connectionName, + 'options' => array_merge($this->_defaultOptions, $options) + )); + + $options = $event->getData('options'); + + $connection = $this->load($engine, false, array($params, $options)); + + if (!$connection) { + throw new Wootook_Core_Exception_Database_AdapterError('Could not find data connection handler.'); + } + + if (($prefix = Wootook::getConfig("resource/database/{$connectionName}/table_prefix")) !== null) { + $connection->setTablePrefix($prefix); + } + + Wootook::dispatchEvent('database.init', array( + 'name' => $connectionName, + 'handler' => $connection + )); + + return $connection; + } + + protected function _load($className, $useSingleton, Array $constructorParams = array()) + { + $reflection = new ReflectionClass($className); + return $reflection->newInstanceArgs($constructorParams); + } +} diff --git a/src/application/code/core/Wootook/Core/Database/Orm/DataMapper.php b/src/application/code/core/Wootook/Core/Database/Orm/DataMapper.php new file mode 100644 index 0000000..d4dc61f --- /dev/null +++ b/src/application/code/core/Wootook/Core/Database/Orm/DataMapper.php @@ -0,0 +1,115 @@ +registerNamespace('Wootook_Core_Database_Orm_DataMapper_'); + + if (!is_array($config) || !$config instanceof Wootook_Core_Config_Node) { + return; + } + + foreach ($config as $field => $typeConfig) { + if (is_string($typeConfig)) { + $this->addRule($field, $typeConfig); + } else if (is_array($typeConfig) && isset($typeConfig['type'])) { + if (isset($typeConfig['alias'])) { + $this->addRule($field, $typeConfig['type'], $typeConfig['alias']); + } else { + $this->addRule($field, $typeConfig['type']); + } + } + } + } + + public function addRule($field, $type, $alias = null) + { + if (($instance = $this->load($type)) !== null) { + $this->_rules[$field] = $instance; + } + + if ($alias === null) { + $alias = $field; + } + + $this->_alias[$field] = $alias; + + return $this; + } + + public function removeRule($field) + { + unset($this->_rules[$field]); + unset($this->_alias[$field]); + + return $this; + } + + protected function _load($className, $useSingleton, Array $constructorParams = array()) + { + $reflection = new ReflectionClass($className); + if ($useSingleton && $reflection->implementsInterface('Wootook_Core_Singleton')) { + $method = $reflection->getMethod('getSingleton'); + return $method->invoke(null); + } + + try { + return $reflection->newInstance($this); + } catch (ReflectionException $e) { + Wootook_Core_ErrorProfiler::getSingleton() + ->addException($e); + return null; + } + } + + /** + * + * @param Wootook_Core_Database_Resource $entity + * @param Array $datas + * @return Array + */ + public function encode(Wootook_Core_Database_Resource $entity, Array $datas = array()) + { + $aliasTable = array_flip($this->_alias); + foreach ($entity->getAllDatas() as $aliasedField => $decodedValue) { + if (!isset($aliasTable[$aliasedField])) { + $field = $aliasedField; + } else { + $field = $aliasTable[$aliasedField]; + } + + if (isset($this->_rules[$field])) { + $datas[$field] = $this->_rules[$field]->encode($decodedValue); + } else { + $datas[$field] = $decodedValue; + } + } + + return $datas; + } + + /** + * + * @param Wootook_Core_Database_Resource $entity + * @param Array $datas + * @return Wootook_Core_Database_Resource + */ + public function decode(Wootook_Core_Database_Resource $entity, Array $datas = array()) + { + foreach ($datas as $field => $encodedValue) { + if (isset($this->_rules[$field])) { + $entity->setData($this->_alias[$field], $this->_rules[$field]->decode($encodedValue)); + } else { + $entity->setData($field, $encodedValue); + } + } + + return $entity; + } +} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Core/Database/Orm/DataMapper/Array.php b/src/application/code/core/Wootook/Core/Database/Orm/DataMapper/Array.php new file mode 100644 index 0000000..f1db44d --- /dev/null +++ b/src/application/code/core/Wootook/Core/Database/Orm/DataMapper/Array.php @@ -0,0 +1,15 @@ +toArray()); + } + + public function decode($value) + { + return new Wootook_Core_Config_Node(parent::decode($value)); + } +} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Core/Database/Orm/DataMapper/DateTime.php b/src/application/code/core/Wootook/Core/Database/Orm/DataMapper/DateTime.php new file mode 100644 index 0000000..1e37d12 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Database/Orm/DataMapper/DateTime.php @@ -0,0 +1,38 @@ +_format = self::DATE_FORMAT_MYSQL; + } else { + $this->_format = $format; + } + return $this; + } + + public function getFormat() + { + return $this->_format; + } + + public function encode($value) + { + if (!$value instanceof Wootook_Core_DateTime) { + $value = new Wootook_Core_DateTime($value); + } + + return $value->toString($this->getFormat()); + } + + public function decode($value) + { + return new Wootook_Core_DateTime($value, $this->getFormat()); + } +} diff --git a/src/application/code/core/Wootook/Core/Database/Orm/DataMapper/FieldMapper.php b/src/application/code/core/Wootook/Core/Database/Orm/DataMapper/FieldMapper.php new file mode 100644 index 0000000..a7e989c --- /dev/null +++ b/src/application/code/core/Wootook/Core/Database/Orm/DataMapper/FieldMapper.php @@ -0,0 +1,15 @@ +_mapper = $mapper; + } + + abstract public function encode($value); + + abstract public function decode($value); +} diff --git a/src/application/code/core/Wootook/Core/Database/Orm/DataMapper/Object.php b/src/application/code/core/Wootook/Core/Database/Orm/DataMapper/Object.php new file mode 100644 index 0000000..7af245b --- /dev/null +++ b/src/application/code/core/Wootook/Core/Database/Orm/DataMapper/Object.php @@ -0,0 +1,43 @@ +_entityClass = $class; + + return $this; + } + + public function getEntityClass() + { + return $this->_entityClass; + } + + protected function _newInstance(Array $args = array()) + { + if ($this->_reflectionClass === null && $this->_entityClass !== null) { + $this->_reflectionClass = new ReflectionClass($this->_entityClass); + } + + return $this->newInstanceArgs($args); + } + + public function encode($value) + { + return parent::encode($value->getAllDatas()); + } + + public function decode($value) + { + $object = $this->_newInstance(); + $object->addData(parent::decode($value)); + + return $object; + } +} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Core/Database/Resource.php b/src/application/code/core/Wootook/Core/Database/Resource.php new file mode 100644 index 0000000..5501b32 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Database/Resource.php @@ -0,0 +1,89 @@ +_dataMapper === null) { + $this->_dataMapper = new Wootook_Core_Database_Orm_DataMapper(); + } + return $this->_dataMapper; + } + + public function setTableName($tableName) + { + $this->_tableName = $tableName; + + return $this; + } + + public function getTableName() + { + return $this->_tableName; + } + + /** + * @return Wootook_Core_Database_Adapter_Adapter + */ + public function getReadConnection() + { + if ($this->_readConnection === null) { + $this->_readConnection = Wootook_Core_Database_ConnectionManager::getSingleton() + ->getConnection('core_read'); + } + + return $this->_readConnection; + } + + public function setReadConnection($connection) + { + if ($connection instanceof Wootook_Core_Database_Adapter_Pdo_Mysql) { + $this->_readConnection = $connection; + } else if (is_string($connection)) { + $this->_readConnection = $this->getConnection($connection); + } else { + throw new Wootook_Core_Exception_RuntimeException( + 'First parameter should be either a database connection object or a string identifier.'); + } + + return $this; + } + + /** + * @return Wootook_Core_Database_Adapter_Adapter + */ + public function getWriteConnection() + { + if ($this->_writeConnection === null) { + $this->_writeConnection = Wootook_Core_Database_ConnectionManager::getSingleton() + ->getConnection('core_write'); + } + return $this->_writeConnection; + } + + public function setWriteConnection($connection) + { + if ($connection instanceof Wootook_Core_Database_Adapter_Pdo_Mysql) { + $this->_readConnection = $connection; + } else if (is_string($connection)) { + $this->_readConnection = $this->getConnection($connection); + } else { + throw new Wootook_Core_Exception_RuntimeException( + 'First parameter should be either a database connection object or a string identifier.'); + } + + return $this; + } +} diff --git a/src/application/code/core/Wootook/Core/Database/Sql/Delete.php b/src/application/code/core/Wootook/Core/Database/Sql/Delete.php new file mode 100644 index 0000000..84d8e37 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Database/Sql/Delete.php @@ -0,0 +1,90 @@ +into($tableName); + } + + return $this; + } + + public function reset($part = null) + { + if ($part === null) { + $this->_parts = array( + self::FROM => null, + self::WHERE => array(), + self::OFFSET => null, + self::LIMIT => null, + ); + } else if (isset($this->_parts[$part])) { + $this->_parts[$part] = array(); + } + + return $this; + } + + public function from($table, $schema = null) + { + $this->_parts[self::FROM] = array( + 'table' => $table, + 'schema' => $schema + ); + + return $this; + } + + public function __toString() + { + return $this->render(); + } + + public function toString($part = null) + { + if ($part === null) { + return $this->render(); + } + + switch ($part) { + case self::FROM: + return $this->renderFrom(); + break; + case self::WHERE: + return $this->renderWhere(); + break; + case self::WHERE: + return $this->renderWhere(); + break; + case self::LIMIT: + return $this->renderLimit(); + break; + } + + return null; + } + + public function renderFrom() + { + if ($this->_parts[self::FROM]['schema'] !== null) { + return "DELETE FROM {$this->getConnection()->quoteIdentifier($this->_parts[self::FROM]['schema'])}.{$this->getConnection()->quoteIdentifier($this->_parts[self::FROM]['table'])}"; + } + return "DELETE FROM {$this->getConnection()->quoteIdentifier($this->_parts[self::FROM]['table'])}"; + } + + public function render() + { + return implode("\n", array( + $this->renderFrom(), + $this->renderWhere(), + $this->renderLimit(), + )); + } +} diff --git a/src/application/code/core/Wootook/Core/Database/Sql/Dml.php b/src/application/code/core/Wootook/Core/Database/Sql/Dml.php new file mode 100644 index 0000000..de0c17b --- /dev/null +++ b/src/application/code/core/Wootook/Core/Database/Sql/Dml.php @@ -0,0 +1,24 @@ +_placeholders[] = $condition; + $this->_parts[self::WHERE][] = $condition; + } else if (is_array($value)) { + $where = $this->_translateSqlWhere($condition, 'or', $value); + if ($where !== null) { + $this->_parts[self::WHERE][] = $where; + } + } else if ($value instanceof Wootook_Core_Database_Sql_Placeholder_Placeholder) { + $this->_parts[self::WHERE][] = "{$this->getConnection()->quoteIdentifier($condition)}=" . $value; + } else { + $this->_parts[self::WHERE][] = $this->getConnection()->quoteInto("{$this->getConnection()->quoteIdentifier($condition)}=?", $value); + } + + return $this; + } + + public function limit($limit, $offset = null) + { + $this->_parts[self::LIMIT] = intval($limit); + $this->_parts[self::OFFSET] = intval($offset); + + return $this; + } + + public function renderWhere() + { + if (count($this->_parts[self::WHERE]) <= 0) { + return ''; + } + + return " WHERE (" . implode(")\n AND (", $this->_parts[self::WHERE]) . ')'; + } + + public function renderLimit() + { + if (!$this->_parts[self::LIMIT]) { + return ''; + } + if (!$this->_parts[self::OFFSET]) { + return sprintf(" LIMIT %d", $this->_parts[self::LIMIT]); + } + return sprintf(" LIMIT %d,%d", $this->_parts[self::LIMIT], $this->_parts[self::OFFSET]); + } + + protected function _translateSqlWhere($field, $operator, $value) + { + if ($value === null) { + return null; + } + $operator = strtoupper($operator); + $adapter = $this->getConnection(); + + $basicBinayOperatorList = array( + self::OPERATOR_EQUALS => '=', + self::OPERATOR_NOT_EQUALS => '!=', + self::OPERATOR_LOWER => '<', + self::OPERATOR_GREATER => '>', + self::OPERATOR_LOWER_EQUALS => '<=', + self::OPERATOR_GREATER_EQUALS => '>=' + ); + + if (in_array($operator, $basicBinayOperatorList)) { + if ($value === true) { + return "{$adapter->quoteIdentifier($field)}{$basicBinayOperatorList[$operator]}TRUE"; + } else if ($value === false) { + return "{$adapter->quoteIdentifier($field)}{$basicBinayOperatorList[$operator]}FALSE"; + } else if (is_numeric($value)) { + return sprintf("{$adapter->quoteIdentifier($field)}{$basicBinayOperatorList[$operator]}%d", $value); + } else if ($value instanceof Wootook_Core_Database_Sql_Placeholder_Placeholder) { + $this->_placeholders[] = $value; + return sprintf("{$adapter->quoteIdentifier($field)}{$basicBinayOperatorList[$operator]}%s", $adapter->quote($value->toString())); + } else { + return sprintf("{$adapter->quoteIdentifier($field)}{$basicBinayOperatorList[$operator]}%s", $adapter->quote($value)); + } + } + + switch ($operator) { + case self::OPERATOR_IS_NULL: + if ($value == false) { + return "{$adapter->quoteIdentifier($field)} IS NOT NULL"; + } else { + return "{$adapter->quoteIdentifier($field)} IS NULL"; + } + break; + + case self::OPERATOR_AND: + case self::OPERATOR_OR: + case self::OPERATOR_XOR: + $where = array(); + foreach ($value as $valueItem) { + $subOperator = key($valueItem); + $realValue = current($valueItem); + + if (is_array($realValue) && isset($realValue['field'])) { + if (!isset($realValue['value'])) { + continue; + } + + $realField = $realValue['field']; + $realValue = $realValue['value']; + } else { + $realField = $field; + } + + if ($realValue === null) { + continue; + } + $actualValue = $this->_translateSqlWhere($realField, $subOperator, $realValue); + if ($actualValue !== null) { + $where[] = $actualValue; + } + } + + if (count($where)) { + return '((' . implode(') ' . strtoupper($operator) . ' (', $where) . '))'; + } + break; + + case self::OPERATOR_IN: + $valueList = array(); + foreach ($value as $setValue) { + $valueList[] = $adapter->quote($setValue); + } + $implodedList = implode(',', $valueList); + return "{$adapter->quoteIdentifier($field)} IN({$implodedList})"; + break; + + case self::OPERATOR_NOT_IN: + $valueList = array(); + foreach ($value as $setValue) { + $valueList[] = $adapter->quote($setValue); + } + $implodedList = implode(',', $valueList); + return "{$adapter->quoteIdentifier($field)} NOT IN({$implodedList})"; + break; + + case self::OPERATOR_FIND_IN_SET: + if (is_array($value)) { + $subField = current($value); + $subOperator = key($value); + + if (in_array($subOperator, $basicBinayOperatorList)) { + return "FIND_IN_SET({$adapter->quote($value)}, {$adapter->quoteIdentifier($field)}){$basicBinayOperatorList[$operator]}{$adapter->quoteIdentifier($subField)}"; + } + } else { + return "0 < FIND_IN_SET({$adapter->quote($value)}, {$adapter->quoteIdentifier($field)})"; + } + break; + + case self::OPERATOR_NOT_FIND_IN_SET: + return "0 = FIND_IN_SET({$adapter->quote($value)}, {$adapter->quoteIdentifier($field)})"; + break; + + case self::OPERATOR_DATE: + $dateValues = array(); + if (isset($value['from'])) { + if ($value['from'] instanceof Wootook_Core_DateTime) { + $dateValues['from'] = "{$adapter->quoteIdentifier($field)} >= {$adapter->quote($this->getConnection()->getDataMapper()->load('DateTime')->encode($value['from']))}"; + } else if (is_string($value['from'])) { + $dateValues['from'] = "{$adapter->quoteIdentifier($field)} >= {$adapter->quote($value['from'])}"; + } else if (is_numeric($value['from'])) { + $dateValues['from'] = "UNIX_TIMESTAMP({$adapter->quoteIdentifier($field)}) >= {$adapter->quote($value['from'])}"; + } + } + if (isset($value['to'])) { + if ($value['to'] instanceof Wootook_Core_DateTime) { + $dateValues['to'] = "{$adapter->quoteIdentifier($field)} <= {$adapter->quote($this->getConnection()->getDataMapper()->load('DateTime')->encode($value['to']))}"; + } else if (is_string($value['to'])) { + $dateValues['to'] = "{$adapter->quoteIdentifier($field)} <= {$adapter->quote($value['to'])}"; + } else if (is_numeric($value['to'])) { + $dateValues['to'] = "UNIX_TIMESTAMP({$adapter->quoteIdentifier($field)}) <= {$adapter->quote($value['to'])}"; + } + } + + return '(' . implode(' AND ', $dateValues) . ')'; + break; + } + + return null; + } +} diff --git a/src/application/code/core/Wootook/Core/Database/Sql/DmlQuery.php b/src/application/code/core/Wootook/Core/Database/Sql/DmlQuery.php new file mode 100644 index 0000000..ebb569e --- /dev/null +++ b/src/application/code/core/Wootook/Core/Database/Sql/DmlQuery.php @@ -0,0 +1,107 @@ +setConnection($connection); + + $this->reset(); + $this->_init($tableName); + } + + /** + * @return Wootook_Core_Database_Adapter_Adapter + */ + public function getConnection() + { + return $this->_connection; + } + + public function setConnection(Wootook_Core_Database_Adapter_Adapter $connection) + { + $this->_connection = $connection; + + return $this; + } + + protected function _init($param = null) + { + return $this; + } + + public function getPart($part = null) + { + if ($part === null) { + return $this->_parts; + } + if (isset($this->_parts[$part])) { + return $this->_parts[$part]; + } + + return null; + } + + public function quote($data) + { + return $this->getConnection()->quote($data); + } + + public function quoteIdentifier($identifier) + { + return $this->getConnection()->quoteIdentifier($identifier); + } + + public function beforePrepare(Wootook_Core_Database_Statement_Statement $statement) + { + foreach ($this->_placeholders as $placeholder) { + $placeholder->beforePrepare($statement); + } + + return $this; + } + + public function afterPrepare(Wootook_Core_Database_Statement_Statement $statement) + { + foreach ($this->_placeholders as $placeholder) { + $placeholder->afterPrepare($statement); + } + + return $this; + } + + public function beforeExecute(Wootook_Core_Database_Statement_Statement $statement) + { + foreach ($this->_placeholders as $placeholder) { + $placeholder->beforeExecute($statement); + } + + return $this; + } + + public function afterExecute(Wootook_Core_Database_Statement_Statement $statement) + { + foreach ($this->_placeholders as $placeholder) { + $placeholder->afterExecute($statement); + } + + return $this; + } + + public function prepare() + { + return $this->getConnection()->prepare($this); + } + + public function execute(Array $params = null) + { + return $this->getConnection()->execute($this, $params); + } +} diff --git a/src/application/code/core/Wootook/Core/Database/Sql/Insert.php b/src/application/code/core/Wootook/Core/Database/Sql/Insert.php new file mode 100644 index 0000000..cccbcc8 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Database/Sql/Insert.php @@ -0,0 +1,150 @@ +into($tableName); + } + + return $this; + } + + public function reset($part = null) + { + if ($part === null) { + $this->_parts = array( + self::INTO => array(), + self::SET => array(), + self::SELECT => array(), + ); + } else if (isset($this->_parts[$part])) { + $this->_parts[$part] = array(); + } + + return $this; + } + + public function set($column, $value = null) + { + if (!is_array($column)) { + $column = array($column => $value); + } + + foreach ($column as $field => $value) { + if ($value instanceof Wootook_Core_Database_Sql_Placeholder_Placeholder) { + $this->_placeholders[] = $value; + } + + $this->_parts[self::SET][] = array( + 'value' => $value, + 'field' => $field + ); + } + + return $this; + } + + public function into($table, $schema = null) + { + $this->_parts[self::INTO] = array( + 'table' => $table, + 'schema' => $schema, + ); + + return $this; + } + + public function select() + { + if (!isset($this->_parts[self::SELECT])) { + $this->_parts[self::SELECT] = $this->getConnection()->select(); + } + + return $this->_parts[self::SELECT]; + } + + public function __toString() + { + return $this->render(); + } + + public function toString($part = null) + { + if ($part === null) { + return $this->render(); + } + + switch ($part) { + case self::COLUMNS: + return $this->renderSet(); + break; + case self::INTO: + return $this->renderInto(); + break; + case self::SELECT: + return $this->renderSelect(); + break; + } + + return null; + } + + public function renderSet() + { + $fields = array(); + foreach ($this->_parts[self::SET] as $field) { + if ($field['value'] instanceof Wootook_Core_Database_Sql_Placeholder_Placeholder) { + $fields[] = "{$this->_connection->quoteIdentifier($field['field'])}={$field['value']->toString()}"; + } else { + $fields[] = "{$this->_connection->quoteIdentifier($field['field'])}={$this->_connection->quote($field['value'])}"; + } + } + + if (!empty($fields)) { + return "SET " . implode(", ", $fields); + } + } + + public function renderInto() + { + if ($this->_parts[self::INTO]['schema'] !== null) { + $output = "{$this->_connection->quoteIdentifier($this->_parts[self::INTO]['schema'])}.{$this->_connection->quoteIdentifier($this->_parts[self::INTO]['table'])}"; + } else { + $output = "{$this->_connection->quoteIdentifier($this->_parts[self::INTO]['table'])}"; + } + + return "INSERT INTO " . $output; + } + + public function renderSelect() + { + if (isset($this->_parts[self::SELECT])) { + return ' ' . $this->_parts[self::SELECT]->render(); + } + return ''; + } + + public function render() + { + if (empty($this->_parts[self::SELECT])) { + return implode("\n", array( + $this->renderInto(), + $this->renderSet(), + )); + } else { + return implode("\n", array( + $this->renderInto(), + $this->renderSelect(), + )); + } + } +} diff --git a/src/application/code/core/Wootook/Core/Database/Sql/Mysql/Select.php b/src/application/code/core/Wootook/Core/Database/Sql/Mysql/Select.php new file mode 100644 index 0000000..5e8c80c --- /dev/null +++ b/src/application/code/core/Wootook/Core/Database/Sql/Mysql/Select.php @@ -0,0 +1,6 @@ +_expression = (string) $expression; + $this->_params = $params; + } + + public function __toString() + { + return $this->_expression; + } + + public function beforeExecute(Wootook_Core_Database_Statement_Statement $statement) + { + parent::beforeExecute($statement); + + foreach ($this->_params as $paramName => $value) { + $statement->bindValue($paramName, $value, $statement->getParamType($value)); + } + + return $this; + } +} diff --git a/src/application/code/core/Wootook/Core/Database/Sql/Placeholder/Param.php b/src/application/code/core/Wootook/Core/Database/Sql/Placeholder/Param.php new file mode 100644 index 0000000..5a77287 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Database/Sql/Placeholder/Param.php @@ -0,0 +1,31 @@ +_paramName = $paramName; + $this->_paramType = $type; + $this->_value = $value; + } + + public function __toString() + { + return ':' . $this->_paramName; + } + + public function beforeExecute(Wootook_Core_Database_Statement_Statement $statement) + { + parent::beforeExecute($statement); + + $type = $this->_paramType !== null ? $this->_paramType : $statement->getParamType($this->_value); + $statement->bindValue($this->_paramName, $this->_value, $type); + + return $this; + } +} diff --git a/src/application/code/core/Wootook/Core/Database/Sql/Placeholder/Placeholder.php b/src/application/code/core/Wootook/Core/Database/Sql/Placeholder/Placeholder.php new file mode 100644 index 0000000..b601575 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Database/Sql/Placeholder/Placeholder.php @@ -0,0 +1,31 @@ +__toString(); + } + + abstract public function __toString(); + + public function beforePrepare(Wootook_Core_Database_Statement_Statement $statement) + { + return $this; + } + + public function afterPrepare(Wootook_Core_Database_Statement_Statement $statement) + { + return $this; + } + + public function beforeExecute(Wootook_Core_Database_Statement_Statement $statement) + { + return $this; + } + + public function afterExecute(Wootook_Core_Database_Statement_Statement $statement) + { + return $this; + } +} diff --git a/src/application/code/core/Wootook/Core/Database/Sql/Placeholder/Variable.php b/src/application/code/core/Wootook/Core/Database/Sql/Placeholder/Variable.php new file mode 100644 index 0000000..04e4217 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Database/Sql/Placeholder/Variable.php @@ -0,0 +1,20 @@ +_paramName = $paramName; + $this->_paramType = $type; + } + + public function __toString() + { + return ':' . $this->_paramName; + } +} diff --git a/src/application/code/core/Wootook/Core/Database/Sql/Select.php b/src/application/code/core/Wootook/Core/Database/Sql/Select.php new file mode 100644 index 0000000..3c67203 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Database/Sql/Select.php @@ -0,0 +1,332 @@ +from($tableName); + } + + return $this; + } + + public function reset($part = null) + { + if ($part === null) { + $this->_parts = array( + self::COLUMNS => array(), + self::FROM => array(), + self::JOIN => array(), + self::WHERE => array(), + self::UNION => array(), + self::LIMIT => null, + self::OFFSET => null, + self::GROUP => array(), + self::HAVING => array(), + self::ORDER => array(), + ); + } else if (isset($this->_parts[$part])) { + $this->_parts[$part] = array(); + } + + return $this; + } + + public function column($column = '*', $table = null) + { + if (is_array($column)) { + foreach ($column as $alias => $field) { + if (is_int($alias)) { + $this->_parts[self::COLUMNS][] = array( + 'table' => $table, + 'alias' => null, + 'field' => $field + ); + } else { + $this->_parts[self::COLUMNS][] = array( + 'table' => $table, + 'alias' => $alias, + 'field' => $field + ); + } + } + } else { + if ($column instanceof Wootook_Core_Database_Sql_Placeholder_Placeholder) { + $this->_placeholders[] = $column; + } + + $this->_parts[self::COLUMNS][] = array( + 'table' => $table, + 'alias' => null, + 'field' => $column + ); + } + + return $this; + } + + public function from($table, $schema = null) + { + if (is_array($table)) { + $alias = key($table); + $table = current($table); + } else { + $alias = null; + } + + $this->_parts[self::FROM][] = array( + 'table' => $table, + 'alias' => $alias, + 'schema' => $schema + ); + + return $this; + } + + public function join($table, $condition, $fields = array('*'), $mode = self::JOIN_INNER, $schema = null) + { + $this->column($fields); + if (is_array($table)) { + $alias = key($table); + $table = $this->_connection->getTable(current($table)); + + if ($schema !== null) { + $this->_parts[self::JOIN][] = "\n{$mode} JOIN {$this->_connection->quoteIdentifier($schema)}{$this->_connection->quoteIdentifier($table)} AS {$this->_connection->quoteIdentifier($alias)}" + . "\n ON {$condition}"; + } else { + $this->_parts[self::JOIN][] = "\n{$mode} JOIN {$this->_connection->quoteIdentifier($table)} AS {$this->_connection->quoteIdentifier($alias)}" + . "\n ON {$condition}"; + } + } else { + $this->_parts[self::JOIN][] = "\n{$mode} JOIN {$this->_connection->quoteIdentifier($table)}" + . "\n ON {$condition}"; + } + + return $this; + } + + public function joinLeft($table, $condition, $fields = array('*')) + { + return $this->join($table, $condition, $fields, self::JOIN_LEFT); + } + + public function joinRight($table, $condition, $fields = array('*')) + { + return $this->join($table, $condition, $fields, self::JOIN_RIGHT); + } + + public function joinInner($table, $condition, $fields = array('*')) + { + return $this->join($table, $condition, $fields, self::JOIN_INNER); + } + + public function joinOuter($table, $condition, $fields = array('*')) + { + return $this->join($table, $condition, $fields, self::JOIN_OUTER); + } + + public function order($field, $direction = 'ASC') + { + $this->_parts[self::ORDER][] = "{$field} {$direction}"; + + return $this; + } + + public function union($collection) + { + $this->_parts[self::UNION][] = $collection; + + return $this; + } + + public function group($groupField) + { + $this->_parts[self::GROUP][] = $groupField; + + return $this; + } + + public function __toString() + { + return $this->render(); + } + + public function toString($part = null) + { + if ($part === null) { + return $this->render(); + } + + switch ($part) { + case self::COLUMNS: + return $this->renderColumns(); + break; + case self::FROM: + return $this->renderFrom(); + break; + case self::WHERE: + return $this->renderWhere(); + break; + case self::JOIN: + return $this->renderJoin(); + break; + case self::ORDER: + return $this->renderOrder(); + break; + case self::UNION: + return $this->renderUnion(); + break; + case self::LIMIT: + return $this->renderLimit(); + break; + case self::GROUP: + return $this->renderGroup(); + break; + case self::HAVING: + return $this->renderHaving(); + break; + } + + return null; + } + + public function renderColumns() + { + $fields = array(); + foreach ($this->_parts[self::COLUMNS] as $field) { + if ($field['field'] instanceof Wootook_Core_Database_Sql_Dml) { + if ($field['alias'] !== null) { + $fields[] = "({$field['field']}) AS {$field['alias']}"; + } else { + $fields[] = "({$field['field']})"; + } + } else if ($field['field'] instanceof Wootook_Core_Database_Sql_Placeholder_Placeholder) { + if ($field['alias'] !== null) { + $fields[] = "({$field['field']}) AS {$field['alias']}"; + } else { + $fields[] = "({$field['field']})"; + } + } else if ($field['alias'] !== null) { + if ($field['table'] !== null) { + $fields[] = "{$field['table']}.{$field['field']} AS {$field['alias']}"; + } else { + $fields[] = "{$field['field']} AS {$field['alias']}"; + } + } else if ($field['table'] !== null) { + $fields[] = "{$field['table']}.{$field['field']}"; + } else { + $fields[] = "{$field['field']}"; + } + } + + if (!empty($fields)) { + return 'SELECT ' . implode(", ", $fields); + } + return 'SELECT *'; + } + + public function renderFrom() + { + $tables = array(); + foreach ($this->_parts[self::FROM] as $table) { + if ($table['table'] instanceof Wootook_Core_Database_Sql_Dml) { + if ($table['alias'] !== null) { + $tables[] = "({$table['table']}) AS {$this->_connection->quoteIdentifier($table['alias'])}"; + } else { + $tables[] = "({$table['table']})"; + } + } else if ($table['alias'] !== null) { + if ($table['schema'] !== null) { + $tables[] = "{$this->_connection->quoteIdentifier($table['schema'])}.{$this->_connection->quoteIdentifier($table['table'])} AS {$this->_connection->quoteIdentifier($table['alias'])}"; + } else { + $tables[] = "{$this->_connection->quoteIdentifier($table['table'])} AS {$this->_connection->quoteIdentifier($table['alias'])}"; + } + } else if ($table['schema'] !== null) { + $tables[] = "{$this->_connection->quoteIdentifier($table['schema'])}.{$this->_connection->quoteIdentifier($table['table'])}"; + } else { + $tables[] = "({$this->_connection->quoteIdentifier($table['table'])})"; + } + } + + return " FROM " . implode(', ', $tables); + } + + public function renderJoin() + { + return implode('', $this->_parts[self::JOIN]); + } + + public function renderOrder() + { + if (count($this->_parts[self::ORDER]) <= 0) { + return null; + } + return " ORDER BY " . implode(', ', $this->_parts[self::ORDER]); + } + + public function renderUnion() + { + $statements = array(); + foreach ($this->_parts[self::UNION] as $statement) { + $statements[] = $statement->render(); + } + + return " (\n" . implode(" )\n UNION\n (\n", $statements) . "\n )"; + } + + public function renderGroup() + { + if (count($this->_parts[self::GROUP]) <= 0) { + return null; + } + return " GROUP BY " . implode(', ', $this->_parts[self::GROUP]); + } + + public function renderHaving() + { + if (count($this->_parts[self::HAVING]) <= 0) { + return null; + } + return " HAVING " . implode(', ', $this->_parts[self::HAVING]); + } + + public function render() + { + if (empty($this->_parts[self::UNION])) { + return implode("\n", array( + $this->renderColumns(), + $this->renderFrom(), + $this->renderJoin(), + $this->renderWhere(), + $this->renderGroup(), + $this->renderHaving(), + $this->renderOrder(), + $this->renderLimit() + )); + } else { + return implode("\n", array( + $this->renderUnion(), + $this->renderWhere(), + $this->renderOrder(), + $this->renderLimit() + )); + } + } +} diff --git a/src/application/code/core/Wootook/Core/Database/Sql/Update.php b/src/application/code/core/Wootook/Core/Database/Sql/Update.php new file mode 100644 index 0000000..5cd83b8 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Database/Sql/Update.php @@ -0,0 +1,126 @@ +into($tableName); + } + + return $this; + } + + public function reset($part = null) + { + if ($part === null) { + $this->_parts = array( + self::INTO => array(), + self::SET => array(), + self::WHERE => array(), + self::LIMIT => null, + self::OFFSET => null, + ); + } else if (isset($this->_parts[$part])) { + $this->_parts[$part] = array(); + } + + return $this; + } + + public function set($column, $value = null) + { + if (!is_array($column)) { + $column = array($column => $value); + } + + foreach ($column as $field => $value) { + if ($value instanceof Wootook_Core_Database_Sql_Placeholder_Placeholder) { + $this->_placeholders[] = $value; + } + + $this->_parts[self::SET][] = array( + 'value' => $value, + 'field' => $field + ); + } + + return $this; + } + + public function into($table, $schema = null) + { + $this->_parts[self::INTO] = array( + 'table' => $table, + 'schema' => $schema, + ); + + return $this; + } + + public function __toString() + { + return $this->render(); + } + + public function toString($part = null) + { + if ($part === null) { + return $this->render(); + } + + switch ($part) { + case self::SET: + return $this->renderSet(); + break; + case self::INTO: + return $this->renderInto(); + break; + } + + return null; + } + + public function renderSet() + { + $fields = array(); + foreach ($this->_parts[self::SET] as $field) { + if ($field['value'] instanceof Wootook_Core_Database_Sql_Placeholder_Placeholder) { + $fields[] = "{$this->_connection->quoteIdentifier($field['field'])}={$field['value']->toString()}"; + } else { + $fields[] = "{$this->_connection->quoteIdentifier($field['field'])}={$this->_connection->quote($field['value'])}"; + } + } + + if (!empty($fields)) { + return ' SET ' . implode(', ', $fields); + } + } + + public function renderInto() + { + if ($this->_parts[self::INTO]['schema'] !== null) { + $output = "{$this->_connection->quoteIdentifier($this->_parts[self::INTO]['schema'])}.{$this->_connection->quoteIdentifier($this->_parts[self::INTO]['table'])}"; + } else { + $output = "{$this->_connection->quoteIdentifier($this->_parts[self::INTO]['table'])}"; + } + + return "UPDATE " . $output; + } + + public function render() + { + return implode("\n", array( + $this->renderInto(), + $this->renderSet(), + $this->renderWhere(), + $this->renderLimit() + )); + } +} diff --git a/src/application/code/core/Wootook/Core/Database/Statement/Pdo/Mysql.php b/src/application/code/core/Wootook/Core/Database/Statement/Pdo/Mysql.php new file mode 100644 index 0000000..33b243d --- /dev/null +++ b/src/application/code/core/Wootook/Core/Database/Statement/Pdo/Mysql.php @@ -0,0 +1,321 @@ +_query = $query; + + if ($this->_query instanceof Wootook_Core_Database_Sql_Dml) { + $this->_query->beforePrepare($this); + } + + try { + $this->_handler = $this->_adapter->getDriverHandler()->prepare($this->_query); + } catch (PDOException $e) { + throw new Wootook_Core_Exception_Database_StatementError($this, $e->getMessage(), null, $e); + } + + if ($this->_query instanceof Wootook_Core_Database_Sql_Dml) { + $this->_query->afterPrepare($this); + } + + return $this; + } + + /** + * + * @param string|int $column + * @param mixed $param + * @param int $type + * @return Wootook_Core_Database_Statement_Statement + */ + public function bindColumn($column, &$param, $type = null) + { + try { + return $this->_handler->bindColumn($column, $param, $type); + } catch (PDOException $e) { + throw new Wootook_Core_Exception_Database_StatementError($this, $e->getMessage(), null, $e); + } + + return false; + } + + /** + * + * @param string|int $parameter + * @param mixed $variable + * @param int $type + * @param int $length + * @param unknown_type $options + * @return Wootook_Core_Database_Statement_Statement + */ + public function bindParam($parameter, &$variable, $type = null, $length = null, $options = null) + { + try { + return $this->_handler->bindParam($parameter, $variable, $type, $length, $options); + } catch (PDOException $e) { + throw new Wootook_Core_Exception_Database_StatementError($this, $e->getMessage(), null, $e); + } + return false; + } + + /** + * + * @param string|int $parameter + * @param mixed $value + * @param int $type + * @return Wootook_Core_Database_Statement_Statement + */ + public function bindValue($parameter, $value, $type = null) + { + try { + return $this->_handler->bindValue($parameter, $value, $type); + } catch (PDOException $e) { + throw new Wootook_Core_Exception_Database_StatementError($this, $e->getMessage(), null, $e); + } + return false; + } + + /** + * + * @param array $params + * @return bool + */ + public function execute(Array $params = null) + { + if ($this->_query instanceof Wootook_Core_Database_Sql_Dml) { + $this->_query->beforeExecute($this); + } + + try { + $result = $this->_handler->execute($params); + } catch (PDOException $e) { + throw new Wootook_Core_Exception_Database_StatementError($this, $e->getMessage(), null, $e); + } + + if ($this->_query instanceof Wootook_Core_Database_Sql_Dml) { + $this->_query->afterExecute($this); + } + + return $result; + } + + /** + * + * @param int $style + * @param int $col + * @return mixed + */ + public function fetchAll($style = null, $col = null) + { + try { + if ($style !== null) { + if ($col !== null) { + $result = $this->_handler->fetchAll($style, $col); + } else { + $result = $this->_handler->fetchAll($style); + } + } else { + $result = $this->_handler->fetchAll($style); + } + } catch (PDOException $e) { + throw new Wootook_Core_Exception_Database_StatementError($this, $e->getMessage(), null, $e); + } + return $result; + } + + /** + * + * @param int $col + * @return mixed + */ + public function fetchColumn($col = 0) + { + try { + return $this->_handler->fetchColumn($col); + } catch (PDOException $e) { + throw new Wootook_Core_Exception_Database_StatementError($this, $e->getMessage(), null, $e); + } + return null; + } + + /** + * + * @return Wootook_Core_Database_Adapter_Adapter + */ + public function getAdapter() + { + return $this->_adapter; + } + + /** + * + * @param string $key + */ + public function getAttribute($key) + { + try { + return $this->_handler->getAttribute($key); + } catch (PDOException $e) { + throw new Wootook_Core_Exception_Database_StatementError($this, $e->getMessage(), null, $e); + } + return null; + } + + /** + * + * @param string $key + * @param mixed $value + * @return Wootook_Core_Database_Statement_Statement + */ + public function setAttribute($key, $value) + { + try { + return $this->_handler->setAttribute($key, $value); + } catch (PDOException $e) { + throw new Wootook_Core_Exception_Database_StatementError($this, $e->getMessage(), null, $e); + } + return false; + } + + /** + * @param unknown_type $mode + * @return Wootook_Core_Database_Statement_Statement + */ + public function setFetchMode($mode) + { + try { + $params = func_get_args(); + return call_user_func_array($array($this->_handler, 'setFetchMode'), $params); + } catch (PDOException $e) { + throw new Wootook_Core_Exception_Database_StatementError($this, $e->getMessage(), null, $e); + } + return false; + } + + /** + * @return int + */ + public function columnCount() + { + try { + return $this->_handler->columnCount(); + } catch (PDOException $e) { + throw new Wootook_Core_Exception_Database_StatementError($this, $e->getMessage(), null, $e); + } + return 0; + } + + /** + * @return int + */ + public function rowCount() + { + try { + return $this->_handler->rowCount(); + } catch (PDOException $e) { + throw new Wootook_Core_Exception_Database_StatementError($this, $e->getMessage(), null, $e); + } + return 0; + } + + /** + * @param int $col + * @return mixed + */ + public function fetch($style = null, $orientation = Wootook_Core_Database_ConnectionManager::FETCH_ORI_NEXT, $cursorOffset = 0) + { + try { + return $this->_handler->fetch($style, $orientation, $cursorOffset); + } catch (PDOException $e) { + throw new Wootook_Core_Exception_Database_StatementError($this, $e->getMessage(), null, $e); + } + return null; + } + + /** + * @param string $class + * @param array $config + * @return Wootook_Object + */ + public function fetchObject($class = 'Wootook_Object', Array $constructorArgs = array()) + { + try { + return $this->_handler->fetchObject($class, $constructorArgs); + } catch (PDOException $e) { + throw new Wootook_Core_Exception_Database_StatementError($this, $e->getMessage(), null, $e); + } + return null; + } + + /** + * @return bool + */ + public function closeCursor() + { + try { + return $this->_handler->closeCursor(); + } catch (PDOException $e) { + throw new Wootook_Core_Exception_Database_AdapterError($this, $e->getMessage(), null, $e); + } + return false; + } + + /** + * @return bool + */ + public function nextRowset() + { + try { + return $this->_handler->nextRowset(); + } catch (PDOException $e) { + throw new Wootook_Core_Exception_Database_AdapterError($this, $e->getMessage(), null, $e); + } + return false; + } + + /** + * @return string + */ + public function errorCode() + { + return $this->_handler->errorCode(); + } + + /** + * @return array + */ + public function errorInfo() + { + return $this->_handler->errorInfo(); + } + + /** + * @return string + */ + public function errorMessage() + { + $info = $this->_handler->errorInfo(); + + return $info[2]; + } + + /** + * @return string + */ + public function errorState() + { + $info = $this->_handler->errorInfo(); + + return $info[0]; + } +} diff --git a/src/application/code/core/Wootook/Core/Database/Statement/Statement.php b/src/application/code/core/Wootook/Core/Database/Statement/Statement.php new file mode 100644 index 0000000..9e8875f --- /dev/null +++ b/src/application/code/core/Wootook/Core/Database/Statement/Statement.php @@ -0,0 +1,215 @@ +_adapter = $adapter; + + $this->_init($sql); + } + + abstract protected function _init($sql); + + /** + * + * @param string|int $column + * @param mixed $param + * @param int $type + * @return Wootook_Core_Database_Statement_Statement + */ + abstract public function bindColumn($column, &$param, $type = null); + + /** + * + * @param string|int $parameter + * @param mixed $variable + * @param int $type + * @param int $length + * @param unknown_type $options + * @return Wootook_Core_Database_Statement_Statement + */ + abstract public function bindParam($parameter, &$variable, $type = null, $length = null, $options = null); + + /** + * + * @param string|int $parameter + * @param mixed $value + * @param int $type + * @return Wootook_Core_Database_Statement_Statement + */ + abstract public function bindValue($parameter, $value, $type = null); + + /** + * + * @param array $params + * @return bool + */ + abstract public function execute(Array $params = null); + + /** + * + * @param int $style + * @param int $col + * @return mixed + */ + abstract public function fetch($style = null, $orientation = Wootook_Core_Database_ConnectionManager::FETCH_ORI_NEXT, $cursorOffset = 0); + + /** + * + * @param int $style + * @param int $col + * @return mixed + */ + abstract public function fetchAll($style = null, $col = null); + + /** + * + * @param int $col + * @return mixed + */ + abstract public function fetchColumn($col = 0); + + /** + * + * @param string $class + * @param array $config + * @return Wootook_Object + */ + abstract public function fetchObject($class = 'Wootook_Object', Array $constructorArgs = array()); + + /** + * + * @param string $class + * @param array $config + * @return Wootook_Object + */ + public function fetchEntity($class = 'Wootook_Core_Mvc_Model_Entity', Array $constructorArgs = array()) + { + $reflection = new ReflectionClass($class); + $object = $reflection->newInstanceArgs($constructorArgs); + + if (!$object instanceof Wootook_Object) { + throw new Wootook_Core_Exception_Database_StatementError($this, 'Destination object should be a Wootook_Core_Mvc_Model_Entity instance.'); + } + + $data = $this->fetch(Wootook_Core_Database_ConnectionManager::FETCH_ASSOC); + if ($data !== false) { + $object->getDataMapper()->decode($object, $data); + } + + return $object; + } + + /** + * + * @return Wootook_Core_Database_Adapter_Adapter + */ + abstract public function getAdapter(); + + /** + * + * @param string $key + */ + abstract public function getAttribute($key); + + /** + * + * @param string $key + * @param mixed $value + * @return Wootook_Core_Database_Statement_Statement + */ + abstract public function setAttribute($key, $value); + + /** + * @param unknown_type $mode + * @return Wootook_Core_Database_Statement_Statement + */ + abstract public function setFetchMode($mode); + + /** + * @return int + */ + abstract public function columnCount(); + + /** + * @return string + */ + abstract public function errorCode(); + + /** + * @return string + */ + abstract public function errorMessage(); + + /** + * @return array + */ + abstract public function errorInfo(); + + /** + * @return string + */ + abstract public function errorState(); + + /** + * @return int + */ + abstract public function rowCount(); + + /** + * @return bool + */ + abstract public function closeCursor(); + + /** + * @return bool + */ + abstract public function nextRowset(); + + public function getParamType($value) + { + if (is_numeric($value)) { + return Wootook_Core_Database_ConnectionManager::PARAM_INT; + } else if (is_bool($value)) { + return Wootook_Core_Database_ConnectionManager::PARAM_BOOL; + } else if (is_string($value)) { + return Wootook_Core_Database_ConnectionManager::PARAM_STR; + } + + return null; + } + + public function current() + { + return $this->_currentRow; + } + + public function next() + { + $this->_currentRow = $this->fetch(); + $this->_currentIndex++; + } + + public function key() + { + return $this->_currentIndex; + } + + public function rewind() + { + return $this->_currentIndex; + } + + public function valid() + { + $rows = $this->rowCount(); + return $rows > 0 && $this->_currentIndex <= $rows; + } +} diff --git a/src/application/code/core/Wootook/Core/DateTime.php b/src/application/code/core/Wootook/Core/DateTime.php new file mode 100644 index 0000000..06a6d79 --- /dev/null +++ b/src/application/code/core/Wootook/Core/DateTime.php @@ -0,0 +1,311 @@ + array(self::DAY => '#(0[1-9]|[12][0-9]|3[01])#'), + 'j' => array(self::DAY => '#([1-9]|[12][0-9]|3[01])#'), + 'D' => array(self::WEEKDAY => '#(Mon|Tue|Wed|Thu|Fri|Sat|Sun)#i', self::PARSER => '_parseShortWeekday'), + 'N' => array(self::WEEKDAY => '#([1-7])#', self::PARSER => '_parseWeekday'), + 'w' => array(self::WEEKDAY => '#([0-6])#'), + 'm' => array(self::MONTH => '#(0[1-9]|1[0-2])#'), + 'M' => array(self::MONTH => '#(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)#i', self::PARSER => '_parseShortMonth'), + 'n' => array(self::MONTH => '#([1-9]|1[0-2])#'), + 'o' => array(self::YEAR_ISO => '#([0-9]{4})#'), + 'Y' => array(self::YEAR => '#([0-9]{4})#'), + 'y' => array(self::YEAR => '#([0-9]{2})#', self::PARSER => '_parseShortYear'), + + 'a' => array(self::MERIDIEM => '#(am|pm)#', self::PARSER => '_parseMeridiem'), + 'A' => array(self::MERIDIEM => '#(AM|PM)#', self::PARSER => '_parseMeridiem'), + 'g' => array(self::HOUR => '#([0-9]{1,2})#'), + 'G' => array(self::HOUR => '#([0-9]{1,2})#'), + 'h' => array(self::HOUR => '#([0-9]{2})#'), + 'H' => array(self::HOUR => '#([0-9]{2})#'), + 'i' => array(self::MINUTE => '#([0-9]{2})#'), + 's' => array(self::SECOND => '#([0-9]{2})#'), + 'u' => array(self::MICROSECOND => '#([0-9]{6})#'), + 'I' => array(self::DAYLIGHT => '#(0|1)#'), + + // Unimplemented and ignored modifiers + 'l' => array(null => '#.#'), + 'S' => array(null => '#.#'), + 'z' => array(null => '#.#'), + 'W' => array(null => '#.#'), + 'f' => array(null => '#.#'), + 't' => array(null => '#.#'), + 'L' => array(null => '#.#'), + 'O' => array(null => '#.#'), + 'P' => array(null => '#.#'), + 'T' => array(null => '#.#'), + 'Z' => array(null => '#.#'), + 'c' => array(null => '#.#'), + 'r' => array(null => '#.#'), + 'U' => array(null => '#.#') + ); + + protected $_datetime = null; + + public static function init($timezone = null, $force = false) + { + static $init = false; + + if ($init === false || $force === true) { + if ($timezone === null) { + //$timezone = Wootook::getConfig('system/date/timezone'); + } + if ($timezone === null) { + $timezone = 'GMT'; + } + + date_default_timezone_set($timezone); + $init = true; + } + } + + public function __construct($timestamp = null, $format = null) + { + self::init(); + + if ($timestamp === null) { + $this->_datetime = time(); + } else if ($format === null) { + $this->_datetime = intval($timestamp); + } else { + $this->_datetime = $this->_parse($timestamp, $format); + } + } + + public function getIso($useTimezone = false) + { + return $this->toString(self::ISO_8601, $useTimezone); + } + + public function getTimestamp() + { + return $this->_datetime; + } + + public function now() + { + return $this->calc(time(), self::TIMESTAMP, self::OPERATOR_SET); + } + + public function set($value, $part = self::TIMESTAMP) + { + return $this->calc($value, $part, self::OPERATOR_SET); + } + + public function add($value, $part = self::TIMESTAMP) + { + return $this->calc($value, $part, self::OPERATOR_ADD); + } + + public function sub($value, $part = self::TIMESTAMP) + { + return $this->calc($value, $part, self::OPERATOR_SUB); + } + + public function calc($value, $part = self::TIMESTAMP, $type = self::OPERATOR_ADD) + { + switch ($part) { + case self::YEAR: + case self::MONTH: + case self::WEEK: + case self::DAY: + case self::HOUR: + case self::MINUTE: + case self::SECOND: + $current = getdate($this->_datetime); + if ($type === self::OPERATOR_ADD) { + $current[$part] += $value; + } else if ($type === self::OPERATOR_SUB) { + $current[$part] -= $value; + } else if ($type === self::OPERATOR_SET) { + $current[$part] = $value; + } + + $this->_datetime = $this->_mktime($current); + break; + + case self::TIMESTAMP: + if ($type === self::OPERATOR_ADD) { + $this->_datetime += intval($value); + } else if ($type === self::OPERATOR_SUB) { + $this->_datetime -= intval($value); + } else if ($type === self::OPERATOR_SET) { + $this->_datetime = intval($value); + } + break; + // default: break; // omitted + } + + return $this; + } + + public function diff(self $date) + { + return $this->_datetime - $date->_datetime; + } + + public function isEarlier(self $date = null) + { + if ($date === null) { + $date = new self(); + } + return (bool) ($this->diff($date) > 0); + } + + public function isLater(self $date = null) + { + if ($date === null) { + $date = new self(); + } + return (bool) ($this->diff($date) < 0); + } + + protected function _mktime(Array $parts) + { + return mktime($parts[self::HOUR], $parts[self::MINUTE], $parts[self::SECOND], + $parts[self::MONTH], $parts[self::DAY], $parts[self::YEAR]); + } + + public function toString($format, $useTimezone = true) + { + if ($useTimezone) { + return date($format, $this->_datetime); + } else { + return gmdate($format, $this->_datetime); + } + } + + public function __toString() + { + return $this->toString(self::ISO_8601, false); + } + + protected function _parseShortYear($match) + { + $year = intval($match); + if ($year < 70) { + $year += 2000; + } else if ($year < 100) { + $year += 1900; + } + return $year; + } + + protected function _parseShortMonth($match) + { + if ($key = array_search(strtolower($match), array('jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'))) { + return $key + 1; + } + return false; + } + + protected function _parseShortWeekday($match) + { + if ($key = array_search(strtolower($match), array('mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'))) { + return $key; + } + return false; + } + + protected function _parseWeekday($match) + { + return intval($match) % 7; + } + + protected function _parseMeridiem($match) + { + if (in_array(strtolower($match), array(self::MERIDIEM_AM, self::MERIDIEM_PM))) { + return strtolower($match); + } + return false; + } + + protected function _parse($datetime, $format) + { + $parts = array( + self::YEAR => false, + self::YEAR_ISO => false, + self::MONTH => false, + self::DAY => false, + self::WEEKDAY => false, + self::HOUR => false, + self::MINUTE => false, + self::SECOND => false, + self::MICROSECOND => false, + self::DAYLIGHT => false, + self::MERIDIEM => false, + ); + + $offset = 0; + + $length = strlen($format); + for ($i = 0; $i < $length; $i++) { + $modifier = $format[$i]; + if (!isset(self::$_rules[$modifier])) { + $offset = (strpos($datetime, $format[$i], $offset)) + 1; + continue; + } + + $rule = self::$_rules[$modifier]; + $callback = null; + if (isset($rule[self::PARSER])) { + $callback = $rule[self::PARSER]; + unset($rule[self::PARSER]); + } + + foreach ($rule as $part => $regex) { + if (!preg_match($regex, $datetime, $matches, null, $offset)) { + continue; + } + + if ($callback === null) { + $parts[$part] = intval($matches[1]); + } else if (is_callable($callback)) { + $parts[$part] = call_user_func($callback, $matches[1]); + } else { + $parts[$part] = $this->$callback($matches[1]); + } + $offset += strlen($matches[1]); + } + } + + if ($parts[self::MERIDIEM] !== false && $parts[self::MERIDIEM] === self::MERIDIEM_PM) { + $parts[self::HOUR] = ($parts[self::HOUR] + 12) % 24; + } + + if ($parts[self::YEAR] !== false || $parts[self::YEAR_ISO] === false) { + return $this->_mktime($parts); + } else { + return $this->_mktime($parts); + } + } +} diff --git a/src/application/code/core/Wootook/Core/Email.php b/src/application/code/core/Wootook/Core/Email.php new file mode 100644 index 0000000..e94331e --- /dev/null +++ b/src/application/code/core/Wootook/Core/Email.php @@ -0,0 +1,51 @@ +setTransport($transport); + } + + public function setTransport(Wootook_Core_Email_Transport_Transport $transport) + { + $this->_transport = $transport; + } + + /** + * @return Wootook_Core_Email_Transport_Transport + */ + public function getTransport() + { + return $this->_transport; + } + + public function send($to, $from, $subject, $body, Array $headers = array()) + { + try { + $this->_transport + ->addRecipient($to) + ->setFrom($from) + ->setSubject($subject) + ->addPart(new Wootook_Core_Email_Part_Part($body)) + ->addHeaders($headers) + ->connect() + ->send() + ; + } catch (Wootook_Core_Exception_RuntimeException $e) { + throw new Wootook_Core_Exception_RuntimeException('Could not send mail.', null, $e); + } + + $this->_transport->disconnect(); + + return $this; + } +} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Core/Email/Part/Part.php b/src/application/code/core/Wootook/Core/Email/Part/Part.php new file mode 100644 index 0000000..563a051 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Email/Part/Part.php @@ -0,0 +1,16 @@ +_content = $content; + } + + public function render() + { + return $this->_content; + } +} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Core/Email/Transport/Sendmail.php b/src/application/code/core/Wootook/Core/Email/Transport/Sendmail.php new file mode 100644 index 0000000..165247a --- /dev/null +++ b/src/application/code/core/Wootook/Core/Email/Transport/Sendmail.php @@ -0,0 +1,162 @@ +_prepareHeaders(); + } + + public function setFrom($from) + { + if (is_array($from)) { + $this->_from = sprintf('"%s" <%s>', $this->_formatUnicode(current($from)), key($from)); + } else { + $this->_from = $from; + } + return $this; + } + + public function clearFrom() + { + $this->_from = null; + + return $this; + } + + public function addRecipient($recipient) + { + if (is_array($recipient)) { + foreach ($recipient as $email => $name) { + $this->_recipients[] = sprintf('"%s" <%s>', $this->_formatUnicode($name), $email); + } + } else { + $this->_recipients[] = $recipient; + } + return $this; + } + + public function clearRecipients() + { + $this->_recipients = array(); + + return $this; + } + + public function setSubject($subject) + { + $this->_subject = $this->_formatUnicode($subject); + + return $this; + } + + public function clearSubject() + { + $this->_subject = null; + + return $this; + } + + public function addHeader($name, $value) + { + $this->_headers[$name] = $value; + + return $this; + } + + public function addHeaders($headers) + { + foreach ($headers as $name => $value) { + $this->_headers[$name] = $value; + } + + return $this; + } + + public function clearHeaders() + { + $this->_headers = array(); + + return $this; + } + + public function addPart(Wootook_Core_Email_Part_Part $part) + { + $this->_parts[] = $part; + + return $this; + } + + public function clearParts() + { + $this->_parts = array(); + + return $this; + } + + protected function _formatUnicode($string) + { + return '=?UTF-8?B?' . base64_encode($string) . '?='; + } + + protected function _prepareHeaders(Array $headers = array()) + { + $this->addHeader('MIME-Version', '1.0'); + + foreach ($headers as $name => $value) { + $this->setHeader($name, $value); + } + + $this->addHeader('X-Mailer', 'PHP/' . PHP_VERSION . ' Wootook/' . VERSION); + $this->addHeader('Content-Transfer-Encoding', '8bit'); + $this->addHeader('Content-Type', 'text/plain; charset=utf-8; format=flowed'); + + return $this; + } + + public function reset() + { + $this->clearHeaders(); + $this->clearParts(); + $this->clearFrom(); + $this->clearRecipients(); + $this->clearSubject(); + + return $this; + } + + public function connect() + { + return $this; + } + + public function disconnect() + { + return $this; + } + + public function send() + { + $content = ''; + foreach ($this->_parts as $part) { + $content .= $part->render(); + } + + $this->addHeader('To', implode(',', $this->_recipients)); + + if (!mail(implode(',', $this->_recipients), $this->_subject, $content, implode("\r\n", $this->_headers))) { + throw new Wootook_Core_Exception_RuntimeException('Could not send mail.'); + } + + return $this; + } +} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Core/Email/Transport/Transport.php b/src/application/code/core/Wootook/Core/Email/Transport/Transport.php new file mode 100644 index 0000000..fed059e --- /dev/null +++ b/src/application/code/core/Wootook/Core/Email/Transport/Transport.php @@ -0,0 +1,22 @@ + + * 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 . + * + * --> 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 Wootook_Core_ErrorProfiler +{ + private static $_singleton = null; + + protected $_errors = array(); + protected $_warnings = array(); + protected $_notices = array(); + protected $_otherErrors = array(); + protected $_exceptions = array(); + + private static $_isTraceRegistered = false; + + private $_listen = true; + + private $_mute = true; + + /** + * + * @return Wootook_Core_ErrorProfiler + */ + public static function getSingleton() + { + if (self::$_singleton === null) { + self::$_singleton = new self; + } + return self::$_singleton; + } + + public function errorManager($errno, $errstr, $errfile = null, $errline = null, Array $errcontext = array()) + { + if (!$this->_listen) { + return; + } + + $trace = debug_backtrace(); + + switch ($errno) { + case E_RECOVERABLE_ERROR: + case E_USER_ERROR: + case E_ERROR: + $this->_errors[] = array( + 'time' => explode(' ', microtime()), + 'code' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + 'context' => $errcontext, + 'trace' => $trace + ); + break; + + case E_USER_WARNING: + case E_WARNING: + $this->_warnings[] = array( + 'time' => explode(' ', microtime()), + 'code' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + 'context' => $errcontext, + 'trace' => $trace + ); + break; + + case E_USER_NOTICE: + case E_NOTICE: + $this->_notices[] = array( + 'time' => explode(' ', microtime()), + 'code' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + 'context' => $errcontext, + 'trace' => $trace + ); + break; + + default: + if (!isset($this->_otherErrors[$errno])) { + $this->_otherErrors[$errno] = array(); + } + + $this->_otherErrors[$errno][] = array( + 'time' => explode(' ', microtime()), + 'code' => $errno, + 'message' => $errstr, + 'file' => $errfile, + 'line' => $errline, + 'context' => $errcontext, + 'trace' => $trace + ); + break; + } + + return true; + } + + public function addException($exception) + { + $this->_exceptions[] = $exception; + } + + public function exceptionManager($exception) + { + if (!$this->_listen) { + return; + } + $this->_exceptions[] = new Wootook_Core_Exception_Exception('Uncaught Exception: ' . $exception->getMessage(), null, $exception); + } + + protected function _renderError($id, $error) + { + $types = array( + 0x0001 => 'E_ERROR', + 0x0002 => 'E_WARNING', + 0x0004 => 'E_PARSE', + 0x0008 => 'E_NOTICE', + 0x0010 => 'E_CORE_ERROR', + 0x0020 => 'E_CORE_WARNING', + 0x0040 => 'E_COMPILE_ERROR', + 0x0080 => 'E_COMPILE_WARNING', + 0x0100 => 'E_USER_ERROR', + 0x0200 => 'E_USER_WARNING', + 0x0400 => 'E_USER_NOTICE', + 0x0800 => 'E_STRICT', + 0x1000 => 'E_RECOVERABLE_ERROR', + 0x2000 => 'E_DEPRECATED', + 0x4000 => 'E_USER_DEPRECATED', + ); + + if (isset($error['code']) && isset($types[$error['code']])) { + $code = $types[$error['code']]; + } else { + $code = "Unknown ({$error['code']})"; + } + + $date = date('Y-m-d H:i:s', (int) $error['time'][1]); + $microsec = (int) ($error['time'][0] * 1000000); + + return <<_renderBacktrace($error['trace'])} + +ERROR_EOF; + } + + protected function _renderBacktrace(Array $traces) + { + $output = '
    ';
    +        foreach (array_slice($traces, 1) as $key => $trace) {
    +            if (preg_match('#^(include|require)(_once)?$#', $trace['function'])) {
    +                $output .= sprintf("#%d %s(%s) called at [%s:%s]\n",
    +                    $key, $trace['function'], $trace['args'][0], $trace['file'], $trace['line']);
    +            } else if (!isset($trace['file']) || !isset($trace['line'])) {
    +                if (isset($trace['class'])) {
    +                    $output .= sprintf("#%d Internal function %s%s%s(%s)\n",
    +                        $key, $trace['class'], $trace['type'], $trace['function'], implode(', ', $this->_formatArgs($trace['args'])));
    +                } else {
    +                    $output .= sprintf("#%d Internal function %s(%s)\n",
    +                        $key, $trace['function'], implode(', ', $this->_formatArgs($trace['args'])));
    +                }
    +            } else {
    +                if (isset($trace['class'])) {
    +                    $output .= sprintf("#%d %s%s%s(%s) called at [%s:%s]\n",
    +                        $key, $trace['class'], $trace['type'], $trace['function'], implode(', ', $this->_formatArgs($trace['args'])), $trace['file'], $trace['line']);
    +                } else {
    +                    $output .= sprintf("#%d %s(%s) called at [%s:%s]\n",
    +                        $key, $trace['function'], implode(', ', $this->_formatArgs($trace['args'])), $trace['file'], $trace['line']);
    +                }
    +            }
    +        }
    +        return $output . '
    '; + } + + private function _formatArgs($args) + { + $argumentList = array(); + foreach ($args as $argument) { + if (is_object($argument)) { + $argumentList[] = get_class($argument); + } else if (is_array($argument)) { + $keys = array_keys($argument); + $values = $this->_formatArgs($argument); + + $length = count($values); + $output = array(); + for ($index = 0; $index < $length; $index++) { + $output[] = sprintf('[%s] => %s', $keys[$index], $values[$index]); + } + + $argumentList[] = '[' . implode(', ', $output) . ']'; + } else { + $argumentList[] = var_export($argument, true); + } + } + + return $argumentList; + } + + protected function _renderConfig(Wootook_Core_Config_Node $config, $level = 0) + { + $output = '
      '; + foreach ($config as $key => $value) { + $output .= sprintf('
    • ', $level); + $output .= sprintf('%s', $key); + if ($value instanceof Wootook_Core_Config_Node) { + if (count($value) > 0) { + $output .= $this->_renderConfig($value, $level + 1); + } else { + $output .= 'Empty node'; + } + } else { + $output .= '' . htmlspecialchars(var_export($value, true), ENT_QUOTES, 'UTF-8') . ''; + } + $output .= '
    • '; + } + $output .= '
    '; + + return $output; + } + + public function shutdownManager() + { + if ($this->_mute === true) { + return; + } + + $index = 0; + echo '
    '; + echo '

    Debug profiler

    '; + echo '
    '; + echo '
    '; + echo ''; + echo '
    '; + foreach ($this->_errors as $error) { + ++$index; + echo '

    Message #' . $index . '

    '; + echo '
    ';
    +            echo $this->_renderError($index, $error);
    +            echo '
    '; + } + echo '
    '; + echo ''; + echo '
    '; + foreach ($this->_warnings as $error) { + ++$index; + echo '

    Message #' . $index . '

    '; + echo '
    ';
    +            echo $this->_renderError($index, $error);
    +            echo '
    '; + } + echo '
    '; + echo ''; + echo '
    '; + foreach ($this->_notices as $error) { + ++$index; + echo '

    Message #' . $index . '

    '; + echo '
    ';
    +            echo $this->_renderError($index, $error);
    +            echo '
    '; + } + echo '
    '; + foreach ($this->_otherErrors as $errno => $errorList) { + echo ''; + echo '
    '; + foreach ($errorList as $error) { + ++$index; + echo '

    Message #' . $index . '

    '; + echo '
    ';
    +                echo $this->_renderError($index, $error);
    +                echo '
    '; + } + echo '
    '; + } + echo ''; + echo '
    '; + foreach ($this->_exceptions as $exception) { + ++$index; + echo '

    Message #' . $index . '

    '; + echo '
    ';
    +            echo $exception->getMessage() . PHP_EOL;
    +            echo $exception->getTraceAsString() . PHP_EOL;
    +            echo '
    '; + + $child = 0; + $current = $exception; + while (($current = $current->getPrevious()) !== null) { + $child++; + echo '

    Message #' . $index . ', child level #' . $child . '

    '; + echo '
    ';
    +                echo $current->getMessage() . PHP_EOL;
    +                echo $current->getTraceAsString() . PHP_EOL;
    +                echo PHP_EOL;
    +                echo '
    '; + } + echo '
    '; + } + echo '
    '; + echo << +(function(){ +var sections = jQuery('.error-profiler'); +sections.each(function(){ + var element = jQuery(this); + element.hide(); + }); + +jQuery('.error-profiler-link').click(function(e){ + var rel = jQuery(this).attr('rel'); + sections.each(function(){ + var element = jQuery(this); + if (element.hasClass(rel) && !element.hasClass('opened')) { + element.slideDown(500, function(){element.addClass('opened');}); + } else { + element.slideUp(500, function(){element.removeClass('opened');}); + } + }); + }); +})(); + +JS_EOF; + echo '

    Configuration profiler

    '; + echo ''; + echo '
    '; + $config = clone Wootook::getConfig(); + foreach ($config->getConfig('resource/database') as $node) { + if ($node->params) { + $node->params->reset(); + } + } + echo $this->_renderConfig(Wootook::getConfig(), 0); + echo '
    '; + echo ''; + echo '
    '; + echo $this->_renderConfig(Wootook::getWebsiteConfig()); + echo '
    '; + echo ''; + echo '
    '; + echo $this->_renderConfig(Wootook::getGameConfig()); + echo '
    '; + echo ''; + echo << +(function(){ +var sections = jQuery('.config-profiler'); +sections.each(function(){ + var element = jQuery(this); + element.hide(); + }); + +jQuery('.config-profiler-link').click(function(e){ + var rel = jQuery(this).attr('rel'); + sections.each(function(){ + var element = jQuery(this); + if (element.hasClass(rel) && !element.hasClass('opened')) { + element.slideDown(500, function(){element.addClass('opened');}); + } else { + element.slideUp(500, function(){element.removeClass('opened');}); + } + }); + }); +})(); + +JS_EOF; + } + + public static function register() + { + set_error_handler(array(self::getSingleton(), 'errorManager')); + set_exception_handler(array(self::getSingleton(), 'exceptionManager')); + + if (defined('DEBUG')) { + self::getSingleton()->_mute = false; + } + + if (self::$_isTraceRegistered === false && defined('DEBUG')) { + self::$_isTraceRegistered = true; + register_shutdown_function(array(self::getSingleton(), 'shutdownManager')); + } + } + + public static function unregister($force = false) + { + restore_error_handler(); + restore_exception_handler(); + + self::getSingleton()->_mute = true; + + if ((self::$_isTraceRegistered === false && defined('DEBUG')) || $force) { + self::$_isTraceRegistered = true; + register_shutdown_function(array(self::getSingleton(), 'shutdownManager')); + } + } + + public function sleep() + { + $this->_listen = false; + } + + public function wakeup() + { + $this->_listen = true; + } +} diff --git a/src/application/code/core/Wootook/Core/Event.php b/src/application/code/core/Wootook/Core/Event.php new file mode 100644 index 0000000..42b4de7 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Event.php @@ -0,0 +1,40 @@ + + * 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 . + * + * --> 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 Wootook_Core_Event + extends Wootook_Object +{ +} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Core/Event/Break.php b/src/application/code/core/Wootook/Core/Event/Break.php new file mode 100644 index 0000000..2722566 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Event/Break.php @@ -0,0 +1,7 @@ + + * 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 . + * + * --> 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 + * + */ +interface Wootook_Core_Exception extends Wootook_Exception {} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Core/Exception/DataAccessException.php b/src/application/code/core/Wootook/Core/Exception/DataAccessException.php new file mode 100644 index 0000000..25ddc44 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Exception/DataAccessException.php @@ -0,0 +1,6 @@ +_adapter = $adapter; + } + + public function getAdapter() + { + return $this->_adapter; + } +} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Core/Exception/Database/Error.php b/src/application/code/core/Wootook/Core/Exception/Database/Error.php new file mode 100644 index 0000000..6d485fa --- /dev/null +++ b/src/application/code/core/Wootook/Core/Exception/Database/Error.php @@ -0,0 +1,5 @@ +_statement = $statement; + } + + public function getStatement() + { + return $this->_statement; + } +} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Core/Exception/Deprecated.php b/src/application/code/core/Wootook/Core/Exception/Deprecated.php new file mode 100644 index 0000000..75cbf77 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Exception/Deprecated.php @@ -0,0 +1,7 @@ += 50300) { + parent::__construct($message, $code, $previous); + } else { + parent::__construct($message, $code); + $this->_previous = $previous; + } + } + + public function __call($method, $params) + { + if (strtolower($method) == 'getprevious') { + return $this->_previous; + } + } +} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Core/Exception/GameError.php b/src/application/code/core/Wootook/Core/Exception/GameError.php new file mode 100644 index 0000000..ab228a8 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Exception/GameError.php @@ -0,0 +1,7 @@ += 50300) { + parent::__construct($message, $code, $previous); + } else { + parent::__construct($message, $code); + $this->_previous = $previous; + } + } + + public function __call($method, $params) + { + if (strtolower($method) == 'getprevious') { + return $this->_previous; + } + } + + public function __toString() + { + return << + * 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 . + * + * --> 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 Wootook_Core_Form +{ + protected $_elements = array(); + + protected $_request = null; + + /** + * + * Element class loader + * @var Wootook_Core_Form_ElementLoader + */ + protected $_elementLoader = null; + + /** + * + * Validator class loader + * @var Wootook_Core_Form_ValidatorLoader + */ + protected $_validatorLoader = null; + + /** + * + * Enter description here ... + * @var Wootook_Core_Model_Session + */ + protected $_session = null; + + public function __construct(Wootook_Core_Model_Session $session, Array $elements = array()) + { + $this->_session = $session; + + $this->_elementLoader = new Wootook_Core_Form_ElementLoader($this, array( + 'Wootook_Core_Form_Element_' => 'Wootook/Core/Form/Element' + )); + + $this->_validatorLoader = new Wootook_Core_Form_ValidatorLoader($this, array( + 'Wootook_Core_Form_Validator_' => 'Wootook/Core/Form/Validator' + )); + + $this->addElement('__formkey', 'text', array('form_key' => 'formKey')); + + foreach ($elements as $elementName => $elementConfig) { + if (is_string($elementConfig)) { + $this->addElement($elementName, $elementConfig); + } else if ($elementConfig instanceof Wootook_Core_Form_ElementAbstract) { + $this->addElement($elementName, $elementConfig); + } else { + if (isset($elementConfig['validators'])) { + $this->addElement($elementName, $elementConfig['type'], $elementConfig['validators']); + } else { + $this->addElement($elementName, $elementConfig['type']); + } + } + } + } + + public function validate() + { + foreach ($this->_elements as $element) { + if (!$element->validate()) { + return false; + } + } + return true; + } + + /** + * + * Enter description here ... + * @param string $name + * @param string|Wootook_Core_Form_ElementAbstract $type + * @return Wootook_Core_Form + */ + public function addElement($name, $type = 'text', Array $validators = array()) + { + if ($type instanceof Wootook_Core_Form_ElementAbstract) { + $this->_elements[$name] = $type; + $this->_elements[$name]->setForm($this); + } else { + $element = $this->_elementLoader->load($type); + + if ($element === null) { + Wootook_Core_ErrorProfiler::getSingleton() + ->addException(new Wootook_Core_Exception_RuntimeException(sprintf('Element %1$s (type: %2$s) could not be created.', $name, $type))); + return $this; + } + $element->setForm($this); + $this->_elements[$name] = $element; + } + $this->_elements[$name]->setName($name); + + foreach ($validators as $validatorName => $validatorType) { + if ($validatorType instanceof Wootook_Core_Form_ElementAbstract) { + $this->_elements[$name]->addValidator($validatorType, $validatorName); + } else { + $validator = $this->_validatorLoader->load($validatorType); + + if ($validator === null) { + Wootook_Core_ErrorProfiler::getSingleton() + ->addException(new Wootook_Core_Exception_RuntimeException(sprintf('Validator %1$s (type: %2$s) could not be created.', $validatorName, $validatorType))); + return $this; + } + $this->_elements[$name]->addValidator($validator, $validatorName); + } + } + + return $this; + } + + /** + * + * Enter description here ... + * @param string $name + * @return Wootook_Core_Form_ElementAbstract + */ + public function getElement($name) + { + if (!isset($this->_elements[$name])) { + return null; + } + + return $this->_elements[$name]; + } + + /** + * + * Enter description here ... + * @param string $name + * @return Wootook_Core_Model_Session + */ + public function getSession() + { + return $this->_session; + } + + public function setRequest(Wootook_Core_Mvc_Controller_Request_Http $request) + { + $this->_request = $request; + + return $this; + } + + /** + * + * Enter description here ... + * @return Wootook_Core_Mvc_Controller_Request_Http + */ + public function getRequest() + { + return $this->_request; + } + + public function getData() + { + $request = $this->getRequest(); + if ($request === null) { + return array(); + } + if ($request->isPost()) { + return $request->getAllPostData(); + } + return $request->getAllQueryData(); + } + + public function populate(Array $datas = array()) + { + $request = $this->getRequest(); + + foreach ($this->_elements as $elementName => $element) { + if (isset($datas[$elementName])) { + $element->populate($datas[$elementName]); + } else if ($request->isPost()) { + $element->populate($request->getPost($elementName)); + } else { + $element->populate($request->getQuery($elementName)); + } + } + } +} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Core/Form/Element/Button.php b/src/application/code/core/Wootook/Core/Form/Element/Button.php new file mode 100644 index 0000000..4e17721 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Form/Element/Button.php @@ -0,0 +1,11 @@ +setForm($form); + } + + $this->setName($name); + $this->setAllParams($params); + } + + abstract public function getType(); + + public function validate() + { + $data = $this->getData(); + + foreach ($this->_validators as $validator) { + if (!$validator->validate($this, $data)) { + return false; + } + } + return true; + } + + public function setName($name) + { + $this->_name = $name; + + return $this; + } + + public function getName() + { + return $this->_name; + } + + public function setAllParams($params) + { + $this->_params = $params; + + return $this; + } + + public function getAllParams() + { + return $this->_params; + } + + public function setParam($param, $value) + { + $this->_params[$param] = $value; + + return $this; + } + + public function getParam($param) + { + return $this->_params[$param]; + } + + public function hasParam($param) + { + return isset($this->_params[$param]); + } + + public function unsetParam($param) + { + unset($this->_params[$param]); + + return $this; + } + + public function setForm(Wootook_Core_Form $form) + { + $this->_form = $form; + + return $this; + } + + public function getForm() + { + return $this->_form; + } + + public function getData() + { + return $this->_value; + } + + public function populate($value) + { + $this->_value = $value; + + return $this; + } + + public function addValidator(Wootook_Core_Form_ValidatorAbstract $validator, $name = null) + { + if ($name === null) { + $this->_validators = array(); + $name = 'default'; + } + + $this->_validators[$name] = $validator; + + return $this; + } + + public function getValidator($name) + { + if (!isset($this->_validators[$name])) { + return null; + } + + return $this->_validators[$name]; + } + + public function clearValidator($name) + { + if (isset($this->_validators[$name])) { + unset($this->_validators[$name]); + } + + return $this; + } + + public function clearAllValidators() + { + $this->_validators = array(); + + return $this; + } +} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Core/Form/ElementLoader.php b/src/application/code/core/Wootook/Core/Form/ElementLoader.php new file mode 100644 index 0000000..019f082 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Form/ElementLoader.php @@ -0,0 +1,37 @@ +_form = $form; + + foreach ($namespaces as $namespace => $path) { + if (is_int($namespace)) { + $this->registerNamespace($path); + } else { + $this->registerNamespace($namespace, $path); + } + } + } + + protected function _load($className, $useSingleton, Array $constructorParams = array()) + { + $reflection = new ReflectionClass($className); + if ($useSingleton && $reflection->implementsInterface('Wootook_Core_Singleton')) { + $method = $reflection->getMethod('getSingleton'); + return $method->invoke(null); + } + + try { + return $reflection->newInstance($this->_form); + } catch (ReflectionException $e) { + Wootook_Core_ErrorProfiler::getSingleton() + ->addException($e); + return null; + } + } +} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Core/Form/Validator/Alnum.php b/src/application/code/core/Wootook/Core/Form/Validator/Alnum.php new file mode 100644 index 0000000..cdacc4f --- /dev/null +++ b/src/application/code/core/Wootook/Core/Form/Validator/Alnum.php @@ -0,0 +1,21 @@ +_validate($element, $data)) { + $this->_getSession($element) + ->addError('Field "%s" should only contain alphanumeric characters.', $element->getName()); + + return false; + } + return true; + } +} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Core/Form/Validator/Alpha.php b/src/application/code/core/Wootook/Core/Form/Validator/Alpha.php new file mode 100644 index 0000000..fb091ce --- /dev/null +++ b/src/application/code/core/Wootook/Core/Form/Validator/Alpha.php @@ -0,0 +1,21 @@ +_validate($element, $data)) { + $this->_getSession($element) + ->addError('Field "%s" should only contain alphabetic characters.', $element->getName()); + + return false; + } + return true; + } +} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Core/Form/Validator/Email.php b/src/application/code/core/Wootook/Core/Form/Validator/Email.php new file mode 100644 index 0000000..3ec8e21 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Form/Validator/Email.php @@ -0,0 +1,21 @@ +_validate($element, $data)) { + $this->_getSession($element) + ->addError('Field "%s" should contain an email.', $element->getName()); + + return false; + } + return true; + } +} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Core/Form/Validator/FormKey.php b/src/application/code/core/Wootook/Core/Form/Validator/FormKey.php new file mode 100644 index 0000000..11f49d0 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Form/Validator/FormKey.php @@ -0,0 +1,20 @@ +getForm(); + $session = $form->getSession(); + + if ($session->getFormKey(false) == $data) { + return true; + } + + $this->_getSession($field) + ->addError('CSRF token failure.', $field->getName()); + + return false; + } +} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Core/Form/Validator/Hex.php b/src/application/code/core/Wootook/Core/Form/Validator/Hex.php new file mode 100644 index 0000000..cbb2913 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Form/Validator/Hex.php @@ -0,0 +1,22 @@ +_validate($element, $data)) { + $this->_getSession($element) + ->addError('Field "%s" should only contain numeric characters.', $element->getName()); + + return false; + } + return true; + } +} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Core/Form/Validator/Host.php b/src/application/code/core/Wootook/Core/Form/Validator/Host.php new file mode 100644 index 0000000..4d1f7f5 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Form/Validator/Host.php @@ -0,0 +1,21 @@ +_validate($element, $data)) { + $this->_getSession($element) + ->addError('Field "%s" should contain a host name.', $element->getName()); + + return false; + } + return true; + } +} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Core/Form/Validator/Numeric.php b/src/application/code/core/Wootook/Core/Form/Validator/Numeric.php new file mode 100644 index 0000000..35f275d --- /dev/null +++ b/src/application/code/core/Wootook/Core/Form/Validator/Numeric.php @@ -0,0 +1,22 @@ +_validate($element, $data)) { + $this->_getSession($element) + ->addError('Field "%s" should only contain numeric characters.', $element->getName()); + + return false; + } + return true; + } +} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Core/Form/Validator/Regex.php b/src/application/code/core/Wootook/Core/Form/Validator/Regex.php new file mode 100644 index 0000000..172a787 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Form/Validator/Regex.php @@ -0,0 +1,28 @@ +_expression = $expression; + } + + public function validate(Wootook_Core_Form_ElementAbstract $element, $data) + { + if (!$this->_validate($element, $data)) { + $this->_getSession($element) + ->addError('Field "%s" does not match the validation pattern.', $element->getName()); + + return false; + } + return true; + } + + protected function _validate(Wootook_Core_Form_ElementAbstract $element, $data) + { + return preg_match($this->_expression, $data); + } +} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Core/Form/ValidatorAbstract.php b/src/application/code/core/Wootook/Core/Form/ValidatorAbstract.php new file mode 100644 index 0000000..d3f6da2 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Form/ValidatorAbstract.php @@ -0,0 +1,15 @@ +getForm(); + if (!$form instanceof Wootook_Core_Form) { + return null; + } + return $element->getSession(); + } +} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Core/Form/ValidatorLoader.php b/src/application/code/core/Wootook/Core/Form/ValidatorLoader.php new file mode 100644 index 0000000..123bd64 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Form/ValidatorLoader.php @@ -0,0 +1,37 @@ +_form = $form; + + foreach ($namespaces as $namespace => $path) { + if (is_int($namespace)) { + $this->registerNamespace($path); + } else { + $this->registerNamespace($namespace, $path); + } + } + } + + protected function _load($className, $useSingleton, Array $constructorParams = array()) + { + $reflection = new ReflectionClass($className); + if ($useSingleton && $reflection->implementsInterface('Wootook_Core_Singleton')) { + $method = $reflection->getMethod('getSingleton'); + return $method->invoke(null); + } + + try { + return $reflection->newInstance(); + } catch (ReflectionException $e) { + Wootook_Core_ErrorProfiler::getSingleton() + ->addException($e); + return null; + } + } +} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Core/Helper/Config/ConfigHandler.php b/src/application/code/core/Wootook/Core/Helper/Config/ConfigHandler.php new file mode 100644 index 0000000..7421bad --- /dev/null +++ b/src/application/code/core/Wootook/Core/Helper/Config/ConfigHandler.php @@ -0,0 +1,59 @@ + 'default', + 'episode' => 'default' + ); + } else { + $config = $config->toArray(); + } + + $path = 'gamedata' . DIRECTORY_SEPARATOR . $config['universe'] . DIRECTORY_SEPARATOR + . $config['episode'] . DIRECTORY_SEPARATOR . $filename . '.php'; + + foreach (include APPLICATION_PATH . $path as $elementId => $fieldName) { + $this->setData($elementId, $fieldName); + } + + return $this; + } + + public function count() + { + return count($this->_data); + } + + public function current() + { + return current($this->_data); + } + + public function next() + { + return next($this->_data); + } + + public function key() + { + return key($this->_data); + } + + public function valid() + { + return $this->current() !== false; + } + + public function rewind() + { + reset($this->_data); + } +} diff --git a/includes/application/code/core/Legacies/Empire/Model/Game/FieldsAlias.php b/src/application/code/core/Wootook/Core/Helper/Config/Events.php similarity index 58% rename from includes/application/code/core/Legacies/Empire/Model/Game/FieldsAlias.php rename to src/application/code/core/Wootook/Core/Helper/Config/Events.php index fcdd2a2..30b0528 100644 --- a/includes/application/code/core/Legacies/Empire/Model/Game/FieldsAlias.php +++ b/src/application/code/core/Wootook/Core/Helper/Config/Events.php @@ -4,12 +4,12 @@ * * Enter description here ... * - * @uses Legacies_Object + * @uses Wootook_Object * @uses Legacies_Empire */ -class Legacies_Empire_Model_Game_FieldsAlias - extends Legacies_Empire_Model_Game_Abstract - implements Legacies_Core_Singleton +class Wootook_Core_Helper_Config_Events + extends Wootook_Core_Helper_Config_ConfigHandler + implements Wootook_Core_Singleton { private static $_singleton = null; @@ -21,11 +21,18 @@ class Legacies_Empire_Model_Game_FieldsAlias return self::$_singleton; } + public static function registerEvents() + { + foreach (self::getSingleton() as $event => $listenerList) { + foreach ($listenerList as $listener) { + Wootook::registerListener($event, $listener); + } + } + } + protected function _init() { - foreach (include ROOT_PATH . 'includes/data/fields-alias.php' as $elementId => $fieldName) { - $this->setData($elementId, $fieldName); - } + $this->_initData('events'); return $this; } diff --git a/src/application/code/core/Wootook/Core/Helper/Config/Modules.php b/src/application/code/core/Wootook/Core/Helper/Config/Modules.php new file mode 100644 index 0000000..17d1a46 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Helper/Config/Modules.php @@ -0,0 +1,47 @@ +_initData('modules'); + return $this; + } + + protected function _load() + { + // NOP + return $this; + } + + protected function _save() + { + // NOP + return $this; + } + + protected function _delete() + { + // NOP + return $this; + } +} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Core/Model/Config.php b/src/application/code/core/Wootook/Core/Model/Config.php new file mode 100644 index 0000000..5607ddf --- /dev/null +++ b/src/application/code/core/Wootook/Core/Model/Config.php @@ -0,0 +1,61 @@ +_tableName = 'core_config'; + $this->_idFieldNames = array('config_path', 'website_id', 'game_id'); + } + + public function setWebsiteId($websiteId) + { + return $this->setData('website_id', $websiteId); + } + + public function getWebsiteId() + { + return $this->getData('website_id'); + } + + public function setGameId($gameId) + { + return $this->setData('game_id', $gameId); + } + + public function getGameId() + { + return $this->getData('game_id'); + } + + public function setPath($path) + { + return $this->setData('config_path', $path); + } + + public function getPath() + { + return $this->getData('config_path'); + } + + public function setValue($value) + { + return $this->setData('config_value', $value); + } + + public function getValue() + { + return $this->getData('config_value'); + } +} diff --git a/src/application/code/core/Wootook/Core/Model/Game.php b/src/application/code/core/Wootook/Core/Model/Game.php new file mode 100644 index 0000000..bc4c234 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Model/Game.php @@ -0,0 +1,23 @@ +_tableName = 'core_game'; + $this->_idFieldName = 'game_id'; + } +} diff --git a/scripts/createbanner.php b/src/application/code/core/Wootook/Core/Model/Image/Png.php similarity index 52% rename from scripts/createbanner.php rename to src/application/code/core/Wootook/Core/Model/Image/Png.php index 93ba5e6..0b3f5f9 100644 --- a/scripts/createbanner.php +++ b/src/application/code/core/Wootook/Core/Model/Image/Png.php @@ -1,52 +1,4 @@ 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 XNova. - * - */ - -define('FONT_FILE', dirname(__FILE__) . '/resources/fonts/visitor/visitor.ttf'); -define('BACKGROUND_FILE', dirname(__FILE__) . '/resources/backgrounds/default.png'); -define('TIMEZONE', 'Europe/Paris'); - -date_default_timezone_set(TIMEZONE); - -require_once dirname(dirname(__FILE__)) . '/db/mysql.php'; /** * @@ -54,7 +6,7 @@ require_once dirname(dirname(__FILE__)) . '/db/mysql.php'; * @author Greg * */ -class Legacies_Block_Image_Png +class Wootook_Core_Model_Image_Png { private $_format = NULL; private $_mime = NULL; @@ -239,69 +191,4 @@ class Legacies_Block_Image_Png return $imageData; } -} - -if (isset($_GET['id'])) { - $id = (int) $_GET['id']; -} else { - header('HTTP/1.1 412 Precondition Failed'); - die(); -} - -$textColor = array( - Legacies_Block_Image_Png::COLOR_RED => 0xEF, - Legacies_Block_Image_Png::COLOR_GREEN => 0xEF, - Legacies_Block_Image_Png::COLOR_BLUE => 0xEF - ); - -$sql = << 'XNova:Legacies', - 'date' => date('d M Y') - ), - doquery($sql, '', true) - ); - -function number_format_custom($number) -{ - return number_format($number, 0, ',', '.'); -} - -$image = new Legacies_Block_Image_Png(); -$image - ->setBackground(BACKGROUND_FILE) - ->addText($data['game_name'], 24, FONT_FILE, 5, 37, 0, $textColor) - ->addText($data['username'], 24, FONT_FILE, 250, 37, 0, $textColor) - - ->addText('Batiments:', - 14, FONT_FILE, 5, 50, 0, $textColor) - ->addText(number_format_custom($data['build_points']), 14, FONT_FILE, 100, 50, 0, $textColor) - ->addText('Flottes:', 14, FONT_FILE, 5, 70, 0, $textColor) - ->addText(number_format_custom($data['fleet_points']), 14, FONT_FILE, 100, 70, 0, $textColor) - - ->addText('Technologies:', 14, FONT_FILE, 205, 50, 0, $textColor) - ->addText(number_format_custom($data['tech_points']), 14, FONT_FILE, 320, 50, 0, $textColor) - ->addText('Total:', 14, FONT_FILE, 205, 70, 0, $textColor) - ->addText(number_format_custom($data['total_points']), 14, FONT_FILE, 320, 70, 0, $textColor) -; - -foreach ($image->getHeaders() as $headerName => $headerValue) { - header(sprintf('%s: %s', $headerName, $headerValue)); -} - -echo $image->render(); +} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Core/Model/Layout.php b/src/application/code/core/Wootook/Core/Model/Layout.php new file mode 100644 index 0000000..d15057f --- /dev/null +++ b/src/application/code/core/Wootook/Core/Model/Layout.php @@ -0,0 +1,632 @@ + + * 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 . + * + * --> 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. + * + */ + +/** + * Page layout class utility. + * Builds page structures from flexible layout declaration files, written in a + * user-friendly XML format. + * + * @author Greg + * @since 1.5.0 + * @package Wootook + * @subpackage Wootook_Core + * @category layout + */ +class Wootook_Core_Model_Layout + extends Wootook_Core_Mvc_Model_Model +{ + const DEFAULT_PACKAGE = 'base'; + const DEFAULT_THEME = 'default'; + + const DOMAIN_FRONTEND = 'frontend'; + const DOMAIN_BACKEND = 'backend'; + + /** @var array */ + protected $_blocks = array(); + + /** @var Wootook_Core_Mvc_View_View */ + protected $_messageBlock = null; + + /** @var Wootook_Core_Mvc_View_View */ + protected $_rootView = null; + + /** @var string */ + protected $_eventPrefix = 'layout'; + + /** @var string */ + protected $_eventObject = 'layout'; + + /** @var string */ + protected $_domain = self::DOMAIN_FRONTEND; + + /** @var string */ + protected $_package = self::DEFAULT_PACKAGE; + + /** @var string */ + protected $_theme = self::DEFAULT_THEME; + + /** @var array */ + protected $_namespaces = array( + 'core' => array( + 'Wootook_Core_Block_' => 'Wootook/Core/Block' + ) + ); + + /** + * Page layout class utility. + * + * @param string $domain + * @param string $package + * @param string $theme + * @param array $data + */ + public function __construct($domain = null, $package = null, $theme = null, Array $data = array()) + { + if ($domain === null) { + if (Wootook::getDefaultWebsite()->getId() == 0) { + $this->_domain = self::DOMAIN_BACKEND; + } else { + $this->_domain = self::DOMAIN_FRONTEND; + } + } else { + $this->_domain = $domain; + } + if ($package !== null) { + $this->setPackage($package); + } + if ($theme !== null) { + $this->setTheme($theme); + } + + parent::__construct($data); + } + + public function _init() + { + $modules = Wootook_Core_Helper_Config_Modules::getSingleton(); + + foreach ($modules['block'] as $module => $moduleNamespaces) { + foreach ($moduleNamespaces as $namespace => $path) { + $this->registerBlockNamespace($module, $namespace, $path); + } + } + + $fileList = Wootook::getGameConfig('layout'); + if ($fileList instanceof Wootook_Core_Config_Node) { + $fileList = $fileList->toArray(); + } + if (!is_array($fileList) || empty($fileList)) { + $fileList = array(); + } + $this->_data = array(); + + $this->setPackage(Wootook::getWebsiteConfig('package')); + $this->setTheme(Wootook::getGameConfig('theme')); + + $parser = new Wootook_Core_Model_Layout_Parser(); + foreach ($fileList as $layoutFile) { + try { + if (preg_match('#\.php$#', $layoutFile)) { + $layoutData = include $this->_getLayoutPath($layoutFile); + } else { + $layoutData = $parser->parse($this->_getLayoutPath($layoutFile), $this->_getLayoutCachePath($layoutFile), 3600); + } + } catch (Wootook_Core_Exception_LayoutException $e) { + Wootook_Core_ErrorProfiler::getSingleton()->addException($e); + continue; + } + + if (!is_array($layoutData)) { + continue; + } + + foreach ($layoutData as $layoutId => $layoutConfig) { + if ($this->hasData($layoutId)) { + $declared = $this->getData($layoutId); + + if (isset($declared['block']) && !isset($layoutConfig['block'])) { + $layoutConfig['block'] = $declared['block']; + } + + if (isset($declared['reference'])) { + if (isset($layoutConfig['reference'])) { + $layoutConfig['reference'] = array_merge($declared['reference'], $layoutConfig['reference']); + } else { + $layoutConfig['reference'] = $declared['reference']; + } + } + } + + $this->setData($layoutId, $layoutConfig); + } + } + + $this->_messageBlock = $this->createBlock('core/messages', 'messages'); + + return $this; + } + + protected function _getAllParents(&$layoutConfigs, $currentHandle) + { + foreach ($currentHandle as $parent) { + $currentLayout = $this->getData($parent); + $layoutConfigs[] = $currentLayout; + + if (!isset($currentLayout['update'])) { + continue; + } + $this->_getAllParents($layoutConfigs, $currentLayout['update']); + } + } + + protected function _load() + { + $layoutId = func_get_arg(0); + + if (!$this->hasData($layoutId)) { + return $this; + } + + $layoutConfigs = array($this->getData($layoutId)); + if (isset($layoutConfigs[0]['update'])) { + $this->_getAllParents($layoutConfigs, $layoutConfigs[0]['update']); + } + + $layoutUpdates = array(); + $layoutConfig = array(); + foreach (array_reverse($layoutConfigs) as $config) { + if (!is_array($config)) { + continue; + } + $layoutConfig = array_merge($layoutConfig, $config); + + if (isset($layoutConfig['reference'])) { + foreach ($layoutConfig['reference'] as $name => $update) { + if (!isset($layoutUpdates[$name])) { + $layoutUpdates[$name] = array(); + } + $layoutUpdates[$name][] = $update; + } + unset($layoutConfig['reference']); + } + } + unset($layoutConfigs, $layoutConfig['update']); + + if (isset($layoutConfig['type'])) { + $type = $layoutConfig['type']; + $name = isset($layoutConfig['name']) ? $layoutConfig['name'] : 'root'; + + $this->_rootView = $this->_createBlock($type, $name, $layoutConfig); + } else if (!isset($this->_rootView)) { + return $this; + } + + foreach ($layoutUpdates as $block => $updates) { + if (!isset($this->_blocks[$block])) { + continue; + } + + $parent = $this->_blocks[$block]; + foreach ($updates as $update) { + if (isset($update['children'])) { + foreach ($update['children'] as $childName => $childConfig) { + $type = $childConfig['type']; + $alias = isset($childConfig['alias']) ? $childConfig['alias'] : $childName; + + $parent->$alias = $this->_createBlock($type, $childName, $childConfig); + } + } + } + } + + foreach ($layoutUpdates as $block => $updates) { + if (!isset($this->_blocks[$block])) { + continue; + } + + foreach ($updates as $update) { + if (isset($update['actions'])) { + $this->_callActions($this->_blocks[$block], $update['actions']); + } + } + } + + Wootook::dispatchEvent($this->_eventPrefix . '.prepare.before', array( + $this->_eventObject => $this + )); + + foreach ($this->_blocks as $block) { + $block->prepareLayout(); + } + + Wootook::dispatchEvent($this->_eventPrefix . '.prepare.after', array( + $this->_eventObject => $this + )); + } + + protected function _save() + { + throw new Wootook_Core_Exception_LayoutException('Save not permitted for the layout manager.'); + } + + protected function _delete() + { + throw new Wootook_Core_Exception_LayoutException('Delete not permitted for the layout manager.'); + } + + protected function _resolveBlockClassType($type) + { + $offset = strpos($type, '/'); + if ($offset === false) { + return null; + } + + $module = substr($type, 0, $offset); + $block = substr($type, $offset + 1); + + /* + $module = str_replace(' ', '', ucwords(str_replace('-', ' ', $module))); + $module = str_replace(' ', '_', ucwords(str_replace('.', ' ', $module))); + */ + $block = str_replace(' ', '', ucwords(str_replace('-', ' ', $block))); + $block = str_replace(' ', '_', ucwords(str_replace('.', ' ', $block))); + + if (isset($this->_namespaces[$module])) { + foreach ($this->_namespaces[$module] as $namespace => $path) { + $className = $namespace . $block; + $fileName = $path . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $block) . '.php'; + + Wootook_Core_ErrorProfiler::getSingleton()->sleep(); + if (!($fp = @fopen($fileName, 'r', true))) { + Wootook_Core_ErrorProfiler::getSingleton()->wakeup(); + continue; + } + Wootook_Core_ErrorProfiler::getSingleton()->wakeup(); + fclose($fp); + + if (!class_exists($className, true)) { + continue; + } + + return $className; + } + } + + Wootook_Core_ErrorProfiler::getSingleton() + ->addException(new Wootook_Core_Exception_LayoutException(sprintf('Class type "%s" could not be resolved.', $type))); + return null; + } + + /** + * Register a new block namespage for use in the layout declaration files + * + * @since 1.5.0 + * @param string $module + * @param string $namespace + * @param string|null $path + * @return Wootook_Core_Model_Layout + */ + public function registerBlockNamespace($module, $namespace, $path = null) + { + if ($path === null) { + $path = str_replace('_', DIRECTORY_SEPARATOR, $namespace); + } + if (!isset($this->_namespaces[$module])) { + $this->_namespaces[$module] = array(); + } + $this->_namespaces[$module][$namespace] = $path; + + return $this; + } + + /** + * Unregister a previously declared block namespace + * + * @since 1.5.0 + * @param string $module + * @param string $namespace + * @return Wootook_Core_Model_Layout + */ + public function unregisterBlockNamespace($module, $namespace) + { + if (isset($this->_namespaces[$module]) && isset($this->_namespaces[$module][$namespace])) { + unset($this->_namespaces[$module][$namespace]); + } + + return $this; + } + + /** + * Create a new block instance + * + * @param string $type + * @param string $name + * @param array $config + * @return Wootook_Core_Mvc_View_View + */ + public function createBlock($type, $name, $config = array()) + { + $instance = $this->_createBlock($type, $name, $config); + + if ($instance === null) { + return null; + } + $instance->prepareLayout(); + + return $instance; + } + + protected function _createBlock($type, $name, $config = array()) + { + $className = $this->_resolveBlockClassType($type); + + if ($className === null) { + return null; + } + + $children = array(); + if (isset($config['children'])) { + $children = $config['children']; + unset($config['children']); + } + $actions = array(); + if (isset($config['actions'])) { + $actions = $config['actions']; + unset($config['actions']); + } + + try { + $reflectionClass = new ReflectionClass($className); + + $instance = $reflectionClass->newInstance($config); + $this->_blocks[$name] = $instance; + $instance->setNameInLayout($name); + + $instance->setLayout($this); + + foreach ($children as $name => $config) { + if (isset($config['alias'])) { + $alias = $config['alias']; + } else { + $alias = $name; + } + + if (!isset($config['type'])) { + $instance->$alias = new Wootook_Core_Mvc_View_View($config); + } else { + $child = $this->_createBlock($config['type'], $name, $config); + if ($child !== null) { + $instance->$alias = $child; + } + } + } + } catch (ReflectionException $e) { + Wootook_Core_ErrorProfiler::getSingleton() + ->addException($e); + return null; + } + + $this->_callActions($instance, $actions); + + return $instance; + } + + protected function _callActions($block, $actions) + { + $reflectionClass = new ReflectionClass($block); + + foreach ($actions as $action) { + if (!isset($action['method'])) { + continue; + } + $method = $action['method']; + + $params = array(); + if (isset($action['params'])) { + $params = $action['params']; + } + + try { + $reflectionMethod = $reflectionClass->getMethod($method); + $requiredParameterCount = $reflectionMethod->getNumberOfRequiredParameters(); + $callParamaters = array(); + foreach ($reflectionMethod->getParameters() as $parameter) { + $paramterName = strtolower(preg_replace('#([A-Z])#', '-\\1', $parameter->getName())); + $paramterPosition = $parameter->getPosition(); + + if (isset($params[$paramterName])) { + $callParamaters[$paramterPosition] = $params[$paramterName]; + } else if ($parameter->isDefaultValueAvailable()) { + $callParamaters[$paramterPosition] = $parameter->getDefaultValue(); + //} else if (!$parameter->isOptionnal()) { + } else if ($paramterPosition <= $requiredParameterCount) { + throw new Wootook_Core_Exception_LayoutException(Wootook::__('Method %s requires parameter %d ($%s) to be defined.', + $reflectionMethod->getName(), $paramterPosition + 1, $paramterName)); + } + } + + $reflectionMethod->invokeArgs($block, $callParamaters); + } catch (ReflectionException $e) { + Wootook_Core_ErrorProfiler::getSingleton() + ->addException($e); + continue; + } catch (RuntimeException $e) { + Wootook_Core_ErrorProfiler::getSingleton() + ->addException($e); + continue; + } + } + } + + /** + * Get the current Layout domain (frontend or backend) + * + * @since 1.5.0 + * @return string + */ + public function getDomain() + { + return $this->_domain; + } + + /** + * Set the current Layout domain (frontend or backend) + * + * @since 1.5.0 + * @param string $domain + * @return Wootook_Core_Model_Layout + */ + public function setDomain($domain) + { + $this->_domain = $domain; + $this->_init(); + + return $this; + } + + public function getPackage() + { + if ($this->_package === null) { + $this->_package = self::DEFAULT_PACKAGE; + } + return $this->_package; + } + + public function setPackage($package) + { + $this->_package = $package; + + return $this; + } + + public function getTheme() + { + if ($this->_theme === null) { + $this->_theme = self::DEFAULT_THEME; + } + return $this->_theme; + } + + public function setTheme($theme) + { + $this->_theme = $theme; + + return $this; + } + + public function getScriptPath() + { + return Wootook::getBasePath('design') . DIRECTORY_SEPARATOR . $this->getDomain(); + } + + public function getAllBlocks() + { + return $this->_blocks; + } + + public function getBlock($code) + { + if (isset($this->_blocks[$code])) { + return $this->_blocks[$code]; + } + return null; + } + + public function render() + { + if (!$this->_rootView instanceof Wootook_Core_Mvc_View_View) { + throw new Wootook_Core_Exception_LayoutException(Wootook::__('No root view declared.')); + } + + $scriptPath = $this->getScriptPath(); + foreach ($this->_blocks as $block) { + if ($block instanceof Wootook_Core_Block_Template) { + $block->setScriptPath($scriptPath); + } + $block->beforeToHtml(); + } + unset($block); + + return $this->_rootView->render(); + } + + protected function _getLayoutCachePath($file) + { + $package = $this->getPackage(); + $theme = $this->getTheme(); + $pattern = APPLICATION_PATH . "cache/" . __CLASS__ . "--{$this->getDomain()}-%s-%s-{$file}.cache"; + + if (empty($package)) { + $package = self::DEFAULT_PACKAGE; + } + if (empty($theme)) { + $theme = self::DEFAULT_THEME; + } + + return sprintf($pattern, $package, $theme); + } + + protected function _getLayoutPath($file) + { + $package = $this->getPackage(); + $theme = $this->getTheme(); + $pattern = "{$this->getScriptPath()}/%s/%s/layouts/{$file}"; + + if ($package !== null && $theme !== null) { + $path = sprintf($pattern, $package, $theme); + if (Wootook::fileExists($path)) { + return $path; + } + } + + if ($package !== null) { + $path = sprintf($pattern, $package, self::DEFAULT_THEME); + if (Wootook::fileExists($path)) { + return $path; + } + } + + $path = sprintf($pattern, self::DEFAULT_PACKAGE, self::DEFAULT_THEME); + if (Wootook::fileExists($path)) { + return $path; + } + + throw new Wootook_Core_Exception_LayoutException(sprintf("Layout file '%s' does not exist.", $file)); + } + + /** + * + * @return Wootook_Core_Block_Messages + */ + public function getMessagesBlock() + { + return $this->_messageBlock; + } +} diff --git a/src/application/code/core/Wootook/Core/Model/Layout/Parser.php b/src/application/code/core/Wootook/Core/Model/Layout/Parser.php new file mode 100644 index 0000000..1e07ae8 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Model/Layout/Parser.php @@ -0,0 +1,165 @@ + 0 && (time() - filemtime($cachePath) <= $cacheLifetime)) { + return include $cachePath; + } + + $parsedData = $this->_parse($filename); + + if ($cachePath !== null) { + $parsedData->save($cachePath); + } + + return $parsedData->toArray(); + } + + protected function _parse($filename) + { + $layout = simplexml_load_file($filename); + + if ($layout->getName() !== 'layout') { + return array(); + } + + $result = new Wootook_Core_Config_Adapter_Array(); + foreach ($layout->handle as $handle) { + $name = (string) $handle['name']; + if (empty($name)) { + continue; + } + + $handleNode = new Wootook_Core_Config_Node(array(), $result); + $result->$name = $handleNode; + + if (isset($handle->update)) { + $updateListNode = new Wootook_Core_Config_Node(array(), $handleNode); + $handleNode->update = $updateListNode; + + foreach ($handle->update as $update) { + if (isset($update['name'])) { + $updateListNode->__set(uniqid(), (string) $update['name']); + } + } + } + + if (isset($handle->block)) { + $this->_parseBlock($handle->block[0], $handleNode); + } + + if (isset($handle->reference)) { + $referenceListNode = new Wootook_Core_Config_Node(array(), $handleNode); + $handleNode->reference = $referenceListNode; + + foreach ($handle->reference as $reference) { + $referenceName = (string) $reference['name']; + if (empty($referenceName)) { + continue; + } + + $referenceNode = new Wootook_Core_Config_Node(array(), $referenceListNode); + $referenceListNode->$referenceName = $referenceNode; + + $this->_parseBlockBody($reference, $referenceNode); + } + } + } + + return $result; + } + + protected function _parseBlock(SimpleXMLElement $handle, Wootook_Core_Config_Node $blockNode) + { + foreach ($handle->attributes() as $attributeName => $attributeValue) { + $blockNode->$attributeName = (string) $attributeValue; + } + + $this->_parseBlockBody($handle, $blockNode); + } + + protected function _parseBlockBody(SimpleXMLElement $handle, Wootook_Core_Config_Node $blockNode) + { + if (isset($handle->block)) { + $childrenNode = new Wootook_Core_Config_Node(array(), $blockNode); + $blockNode->children = $childrenNode; + + foreach ($handle->block as $block) { + $blockName = (string) $block['name']; + if (empty($blockName)) { + continue; + } + + $childNode = new Wootook_Core_Config_Node(array(), $childrenNode); + $childrenNode->$blockName = $childNode; + + $this->_parseBlock($block, $childNode); + } + } + + if (isset($handle->action)) { + $actionListNode = new Wootook_Core_Config_Node(array(), $blockNode); + $blockNode->actions = $actionListNode; + + foreach ($handle->action as $action) { + $methodName = (string) $action['method']; + if (empty($methodName)) { + continue; + } + + $actionNode = new Wootook_Core_Config_Node(array( + 'method' => $methodName, + 'params' => array() + ), $actionListNode); + + $actionListNode[] = $actionNode; + + if (isset($action->param)) { + $paramsNode = $actionNode->params; + + foreach ($action->param as $param) { + $paramName = (string) $param['name']; + if (empty($paramName)) { + continue; + } + + if (count($param)) { + if (isset($param->const) && isset($param->const['name']) && defined((string) $param->const['name'])) { + $paramsNode->$paramName = constant((string) $param->const['name']); + } else { + $paramArrayNode = new Wootook_Core_Config_Node(array(), $paramsNode); + $paramsNode->$paramName = $paramArrayNode; + + $this->_parseArrayParam($param, $paramArrayNode); + } + } else { + $paramsNode->$paramName = (string) $param; + } + } + } + } + } + } + + protected function _parseArrayParam(SimpleXMLElement $element, Wootook_Core_Config_Node $parentNode) + { + foreach ($element->children() as $child) { + if (count($child)) { + $childNode = new Wootook_Core_Config_Node(array(), $parentNode); + $parentNode->{$child->getName()} = $childNode; + + $this->_parseArrayParam($child, $childNode); + continue; + } + + $parentNode->{$child->getName()} = (string) $child; + } + } +} diff --git a/src/application/code/core/Wootook/Core/Model/Session.php b/src/application/code/core/Wootook/Core/Model/Session.php new file mode 100644 index 0000000..2306f03 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Model/Session.php @@ -0,0 +1,226 @@ + 'CRIT', + self::ERR => 'ERR', + self::WARN => 'WARN', + self::INFO => 'INFO', + self::DEBUG => 'DEBUG', + self::SUCCESS => 'SUCCESS' + ); + + protected $_messages = array(); + + const COOKIE_LIFETIME_CONFIG_KEY = 'web/session/time'; + const COOKIE_DOMAIN_CONFIG_KEY = 'web/session/domain'; + const COOKIE_PATH_CONFIG_KEY = 'web/session/path'; + + const IDENTIFIER_MESSAGES = 'messages'; + const IDENTIFIER_DATA = 'data'; + + public static function factory($namespace) + { + $namespace = (string) $namespace; + if (!isset(self::$_instances[$namespace])) { + self::$_instances[$namespace] = new self($namespace); + } + return self::$_instances[$namespace]; + } + + public static function destroy() + { + session_destroy(); + } + + public function __construct($namespace) + { + if (session_id() == '') { + session_set_cookie_params($this->getCookieLifetime(), $this->getCookiePath(), $this->getCookieDomain(), false, true); + + session_cache_limiter('private_no_expire'); + session_cache_expire(15); + + session_start(); + session_regenerate_id(true); + } + + if (!isset($_SESSION[$namespace])) { + $_SESSION[$namespace] = array( + self::IDENTIFIER_MESSAGES => array(), + self::IDENTIFIER_DATA => array() + ); + } + + if (!isset($_SESSION[$namespace][self::IDENTIFIER_MESSAGES]) || !is_array($_SESSION[$namespace][self::IDENTIFIER_MESSAGES])) { + $_SESSION[$namespace][self::IDENTIFIER_MESSAGES] = array(); + } + + $this->_data = &$_SESSION[$namespace][self::IDENTIFIER_DATA]; + $this->_messages = &$_SESSION[$namespace][self::IDENTIFIER_MESSAGES]; + } + + public function getCookieLifetime() + { + $lifetime = Wootook::getWebsiteConfig(self::COOKIE_LIFETIME_CONFIG_KEY); + if (!is_numeric($lifetime) || $lifetime <= 0) { + return 900; + } + + return $lifetime; + } + + public function getCookieDomain() + { + $domain = Wootook::getWebsiteConfig(self::COOKIE_DOMAIN_CONFIG_KEY); + if ($domain === null) { + return $_SERVER['SERVER_NAME']; + } + return $domain; + } + + public function getCookiePath() + { + $path = Wootook::getWebsiteConfig(self::COOKIE_PATH_CONFIG_KEY); + if ($path === null) { + return '/'; + } + return $path; + } + + public function getMessages($clear = true) + { + $messages = $this->_messages; + if ($clear == true) { + $this->_messages = array(); + } + return $messages; + } + + public function addMessage($message, $type = self::DEBUG) + { + if (!isset(self::$_levels[$type])) { + $type = self::DEBUG; + } + + if (!isset($this->_messages)) { + $this->_messages = array(); + } + if (!isset($this->_messages[self::$_levels[$type]])) { + $this->_messages[self::$_levels[$type]] = array(); + } + $this->_messages[self::$_levels[$type]][] = $message; + + return $this; + } + + public function addCritical($message, $_ = null) + { + $args = func_get_args(); + array_shift($args); + + return $this->addMessage(vsprintf($message, $args), self::CRIT); + } + + public function addError($message, $_ = null) + { + $args = func_get_args(); + array_shift($args); + + return $this->addMessage(vsprintf($message, $args), self::ERR); + } + + public function addWarning($message, $_ = null) + { + $args = func_get_args(); + array_shift($args); + + return $this->addMessage(vsprintf($message, $args), self::WARN); + } + + public function addSuccess($message, $_ = null) + { + $args = func_get_args(); + array_shift($args); + + return $this->addMessage(vsprintf($message, $args), self::SUCCESS); + } + + public function addInfo($message, $_ = null) + { + $args = func_get_args(); + array_shift($args); + + return $this->addMessage(vsprintf($message, $args), self::INFO); + } + + public function addDebug($message, $_ = null) + { + $args = func_get_args(); + array_shift($args); + + return $this->addMessage(vsprintf($message, $args), self::DEBUG); + } + + public function initFormKey() + { + $key = $this->getData('form_key'); + $this->setData('form_key', uniqid()); + + return $key; + } + + public function getFormKey($reset = true) + { + if (!$this->getData('form_key')) { + $this->initFormKey(); + return $this->getData('form_key'); + } + + if ($reset === true) { + $this->initFormKey(); + } + + return $this->getData('form_key'); + } + + public function setFormData(Array $data = array()) + { + if (isset($data['__formkey'])) { + unset($data['__formkey']); + } + + $this->setData('form_data', $data); + + return $this; + } + + public function getFormData($key = null, $default = null) + { + $data = $this->getData('form_data'); + if ($key === null) { + return $data; + } else if (isset($data[$key])) { + return $data[$key]; + } + return $default; + } +} diff --git a/includes/application/code/core/Legacies/Core/Model/Translator.php b/src/application/code/core/Wootook/Core/Model/Translator.php similarity index 96% rename from includes/application/code/core/Legacies/Core/Model/Translator.php rename to src/application/code/core/Wootook/Core/Model/Translator.php index bcbb892..6d81883 100644 --- a/includes/application/code/core/Legacies/Core/Model/Translator.php +++ b/src/application/code/core/Wootook/Core/Model/Translator.php @@ -1,6 +1,6 @@ _tableName = 'core_website'; + $this->_idFieldName = 'website_id'; + } +} diff --git a/src/application/code/core/Wootook/Core/Mvc/Controller/Action.php b/src/application/code/core/Wootook/Core/Mvc/Controller/Action.php new file mode 100644 index 0000000..e6230ba --- /dev/null +++ b/src/application/code/core/Wootook/Core/Mvc/Controller/Action.php @@ -0,0 +1,164 @@ +setRequest($request); + $this->setResponse($response); + } + + public function init() + { + } + + public function preDispatch() + { + } + + public function postDispatch() + { + } + + public function setRequest(Wootook_Core_Mvc_Controller_Request_Http $request) + { + $this->_request = $request; + + return $this; + } + + public function setResponse(Wootook_Core_Mvc_Controller_Response_Http $response) + { + $this->_response = $response; + + return $this; + } + + /** + * + * @return Wootook_Core_Mvc_Controller_Request_Http + */ + public function getRequest() + { + return $this->_request; + } + + /** + * + * @return Wootook_Core_Mvc_Controller_Response_Http + */ + public function getResponse() + { + return $this->_response; + } + + protected function _forward($action, $controller = null, $module = null) + { + $request = $this->getRequest(); + + $request->setActionName($action); + if ($controller !== null) { + $request->setControllerName($controller); + if ($module != null) { + $request->setModuleName($module); + } + } + $this->getResponse()->setIsDispatched(false); + } + + protected function _redirect($uri, Array $params = array(), $code = Wootook_Core_Mvc_Controller_Response_Http::REDIRECT_FOUND) + { + $parts = explode('/', $uri); + $partsCount = count($parts); + if ($partsCount > 0 && $parts[0] == '*') { + $parts[0] = $this->getRequest()->getModuleName(); + if ($partsCount > 1 && $parts[1] == '*') { + $parts[1] = $this->getRequest()->getControllerName(); + if ($partsCount > 2 && $parts[2] == '*') { + $parts[2] = $this->getRequest()->getActionName(); + } + } + } + $uri = implode('/', array_slice($parts, 0, 3)); + + $this->getResponse() + ->setRedirect(Wootook::getUrl($uri, $params), $code); + + Wootook_Core_ErrorProfiler::unregister(true); + + return $this; + } + + protected function _redirectUrl($url, $code = Wootook_Core_Mvc_Controller_Response_Http::REDIRECT_FOUND) + { + $this->getResponse()->setRedirect($url, $code); + + return $this; + } + + protected function _buildLayoutHandle() + { + $request = $this->getRequest(); + + $module = $request->getModuleName(); + $controller = $request->getControllerName(); + $action = $request->getActionName(); + + return "{$module}.{$controller}.{$action}"; + } + + public function loadLayout($handle = null) + { + if ($this->_layout === null) { + $this->_layout = $this->_initLayout(); + } + + if ($handle === null) { + $handle = $this->_buildLayoutHandle(); + } + $this->_layout->load($handle); + + return $this; + } + + protected function _initLayout() + { + return new Wootook_Core_Model_Layout(Wootook_Core_Model_Layout::DOMAIN_FRONTEND); + } + + /** + * + * @return Wootook_Core_Model_Layout + */ + public function getLayout() + { + return $this->_layout; + } + + public function renderLayout() + { + try { + $content = $this->getLayout()->render(); + } catch (Wootook_Core_Exception_LayoutException $e) { + Wootook_Core_ErrorProfiler::getSingleton()->addException($e); + return $this; + } + $this->getResponse()->setBody($content); + + return $this; + } + + protected function _prepareLayoutMessages($namespace) + { + $this->getLayout() + ->getMessagesBlock() + ->prepareMessages($namespace); + + return $this; + } +} diff --git a/src/application/code/core/Wootook/Core/Mvc/Controller/Front.php b/src/application/code/core/Wootook/Core/Mvc/Controller/Front.php new file mode 100644 index 0000000..6c6b20f --- /dev/null +++ b/src/application/code/core/Wootook/Core/Mvc/Controller/Front.php @@ -0,0 +1,271 @@ + array( + 'modules' => array( + 'core' => array( + 'class' => 'Wootook_Core_Controller_', + 'path' => 'Wootook/Core/Controller' + ) + ), + 'defaults' => array( + 'module' => 'core', + 'controller' => 'error', + 'action' => 'no-route' + ) + ), + self::ROUTE_DEFAULT => array( + 'modules' => array( + ), + 'defaults' => array( + 'module' => 'core', + 'controller' => 'index', + 'action' => 'index' + ) + ) + ); + + protected $_request = null; + protected $_response = null; + + public function __construct(Wootook_Core_Mvc_Controller_Request_Request $request, + Wootook_Core_Mvc_Controller_Response_Response $response) + { + $this->_request = $request; + $this->_response = $response; + } + + protected function _setNoRouteAction(&$route, &$moduleKey, &$controllerKey, &$actionKey) + { + $route = self::ROUTE_ERROR; + $moduleKey = $this->_routes[self::ROUTE_ERROR]['defaults']['module']; + $controllerKey = $this->_routes[self::ROUTE_ERROR]['defaults']['controller']; + $actionKey = $this->_routes[self::ROUTE_ERROR]['defaults']['action']; + + return $this; + } + + protected function _setDefaultRouteAction(&$route, &$moduleKey, &$controllerKey, &$actionKey) + { + $route = self::ROUTE_DEFAULT; + $moduleKey = $this->_routes[self::ROUTE_DEFAULT]['defaults']['module']; + $controllerKey = $this->_routes[self::ROUTE_DEFAULT]['defaults']['controller']; + $actionKey = $this->_routes[self::ROUTE_DEFAULT]['defaults']['action']; + + return $this; + } + + protected function _camelizeClass($string) + { + $string = strtolower($string); + $string = str_replace(' ', '_', ucwords(str_replace('.', ' ', $string))); + return str_replace(' ', '', ucwords(str_replace('-', ' ', $string))); + } + + protected function _camelizePath($string) + { + $string = strtolower($string); + $string = str_replace(' ', DIRECTORY_SEPARATOR, ucwords(str_replace('.', ' ', $string))); + return str_replace(' ', '', ucwords(str_replace('-', ' ', $string))); + } + + protected function _camelizeMethod($string) + { + return lcfirst(str_replace(' ', '', ucwords(str_replace('-', ' ', $string)))); + } + + protected function _getControllerClass($route, $module, $controllerKey) + { + if (!isset($this->_routes[$route])) { + return null; + } + if (!isset($this->_routes[$route]['modules'][$module])) { + return null; + } + $modulePrefix = $this->_routes[$route]['modules'][$module]['class']; + return $modulePrefix . $this->_camelizeClass($controllerKey) . 'Controller'; + } + + protected function _getControllerFilename($route, $module, $controllerKey) + { + if (!isset($this->_routes[$route])) { + return null; + } + if (!isset($this->_routes[$route]['modules'][$module])) { + return null; + } + $modulePath = $this->_routes[$route]['modules'][$module]['path']; + + return $modulePath . DIRECTORY_SEPARATOR . $this->_camelizePath($controllerKey) . 'Controller.php'; + } + + protected function _getActionMethod($actionKey) + { + return $this->_camelizeMethod($actionKey) . 'Action'; + } + + protected function _forward($action, $controller = null, $module = null) + { + $this->_request->setActionName($action); + if ($controller !== null) { + $this->_request->setControllerName($controller); + if ($module != null) { + $this->_request->setModuleName($module); + } + } + $this->_response->setIsDispatched(false); + } + + public function dispatch($route = null) + { + if ($route == null) { + $route = self::ROUTE_DEFAULT; + } + + if (!isset($this->_routes[$route])) { + $route = self::ROUTE_DEFAULT; + } + + $loop = 0; + while ($loop++ < 100) { + $moduleKey = $this->_request->getModuleName(); + if (empty($moduleKey)) { + $this->_forward( + $this->_routes[$route]['defaults']['action'], + $this->_routes[$route]['defaults']['controller'], + $this->_routes[$route]['defaults']['module'] + ); + continue; + } + + if (!isset($this->_routes[$route]['modules'][$moduleKey])) { + $this->_forward( + $this->_routes[self::ROUTE_ERROR]['defaults']['action'], + $this->_routes[self::ROUTE_ERROR]['defaults']['controller'], + $this->_routes[self::ROUTE_ERROR]['defaults']['module'] + ); + $route = self::ROUTE_ERROR; + continue; + } + + $controllerKey = $this->_request->getControllerName(); + if (empty($controllerKey)) { + $controllerKey = $this->_routes[$route]['defaults']['controller']; + } + + $controllerClass = $this->_getControllerClass($route, $moduleKey, $controllerKey); + $controllerPath = $this->_getControllerFilename($route, $moduleKey, $controllerKey); + + if (!class_exists($controllerClass, false) && Wootook::fileExists($controllerPath)) { + include_once $controllerPath; + } + + if (!class_exists($controllerClass, false)) { + $this->_forward( + $this->_routes[self::ROUTE_ERROR]['defaults']['action'], + $this->_routes[self::ROUTE_ERROR]['defaults']['controller'], + $this->_routes[self::ROUTE_ERROR]['defaults']['module'] + ); + $route = self::ROUTE_ERROR; + continue; + } + + $actionKey = $this->_request->getActionName(); + if (empty($actionKey)) { + $actionKey = $this->_routes[$route]['defaults']['action']; + } + + $actionMethod = $this->_getActionMethod($actionKey); + if (!method_exists($controllerClass, $actionMethod)) { + $this->_forward( + $this->_routes[self::ROUTE_ERROR]['defaults']['action'], + $this->_routes[self::ROUTE_ERROR]['defaults']['controller'], + $this->_routes[self::ROUTE_ERROR]['defaults']['module'] + ); + $route = self::ROUTE_ERROR; + continue; + } + + $controller = new $controllerClass($this->_request, $this->_response); + $controller->init(); + + $this->_response->setIsDispatched(); + + $this->preDispatch(); + $controller->preDispatch(); + if (!$this->_response->isDispatched()) { + continue; + } + if ($this->_response->isRedirect()) { + break; + } + + $controller->$actionMethod(); + + if (!$this->_response->isDispatched()) { + continue; + } + + $controller->postDispatch(); + $this->postDispatch(); + + if ($this->_response->isDispatched() || $this->_response->isRedirect()) { + break; + } + } + + return $this; + } + + public function send() + { + $this->_response->render(); + } + + public function addModule($frontName, $namespace, $path) + { + $this->_routes[self::ROUTE_DEFAULT]['modules'][$frontName] = array( + 'class' => $namespace, + 'path' => $path + ); + + return $this; + } + + public function setDefaults($module, $controller, $action) + { + $this->_routes[self::ROUTE_DEFAULT]['defaults'] = array( + 'module' => $module, + 'controller' => $controller, + 'action' => $action + ); + + return $this; + } + + public function preDispatch() + { + Wootook::dispatchEvent('core.mvc.controller.front.pre-dispatch', array( + 'request' => $this->_request, + 'response' => $this->_response + )); + + return $this; + } + + public function postDispatch() + { + Wootook::dispatchEvent('core.mvc.controller.front.post-dispatch', array( + 'request' => $this->_request, + 'response' => $this->_response + )); + + return $this; + } +} diff --git a/src/application/code/core/Wootook/Core/Mvc/Controller/Request/Http.php b/src/application/code/core/Wootook/Core/Mvc/Controller/Request/Http.php new file mode 100644 index 0000000..3780a37 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Mvc/Controller/Request/Http.php @@ -0,0 +1,374 @@ +_baseUrl = Wootook::getBaseUrl('link'); + if ($this->_baseUrl === null) { + $this->_baseUrl = 'http://' . $this->getServer('HTTP_HOST') . $this->getServer('REQUEST_URI'); + } + $offset = strpos($this->_baseUrl, '/', 8); + if ($offset !== false) { + $baseUri = substr($this->_baseUrl, $offset); // Get the path from the DocumentRoot + } else { + $baseUri = '/'; + } + + $params = ''; + if (($offset = strpos($this->getServer('REQUEST_URI'), $baseUri)) !== false) { + $queryParamsOffset = strpos($this->getServer('REQUEST_URI'), '?'); + if ($queryParamsOffset !== false) { + $path = substr($this->getServer('REQUEST_URI'), $offset + strlen($baseUri), $queryParamsOffset - $offset - 1); + } else { + $path = substr($this->getServer('REQUEST_URI'), $offset + strlen($baseUri)); + } + + $moduleOffset = strpos($path, '/'); + if ($moduleOffset !== false) { + $this->setModuleName(substr($path, 0, $moduleOffset)); + + $controllerOffset = strpos($path, '/', $moduleOffset + 1); + if ($controllerOffset !== false) { + $this->setControllerName(substr($path, $moduleOffset + 1, $controllerOffset - $moduleOffset - 1)); + + $actionOffset = strpos($path, '/', $controllerOffset + 1); + if ($actionOffset !== false) { + $this->setActionName(substr($path, $controllerOffset + 1, $actionOffset - $controllerOffset - 1)); + + $params = substr($path, $actionOffset); + } else if ($controllerOffset !== false) { + $this->setActionName(substr($path, $controllerOffset + 1)); + } + } else if ($moduleOffset !== false) { + $this->setControllerName(substr($path, $moduleOffset + 1)); + } + } else { + $this->setModuleName($path); + } + } + + if (!empty($params)) { + $paramOffset = 0; + $valueOffset = 0; + while (true) { + $paramOffset = strpos($params, '/', $valueOffset + 1); + if ($paramOffset === false) { + break; + } + $paramKey = substr($params, $valueOffset + 1, $paramOffset - $valueOffset - 1); + + $valueOffset = strpos($params, '/', $paramOffset + 1); + if ($valueOffset === false) { + $this->setParam($paramKey, substr($params, $paramOffset + 1)); + break; + } + $this->setParam($paramKey, substr($params, $paramOffset + 1, $valueOffset - $paramOffset - 1)); + } + } + } + + public function init() + { + $this->_queryVars = $_GET; + $this->_postVars = $_POST; + $this->_cookieVars = $_COOKIE; + $this->_serverVars = $_SERVER; + $this->_postFiles = $_FILES; + + $this->clearData(); + + $this->addData($this->_serverVars); + $this->addData($this->_cookieVars); + $this->addData($this->_queryVars); + $this->addData($this->_postVars); + } + + public function setParam($key, $value) + { + return $this->setData($key, $value); + } + + public function getParam($key, $default = null) + { + if ($this->hasData($key)) { + return $this->getData($key); + } + if ($this->hasPost($key)) { + return $this->getPost($key); + } + if ($this->hasQuery($key)) { + return $this->getQuery($key); + } + if ($this->hasCookie($key)) { + return $this->getCookie($key); + } + + return $this->getServer($key, $default); + } + + public function getQuery($key, $default = null) + { + if (!isset($this->_queryVars[$key])) { + return $default; + } + return $this->_queryVars[$key]; + } + + public function getAllQueryData() + { + return $this->_queryVars; + } + + public function hasQuery($key) + { + return isset($this->_queryVars[$key]); + } + + public function setQuery($key, $value) + { + $this->_queryVars[$key] = (string) $value; + + return $this; + } + + public function unsetQuery($key) + { + unset($this->_queryVars[$key]); + + return $this; + } + + public function getPost($key, $default = null) + { + if (!isset($this->_postVars[$key])) { + return $default; + } + return $this->_postVars[$key]; + } + + public function getAllPostData() + { + return $this->_postVars; + } + + public function hasPost($key) + { + return isset($this->_postVars[$key]); + } + + public function setPost($key, $value) + { + $this->_postVars[$key] = (string) $value; + + return $this; + } + + public function unsetPost($key) + { + unset($this->_postVars[$key]); + + return $this; + } + + public function getCookie($key, $default = null) + { + if (!isset($this->_cookieVars[$key])) { + return $default; + } + return unserialize(stripslashes($this->_cookieVars[$key])); + } + + public function getRawCookie($key, $default = null) + { + if (!isset($this->_cookieVars[$key])) { + return $default; + } + return $this->_cookieVars[$key]; + } + + public function getAllCookieData() + { + $data = array(); + foreach ($this->_cookieVars as $key => $value) { + $data[$key] = unserialize(stripslashes($value)); + } + return $data; + } + + public function getAllRawCookieData() + { + return $this->_cookieVars; + } + + public function hasCookie($key) + { + return isset($this->_cookieVars[$key]); + } + + public function setCookie($key, $value) + { + $this->_cookieVars[$key] = addslashes(serialize((string) $value)); + + return $this; + } + + public function setRawCookie($key, $value) + { + $this->_cookieVars[$key] = (string) $value; + + return $this; + } + + public function unsetCookie($key) + { + unset($this->_cookieVars[$key]); + + return $this; + } + + public function getServer($key, $default = null) + { + if (!isset($this->_serverVars[$key])) { + return $default; + } + return $this->_serverVars[$key]; + } + + public function getAllServerData() + { + return $this->_serverVars; + } + + public function getFile($key, $default = null) + { + if (!isset($this->_postFiles[$key])) { + return $default; + } + return $this->_postFiles[$key]; + } + + public function getAllFilesData() + { + return $this->_postFiles; + } + + public function isPost() + { + if (strtoupper($this->getServer('REQUEST_METHOD')) == 'POST') { + return true; + } + return false; + } + + public function isPut() + { + if (strtoupper($this->getServer('REQUEST_METHOD')) == 'PUT') { + return true; + } + return false; + } + + public function isHead() + { + if (strtoupper($this->getServer('REQUEST_METHOD')) == 'HEAD') { + return true; + } + return false; + } + + public function isGet() + { + if (strtoupper($this->getServer('REQUEST_METHOD')) == 'GET') { + return true; + } + return false; + } + + public function getModuleKey() + { + return $this->_moduleKey; + } + + public function setModuleKey($key) + { + $this->_moduleKey = $key; + + return $this; + } + + public function getModuleName() + { + return $this->getParam($this->getModuleKey()); + } + + public function setModuleName($name) + { + if ($name === null || is_string($name)) { + return $this->setParam($this->getModuleKey(), $name); + } + } + + public function getControllerKey() + { + return $this->_controllerKey; + } + + public function setControllerKey($key) + { + $this->_controllerKey = $key; + + return $this; + } + + public function getControllerName() + { + return $this->getParam($this->getControllerKey()); + } + + public function setControllerName($name) + { + if ($name === null || is_string($name)) { + return $this->setParam($this->getControllerKey(), $name); + } + } + + public function getActionKey() + { + return $this->_actionKey; + } + + public function setActionKey($key) + { + $this->_actionKey = $key; + + return $this; + } + + public function getActionName() + { + return $this->getParam($this->getActionKey()); + } + + public function setActionName($name) + { + if ($name === null || is_string($name)) { + return $this->setParam($this->getActionKey(), $name); + } + } +} diff --git a/src/application/code/core/Wootook/Core/Mvc/Controller/Request/Request.php b/src/application/code/core/Wootook/Core/Mvc/Controller/Request/Request.php new file mode 100644 index 0000000..3a77073 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Mvc/Controller/Request/Request.php @@ -0,0 +1,35 @@ +init(); + + parent::__construct($data); + } + + public function setParam($key, $value) + { + return $this->setData($key, $value); + } + + public function getParam($key, $default = null) + { + if ($this->hasData($key)) { + return $this->getData($key); + } + return $default; + } + + abstract public function init(); + + abstract public function getModuleName(); + abstract public function getControllerName(); + abstract public function getActionName(); + + abstract public function setModuleName($name); + abstract public function setControllerName($name); + abstract public function setActionName($name); +} diff --git a/includes/application/code/core/Legacies/Core/Controller/Response/Http.php b/src/application/code/core/Wootook/Core/Mvc/Controller/Response/Http.php similarity index 59% rename from includes/application/code/core/Legacies/Core/Controller/Response/Http.php rename to src/application/code/core/Wootook/Core/Mvc/Controller/Response/Http.php index 6d289ad..3025249 100644 --- a/includes/application/code/core/Legacies/Core/Controller/Response/Http.php +++ b/src/application/code/core/Wootook/Core/Mvc/Controller/Response/Http.php @@ -1,12 +1,23 @@ 'Moved Permanently', + self::REDIRECT_FOUND => 'Found', + self::REDIRECT_SEE_OTHER => 'See Other', + self::REDIRECT_TEMPORARY => 'Temporary Redirect' + ); + + protected $_returnCode = self::STATUS_OK; public function setBody($data) { @@ -34,6 +45,9 @@ class Legacies_Core_Controller_Response_Http public function sendBody() { + if (!isset($this->_data['body']) || empty($this->_data['body'])) { + return ''; + } return implode('', $this->_data['body']); } @@ -69,7 +83,7 @@ class Legacies_Core_Controller_Response_Http return $this; } - public function setRawHeader($name, $value) + public function setRawHeader($value) { if (!isset($this->_data['raw_headers']) || !is_array($this->_data['raw_headers'])) { $this->clearRawHeaders(); @@ -96,22 +110,9 @@ class Legacies_Core_Controller_Response_Http return $this; } - public function setIsRedirect($value = null) + public function isRedirect() { - if (is_bool($value)) { - $this->_data['is_redirect'] = $value; - } - return $this->_data['is_redirect']; - } - - public function setIsDispatched($dispatched = true) - { - return $this->setData('id_dispatched', $dispatched); - } - - public function getIsDispatched() - { - return $this->getData('id_dispatched'); + return $this->_returnCode >= 300 && $this->_returnCode < 400; } public function setCookie($name, $value, $lifetime = null, $path = null, $domain = null) @@ -126,7 +127,35 @@ class Legacies_Core_Controller_Response_Http public function setRawCookie($name, $value, $lifetime = null, $path = null, $domain = null) { - setcookie($name, $value, time() + $lifetime, $path, $domain); + $date = new Wootook_Core_DateTime(); + $date->add($lifetime); + + setcookie($name, $value, $date->getTimestamp(), $path, $domain); return $this; } -} \ No newline at end of file + + public function setRedirect($url, $code = self::REDIRECT_FOUND) + { + if (!in_array($code, self::$_redirectCodes)) { + $code = self::REDIRECT_FOUND; + } + + $this->_returnCode = $code; + + $statusText = self::$_redirectCodes[$code]; + $this->setRawHeader("HTTP/1.1 {$code} {$statusText}") + ->setHeader('Location', $url); + + return $this; + } + + public function render($send = true) + { + if ($send) { + $this->sendHeaders(); + echo $this->sendBody(); + } else { + return $this->sendBody(); + } + } +} diff --git a/src/application/code/core/Wootook/Core/Mvc/Controller/Response/Response.php b/src/application/code/core/Wootook/Core/Mvc/Controller/Response/Response.php new file mode 100644 index 0000000..a36048a --- /dev/null +++ b/src/application/code/core/Wootook/Core/Mvc/Controller/Response/Response.php @@ -0,0 +1,21 @@ +_isDispatched = $dispatched; + + return $this; + } + + public function isDispatched() + { + return $this->_isDispatched; + } + + abstract public function render($send = true); +} diff --git a/src/application/code/core/Wootook/Core/Mvc/Model/Entity.php b/src/application/code/core/Wootook/Core/Mvc/Model/Entity.php new file mode 100644 index 0000000..2c19005 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Mvc/Model/Entity.php @@ -0,0 +1,142 @@ +_idFieldName = $fieldName; + + return $this; + } + + public function getIdFieldName() + { + return $this->_idFieldName; + } + + public function setId($id) + { + $this->setData($this->getIdFieldName(), $id); + + return $this; + } + + public function getId() + { + return $this->getData($this->getIdFieldName()); + } + + protected function _load() + { + $id = func_get_arg(0); + + if (func_num_args() >= 2) { + $idFieldName = func_get_arg(1); + } else { + $idFieldName = $this->getIdFieldName(); + } + + $database = $this->getReadConnection(); + if ($database === null) { + throw new Wootook_Core_Exception_DataAccessException('Could not load data: no read connection configured.'); + } + + $select = $database->select() + ->from(array('main_table' => $database->getTable($this->getTableName()))) + ->where($idFieldName, new Wootook_Core_Database_Sql_Placeholder_Param('id', $id)) + ->limit(1); + + $statement = $select->prepare(); + $statement->execute(array( + 'id' => $id + )); + + $datas = $statement->fetch(PDO::FETCH_ASSOC); + if (!is_array($datas) || empty($datas)) { + throw new Wootook_Core_Exception_DataAccessException('Could not load data: this id could not be found.'); + } + $realId = $datas[$this->getIdFieldName()]; + unset($datas[$this->getIdFieldName()]); + + $this->_data = array(); + $this->getDataMapper()->decode($this, $datas); + $this->setId($realId); + + return $this; + } + + protected function _save() + { + $adapter = $this->getWriteConnection(); + + if ($adapter === null) { + throw new Wootook_Core_Exception_DataAccessException('Could not save data: no write connection configured.'); + } + + if ($this->getId() !== null) { + $update = $adapter->update() + ->into($adapter->getTable($this->getTableName())) + ->where(new Wootook_Core_Database_Sql_Placeholder_Expression("{$adapter->quoteIdentifier($this->getIdFieldName())}=:id", array('id' => $this->getId()))); + + foreach ($this->getDataMapper()->encode($this, $this->getChangedDatas()) as $field => $value) { + $update->set($field, new Wootook_Core_Database_Sql_Placeholder_Param($field, $value)); + } + try { + $statement = $update->prepare(); + $statement->execute(); + } catch (Wootook_Core_Exception_Database_AdapterError $e) { + throw new Wootook_Core_Exception_DataAccessException('Could not save data: ' . $e->getMessage(), null, $e); + } catch (Wootook_Core_Exception_Database_StatementError $e) { + throw new Wootook_Core_Exception_DataAccessException('Could not save data: ' . $e->getMessage(), null, $e); + } + } else { + $insert = $adapter->insert() + ->into($adapter->getTable($this->getTableName())); + + foreach ($this->getDataMapper()->encode($this, $this->getAllDatas()) as $field => $value) { + $insert->set($field, new Wootook_Core_Database_Sql_Placeholder_Param($field, $value)); + } + try { + $statement = $insert->prepare(); + $statement->execute(); + + $id = $adapter->lastInsertId($adapter->getTable($this->getTableName())); + $this->setId($id); + } catch (Wootook_Core_Exception_Database_AdapterError $e) { + throw new Wootook_Core_Exception_DataAccessException('Could not save data: ' . $e->getMessage(), null, $e); + } catch (Wootook_Core_Exception_Database_StatementError $e) { + throw new Wootook_Core_Exception_DataAccessException('Could not save data: ' . $e->getMessage(), null, $e); + } + } + + return $this; + } + + protected function _delete() + { + $adapter = $this->getWriteConnection(); + if ($adapter === null) { + throw new Wootook_Core_Exception_DataAccessException('Could not delete data: no write connection configured.'); + } + $delete = $adapter + ->delete() + ->from($adapter->getTable($this->getTableName())) + ->where($this->getIdFieldName(), $this->getId()) + ->limit(1); + + try { + $statement = $adapter->prepare($delete); + $statement->execute(); + } catch (Wootook_Core_Exception_Database_AdapterError $e) { + throw new Wootook_Core_Exception_DataAccessException('Could not delete data: ' . $e->getMessage(), null, $e); + } catch (Wootook_Core_Exception_Database_StatementError $e) { + throw new Wootook_Core_Exception_DataAccessException('Could not delete data: ' . $e->getMessage(), null, $e); + } + + return $this; + } +} diff --git a/includes/application/code/core/Legacies/Core/Entity/SubTable.php b/src/application/code/core/Wootook/Core/Mvc/Model/Entity/SubTable.php similarity index 71% rename from includes/application/code/core/Legacies/Core/Entity/SubTable.php rename to src/application/code/core/Wootook/Core/Mvc/Model/Entity/SubTable.php index 550acb6..791d481 100644 --- a/includes/application/code/core/Legacies/Core/Entity/SubTable.php +++ b/src/application/code/core/Wootook/Core/Mvc/Model/Entity/SubTable.php @@ -2,15 +2,14 @@ /** * - * @uses Legacies_Object + * @uses Wootook_Object * @uses Legacies_Empire - * @uses Legacies_Empire_User + * @uses Wootook_Player_Model_Entity */ -abstract class Legacies_Core_Entity_SubTable - extends Legacies_Core_Model +abstract class Wootook_Core_Mvc_Model_Entity_SubTable + extends Wootook_Core_Database_Resource { private $_isLoaded = false; - protected $_tableName = null; protected $_idFieldNames = array(); protected $_eventPrefix = 'entity.sub-table'; @@ -32,7 +31,7 @@ abstract class Legacies_Core_Entity_SubTable $idFields = '(' . implode(') AND (', $idFields) . ')'; $fields = implode(', ', $fields); - $database = Legacies_Database::getSingleton(); + $database = $this->getWriteConnection(); $sql =<<getTable(self::getTableName())} SET {$fields} @@ -51,7 +50,7 @@ SQL_EOF; } $tokens = implode(', ', $tokens); - $database = Legacies_Database::getSingleton(); + $database = $this->getWriteConnection(); $sql =<<getTable(self::getTableName())} ($fields) VALUES ({$tokens}) @@ -66,28 +65,28 @@ SQL_EOF; protected function _load() { $idValues = func_get_arg(0); - $database = Legacies_Database::getSingleton(); + $database = $this->getReadConnection(); + + $select = $database->select() + ->from(array('main_table' => $database->getTable($this->getTableName()))) + ->limit(1); $idFields = array(); foreach ($this->_idFieldNames as $field) { - $idFields[] = "{$field}=:{$field}"; + $select->where("{$database->quoteIdentifier($field)}=:{$field}"); } - $idFields = '(' . implode(') AND (', $idFields) . ')'; - $sql =<<getTable(self::getTableName())} - WHERE $idFields - LIMIT 1 -SQL_EOF; - $statement = $database->prepare($sql); + $statement = $database->prepare($select); $statement->execute($idValues); $datas = $statement->fetch(PDO::FETCH_ASSOC); if (!is_array($datas) || empty($datas)) { - throw new Legacies_Core_Model_Exception('Could not load data: this id combination could not be found.'); + throw new Wootook_Core_Exception_DataAccessException('Could not load data: this id combination could not be found.'); } - $this->_data = $datas; + $this->_data = array(); + $this->getDataMapper()->decode($this, $datas); + $this->_isLoaded = true; return $this; @@ -95,7 +94,7 @@ SQL_EOF; protected function _delete() { - $database = Legacies_Database::getSingleton(); + $database = $this->getWriteConnection(); $idFields = array(); $idValues = array(); @@ -118,16 +117,4 @@ SQL_EOF; return $this; } - - public function setTableName($tableName) - { - $this->_tableName = $tableName; - - return $this; - } - - public function getTableName() - { - return $this->_tableName; - } -} \ No newline at end of file +} diff --git a/src/application/code/core/Wootook/Core/Mvc/Model/EntityInterface.php b/src/application/code/core/Wootook/Core/Mvc/Model/EntityInterface.php new file mode 100644 index 0000000..e512a5d --- /dev/null +++ b/src/application/code/core/Wootook/Core/Mvc/Model/EntityInterface.php @@ -0,0 +1,47 @@ + + * 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 . + * + * --> 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 + * + */ +interface Wootook_Core_Mvc_Model_EntityInterface +{ + public function getId(); + public function setId($id); + + public function getIdFieldName(); + public function setIdFieldName($fieldName); + + public function getTableName(); + public function setTableName($tableName); +} diff --git a/src/application/code/core/Wootook/Core/Mvc/Model/Model.php b/src/application/code/core/Wootook/Core/Mvc/Model/Model.php new file mode 100644 index 0000000..e91265f --- /dev/null +++ b/src/application/code/core/Wootook/Core/Mvc/Model/Model.php @@ -0,0 +1,205 @@ + + * 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 . + * + * --> 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 + * + */ +abstract class Wootook_Core_Mvc_Model_Model + extends Wootook_Object +{ + protected $_originalData = array(); + + protected $_eventPrefix = null; + protected $_eventObject = null; + + public function __construct(Array $data = array()) + { + $this->_data = $data; + + $this->_init(); + $this->_setOriginalData(); + } + + abstract protected function _init(); + + protected function _setOriginalData() + { + $this->_originalData = $this->_data; + } + + public function getChangedDatas() + { + return array_diff_assoc($this->_data, $this->_originalData); + } + + public function hasChangedDatas() + { + if (count($this->getChangedDatas()) > 0) { + return true; + } + return false; + } + + final public function save() + { + try { + $params = func_get_args(); + call_user_func_array(array($this, '_beforeSave'), $params); + call_user_func_array(array($this, '_save'), $params); + call_user_func_array(array($this, '_afterSave'), $params); + $this->_setOriginalData($this->_data); + } catch (PDOException $e) { + throw new Wootook_Core_Exception_DataAccessException('Could not save data: ' . $e->getMessage(), 0); + } + return $this; + } + + abstract protected function _save(); + + protected function _beforeSave() + { + Wootook::dispatchEvent('model.before-save', array('model' => $this)); + + if ($this->_eventPrefix !== null && $this->_eventObject !== null) { + Wootook::dispatchEvent($this->_eventPrefix . '.before-save', array($this->_eventObject => $this)); + } + + return $this; + } + + protected function _afterSave() + { + Wootook::dispatchEvent('model.after-save', array('model' => $this)); + + if ($this->_eventPrefix !== null && $this->_eventObject !== null) { + Wootook::dispatchEvent($this->_eventPrefix . '.after-save', array($this->_eventObject => $this)); + } + + return $this; + } + + final public function load() + { + try { + $params = func_get_args(); + call_user_func_array(array($this, '_beforeLoad'), $params); + call_user_func_array(array($this, '_load'), $params); + call_user_func_array(array($this, '_afterLoad'), $params); + $this->_setOriginalData($this->_data); + } catch (PDOException $e) { + throw new Wootook_Core_Exception_DataAccessException('Could not load data: ' . $e->getMessage(), 0, $e); + } + return $this; + } + + abstract protected function _load(); + + protected function _beforeLoad() + { + Wootook::dispatchEvent('model.before-load', array('model' => $this)); + + if ($this->_eventPrefix !== null && $this->_eventObject !== null) { + Wootook::dispatchEvent($this->_eventPrefix . '.before-load', array($this->_eventObject => $this)); + } + + return $this; + } + + protected function _afterLoad() + { + Wootook::dispatchEvent('model.after-load', array('model' => $this)); + + if ($this->_eventPrefix !== null && $this->_eventObject !== null) { + Wootook::dispatchEvent($this->_eventPrefix . '.after-load', array($this->_eventObject => $this)); + } + + return $this; + } + + final public function delete() + { + try { + $params = func_get_args(); + call_user_func_array(array($this, '_beforeDelete'), $params); + call_user_func_array(array($this, '_delete'), $params); + call_user_func_array(array($this, '_afterDelete'), $params); + } catch (PDOException $e) { + throw new Wootook_Core_Exception_DataAccessException('Could not delete entity: ' . $e->getMessage(), 0); + } + return $this; + } + + abstract protected function _delete(); + + protected function _beforeDelete() + { + Wootook::dispatchEvent('model.before-delete', array('model' => $this)); + + if ($this->_eventPrefix !== null && $this->_eventObject !== null) { + Wootook::dispatchEvent($this->_eventPrefix . '.before-delete', array($this->_eventObject => $this)); + } + + return $this; + } + + protected function _afterDelete() + { + Wootook::dispatchEvent('model.after-delete', array('model' => $this)); + + if ($this->_eventPrefix !== null && $this->_eventObject !== null) { + Wootook::dispatchEvent($this->_eventPrefix . '.after-delete', array($this->_eventObject => $this)); + } + + return $this; + } + + public function __set($key, $value) + { + return $this->setData($key, $value); + } + + public function __get($key) + { + return $this->getData($key); + } + + public function __unset($key) + { + return $this->unsetData($key); + } + + public function __isset($key) + { + return $this->hasData($key); + } +} diff --git a/src/application/code/core/Wootook/Core/Mvc/View/View.php b/src/application/code/core/Wootook/Core/Mvc/View/View.php new file mode 100644 index 0000000..4847061 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Mvc/View/View.php @@ -0,0 +1,346 @@ + + * 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 . + * + * --> 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 Wootook_Core_Mvc_View_View + extends Wootook_Object +{ + protected $_template = null; + protected $_partials = array(); + protected $_layout = null; + protected $_nameInLayout = null; + + protected $_scriptPath = null; + + public function __construct(Array $data = array()) + { + if (isset($data['template'])) { + $this->_template = $data['template']; + unset($data['template']); + } + + parent::__construct($data); + } + + protected function _prepareRender() + { + return $this; + } + + public function renderNumber($number) + { + return Math::render($number); + } + + public function renderTime($time, $unique = false) + { + if ($time >= 10) { + $seconds = $time % 60; + $minutes = (int) (($time - $seconds) / 60) % 60; + $hours = (int) ((($time - $seconds) / 60) - $minutes) / 60; + + if ($hours > 24) { + $dayHours = (int) $hours % 24; + $days = (int) ($hours - $dayHours) / 24; + + return $this->__('%1$d day(s) and %2$d hour(s)', $days, $dayHours); + } else if ($hours > 0) { + return $this->__('%1$d hour(s), %2$d minute(s) and %3$d second(s)', $hours, $minutes, $seconds); + } else if ($minutes > 0) { + return $this->__('%1$d minute(s) and %2$d second(s)', $minutes, $seconds); + } else { + return $this->__('%1$d second(s)', $seconds); + } + } else if (!$unique && $time > 0) { + return $this->__('%1$d per minute', 60 / $time); + } else { + return $this->__('instantaneous'); + } + } + + public function renderDateTime($dateTime, $format = null) + { + if ($format === null) { + $format = 'H:i:s'; + } + if (!$dateTime instanceof Wootook_Core_DateTime) { + $dateTime = new Wootook_Core_DateTime($dateTime); + } + return $dateTime->toString($format); + } + + public function escape($unescaped) + { + return htmlspecialchars($unescaped, ENT_QUOTES, 'UTF-8'); + } + + public function escapeJs($unescaped) + { + return addslashes($unescaped); + } + + public function __($message, $_ = null) + { + $args = func_get_args(); + array_shift($args); + + return Wootook::translate(Wootook::getDefaultLocale(), $message, $args); + } + + public function translate($message, $_ = null) + { + $args = func_get_args(); + array_shift($args); + + return Wootook::translate(Wootook::getLocale(), $message, $args); + } + + public function renderScript($file) + { + $this->_prepareRender(); + + $templatePath = $this->_getTemplatePath($file); + if ($templatePath !== null) { + ob_start(); + include $this->_getTemplatePath($file); + $contents = ob_get_contents(); + ob_end_clean(); + + return $contents; + } + return ''; + } + + public function renderPartial($blockName) + { + if (($block = $this->getPartial($blockName)) !== null) { + return $block->render(); + } + return null; + } + + protected function _getTemplatePath($file) + { + return $this->getScriptPath() . DIRECTORY_SEPARATOR . $file; + } + + public function render() + { + $template = $this->getTemplate(); + if (empty($template)) { + return null; + } + return $this->renderScript($template); + } + + public function setTemplate($template) + { + $this->_template = $template; + + return $this; + } + + public function getTemplate() + { + return $this->_template; + } + + public function getUrl($uri, Array $params = array()) + { + return Wootook::getUrl($uri, $params); + } + + public function getStaticUrl($uri, Array $params = array()) + { + return Wootook::getStaticUrl($uri, $params); + } + + public function getSkinUrl($uri, Array $params = array(), $theme = null, $package = null) + { + if (Wootook::$isInstalled) { + $player = Wootook_Player_Model_Session::getSingleton()->getPlayer(); + if ($player !== null && $player->getId()) { + $theme = $player->getSkinPath(); + } + } + if ($theme === null || empty($theme)) { + $theme = $this->getLayout()->getTheme(); + } + if ($theme === null || empty($theme)) { + $theme = Wootook_Core_Model_Layout::DEFAULT_THEME; + } + + if ($package === null || empty($package)) { + $package = $this->getLayout()->getPackage(); + } + if ($package === null || empty($package)) { + $package = Wootook_Core_Model_Layout::DEFAULT_PACKAGE; + } + $domain = $this->getLayout()->getDomain(); + + $baseUrl = Wootook::getBaseUrl('skin'); + $basePath = Wootook::getBasePath('skin'); + $pathPattern = $basePath . "{$domain}/%s/%s/{$uri}"; + $urlPattern = $baseUrl . "{$domain}/%s/%s/{$uri}"; + + if (count($params) > 0) { + $serializedParams = array(); + foreach ($params as $paramKey => $paramValue) { + if ($paramValue) { + $serializedParams[] = "{$paramKey}={$paramValue}"; + } + } + + $urlPattern .= '?' . implode('&', $serializedParams); + } + + if (Wootook::fileExists(sprintf($pathPattern, $package, $theme))) { + return sprintf($urlPattern, $package, $theme); + } + if (Wootook::fileExists(sprintf($pathPattern, $package, Wootook_Core_Model_Layout::DEFAULT_THEME))) { + return sprintf($urlPattern, $package, Wootook_Core_Model_Layout::DEFAULT_THEME); + } + + return sprintf($urlPattern, Wootook_Core_Model_Layout::DEFAULT_PACKAGE, Wootook_Core_Model_Layout::DEFAULT_THEME); + } + + public function setPartial($name, $content) + { + if (!is_string($content) && !$content instanceof self) { + return $this; + } + + $this->_partials[$name] = $content; + + return $this; + } + + public function getPartial($name) + { + if (!$this->hasPartial($name)) { + return null; + } + return $this->_partials[$name]; + } + + public function getAllPartials() + { + return $this->_partials; + } + + public function unsetPartial($name) + { + if (isset($this->_partials[$name])) { + unset($this->_partials[$name]); + } + + return $this; + } + + public function hasPartial($name) + { + return isset($this->_partials[$name]) && (is_string($this->_partials[$name]) || $this->_partials[$name] instanceof self); + } + + public function __set($name, $content) + { + return $this->setPartial($name, $content); + } + + public function __get($name) + { + $name = str_replace(' ', '', ucwords(str_replace('-', ' ', $name))); + $name[0] = strtolower($name[0]); + return $this->getPartial($name); + } + + public function __unset($name) + { + return $this->unsetPartial($name); + } + + public function __isset($name) + { + return $this->hasPartial($name); + } + + public function setLayout($layout) + { + $this->_layout = $layout; + + return $this; + } + + /** + * + * @return Wootook_Core_Model_Layout + */ + public function getLayout() + { + return $this->_layout; + } + + public function prepareLayout() + { + } + + public function beforeToHtml() + { + } + + public function setNameInLayout($name) + { + $this->_nameInLayout = $name; + + return $this; + } + + public function getNameInLayout() + { + return $this->_nameInLayout; + } + + public function setScriptPath($scriptPath) + { + $this->_scriptPath = $scriptPath; + + return $this; + } + + public function getScriptPath() + { + return $this->_scriptPath; + } +} diff --git a/src/application/code/core/Wootook/Core/PluginLoader/PluginLoader.php b/src/application/code/core/Wootook/Core/PluginLoader/PluginLoader.php new file mode 100644 index 0000000..eaaff7a --- /dev/null +++ b/src/application/code/core/Wootook/Core/PluginLoader/PluginLoader.php @@ -0,0 +1,80 @@ +_pluginInstances[$pluginName])) { + return $this->_pluginInstances[$pluginName]; + } + + $pluginName = str_replace(' ', '_', ucwords(str_replace('.', ' ', $pluginName))); + $pluginName = str_replace(' ', '', ucwords(str_replace('-', ' ', $pluginName))); + + foreach ($this->_namespaces as $namespace => $path) { + $className = $namespace . $pluginName; + $fileName = $path . DIRECTORY_SEPARATOR . + str_replace('_', DIRECTORY_SEPARATOR, $pluginName) . '.php'; + + if (!Wootook::fileExists($fileName)) { + continue; + } + + if (!class_exists($className, true)) { + continue; + } + + return $this->_load($className, $useSingleton, $constructorParams); + } + + return null; + } + + public function registerNamespace($namespace, $path = null) + { + if ($path === null) { + $path = str_replace('_', DIRECTORY_SEPARATOR, $namespace); + } + $this->_namespaces[$namespace] = $path; + + return $this; + } + + public function unregisterNamespace($namespace) + { + if (isset($this->_namespaces[$namespace])) { + unset($this->_namespaces[$namespace]); + } + + return $this; + } + + abstract protected function _load($className, $useSingleton, Array $constructorParams = array()); + + public function getPlugin($pluginName) + { + return $this->load($pluginName); + } + + public function setPlugin($pluginName, $pluginInstance) + { + $this->_pluginInstances[$pluginName] = $pluginInstance; + + return $this; + } + + public function hasPlugin($pluginName) + { + return isset($this->_pluginInstances[$pluginName]); + } + + public function unsetPlugin($pluginName) + { + unset($this->_pluginInstances[$pluginName]); + + return $this; + } +} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Core/Resource/EntityCollection.php b/src/application/code/core/Wootook/Core/Resource/EntityCollection.php new file mode 100644 index 0000000..0f0d29b --- /dev/null +++ b/src/application/code/core/Wootook/Core/Resource/EntityCollection.php @@ -0,0 +1,268 @@ +setReadConnection($connection); + + $this->_construct(); + } + + abstract protected function _construct(); + + protected function _init($entityTable, $entityClass) + { + $this->_entityTable = $entityTable; + $this->_entityClass = $entityClass; + } + + public function getSelect() + { + if ($this->_select === null) { + $this->_select = $this->getReadConnection() + ->select() + ->from(array('main_table' => $this->getReadConnection()->getTable($this->_entityTable))); + + $this->_prepareSelect($this->_select); + } + + return $this->_select; + } + + public function _prepareSelect(Wootook_Core_Database_Sql_Select $select) + { + } + + /** + * + * @return Wootook_Core_Database_Orm_DataMapper + */ + public function getDataMapper() + { + if ($this->_dataMapper === null) { + $this->_dataMapper = new Wootook_Core_Database_Orm_DataMapper(); + } + return $this->_dataMapper; + } + + /** + * @return Wootook_Core_Database_Adapter_Adapter + */ + public function getReadConnection() + { + return $this->_connection; + } + + public function setReadConnection($connection) + { + if ($connection instanceof Wootook_Core_Database_Adapter_Pdo_Mysql) { + $this->_connection = $connection; + } else if (is_string($connection)) { + $this->_connection = Wootook_Core_Database_ConnectionManager::getSingleton() + ->getConnection($connection); + } else { + throw new Wootook_Core_Exception_RuntimeException( + 'First parameter should be either a database connection object or a string identifier.'); + } + + return $this; + } + + final public function load() + { + $this->_beforeLoad(); + $this->_load(); + $this->_afterLoad(); + + return $this; + } + + protected function _beforeLoad() + { + Wootook::dispatchEvent('resource.collection.before-load', array('model' => $this)); + + if ($this->_eventPrefix !== null && $this->_eventObject !== null) { + Wootook::dispatchEvent($this->_eventPrefix . '.before-load', array($this->_eventObject => $this)); + } + + return $this; + } + + protected function _afterLoad() + { + Wootook::dispatchEvent('resource.collection.after-load', array('model' => $this)); + + if ($this->_eventPrefix !== null && $this->_eventObject !== null) { + Wootook::dispatchEvent($this->_eventPrefix . '.after-load', array($this->_eventObject => $this)); + } + + return $this; + } + + protected function _load() + { + $select = clone $this->getSelect(); + + if ($this->_pageSize !== null) { + if ($this->_curPage !== null) { + $select->limit($this->_pageSize, ($this->_curPage - 1) * $this->_pageSize); + } else { + $select->limit($this->_pageSize); + } + } + + $statement = $select->prepare(); + + $args = func_get_args(); + $statement->execute(array_shift($args)); + + $this->_items = array(); + if (func_num_args() > 1) { + $reflection = new ReflectionClass(array_shift($args)); + } else { + $reflection = new ReflectionClass($this->_entityClass); + } + + while ($row = $statement->fetch(PDO::FETCH_ASSOC)) { + $item = $reflection->newInstanceArgs(); + $item->getDataMapper()->decode($item, $row); + + $this->_items[] = $item; + } + + return $this; + } + + public function getSize($maintainGrouping = array()) + { + $clone = clone $this->_select; + $clone->reset(Wootook_Core_Database_Sql_Select::COLUMNS); + if (empty($maintainGrouping)) { + $clone->reset(Wootook_Core_Database_Sql_Select::GROUP); + } else { + $groupingFields = $clone->getPart(Wootook_Core_Database_Sql_Select::GROUP); + $clone->reset(Wootook_Core_Database_Sql_Select::GROUP); + foreach ($groupingFields as $field) { + if (in_array($field, $maintainGrouping)) { + $clone->group($field); + } + } + } + $clone->column(new Wootook_Core_Database_Sql_Placeholder_Expression('COUNT(*)')); + + $database = $this->getReadConnection(); + $statement = $database->prepare($clone); + + $statement->execute(); + $count = $statement->fetchColumn(); + $statement->closeCursor(); + + return $count; + } + + public function count() + { + return count($this->_items); + } + + public function current() + { + return current($this->_items); + } + + public function next() + { + next($this->_items); + + return $this; + } + + public function rewind() + { + reset($this->_items); + + return $this; + } + + public function key() + { + return key($this->_items); + } + + public function valid() + { + return current($this->_items) !== false; + } + + public function getFirstItem() + { + if (count($this->_items) > 0) { + return $this->_items[0]; + } + return null; + } + + public function getLastItem() + { + $size = count($this->_items); + if ($size > 0) { + return $this->_items[$size - 1]; + } + return null; + } + + public function addOrderBy($field, $type = 'ASC') + { + $this->getSelect()->order($field, $type); + + return $this; + } + + public function addFieldToFilter($field, $value = null) + { + $this->getSelect()->where($field, $value); + + return $this; + } + + public function setPage($curPage, $pageSize) + { + $this->setCurPage($curPage)->setPageSize($pageSize); + + return $this; + } + + public function setCurPage($curPage) + { + $this->_curPage = $curPage; + + return $this; + } + + public function setPageSize($pageSize) + { + $this->_pageSize = $pageSize; + + return $this; + } +} diff --git a/src/application/code/core/Wootook/Core/Setup/Exception/RuntimeException.php b/src/application/code/core/Wootook/Core/Setup/Exception/RuntimeException.php new file mode 100644 index 0000000..29a8002 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Setup/Exception/RuntimeException.php @@ -0,0 +1,7 @@ +_setupConnection = Wootook_Core_Database_ConnectionManager::getSingleton() + ->getConnection($connection); + } else { + $this->_setupConnection = $connection; + } + + return $this; + } + + /** + * + * Enter description here ... + * @return Wootook_Core_Database_Adapter_Pdo_Mysql + */ + public function getSetupConnection() + { + if ($this->_setupConnection === null) { + $this->setSetupConnection('default'); + } + return $this->_setupConnection; + } + + public function getTableName($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) + { + $hostname = Wootook::getConfig("database/{$connectionName}/params/hostname"); + $username = Wootook::getConfig("database/{$connectionName}/params/username"); + $database = Wootook::getConfig("database/{$connectionName}/params/database"); + $password = Wootook::getConfig("database/{$connectionName}/params/password"); + + if ($perms === null) { + $perms = 'ALL PRIVILEGES'; + } else if (is_array($perms)) { + $perms = implode(' ', $perms); + } + + $sql =<<getTable($tableName)} +TO '{$username}@{$hostname}' IDENTIFIED BY '$password' +SQL_EOF; + + $this->getSetupConnection()->query($sql); + + return $this; + } + + public function revoke($tableName, $connectionName, $perms = null) + { + $hostname = Wootook::getConfig("database/{$connectionName}/params/hostname"); + $username = Wootook::getConfig("database/{$connectionName}/params/username"); + $database = Wootook::getConfig("database/{$connectionName}/params/database"); + $password = Wootook::getConfig("database/{$connectionName}/params/password"); + + if ($perms === null) { + $perms = 'ALL PRIVILEGES'; + } else if (is_array($perms)) { + $perms = implode(' ', $perms); + } + + $sql =<<getTable($tableName)} +FROM '{$username}@{$hostname}' +SQL_EOF; + + $this->getSetupConnection()->query($sql); + + return $this; + } + + public function run($script) + { + include $script; + } + + public function getConfig($path = null) + { + return Wootook::getConfig($path); + } + + public function getWebsiteConfig($path = null, $websiteId = null) + { + return Wootook::getWebsiteConfig($path, $websiteId); + } + + public function getGameConfig($path = null, $gameId = null) + { + return Wootook::getGameConfig($path, $gameId); + } +} diff --git a/includes/application/code/core/Legacies/Core/Setup/Updater/ScriptQueue.php b/src/application/code/core/Wootook/Core/Setup/Updater/ScriptQueue.php similarity index 87% rename from includes/application/code/core/Legacies/Core/Setup/Updater/ScriptQueue.php rename to src/application/code/core/Wootook/Core/Setup/Updater/ScriptQueue.php index a17096f..e0ce1d5 100644 --- a/includes/application/code/core/Legacies/Core/Setup/Updater/ScriptQueue.php +++ b/src/application/code/core/Wootook/Core/Setup/Updater/ScriptQueue.php @@ -1,6 +1,6 @@ install|upgrade|uninstall|downgrade)-(?[0-9]+\.[0-9]+\.[0-9]+)(?:\.(?[a-z]+)(?[0-9]+))?(?:-(?[0-9]+\.[0-9]+\.[0-9]+)(?:\.(?[a-z]+)(?[0-9]+))?)?$%'; @@ -36,27 +36,35 @@ class Legacies_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); @@ -80,7 +88,7 @@ class Legacies_Core_Setup_Model_Updater_ScriptQueue if ($fromVersion['level'] < $toVersion['level']) { $this->_upgradeToVersion($fromVersion, $toVersion); } else { -// throw new RuntimeException("Version already installed."); +// throw new Wootook_Core_Exception_RuntimeException("Version already installed."); } } else { $this->_upgradeToVersion($fromVersion, $toVersion); @@ -92,7 +100,7 @@ class Legacies_Core_Setup_Model_Updater_ScriptQueue if ($fromVersion['level'] < $toVersion['level']) { $this->_upgradeToVersion($fromVersion, $toVersion); } else { -// throw new RuntimeException("Version already installed."); +// throw new Wootook_Core_Exception_RuntimeException("Version already installed."); } } else { $this->_upgradeToVersion($fromVersion, $toVersion); @@ -104,13 +112,13 @@ class Legacies_Core_Setup_Model_Updater_ScriptQueue if ($fromVersion['level'] < $toVersion['level']) { $this->_upgradeToVersion($fromVersion, $toVersion); } else { -// throw new RuntimeException("Version already installed."); +// throw new Wootook_Core_Exception_RuntimeException("Version already installed."); } } else { $this->_upgradeToVersion($fromVersion, $toVersion); } } else { - throw new RuntimeException("Invalid version stage."); + throw new Wootook_Core_Setup_Exception_VersionStageError("Invalid version stage."); } break; } @@ -123,6 +131,13 @@ class Legacies_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 Legacies_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 RuntimeException("Invalid version stage."); + throw new Wootook_Core_Setup_Exception_VersionStageError("Invalid version stage."); } $levelList = array_keys($this->_installVersions[$highestVersion][$stage]); @@ -175,7 +192,7 @@ class Legacies_Core_Setup_Model_Updater_ScriptQueue protected function _downgradeToVersion($fromVersion, $toVersion) { - throw new RuntimeException("Downgrade isn't yet implemented."); + throw new Wootook_Core_Exception_RuntimeException("Downgrade isn't yet implemented."); } protected function _upgradeToVersion($fromVersion, $toVersion) @@ -232,7 +249,7 @@ class Legacies_Core_Setup_Model_Updater_ScriptQueue $level = max(array_keys($versionPointer[$highestVersion][$stage])); } else { - throw new RuntimeException("Invalid version value."); + throw new Wootook_Core_Setup_Exception_VersionValueError("Invalid version value."); } $currentVersion = array( diff --git a/includes/functions/CheckInputStrings.php b/src/application/code/core/Wootook/Core/Singleton.php similarity index 58% rename from includes/functions/CheckInputStrings.php rename to src/application/code/core/Wootook/Core/Singleton.php index eedf3e1..c136e82 100644 --- a/includes/functions/CheckInputStrings.php +++ b/src/application/code/core/Wootook/Core/Singleton.php @@ -1,15 +1,15 @@ + * Copyright (c) 2011-Present, Grégory PLANCHAT * All rights reserved. * * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by + * 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. * @@ -18,22 +18,23 @@ * 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 General Public License + * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ /** * - * @deprecated - * @param unknown_type $String + * Enter description here ... + * @author Greg + * */ -function CheckInputStrings($string) +interface Wootook_Core_Singleton { - return htmlspecialchars($string, ENT_QUOTES, 'UTF-8'); + public static function getSingleton(); } \ No newline at end of file diff --git a/src/application/code/core/Wootook/Core/configs/module.php b/src/application/code/core/Wootook/Core/configs/module.php new file mode 100644 index 0000000..9b01f6a --- /dev/null +++ b/src/application/code/core/Wootook/Core/configs/module.php @@ -0,0 +1,33 @@ + array( + 'Wootook_Core' => array( + 'version' => '1.5.0' + ) + ), + 'global' => array( + 'models' => array( + 'core' => array( + 'namespace' => 'Warner_Core_Model_', + 'connection' => array( + 'read' => 'core_read', + 'write' => 'core_write', + 'setup' => 'core_setup', + ) + ) + ), + 'blocks' => array( + 'core' => array( + 'namespace' => 'Warner_Core_Block_' + ) + ) + ), + 'frontend' => array( + 'routes' => array( + 'core' => array( + 'modules' => array( + 'core' => 'Wootook_Core' + ) + ) + ) + ) + ); \ No newline at end of file diff --git a/src/application/code/core/Wootook/Core/install/mysql5/install-1.5.0.php b/src/application/code/core/Wootook/Core/install/mysql5/install-1.5.0.php new file mode 100644 index 0000000..44fd985 --- /dev/null +++ b/src/application/code/core/Wootook/Core/install/mysql5/install-1.5.0.php @@ -0,0 +1,208 @@ + + * 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 . + * + * --> 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. + * + */ + +$this->setSetupConnection('core_setup'); + +$sql = <<getTableName('core_website')} ( + `website_id` TINYINT UNSIGNED NOT NULL, + `code` VARCHAR(64) NOT NULL, + `name` VARCHAR(255) NOT NULL, + `sort_order` TINYINT UNSIGNED NOT NULL, + `default_group_id` TINYINT UNSIGNED NOT NULL, + `is_default` BOOL NOT NULL, + `is_staging` BOOL NOT NULL, + `is_active` BOOL NOT NULL, + PRIMARY KEY (`website_id`), + UNIQUE (`code`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +SQL_EOF; + +$this->query($sql); + +$sql = <<getTableName('core_game_group')} ( + `group_id` TINYINT UNSIGNED NOT NULL, + `website_id` TINYINT UNSIGNED NOT NULL, + `code` VARCHAR(64) NOT NULL, + `name` VARCHAR(255) NOT NULL, + `sort_order` TINYINT UNSIGNED NOT NULL, + `is_default` BOOL NOT NULL, + PRIMARY KEY (`group_id`), + INDEX (`website_id`), + UNIQUE (`code`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +SQL_EOF; + +$this->query($sql); + +$sql = <<getTableName('core_game')} ( + `game_id` SMALLINT UNSIGNED NOT NULL, + `group_id` TINYINT UNSIGNED NOT NULL, + `website_id` TINYINT UNSIGNED NOT NULL, + `code` VARCHAR(64) NOT NULL, + `name` VARCHAR(255) NOT NULL, + `sort_order` TINYINT UNSIGNED NOT NULL, + `is_default` BOOL NOT NULL, + `is_staging` BOOL NOT NULL, + `is_active` BOOL NOT NULL, + PRIMARY KEY (`group_id`), + INDEX (`website_id`), + UNIQUE (`code`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +SQL_EOF; + +$this->query($sql); + +$sql = <<getTableName('core_website')} (`website_id`, `code`, `name`, `sort_order`, `default_group_id`, `is_default`, `is_staging`, `is_active`) +VALUES +(0, "admin", "Administration", 0, 0, 0, 0, 1), +(1, "default", "Default Website", 1, 1, 1, 0, 1); +SQL_EOF; + +$this->query($sql); + +$sql = <<getTableName('core_game_group')} (`group_id`, `website_id`, `code`, `name`, `sort_order`, `is_default`) +VALUES +(0, 0, "admin", "Administration", 0, 0), +(1, 1, "default", "Default Group", 1, 1); +SQL_EOF; + +$this->query($sql); + +$sql = <<getTableName('core_game')} (`game_id`, `group_id`, `website_id`, `code`, `name`, `sort_order`, `is_default`, `is_staging`, `is_active`) +VALUES +(0, 0, 0, "admin", "Administration", 0, 0, 0, 1), +(1, 1, 1, "default", "Default Game", 1, 1, 0, 1); +SQL_EOF; + +$this->query($sql); + +$sql = <<getTableName('core_config')} ( + `website_id` TINYINT UNSIGNED NOT NULL, + `game_id` TINYINT UNSIGNED NOT NULL, + `config_path` VARCHAR(64) NOT NULL, + `config_value` VARCHAR(255) NOT NULL, + PRIMARY KEY (`website_id`, `game_id`, `config_path`), + INDEX (`website_id`), + INDEX (`game_id`), + INDEX (`config_path`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +SQL_EOF; + +$this->query($sql); + +$sql = <<getTableName('core_config')} (`website_id`, `game_id`, `config_path`, `config_value`) VALUES + (1, 1, 'resources/base-income/metal', '20'), + (1, 1, 'resources/base-income/cristal', '10'), + (1, 1, 'resources/base-income/deuterium', '0'), + (1, 1, 'resources/base-income/energy', '0'), + + (1, 1, 'planet/initial/fields', '163'), + + (1, 1, 'resources/initial/metal', '500'), + (1, 1, 'resources/initial/cristal', '500'), + (1, 1, 'resources/initial/deuterium', '0'), + (1, 1, 'resources/initial/energy', '0'), + + (1, 1, 'game/general/name', 'Wootook'), + (1, 1, 'game/general/boards-url', 'http://wootook.org/board/'), + (1, 1, 'game/general/extra-url-title', 'Wootook!'), + (1, 1, 'game/general/extra-url', 'http://wootook.org/'), + (1, 1, 'game/general/active', '1'), + (1, 1, 'game/general/closing-message', 'Le jeu est clos pour le moment.'), + (1, 1, 'game/general/locale', 'fr_FR'), + + (1, 1, 'game/resource/multiplier', '1000'), + (1, 1, 'game/speed/general', '2500'), + (1, 1, 'game/speed/fleet', '2500'), + + (1, 1, 'game/debris/metal-percent', '30'), + (1, 1, 'game/debris/cristal-percent', '30'), + (1, 1, 'game/debris/deuterium-percent', '0'), + (1, 1, 'game/debris/energy-percent', '0'), + + (1, 1, 'game/debris/fleet', '1'), + (1, 1, 'game/debris/defense', '0'), + + (1, 1, 'game/noob-protection/active', '0'), + (1, 1, 'game/noob-protection/points-cap', '5000'), + (1, 1, 'game/noob-protection/multiplier', '5'), + +-- (0, 0, 'web/cookie/name', '__wtk'), +-- (0, 0, 'web/cookie/time', '2592000'), +-- (0, 0, 'web/cookie/domain', ''), +-- (0, 0, 'web/cookie/path', ''), + + (1, 1, 'web/cookie/name', '__wtk_1_1'), + +-- (0, 0, 'web/session/time', '900'), +-- (0, 0, 'web/session/domain', '.wootook.org'), +-- (0, 0, 'web/session/path', '/'), + + (0, 0, 'engine/options/bbcode', '1'), + (0, 0, 'engine/options/ga', '1'), + (0, 0, 'engine/options/announces', '0'), + (0, 0, 'engine/options/retailer', '0'), + (0, 0, 'engine/options/notes', '0'), + (0, 0, 'engine/options/chat', '0'), + (0, 0, 'engine/options/banner', '0'), + (0, 0, 'engine/options/vacation-min-time', '172800'), + + (0, 0, 'game/news/active', '0'), + (0, 0, 'game/news/content', 'Bienvenue sur le nouveau serveur de jeu Wootook!'), + + (0, 0, 'engine/ban/duration', '86400'), + + (0, 0, 'engine/bot/active', '0'), + (0, 0, 'engine/bot/name', 'Woot'), + (0, 0, 'engine/bot/email', 'contact@wootook.org'); +SQL_EOF; + +$this->query($sql); + +$sql = <<getTableName('errors')} ( + `error_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, + `error_sender` VARCHAR(32) NOT NULL, + `error_time` TIMESTAMP NOT NULL, + `error_type` VARCHAR(32) NOT NULL DEFAULT 'unknown', + `error_text` TEXT, + PRIMARY KEY (`error_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +SQL_EOF; + +$this->query($sql); diff --git a/src/application/code/core/Wootook/Core/install/mysql5/uninstall-1.5.0.php b/src/application/code/core/Wootook/Core/install/mysql5/uninstall-1.5.0.php new file mode 100644 index 0000000..2b0aad2 --- /dev/null +++ b/src/application/code/core/Wootook/Core/install/mysql5/uninstall-1.5.0.php @@ -0,0 +1,73 @@ + + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * - Neither the name of Grégory PLANCHAT nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * --> 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 One.Platform. + * + */ + +$this->setSetupConnection('core_setup'); + +$sql = <<getTableName('core_website')}; +SQL_EOF; + +$this->query($sql); + +$sql = <<getTableName('core_game_group')}; +SQL_EOF; + +$this->query($sql); + +$sql = <<getTableName('core_game')}; +SQL_EOF; + +$this->query($sql); + +$sql = <<getTableName('core_config')}; +SQL_EOF; + +$this->query($sql); + +$sql = <<getTableName('errors')}; +SQL_EOF; + +$this->query($sql); diff --git a/src/application/code/core/Wootook/Empire/Block/Overview/DestroyPlanet.php b/src/application/code/core/Wootook/Empire/Block/Overview/DestroyPlanet.php new file mode 100644 index 0000000..8d78612 --- /dev/null +++ b/src/application/code/core/Wootook/Empire/Block/Overview/DestroyPlanet.php @@ -0,0 +1,7 @@ +_fleetCollection === null) { + $player = Wootook_Player_Model_Session::getSingleton()->getPlayer(); + $this->_fleetCollection = $player->getVisibleFleets(); + } + return $this->_fleetCollection; + } + + public function setItemTemplate($template) + { + $this->_itemTemplate = $template; + + return $this; + } + + public function getItemTemplate() + { + return $this->_itemTemplate; + } + + public function setItemBlockType($blockType) + { + $this->_itemBlockType = $blockType; + + return $this; + } + + public function getItemBlockType() + { + return $this->_itemBlockType; + } + + public function getItemBlock($fleet) + { + $blockName = $this->getNameInLayout() . ".item({$fleet->getId()})"; + + return $this->getLayout() + ->createBlock($this->getItemBlockType(), $blockName) + ->setTemplate($this->getItemTemplate()) + ->setFleetItem($fleet); + } + + public function prepareLayout() + { + parent::prepareLayout(); + + $this->_initChildBlocks(); + + return $this; + } + + public function _initChildBlocks() + { + $parentBlock = $this->getLayout() + ->createBlock('core/concat', $this->getNameInLayout() . '.item-list') + ; + $this->setPartial('item-list', $parentBlock); + + foreach ($this->getFleetCollection()->load() as $fleet) { + $block = $this->getItemBlock($fleet); + $parentBlock->setPartial($block->getNameInLayout(), $block); + } + + return $this; + } +} diff --git a/src/application/code/core/Wootook/Empire/Block/Overview/Fleet/List/Item.php b/src/application/code/core/Wootook/Empire/Block/Overview/Fleet/List/Item.php new file mode 100644 index 0000000..cd1cffc --- /dev/null +++ b/src/application/code/core/Wootook/Empire/Block/Overview/Fleet/List/Item.php @@ -0,0 +1,153 @@ +_currentPlayer == null) { + $this->_currentPlayer = Wootook_Player_Model_Session::getSingleton()->getPlayer(); + } + return $this->_currentPlayer; + } + + /** + * @return Wootook_Player_Resource_Entity_Collection + */ + public function getFleetOwnerCollection() + { + if ($this->_ownerCollection == null) { + $this->_ownerCollection = $this->getFleetItem()->getOwnerCollection(); + } + return $this->_ownerCollection; + } + + /** + * @return Wootook_Player_Resource_Entity_Collection + */ + public function getFleetOwnerUsernames() + { + $usernameList = array(); + foreach ($this->getFleetOwnerCollection()->load() as $owner) { + $usernameList[] = $owner->getUsername(); + } + return $usernameList; + } + + public function setFleetItem(Wootook_Empire_Model_Fleet $fleetItem) + { + $this->_fleet = $fleetItem; + + return $this; + } + + /** + * @return Wootook_Empire_Model_Fleet + */ + public function getFleetItem() + { + return $this->_fleet; + } + + public function getStartTime() + { + return $this->getFleetItem()->getStartTime(); + } + + public function getActionTime() + { + return $this->getFleetItem()->getActionTime(); + } + + public function getArrivalTime() + { + return $this->getFleetItem()->getArrivalTime(); + } + + public function isOwner() + { + return $this->getFleetItem()->isOwnedBy($this->getPlayer()); + } + + public function getRowClass() + { + return $this->getFleetItem()->getRowClass($this->getPlayer()); + } + + public function getOriginPlanet() + { + return $this->getFleetItem()->getOriginPlanet(); + } + + public function getOriginPlayer() + { + return $this->getOriginPlanet()->getPlayer(); + } + + public function getOriginPlayerName() + { + $player = $this->getOriginPlanet()->getPlayer(); + + if ($player !== null) { + return $player->getUsername(); + } + return null; + } + + public function getOriginPlanetName() + { + return $this->getOriginPlanetName(); + } + + public function getOriginPlanetCoords() + { + return $this->getOriginPlanetCoords(); + } + + public function getDestinationPlanet() + { + return $this->getFleetItem()->getDestinationPlanet(); + } + + public function getDestinationPlayer() + { + return $this->getDestinationPlanet()->getPlayer(); + } + + public function getDestinationPlayerName() + { + $player = $this->getDestinationPlanet()->getPlayer(); + + if ($player !== null) { + return $player->getUsername(); + } + return null; + } + + public function getDestinationPlanetName() + { + return $this->getDestinationPlanetName(); + } + + public function getDestinationPlanetCoords() + { + return $this->getDestinationPlanetCoords(); + } + + public function getMissionLabel() + { + return $this->getFleetItem()->getMissionLabel(); + } + + public function isMission($type) + { + return $this->getFleetItem()->isMission($type); + } +} diff --git a/src/application/code/core/Wootook/Empire/Block/Overview/RenamePlanet.php b/src/application/code/core/Wootook/Empire/Block/Overview/RenamePlanet.php new file mode 100644 index 0000000..24ece3e --- /dev/null +++ b/src/application/code/core/Wootook/Empire/Block/Overview/RenamePlanet.php @@ -0,0 +1,7 @@ +_labels = Wootook_Empire_Helper_Config_Labels::getSingleton(); + } + + public function setPlayer(Wootook_Player_Model_Entity $player) + { + $this->_player = $player; + + return $this; + } + + public function getPlayer() + { + if ($this->_player === null) { + $this->_player = Wootook_Player_Model_Session::getSingleton()->getPlayer(); + } + + return $this->_player; + } + + public function setPlanet(Wootook_Empire_Model_Planet $planet) + { + $this->_planet = $planet; + + return $this; + } + + public function getPlanet() + { + if ($this->_planet === null) { + $this->_planet = $this->getPlayer()->getCurrentPlanet(); + } + + return $this->_planet; + } + + public function setItemId($itemId) + { + $this->_itemId = $itemId; + + return $this; + } + + public function getItemId() + { + return $this->_itemId; + } + + public function getItemInfoUrl() + { + return $this->getStaticUrl('infos.php', array('gid' => $this->getItemId())); + } + + public function getLabel($type) + { + return $this->_labels[$this->getItemId()][$type]; + } + + public function getItemImageUrl() + { + return $this->getStaticUrl($this->getLabel('image')); + } + + public function getName() + { + return $this->getLabel('name'); + } + + public function getDescription() + { + return $this->getLabel('description'); + } + + public function getResourceName($resourceId) + { + static $lang = null; + if ($lang === null) { + // FIXME: implement a cleaner way to get names + $lang = includeLang('imperium'); + } + if ($resourceId == 'cristal') { + $resourceId = 'crystal'; // FIXME: backward compatibility + } + + if (isset($lang[$resourceId])) { + return $this->__($lang[$resourceId]); + } + return ''; + } + + public function getNextLevel() + { + return $this->getQueuedLevel() + 1; + } + + abstract public function getResourcesNeeded($level); + + abstract public function getBuildingTime($level); +} diff --git a/includes/application/code/core/Legacies/Empire/Block/Planet/Builder/Queue/ItemAbstract.php b/src/application/code/core/Wootook/Empire/Block/Planet/Builder/Queue/ItemAbstract.php similarity index 57% rename from includes/application/code/core/Legacies/Empire/Block/Planet/Builder/Queue/ItemAbstract.php rename to src/application/code/core/Wootook/Empire/Block/Planet/Builder/Queue/ItemAbstract.php index 9a9b122..962783a 100644 --- a/includes/application/code/core/Legacies/Empire/Block/Planet/Builder/Queue/ItemAbstract.php +++ b/src/application/code/core/Wootook/Empire/Block/Planet/Builder/Queue/ItemAbstract.php @@ -1,13 +1,13 @@ _item = $item; $this->setItemId($item->getData($this->_itemIdField)); diff --git a/includes/application/code/core/Legacies/Empire/Block/Planet/Builder/QueueAbstract.php b/src/application/code/core/Wootook/Empire/Block/Planet/Builder/QueueAbstract.php similarity index 71% rename from includes/application/code/core/Legacies/Empire/Block/Planet/Builder/QueueAbstract.php rename to src/application/code/core/Wootook/Empire/Block/Planet/Builder/QueueAbstract.php index 5a785b3..baf9c71 100644 --- a/includes/application/code/core/Legacies/Empire/Block/Planet/Builder/QueueAbstract.php +++ b/src/application/code/core/Wootook/Empire/Block/Planet/Builder/QueueAbstract.php @@ -1,30 +1,30 @@ _user = $user; + $this->_player = $player; return $this; } - public function getUser() + public function getPlayer() { - if ($this->_user === null) { - $this->_user = Legacies_Empire_Model_User::getSingleton(); + if ($this->_player === null) { + $this->_player = Wootook_Player_Model_Session::getSingleton()->getPlayer(); } - return $this->_user; + return $this->_player; } - public function setPlanet(Legacies_Empire_Model_Planet $planet) + public function setPlanet(Wootook_Empire_Model_Planet $planet) { $this->_planet = $planet; @@ -34,7 +34,7 @@ abstract class Legacies_Empire_Block_Planet_Builder_QueueAbstract public function getPlanet() { if ($this->_planet === null) { - $this->_planet = $this->getUser()->getCurrentPlanet(); + $this->_planet = $this->getPlayer()->getCurrentPlanet(); } return $this->_planet; @@ -64,7 +64,7 @@ abstract class Legacies_Empire_Block_Planet_Builder_QueueAbstract return $this->_itemBlockType; } - public function getItemBlock(Legacies_Empire_Model_Builder_Item $item) + public function getItemBlock(Wootook_Empire_Model_Builder_Item $item) { $index = $item->getIndex(); $blockName = "item({$index})"; diff --git a/includes/application/code/core/Legacies/Empire/Block/Planet/BuilderAbstract.php b/src/application/code/core/Wootook/Empire/Block/Planet/BuilderAbstract.php similarity index 91% rename from includes/application/code/core/Legacies/Empire/Block/Planet/BuilderAbstract.php rename to src/application/code/core/Wootook/Empire/Block/Planet/BuilderAbstract.php index 7f469ab..9cc98f2 100644 --- a/includes/application/code/core/Legacies/Empire/Block/Planet/BuilderAbstract.php +++ b/src/application/code/core/Wootook/Empire/Block/Planet/BuilderAbstract.php @@ -1,7 +1,7 @@ _planet = $planet; @@ -15,7 +15,7 @@ class Legacies_Empire_Block_Planet_Buildings public function getPlanet() { if ($this->_planet === null) { - $this->_planet = Legacies_Empire_Model_User::getSingleton() + $this->_planet = Wootook_Player_Model_Session::getSingleton()->getPlayer() ->getCurrentPlanet() ; } @@ -24,13 +24,13 @@ class Legacies_Empire_Block_Planet_Buildings public function _initChildBlocks() { - $types = Legacies_Empire_Model_Game_Types::getSingleton(); + $types = Wootook_Empire_Helper_Config_Types::getSingleton(); $type = Legacies_Empire::TYPE_BUILDING_PLANET; if ($this->getPlanet()->isMoon()) { $type = Legacies_Empire::TYPE_BUILDING_MOON; } - /** @var Legacies_Core_Block_Concat $parentBlock */ + /** @var Wootook_Core_Block_Concat $parentBlock */ $parentBlock = $this->getLayout()->getBlock('item-list.items'); foreach ($types->getData($type) as $itemId) { if (!$this->getPlanet()->checkAvailability($itemId)) { diff --git a/includes/application/code/core/Legacies/Empire/Block/Planet/Buildings/Item.php b/src/application/code/core/Wootook/Empire/Block/Planet/Buildings/Item.php similarity index 70% rename from includes/application/code/core/Legacies/Empire/Block/Planet/Buildings/Item.php rename to src/application/code/core/Wootook/Empire/Block/Planet/Buildings/Item.php index a1c63a4..1c4a970 100644 --- a/includes/application/code/core/Legacies/Empire/Block/Planet/Buildings/Item.php +++ b/src/application/code/core/Wootook/Empire/Block/Planet/Buildings/Item.php @@ -1,7 +1,7 @@ getPlanet()->getResourcesNeeded($this->getItemId(), $level); } + public function isBuildable($level = null) + { + if ($level === null) { + $level = $this->getNextLevel(); + } + $resources = $this->getResourcesNeeded($level); + + foreach ($resources as $resourceId => $resourceValue) { + $amount = $this->getPlanet()->getResourceAmount($resourceId); + if (Math::comp($amount, $resourceValue) < 0) { + return false; + } + } + return true; + } + public function getQueuedLevel() { return $this->getPlanet()->getBuildingLevelQueued($this->getItemId()); @@ -29,7 +45,7 @@ class Legacies_Empire_Block_Planet_Buildings_Item $resourceConfig = array(); foreach ($resources as $resourceId => $resourceValue) { - $resourceConfig[$resourceId] = new Legacies_Object(array( + $resourceConfig[$resourceId] = new Wootook_Object(array( 'resource_id' => $resourceId, 'value' => $resourceValue )); diff --git a/includes/application/code/core/Legacies/Empire/Block/Planet/Buildings/Queue.php b/src/application/code/core/Wootook/Empire/Block/Planet/Buildings/Queue.php similarity index 63% rename from includes/application/code/core/Legacies/Empire/Block/Planet/Buildings/Queue.php rename to src/application/code/core/Wootook/Empire/Block/Planet/Buildings/Queue.php index 2eff182..b1c3f55 100644 --- a/includes/application/code/core/Legacies/Empire/Block/Planet/Buildings/Queue.php +++ b/src/application/code/core/Wootook/Empire/Block/Planet/Buildings/Queue.php @@ -1,7 +1,7 @@ + * 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 . + * + * --> 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. + * + */ -class Legacies_Empire_Block_Planet_Buildings_Queue_Item - extends Legacies_Empire_Block_Planet_Builder_Queue_ItemAbstract +/** + * + * Enter description here ... + * @author Greg + * + */ +class Wootook_Empire_Block_Planet_Buildings_Queue_Item + extends Wootook_Empire_Block_Planet_Builder_Queue_ItemAbstract { protected $_itemIdField = 'building_id'; @@ -30,13 +64,21 @@ class Legacies_Empire_Block_Planet_Buildings_Queue_Item return $this->getPlanet()->getBuildingTime($this->getItemId(), $level); } + public function getBuildingRemainingTime() + { + $totalTime = $this->getPlanet()->getBuildingTime($this->getItemId(), $this->getItemQueuedLevel()); + $item = $this->getItem(); + + return $item->getData('created_at') - $item->getData('updated_at') + $totalTime; + } + public function getResourcesConfigForLevel($level) { $resources = $this->getResourcesNeeded($level); $resourceConfig = array(); foreach ($resources as $resourceId => $resourceValue) { - $resourceConfig[$resourceId] = new Legacies_Object(array( + $resourceConfig[$resourceId] = new Wootook_Object(array( 'resource_id' => $resourceId, 'value' => $resourceValue )); diff --git a/src/application/code/core/Wootook/Empire/Block/Planet/Overview.php b/src/application/code/core/Wootook/Empire/Block/Planet/Overview.php new file mode 100644 index 0000000..f24f5dc --- /dev/null +++ b/src/application/code/core/Wootook/Empire/Block/Planet/Overview.php @@ -0,0 +1,40 @@ +getPlayer(); + } + + /** + * + * @return Wootook_Empire_Model_Planet + */ + public function getPlanet() + { + if ($this->_planet === null) { + $this->_planet = $this->getPlayer()->getCurrentPlanet(); + } + return $this->_planet; + } + + public function getPlanetName() + { + return $this->getPlanet()->getName(); + } + + public function getPlanetCoords() + { + return $this->getPlanet()->getCoords(); + } + + public function getPlanetImage() + { + return $this->getPlanet()->getImage(); + } +} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Empire/Block/PlanetList.php b/src/application/code/core/Wootook/Empire/Block/PlanetList.php new file mode 100644 index 0000000..4d1decf --- /dev/null +++ b/src/application/code/core/Wootook/Empire/Block/PlanetList.php @@ -0,0 +1,7 @@ +getPlayer(); + } + + /** + * + * @return Wootook_Empire_Model_Planet + */ + public function getCurrentPlanet() + { + return $this->getCurrentPlayer()->getCurrentPlanet(); + } + + /** + * + * @return Wootook_Empire_Resource_Planet_Collection + */ + public function getPlanetCollection() + { + return $this->getCurrentPlayer() + ->getPlanetCollection(array(Wootook_Empire_Model_Planet::TYPE_PLANET)) + ->load(); + } +} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Empire/Controller/BuildingsController.php b/src/application/code/core/Wootook/Empire/Controller/BuildingsController.php new file mode 100644 index 0000000..6a5234b --- /dev/null +++ b/src/application/code/core/Wootook/Empire/Controller/BuildingsController.php @@ -0,0 +1,43 @@ +loadLayout('planet.buildings'); + $this->renderLayout(); + } + + public function buildAction() + { + if (!is_numeric($buildingId = $this->getRequest()->getParam('id'))) { + $this->_redirect('*/*/view'); + return; + } + + $this->getCurrentPlanet()->appendBuildingQueue($buildingId); + $this->getCurrentPlanet()->save(); + + $this->_redirect('*/*/'); + } + + public function cancelAction() + { + if (!is_numeric($buildingId = $this->getRequest()->getParam('id'))) { + $this->_redirect('*/*/view'); + return; + } + + $this->getCurrentPlanet()->dequeueBuilding($buildingId); + $this->getCurrentPlanet()->save(); + + $this->_redirect('*/*/'); + } +} diff --git a/src/application/code/core/Wootook/Empire/Exception.php b/src/application/code/core/Wootook/Empire/Exception.php new file mode 100644 index 0000000..e2bd909 --- /dev/null +++ b/src/application/code/core/Wootook/Empire/Exception.php @@ -0,0 +1,3 @@ += 50300) { + parent::__construct($message, $code, $previous); + } else { + parent::__construct($message, $code); + $this->_previous = $previous; + } + } + + public function __call($method, $params) + { + if (strtolower($method) == 'getprevious') { + return $this->_previous; + } + } +} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Empire/Exception/Planet.php b/src/application/code/core/Wootook/Empire/Exception/Planet.php new file mode 100644 index 0000000..36c2cf2 --- /dev/null +++ b/src/application/code/core/Wootook/Empire/Exception/Planet.php @@ -0,0 +1,7 @@ += 50300) { + parent::__construct($message, $code, $previous); + } else { + parent::__construct($message, $code); + $this->_previous = $previous; + } + } + + public function __call($method, $params) + { + if (strtolower($method) == 'getprevious') { + return $this->_previous; + } + } +} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Empire/Model/Game/Combat.php b/src/application/code/core/Wootook/Empire/Helper/Config/Combat.php similarity index 66% rename from includes/application/code/core/Legacies/Empire/Model/Game/Combat.php rename to src/application/code/core/Wootook/Empire/Helper/Config/Combat.php index 306699a..26a1bc8 100644 --- a/includes/application/code/core/Legacies/Empire/Model/Game/Combat.php +++ b/src/application/code/core/Wootook/Empire/Helper/Config/Combat.php @@ -4,12 +4,12 @@ * * Enter description here ... * - * @uses Legacies_Object + * @uses Wootook_Object * @uses Legacies_Empire */ -class Legacies_Empire_Model_Game_Combat - extends Legacies_Empire_Model_Game_Abstract - implements Legacies_Core_Singleton +class Wootook_Empire_Helper_Config_Combat + extends Wootook_Core_Helper_Config_ConfigHandler + implements Wootook_Core_Singleton { private static $_singleton = null; @@ -23,9 +23,7 @@ class Legacies_Empire_Model_Game_Combat protected function _init() { - foreach (include ROOT_PATH . 'includes/data/combat.php' as $elementId => $fieldName) { - $this->setData($elementId, $fieldName); - } + $this->_initData('combat'); return $this; } diff --git a/src/application/code/core/Wootook/Empire/Helper/Config/FieldsAlias.php b/src/application/code/core/Wootook/Empire/Helper/Config/FieldsAlias.php new file mode 100644 index 0000000..101bc5f --- /dev/null +++ b/src/application/code/core/Wootook/Empire/Helper/Config/FieldsAlias.php @@ -0,0 +1,47 @@ +_initData('fields-alias'); + return $this; + } + + protected function _load() + { + // NOP + return $this; + } + + protected function _save() + { + // NOP + return $this; + } + + protected function _delete() + { + // NOP + return $this; + } +} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Empire/Helper/Config/Labels.php b/src/application/code/core/Wootook/Empire/Helper/Config/Labels.php new file mode 100644 index 0000000..94297a2 --- /dev/null +++ b/src/application/code/core/Wootook/Empire/Helper/Config/Labels.php @@ -0,0 +1,51 @@ +_initData("locale/{$locale}/labels"); + return $this; + } + + protected function _load() + { + // NOP + return $this; + } + + protected function _save() + { + // NOP + return $this; + } + + protected function _delete() + { + // NOP + return $this; + } +} diff --git a/includes/application/code/core/Legacies/Empire/Model/Game/Prices.php b/src/application/code/core/Wootook/Empire/Helper/Config/Prices.php similarity index 66% rename from includes/application/code/core/Legacies/Empire/Model/Game/Prices.php rename to src/application/code/core/Wootook/Empire/Helper/Config/Prices.php index a2b0c20..1a328de 100644 --- a/includes/application/code/core/Legacies/Empire/Model/Game/Prices.php +++ b/src/application/code/core/Wootook/Empire/Helper/Config/Prices.php @@ -4,12 +4,12 @@ * * Enter description here ... * - * @uses Legacies_Object + * @uses Wootook_Object * @uses Legacies_Empire */ -class Legacies_Empire_Model_Game_Prices - extends Legacies_Empire_Model_Game_Abstract - implements Legacies_Core_Singleton +class Wootook_Empire_Helper_Config_Prices + extends Wootook_Core_Helper_Config_ConfigHandler + implements Wootook_Core_Singleton { private static $_singleton = null; @@ -23,9 +23,7 @@ class Legacies_Empire_Model_Game_Prices protected function _init() { - foreach (include ROOT_PATH . 'includes/data/prices.php' as $elementId => $fieldName) { - $this->setData($elementId, $fieldName); - } + $this->_initData('prices'); return $this; } diff --git a/includes/application/code/core/Legacies/Empire/Model/Game/Production.php b/src/application/code/core/Wootook/Empire/Helper/Config/Production.php similarity index 65% rename from includes/application/code/core/Legacies/Empire/Model/Game/Production.php rename to src/application/code/core/Wootook/Empire/Helper/Config/Production.php index 38eb98f..d4539fc 100644 --- a/includes/application/code/core/Legacies/Empire/Model/Game/Production.php +++ b/src/application/code/core/Wootook/Empire/Helper/Config/Production.php @@ -4,12 +4,12 @@ * * Enter description here ... * - * @uses Legacies_Object + * @uses Wootook_Object * @uses Legacies_Empire */ -class Legacies_Empire_Model_Game_Production - extends Legacies_Empire_Model_Game_Abstract - implements Legacies_Core_Singleton +class Wootook_Empire_Helper_Config_Production + extends Wootook_Core_Helper_Config_ConfigHandler + implements Wootook_Core_Singleton { private static $_singleton = null; @@ -23,9 +23,7 @@ class Legacies_Empire_Model_Game_Production protected function _init() { - foreach (include ROOT_PATH . 'includes/data/production.php' as $elementId => $fieldName) { - $this->setData($elementId, $fieldName); - } + $this->_initData('production'); return $this; } diff --git a/src/application/code/core/Wootook/Empire/Helper/Config/Requirements.php b/src/application/code/core/Wootook/Empire/Helper/Config/Requirements.php new file mode 100644 index 0000000..04ea042 --- /dev/null +++ b/src/application/code/core/Wootook/Empire/Helper/Config/Requirements.php @@ -0,0 +1,47 @@ +_initData('requirements'); + return $this; + } + + protected function _load() + { + // NOP + return $this; + } + + protected function _save() + { + // NOP + return $this; + } + + protected function _delete() + { + // NOP + return $this; + } +} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Empire/Model/Game/Resources.php b/src/application/code/core/Wootook/Empire/Helper/Config/Resources.php similarity index 66% rename from includes/application/code/core/Legacies/Empire/Model/Game/Resources.php rename to src/application/code/core/Wootook/Empire/Helper/Config/Resources.php index ec3cab5..8ce2483 100644 --- a/includes/application/code/core/Legacies/Empire/Model/Game/Resources.php +++ b/src/application/code/core/Wootook/Empire/Helper/Config/Resources.php @@ -4,12 +4,12 @@ * * Enter description here ... * - * @uses Legacies_Object + * @uses Wootook_Object * @uses Legacies_Empire */ -class Legacies_Empire_Model_Game_Resources - extends Legacies_Empire_Model_Game_Abstract - implements Legacies_Core_Singleton +class Wootook_Empire_Helper_Config_Resources + extends Wootook_Core_Helper_Config_ConfigHandler + implements Wootook_Core_Singleton { private static $_singleton = null; @@ -23,9 +23,7 @@ class Legacies_Empire_Model_Game_Resources protected function _init() { - foreach (include ROOT_PATH . 'includes/data/resources.php' as $elementId => $fieldName) { - $this->setData($elementId, $fieldName); - } + $this->_initData('resources'); return $this; } diff --git a/includes/application/code/core/Legacies/Empire/Model/Game/Types.php b/src/application/code/core/Wootook/Empire/Helper/Config/Types.php similarity index 72% rename from includes/application/code/core/Legacies/Empire/Model/Game/Types.php rename to src/application/code/core/Wootook/Empire/Helper/Config/Types.php index feed33c..9ef029d 100644 --- a/includes/application/code/core/Legacies/Empire/Model/Game/Types.php +++ b/src/application/code/core/Wootook/Empire/Helper/Config/Types.php @@ -4,12 +4,12 @@ * * Enter description here ... * - * @uses Legacies_Object + * @uses Wootook_Object * @uses Legacies_Empire */ -class Legacies_Empire_Model_Game_Types - extends Legacies_Empire_Model_Game_Abstract - implements Legacies_Core_Singleton +class Wootook_Empire_Helper_Config_Types + extends Wootook_Core_Helper_Config_ConfigHandler + implements Wootook_Core_Singleton { private static $_singleton = null; @@ -23,9 +23,7 @@ class Legacies_Empire_Model_Game_Types protected function _init() { - foreach (include ROOT_PATH . 'includes/data/types.php' as $elementId => $fieldName) { - $this->setData($elementId, $fieldName); - } + $this->_initData('types'); return $this; } diff --git a/src/application/code/core/Wootook/Empire/Model/Builder/Break.php b/src/application/code/core/Wootook/Empire/Model/Builder/Break.php new file mode 100644 index 0000000..a1bfc75 --- /dev/null +++ b/src/application/code/core/Wootook/Empire/Model/Builder/Break.php @@ -0,0 +1,7 @@ +_currentPlanet = $currentPlanet; - $this->_currentUser = $currentUser; + $this->_currentPlayer = $currentPlayer; $this->init(); } @@ -46,6 +46,10 @@ abstract class Legacies_Empire_Model_BuilderAbstract public function enqueue($params, $index = null) { + if ($this->_currentPlayer->isVacation()) { + return $this; + } + $item = $this->_initItem($params); if ($item === null) { return $this; @@ -94,7 +98,10 @@ abstract class Legacies_Empire_Model_BuilderAbstract { $this->clearQueue(); - $unserialized = @unserialize($serialized); + $unserialized = false; + if (!empty($serialized)) { + $unserialized = @unserialize($serialized); + } if ($unserialized === false) { $this->_queue = array(); return $this; @@ -122,8 +129,8 @@ abstract class Legacies_Empire_Model_BuilderAbstract $this->_queue = array(); } - abstract public function updateQueue($time); - abstract public function appendQueue($typeId, $qty, $time); + abstract public function updateQueue(Wootook_Core_DateTime $time); + abstract public function appendQueue($typeId, $qty, Wootook_Core_DateTime $time); /** * Check if an item type is actually buildable on the current @@ -134,8 +141,8 @@ abstract class Legacies_Empire_Model_BuilderAbstract */ public function checkAvailability($typeId) { - $types = Legacies_Empire_Model_Game_Types::getSingleton(); - $requirements = Legacies_Empire_Model_Game_Requirements::getSingleton(); + $types = Wootook_Empire_Helper_Config_Types::getSingleton(); + $requirements = Wootook_Empire_Helper_Config_Requirements::getSingleton(); if (!isset($requirements[$typeId]) || empty($requirements[$typeId])) { return true; @@ -144,7 +151,7 @@ abstract class Legacies_Empire_Model_BuilderAbstract foreach ($requirements[$typeId] as $requirement => $level) { if ($types->is($requirement, Legacies_Empire::TYPE_BUILDING) && $this->_currentPlanet->hasElement($requirement, $level)) { continue; - } else if ($types->is($requirement, Legacies_Empire::TYPE_RESEARCH) && $this->_currentUser->hasElement($requirement, $level)) { + } else if ($types->is($requirement, Legacies_Empire::TYPE_RESEARCH) && $this->_currentPlayer->hasElement($requirement, $level)) { continue; } else if ($types->is($requirement, Legacies_Empire::TYPE_DEFENSE) && $this->_currentPlanet->hasElement($requirement, $level)) { continue; @@ -205,21 +212,21 @@ abstract class Legacies_Empire_Model_BuilderAbstract return $this->_currentPlanet; } - public function getCurrentUser() + public function getCurrentPlayer() { - return $this->_currentUser; + return $this->_currentPlayer; } - public function setCurrentPlanet(Legacies_Empire_Model_Planet $planet) + public function setCurrentPlanet(Wootook_Empire_Model_Planet $planet) { $this->_currentPlanet = $planet; return $this; } - public function setCurrentUser(Legacies_Empire_Model_User $user) + public function setCurrentPlayer(Wootook_Player_Model_Entity $player) { - $this->_currentUser = $user; + $this->_currentPlayer = $player; return $this; } @@ -244,4 +251,4 @@ abstract class Legacies_Empire_Model_BuilderAbstract } return $resourceAmounts; } -} \ No newline at end of file +} diff --git a/src/application/code/core/Wootook/Empire/Model/Fleet.php b/src/application/code/core/Wootook/Empire/Model/Fleet.php new file mode 100644 index 0000000..e622226 --- /dev/null +++ b/src/application/code/core/Wootook/Empire/Model/Fleet.php @@ -0,0 +1,248 @@ +setIdFieldName('fleet_id'); + $this->setTableName('fleets'); + + $this->getDataMapper() + ->addRule('fleet_start_time', 'date-time') + ->addRule('fleet_end_time', 'date-time') + ->addRule('fleet_end_stay', 'date-time') + ; + } + + public static function planetListener($eventData) + { + } + + public function isOwnedBy(Wootook_Player_Model_Entity $player) + { + if ($this->getData('fleet_owner') == $player->getId()) { + return true; + } + return false; + } + + /** + * @return null|Wootook_Player_Resource_Entity_Collection + */ + public function getOwnerCollection() + { + if ($id = $this->getData('fleet_owner')) { + $ownerCollection = new Wootook_Player_Resource_Entity_Collection($this->getReadConnection()); + $ownerCollection->addFieldToFilter('id', $id); + + return $ownerCollection; + } + return null; + } + + public function isMission($missionType) + { + if ($this->getData('fleet_mission') == $missionType) { + return true; + } + return false; + } + + public function getRowClass(Wootook_Player_Model_Entity $player = null) + { + if ($this->isMission(Legacies_Empire::ID_MISSION_ATTACK) || $this->isMission(Legacies_Empire::ID_MISSION_GROUP_ATTACK)) { + if ($player !== null && $this->isOwnedBy($player)) { + return 'attack'; + } else { + return 'ownattack'; + } + } else if ($this->isMission(Legacies_Empire::ID_MISSION_TRANSPORT)) { + return 'transport'; + } else if ($this->isMission(Legacies_Empire::ID_MISSION_STATION) || $this->isMission(Legacies_Empire::ID_MISSION_STATION_ALLY)) { + return 'station'; + } else if ($this->isMission(Legacies_Empire::ID_MISSION_SETTLE_COLONY)) { + return 'settle'; + } else if ($this->isMission(Legacies_Empire::ID_MISSION_RECYCLE)) { + return 'recycle'; + } else if ($this->isMission(Legacies_Empire::ID_MISSION_DESTROY)) { + return 'destroy'; + } else if ($this->isMission(Legacies_Empire::ID_MISSION_MISSILES)) { + return 'missiles'; + } else if ($this->isMission(Legacies_Empire::ID_MISSION_EXPEDITION)) { + return 'expedition'; + } else if ($this->isMission(Legacies_Empire::ID_MISSION_ORE_MINING)) { + return 'ore-mining'; + } + } + + public function getMissionLabel() + { + if ($this->isMission(Legacies_Empire::ID_MISSION_ATTACK) || $this->isMission(Legacies_Empire::ID_MISSION_GROUP_ATTACK)) { + return Wootook::__('Attack'); + } else if ($this->isMission(Legacies_Empire::ID_MISSION_TRANSPORT)) { + return Wootook::__('Transport'); + } else if ($this->isMission(Legacies_Empire::ID_MISSION_STATION) || $this->isMission(Legacies_Empire::ID_MISSION_STATION_ALLY)) { + return Wootook::__('Station'); + } else if ($this->isMission(Legacies_Empire::ID_MISSION_SETTLE_COLONY)) { + return Wootook::__('Settle'); + } else if ($this->isMission(Legacies_Empire::ID_MISSION_RECYCLE)) { + return Wootook::__('Recycle'); + } else if ($this->isMission(Legacies_Empire::ID_MISSION_DESTROY)) { + return Wootook::__('Destroy'); + } else if ($this->isMission(Legacies_Empire::ID_MISSION_MISSILES)) { + return Wootook::__('Missiles Launch'); + } else if ($this->isMission(Legacies_Empire::ID_MISSION_EXPEDITION)) { + return Wootook::__('Expedition'); + } else if ($this->isMission(Legacies_Empire::ID_MISSION_ORE_MINING)) { + return Wootook::__('Ore mining'); + } + return Legacies::__('Unknown'); + } + + /** + * @return Wootook_Core_DateTime + */ + public function getStartTime() + { + return $this->getData('fleet_start_time'); + } + + /** + * @return Wootook_Core_DateTime + */ + + public function getActionTime() + { + return $this->getData('fleet_end_stay'); + } + + /** + * @return Wootook_Core_DateTime + */ + public function getArrivalTime() + { + return $this->getData('fleet_end_time'); + } + + public function getOriginPlanet() + { + $coords = array( + 'galaxy' => $this->getData('fleet_start_galaxy'), + 'system' => $this->getData('fleet_start_system'), + 'position' => $this->getData('fleet_start_planet') + ); + $type = $this->getData('fleet_start_type'); + + return Wootook_Empire_Model_Planet::factoryFromCoords($coords, $type); + } + + public function getOriginPlanetName() + { + if (!($planet = $this->getOriginPlanet()->getId())) { + return ''; + } + return $planet->getName(); + } + + public function getOriginPlanetCoords() + { + if (!($planet = $this->getOriginPlanet()->getId())) { + return sprintf('%s:%s:%s', $this->getData('fleet_start_galaxy'), $this->getData('fleet_start_system'), $this->getData('fleet_start_planet')); + } + return $planet->getCoords(); + } + + public function getDestinationPlanet() + { + $coords = array( + 'galaxy' => $this->getData('fleet_end_galaxy'), + 'system' => $this->getData('fleet_end_system'), + 'position' => $this->getData('fleet_end_planet') + ); + $type = $this->getData('fleet_end_type'); + + return Wootook_Empire_Model_Planet::factoryFromCoords($coords, $type); + } + + public function getDestinationPlanetName() + { + if (!($planet = $this->getDestinationPlanet()->getId())) { + return ''; + } + return $planet->getName(); + } + + public function getDestinationPlanetCoords() + { + if (!($planet = $this->getDestinationPlanet()->getId())) { + return sprintf('%s:%s:%s', $this->getData('fleet_end_galaxy'), $this->getData('fleet_end_system'), $this->getData('fleet_end_planet')); + } + return $planet->getCoords(); + } + + public function goBack() + { + $this->setData('fleet_mess', 1)->save(); + + return $this; + } + + /** + * @param Wootook_Empire_Model_Planet $planet + * @return Wootook_Empire_Model_Fleet + */ + public function dock(Wootook_Empire_Model_Planet $planet) + { + // Backward-compatible way to unserialize fleet ships listing + $serializedFleetArray = $this->getData('fleet_array'); + foreach (explode(';', $serializedFleetArray) as $fleetShipData) { + if (empty($fleetShipData)) { + continue; + } + $fleetShipData = explode(',', $fleetShipData); + if (count($fleetShipData) != 2) { + continue; + } + $planet->setElement($fleetShipData[0], Math::add($planet->getElement($fleetShipData[0]), $fleetShipData[1])); + } + + $planet + ->setData('metal', Math::add($planet->getData('metal'), $this->getData('fleet_resource_metal'))) + ->setData('cristal', Math::add($planet->getData('cristal'), $this->getData('fleet_resource_crystal'))) + ->setData('deuterium', Math::add($planet->getData('deuterium'), $this->getData('fleet_resource_deuterium'))) + ->save(); + ; + + $this->delete(); + + return $this; + } +} diff --git a/src/application/code/core/Wootook/Empire/Model/Galaxy/Position.php b/src/application/code/core/Wootook/Empire/Model/Galaxy/Position.php new file mode 100644 index 0000000..2ce4b24 --- /dev/null +++ b/src/application/code/core/Wootook/Empire/Model/Galaxy/Position.php @@ -0,0 +1,11 @@ +_tableName = 'galaxy'; + $this->_idFieldNames = array('id_planet'); + } +} diff --git a/includes/application/code/core/Legacies/Empire/Model/Planet.php b/src/application/code/core/Wootook/Empire/Model/Planet.php similarity index 58% rename from includes/application/code/core/Legacies/Empire/Model/Planet.php rename to src/application/code/core/Wootook/Empire/Model/Planet.php index a1688bb..980524f 100644 --- a/includes/application/code/core/Legacies/Empire/Model/Planet.php +++ b/src/application/code/core/Wootook/Empire/Model/Planet.php @@ -2,12 +2,12 @@ /** * - * @uses Legacies_Object + * @uses Wootook_Object * @uses Legacies_Empire - * @uses Legacies_Empire_User + * @uses Wootook_Player_Model_Entity */ -class Legacies_Empire_Model_Planet - extends Legacies_Core_Entity +class Wootook_Empire_Model_Planet + extends Wootook_Core_Mvc_Model_Entity { const TYPE_PLANET = 1; const TYPE_DEBRIS = 2; @@ -17,17 +17,22 @@ class Legacies_Empire_Model_Planet protected $_eventObject = 'planet'; /** - * @var Legacies_Empire_Model_User + * @var Wootook_Player_Model_Entity */ - protected $_user = null; + protected $_player = null; /** - * @var Legacies_Empire_Model_Planet + * @var Wootook_Empire_Model_Planet */ protected $_moon = null; /** - * @var Legacies_Empire_Model_Planet_Builder + * @var Wootook_Empire_Model_Planet + */ + protected $_planet = null; + + /** + * @var Wootook_Empire_Model_Planet_Builder_Builder */ protected $_builder = null; @@ -48,6 +53,9 @@ class Legacies_Empire_Model_Planet protected static $_productionInstances = array(); + /** @var Wootook_Empire_Model_Planet_PluginLoader */ + protected $_pluginLoader = null; + public static function factory($id) { if ($id === null) { @@ -64,12 +72,104 @@ class Legacies_Empire_Model_Planet return self::$_instances[$id]; } + public static function factoryFromCoords($coords, $type = self::TYPE_PLANET) + { + if ($coords === null || empty($coords)) { + return new self(); + } + + if (!in_array($type, array(self::TYPE_PLANET, self::TYPE_DEBRIS, self::TYPE_MOON))) { + $type = self::TYPE_PLANET; + } + + if (!is_array($coords)) { + $coords = explode(':', $coords); + + if (count($coords) != 3) { + return new self(); + } + + $coords = array( + 'galaxy' => $coords[0], + 'system' => $coords[1], + 'position' => $coords[2], + 'type' => $type + ); + } + + if (!isset($coords['type'])) { + $coords['type'] = $type; + } + + $adapter = Wootook_Core_Database_ConnectionManager::getSingleton() + ->getConnection('core_read'); + $collection = new Wootook_Empire_Resource_Planet_Collection($adapter); + $collection->addCoordsToFilter($coords['galaxy'], $coords['system'], $coords['position'], $coords['type']) + ->setPage(1, 1) + ->load(); + + $planet = $collection->getFirstItem(); + if ($planet !== null) { + return $planet; + } + + return new self; + } + + public function __construct(Array $data = array(), Wootook_Player_Model_Entity $player = null) + { + parent::__construct($data); + + if ($player !== null) { + $this->setPlayer($player); + } + } + public function _init() { $this->_tableName = 'planets'; $this->_idFieldName = 'id'; + + $this->getDataMapper() + ->addRule('last_update', 'date-time') + ->addRule('b_building', 'date-time') + ->addRule('b_tech', 'date-time') + ->addRule('b_hangar', 'date-time'); } + public function __call($method, $params) + { + $prefix = substr($method, 0, 3); + $plugin = substr($method, 3); + + if ($this->_pluginLoader === null) { + $this->_pluginLoader = new Wootook_Empire_Model_Planet_PluginLoader($this, $this->getPlayer()); + } + + switch ($prefix) { + case 'get': + return $this->_pluginLoader->getPlugin($plugin); + break; + + case 'set': + return $this->_pluginLoader->setPlugin($plugin, $params[0]); + break; + + case 'uns': + return $this->_pluginLoader->unsetPlugin($plugin); + break; + + case 'has': + return $this->_pluginLoader->hasPlugin($plugin); + break; + } + + throw new Wootook_Core_Exception_RuntimeException(Wootook::__('Undefined method %s::%s.', get_class($this), $method)); + } + + /** + * @return Wootook_Core_DateTime + */ public function getLastUpdate() { return $this->getData('last_update'); @@ -92,24 +192,25 @@ class Legacies_Empire_Model_Planet public function getGalaxyData() { - $entity = new Legacies_Empire_Model_Galaxy_Position(); - $entity->load(array('id_planet' => $this->getId())); + if ($this->isPlanet()) { + $entity = new Wootook_Empire_Model_Galaxy_Position(); + $entity->load(array('id_planet' => $this->getId())); - return $entity; + return $entity; + } + + return $this->getPlanet()->getGalaxyData(); } - public function updateStorages($time = null) + public function updateStorages() { Math::setPrecision(50); - $resources = Legacies_Empire_Model_Game_Resources::getSingleton(); + $resources = Wootook_Empire_Helper_Config_Resources::getSingleton(); foreach ($resources->getAllDatas() as $resource => $resourceData) { - if (!isset($resourceData['storage_field']) || $resourceData['storage_field'] === null) { + if (!isset($resourceData['storage']) || $resourceData['storage'] === null) { continue; } - //$officerEnhancement = (.5 * $this->getUser()->getData('rpg_stockeur')) + 1; - $officerEnhancement = 1; - if ($this->getElement($resourceData['storage'])) { $storageEnhancementFactor = Math::floor(Math::pow(1.6, $this->getElement($resourceData['storage']))); $storageEnhancement = Math::mul(BASE_STORAGE_SIZE / 2, $storageEnhancementFactor); @@ -117,9 +218,18 @@ class Legacies_Empire_Model_Planet $storageEnhancement = 0; } - $value = Math::mul(MAX_OVERFLOW, Math::mul($officerEnhancement, Math::add(BASE_STORAGE_SIZE, $storageEnhancement))); + $storageSize = Math::add(BASE_STORAGE_SIZE, $storageEnhancement); - $this->setData($resourceData['storage_field'], Math::floor($value)); + $event = Wootook::dispatchEvent($this->_eventPrefix . 'update-storage.resource', array( + 'resource_id' => $resource, + 'resource_data' => $resourceData, + 'default_size' => $storageSize, + 'calculated_size' => $storageSize + )); + + $calculatedSize = $event->getData('calculated_size'); + + $this->setData($resourceData['storage_field'], Math::floor($calculatedSize)); } Math::setPrecision(); @@ -128,7 +238,7 @@ class Legacies_Empire_Model_Planet public function updateBuildingFields() { - $types = Legacies_Empire_Model_Game_Types::getSingleton(); + $types = Wootook_Empire_Helper_Config_Types::getSingleton(); if ($this->isPlanet()) { $filter = Legacies_Empire::TYPE_BUILDING_PLANET; @@ -148,17 +258,21 @@ class Legacies_Empire_Model_Planet return $this; } - public function updateResourceProduction($time = null) + public function updateResourceProduction() { - $types = Legacies_Empire_Model_Game_Types::getSingleton(); - $resources = Legacies_Empire_Model_Game_Resources::getSingleton(); - $production = Legacies_Empire_Model_Game_Production::getSingleton(); + $types = Wootook_Empire_Helper_Config_Types::getSingleton(); + $resources = Wootook_Empire_Helper_Config_Resources::getSingleton(); + $production = Wootook_Empire_Helper_Config_Production::getSingleton(); - if ($time === null) { - $time = Legacies::now(); + if (!$this->isPlanet() || !$this->getPlayer()) { + return $this; } - if (!$this->isPlanet()) { + if ($this->getPlayer()->isVacation()) { + $resourceConfig = Wootook::getGameConfig('resource/base-income'); + foreach ($resources->getAllDatas() as $resource => $resourceData) { + $this->setData($resourceData['production_field'], $resourceConfig[$resource]); + } return $this; } @@ -181,7 +295,7 @@ class Legacies_Empire_Model_Planet $ratio = $this->getData($ratioField); $element = self::getProductionElementInstance($productionUnit); - $productionRatios[$productionUnit] = $element->getProductionRatios($level, $ratio, $this, $this->getUser()); + $productionRatios[$productionUnit] = $element->getProductionRatios($level, $ratio, $this, $this->getPlayer()); foreach ($productionRatios[$productionUnit] as $resourceId => $resourceProduction) { $comp = Math::comp($resourceProduction, 0); if ($comp < 0) { @@ -248,9 +362,9 @@ class Legacies_Empire_Model_Planet } // Dispatch 'planet.update-production.before' event - Legacies::dispatchEvent($this->_eventPrefix . '.update-production.before', array( + Wootook::dispatchEvent($this->_eventPrefix . '.update-production.before', array( $this->_eventObject => $this, - 'user' => $this->getUser(), + 'player' => $this->getPlayer(), 'productions' => $actualProduction )); @@ -264,29 +378,30 @@ class Legacies_Empire_Model_Planet } // Dispatch 'planet.update-production.after' event - Legacies::dispatchEvent($this->_eventPrefix . '.update-production.after', array( + Wootook::dispatchEvent($this->_eventPrefix . '.update-production.after', array( $this->_eventObject => $this, - 'user' => $this->getUser() + 'player' => $this->getPlayer() )); return $this; } - public function updateResources($time = null) + public function updateResources(Wootook_Core_DateTime $time = null) { - $resources = Legacies_Empire_Model_Game_Resources::getSingleton(); + $resources = Wootook_Empire_Helper_Config_Resources::getSingleton(); if ($time === null) { - $time = Legacies::now(); + $time = new Wootook_Core_DateTime(); } - $timeDiff = ($time - $this->getLastUpdate()) / 3600; + $timeDiff = $time->diff($this->getLastUpdate()); + foreach ($resources->getAllDatas() as $resourceId => $resourceConfig) { if (!$resourceConfig['storage_field']) { continue; } - $production = Math::mul($this->getData($resourceConfig['production_field']), $timeDiff); + $production = Math::mul($this->getData($resourceConfig['production_field']), $timeDiff / 3600); $resourceValue = Math::add($this->getData($resourceConfig['field']), $production); $this->setData($resourceConfig['field'], Math::min($resourceValue, $this->getData($resourceConfig['storage_field']))); } @@ -297,13 +412,13 @@ class Legacies_Empire_Model_Planet public static function getProductionElementInstance($buildingId) { - $production = Legacies_Empire_Model_Game_Production::getSingleton(); + $production = Wootook_Empire_Helper_Config_Production::getSingleton(); if (!isset(self::$_productionInstances[$buildingId])) { if (!isset($production[$buildingId])) { return null; } - $class = $production[$buildingId][Legacies_Empire::RESOURCE_CLASS]; + $class = $production[$buildingId]; $reflection = new ReflectionClass($class); self::$_productionInstances[$buildingId] = $reflection->newInstance(); } @@ -313,93 +428,30 @@ class Legacies_Empire_Model_Planet public function getFleetCollection($time = null) { - $firstCollection = new Legacies_Core_Collection(array('fleet' => 'fleets')); - $firstCollection - ->column('*') - ->where('fleet.fleet_start_galaxy = :galaxy') - ->where('fleet.fleet_start_system = :system') - ->where('fleet.fleet_start_planet = :position') - ->where('fleet.fleet_start_type = :planet_type') - ; - $backCollection = new Legacies_Core_Collection(array('fleet' => 'fleets')); - $backCollection - ->column('*') - ->where('fleet.fleet_end_galaxy = :galaxy') - ->where('fleet.fleet_end_system = :system') - ->where('fleet.fleet_end_planet = :position') - ->where('fleet.fleet_end_type = :planet_type') - ; - - $options = array( - 'galaxy' => $this->getSystem(), - 'system' => $this->getSystem(), - 'position' => $this->getPosition(), - 'planet_type' => $this->getType() - ); - - if ($time !== null) { - $options['now'] = $time; - $firstCollection->where('fleet_start_time <= :now'); - $backCollection->where('fleet_end_time <= :now'); - } - - $collection = new Legacies_Core_Collection(); - $collection - ->setEntityClassName('Legacies_Empire_Model_Fleet') - ->union($firstCollection) - ->union($backCollection) - ->load($options) - ; + $collection = new Wootook_Empire_Resource_Fleet_Collection($this->getReadConnection()); + $collection->addPlanetToFilter($this, $time); return $collection; } - public function getUserId() + public function getPlayerId() { return (int) $this->getData('id_owner'); } - public function getUser() + public function getPlayer() { - if ($this->_user === null && $this->getUserId()) { - $this->_user = Legacies_Empire_Model_User::factory($this->getUserId()); + if ($this->_player === null && $this->getPlayerId()) { + $this->_player = new Wootook_Player_Model_Entity(); + $this->_player->load($this->getPlayerId()); } - return $this->_user; + return $this->_player; } - public function setUser(Legacies_Empire_Model_User $user) + public function setPlayer(Wootook_Player_Model_Entity $player) { - $this->_user = $user; - - return $this; - } - - public function getShipyard() - { - if ($this->_shipyard === null) { - $this->_shipyard = new Legacies_Empire_Model_Planet_Building_Shipyard($this, $this->getUser()); - } - return $this->_shipyard; - } - - public function setShipyard(Legacies_Empire_Model_Planet_Building_Shipyard $shipyard) - { - $this->_shipyard = $shipyard; - - return $this; - } - - public function getResearchLab() - { - if ($this->_laboratory === null) { - $this->_laboratory = new Legacies_Empire_Model_Planet_Building_ResearchLab($this, $this->getUser()); - } - return $this->_laboratory; - } - - public function setResearchLab(Legacies_Empire_Model_Planet_Building_ResearchLab $laboratory) - { - $this->_laboratory = $laboratory; + $this->_player = $player; + $this->setData('id_owner', $player->getId()); return $this; } @@ -421,31 +473,60 @@ class Legacies_Empire_Model_Planet public function getMoon() { - static $statement = null; - if ($this->isMoon()) { return null; } if ($this->_moon === null) { - if ($statement === null) { - $statement = new Legacies_Core_Collection(array('planet' => 'planets'), get_class($this)); - $statement - ->where('galaxy=:galaxy') - ->where('system=:system') - ->where('planet=:position') - ->where('planet_type=' . strval(self::TYPE_MOON)) - ; + $collection = new Wootook_Empire_Resource_Planet_Collection($this->getReadConnection()); + $collection->addFieldToFilter('galaxy', $this->getGalaxy()) + ->addFieldToFilter('system', $this->getGalaxy()) + ->addFieldToFilter('planet', $this->getPosition()) + ->addFieldToFilter('planet_type', self::TYPE_MOON) + ->load() + ; + + $this->_moon = $collection->getFirstItem(); + + if ($this->_moon !== null && $this->_moon instanceof self) { + $this->_moon->setPlanet($this); } - $statement->load(array( + } + return $this->_moon; + } + + public function setMoon(Wootook_Empire_Model_Planet $moon) + { + $this->_moon = $moon; + + return $this; + } + + public function getPlanet() + { + if ($this->isPlanet()) { + return null; + } + + if ($this->_planet === null) { + $this->_planet = Wootook_Empire_Model_Planet::factoryFromCoords(array( 'galaxy' => $this->getGalaxy(), 'system' => $this->getSystem(), 'position' => $this->getPosition() )); - $this->_moon = $statement->current(); + if ($this->_planet !== null && $this->_planet instanceof self) { + $this->_planet->setMoon($this); + } } - return $this->_moon; + return $this->_planet; + } + + public function setPlanet(Wootook_Empire_Model_Planet $planet) + { + $this->_planet = $planet; + + return $this; } public function setGalaxy($galaxy) @@ -525,7 +606,7 @@ class Legacies_Empire_Model_Planet public function isDestroyed() { - return (bool) $this->getData('destruyed'); + return (bool) ($this->getData('destruyed') > 0); } public function destroy() @@ -535,23 +616,23 @@ class Legacies_Empire_Model_Planet } if ($this->isDestroyed()) { - throw new Legacies_Empire_Model_Planet_Exception(Legacies::__('Planet is already destroyed.')); + throw new Wootook_Empire_Exception_Planet(Wootook::__('Planet is already destroyed.')); } if ($this->getFleetCollection()->count() > 0) { - throw new Legacies_Empire_Model_Planet_Exception(Legacies::__("Could not delete planet until fleets aten't retuned.")); + throw new Wootook_Empire_Exception_Planet(Wootook::__("Could not delete planet until fleets aten't retuned.")); } - $user = $this->getUser(); - if ($user->getHomePlanet()->getId() == $this->getId()) { - throw new Legacies_Empire_Model_Planet_Exception(Legacies::__("You can't destroy your home planet.")); + $player = $this->getPlayer(); + if ($player->getHomePlanet()->getId() == $this->getId()) { + throw new Wootook_Empire_Exception_Planet(Wootook::__("You can't destroy your home planet.")); } - if ($user->getCurrentPlanet()->getId() == $this->getId()) { - $homePlanet = $user->getHomePlanet(); + if ($player->getCurrentPlanet()->getId() == $this->getId()) { + $homePlanet = $player->getHomePlanet(); if ($homePlanet !== null) { - $user->updateCurrentPlanet($homePlanet); + $player->updateCurrentPlanet($homePlanet); } } @@ -560,41 +641,49 @@ class Legacies_Empire_Model_Planet } $this - ->setData('destruyed', true) + ->setData('destruyed', time() + 172800) ->setData('id_owner', 0) ->save(); return $this; } + public function isErasable() + { + if ($this->isDestroyed() && $this->getData('destruyed') >= time()) { + return true; + } + return false; + } + public function getElement($elementId) { - $fields = Legacies_Empire_Model_Game_FieldsAlias::getSingleton(); + $fields = Wootook_Empire_Helper_Config_FieldsAlias::getSingleton(); return $this->getData($fields[$elementId]); } public function setElement($elementId, $level) { - $fields = Legacies_Empire_Model_Game_FieldsAlias::getSingleton(); + $fields = Wootook_Empire_Helper_Config_FieldsAlias::getSingleton(); return $this->setData($fields[$elementId], $level); } public function hasElement($elementId, $levelRequired = 0) { - $fields = Legacies_Empire_Model_Game_FieldsAlias::getSingleton(); + $fields = Wootook_Empire_Helper_Config_FieldsAlias::getSingleton(); return $this->hasData($fields[$elementId]) && Math::comp($this->getElement($elementId), $levelRequired) > 0; } - public function appendBuildingQueue($buildingId, $destroy = false, $time = null) + public function appendBuildingQueue($buildingId, $destroy = false, Wootook_Core_DateTime $time = null) { - $types = Legacies_Empire_Model_Game_Types::getSingleton(); - $prices = Legacies_Empire_Model_Game_Prices::getSingleton(); + $types = Wootook_Empire_Helper_Config_Types::getSingleton(); + $prices = Wootook_Empire_Helper_Config_Prices::getSingleton(); if ($time === null) { - $time = Legacies::now(); + $time = new Wootook_Core_DateTime(); } if (!$types->is($buildingId, Legacies_Empire::TYPE_BUILDING)) { @@ -606,11 +695,11 @@ class Legacies_Empire_Model_Planet } // Dispatch 'planet.building.append-queue.before' event - Legacies::dispatchEvent($this->_eventPrefix . '.building.append-queue.before', array( + Wootook::dispatchEvent($this->_eventPrefix . '.building.append-queue.before', array( 'bulding_id' => $buildingId, 'level' => $this->getElement($buildingId), $this->_eventObject => $this, - 'user' => $this->getUser(), + 'player' => $this->getPlayer(), 'destroy' => $destroy )); @@ -623,38 +712,37 @@ class Legacies_Empire_Model_Planet $this->getBuildingQueue()->appendQueue($buildingId, $level, $time); // Dispatch 'planet.shipyard.append-queue.after' event - Legacies::dispatchEvent($this->_eventPrefix . '.building.append-queue.after', array( + Wootook::dispatchEvent($this->_eventPrefix . '.building.append-queue.after', array( 'bulding_id' => $buildingId, 'level' => $this->getElement($buildingId), $this->_eventObject => $this, - 'user' => $this->getUser(), + 'player' => $this->getPlayer(), 'destroy' => $destroy )); return $this; } - public function updateBuildingQueue($time = null) + public function updateBuildingQueue(Wootook_Core_DateTime $time = null) { if ($time === null) { - $time = Legacies::now(); + $time = new Wootook_Core_DateTime(); } // Dispatch event - Legacies::dispatchEvent($this->_eventPrefix . '.update-queue.before', array( + Wootook::dispatchEvent($this->_eventPrefix . '.update-queue.before', array( 'time' => &$time, - $this->_eventObject => $this->_currentPlanet, - 'user' => $this->_currentUser + $this->_eventObject => $this, + 'player' => $this->getPlayer() )); $this->getBuildingQueue()->updateQueue($time); // Dispatch event - Legacies::dispatchEvent($this->_eventPrefix . '.update-queue.after', array( + Wootook::dispatchEvent($this->_eventPrefix . '.update-queue.after', array( 'time' => $time, - 'shipyard' => $this, - $this->_eventObject => $this->_currentPlanet, - 'user' => $this->_currentUser + $this->_eventObject => $this, + 'player' => $this->getPlayer() )); return $this; @@ -675,12 +763,12 @@ class Legacies_Empire_Model_Planet /** * - * @return Legacies_Empire_Model_Planet_Builder + * @return Wootook_Empire_Model_Planet_Builder_Builder */ public function getBuildingQueue() { - if ($this->_builder === null) { - $this->_builder = new Legacies_Empire_Model_Planet_Builder($this, $this->getUser()); + if ($this->_builder === null && $this->getPlayer()) { + $this->_builder = new Wootook_Empire_Model_Planet_Builder_Builder($this, $this->getPlayer()); } return $this->_builder; } @@ -688,14 +776,14 @@ class Legacies_Empire_Model_Planet /** * * Enter description here ... - * @return Legacies_Empire_Model_Planet + * @return Wootook_Empire_Model_Planet */ public function dequeueBuilding() { $this->getBuildingQueue()->rewind(); $item = $this->getBuildingQueue()->current(); - $this->getBuildingQueue()->dequeueFirstItem(Legacies::now()); + $this->getBuildingQueue()->dequeueFirstItem(new Wootook_Core_DateTime()); return $this; } @@ -703,7 +791,7 @@ class Legacies_Empire_Model_Planet /** * * Enter description here ... - * @return Legacies_Empire_Model_Planet + * @return Wootook_Empire_Model_Planet */ public function dequeueItem($itemId) { @@ -721,15 +809,17 @@ class Legacies_Empire_Model_Planet */ public function checkAvailability($buildingId) { - $this->getBuildingQueue()->checkAvailability($buildingId); + if (!$this->getBuildingQueue()->checkAvailability($buildingId)) { + return false; + } try { // Dispatch event. Throw an exception to break the avaliability. - Legacies::dispatchEvent($this->_eventPrefix . '.check-availability', array( + Wootook::dispatchEvent($this->_eventPrefix . '.check-availability', array( 'ship_id' => $buildingId, 'shipyard' => $this, - $this->_eventObject => $this->_currentPlanet, - 'user' => $this->_currentUser + $this->_eventObject => $this, + 'player' => $this->getPlayer() )); } catch (Exception $e) { return false; @@ -760,129 +850,53 @@ class Legacies_Empire_Model_Planet return $this->getBuildingQueue()->getBuildingTime($buildingId, $level); } - public static function registrationListener($eventData) - { - if (isset($eventData['user'])) { - $user = $eventData['user']; - - if ($user === null || !$user instanceof Legacies_Empire_Model_User || !$user->getId()) { - return; - } - - $collection = self::searchMostFreeSystems(); - $collection->limit(1)->load(); - - if ($collection->count() == 0) { - throw new Exception('No more planet to colonize!'); // Oops, no more free place - } - - $systemInfo = $collection->current(); - if ($systemInfo->getData('count') >= MAX_PLANET_IN_SYSTEM) { - throw new Exception('No more planet to colonize!'); // Oops, no more free place - } - - $collection = new Legacies_Core_Collection(array('planet' => 'planets')); - $collection - ->column(array('position' => 'planet.planet')) - ->where('planet.planet_type=1') - ->where('planet.galaxy=:galaxy') - ->where('planet.system=:system') - ->load(array( - 'galaxy' => $systemInfo->getData('galaxy'), - 'system' => $systemInfo->getData('system'), - )) - ; - $positions = range(1, MAX_PLANET_IN_SYSTEM); - foreach ($collection as $planet) { - $key = array_search($planet->getData('position'), $positions); - if ($key !== false) { - unset($positions[$key]); - } - } - $key = array_rand($positions, 1); - $finalPosition = $positions[$key]; - - $config = Legacies_Core_Model_Config::getSingleton(); - $planet = new self(); - $planet - ->setData('id_owner', $user->getId()) - ->setData('name', Legacies::getRequest()->getParam('planet')) - ->setData('galaxy', $systemInfo->getData('galaxy')) - ->setData('system', $systemInfo->getData('system')) - ->setData('planet', $finalPosition) - ->setData('planet_type', 1) - ->setData('field_max', $config->getData('initial_fields')) - ->setData('field_current', 0) - ->setData('metal', 500) // TODO: use config - ->setData('cristal', 500) // TODO: use config - ; - - $planet->save(); - - $user - ->setData('id_planet', $planet->getId()) - ->setData('current_planet', $planet->getId()) - ->setData('galaxy', $planet->getGalaxy()) - ->setData('system', $planet->getSystem()) - ->setData('planet', $planet->getPosition()) - ; - - Legacies::dispatchEvent('planet.init', array( - 'planet' => $planet, - 'user' => $user - )); - - $planet->save(); - } - } - public static function searchMostFreeSystems($galaxyList = null, $systemList = null) { - $collection = new Legacies_Core_Collection(array('galaxy' => 'galaxy')); - $collection + $adapter = Wootook_Core_Database_ConnectionManager::getSingleton() + ->getConnection('core_read'); + $select = $adapter->select(array('galaxy' => $adapter->getTable('galaxy'))); + $select ->column(array( - 'galaxy' => 'galaxy.galaxy', - 'system' => 'galaxy.system', - 'count' => 'COUNT(*)' + 'galaxy' => 'galaxy', + 'system' => 'system', + 'count' => new Wootook_Core_Database_Sql_Placeholder_Expression('COUNT(*)') )) ->group('galaxy.galaxy') ->group('galaxy.system') ; - $config = Legacies_Core_Model_Config::getSingleton(); - - if ($galaxyList === null && $config->hasData('user/registration/galaxy_list')) { - $galaxyList = explode(',', $config->getData('user/registration/galaxy_list')); + if ($galaxyList === null && Wootook::getGameConfig('user/registration/galaxy_list')) { + $galaxyList = explode(',', Wootook::getGameConfig('user/registration/galaxy_list')); } if ($galaxyList !== null) { array_walk($galaxyList, array(__CLASS__, '_cleanItemRanges')); - $collection->where('galaxy.galaxy IN(' . implode(', ', $galaxyList) . ')'); + $select->where('galaxy', array(array(Wootook_Core_Database_Sql_Select::OPERATOR_IN => $galaxyList))); } - if ($systemList === null && $config->hasData('user/registration/system_list')) { - $systemList = explode(',', $config->getData('user/registration/system_list')); + if ($systemList === null && Wootook::getGameConfig('user/registration/system_list')) { + $systemList = explode(',', Wootook::getGameConfig('user/registration/system_list')); } if ($systemList !== null) { array_walk($systemList, array(__CLASS__, '_cleanItemRanges')); - $collection->where('galaxy.system IN(' . implode(', ', $systemList) . ')'); + $select->where('system', array(array(Wootook_Core_Database_Sql_Select::OPERATOR_IN => $systemList))); } $orders = array( - "COUNT(*) / {$collection->quote(MAX_PLANET_IN_SYSTEM)}", - "1 + ABS(galaxy.galaxy - CEIL({$collection->quote(MAX_GALAXY_IN_WORLD)} / 2))", - "1 + 2 * ABS(galaxy.system - CEIL({$collection->quote(MAX_SYSTEM_IN_GALAXY)} / 2))", + "COUNT(*) / {$adapter->quote(Wootook::getGameConfig('engine/universe/positions'))}", + "1 + ABS(galaxy.galaxy - CEIL({$adapter->quote(Wootook::getGameConfig('engine/universe/galaxies'))} / 2))", + "1 + 2 * ABS(galaxy.system - CEIL({$adapter->quote(Wootook::getGameConfig('engine/universe/systems'))} / 2))", "RAND() / 1000", ); - $collection - ->order('((' . implode(') * (', $orders) . '))', 'ASC') - //->order("ABS(galaxy.system - CEIL({$collection->quote(MAX_SYSTEM_IN_GALAXY)} / 2))", 'ASC') - //->order("ABS(galaxy.galaxy - CEIL({$collection->quote(MAX_GALAXY_IN_WORLD)} / 2))", 'ASC') + $select + ->order(new Wootook_Core_Database_Sql_Placeholder_Expression('((' . implode(') * (', $orders) . '))'), 'ASC') + //->order("ABS(galaxy.system - CEIL({$collection->quote(Wootook::getGameConfig('engine/universe/systems'))} / 2))", 'ASC') + //->order("ABS(galaxy.galaxy - CEIL({$collection->quote(Wootook::getGameConfig('engine/universe/galaxies'))} / 2))", 'ASC') //->order("1.5 / COUNT(*)", 'ASC') ->order('RAND()', 'ASC'); - return $collection; + return $select; } private static function _cleanItemRanges(&$value, $index, $userdata = null) @@ -890,6 +904,32 @@ class Legacies_Empire_Model_Planet return intval($value); } + public static function planetChangeListener($eventData) + { + if (!isset($eventData['request']) || !$eventData['request'] instanceof Wootook_Core_Mvc_Controller_Request_Http) { + return; + } + + /** @var Wootook_Core_Mvc_Controller_Request_Http $request */ + $request = $eventData['request']; + if (!($planetId = $request->getQuery('___planet'))) { + return; + } + + $session = Wootook_Player_Model_Session::getSingleton(); + if (!$session->isLoggedIn()) { + return; + } + $planet = new Wootook_Empire_Model_Planet(); + $planet->load($planetId); + if (!$planet->getId()) { + return; + } + + $player = $session->getPlayer(); + $player->setCurrentPlanet($planet); + } + public static function planetUpdateListener($eventData) { if (isset($eventData['planet'])) { @@ -898,23 +938,29 @@ class Legacies_Empire_Model_Planet if (isset($eventData['time'])) { $time = $eventData['time']; } else { - $time = time(); + $time = new Wootook_Core_DateTime(); + } + if (!$time instanceof Wootook_Core_DateTime) { + $time = new Wootook_Core_DateTime($time); } - if ($planet === null || !$planet instanceof Legacies_Empire_Model_Planet) { + if ($planet === null || !$planet instanceof Wootook_Empire_Model_Planet) { return; } $planet->updateBuildingQueue($time); $planet->updateResources($time); - $planet->getShipyard()->updateQueue($time); + $planet->getShipyard()->updateQueue($time); // FIXME : update all plugin queues + $planet->getResearchLab()->updateQueue($time); // FIXME : update all plugin queues $planet->setLastUpdate($time); + + $planet->getPlayer()->save(); } } public function getResourceAmount($resourceType) { - $resources = Legacies_Empire_Model_Game_Resources::getSingleton(); + $resources = Wootook_Empire_Helper_Config_Resources::getSingleton(); $resourceConfig = $resources->getData($resourceType); if ($resourceConfig === null) { @@ -925,7 +971,7 @@ class Legacies_Empire_Model_Planet public function getResourceCap($resourceType) { - $resources = Legacies_Empire_Model_Game_Resources::getSingleton(); + $resources = Wootook_Empire_Helper_Config_Resources::getSingleton(); $resourceConfig = $resources->getData($resourceType); if ($resourceConfig === null) { @@ -945,4 +991,4 @@ class Legacies_Empire_Model_Planet } return false; } -} \ No newline at end of file +} diff --git a/includes/application/code/core/Legacies/Empire/Model/Planet/Builder.php b/src/application/code/core/Wootook/Empire/Model/Planet/Builder/Builder.php similarity index 55% rename from includes/application/code/core/Legacies/Empire/Model/Planet/Builder.php rename to src/application/code/core/Wootook/Empire/Model/Planet/Builder/Builder.php index 5c5bc60..eddf545 100644 --- a/includes/application/code/core/Legacies/Empire/Model/Planet/Builder.php +++ b/src/application/code/core/Wootook/Empire/Model/Planet/Builder/Builder.php @@ -1,11 +1,59 @@ + * 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 . + * + * --> 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. + * + */ -class Legacies_Empire_Model_Planet_Builder - extends Legacies_Empire_Model_BuilderAbstract +/** + * + * Enter description here ... + * @author Greg + * + */ +class Wootook_Empire_Model_Planet_Builder_Builder + extends Wootook_Empire_Model_BuilderAbstract { + const FIELD_SERIALIZED = 'b_building_id'; + + /** + * @var int + */ + protected $_maxLength = 0; + + /** + * @var float + */ + protected $_speedEnhancement = null; + public function init() { - $this->_unserializeQueue($this->_currentPlanet->getData('b_building_id')); + $this->_unserializeQueue($this->_currentPlanet->getData(self::FIELD_SERIALIZED)); + + $this->_maxLength = Wootook::getGameConfig('engine/core/buildings_queue_size'); } /** @@ -21,13 +69,13 @@ class Legacies_Empire_Model_Planet_Builder $level = $params['level']; if (!isset($params['created_at'])) { - $createdAt = time(); + $createdAt = new Wootook_Core_DateTime(); } else { $createdAt = $params['created_at']; } if (!isset($params['started_at'])) { - $startedAt = 0; + $startedAt = null; } else { $startedAt = $params['started_at']; } @@ -38,7 +86,7 @@ class Legacies_Empire_Model_Planet_Builder $updatedAt = $params['updated_at']; } - return new Legacies_Empire_Model_Planet_Builder_Item(array( + return new Wootook_Empire_Model_Planet_Builder_Item(array( 'building_id' => $buildingId, 'level' => $level, 'created_at' => $createdAt, @@ -47,44 +95,68 @@ class Legacies_Empire_Model_Planet_Builder )); } + public function getSpeedEnhancement() + { + if ($this->_speedEnhancement === null) { + $event = Wootook::dispatchEvent('planet.building.speed-enhancement', array( + 'player' => $this->_currentPlanet, + 'planet' => $this->_currentPlanet, + 'enhancement' => 1 + )); + + $this->_speedEnhancement = $event->getData('enhancement'); + } + + return $this->_speedEnhancement; + } + /** * Check if a building is actually buildable on the current planet, * depending on the technology and buildings requirements. * - * @param int $buildingId + * @param int|string $buildingId * @return bool */ public function checkAvailability($buildingId) { - $types = Legacies_Empire_Model_Game_Types::getSingleton(); + $types = Wootook_Empire_Helper_Config_Types::getSingleton(); - if ($types->is($buildingId, Legacies_Empire::TYPE_BUILDING)) { - return true; + if (!$types->is($buildingId, Legacies_Empire::TYPE_BUILDING)) { + return false; } - return false; + return parent::checkAvailability($buildingId); } + /** + * Returns the time needed to build $level of $buildingId + * + * @param int|string $buildingId + * @param int $level + */ public function getBuildingTime($buildingId, $level) { - $prices = Legacies_Empire_Model_Game_Prices::getSingleton(); - $gameConfig = Legacies_Core_Model_Config::getSingleton(); + $prices = Wootook_Empire_Helper_Config_Prices::getSingleton(); Math::setPrecision(50); $firstLevelTime = $prices[$buildingId][Legacies_Empire::BASE_BUILDING_TIME]; $partialLevelTime = Math::mul($firstLevelTime, Math::pow($prices[$buildingId][Legacies_Empire::RESOURCE_MULTIPLIER], $level)); $levelTime = Math::sub($partialLevelTime, $firstLevelTime); - $speedFactor = $gameConfig->getData('game_speed'); - $baseTime = $levelTime / $speedFactor * 3600; + $speedFactor = Wootook::getGameConfig('game/speed/general'); + + if ($speedFactor == null) { + $speedFactor = 1; + } + $baseTime = Math::div($levelTime, 3600 / ($speedFactor * $this->getSpeedEnhancement())); Math::setPrecision(); - $event = Legacies::dispatchEvent('planet.building.building-time', array( + $event = Wootook::dispatchEvent('planet.building.building-time', array( 'time' => $baseTime, 'base_time' => $baseTime, 'planet' => $this->_currentPlanet, - 'user' => $this->_currentUser, + 'player' => $this->_currentPlayer, 'building_id' => $buildingId, 'level' => $level )); @@ -92,10 +164,14 @@ class Legacies_Empire_Model_Planet_Builder return $event->getData('time'); } + /** + * (non-PHPdoc) + * @see Legacies_Empire_Model_BuilderAbstract::getResourcesNeeded() + */ public function getResourcesNeeded($buildingId, $level) { - $prices = Legacies_Empire_Model_Game_Prices::getSingleton(); - $resources = Legacies_Empire_Model_Game_Resources::getSingleton(); + $prices = Wootook_Empire_Helper_Config_Prices::getSingleton(); + $resources = Wootook_Empire_Helper_Config_Resources::getSingleton(); if (!isset($prices[$buildingId])) { return array(); @@ -117,54 +193,56 @@ class Legacies_Empire_Model_Planet_Builder /** * Update the contruction queue. * - * @return Legacies_Empire_Model_Planet_Building_Shipyard + * @return Wootook_Empire_Model_Planet_Builder_Builder */ - public function updateQueue($time) + public function updateQueue(Wootook_Core_DateTime $time) { - $fields = Legacies_Empire_Model_Game_FieldsAlias::getSingleton(); + $fields = Wootook_Empire_Helper_Config_FieldsAlias::getSingleton(); - $startingTime = $this->_currentPlanet->getData('b_building'); + $startingTime = clone $this->_currentPlanet->getData('b_building'); foreach ($this->getQueue() as $element) { $elementTime = $element->getData('started_at'); - if ($elementTime == 0) { - $element->setData('started_at', $startingTime); - $elementTime = $startingTime; + if ($elementTime === null) { + $element->setData('started_at', $startingTime->getTimestamp()); + $elementTime = $startingTime->getTimestamp(); } $level = $element->getData('level'); $buildingId = $element->getData('building_id'); $buildTime = $this->getBuildingTime($buildingId, $level); - $elapsedTime = $time - $elementTime; + $elapsedTime = $time->getTimestamp() - $elementTime; if ($elapsedTime >= $buildTime) { - $this->_currentPlanet->updateResources($time - $elapsedTime); - $this->_currentPlanet->setElement($buildingId, $level); - $this->_currentPlanet->updateResourceProduction($time - $elapsedTime); - $this->_currentPlanet->updateStorages($time - $elapsedTime); - $this->_currentPlanet->updateBuildingFields(); - $this->dequeue($element); - Legacies::dispatchEvent('planet.building.level-update', array( - 'time' => $time - $elapsedTime, + $currentTime = clone $startingTime; + $currentTime->add($elapsedTime); + + $this->_currentPlanet->updateResources($currentTime); + $this->_currentPlanet->setElement($buildingId, $level); + $this->_currentPlanet->updateStorages($currentTime); + $this->_currentPlanet->updateResourceProduction($currentTime); + $this->_currentPlanet->updateBuildingFields(); + + Wootook::dispatchEvent('planet.building.level-update', array( + 'time' => $currentTime, 'planet' => $this->_currentPlanet, - 'user' => $this->_currentUser, + 'player' => $this->_currentPlayer, 'building_id' => $buildingId, 'level' => $level )); - $startingTime = $elementTime + $buildTime; + $startingTime->set($elementTime + $buildTime); continue; } - $element->setData('updated_at', $time); break; } $this->_currentPlanet->setData('b_building_id', $this->serialize()); - $this->_currentPlanet->setData('b_building', $startingTime); + $this->_currentPlanet->setData('b_building', $startingTime->now()); return $this; } @@ -172,14 +250,17 @@ class Legacies_Empire_Model_Planet_Builder /** * Append items to build to the construction list * - * @param int $buildingId - * @param int|string $level - * @return Legacies_Empire_Model_Planet_Building_Shipyard + * @param int|string $buildingId + * @param int $level + * @return Wootook_Empire_Model_Planet_Builder_Builder */ - public function appendQueue($buildingId, $level, $time) + public function appendQueue($buildingId, $level, Wootook_Core_DateTime $time) { - $types = Legacies_Empire_Model_Game_Types::getSingleton(); - $resources = Legacies_Empire_Model_Game_Resources::getSingleton(); + if ($this->_maxLength > 0 && $this->count() >= $this->_maxLength) { + return $this; + } + + $types = Wootook_Empire_Helper_Config_Types::getSingleton(); if (!Math::isPositive($level)) { return $this; @@ -199,10 +280,14 @@ class Legacies_Empire_Model_Planet_Builder return $this; } + if ($this->count() == 0) { + $this->_currentPlanet->setData('b_building', $time); + } + $this->enqueue(array( 'building_id' => $buildingId, 'level' => $level, - 'created_at' => $time + 'created_at' => $time->getTimestamp() )); $this->_currentPlanet->setData('b_building_id', $this->serialize()); @@ -217,7 +302,7 @@ class Legacies_Empire_Model_Planet_Builder * Dequeues the first item to build to the construction list and removes all * its successors of the same type. * - * @return Legacies_Empire_Model_Planet_Builder + * @return Wootook_Empire_Model_Planet_Builder_Builder */ public function dequeueFirstItem() { @@ -232,7 +317,7 @@ class Legacies_Empire_Model_Planet_Builder * successors of the same type. * * @param string $itemId - * @return Legacies_Empire_Model_Planet_Builder + * @return Wootook_Empire_Model_Planet_Builder_Builder */ public function dequeueItem($itemId) { @@ -265,4 +350,4 @@ class Legacies_Empire_Model_Planet_Builder return $this; } -} \ No newline at end of file +} diff --git a/src/application/code/core/Wootook/Empire/Model/Planet/Builder/Item.php b/src/application/code/core/Wootook/Empire/Model/Planet/Builder/Item.php new file mode 100644 index 0000000..2e40fd2 --- /dev/null +++ b/src/application/code/core/Wootook/Empire/Model/Planet/Builder/Item.php @@ -0,0 +1,6 @@ +_currentPlayer = $currentPlayer; + $this->_currentPlanet = $currentPlanet; + + $this->registerNamespace('Legacies_Empire_Model_Planet_Building_'); + } + + protected function _load($className, $useSingleton, Array $constructorParams = array()) + { + $reflection = new ReflectionClass($className); + if ($useSingleton && $reflection->implementsInterface('Wootook_Core_Singleton')) { + $method = $reflection->getMethod('getSingleton'); + $method->invoke(); + } + + try { + return $reflection->newInstance($this->_currentPlanet, $this->_currentPlayer); + } catch (ReflectionException $e) { + return null; + } + } +} diff --git a/src/application/code/core/Wootook/Empire/Model/Planet/QueueInterface.php b/src/application/code/core/Wootook/Empire/Model/Planet/QueueInterface.php new file mode 100644 index 0000000..7bd2c42 --- /dev/null +++ b/src/application/code/core/Wootook/Empire/Model/Planet/QueueInterface.php @@ -0,0 +1,9 @@ +getElement(Legacies_Empire::ID_RESEARCH_COMBUSTION_DRIVE)); + } + + public function getActualSpeed(Wootook_Player_Model_Entity $player) + { + return $this->getBaseSpeed($player) * $this->getSpeedMultiplier($player); + } + + public function getActualConsumption(Wootook_Player_Model_Entity $player, $speed) + { + return $this->getBaseConsumption($player) * ($speed / 100) * $this->getSpeedMultiplier($player); + } +} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Empire/Model/Planet/ShipInterface.php b/src/application/code/core/Wootook/Empire/Model/Planet/ShipInterface.php new file mode 100644 index 0000000..dc9863a --- /dev/null +++ b/src/application/code/core/Wootook/Empire/Model/Planet/ShipInterface.php @@ -0,0 +1,11 @@ +_init('fleets', 'Wootook_Empire_Model_Fleet'); + } + + public function addPlanetToFilter(Wootook_Empire_Model_Planet $planet, $time = null) + { + if ($time === null) { + $time = new Wootook_Core_DateTime(); + } + $this->addFieldToFilter(null, array( + array('and' => array( + array('eq' => array('field' => 'fleet_start_galaxy', 'value' => $planet->getGalaxy())), + array('eq' => array('field' => 'fleet_start_system', 'value' => $planet->getSystem())), + array('eq' => array('field' => 'fleet_start_planet', 'value' => $planet->getPosition())), + array('eq' => array('field' => 'fleet_start_type', 'value' => $planet->getType())), + //array('date' => array('field' => 'fleet_start_time', 'value' => array('to' => $time))), + )), + array('and' => array( + array('eq' => array('field' => 'fleet_end_galaxy', 'value' => $planet->getGalaxy())), + array('eq' => array('field' => 'fleet_end_system', 'value' => $planet->getSystem())), + array('eq' => array('field' => 'fleet_end_planet', 'value' => $planet->getPosition())), + array('eq' => array('field' => 'fleet_end_type', 'value' => $planet->getType())), + //array('date' => array('field' => 'fleet_end_time', 'value' => array('to' => $time))), + )) + )); + + return $this; + } + + public function addIsVisibleToFilter(Wootook_Player_Model_Entity $player, $time = null) + { + if ($time === null) { + $time = new Wootook_Core_DateTime(); + } + $this->addFieldToFilter(null, array( + array('and' => array( + array('eq' => array('field' => 'fleet_owner', 'value' => $player->getId())), + array('date' => array('field' => 'fleet_start_time', 'value' => array('to' => $time))), + )), + array('and' => array( + array('eq' => array('field' => 'fleet_owner', 'value' => $player->getId())), + array('date' => array('field' => 'fleet_end_time', 'value' => array('to' => $time))), + )) + )); + + return $this; + } +} diff --git a/src/application/code/core/Wootook/Empire/Resource/Planet/Collection.php b/src/application/code/core/Wootook/Empire/Resource/Planet/Collection.php new file mode 100644 index 0000000..fc3e8ee --- /dev/null +++ b/src/application/code/core/Wootook/Empire/Resource/Planet/Collection.php @@ -0,0 +1,64 @@ +_init('planets', 'Wootook_Empire_Model_Planet'); + } + + public function addPlayerToFilter(Wootook_Player_Model_Entity $player) + { + $this->addFieldToFilter('id_owner', $player->getId()); + + return $this; + } + + public function addGalaxyToFilter($galaxy) + { + $this->addFieldToFilter('galaxy', $galaxy); + + return $this; + } + + public function addSystemToFilter($system) + { + $this->addFieldToFilter('system', $system); + + return $this; + } + + public function addPositionToFilter($position) + { + $this->addFieldToFilter('planet', $position); + + return $this; + } + + public function addTypeToFilter($type) + { + $this->addFieldToFilter('planet_type', $type); + + return $this; + } + + public function addCoordsToFilter($galaxy, $system = null, $position = null, $type = null) + { + $this->addGalaxyToFilter($galaxy); + + if ($system !== null) { + $this->addSystemToFilter($system); + + if ($position !== null) { + $this->addPositionToFilter($position); + + if ($type !== null) { + $this->addTypeToFilter($type); + } + } + } + + return $this; + } +} diff --git a/config.php b/src/application/code/core/Wootook/Empire/install/mysql5/.placeholder similarity index 100% rename from config.php rename to src/application/code/core/Wootook/Empire/install/mysql5/.placeholder diff --git a/src/application/code/core/Wootook/Exception.php b/src/application/code/core/Wootook/Exception.php new file mode 100644 index 0000000..c3b339a --- /dev/null +++ b/src/application/code/core/Wootook/Exception.php @@ -0,0 +1,37 @@ + + * 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 . + * + * --> 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 + * + */ +interface Wootook_Exception {} \ No newline at end of file diff --git a/includes/application/code/core/Legacies/Object.php b/src/application/code/core/Wootook/Object.php similarity index 53% rename from includes/application/code/core/Legacies/Object.php rename to src/application/code/core/Wootook/Object.php index 16d47c1..d3271ee 100644 --- a/includes/application/code/core/Legacies/Object.php +++ b/src/application/code/core/Wootook/Object.php @@ -1,6 +1,40 @@ + * 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 . + * + * --> 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. + * + */ -class Legacies_Object +/** + * + * Enter description here ... + * @author Greg + * + */ +class Wootook_Object implements ArrayAccess { protected $_data = array(); @@ -79,4 +113,4 @@ class Legacies_Object { return $this->unsetData($offset); } -} \ No newline at end of file +} diff --git a/src/application/code/core/Wootook/Player/Block/Overview.php b/src/application/code/core/Wootook/Player/Block/Overview.php new file mode 100644 index 0000000..bf689f0 --- /dev/null +++ b/src/application/code/core/Wootook/Player/Block/Overview.php @@ -0,0 +1,7 @@ +getSession()->isLoggedIn(); + } + + public function getPlayer() + { + return $this->getSession()->getPlayer(); + } + + public function getPlayerCount() + { + $collection = new Wootook_Player_Resource_Entity_Collection($this->getPlayer()->getReadConnection()); + $collection->addAuthlevelToFilter(array(LEVEL_ADMIN), true); + + return $collection->getSize(); + } + + public function getOnlinePlayerCount() + { + $collection = new Wootook_Player_Resource_Entity_Collection($this->getPlayer()->getReadConnection()); + $collection->addAuthlevelToFilter(array(LEVEL_ADMIN), true); + $collection->addIsOnlineToFilter(); + + return $collection->getSize(); + } +} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Player/Controller/AccountController.php b/src/application/code/core/Wootook/Player/Controller/AccountController.php new file mode 100644 index 0000000..824a20d --- /dev/null +++ b/src/application/code/core/Wootook/Player/Controller/AccountController.php @@ -0,0 +1,235 @@ + + * 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 . + * + * --> 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 Wootook_Player_Controller_AccountController + extends Wootook_Core_Mvc_Controller_Action +{ + public function loginAction() + { + $session = new Wootook_Player_Model_Session(); + if ($session->isLoggedIn()) { + $this->_redirect('*/overview'); + return; + } + + $this->loadLayout('player.login'); + $this->_prepareLayoutMessages(Wootook_Player_Model_Entity::SESSION_KEY); + $this->renderLayout(); + } + + public function loginPostAction() + { + $request = $this->getRequest(); + + if (!$request->isPost()) { + $this->_redirect('*/*/login'); + return; + } + + if ($request->getPost('username') === null || $request->getPost('password') === null) { + $this->_redirect('*/*/login'); + return; + } + + $session = new Wootook_Player_Model_Session(); + if ($session->isLoggedIn()) { + $this->_redirect('*/overview'); + return; + } + + $session->login($request->getPost('username'), $request->getPost('password'), (bool) $request->getPost('rememberme')); + + if ($session->isLoggedIn()) { + $this->_redirect('*/overview'); + return; + } else { + $this->_redirect('*/*/login'); + return; + } + } + + public function logoutAction() + { + $session = Wootook_Player_Model_Session::getSingleton(); + if ($session->isLoggedIn()) { + $session->logout(); + } else { + $this->_redirect('*/*/login'); + return; + } + + $this->_redirect(''); + } + + public function newAction() + { + $session = new Wootook_Player_Model_Session(); + if ($session->isLoggedIn()) { + $this->_redirect('*/overview'); + return; + } + + $this->loadLayout('player.registration'); + $this->_prepareLayoutMessages(Wootook_Player_Model_Entity::SESSION_KEY); + $this->renderLayout(); + } + + public function newPostAction() + { + $session = Wootook_Player_Model_Session::getSingleton(); + if ($session->isLoggedIn()) { + $this->_redirect('*/overview'); + return; + } + + $request = $this->getRequest(); + + if ($request->getPost('password') != $request->getPost('password_confirm')) { + $session->addError(Wootook::__('Passwords does not match. Please check your input.')); + $this->_redirect('*/*/new'); + return; + } + + if ($request->getPost('email') != $request->getPost('email_confirm')) { + $session->addError(Wootook::__('Both emails does not match. Please check your input.')); + $this->_redirect('*/*/new'); + return; + } + + try { + $user = Wootook_Player_Model_Entity::register($request->getPost('username'), $request->getPost('email'), $request->getPost('password')); + } catch (Wootook_Empire_Exception_RuntimeException $e) { + $session->addError(Wootook::__('Could not create user: %s', $e->getMessage())); + $this->_redirect('*/*/new'); + return; + } + + if (!$user || !$user->getId()) { + $session->addError(Wootook::__('Could not create user. Please contact the game administrator for more information.')); + $this->_redirect('*/*/new'); + return; + } + + $session->setLoggedIn($user); + if ($request->getPost('planet_name') != '') { + $user->getHomePlanet()->setName($request->getPost('planet_name'))->save(); + } else { + $user->getHomePlanet()->setName(Wootook::__('Planet'))->save(); + } + + $this->_redirect('*/overview'); + } + + public function lostPasswordAction() + { + $session = new Wootook_Player_Model_Session(); + if ($session->isLoggedIn()) { + $this->_redirect('*/overview'); + return; + } + + $this->loadLayout('player.lost-password'); + $this->_prepareLayoutMessages(Wootook_Player_Model_Entity::SESSION_KEY); + $this->renderLayout(); + } + + /** + * Send new password by mail + */ + public function lostPasswordPostAction() + { + $session = new Wootook_Player_Model_Session(); + if ($session->isLoggedIn()) { + $this->_redirect('*/overview'); + return; + } + + if (!$this->getRequest()->isPost()) { + $this->_redirect('*/*/lost-password'); + return; + } + + $email = $this->getRequest()->getPost('email'); + $username = $this->getRequest()->getPost('username'); + + $player = new Wootook_Player_Model_Entity(); + $player->loadByEmail($email); + + if (!$player->getId() || strtolower($player->getUsername()) != strtolower(trim($username))) { + $session->addError(Wootook::__('The information you entered could not be found.')); + $this->_redirect('*/*/lost-password'); + return; + } + + $chars = array( + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', + 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', + 'f', 'g', 'h', 'j', 'k', 'm', 'n', 'p', 'q', 'r', 's', 't', 'u', 'v', + 'w', 'x', 'y', 'z', '2', '3', '4', '5', '6', '7', '8', '9' + ); + + shuffle($chars); + $passwordChars = array_slice($chars, 0, 10); + $newPassword = implode($passwordChars); + + $player->setPassword($newPassword)->save(); + + try { + $mailer = new Wootook_Core_Email(); + $mailer->send( + array($player->getEmail() => $player->getUsername()), + array('contact@wootook.org' => 'Wootook'), + Wootook::__('Your new password'), + Wootook::__('Your new password is %s', $newPassword)); + } catch (Wootook_Core_Exception_RuntimeException $e) { + Wootook_Player_Model_Session::getSingleton() + ->addError($e->getMessage()); + + $this->_redirect('*/*/lost-password'); + return; + } + + $this->_redirect('*/*/login'); + } + + public function editAction() + { + } + + public function optionsAction() + { + } +} diff --git a/src/application/code/core/Wootook/Player/Controller/OverviewController.php b/src/application/code/core/Wootook/Player/Controller/OverviewController.php new file mode 100644 index 0000000..97db0cf --- /dev/null +++ b/src/application/code/core/Wootook/Player/Controller/OverviewController.php @@ -0,0 +1,12 @@ +loadLayout('player.overview'); + $this->_prepareLayoutMessages(Wootook_Player_Model_Entity::SESSION_KEY); + $this->renderLayout(); + } +} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Player/Exception.php b/src/application/code/core/Wootook/Player/Exception.php new file mode 100644 index 0000000..6a51351 --- /dev/null +++ b/src/application/code/core/Wootook/Player/Exception.php @@ -0,0 +1,3 @@ += 50300) { + parent::__construct($message, $code, $previous); + } else { + parent::__construct($message, $code); + $this->_previous = $previous; + } + } + + public function __call($method, $params) + { + if (strtolower($method) == 'getprevious') { + return $this->_previous; + } + } +} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Player/Exception/RuntimeException.php b/src/application/code/core/Wootook/Player/Exception/RuntimeException.php new file mode 100644 index 0000000..e270f3f --- /dev/null +++ b/src/application/code/core/Wootook/Player/Exception/RuntimeException.php @@ -0,0 +1,25 @@ += 50300) { + parent::__construct($message, $code, $previous); + } else { + parent::__construct($message, $code); + $this->_previous = $previous; + } + } + + public function __call($method, $params) + { + if (strtolower($method) == 'getprevious') { + return $this->_previous; + } + } +} \ No newline at end of file diff --git a/src/application/code/core/Wootook/Player/Exception/Session.php b/src/application/code/core/Wootook/Player/Exception/Session.php new file mode 100644 index 0000000..b546e5d --- /dev/null +++ b/src/application/code/core/Wootook/Player/Exception/Session.php @@ -0,0 +1,7 @@ +getData('username'); + } + + public function getEmail() + { + return $this->getData('email'); + } + + public function loadByEmail($email) + { + return $this->load($email, 'email'); + } + + public function setPassword($newPassword) + { + return $this->setData('password', $this->hash($newPassword)); + } + + public static function hash($password, $salt = null) + { + if ($salt === null) { + return call_user_func(self::$hashCallback, ($password)); + } + + return call_user_func(self::$hashCallback, ($password . $salt)); + } + + protected function _init() + { + $this->setIdFieldName('id'); + $this->setTableName('users'); + + $this->getDataMapper() + ->addRule('onlinetime', 'date-time') + ->addRule('urlaubs_until', 'date-time') + ->addRule('register_time', 'date-time') + ; + } + + public function updateActivity() + { + $this + ->setData('current_page', $_SERVER['REQUEST_URI']) + ->setData('user_lastip', $_SERVER['REMOTE_ADDR']) + ->setData('user_agent', $_SERVER['HTTP_USER_AGENT']) + ->setData('onlinetime', new Wootook_Core_DateTime()) + ->save() + ; + return $this; + } + + public static function register($username, $email, $password) + { + try { + $request = Wootook::getRequest(); + $player = new self(array( + 'username' => $username, + 'password' => md5($password), + 'email' => $email, + 'email_2' => $email, + + 'register_time' => new Wootook_Core_DateTime(), + 'onlinetime' => new Wootook_Core_DateTime(), + 'ip_at_reg' => $request->getServer('REMOTE_ADDR'), + 'user_lastip' => $request->getServer('REMOTE_ADDR'), + 'user_agent' => $request->getServer('HTTP_USER_AGENT') + )); + + //$player->getWriteConnection()->beginTransaction(); + + $player->save(); + + $select = Wootook_Empire_Model_Planet::searchMostFreeSystems(); + $select->limit(1); + + try { + $statement = $select->prepare(); + if (!$statement->execute()) { + throw new Wootook_Empire_Exception_RuntimeException('No more planet to colonize!'); // Oops, no more free place + } + } catch (Wootook_Core_Exception_Database_Error $e) { + Wootook_Core_ErrorProfiler::getSingleton()->addException($e); + //$this->getWriteConnection()->rollback(); + return null; + } + + $systemInfo = $statement->fetch(); + if ($systemInfo['count'] >= Wootook::getGameConfig('engine/universe/positions')) { + throw new Wootook_Empire_Exception_RuntimeException('No more planet to colonize!'); // Oops, no more free place + } + + $collection = new Wootook_Empire_Resource_Planet_Collection($player->getReadConnection()); + $collection->addTypeToFilter(Wootook_Empire_Model_Planet::TYPE_PLANET) + ->addFieldToFilter('galaxy', $systemInfo['galaxy']) + ->addFieldToFilter('system', $systemInfo['system']) + ; + + $positions = range(1, Wootook::getGameConfig('engine/universe/positions')); + foreach ($collection as $planet) { + $key = array_search($planet->getData('position'), $positions); + if ($key !== false) { + unset($positions[$key]); + } + } + $key = array_rand($positions, 1); + $finalPosition = $positions[$key]; + + $planet = $player->createNewPlanet( + $systemInfo['galaxy'], + $systemInfo['system'], + $finalPosition, + Wootook_Empire_Model_Planet::TYPE_PLANET, + Wootook::__('Planet'), + Wootook::getGameConfig('resource/initial/fields') + ); + + $player + ->setData('id_planet', $planet->getId()) + ->setData('current_planet', $planet->getId()) + ->setData('galaxy', $planet->getGalaxy()) + ->setData('system', $planet->getSystem()) + ->setData('planet', $planet->getPosition()) + ; + + Wootook::dispatchEvent('player.init', array( + 'player' => $player + )); + + $player->save(); + } catch (Wootook_Core_Exception_DataAccessException $e) { + //$player->getWriteConnection()->rollback(); + $session = Wootook_Core_Model_Session::factory(Wootook_Player_Model_Entity::SESSION_KEY); + + Wootook_Core_ErrorProfiler::getSingleton()->addException($e); + $session->addError($e->getMessage()); + return null; + } catch (Wootook_Empire_Exception_RuntimeException $e) { + //$player->getWriteConnection()->rollback(); + $session = Wootook_Core_Model_Session::factory(Wootook_Player_Model_Entity::SESSION_KEY); + + Wootook_Core_ErrorProfiler::getSingleton()->addException($e); + $session->addError($e->getMessage()); + return null; + } + //$player->getWriteConnection()->commit(); + + return $player; + } + + public function createNewPlanet($galaxy, $system, $position, $type, $name, $size = null) + { + if ($size === null) { + $size = Wootook::getGameConfig('planet/initial/fields'); + } + if ($size === null) { + $size = 200; + } + + $now = new Wootook_Core_DateTime(); + $planet = new Wootook_Empire_Model_Planet(array(), $this); + $planet + ->setData('name', $name) + ->setData('galaxy', $galaxy) + ->setData('system', $system) + ->setData('planet', $position) + ->setData('planet_type', $type) + ->setData('field_max', $size) + ->setData('diameter', pow($size, 2) + mt_rand(0, $size * $position)) + ->setData('field_current', 0) + ->setData('last_update', $now) + ->setData('b_tech', $now) + ->setData('b_hangar', $now) + ->setData('b_building', $now) + ; + + $resourceList = Wootook_Empire_Helper_Config_Resources::getSingleton(); + $resourceConfig = Wootook::getGameConfig('resources/initial'); + foreach ($resourceList as $resource => $resourceData) { + if ($resourceData['field'] === null || !isset($resourceConfig[$resource])) { + continue; + } + $planet->setData($resourceData['field'], $resourceConfig[$resource]); + } + + $resourceConfig = Wootook::getGameConfig('resources/base-income'); + foreach ($resourceList as $resource => $resourceData) { + if ($resourceData['production_field'] === null || !isset($resourceConfig[$resource])) { + continue; + } + $planet->setData($resourceData['production_field'], $resourceConfig[$resource]); + } + + $planet->updateStorages($now); + $planet->updateBuildingQueue($now); + $planet->updateResourceProduction($now); + $planet->updateResources($now); + + $planet->save(); + + if ($planet->isPlanet()) { + $galaxy = new Wootook_Empire_Model_Galaxy_Position(); + $galaxy + ->setData('galaxy', $planet->getGalaxy()) + ->setData('system', $planet->getSystem()) + ->setData('planet', $planet->getPosition()) + ->setData('id_planet', $planet->getId()) + ->save() + ; + } + + Wootook::dispatchEvent('planet.init', array( + 'planet' => $planet, + 'player' => $this + )); + + $planet->save(); + + return $planet; + } + + /** + * + * Enter description here ... + * @param int|Wootook_Empire_Model_Planet $planet + */ + public function updateCurrentPlanet($planet) + { + if (!$planet instanceof Wootook_Empire_Model_Planet) { + $planetCollection = $this->_preparePlanetCollection()->where('id=:id'); + + $planetCollection->load(array( + 'id' => $planet, + 'user' => $this->getId() + )); + + if ($planetCollection->count() !== 1) { + return $this; + } + + $planet = $planetCollection->current(); + } + + if ($planet->getPlayerId() != $this->getId() || $planet->isDestroyed()) { + return $this; + } + + $this->setData('current_planet', $planet->getId())->save(); + + return $this; + } + + /** + * + * Enter description here ... + * @param Wootook_Empire_Model_Planet $planet + */ + public function setHomePlanet(Wootook_Empire_Model_Planet $planet) + { + if ($planet->getPlayerId() != $this->getId() || $planet->isDestroyed()) { + return $this; + } + + $this->setData('id_planet', $planet->getId()); + $this->_homePlanet = $planet; + + return $this; + } + + /** + * + * Enter description here ... + * @param Wootook_Empire_Model_Planet $planet + */ + public function setCurrentPlanet(Wootook_Empire_Model_Planet $planet) + { + if ($planet->getPlayerId() != $this->getId() || $planet->isDestroyed()) { + return $this; + } + + $this->setData('current_planet', $planet->getId()); + $this->_currentPlanet = $planet; + + return $this; + } + + /** + * + * Enter description here ... + * @return Wootook_Empire_Model_Planet + */ + public function getHomePlanet() + { + if ($this->_homePlanet === null) { + $planetId = $this->getData('id_planet'); + if (!$planetId) { + return null; + } + + $planet = Wootook_Empire_Model_Planet::factory($planetId); + + if ($planet->getPlayerId() != $this->getId() || $planet->isDestroyed()) { + return null; + } + + $this->_homePlanet = $planet; + } + + return $planet; + } + + /** + * + * Enter description here ... + * @return Wootook_Empire_Model_Planet + */ + public function getCurrentPlanet() + { + if ($this->_currentPlanet === null) { + $planetId = $this->getData('current_planet'); + + if (!$planetId) { + $this->_currentPlanet = $this->getHomePlanet(); + if ($this->_currentPlanet === null) { + return null; + } + $this->setData('current_planet', $this->_currentPlanet->getId())->save(); + + return $this->_currentPlanet; + } + + $planet = Wootook_Empire_Model_Planet::factory($planetId); + + if ($planet->getPlayerId() != $this->getId() || $planet->isDestroyed()) { + $this->_currentPlanet = $this->getHomePlanet(); + $this->setData('current_planet', $this->_currentPlanet->getId())->save(); + + return $this->_currentPlanet; + } + + $this->_currentPlanet = $planet; + } + + return $this->_currentPlanet; + } + + protected function _preparePlanetCollection() + { + $planetCollection = new Wootook_Empire_Resource_Planet_Collection($this->getReadConnection()); + $planetCollection->addPlayerToFilter($this); + + $order = ($this->getData('planet_sort_order') == 1) ? 'DESC' : 'ASC'; + + switch ($this->getData('planet_sort')) { + case self::PLANET_SORT_POSITION: + $planetCollection + ->addOrderBy('galaxy', $order) + ->addOrderBy('system', $order) + ->addOrderBy('planet', $order) + ->addOrderBy('planet_type', $order) + ; + break; + + case self::PLANET_SORT_NAME: + $planetCollection->addOrderBy('name', $order); + break; + + case self::PLANET_SORT_DATE: + default: + $planetCollection->addOrderBy('id', $order); + break; + } + return $planetCollection; + } + + public function getPlanetCollection(Array $typeFilter = array()) + { + $planetCollection = $this->_preparePlanetCollection(); + + if (!empty($typeFilter)) { + $planetCollection->addFieldToFilter('planet_type', array(array('in' => $typeFilter))); + } + + return $planetCollection; + } + + protected function _prepareFleetCollection($collection) + { + $collection->addFieldToFilter('fleet_owner', $this->getId()); + + return $this; + } + + /** + * Returns all the flying fleets owned by the player + * + * @return Wootook_Empire_Resource_Fleet_Collection + */ + public function getFleets() + { + $collection = new Wootook_Empire_Resource_Fleet_Collection($this->getReadConnection()); + + $this->_prepareFleetCollection($collection); + + return $collection; + } + + /** + * Counts all the flying fleets owned by the player + * + * @return mixed + */ + public function getFleetCount() + { + return $this->getFleets()->getSize(); + } + + /** + * Returns all the visible fleets + * + * @param null $time + * @return Wootook_Empire_Resource_Fleet_Collection + */ + public function getVisibleFleets($time = null) + { + $collection = new Wootook_Empire_Resource_Fleet_Collection($this->getReadConnection()); + + if ($time === null) { + $time = new Wootook_Core_DateTime(); + } + $collection->addIsVisibleToFilter($this, $time); + + return $collection; + } + + /** + * Returns all the visible fleets + * + * @param null $time + * @return Wootook_Empire_Resource_Fleet_Collection + * @deprecated + * @alias getVisibleFleets + */ + public function getFleetCollection($time = null) + { + return $this->getVisibleFleets($time); + } + + public function getElement($elementId) + { + $fields = Wootook_Empire_Helper_Config_FieldsAlias::getSingleton(); + + return $this->getData($fields[$elementId]); + } + + public function setElement($elementId, $level) + { + $fields = Wootook_Empire_Helper_Config_FieldsAlias::getSingleton(); + + return $this->setData($fields[$elementId], $level); + } + + public function hasElement($elementId, $levelRequired = 0) + { + $fields = Wootook_Empire_Helper_Config_FieldsAlias::getSingleton(); + + return $this->hasData($fields[$elementId]) && Math::comp($this->getElement($elementId), $levelRequired) > 0; + } + + public function getSkinPath($default = null) + { + if ($path = $this->getData('dpath')) { + return $path; + } + return $default; + } + + public function setSkinPath($path) + { + $this->setData('dpath', $path); + + return $this; + } + + public function checkPassword($password) + { + if (self::hash($password) == $this->getData('password')) { + return true; + } + return false; + } + + public function getNewMessagesCount() + { + $messageCollection = new Wootook_Player_Resource_Message_Collection($this->getReadConnection()); + $messageCollection->addPlayerToFilter($this)->addUnreadToFilter(); + + $newMessages = null; + if (($count = $messageCollection->getSize()) > 0) { + return $count; + } + return null; + } + + public static function layoutPrepareAfterListener($eventData) + { + $player = Wootook_Player_Model_Session::getSingleton()->getPlayer(); + if ($player === null || !$player->getId() || !in_array($player->getData('authlevel'), array(LEVEL_ADMIN, LEVEL_OPERATOR, LEVEL_MODERATOR))) { + return; + } + + if (!isset($eventData['layout']) || !$eventData['layout'] instanceof Wootook_Core_Model_Layout) { + return; + } + $layout = $eventData['layout']; + $navigation = $layout->getBlock('navigation'); + + if ($navigation === null) { + return; + } + + if (!defined('IN_ADMIN')) { + $navigation->addLink('tools/admin', 'Admin Panel', 'Admin Panel', 'admin/overview.php', array(), array('admin')); + } else { + $navigation->addLink('tools/back', 'Go back to the game', 'Go back to the game', 'overview.php', array(), array('admin')); + } + } + + public function isBanned() + { + return $this->getData('bana') ? true : false; + } + + public function isVacation() + { + return $this->getData('urlaubs_modus') ? true : false; + } + + public function getVacationEndDate() + { + return $this->getData('urlaubs_until'); + } + + public function getLastLoginDate() + { + return $this->getData('onlinetime'); + } + + public function setVacation($active = true) + { + $this->setData('urlaubs_modus', $active); + + foreach ($this->getPlanetCollection() as $planet) { + $planet->updateResources(); + $planet->updateResourceProduction(); + $planet->save(); + } + + if ($active) { + $this->setData('urlaubs_until', time() + Wootook::getConfig('engine/options/vacation-min-time')); + } else { + $this->setData('urlaubs_until', null); + } + $this->save(); + + return $this; + } + + public function isAuthorized($levels = array(LEVEL_ADMIN)) + { + if (!is_array($levels)) { + $levels = array($levels); + } + + if (in_array($this->getData('authlevel'), $levels)) { + return true; + } + return false; + } +} diff --git a/includes/application/code/core/Legacies/Empire/Model/User/Message.php b/src/application/code/core/Wootook/Player/Model/Message.php similarity index 59% rename from includes/application/code/core/Legacies/Empire/Model/User/Message.php rename to src/application/code/core/Wootook/Player/Model/Message.php index f3ea9a4..0002d94 100644 --- a/includes/application/code/core/Legacies/Empire/Model/User/Message.php +++ b/src/application/code/core/Wootook/Player/Model/Message.php @@ -1,14 +1,14 @@ _tableName = 'messages'; $this->_idFieldNames = array('message_id', 'message_owner'); } -} \ No newline at end of file +} diff --git a/src/application/code/core/Wootook/Player/Model/Session.php b/src/application/code/core/Wootook/Player/Model/Session.php new file mode 100644 index 0000000..9ae226c --- /dev/null +++ b/src/application/code/core/Wootook/Player/Model/Session.php @@ -0,0 +1,205 @@ +getData('player_id'); + } + + public function setPlayer(Wootook_Player_Model_Entity $player) + { + $this->_player = $player; + $this->setData('player_id', $player->getId()); + + return $this; + } + + /** + * + * Enter description here ... + * @return Wootook_Player_Model_Entity + */ + public function getPlayer() + { + if ($this->_player === null) { + $this->_player = new Wootook_Player_Model_Entity(); + + try { + if ($this->hasData('player_id')) { + $id = intval($this->getData('player_id')); + } else if (Wootook::getRequest() !== null && + ($cookieData = Wootook::getRequest()->getCookie($this->_player->getCookieName())) !== null && + is_array($cookieData)) { + + $adapter = $this->_player->getReadConnection(); + $select = $adapter->select(array('user' => $adapter->getTable('users'))); + + $select + ->column('id') + ->where('id', isset($cookieData['id']) ? intval($cookieData['id']) : 0) + ->where(new Wootook_Core_Database_Sql_Placeholder_Expression( + ':key=CONCAT((@salt:=MID(:key, 0, 4)), SHA1(CONCAT(user.username, user.password, @salt)))', + array('key' => isset($cookieData['key']) ? $adapter->quote($cookieData['key']) : null))) + ; + try { + $statement = $adapter->prepare($select); + if (!$statement->execute($cookieData) || $statement->rowCount() <= 0) { + throw new Wootook_Player_Exception_Session('Your session has expired, please login.'); + } + + $id = $statement->fetchColumn(); + } catch (Wootook_Core_Exception_Database_AdapterError $e) { + throw new Wootook_Core_Exception_DataAccessException('Session error.', null, $e); + } catch (Wootook_Core_Exception_Database_StatementError $e) { + throw new Wootook_Core_Exception_DataAccessException('Session error.', null, $e); + } + } else { + //throw new Wootook_Player_Exception_Session('Your session has expired, please login.'); + return $this->_player; + } + } catch (Wootook_Player_Exception_Session $e) { + $this->addError($e->getMessage()); + return $this->_player; + } + + try { + $this->_player->load($id); + } catch (Wootook_Core_Exception_DataAccessException $e) { + $this->addError('Session error.'); + return $this->_player; + } + $this->_player->updateActivity(); + } + return $this->_player; + } + + public function isLoggedIn() + { + if ($this->getPlayerId()) { + return true; + } + return false; + } + + public function logout() + { + $this->clearData(); + + return $this; + } + + public function login($username, $password, $remember = false) + { + try { + if ($this->_player === null) { + $this->_player = new Wootook_Player_Model_Entity(); + } + + if ($this->_player->getId()) { + return $this->_player; + } + $adapter = $this->_player->getReadConnection(); + $select = $adapter->select(array('user' => $adapter->getTable($this->_player->getTableName()))); + + $passwordHash = $this->_player->hash($password); + $select + ->column(array( + 'id' => 'user.id', + 'username' => 'user.username', + 'password_hash' => 'user.password', + 'is_banned' => 'user.banaday', + 'login_rememberme' => new Wootook_Core_Database_Sql_Placeholder_Expression('CONCAT((@salt:=MID(MD5(RAND()), 0, 4)), SHA1(CONCAT(user.username, user.password, @salt)))'), + 'login_success' => new Wootook_Core_Database_Sql_Placeholder_Expression("(CASE WHEN user.password={$adapter->quote($passwordHash)} THEN 1 ELSE 0 END)") + )) + ->where(new Wootook_Core_Database_Sql_Placeholder_Expression('user.username=:username', array('username' => $username))); + + $statement = $adapter->prepare($select); + if (!$statement->execute()) { + $this->addError(Wootook::__('No such user.')); + return $this->_player; + } + } catch (Wootook_Core_Exception_Database_StatementError $e) { + Wootook_Core_ErrorProfiler::getSingleton()->exceptionManager($e); + $this->addError(Wootook::__('No such user.')); + return $this->_player; + } catch (Wootook_Core_Exception_DataAccessException $e) { + Wootook_Core_ErrorProfiler::getSingleton()->exceptionManager($e); + $this->addError(Wootook::__('No such user.')); + return $this->_player; + } + + $login = $statement->fetch(); + + if (intval($login['login_success']) == 1) { + $this->_player->load($login['id']); + + if ($login['is_banned'] != 0) { + if ($login['is_banned'] <= time()) { + $this->_player->setData('banaday', 0) + ->setData('bana', 0) + ->setData('urlaubs_modus', 0) + ->setData('urlaubs_until', null) + ->save() + ; + } else { + $this->addError(Wootook::__('You were banned, please contact admin for more information.')); + return $this->_player; + } + } + + if (isset($_POST["rememberme"]) && Wootook::getResponse() !== null) { + Wootook::getResponse()->setCookie( + $this->_player->getCookieName(), + array('id' => $this->_player->getId(), 'key' => $login['login_rememberme']), + $this->_player->getCookieLifetime(), + $this->_player->getCookiePath(), + $this->_player->getCookieDomain() + ); + } + + $this->setLoggedIn($this->_player); + return $this->_player; + } + + $this->addError(Wootook::__('Your username or credential is invalid, please check your input.')); + return $this->_player; + } + + public function setLoggedIn(Wootook_Player_Model_Entity $player) + { + $player->updateActivity(); + + $this->setData('player_id', intval($player->getId())); + + return $this; + } +} diff --git a/src/application/code/core/Wootook/Player/Mvc/Controller/Registered.php b/src/application/code/core/Wootook/Player/Mvc/Controller/Registered.php new file mode 100644 index 0000000..3374acf --- /dev/null +++ b/src/application/code/core/Wootook/Player/Mvc/Controller/Registered.php @@ -0,0 +1,32 @@ +getSession()->getPlayer(); + } + + public function getCurrentPlanet() + { + return $this->getPlayer()->getCurrentPlanet(); + } + + public function preDispatch() + { + if (!$this->getSession()->isLoggedIn()) { + $this->_redirectLogin(); + } + } + + protected function _redirectLogin() + { + return $this->_redirect('player/account/login'); + } +} diff --git a/src/application/code/core/Wootook/Player/Resource/Entity/Collection.php b/src/application/code/core/Wootook/Player/Resource/Entity/Collection.php new file mode 100644 index 0000000..3e2c1bc --- /dev/null +++ b/src/application/code/core/Wootook/Player/Resource/Entity/Collection.php @@ -0,0 +1,37 @@ +_init('users', 'Wootook_Player_Model_Entity'); + } + + public function addAuthlevelToFilter(Array $levels, $exclude = false) + { + if ($exclude === true) { + $this->addFieldToFilter('authlevel', array(array('nin' => $levels))); + } else { + $this->addFieldToFilter('authlevel', array(array('in' => $levels))); + } + + return $this; + } + + public function addIsOnlineToFilter($onlineTime = 900) + { + $onlineTime = (int) $onlineTime; + + $date = new Wootook_Core_DateTime(); + $date->sub($onlineTime, Wootook_Core_DateTime::TIMESTAMP); + + if ($onlineTime > 0) { + $this->addFieldToFilter('onlinetime', array(array( + Wootook_Core_Database_Sql_Select::OPERATOR_DATE => array('from' => $date) + ))); + } + + return $this; + } +} diff --git a/src/application/code/core/Wootook/Player/Resource/Message/Collection.php b/src/application/code/core/Wootook/Player/Resource/Message/Collection.php new file mode 100644 index 0000000..e6d9198 --- /dev/null +++ b/src/application/code/core/Wootook/Player/Resource/Message/Collection.php @@ -0,0 +1,24 @@ +_init('messages', 'Wootook_Player_Model_Message'); + } + + public function addPlayerToFilter(Wootook_Player_Model_Entity $player) + { + $this->addFieldToFilter('message_owner', $player->getId()); + + return $this; + } + + public function addUnreadToFilter() + { + $this->addFieldToFilter('message_read_at', array(array('lteq' => 0))); + + return $this; + } +} diff --git a/includes/application/design/scripts/empire/overview/fleet/item.phtml b/src/application/code/core/Wootook/Server/Mvc/Dispatcher.php similarity index 100% rename from includes/application/design/scripts/empire/overview/fleet/item.phtml rename to src/application/code/core/Wootook/Server/Mvc/Dispatcher.php diff --git a/includes/application/code/libraries/Math.php b/src/application/code/libraries/Math.php similarity index 69% rename from includes/application/code/libraries/Math.php rename to src/application/code/libraries/Math.php index bd77353..f429008 100644 --- a/includes/application/code/libraries/Math.php +++ b/src/application/code/libraries/Math.php @@ -1,5 +1,38 @@ + * 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 . + * + * --> 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 Math { const DEFAULT_PRECISTION = 0; diff --git a/includes/application/code/libraries/Math/Bcmath.php b/src/application/code/libraries/Math/Bcmath.php similarity index 71% rename from includes/application/code/libraries/Math/Bcmath.php rename to src/application/code/libraries/Math/Bcmath.php index 8c4c592..e5368c6 100644 --- a/includes/application/code/libraries/Math/Bcmath.php +++ b/src/application/code/libraries/Math/Bcmath.php @@ -1,4 +1,38 @@ + * 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 . + * + * --> 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 Math_Bcmath { diff --git a/src/application/code/libraries/Math/Native.php b/src/application/code/libraries/Math/Native.php new file mode 100644 index 0000000..0958113 --- /dev/null +++ b/src/application/code/libraries/Math/Native.php @@ -0,0 +1,97 @@ + + * 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 . + * + * --> 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 Math_Native +{ + public function setPrecision($precision) + { + } + + public function add($a, $b) + { + return $a + $b; + } + + public function mul($a, $b) + { + return $a * $b; + } + + public function sub($a, $b) + { + return $a - $b; + } + + public function div($a, $b) + { + return $a / $b; + } + + public function mod($a, $b) + { + return $a % $b; + } + + public function pow($a, $b) + { + return pow($a, $b); + } + + public function comp($a, $b) + { + return ($a > $b) ? 1 : (($a < $b) ? -1 : 0); + } + + public function ceil($x) + { + return ceil($x); + } + + public function floor($x) + { + return floor($x); + } + + public function round($range = 0) + { + return round($x, $range); + } + + public function render($a) + { + return number_format($a, 0, ',', '.'); + } +} \ No newline at end of file diff --git a/src/application/code/libraries/Wildfire/Stream.php b/src/application/code/libraries/Wildfire/Stream.php new file mode 100644 index 0000000..9966a44 --- /dev/null +++ b/src/application/code/libraries/Wildfire/Stream.php @@ -0,0 +1,1753 @@ + + * @license http://www.opensource.org/licenses/bsd-license.php + * @package FirePHPCore + */ + + +/** + * Sends the given data to the FirePHP Firefox Extension. + * The data can be displayed in the Firebug Console or in the + * "Server" request tab. + * + * For more information see: http://www.firephp.org/ + * + * @copyright Copyright (C) 2007-2009 Christoph Dorn + * @author Christoph Dorn + * @license http://www.opensource.org/licenses/bsd-license.php + * @package FirePHPCore + */ +class Wildfire_Stream { + + /** + * FirePHP version + * + * @var string + */ + const VERSION = '0.3'; // @pinf replace '0.3' with '%%package.version%%' + + /** + * Firebug LOG level + * + * Logs a message to firebug console. + * + * @var string + */ + const LOG = 'LOG'; + + /** + * Firebug INFO level + * + * Logs a message to firebug console and displays an info icon before the message. + * + * @var string + */ + const INFO = 'INFO'; + + /** + * Firebug WARN level + * + * Logs a message to firebug console, displays an warning icon before the message and colors the line turquoise. + * + * @var string + */ + const WARN = 'WARN'; + + /** + * Firebug ERROR level + * + * Logs a message to firebug console, displays an error icon before the message and colors the line yellow. Also increments the firebug error count. + * + * @var string + */ + const ERROR = 'ERROR'; + + /** + * Dumps a variable to firebug's server panel + * + * @var string + */ + const DUMP = 'DUMP'; + + /** + * Displays a stack trace in firebug console + * + * @var string + */ + const TRACE = 'TRACE'; + + /** + * Displays an exception in firebug console + * + * Increments the firebug error count. + * + * @var string + */ + const EXCEPTION = 'EXCEPTION'; + + /** + * Displays an table in firebug console + * + * @var string + */ + const TABLE = 'TABLE'; + + /** + * Starts a group in firebug console + * + * @var string + */ + const GROUP_START = 'GROUP_START'; + + /** + * Ends a group in firebug console + * + * @var string + */ + const GROUP_END = 'GROUP_END'; + + /** + * Singleton instance of FirePHP + * + * @var FirePHP + */ + protected static $instance = null; + + /** + * Flag whether we are logging from within the exception handler + * + * @var boolean + */ + protected $inExceptionHandler = false; + + /** + * Flag whether to throw PHP errors that have been converted to ErrorExceptions + * + * @var boolean + */ + protected $throwErrorExceptions = true; + + /** + * Flag whether to convert PHP assertion errors to Exceptions + * + * @var boolean + */ + protected $convertAssertionErrorsToExceptions = true; + + /** + * Flag whether to throw PHP assertion errors that have been converted to Exceptions + * + * @var boolean + */ + protected $throwAssertionExceptions = false; + + /** + * Wildfire protocol message index + * + * @var int + */ + protected $messageIndex = 1; + + /** + * Options for the library + * + * @var array + */ + protected $options = array('maxDepth' => 10, + 'maxObjectDepth' => 5, + 'maxArrayDepth' => 5, + 'useNativeJsonEncode' => true, + 'includeLineNumbers' => true); + + /** + * Filters used to exclude object members when encoding + * + * @var array + */ + protected $objectFilters = array( + 'firephp' => array('objectStack', 'instance', 'json_objectStack'), + 'firephp_test_class' => array('objectStack', 'instance', 'json_objectStack') + ); + + /** + * A stack of objects used to detect recursion during object encoding + * + * @var object + */ + protected $objectStack = array(); + + /** + * Flag to enable/disable logging + * + * @var boolean + */ + protected $enabled = true; + + /** + * The insight console to log to if applicable + * + * @var object + */ + protected $logToInsightConsole = null; + + /** + * When the object gets serialized only include specific object members. + * + * @return array + */ + public function __sleep() + { + return array('options','objectFilters','enabled'); + } + + /** + * Gets singleton instance of FirePHP + * + * @param boolean $AutoCreate + * @return FirePHP + */ + public static function getInstance($AutoCreate = false) + { + if ($AutoCreate===true && !self::$instance) { + self::init(); + } + return self::$instance; + } + + /** + * Creates FirePHP object and stores it for singleton access + * + * @return FirePHP + */ + public static function init() + { + return self::setInstance(new self()); + } + + /** + * Set the instance of the FirePHP singleton + * + * @param FirePHP $instance The FirePHP object instance + * @return FirePHP + */ + public static function setInstance($instance) + { + return self::$instance = $instance; + } + + /** + * Set an Insight console to direct all logging calls to + * + * @param object $console The console object to log to + * @return void + */ + public function setLogToInsightConsole($console) + { + if(is_string($console)) { + if(get_class($this)!='FirePHP_Insight' && !is_subclass_of($this, 'FirePHP_Insight')) { + throw new Exception('FirePHP instance not an instance or subclass of FirePHP_Insight!'); + } + $this->logToInsightConsole = $this->to('request')->console($console); + } else { + $this->logToInsightConsole = $console; + } + } + + /** + * Enable and disable logging to Firebug + * + * @param boolean $Enabled TRUE to enable, FALSE to disable + * @return void + */ + public function setEnabled($Enabled) + { + $this->enabled = $Enabled; + } + + /** + * Check if logging is enabled + * + * @return boolean TRUE if enabled + */ + public function getEnabled() + { + return $this->enabled; + } + + /** + * Specify a filter to be used when encoding an object + * + * Filters are used to exclude object members. + * + * @param string $Class The class name of the object + * @param array $Filter An array of members to exclude + * @return void + */ + public function setObjectFilter($Class, $Filter) + { + $this->objectFilters[strtolower($Class)] = $Filter; + } + + /** + * Set some options for the library + * + * Options: + * - maxDepth: The maximum depth to traverse (default: 10) + * - maxObjectDepth: The maximum depth to traverse objects (default: 5) + * - maxArrayDepth: The maximum depth to traverse arrays (default: 5) + * - useNativeJsonEncode: If true will use json_encode() (default: true) + * - includeLineNumbers: If true will include line numbers and filenames (default: true) + * + * @param array $Options The options to be set + * @return void + */ + public function setOptions($Options) + { + $this->options = array_merge($this->options,$Options); + } + + /** + * Get options from the library + * + * @return array The currently set options + */ + public function getOptions() + { + return $this->options; + } + + /** + * Set an option for the library + * + * @param string $Name + * @param mixed $Value + * @throws Exception + * @return void + */ + public function setOption($Name, $Value) + { + if (!isset($this->options[$Name])) { + throw $this->newException('Unknown option: ' . $Name); + } + $this->options[$Name] = $Value; + } + + /** + * Get an option from the library + * + * @param string $Name + * @throws Exception + * @return mixed + */ + public function getOption($Name) + { + if (!isset($this->options[$Name])) { + throw $this->newException('Unknown option: ' . $Name); + } + return $this->options[$Name]; + } + + /** + * Register FirePHP as your error handler + * + * Will throw exceptions for each php error. + * + * @return mixed Returns a string containing the previously defined error handler (if any) + */ + public function registerErrorHandler($throwErrorExceptions = false) + { + //NOTE: The following errors will not be caught by this error handler: + // E_ERROR, E_PARSE, E_CORE_ERROR, + // E_CORE_WARNING, E_COMPILE_ERROR, + // E_COMPILE_WARNING, E_STRICT + + $this->throwErrorExceptions = $throwErrorExceptions; + + return set_error_handler(array($this,'errorHandler')); + } + + /** + * FirePHP's error handler + * + * Throws exception for each php error that will occur. + * + * @param int $errno + * @param string $errstr + * @param string $errfile + * @param int $errline + * @param array $errcontext + */ + public function errorHandler($errno, $errstr, $errfile, $errline, $errcontext) + { + // Don't throw exception if error reporting is switched off + if (error_reporting() == 0) { + return; + } + // Only throw exceptions for errors we are asking for + if (error_reporting() & $errno) { + + $exception = new ErrorException($errstr, 0, $errno, $errfile, $errline); + if ($this->throwErrorExceptions) { + throw $exception; + } else { + $this->fb($exception); + } + } + } + + /** + * Register FirePHP as your exception handler + * + * @return mixed Returns the name of the previously defined exception handler, + * or NULL on error. + * If no previous handler was defined, NULL is also returned. + */ + public function registerExceptionHandler() + { + return set_exception_handler(array($this,'exceptionHandler')); + } + + /** + * FirePHP's exception handler + * + * Logs all exceptions to your firebug console and then stops the script. + * + * @param Exception $Exception + * @throws Exception + */ + function exceptionHandler($Exception) + { + + $this->inExceptionHandler = true; + + header('HTTP/1.1 500 Internal Server Error'); + + try { + $this->fb($Exception); + } catch (Exception $e) { + echo 'We had an exception: ' . $e; + } + $this->inExceptionHandler = false; + } + + /** + * Register FirePHP driver as your assert callback + * + * @param boolean $convertAssertionErrorsToExceptions + * @param boolean $throwAssertionExceptions + * @return mixed Returns the original setting or FALSE on errors + */ + public function registerAssertionHandler($convertAssertionErrorsToExceptions = true, $throwAssertionExceptions = false) + { + $this->convertAssertionErrorsToExceptions = $convertAssertionErrorsToExceptions; + $this->throwAssertionExceptions = $throwAssertionExceptions; + + if ($throwAssertionExceptions && !$convertAssertionErrorsToExceptions) { + throw $this->newException('Cannot throw assertion exceptions as assertion errors are not being converted to exceptions!'); + } + + return assert_options(ASSERT_CALLBACK, array($this, 'assertionHandler')); + } + + /** + * FirePHP's assertion handler + * + * Logs all assertions to your firebug console and then stops the script. + * + * @param string $file File source of assertion + * @param int $line Line source of assertion + * @param mixed $code Assertion code + */ + public function assertionHandler($file, $line, $code) + { + if ($this->convertAssertionErrorsToExceptions) { + + $exception = new ErrorException('Assertion Failed - Code[ '.$code.' ]', 0, null, $file, $line); + + if ($this->throwAssertionExceptions) { + throw $exception; + } else { + $this->fb($exception); + } + + } else { + $this->fb($code, 'Assertion Failed', FirePHP::ERROR, array('File'=>$file,'Line'=>$line)); + } + } + + /** + * Start a group for following messages. + * + * Options: + * Collapsed: [true|false] + * Color: [#RRGGBB|ColorName] + * + * @param string $Name + * @param array $Options OPTIONAL Instructions on how to log the group + * @return true + * @throws Exception + */ + public function group($Name, $Options = null) + { + + if (!$Name) { + throw $this->newException('You must specify a label for the group!'); + } + + if ($Options) { + if (!is_array($Options)) { + throw $this->newException('Options must be defined as an array!'); + } + if (array_key_exists('Collapsed', $Options)) { + $Options['Collapsed'] = ($Options['Collapsed'])?'true':'false'; + } + } + + return $this->fb(null, $Name, FirePHP::GROUP_START, $Options); + } + + /** + * Ends a group you have started before + * + * @return true + * @throws Exception + */ + public function groupEnd() + { + return $this->fb(null, null, FirePHP::GROUP_END); + } + + /** + * Log object with label to firebug console + * + * @see FirePHP::LOG + * @param mixes $Object + * @param string $Label + * @return true + * @throws Exception + */ + public function log($Object, $Label = null, $Options = array()) + { + return $this->fb($Object, $Label, FirePHP::LOG, $Options); + } + + /** + * Log object with label to firebug console + * + * @see FirePHP::INFO + * @param mixes $Object + * @param string $Label + * @return true + * @throws Exception + */ + public function info($Object, $Label = null, $Options = array()) + { + return $this->fb($Object, $Label, FirePHP::INFO, $Options); + } + + /** + * Log object with label to firebug console + * + * @see FirePHP::WARN + * @param mixes $Object + * @param string $Label + * @return true + * @throws Exception + */ + public function warn($Object, $Label = null, $Options = array()) + { + return $this->fb($Object, $Label, FirePHP::WARN, $Options); + } + + /** + * Log object with label to firebug console + * + * @see FirePHP::ERROR + * @param mixes $Object + * @param string $Label + * @return true + * @throws Exception + */ + public function error($Object, $Label = null, $Options = array()) + { + return $this->fb($Object, $Label, FirePHP::ERROR, $Options); + } + + /** + * Dumps key and variable to firebug server panel + * + * @see FirePHP::DUMP + * @param string $Key + * @param mixed $Variable + * @return true + * @throws Exception + */ + public function dump($Key, $Variable, $Options = array()) + { + if (!is_string($Key)) { + throw $this->newException('Key passed to dump() is not a string'); + } + if (strlen($Key)>100) { + throw $this->newException('Key passed to dump() is longer than 100 characters'); + } + if (!preg_match_all('/^[a-zA-Z0-9-_\.:]*$/', $Key, $m)) { + throw $this->newException('Key passed to dump() contains invalid characters [a-zA-Z0-9-_\.:]'); + } + return $this->fb($Variable, $Key, FirePHP::DUMP, $Options); + } + + /** + * Log a trace in the firebug console + * + * @see FirePHP::TRACE + * @param string $Label + * @return true + * @throws Exception + */ + public function trace($Label) + { + return $this->fb($Label, FirePHP::TRACE); + } + + /** + * Log a table in the firebug console + * + * @see FirePHP::TABLE + * @param string $Label + * @param string $Table + * @return true + * @throws Exception + */ + public function table($Label, $Table, $Options = array()) + { + return $this->fb($Table, $Label, FirePHP::TABLE, $Options); + } + + /** + * Insight API wrapper + * + * @see Insight_Helper::to() + */ + public static function to() + { + $instance = self::getInstance(); + if (!method_exists($instance, "_to")) { + throw new Exception("FirePHP::to() implementation not loaded"); + } + $args = func_get_args(); + return call_user_func_array(array($instance, '_to'), $args); + } + + /** + * Insight API wrapper + * + * @see Insight_Helper::plugin() + */ + public static function plugin() + { + $instance = self::getInstance(); + if (!method_exists($instance, "_plugin")) { + throw new Exception("FirePHP::plugin() implementation not loaded"); + } + $args = func_get_args(); + return call_user_func_array(array($instance, '_plugin'), $args); + } + + /** + * Check if FirePHP is installed on client + * + * @return boolean + */ + public function detectClientExtension() + { + // Check if FirePHP is installed on client via User-Agent header + if (@preg_match_all('/\sFirePHP\/([\.\d]*)\s?/si',$this->getUserAgent(),$m) && + version_compare($m[1][0],'0.0.6','>=')) { + return true; + } else + // Check if FirePHP is installed on client via X-FirePHP-Version header + if (@preg_match_all('/^([\.\d]*)$/si',$this->getRequestHeader("X-FirePHP-Version"),$m) && + version_compare($m[1][0],'0.0.6','>=')) { + return true; + } + return false; + } + + /** + * Log varible to Firebug + * + * @see http://www.firephp.org/Wiki/Reference/Fb + * @param mixed $Object The variable to be logged + * @return true Return TRUE if message was added to headers, FALSE otherwise + * @throws Exception + */ + public function fb($Object) + { + if($this instanceof FirePHP_Insight && method_exists($this, '_logUpgradeClientMessage')) { + if(!FirePHP_Insight::$upgradeClientMessageLogged) { // avoid infinite recursion as _logUpgradeClientMessage() logs a message + $this->_logUpgradeClientMessage(); + } + } + + static $insightGroupStack = array(); + + if (!$this->getEnabled()) { + return false; + } + + if ($this->headersSent($filename, $linenum)) { + // If we are logging from within the exception handler we cannot throw another exception + if ($this->inExceptionHandler) { + // Simply echo the error out to the page + echo '
    FirePHP ERROR: Headers already sent in '.$filename.' on line '.$linenum.'. Cannot send log data to FirePHP. You must have Output Buffering enabled via ob_start() or output_buffering ini directive.
    '; + } else { + throw $this->newException('Headers already sent in '.$filename.' on line '.$linenum.'. Cannot send log data to FirePHP. You must have Output Buffering enabled via ob_start() or output_buffering ini directive.'); + } + } + + $Type = null; + $Label = null; + $Options = array(); + + if (func_num_args()==1) { + } else + if (func_num_args()==2) { + switch(func_get_arg(1)) { + case self::LOG: + case self::INFO: + case self::WARN: + case self::ERROR: + case self::DUMP: + case self::TRACE: + case self::EXCEPTION: + case self::TABLE: + case self::GROUP_START: + case self::GROUP_END: + $Type = func_get_arg(1); + break; + default: + $Label = func_get_arg(1); + break; + } + } else + if (func_num_args()==3) { + $Type = func_get_arg(2); + $Label = func_get_arg(1); + } else + if (func_num_args()==4) { + $Type = func_get_arg(2); + $Label = func_get_arg(1); + $Options = func_get_arg(3); + } else { + throw $this->newException('Wrong number of arguments to fb() function!'); + } + + if($this->logToInsightConsole!==null && (get_class($this)=='FirePHP_Insight' || is_subclass_of($this, 'FirePHP_Insight'))) { + $msg = $this->logToInsightConsole; + if ($Object instanceof Exception) { + $Type = self::EXCEPTION; + } + if($Label && $Type!=self::TABLE && $Type!=self::GROUP_START) { + $msg = $msg->label($Label); + } + switch($Type) { + case self::DUMP: + case self::LOG: + return $msg->log($Object); + case self::INFO: + return $msg->info($Object); + case self::WARN: + return $msg->warn($Object); + case self::ERROR: + return $msg->error($Object); + case self::TRACE: + return $msg->trace($Object); + case self::EXCEPTION: + return $this->plugin('engine')->handleException($Object, $msg); + case self::TABLE: + if (isset($Object[0]) && !is_string($Object[0]) && $Label) { + $Object = array($Label, $Object); + } + return $msg->table($Object[0], array_slice($Object[1],1), $Object[1][0]); + case self::GROUP_START: + $insightGroupStack[] = $msg->group(md5($Label))->open(); + return $msg->log($Label); + case self::GROUP_END: + if(count($insightGroupStack)==0) { + throw new Error('Too many groupEnd() as opposed to group() calls!'); + } + $group = array_pop($insightGroupStack); + return $group->close(); + default: + return $msg->log($Object); + } + } + + if (!$this->detectClientExtension()) { + return false; + } + + $meta = array(); + $skipFinalObjectEncode = false; + + if ($Object instanceof Exception) { + + $meta['file'] = $this->_escapeTraceFile($Object->getFile()); + $meta['line'] = $Object->getLine(); + + $trace = $Object->getTrace(); + if ($Object instanceof ErrorException + && isset($trace[0]['function']) + && $trace[0]['function']=='errorHandler' + && isset($trace[0]['class']) + && $trace[0]['class']=='FirePHP') { + + $severity = false; + switch($Object->getSeverity()) { + case E_WARNING: $severity = 'E_WARNING'; break; + case E_NOTICE: $severity = 'E_NOTICE'; break; + case E_USER_ERROR: $severity = 'E_USER_ERROR'; break; + case E_USER_WARNING: $severity = 'E_USER_WARNING'; break; + case E_USER_NOTICE: $severity = 'E_USER_NOTICE'; break; + case E_STRICT: $severity = 'E_STRICT'; break; + case E_RECOVERABLE_ERROR: $severity = 'E_RECOVERABLE_ERROR'; break; + case E_DEPRECATED: $severity = 'E_DEPRECATED'; break; + case E_USER_DEPRECATED: $severity = 'E_USER_DEPRECATED'; break; + } + + $Object = array('Class'=>get_class($Object), + 'Message'=>$severity.': '.$Object->getMessage(), + 'File'=>$this->_escapeTraceFile($Object->getFile()), + 'Line'=>$Object->getLine(), + 'Type'=>'trigger', + 'Trace'=>$this->_escapeTrace(array_splice($trace,2))); + $skipFinalObjectEncode = true; + } else { + $Object = array('Class'=>get_class($Object), + 'Message'=>$Object->getMessage(), + 'File'=>$this->_escapeTraceFile($Object->getFile()), + 'Line'=>$Object->getLine(), + 'Type'=>'throw', + 'Trace'=>$this->_escapeTrace($trace)); + $skipFinalObjectEncode = true; + } + $Type = self::EXCEPTION; + + } else + if ($Type==self::TRACE) { + + $trace = debug_backtrace(); + if (!$trace) return false; + for( $i=0 ; $i_standardizePath($trace[$i]['file']),-18,18)=='FirePHPCore/fb.php' + || substr($this->_standardizePath($trace[$i]['file']),-29,29)=='FirePHPCore/FirePHP.class.php')) { + /* Skip - FB::trace(), FB::send(), $firephp->trace(), $firephp->fb() */ + } else + if (isset($trace[$i]['class']) + && isset($trace[$i+1]['file']) + && $trace[$i]['class']=='FirePHP' + && substr($this->_standardizePath($trace[$i+1]['file']),-18,18)=='FirePHPCore/fb.php') { + /* Skip fb() */ + } else + if ($trace[$i]['function']=='fb' + || $trace[$i]['function']=='trace' + || $trace[$i]['function']=='send') { + + $Object = array('Class'=>isset($trace[$i]['class'])?$trace[$i]['class']:'', + 'Type'=>isset($trace[$i]['type'])?$trace[$i]['type']:'', + 'Function'=>isset($trace[$i]['function'])?$trace[$i]['function']:'', + 'Message'=>$trace[$i]['args'][0], + 'File'=>isset($trace[$i]['file'])?$this->_escapeTraceFile($trace[$i]['file']):'', + 'Line'=>isset($trace[$i]['line'])?$trace[$i]['line']:'', + 'Args'=>isset($trace[$i]['args'])?$this->encodeObject($trace[$i]['args']):'', + 'Trace'=>$this->_escapeTrace(array_splice($trace,$i+1))); + + $skipFinalObjectEncode = true; + $meta['file'] = isset($trace[$i]['file'])?$this->_escapeTraceFile($trace[$i]['file']):''; + $meta['line'] = isset($trace[$i]['line'])?$trace[$i]['line']:''; + break; + } + } + + } else + if ($Type==self::TABLE) { + + if (isset($Object[0]) && is_string($Object[0])) { + $Object[1] = $this->encodeTable($Object[1]); + } else { + $Object = $this->encodeTable($Object); + } + + $skipFinalObjectEncode = true; + + } else + if ($Type==self::GROUP_START) { + + if (!$Label) { + throw $this->newException('You must specify a label for the group!'); + } + + } else { + if ($Type===null) { + $Type = self::LOG; + } + } + + if ($this->options['includeLineNumbers']) { + if (!isset($meta['file']) || !isset($meta['line'])) { + + $trace = debug_backtrace(); + for( $i=0 ; $trace && $i_standardizePath($trace[$i]['file']),-18,18)=='FirePHPCore/fb.php' + || substr($this->_standardizePath($trace[$i]['file']),-29,29)=='FirePHPCore/FirePHP.class.php')) { + /* Skip - FB::trace(), FB::send(), $firephp->trace(), $firephp->fb() */ + } else + if (isset($trace[$i]['class']) + && isset($trace[$i+1]['file']) + && $trace[$i]['class']=='FirePHP' + && substr($this->_standardizePath($trace[$i+1]['file']),-18,18)=='FirePHPCore/fb.php') { + /* Skip fb() */ + } else + if (isset($trace[$i]['file']) + && substr($this->_standardizePath($trace[$i]['file']),-18,18)=='FirePHPCore/fb.php') { + /* Skip FB::fb() */ + } else { + $meta['file'] = isset($trace[$i]['file'])?$this->_escapeTraceFile($trace[$i]['file']):''; + $meta['line'] = isset($trace[$i]['line'])?$trace[$i]['line']:''; + break; + } + } + } + } else { + unset($meta['file']); + unset($meta['line']); + } + + $this->setHeader('X-Wf-Protocol-1','http://meta.wildfirehq.org/Protocol/JsonStream/0.2'); + $this->setHeader('X-Wf-1-Plugin-1','http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/'.self::VERSION); + + $structure_index = 1; + if ($Type==self::DUMP) { + $structure_index = 2; + $this->setHeader('X-Wf-1-Structure-2','http://meta.firephp.org/Wildfire/Structure/FirePHP/Dump/0.1'); + } else { + $this->setHeader('X-Wf-1-Structure-1','http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1'); + } + + if ($Type==self::DUMP) { + $msg = '{"'.$Label.'":'.$this->jsonEncode($Object, $skipFinalObjectEncode).'}'; + } else { + $msg_meta = $Options; + $msg_meta['Type'] = $Type; + if ($Label!==null) { + $msg_meta['Label'] = $Label; + } + if (isset($meta['file']) && !isset($msg_meta['File'])) { + $msg_meta['File'] = $meta['file']; + } + if (isset($meta['line']) && !isset($msg_meta['Line'])) { + $msg_meta['Line'] = $meta['line']; + } + $msg = '['.$this->jsonEncode($msg_meta).','.$this->jsonEncode($Object, $skipFinalObjectEncode).']'; + } + + $parts = explode("\n",chunk_split($msg, 5000, "\n")); + + for( $i=0 ; $i2) { + // Message needs to be split into multiple parts + $this->setHeader('X-Wf-1-'.$structure_index.'-'.'1-'.$this->messageIndex, + (($i==0)?strlen($msg):'') + . '|' . $part . '|' + . (($isetHeader('X-Wf-1-'.$structure_index.'-'.'1-'.$this->messageIndex, + strlen($part) . '|' . $part . '|'); + } + + $this->messageIndex++; + + if ($this->messageIndex > 99999) { + throw $this->newException('Maximum number (99,999) of messages reached!'); + } + } + } + + $this->setHeader('X-Wf-1-Index',$this->messageIndex-1); + + return true; + } + + /** + * Standardizes path for windows systems. + * + * @param string $Path + * @return string + */ + protected function _standardizePath($Path) + { + return preg_replace('/\\\\+/','/',$Path); + } + + /** + * Escape trace path for windows systems + * + * @param array $Trace + * @return array + */ + protected function _escapeTrace($Trace) + { + if (!$Trace) return $Trace; + for( $i=0 ; $i_escapeTraceFile($Trace[$i]['file']); + } + if (isset($Trace[$i]['args'])) { + $Trace[$i]['args'] = $this->encodeObject($Trace[$i]['args']); + } + } + return $Trace; + } + + /** + * Escape file information of trace for windows systems + * + * @param string $File + * @return string + */ + protected function _escapeTraceFile($File) + { + /* Check if we have a windows filepath */ + if (strpos($File,'\\')) { + /* First strip down to single \ */ + + $file = preg_replace('/\\\\+/','\\',$File); + + return $file; + } + return $File; + } + + /** + * Check if headers have already been sent + * + * @param string $Filename + * @param integer $Linenum + */ + protected function headersSent(&$Filename, &$Linenum) + { + return headers_sent($Filename, $Linenum); + } + + /** + * Send header + * + * @param string $Name + * @param string $Value + */ + protected function setHeader($Name, $Value) + { + return header($Name.': '.$Value); + } + + /** + * Get user agent + * + * @return string|false + */ + protected function getUserAgent() + { + if (!isset($_SERVER['HTTP_USER_AGENT'])) return false; + return $_SERVER['HTTP_USER_AGENT']; + } + + /** + * Get all request headers + * + * @return array + */ + public static function getAllRequestHeaders() { + static $_cached_headers = false; + if($_cached_headers!==false) { + return $_cached_headers; + } + $headers = array(); + if(function_exists('getallheaders')) { + foreach( getallheaders() as $name => $value ) { + $headers[strtolower($name)] = $value; + } + } else { + foreach($_SERVER as $name => $value) { + if(substr($name, 0, 5) == 'HTTP_') { + $headers[strtolower(str_replace(' ', '-', str_replace('_', ' ', substr($name, 5))))] = $value; + } + } + } + return $_cached_headers = $headers; + } + + /** + * Get a request header + * + * @return string|false + */ + protected function getRequestHeader($Name) + { + $headers = self::getAllRequestHeaders(); + if (isset($headers[strtolower($Name)])) { + return $headers[strtolower($Name)]; + } + return false; + } + + /** + * Returns a new exception + * + * @param string $Message + * @return Exception + */ + protected function newException($Message) + { + return new Exception($Message); + } + + /** + * Encode an object into a JSON string + * + * Uses PHP's jeson_encode() if available + * + * @param object $Object The object to be encoded + * @return string The JSON string + */ + public function jsonEncode($Object, $skipObjectEncode = false) + { + if (!$skipObjectEncode) { + $Object = $this->encodeObject($Object); + } + + if (function_exists('json_encode') + && $this->options['useNativeJsonEncode']!=false) { + + return json_encode($Object); + } else { + return $this->json_encode($Object); + } + } + + /** + * Encodes a table by encoding each row and column with encodeObject() + * + * @param array $Table The table to be encoded + * @return array + */ + protected function encodeTable($Table) + { + + if (!$Table) return $Table; + + $new_table = array(); + foreach($Table as $row) { + + if (is_array($row)) { + $new_row = array(); + + foreach($row as $item) { + $new_row[] = $this->encodeObject($item); + } + + $new_table[] = $new_row; + } + } + + return $new_table; + } + + /** + * Encodes an object including members with + * protected and private visibility + * + * @param Object $Object The object to be encoded + * @param int $Depth The current traversal depth + * @return array All members of the object + */ + protected function encodeObject($Object, $ObjectDepth = 1, $ArrayDepth = 1, $MaxDepth = 1) + { + if ($MaxDepth > $this->options['maxDepth']) { + return '** Max Depth ('.$this->options['maxDepth'].') **'; + } + + $return = array(); + + if (is_resource($Object)) { + + return '** '.(string)$Object.' **'; + + } else + if (is_object($Object)) { + + if ($ObjectDepth > $this->options['maxObjectDepth']) { + return '** Max Object Depth ('.$this->options['maxObjectDepth'].') **'; + } + + foreach ($this->objectStack as $refVal) { + if ($refVal === $Object) { + return '** Recursion ('.get_class($Object).') **'; + } + } + array_push($this->objectStack, $Object); + + $return['__className'] = $class = get_class($Object); + $class_lower = strtolower($class); + + $reflectionClass = new ReflectionClass($class); + $properties = array(); + foreach( $reflectionClass->getProperties() as $property) { + $properties[$property->getName()] = $property; + } + + $members = (array)$Object; + + foreach( $properties as $plain_name => $property ) { + + $name = $raw_name = $plain_name; + if ($property->isStatic()) { + $name = 'static:'.$name; + } + if ($property->isPublic()) { + $name = 'public:'.$name; + } else + if ($property->isPrivate()) { + $name = 'private:'.$name; + $raw_name = "\0".$class."\0".$raw_name; + } else + if ($property->isProtected()) { + $name = 'protected:'.$name; + $raw_name = "\0".'*'."\0".$raw_name; + } + + if (!(isset($this->objectFilters[$class_lower]) + && is_array($this->objectFilters[$class_lower]) + && in_array($plain_name,$this->objectFilters[$class_lower]))) { + + if (array_key_exists($raw_name,$members) + && !$property->isStatic()) { + + $return[$name] = $this->encodeObject($members[$raw_name], $ObjectDepth + 1, 1, $MaxDepth + 1); + + } else { + if (method_exists($property,'setAccessible')) { + $property->setAccessible(true); + $return[$name] = $this->encodeObject($property->getValue($Object), $ObjectDepth + 1, 1, $MaxDepth + 1); + } else + if ($property->isPublic()) { + $return[$name] = $this->encodeObject($property->getValue($Object), $ObjectDepth + 1, 1, $MaxDepth + 1); + } else { + $return[$name] = '** Need PHP 5.3 to get value **'; + } + } + } else { + $return[$name] = '** Excluded by Filter **'; + } + } + + // Include all members that are not defined in the class + // but exist in the object + foreach( $members as $raw_name => $value ) { + + $name = $raw_name; + + if ($name{0} == "\0") { + $parts = explode("\0", $name); + $name = $parts[2]; + } + + $plain_name = $name; + + if (!isset($properties[$name])) { + $name = 'undeclared:'.$name; + + if (!(isset($this->objectFilters[$class_lower]) + && is_array($this->objectFilters[$class_lower]) + && in_array($plain_name,$this->objectFilters[$class_lower]))) { + + $return[$name] = $this->encodeObject($value, $ObjectDepth + 1, 1, $MaxDepth + 1); + } else { + $return[$name] = '** Excluded by Filter **'; + } + } + } + + array_pop($this->objectStack); + + } elseif (is_array($Object)) { + + if ($ArrayDepth > $this->options['maxArrayDepth']) { + return '** Max Array Depth ('.$this->options['maxArrayDepth'].') **'; + } + + foreach ($Object as $key => $val) { + + // Encoding the $GLOBALS PHP array causes an infinite loop + // if the recursion is not reset here as it contains + // a reference to itself. This is the only way I have come up + // with to stop infinite recursion in this case. + if ($key=='GLOBALS' + && is_array($val) + && array_key_exists('GLOBALS',$val)) { + $val['GLOBALS'] = '** Recursion (GLOBALS) **'; + } + + $return[$key] = $this->encodeObject($val, 1, $ArrayDepth + 1, $MaxDepth + 1); + } + } else { + if (self::is_utf8($Object)) { + return $Object; + } else { + return utf8_encode($Object); + } + } + return $return; + } + + /** + * Returns true if $string is valid UTF-8 and false otherwise. + * + * @param mixed $str String to be tested + * @return boolean + */ + protected static function is_utf8($str) + { + if(function_exists('mb_detect_encoding')) { + return (mb_detect_encoding($str) == 'UTF-8'); + } + $c=0; $b=0; + $bits=0; + $len=strlen($str); + for($i=0; $i<$len; $i++){ + $c=ord($str[$i]); + if ($c > 128){ + if (($c >= 254)) return false; + elseif ($c >= 252) $bits=6; + elseif ($c >= 248) $bits=5; + elseif ($c >= 240) $bits=4; + elseif ($c >= 224) $bits=3; + elseif ($c >= 192) $bits=2; + else return false; + if (($i+$bits) > $len) return false; + while($bits > 1){ + $i++; + $b=ord($str[$i]); + if ($b < 128 || $b > 191) return false; + $bits--; + } + } + } + return true; + } + + /** + * Converts to and from JSON format. + * + * JSON (JavaScript Object Notation) is a lightweight data-interchange + * format. It is easy for humans to read and write. It is easy for machines + * to parse and generate. It is based on a subset of the JavaScript + * Programming Language, Standard ECMA-262 3rd Edition - December 1999. + * This feature can also be found in Python. JSON is a text format that is + * completely language independent but uses conventions that are familiar + * to programmers of the C-family of languages, including C, C++, C#, Java, + * JavaScript, Perl, TCL, and many others. These properties make JSON an + * ideal data-interchange language. + * + * This package provides a simple encoder and decoder for JSON notation. It + * is intended for use with client-side Javascript applications that make + * use of HTTPRequest to perform server communication functions - data can + * be encoded into JSON notation for use in a client-side javascript, or + * decoded from incoming Javascript requests. JSON format is native to + * Javascript, and can be directly eval()'ed with no further parsing + * overhead + * + * All strings should be in ASCII or UTF-8 format! + * + * LICENSE: Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: Redistributions of source code must retain the + * above copyright notice, this list of conditions and the following + * disclaimer. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN + * NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * @category + * @package Services_JSON + * @author Michal Migurski + * @author Matt Knapp + * @author Brett Stimmerman + * @author Christoph Dorn + * @copyright 2005 Michal Migurski + * @version CVS: $Id: JSON.php,v 1.31 2006/06/28 05:54:17 migurski Exp $ + * @license http://www.opensource.org/licenses/bsd-license.php + * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198 + */ + + + /** + * Keep a list of objects as we descend into the array so we can detect recursion. + */ + private $json_objectStack = array(); + + + /** + * convert a string from one UTF-8 char to one UTF-16 char + * + * Normally should be handled by mb_convert_encoding, but + * provides a slower PHP-only method for installations + * that lack the multibye string extension. + * + * @param string $utf8 UTF-8 character + * @return string UTF-16 character + * @access private + */ + private function json_utf82utf16($utf8) + { + // oh please oh please oh please oh please oh please + if (function_exists('mb_convert_encoding')) { + return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8'); + } + + switch(strlen($utf8)) { + case 1: + // this case should never be reached, because we are in ASCII range + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + return $utf8; + + case 2: + // return a UTF-16 character from a 2-byte UTF-8 char + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + return chr(0x07 & (ord($utf8{0}) >> 2)) + . chr((0xC0 & (ord($utf8{0}) << 6)) + | (0x3F & ord($utf8{1}))); + + case 3: + // return a UTF-16 character from a 3-byte UTF-8 char + // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + return chr((0xF0 & (ord($utf8{0}) << 4)) + | (0x0F & (ord($utf8{1}) >> 2))) + . chr((0xC0 & (ord($utf8{1}) << 6)) + | (0x7F & ord($utf8{2}))); + } + + // ignoring UTF-32 for now, sorry + return ''; + } + + /** + * encodes an arbitrary variable into JSON format + * + * @param mixed $var any number, boolean, string, array, or object to be encoded. + * see argument 1 to Services_JSON() above for array-parsing behavior. + * if var is a strng, note that encode() always expects it + * to be in ASCII or UTF-8 format! + * + * @return mixed JSON string representation of input var or an error if a problem occurs + * @access public + */ + private function json_encode($var) + { + + if (is_object($var)) { + if (in_array($var,$this->json_objectStack)) { + return '"** Recursion **"'; + } + } + + switch (gettype($var)) { + case 'boolean': + return $var ? 'true' : 'false'; + + case 'NULL': + return 'null'; + + case 'integer': + return (int) $var; + + case 'double': + case 'float': + return (float) $var; + + case 'string': + // STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT + $ascii = ''; + $strlen_var = strlen($var); + + /* + * Iterate over every character in the string, + * escaping with a slash or encoding to UTF-8 where necessary + */ + for ($c = 0; $c < $strlen_var; ++$c) { + + $ord_var_c = ord($var{$c}); + + switch (true) { + case $ord_var_c == 0x08: + $ascii .= '\b'; + break; + case $ord_var_c == 0x09: + $ascii .= '\t'; + break; + case $ord_var_c == 0x0A: + $ascii .= '\n'; + break; + case $ord_var_c == 0x0C: + $ascii .= '\f'; + break; + case $ord_var_c == 0x0D: + $ascii .= '\r'; + break; + + case $ord_var_c == 0x22: + case $ord_var_c == 0x2F: + case $ord_var_c == 0x5C: + // double quote, slash, slosh + $ascii .= '\\'.$var{$c}; + break; + + case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)): + // characters U-00000000 - U-0000007F (same as ASCII) + $ascii .= $var{$c}; + break; + + case (($ord_var_c & 0xE0) == 0xC0): + // characters U-00000080 - U-000007FF, mask 110XXXXX + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $char = pack('C*', $ord_var_c, ord($var{$c + 1})); + $c += 1; + $utf16 = $this->json_utf82utf16($char); + $ascii .= sprintf('\u%04s', bin2hex($utf16)); + break; + + case (($ord_var_c & 0xF0) == 0xE0): + // characters U-00000800 - U-0000FFFF, mask 1110XXXX + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $char = pack('C*', $ord_var_c, + ord($var{$c + 1}), + ord($var{$c + 2})); + $c += 2; + $utf16 = $this->json_utf82utf16($char); + $ascii .= sprintf('\u%04s', bin2hex($utf16)); + break; + + case (($ord_var_c & 0xF8) == 0xF0): + // characters U-00010000 - U-001FFFFF, mask 11110XXX + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $char = pack('C*', $ord_var_c, + ord($var{$c + 1}), + ord($var{$c + 2}), + ord($var{$c + 3})); + $c += 3; + $utf16 = $this->json_utf82utf16($char); + $ascii .= sprintf('\u%04s', bin2hex($utf16)); + break; + + case (($ord_var_c & 0xFC) == 0xF8): + // characters U-00200000 - U-03FFFFFF, mask 111110XX + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $char = pack('C*', $ord_var_c, + ord($var{$c + 1}), + ord($var{$c + 2}), + ord($var{$c + 3}), + ord($var{$c + 4})); + $c += 4; + $utf16 = $this->json_utf82utf16($char); + $ascii .= sprintf('\u%04s', bin2hex($utf16)); + break; + + case (($ord_var_c & 0xFE) == 0xFC): + // characters U-04000000 - U-7FFFFFFF, mask 1111110X + // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 + $char = pack('C*', $ord_var_c, + ord($var{$c + 1}), + ord($var{$c + 2}), + ord($var{$c + 3}), + ord($var{$c + 4}), + ord($var{$c + 5})); + $c += 5; + $utf16 = $this->json_utf82utf16($char); + $ascii .= sprintf('\u%04s', bin2hex($utf16)); + break; + } + } + + return '"'.$ascii.'"'; + + case 'array': + /* + * As per JSON spec if any array key is not an integer + * we must treat the the whole array as an object. We + * also try to catch a sparsely populated associative + * array with numeric keys here because some JS engines + * will create an array with empty indexes up to + * max_index which can cause memory issues and because + * the keys, which may be relevant, will be remapped + * otherwise. + * + * As per the ECMA and JSON specification an object may + * have any string as a property. Unfortunately due to + * a hole in the ECMA specification if the key is a + * ECMA reserved word or starts with a digit the + * parameter is only accessible using ECMAScript's + * bracket notation. + */ + + // treat as a JSON object + if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) { + + $this->json_objectStack[] = $var; + + $properties = array_map(array($this, 'json_name_value'), + array_keys($var), + array_values($var)); + + array_pop($this->json_objectStack); + + foreach($properties as $property) { + if ($property instanceof Exception) { + return $property; + } + } + + return '{' . join(',', $properties) . '}'; + } + + $this->json_objectStack[] = $var; + + // treat it like a regular array + $elements = array_map(array($this, 'json_encode'), $var); + + array_pop($this->json_objectStack); + + foreach($elements as $element) { + if ($element instanceof Exception) { + return $element; + } + } + + return '[' . join(',', $elements) . ']'; + + case 'object': + $vars = self::encodeObject($var); + + $this->json_objectStack[] = $var; + + $properties = array_map(array($this, 'json_name_value'), + array_keys($vars), + array_values($vars)); + + array_pop($this->json_objectStack); + + foreach($properties as $property) { + if ($property instanceof Exception) { + return $property; + } + } + + return '{' . join(',', $properties) . '}'; + + default: + return null; + } + } + + /** + * array-walking function for use in generating JSON-formatted name-value pairs + * + * @param string $name name of key to use + * @param mixed $value reference to an array element to be encoded + * + * @return string JSON-formatted name-value pair, like '"name":value' + * @access private + */ + private function json_name_value($name, $value) + { + // Encoding the $GLOBALS PHP array causes an infinite loop + // if the recursion is not reset here as it contains + // a reference to itself. This is the only way I have come up + // with to stop infinite recursion in this case. + if ($name=='GLOBALS' + && is_array($value) + && array_key_exists('GLOBALS',$value)) { + $value['GLOBALS'] = '** Recursion **'; + } + + $encoded_value = $this->json_encode($value); + + if ($encoded_value instanceof Exception) { + return $encoded_value; + } + + return $this->json_encode(strval($name)) . ':' . $encoded_value; + } +} diff --git a/src/application/code/local/.placeholder b/src/application/code/local/.placeholder new file mode 100644 index 0000000..e69de29 diff --git a/src/application/code/test/Legacies/Core/LayoutTest.php b/src/application/code/test/Legacies/Core/LayoutTest.php new file mode 100644 index 0000000..1e2a2fd --- /dev/null +++ b/src/application/code/test/Legacies/Core/LayoutTest.php @@ -0,0 +1,41 @@ +markTestIncomplete(); + /* + $layoutDir = vfsStreamWrapper::getContent(''); + vfsStream::addStructure(array()); + + $this->_object = new Legacies_Core_Layout(); + */ + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + + public function testEmpty() + { + + } +} diff --git a/includes/application/code/core/Test/Legacies/Empire/Model/BuilderTest.php b/src/application/code/test/Legacies/Empire/Model/BuilderTest.php similarity index 99% rename from includes/application/code/core/Test/Legacies/Empire/Model/BuilderTest.php rename to src/application/code/test/Legacies/Empire/Model/BuilderTest.php index 46e436c..45b7013 100644 --- a/includes/application/code/core/Test/Legacies/Empire/Model/BuilderTest.php +++ b/src/application/code/test/Legacies/Empire/Model/BuilderTest.php @@ -1,7 +1,7 @@ _object = new Legacies_Object(); + $this->_object = new Wootook_Object(); } /** @@ -109,7 +109,7 @@ class Test_Legacies_ObjectTest extends PHPUnit_Framework_TestCase $expected = array( 'test' => 'legacies', 'testing' => false, - 'legacies' => 'Legacies_Object' + 'legacies' => 'Wootook_Object' ); $this->_object->addData($expected); diff --git a/includes/application/code/core/Test/LegaciesTest.php b/src/application/code/test/WootookTest.php similarity index 58% rename from includes/application/code/core/Test/LegaciesTest.php rename to src/application/code/test/WootookTest.php index 678da8b..8962684 100644 --- a/includes/application/code/core/Test/LegaciesTest.php +++ b/src/application/code/test/WootookTest.php @@ -1,11 +1,11 @@ false)); + $observer = Wootook::dispatchEvent('testing', array('success' => false)); $this->assertInstanceOf('Legacies_Core_Event', $observer); $this->assertTrue($observer->getData('success')); @@ -30,9 +30,9 @@ class Test_LegaciesTest public function testRegisteringStaticEvent() { - Legacies::registerListener('testing', array(get_class($this), 'staticListener')); + Wootook::registerListener('testing', array(get_class($this), 'staticListener')); - $observer = Legacies::dispatchEvent('testing', array('success' => false)); + $observer = Wootook::dispatchEvent('testing', array('success' => false)); $this->assertInstanceOf('Legacies_Core_Event', $observer); $this->assertTrue($observer->getData('success')); @@ -40,7 +40,7 @@ class Test_LegaciesTest public function testDispatchNonExistingEvent() { - $observer = Legacies::dispatchEvent('testing', array('success' => true)); + $observer = Wootook::dispatchEvent('testing', array('success' => true)); $this->assertInstanceOf('Legacies_Core_Event', $observer); $this->assertTrue($observer->getData('success')); @@ -51,11 +51,11 @@ class Test_LegaciesTest */ public function testUnregisteringNonStaticEvent() { - Legacies::registerListener('testing', array($this, 'nonStaticListener')); + Wootook::registerListener('testing', array($this, 'nonStaticListener')); - Legacies::clearEventListeners('testing'); + Wootook::clearEventListeners('testing'); - $observer = Legacies::dispatchEvent('testing', array('success' => false)); + $observer = Wootook::dispatchEvent('testing', array('success' => false)); $this->assertInstanceOf('Legacies_Core_Event', $observer); $this->assertFalse($observer->getData('success')); @@ -66,11 +66,11 @@ class Test_LegaciesTest */ public function testUnregisteringStaticEvent() { - Legacies::registerListener('testing', array(get_class($this), 'staticListener')); + Wootook::registerListener('testing', array(get_class($this), 'staticListener')); - Legacies::clearEventListeners('testing'); + Wootook::clearEventListeners('testing'); - $observer = Legacies::dispatchEvent('testing', array('success' => false)); + $observer = Wootook::dispatchEvent('testing', array('success' => false)); $this->assertInstanceOf('Legacies_Core_Event', $observer); $this->assertFalse($observer->getData('success')); @@ -79,31 +79,31 @@ class Test_LegaciesTest public function testGetSession() { $this->markTestSkipped('Sessions could not be tested in CLI.'); - $this->assertInstanceOf('Legacies_Core_Model_Session', Legacies::getSession('test')); + $this->assertInstanceOf('Legacies_Core_Model_Session', Wootook::getSession('test')); } public function testGetTranslator() { - $this->assertInstanceOf('Legacies_Core_Model_Translator', Legacies::getTranslator('test')); + $this->assertInstanceOf('Legacies_Core_Model_Translator', Wootook::getTranslator('test')); - $this->assertInstanceOf('Legacies_Core_Model_Translator', Legacies::getTranslator()); + $this->assertInstanceOf('Legacies_Core_Model_Translator', Wootook::getTranslator()); } public function testTranslate() { - $this->assertEquals('My testing message!', Legacies::translate('test', 'My %s message!', array('testing'))); + $this->assertEquals('My testing message!', Wootook::translate('test', 'My %s message!', array('testing'))); } public function testTranslateGettextStyle() { - $this->assertEquals('My testing message!', Legacies::__('My %s message!', 'testing')); + $this->assertEquals('My testing message!', Wootook::__('My %s message!', 'testing')); } public function testSetDefaultLocale() { - Legacies::setDefaultLocale('test'); + Wootook::setDefaultLocale('test'); - $this->assertAttributeEquals('test', '_defaultLocale', 'Legacies'); + $this->assertAttributeEquals('test', '_defaultLocale', 'Beyond'); } /** @@ -112,8 +112,8 @@ class Test_LegaciesTest */ public function testGetDefaultLocale() { - Legacies::setDefaultLocale('test'); + Wootook::setDefaultLocale('test'); - $this->assertEquals('test', Legacies::getDefaultLocale()); + $this->assertEquals('test', Wootook::getDefaultLocale()); } } diff --git a/includes/application/code/core/Test/bootstrap.php b/src/application/code/test/bootstrap.php similarity index 100% rename from includes/application/code/core/Test/bootstrap.php rename to src/application/code/test/bootstrap.php diff --git a/src/application/configs/local.php.sample b/src/application/configs/local.php.sample new file mode 100644 index 0000000..94fa83f --- /dev/null +++ b/src/application/configs/local.php.sample @@ -0,0 +1,85 @@ + array( + 'resource' => array( + 'database' => array( + 'default' => array( + 'engine' => 'mysql', + 'options' => array( + ), + 'params' => array( + 'hostname' => 'localhost', + 'username' => 'root', + 'password' => '', + 'database' => 'db_wootook' + ), + 'table_prefix' => 'wtk_', + ), + ), + ), + ), + 'backend' => array( + 'web' => array( + 'url' => array( + 'base' => 'http://testing.wootook.org/', + 'skin' => 'http://testing.wootook.org/skin/', + 'js' => 'http://testing.wootook.org/js/', + 'css' => 'http://testing.wootook.org/css/', + ), + 'session' => array( + 'time' => 900, + 'domain' => 'testing.wootook.org', + 'path' => '/' + ) + ), + 'system' => array( + 'path' => array( + 'base' => ROOT_PATH, + 'skin' => ROOT_PATH . 'skin' . DIRECTORY_SEPARATOR, + ), + 'date' => array( + 'timezone' => 'Europe/Paris' + ), + ), + ), + 'frontend' => array( + 'web' => array( + 'url' => array( + 'base' => 'http://testing.wootook.org/', + 'skin' => 'http://testing.wootook.org/skin/', + 'js' => 'http://testing.wootook.org/js/', + 'css' => 'http://testing.wootook.org/css/', + ), + 'session' => array( + 'time' => 900, + 'domain' => 'testing.wootook.org', + 'path' => '/' + ) + ), + 'system' => array( + 'path' => array( + 'base' => ROOT_PATH, + 'skin' => ROOT_PATH . 'skin' . DIRECTORY_SEPARATOR, + ), + 'date' => array( + 'timezone' => 'Europe/Paris' + ), + ), + 'engine' => array( + 'storyline' => array( + 'universe' => 'legacies', + 'episode' => 'default', + ), + 'core' => array( + 'use_large_numbers' => true + ), + 'universe' => array( + 'galaxies' => 3, + 'systems' => 100, + 'positions' => 15 + ), + 'combat' => array( + 'allow_spy_drone_attacks' => true + ) + ), + ) + ); \ No newline at end of file diff --git a/src/application/configs/system.php b/src/application/configs/system.php new file mode 100644 index 0000000..8246cb4 --- /dev/null +++ b/src/application/configs/system.php @@ -0,0 +1,72 @@ + array( + 'resource' => array( + 'database' => array( + 'default' => array( + 'engine' => 'pdo_mysql', + 'options' => array( + ), + 'params' => array( + 'hostname' => 'localhost', + 'username' => 'root', + 'password' => '', + 'database' => 'db_wootook' + ), + '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' => true, + ), + 'universe' => array( + 'galaxies' => 3, + 'systems' => 100, + 'positions' => 15, + ), + 'combat' => array( + 'allow_spy_drone_attacks' => true, + ) + ), + 'system' => array( + 'date' => array( + 'timezone' => 'Europe/Paris' + ), + ), + 'game' => array( + 'speed' => array( + 'general' => 1000, + 'ships' => 1000 + ), + 'home' => array( + 'title' => 'Welcome on Wootook!', + 'formated-welcome-text' => '

    Wootook make you an emperor.

    Conquer outer space and master other players on Wootook.

    ' + ) + ) + ), + 'frontend' => array( + 'layout' => array( + 'page' => 'page.xml', + 'player' => 'player.xml', + 'empire' => 'empire.xml' + ), + ), + 'backend' => array( + 'layout' => array( + 'page' => 'page.xml', + 'admin' => 'admin.php' + ), + ) + ); diff --git a/src/application/design/backend/base/default/layouts/admin.php b/src/application/design/backend/base/default/layouts/admin.php new file mode 100644 index 0000000..ddac4e8 --- /dev/null +++ b/src/application/design/backend/base/default/layouts/admin.php @@ -0,0 +1,283 @@ + array( + 'update' => array('1column'), + 'reference' => array( + 'header' => array( + 'children' => array( + 'navigation' => array( + 'type' => 'core/html.navigation', + 'template' => 'page/html/navigation.phtml', + 'actions' => array( + array( + 'method' => 'setNodeTitle', + 'params' => array( + 'path' => 'system', + 'title' => 'System' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'system/overview', + 'label' => 'Overview', + 'title' => 'Overview', + 'uri' => 'admin/overview.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'system/settings', + 'label' => 'Settings', + 'title' => 'Settings', + 'uri' => 'admin/settings.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'system/reset-universe', + 'label' => 'Reset Universe', + 'title' => 'Reset Universe', + 'uri' => 'admin/XNovaResetUnivers.php' + ) + ), + array( + 'method' => 'setNodeTitle', + 'params' => array( + 'path' => 'players', + 'title' => 'Player Accounts' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'players/list', + 'label' => 'List', + 'title' => 'List', + 'uri' => 'admin/userlist.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'players/password-recovery', + 'label' => 'Change a password', + 'title' => 'Change a password', + 'uri' => 'admin/md5changepass.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'players/search', + 'label' => 'Search', + 'title' => 'Search', + 'uri' => 'admin/paneladmina.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'players/multi-account-alerts', + 'label' => 'Multi account alerts', + 'title' => 'Multi account alerts', + 'uri' => 'admin/multi.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'players/declared-multi-account', + 'label' => 'Declared multi accounts', + 'title' => 'Declared multi accounts', + 'uri' => 'admin/declare_list.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'players/add-resources', + 'label' => 'Add Resources', + 'title' => 'Add Resources', + 'uri' => 'admin/add_money.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'players/messages', + 'label' => 'Private messages management', + 'title' => 'Private messages management', + 'uri' => 'admin/messagelist.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'players/chat', + 'label' => 'Manage Chat', + 'title' => 'Manage Chat', + 'uri' => 'chat.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'players/ban', + 'label' => 'Ban Player', + 'title' => 'Ban Player', + 'uri' => 'admin/banned.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'players/unban', + 'label' => 'Unban Player', + 'title' => 'Unban Player', + 'uri' => 'admin/unbanned.php' + ) + ), + array( + 'method' => 'setNodeTitle', + 'params' => array( + 'path' => 'empire', + 'title' => 'Empires' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'empire/planet-list', + 'label' => 'Planet List', + 'title' => 'Planet List', + 'uri' => 'admin/planetlist.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'empire/moon-list', + 'label' => 'Moon List', + 'title' => 'Moon List', + 'uri' => 'admin/moonlist.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'empire/add-moon', + 'label' => 'Add a moon', + 'title' => 'Add a moon', + 'uri' => 'admin/add_moon.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'empire/planet-activity', + 'label' => 'Planet Activity', + 'title' => 'Planet Activity', + 'uri' => 'admin/activeplanet.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'empire/fleet-list', + 'label' => 'Fleet list', + 'title' => 'Fleet list', + 'uri' => 'admin/ShowFlyingFleets.php' + ) + ), + array( + 'method' => 'setNodeTitle', + 'params' => array( + 'path' => 'tools', + 'title' => 'Tools' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'tools/phpinfo', + 'label' => 'PHP Info', + 'title' => 'PHP Info', + 'uri' => 'variables.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'tools/stats', + 'label' => 'Stats updater', + 'title' => 'Stats updater', + 'uri' => 'statbuilder.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'tools/errors', + 'label' => 'Error reporting', + 'title' => 'Error reporting', + 'uri' => 'errors.php' + ) + ), + array( + 'method' => 'addExternalLink', + 'params' => array( + 'name' => 'tools/help', + 'label' => 'Need help?', + 'title' => 'Need help?', + 'url' => 'http://wootook.org/board/' + ) + ) + ) + ) + ) + ) + ) + ), + 'admin.grid' => array( + 'update' => array('admin'), + 'reference' => array( + 'content' => array( + 'children' => array( + 'grid.container' => array( + 'type' => 'admin/grid.container', + 'template' => 'grid/container.phtml', + 'children' => array( + 'mass-actions' => array( + 'type' => 'admin/grid.mass-actions', + 'template' => 'grid/view.phtml', + ), + 'grid' => array( + 'type' => 'admin/grid.view', + 'template' => 'grid/view.phtml', + ) + ) + ) + ) + ) + ) + ), + 'admin.user.grid' => array( + 'update' => array('admin.grid'), + 'reference' => array( + 'grid' => array( + 'actions' => array( + array( + 'method' => 'addColumn', + 'params' => array( + 'name' => 'index', + 'type' => 'indexer', + 'config' => array() + ) + ) + ) + ) + ) + ) + ); diff --git a/src/application/design/backend/base/default/layouts/admin.xml b/src/application/design/backend/base/default/layouts/admin.xml new file mode 100644 index 0000000..18fde20 --- /dev/null +++ b/src/application/design/backend/base/default/layouts/admin.xml @@ -0,0 +1,19 @@ + + + + + + + + + system + System + + + players + Player Accounts + + + + + diff --git a/src/application/design/backend/base/default/layouts/page.xml b/src/application/design/backend/base/default/layouts/page.xml new file mode 100644 index 0000000..6becaf2 --- /dev/null +++ b/src/application/design/backend/base/default/layouts/page.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + page/2columns-left.phtml + + + + + + + + + + page/2columns-right.phtml + + + + + + + + + + page/3columns.phtml + + + + + + + + + + css/base.css + + + css/deprecated/default.css + + + css/deprecated/formate.css + + + scripts/jquery/jquery-1.6.4.js + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/includes/application/design/scripts/deprecated/admin/activeplanet_body.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/activeplanet_body.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/admin/activeplanet_body.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/activeplanet_body.tpl diff --git a/includes/application/design/scripts/deprecated/admin/add_money.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/add_money.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/admin/add_money.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/add_money.tpl diff --git a/includes/application/design/scripts/deprecated/admin/add_moon.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/add_moon.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/admin/add_moon.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/add_moon.tpl diff --git a/includes/application/design/scripts/deprecated/admin/admin_panel_asw1.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/admin_panel_asw1.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/admin/admin_panel_asw1.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/admin_panel_asw1.tpl diff --git a/includes/application/design/scripts/deprecated/admin/admin_panel_asw2.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/admin_panel_asw2.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/admin/admin_panel_asw2.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/admin_panel_asw2.tpl diff --git a/includes/application/design/scripts/deprecated/admin/admin_panel_frm1.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/admin_panel_frm1.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/admin/admin_panel_frm1.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/admin_panel_frm1.tpl diff --git a/includes/application/design/scripts/deprecated/admin/admin_panel_frm2.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/admin_panel_frm2.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/admin/admin_panel_frm2.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/admin_panel_frm2.tpl diff --git a/includes/application/design/scripts/deprecated/admin/admin_panel_frm3.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/admin_panel_frm3.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/admin/admin_panel_frm3.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/admin_panel_frm3.tpl diff --git a/includes/application/design/scripts/deprecated/admin/admin_panel_frm4.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/admin_panel_frm4.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/admin/admin_panel_frm4.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/admin_panel_frm4.tpl diff --git a/includes/application/design/scripts/deprecated/admin/admin_panel_main.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/admin_panel_main.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/admin/admin_panel_main.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/admin_panel_main.tpl diff --git a/includes/application/design/scripts/deprecated/admin/banadni.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/banadni.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/admin/banadni.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/banadni.tpl diff --git a/includes/application/design/scripts/deprecated/admin/banned.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/banned.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/admin/banned.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/banned.tpl diff --git a/includes/application/design/scripts/deprecated/admin/changepass.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/changepass.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/admin/changepass.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/changepass.tpl diff --git a/includes/application/design/scripts/deprecated/admin/chat_body.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/chat_body.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/admin/chat_body.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/chat_body.tpl diff --git a/includes/application/design/scripts/deprecated/admin/credit_body.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/credit_body.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/admin/credit_body.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/credit_body.tpl diff --git a/includes/application/design/scripts/deprecated/admin/declarelist_body.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/declarelist_body.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/admin/declarelist_body.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/declarelist_body.tpl diff --git a/includes/application/design/scripts/deprecated/admin/declarelist_rows.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/declarelist_rows.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/admin/declarelist_rows.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/declarelist_rows.tpl diff --git a/includes/application/design/scripts/deprecated/admin/deletuser.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/deletuser.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/admin/deletuser.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/deletuser.tpl diff --git a/includes/application/design/scripts/deprecated/admin/errors_body.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/errors_body.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/admin/errors_body.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/errors_body.tpl diff --git a/includes/application/design/scripts/deprecated/admin/exec_query.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/exec_query.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/admin/exec_query.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/exec_query.tpl diff --git a/includes/application/design/scripts/deprecated/admin/fleet_body.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/fleet_body.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/admin/fleet_body.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/fleet_body.tpl diff --git a/includes/application/design/scripts/deprecated/admin/fleet_rows.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/fleet_rows.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/admin/fleet_rows.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/fleet_rows.tpl diff --git a/includes/application/design/scripts/deprecated/admin/left_menu.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/left_menu.tpl similarity index 97% rename from includes/application/design/scripts/deprecated/admin/left_menu.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/left_menu.tpl index 6955190..9cc9100 100644 --- a/includes/application/design/scripts/deprecated/admin/left_menu.tpl +++ b/src/application/design/backend/base/default/scripts/deprecated/admin/left_menu.tpl @@ -78,7 +78,7 @@ parent.frames['Hauptframe'].location.replace("overview.php"); - + diff --git a/includes/application/design/scripts/deprecated/admin/md5enc.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/md5enc.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/admin/md5enc.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/md5enc.tpl diff --git a/includes/application/design/scripts/deprecated/admin/message_body.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/message_body.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/admin/message_body.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/message_body.tpl diff --git a/includes/application/design/scripts/deprecated/admin/messagelist_body.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/messagelist_body.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/admin/messagelist_body.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/messagelist_body.tpl diff --git a/includes/application/design/scripts/deprecated/admin/messagelist_table_rows.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/messagelist_table_rows.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/admin/messagelist_table_rows.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/messagelist_table_rows.tpl diff --git a/includes/application/design/scripts/deprecated/admin/messall_body.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/messall_body.tpl similarity index 51% rename from includes/application/design/scripts/deprecated/admin/messall_body.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/messall_body.tpl index cf4b14e..b4b4fb8 100644 --- a/includes/application/design/scripts/deprecated/admin/messall_body.tpl +++ b/src/application/design/backend/base/default/scripts/deprecated/admin/messall_body.tpl @@ -3,13 +3,13 @@ - + - - + + diff --git a/includes/application/design/scripts/deprecated/admin/moonlist_body.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/moonlist_body.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/admin/moonlist_body.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/moonlist_body.tpl diff --git a/includes/application/design/scripts/deprecated/admin/multi_body.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/multi_body.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/admin/multi_body.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/multi_body.tpl diff --git a/includes/application/design/scripts/deprecated/admin/multi_rows.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/multi_rows.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/admin/multi_rows.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/multi_rows.tpl diff --git a/includes/application/design/scripts/deprecated/admin/options_body.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/options_body.tpl similarity index 89% rename from includes/application/design/scripts/deprecated/admin/options_body.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/options_body.tpl index fb92f13..ecb278a 100644 --- a/includes/application/design/scripts/deprecated/admin/options_body.tpl +++ b/src/application/design/backend/base/default/scripts/deprecated/admin/options_body.tpl @@ -102,24 +102,17 @@ - - + + - - - - - - - - - - + + + - + diff --git a/src/application/design/backend/base/default/scripts/deprecated/admin/overview_body.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/overview_body.tpl new file mode 100644 index 0000000..f9220f0 --- /dev/null +++ b/src/application/design/backend/base/default/scripts/deprecated/admin/overview_body.tpl @@ -0,0 +1,35 @@ +

    __('Overview')?>

    +
    Message Général__('General message')?>
    Sujet
    Texte (0 / 5000 Caractère)__('Content 0 / %1$d chars)', 5000)?>
    getData('adm_opt_game_oth_chat')?>getData('chatframe')?> type="checkbox" />__('Enable Google Analytics')?>getData('ga')?> type="checkbox" />
    getData('adm_opt_game_oth_adds')?>getData('googlead')?> type="checkbox" />
    getData('adm_opt_game_debugmod')?>getData('debug')?> type="checkbox" />
    __('Google Analytics Identifier')?>
    getData('banner')?>
    <?php echo $this->getData('banner_source_post')?>
    + + + + + + + +
    __('General information')?>
    __('Your version:')?>getData('version')?>__('Latest version avalaiable at Wootook.org')?>
    + + + + + + + + + + + + + + + + + + + + + getData('adm_ov_data_table')?> + + + +
    __('Online players')?>
    getData('adm_ul_id')?>getData('adm_ul_name')?>getData('adm_ul_adip')?>getData('adm_ov_ally')?>getData('adm_ov_point')?>getData('adm_ov_activ')?>getData('usr_email')?>getData('xp_raid')?>getData('xp_min')?>getData('lang_vacancy')?>getData('banned_lang')?>getData('usr_current_planet')?>getData('usr_current_page')?>
    getData('adm_ov_count')?>: getData('adm_ov_data_count')?>
    diff --git a/includes/application/design/scripts/deprecated/admin/overview_rows.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/overview_rows.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/admin/overview_rows.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/overview_rows.tpl diff --git a/includes/application/design/scripts/deprecated/admin/planetlist_body.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/planetlist_body.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/admin/planetlist_body.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/planetlist_body.tpl diff --git a/includes/application/design/scripts/deprecated/admin/reset_body.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/reset_body.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/admin/reset_body.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/reset_body.tpl diff --git a/includes/application/design/scripts/deprecated/admin/simple_header.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/simple_header.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/admin/simple_header.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/simple_header.tpl diff --git a/includes/application/design/scripts/deprecated/admin/unbanned.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/unbanned.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/admin/unbanned.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/unbanned.tpl diff --git a/includes/application/design/scripts/deprecated/admin/userlist_body.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/userlist_body.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/admin/userlist_body.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/userlist_body.tpl diff --git a/includes/application/design/scripts/deprecated/admin/userlist_rows.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/userlist_rows.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/admin/userlist_rows.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/userlist_rows.tpl diff --git a/includes/application/design/scripts/deprecated/admin/variables_body.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/variables_body.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/admin/variables_body.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/variables_body.tpl diff --git a/includes/application/design/scripts/deprecated/admin/variables_rows.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/variables_rows.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/admin/variables_rows.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/variables_rows.tpl diff --git a/src/application/design/backend/base/default/scripts/grid/container.phtml b/src/application/design/backend/base/default/scripts/grid/container.phtml new file mode 100644 index 0000000..7898192 --- /dev/null +++ b/src/application/design/backend/base/default/scripts/grid/container.phtml @@ -0,0 +1 @@ +a diff --git a/src/application/design/backend/base/default/scripts/page/1column.phtml b/src/application/design/backend/base/default/scripts/page/1column.phtml new file mode 100644 index 0000000..ffaa1c8 --- /dev/null +++ b/src/application/design/backend/base/default/scripts/page/1column.phtml @@ -0,0 +1,15 @@ + + + head->render()?> + + getBodyClasses()):?> class="escape($classes)?>"> +
    +
    + header->render()?> +
    +
    + content->render()?> +
    +
    + + diff --git a/src/application/design/backend/base/default/scripts/page/2columns-left.phtml b/src/application/design/backend/base/default/scripts/page/2columns-left.phtml new file mode 100644 index 0000000..2a5d895 --- /dev/null +++ b/src/application/design/backend/base/default/scripts/page/2columns-left.phtml @@ -0,0 +1,18 @@ + + + head->render()?> + + getBodyClasses()):?> class="escape($classes)?>"> +
    +
    + header->render()?> +
    +
    + left->render()?> +
    +
    + content->render()?> +
    +
    + + diff --git a/src/application/design/backend/base/default/scripts/page/2columns-right.phtml b/src/application/design/backend/base/default/scripts/page/2columns-right.phtml new file mode 100644 index 0000000..95fd758 --- /dev/null +++ b/src/application/design/backend/base/default/scripts/page/2columns-right.phtml @@ -0,0 +1,18 @@ + + + head->render()?> + + getBodyClasses()):?> class="escape($classes)?>"> +
    +
    + header->render()?> +
    +
    + content->render()?> +
    +
    + left->render()?> +
    +
    + + diff --git a/src/application/design/backend/base/default/scripts/page/3columns.phtml b/src/application/design/backend/base/default/scripts/page/3columns.phtml new file mode 100644 index 0000000..0611279 --- /dev/null +++ b/src/application/design/backend/base/default/scripts/page/3columns.phtml @@ -0,0 +1,21 @@ + + + head->render()?> + + getBodyClasses()):?> class="escape($classes)?>"> +
    +
    + header->render()?> +
    +
    + left->render()?> +
    +
    + content->render()?> +
    +
    + left->render()?> +
    +
    + + diff --git a/includes/application/design/scripts/page/html/head.phtml b/src/application/design/backend/base/default/scripts/page/html/head.phtml similarity index 82% rename from includes/application/design/scripts/page/html/head.phtml rename to src/application/design/backend/base/default/scripts/page/html/head.phtml index 7933554..b98b464 100644 --- a/includes/application/design/scripts/page/html/head.phtml +++ b/src/application/design/backend/base/default/scripts/page/html/head.phtml @@ -1,5 +1,5 @@ -XNova:Legacies - +<?php echo $this->escape($this->getTitle())?> + getCss() as $css):?> @@ -12,7 +12,7 @@ getJs() as $js):?> - + getSkinJs() as $js):?> diff --git a/includes/application/design/scripts/page/html/message.phtml b/src/application/design/backend/base/default/scripts/page/html/message.phtml similarity index 100% rename from includes/application/design/scripts/page/html/message.phtml rename to src/application/design/backend/base/default/scripts/page/html/message.phtml diff --git a/src/application/design/backend/base/default/scripts/page/html/navigation.phtml b/src/application/design/backend/base/default/scripts/page/html/navigation.phtml new file mode 100644 index 0000000..612ee09 --- /dev/null +++ b/src/application/design/backend/base/default/scripts/page/html/navigation.phtml @@ -0,0 +1,28 @@ + diff --git a/src/application/design/backend/base/default/scripts/page/html/navigation/link.phtml b/src/application/design/backend/base/default/scripts/page/html/navigation/link.phtml new file mode 100644 index 0000000..4fa6fc8 --- /dev/null +++ b/src/application/design/backend/base/default/scripts/page/html/navigation/link.phtml @@ -0,0 +1,3 @@ + + getAttributes() as $attributeName => $attributeValue):?> ="">escape($this->getLabel())?> + diff --git a/src/application/design/backend/base/default/scripts/page/html/navigation/node.phtml b/src/application/design/backend/base/default/scripts/page/html/navigation/node.phtml new file mode 100644 index 0000000..266fae4 --- /dev/null +++ b/src/application/design/backend/base/default/scripts/page/html/navigation/node.phtml @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/src/application/design/frontend/base/default/layouts/empire.xml b/src/application/design/frontend/base/default/layouts/empire.xml new file mode 100644 index 0000000..f18da5b --- /dev/null +++ b/src/application/design/frontend/base/default/layouts/empire.xml @@ -0,0 +1,324 @@ + + + + + + + planet + Planet + + + universe + Universe + + + account + My Account + + + tools + Tools + + + community + Community + + + planet/overview + Overview + Overview + player/overview + + + planet/buildings + Buildings + Buildings + empire/buildings + + + planet/research-lab + Research Lab + Research Lab + legacies-empire/research-lab + + + planet/shipyard + Shipyard + Shipyard + legacies-empire/shipyard + + + planet/defenses + Defenses + Defenses + legacies-empire/defense + + + universe/galaxy + Check out the Galaxy + Check out the Galaxy + galaxy.php + + + universe/fleet + Send a Fleet + Send a Fleet + fleet.php + + + universe/retailer + Retailer + Retailer + marchand.php + + + universe/records + All Records + All Records + records.php + + + universe/statistics + My Stats + My Stats + stat.php + + + universe/search-player + Search a Player + Search a Player + search.php + + + universe/empire + Empire + Empire + imperium.php + + + account/alliance + My Alliance + My Alliance + alliance.php + + + account/messages + My Messages + My Messages + messages.php + + + account/resources + My Resources Production + My Resources Production + resources.php + + + account/tech-tree + Technology Tree + Technology Tree + techtree.php + + + tools/notes + Note Pad + Note Pad + notes.php + + + tools/options + Account Options + Account Options + options.php + + + tools/logout + Log Out + Log Out + player/account/logout + + + community/board + Forum board + Forum board + http://wootook.org/board/ + + + community/chat + Chat + Chat + chat.php + + + community/announcement + Announcements + Announcements + annonce.php + + + community/multi + Declare Multi-account + Declare Multi-account + delclare_multi.php + + + community/rules + Rules + Rules + rules.php + + + community/contact + Contact Admin + Contact Admin + contact.php + + + community/banned + Banned Players + Banned Players + banned.php + + + + + + + + + + + + + + + + + + + + + + + overview + + + + + + + + + + player/overview/fleet/item.phtml + + + empire/overview.fleet.list.item + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + empire/planet/buildings/queue/item.phtml + + + empire/planet.buildings.queue.item + + + + + + empire/planet/buildings/item.phtml + + + empire/planet.buildings.item + + + + + + + + + + + + + empire/planet/shipyard/queue/item.phtml + + + legacies-empire/planet.shipyard.queue.item + + + + + + empire/planet/shipyard/item.phtml + + + legacies-empire/planet.shipyard.item + + + + + + + + + + + + + + + + + + + + + + + empire/planet/research-lab/queue/item.phtml + + + legacies-empire/planet.research-lab.queue.item + + + + + + empire/planet/research-lab/item.phtml + + + legacies-empire/planet.research-lab.item + + + + + diff --git a/src/application/design/frontend/base/default/layouts/page.xml b/src/application/design/frontend/base/default/layouts/page.xml new file mode 100644 index 0000000..b2975e7 --- /dev/null +++ b/src/application/design/frontend/base/default/layouts/page.xml @@ -0,0 +1,127 @@ + + + + + + + + + + + page/2columns-left.phtml + + + + + + + + + + page/2columns-right.phtml + + + + + + + + + + page/3columns.phtml + + + + + + + + + + css/deprecated/default.css + + + css/deprecated/formate.css + + + css/base.css + + + scripts/jquery/jquery-1.6.4.js + + + Wootook! + + + + + + + + + + + public + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Not Found + + + + + + + + + + home + + + public-form + + + + + + Welcome + + + + + + + + diff --git a/src/application/design/frontend/base/default/layouts/player.xml b/src/application/design/frontend/base/default/layouts/player.xml new file mode 100644 index 0000000..16bd812 --- /dev/null +++ b/src/application/design/frontend/base/default/layouts/player.xml @@ -0,0 +1,74 @@ + + + + + + + + + login + + + public-form + + + + + + Log in + + + + + + + + + + + + + + + registration + + + public-form + + + + + + Register + + + + + + + + + + + + + + + lost-password + + + public-form + + + + + + Lost your password? + + + + + + + + diff --git a/includes/application/design/scripts/deprecated/add_declare.tpl b/src/application/design/frontend/base/default/scripts/deprecated/add_declare.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/add_declare.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/add_declare.tpl diff --git a/includes/application/design/scripts/deprecated/alliance_admin.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_admin.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/alliance_admin.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_admin.tpl diff --git a/src/application/design/frontend/base/default/scripts/deprecated/alliance_admin_laws.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_admin_laws.tpl new file mode 100644 index 0000000..b557fbf --- /dev/null +++ b/src/application/design/frontend/base/default/scripts/deprecated/alliance_admin_laws.tpl @@ -0,0 +1,71 @@ +
    + + +getData('list')?> + + +
    getData('Configure_laws')?>
    + +
    + +
    + + + + + + + + + + + +
    getData('Range_make')?>
    getData('Range_name')?>
    +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    getData('Law_leyends')?>
    getData('Alliance_dissolve')?>
    getData('Expel_users')?>
    getData('See_the_requests')?>
    getData('See_the_list_members')?>
    getData('Check_the_requests')?>
    getData('Alliance_admin')?>
    getData('See_the_online_list_member')?>
    getData('Make_a_circular_message')?>
    getData('Left_hand_text')?>
    getData('Return_to_overview')?>
    +
    diff --git a/includes/application/design/scripts/deprecated/alliance_admin_laws_feet.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_admin_laws_feet.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/alliance_admin_laws_feet.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_admin_laws_feet.tpl diff --git a/src/application/design/frontend/base/default/scripts/deprecated/alliance_admin_laws_head.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_admin_laws_head.tpl new file mode 100644 index 0000000..9afc37c --- /dev/null +++ b/src/application/design/frontend/base/default/scripts/deprecated/alliance_admin_laws_head.tpl @@ -0,0 +1,15 @@ +
    +
    + + + getData('Range_name')?> + + + + + + + + + + diff --git a/src/application/design/frontend/base/default/scripts/deprecated/alliance_admin_laws_row.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_admin_laws_row.tpl new file mode 100644 index 0000000..e1c8f57 --- /dev/null +++ b/src/application/design/frontend/base/default/scripts/deprecated/alliance_admin_laws_row.tpl @@ -0,0 +1,21 @@ + + + getData('a') > 0):?> + + <?php echo $this->__('Remove rank')?> + + + + + getData('r0')?> + getData('r1')?> + getData('r2')?> + getData('r3')?> + getData('r4')?> + getData('r5')?> + getData('r6')?> + getData('r7')?> + getData('r8')?> + getData('r9')?> + + \ No newline at end of file diff --git a/includes/application/design/scripts/deprecated/alliance_admin_members_function.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_admin_members_function.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/alliance_admin_members_function.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_admin_members_function.tpl diff --git a/includes/application/design/scripts/deprecated/alliance_admin_members_row.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_admin_members_row.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/alliance_admin_members_row.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_admin_members_row.tpl diff --git a/includes/application/design/scripts/deprecated/alliance_admin_members_row_edit.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_admin_members_row_edit.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/alliance_admin_members_row_edit.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_admin_members_row_edit.tpl diff --git a/includes/application/design/scripts/deprecated/alliance_admin_members_table.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_admin_members_table.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/alliance_admin_members_table.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_admin_members_table.tpl diff --git a/includes/application/design/scripts/deprecated/alliance_admin_rename.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_admin_rename.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/alliance_admin_rename.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_admin_rename.tpl diff --git a/includes/application/design/scripts/deprecated/alliance_admin_rename1.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_admin_rename1.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/alliance_admin_rename1.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_admin_rename1.tpl diff --git a/includes/application/design/scripts/deprecated/alliance_admin_rename2.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_admin_rename2.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/alliance_admin_rename2.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_admin_rename2.tpl diff --git a/includes/application/design/scripts/deprecated/alliance_admin_request_form.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_admin_request_form.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/alliance_admin_request_form.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_admin_request_form.tpl diff --git a/includes/application/design/scripts/deprecated/alliance_admin_request_row.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_admin_request_row.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/alliance_admin_request_row.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_admin_request_row.tpl diff --git a/includes/application/design/scripts/deprecated/alliance_admin_request_table.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_admin_request_table.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/alliance_admin_request_table.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_admin_request_table.tpl diff --git a/includes/application/design/scripts/deprecated/alliance_ainfo.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_ainfo.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/alliance_ainfo.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_ainfo.tpl diff --git a/includes/application/design/scripts/deprecated/alliance_apply_waitform.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_apply_waitform.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/alliance_apply_waitform.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_apply_waitform.tpl diff --git a/includes/application/design/scripts/deprecated/alliance_applyform.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_applyform.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/alliance_applyform.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_applyform.tpl diff --git a/includes/application/design/scripts/deprecated/alliance_circular.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_circular.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/alliance_circular.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_circular.tpl diff --git a/includes/application/design/scripts/deprecated/alliance_circular_form.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_circular_form.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/alliance_circular_form.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_circular_form.tpl diff --git a/includes/application/design/scripts/deprecated/alliance_defaultmenu.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_defaultmenu.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/alliance_defaultmenu.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_defaultmenu.tpl diff --git a/includes/application/design/scripts/deprecated/alliance_frontpage.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_frontpage.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/alliance_frontpage.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_frontpage.tpl diff --git a/includes/application/design/scripts/deprecated/alliance_make.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_make.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/alliance_make.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_make.tpl diff --git a/includes/application/design/scripts/deprecated/alliance_makeform.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_makeform.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/alliance_makeform.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_makeform.tpl diff --git a/includes/application/design/scripts/deprecated/alliance_memberslist_row.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_memberslist_row.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/alliance_memberslist_row.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_memberslist_row.tpl diff --git a/includes/application/design/scripts/deprecated/alliance_memberslist_table.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_memberslist_table.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/alliance_memberslist_table.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_memberslist_table.tpl diff --git a/includes/application/design/scripts/deprecated/alliance_searchform.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_searchform.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/alliance_searchform.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_searchform.tpl diff --git a/includes/application/design/scripts/deprecated/alliance_searchresult_row.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_searchresult_row.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/alliance_searchresult_row.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_searchresult_row.tpl diff --git a/includes/application/design/scripts/deprecated/alliance_searchresult_table.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_searchresult_table.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/alliance_searchresult_table.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_searchresult_table.tpl diff --git a/includes/application/design/scripts/deprecated/banned_body.tpl b/src/application/design/frontend/base/default/scripts/deprecated/banned_body.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/banned_body.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/banned_body.tpl diff --git a/includes/application/design/scripts/deprecated/changelog_body.tpl b/src/application/design/frontend/base/default/scripts/deprecated/changelog_body.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/changelog_body.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/changelog_body.tpl diff --git a/includes/application/design/scripts/deprecated/changelog_table.tpl b/src/application/design/frontend/base/default/scripts/deprecated/changelog_table.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/changelog_table.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/changelog_table.tpl diff --git a/includes/application/design/scripts/deprecated/chat_body.tpl b/src/application/design/frontend/base/default/scripts/deprecated/chat_body.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/chat_body.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/chat_body.tpl diff --git a/includes/application/design/scripts/deprecated/contact_body.tpl b/src/application/design/frontend/base/default/scripts/deprecated/contact_body.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/contact_body.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/contact_body.tpl diff --git a/includes/application/design/scripts/deprecated/contact_body_rows.tpl b/src/application/design/frontend/base/default/scripts/deprecated/contact_body_rows.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/contact_body_rows.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/contact_body_rows.tpl diff --git a/includes/application/design/scripts/deprecated/credit_body.tpl b/src/application/design/frontend/base/default/scripts/deprecated/credit_body.tpl similarity index 83% rename from includes/application/design/scripts/deprecated/credit_body.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/credit_body.tpl index 77c7886..525309d 100644 --- a/includes/application/design/scripts/deprecated/credit_body.tpl +++ b/src/application/design/frontend/base/default/scripts/deprecated/credit_body.tpl @@ -6,7 +6,7 @@ getData('cred_link')?> getData('cred_site')?>:
    getData('cred_forum')?>: - www.xnova-ng.org
    www.xnova-ng.org/forum + www.xnova-ng.org
    www.xnova-ng.org/forum getData('cred_credit')?> @@ -18,5 +18,4 @@ UGamela
    Britania getData('cred_based')?>
    getData('cred_start')?> -getData('ExtCopyFrame')?> \ No newline at end of file diff --git a/includes/application/design/scripts/deprecated/galaxy_body.tpl b/src/application/design/frontend/base/default/scripts/deprecated/galaxy_body.tpl similarity index 94% rename from includes/application/design/scripts/deprecated/galaxy_body.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/galaxy_body.tpl index dfb452b..0d7e0d7 100644 --- a/includes/application/design/scripts/deprecated/galaxy_body.tpl +++ b/src/application/design/frontend/base/default/scripts/deprecated/galaxy_body.tpl @@ -1,4 +1,6 @@ - - + -

    - +
    "; + $MissionSelector .= ""; + $MissionSelector .= ""; + } else { + $i = 0; + foreach ($missionTypes as $a => $b) { + $MissionSelector .= ""; + $MissionSelector .= ""; + $MissionSelector .= ""; + $i++; + } + } +} else { + $MissionSelector .= ""; + $MissionSelector .= ""; + $MissionSelector .= ""; +} + +if ($planet->isPlanet()) { + $TableTitle = "{$planet->getCoords()} - {$lang['fl_planet']}"; +} elseif ($planet->isMoon()) { + $TableTitle = "{$planet->getCoords()} - {$lang['fl_moon']}"; +} + +$readAdapter = Wootook_Core_Database_ConnectionManager::getSingleton()->getConnection('core_read'); +$maxExpedition = $user->getElement(Legacies_Empire::ID_RESEARCH_EXPEDITION_TECHNOLOGY); +$ExpeditionEnCours = 0; +$EnvoiMaxExpedition = 0; +if ($maxExpedition >= 1) { + $ExpeditionEnCours = $readAdapter->select() + ->column(new Wootook_Core_Database_Sql_Placeholder_Expression('COUNT(*)')) + ->from(array('fleet' => $readAdapter->getTable('fleets'))) + ->where('fleet_owner', $user->getId()) + ->where('fleet_mission', Legacies_Empire::ID_MISSION_EXPEDITION) + ->prepare() + ->fetchColumn() + ; + + $EnvoiMaxExpedition = 1 + floor(sqrt($maxExpedition)); +} + +$MaxFlyingFleets = $readAdapter->select() + ->column(new Wootook_Core_Database_Sql_Placeholder_Expression('COUNT(*)')) + ->from(array('fleet' => $readAdapter->getTable('fleets'))) + ->where('fleet_owner', $user->getId()) + ->prepare() + ->fetchColumn() +; + +$page = ""; +$page .= "\n"; +$page .= "
    "; +$page .= "
    \n"; +$page .= "\n"; +$page .= "\n"; +$page .= "\n"; +$page .= "getGalaxy() ."\" />\n"; +$page .= "getSystem() ."\" />\n"; +$page .= "getPosition() ."\" />\n"; +$page .= "\n"; +$page .= "\n"; +$page .= "\n"; +$page .= "getType() ."\" />\n"; +$page .= "\n"; +$page .= "\n"; +$page .= "\n"; +$page .= "\n"; +$page .= "\n"; +$page .= "\n"; +foreach ($fleetArray as $shipId => $count) { + $page .= "\n"; + $page .= "\n"; + $page .= "\n"; + $page .= "\n"; + +} +$page .= "
    @@ -276,4 +277,4 @@ function setShips(ship, count) { - + diff --git a/includes/application/design/scripts/deprecated/galaxy_row.tpl b/src/application/design/frontend/base/default/scripts/deprecated/galaxy_row.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/galaxy_row.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/galaxy_row.tpl diff --git a/includes/application/design/scripts/deprecated/galaxy_row_action.tpl b/src/application/design/frontend/base/default/scripts/deprecated/galaxy_row_action.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/galaxy_row_action.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/galaxy_row_action.tpl diff --git a/includes/application/design/scripts/deprecated/galaxy_row_ally.tpl b/src/application/design/frontend/base/default/scripts/deprecated/galaxy_row_ally.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/galaxy_row_ally.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/galaxy_row_ally.tpl diff --git a/includes/application/design/scripts/deprecated/galaxy_row_debris.tpl b/src/application/design/frontend/base/default/scripts/deprecated/galaxy_row_debris.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/galaxy_row_debris.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/galaxy_row_debris.tpl diff --git a/includes/application/design/scripts/deprecated/galaxy_row_luna.tpl b/src/application/design/frontend/base/default/scripts/deprecated/galaxy_row_luna.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/galaxy_row_luna.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/galaxy_row_luna.tpl diff --git a/includes/application/design/scripts/deprecated/galaxy_row_planet.tpl b/src/application/design/frontend/base/default/scripts/deprecated/galaxy_row_planet.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/galaxy_row_planet.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/galaxy_row_planet.tpl diff --git a/includes/application/design/scripts/deprecated/galaxy_row_user.tpl b/src/application/design/frontend/base/default/scripts/deprecated/galaxy_row_user.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/galaxy_row_user.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/galaxy_row_user.tpl diff --git a/includes/application/design/scripts/deprecated/gate_fleet_rows.tpl b/src/application/design/frontend/base/default/scripts/deprecated/gate_fleet_rows.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/gate_fleet_rows.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/gate_fleet_rows.tpl diff --git a/includes/application/design/scripts/deprecated/gate_fleet_table.tpl b/src/application/design/frontend/base/default/scripts/deprecated/gate_fleet_table.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/gate_fleet_table.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/gate_fleet_table.tpl diff --git a/includes/application/design/scripts/deprecated/imperium_row.tpl b/src/application/design/frontend/base/default/scripts/deprecated/imperium_row.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/imperium_row.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/imperium_row.tpl diff --git a/includes/application/design/scripts/deprecated/imperium_row2.tpl b/src/application/design/frontend/base/default/scripts/deprecated/imperium_row2.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/imperium_row2.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/imperium_row2.tpl diff --git a/includes/application/design/scripts/deprecated/imperium_table.tpl b/src/application/design/frontend/base/default/scripts/deprecated/imperium_table.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/imperium_table.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/imperium_table.tpl diff --git a/includes/application/design/scripts/deprecated/info_buildings_defense.tpl b/src/application/design/frontend/base/default/scripts/deprecated/info_buildings_defense.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/info_buildings_defense.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/info_buildings_defense.tpl diff --git a/includes/application/design/scripts/deprecated/info_buildings_destroy.tpl b/src/application/design/frontend/base/default/scripts/deprecated/info_buildings_destroy.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/info_buildings_destroy.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/info_buildings_destroy.tpl diff --git a/includes/application/design/scripts/deprecated/info_buildings_fleet.tpl b/src/application/design/frontend/base/default/scripts/deprecated/info_buildings_fleet.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/info_buildings_fleet.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/info_buildings_fleet.tpl diff --git a/includes/application/design/scripts/deprecated/info_buildings_general.tpl b/src/application/design/frontend/base/default/scripts/deprecated/info_buildings_general.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/info_buildings_general.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/info_buildings_general.tpl diff --git a/includes/application/design/scripts/deprecated/info_buildings_table.tpl b/src/application/design/frontend/base/default/scripts/deprecated/info_buildings_table.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/info_buildings_table.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/info_buildings_table.tpl diff --git a/includes/application/design/scripts/deprecated/info_officiers_general.tpl b/src/application/design/frontend/base/default/scripts/deprecated/info_officiers_general.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/info_officiers_general.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/info_officiers_general.tpl diff --git a/includes/application/design/scripts/deprecated/lostpassword.tpl b/src/application/design/frontend/base/default/scripts/deprecated/lostpassword.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/lostpassword.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/lostpassword.tpl diff --git a/includes/application/design/scripts/deprecated/marchand_cristal.tpl b/src/application/design/frontend/base/default/scripts/deprecated/marchand_cristal.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/marchand_cristal.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/marchand_cristal.tpl diff --git a/includes/application/design/scripts/deprecated/marchand_deuterium.tpl b/src/application/design/frontend/base/default/scripts/deprecated/marchand_deuterium.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/marchand_deuterium.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/marchand_deuterium.tpl diff --git a/includes/application/design/scripts/deprecated/marchand_main.tpl b/src/application/design/frontend/base/default/scripts/deprecated/marchand_main.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/marchand_main.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/marchand_main.tpl diff --git a/includes/application/design/scripts/deprecated/marchand_metal.tpl b/src/application/design/frontend/base/default/scripts/deprecated/marchand_metal.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/marchand_metal.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/marchand_metal.tpl diff --git a/includes/application/design/scripts/deprecated/message_body.tpl b/src/application/design/frontend/base/default/scripts/deprecated/message_body.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/message_body.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/message_body.tpl diff --git a/includes/application/design/scripts/deprecated/messages_pm_form.tpl b/src/application/design/frontend/base/default/scripts/deprecated/messages_pm_form.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/messages_pm_form.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/messages_pm_form.tpl diff --git a/includes/application/design/scripts/deprecated/messages_pm_form_bb.tpl b/src/application/design/frontend/base/default/scripts/deprecated/messages_pm_form_bb.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/messages_pm_form_bb.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/messages_pm_form_bb.tpl diff --git a/includes/application/design/scripts/deprecated/multi.tpl b/src/application/design/frontend/base/default/scripts/deprecated/multi.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/multi.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/multi.tpl diff --git a/includes/application/design/scripts/deprecated/notes_body.tpl b/src/application/design/frontend/base/default/scripts/deprecated/notes_body.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/notes_body.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/notes_body.tpl diff --git a/includes/application/design/scripts/deprecated/notes_body_entry.tpl b/src/application/design/frontend/base/default/scripts/deprecated/notes_body_entry.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/notes_body_entry.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/notes_body_entry.tpl diff --git a/includes/application/design/scripts/deprecated/notes_form.tpl b/src/application/design/frontend/base/default/scripts/deprecated/notes_form.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/notes_form.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/notes_form.tpl diff --git a/includes/application/design/scripts/deprecated/officier_body.tpl b/src/application/design/frontend/base/default/scripts/deprecated/officier_body.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/officier_body.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/officier_body.tpl diff --git a/includes/application/design/scripts/deprecated/officier_rows.tpl b/src/application/design/frontend/base/default/scripts/deprecated/officier_rows.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/officier_rows.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/officier_rows.tpl diff --git a/includes/application/design/scripts/deprecated/options_admadd.tpl b/src/application/design/frontend/base/default/scripts/deprecated/options_admadd.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/options_admadd.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/options_admadd.tpl diff --git a/includes/application/design/scripts/deprecated/options_body.tpl b/src/application/design/frontend/base/default/scripts/deprecated/options_body.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/options_body.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/options_body.tpl diff --git a/includes/application/design/scripts/deprecated/options_body_vmode.tpl b/src/application/design/frontend/base/default/scripts/deprecated/options_body_vmode.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/options_body_vmode.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/options_body_vmode.tpl diff --git a/includes/application/design/scripts/deprecated/overall_footer.tpl b/src/application/design/frontend/base/default/scripts/deprecated/overall_footer.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/overall_footer.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/overall_footer.tpl diff --git a/includes/application/design/scripts/deprecated/overview_body.tpl b/src/application/design/frontend/base/default/scripts/deprecated/overview_body.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/overview_body.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/overview_body.tpl diff --git a/includes/application/design/scripts/deprecated/overview_deleteplanet.tpl b/src/application/design/frontend/base/default/scripts/deprecated/overview_deleteplanet.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/overview_deleteplanet.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/overview_deleteplanet.tpl diff --git a/includes/application/design/scripts/deprecated/overview_fleet_event.tpl b/src/application/design/frontend/base/default/scripts/deprecated/overview_fleet_event.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/overview_fleet_event.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/overview_fleet_event.tpl diff --git a/includes/application/design/scripts/deprecated/overview_renameplanet.tpl b/src/application/design/frontend/base/default/scripts/deprecated/overview_renameplanet.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/overview_renameplanet.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/overview_renameplanet.tpl diff --git a/includes/application/design/scripts/deprecated/phalanx_body.tpl b/src/application/design/frontend/base/default/scripts/deprecated/phalanx_body.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/phalanx_body.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/phalanx_body.tpl diff --git a/includes/application/design/scripts/deprecated/records_body.tpl b/src/application/design/frontend/base/default/scripts/deprecated/records_body.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/records_body.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/records_body.tpl diff --git a/includes/application/design/scripts/deprecated/records_section_header.tpl b/src/application/design/frontend/base/default/scripts/deprecated/records_section_header.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/records_section_header.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/records_section_header.tpl diff --git a/includes/application/design/scripts/deprecated/records_section_rows.tpl b/src/application/design/frontend/base/default/scripts/deprecated/records_section_rows.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/records_section_rows.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/records_section_rows.tpl diff --git a/includes/application/design/scripts/deprecated/registry_form.tpl b/src/application/design/frontend/base/default/scripts/deprecated/registry_form.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/registry_form.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/registry_form.tpl diff --git a/includes/application/design/scripts/deprecated/resources.tpl b/src/application/design/frontend/base/default/scripts/deprecated/resources.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/resources.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/resources.tpl diff --git a/includes/application/design/scripts/deprecated/resources_row.tpl b/src/application/design/frontend/base/default/scripts/deprecated/resources_row.tpl similarity index 90% rename from includes/application/design/scripts/deprecated/resources_row.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/resources_row.tpl index 6c9ce84..5592d79 100644 --- a/includes/application/design/scripts/deprecated/resources_row.tpl +++ b/src/application/design/frontend/base/default/scripts/deprecated/resources_row.tpl @@ -5,8 +5,10 @@ \ No newline at end of file diff --git a/includes/application/design/scripts/deprecated/rules_body.tpl b/src/application/design/frontend/base/default/scripts/deprecated/rules_body.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/rules_body.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/rules_body.tpl diff --git a/includes/application/design/scripts/deprecated/search_ally_row.tpl b/src/application/design/frontend/base/default/scripts/deprecated/search_ally_row.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/search_ally_row.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/search_ally_row.tpl diff --git a/includes/application/design/scripts/deprecated/search_ally_table.tpl b/src/application/design/frontend/base/default/scripts/deprecated/search_ally_table.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/search_ally_table.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/search_ally_table.tpl diff --git a/includes/application/design/scripts/deprecated/search_body.tpl b/src/application/design/frontend/base/default/scripts/deprecated/search_body.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/search_body.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/search_body.tpl diff --git a/includes/application/design/scripts/deprecated/search_user_row.tpl b/src/application/design/frontend/base/default/scripts/deprecated/search_user_row.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/search_user_row.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/search_user_row.tpl diff --git a/includes/application/design/scripts/deprecated/search_user_table.tpl b/src/application/design/frontend/base/default/scripts/deprecated/search_user_table.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/search_user_table.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/search_user_table.tpl diff --git a/includes/application/design/scripts/deprecated/serv_infos.tpl b/src/application/design/frontend/base/default/scripts/deprecated/serv_infos.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/serv_infos.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/serv_infos.tpl diff --git a/includes/application/design/scripts/deprecated/simple_footer.tpl b/src/application/design/frontend/base/default/scripts/deprecated/simple_footer.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/simple_footer.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/simple_footer.tpl diff --git a/includes/application/design/scripts/deprecated/simple_header.tpl b/src/application/design/frontend/base/default/scripts/deprecated/simple_header.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/simple_header.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/simple_header.tpl diff --git a/includes/application/design/scripts/deprecated/stat_alliancetable.tpl b/src/application/design/frontend/base/default/scripts/deprecated/stat_alliancetable.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/stat_alliancetable.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/stat_alliancetable.tpl diff --git a/includes/application/design/scripts/deprecated/stat_alliancetable_header.tpl b/src/application/design/frontend/base/default/scripts/deprecated/stat_alliancetable_header.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/stat_alliancetable_header.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/stat_alliancetable_header.tpl diff --git a/includes/application/design/scripts/deprecated/stat_body.tpl b/src/application/design/frontend/base/default/scripts/deprecated/stat_body.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/stat_body.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/stat_body.tpl diff --git a/includes/application/design/scripts/deprecated/stat_playertable.tpl b/src/application/design/frontend/base/default/scripts/deprecated/stat_playertable.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/stat_playertable.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/stat_playertable.tpl diff --git a/includes/application/design/scripts/deprecated/stat_playertable_header.tpl b/src/application/design/frontend/base/default/scripts/deprecated/stat_playertable_header.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/stat_playertable_header.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/stat_playertable_header.tpl diff --git a/includes/application/design/scripts/deprecated/statjoueur.tpl b/src/application/design/frontend/base/default/scripts/deprecated/statjoueur.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/statjoueur.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/statjoueur.tpl diff --git a/includes/application/design/scripts/deprecated/techtree_body.tpl b/src/application/design/frontend/base/default/scripts/deprecated/techtree_body.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/techtree_body.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/techtree_body.tpl diff --git a/includes/application/design/scripts/deprecated/techtree_details.tpl b/src/application/design/frontend/base/default/scripts/deprecated/techtree_details.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/techtree_details.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/techtree_details.tpl diff --git a/includes/application/design/scripts/deprecated/techtree_head.tpl b/src/application/design/frontend/base/default/scripts/deprecated/techtree_head.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/techtree_head.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/techtree_head.tpl diff --git a/includes/application/design/scripts/deprecated/techtree_row.tpl b/src/application/design/frontend/base/default/scripts/deprecated/techtree_row.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/techtree_row.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/techtree_row.tpl diff --git a/includes/application/design/scripts/deprecated/teleport.tpl b/src/application/design/frontend/base/default/scripts/deprecated/teleport.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/teleport.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/teleport.tpl diff --git a/includes/application/design/scripts/deprecated/tradingscrapmetal.tpl b/src/application/design/frontend/base/default/scripts/deprecated/tradingscrapmetal.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/tradingscrapmetal.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/tradingscrapmetal.tpl diff --git a/includes/application/design/scripts/deprecated/tradingscrapmetal_n.tpl b/src/application/design/frontend/base/default/scripts/deprecated/tradingscrapmetal_n.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/tradingscrapmetal_n.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/tradingscrapmetal_n.tpl diff --git a/includes/application/design/scripts/deprecated/usr_banned.tpl b/src/application/design/frontend/base/default/scripts/deprecated/usr_banned.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/usr_banned.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/usr_banned.tpl diff --git a/includes/application/design/scripts/deprecated/usuw_body.tpl b/src/application/design/frontend/base/default/scripts/deprecated/usuw_body.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/usuw_body.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/usuw_body.tpl diff --git a/includes/application/design/scripts/deprecated/zglos.tpl b/src/application/design/frontend/base/default/scripts/deprecated/zglos.tpl similarity index 100% rename from includes/application/design/scripts/deprecated/zglos.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/zglos.tpl diff --git a/src/application/design/frontend/base/default/scripts/empire/planet/buildings.phtml b/src/application/design/frontend/base/default/scripts/empire/planet/buildings.phtml new file mode 100644 index 0000000..e2e2580 --- /dev/null +++ b/src/application/design/frontend/base/default/scripts/empire/planet/buildings.phtml @@ -0,0 +1,28 @@ +
    +

    __('Buildings')?>

    + getPartial('item-list.items')->render()?> +
    +
    + \ No newline at end of file diff --git a/src/application/design/frontend/base/default/scripts/empire/planet/buildings/item.phtml b/src/application/design/frontend/base/default/scripts/empire/planet/buildings/item.phtml new file mode 100644 index 0000000..1d3fb40 --- /dev/null +++ b/src/application/design/frontend/base/default/scripts/empire/planet/buildings/item.phtml @@ -0,0 +1,36 @@ + +
    +
    +

    escape($this->getName())?>

    +

    __('Level %d', $this->renderNumber($this->getLevel()))?>

    +
    +
    + + isBuildable()):?> +
    +

    __('Resources Needed')?>

    +
    + + + +
    +

    getDescription()?>

    +
      + getResourcesConfigForNextLevel() as $resourceId => $resourceConfig):?> +
    • + getResourceName($resourceId)?> + renderNumber($resourceConfig->getData('value'))?> + hasData('requirement')):?> + (renderNumber($resourceConfig->getData('requirement'))?>) + + (renderNumber($resourceConfig->getData('overflow'))?>) + +
    • + +
    +

    __('Building time: %s', $this->renderTime($this->getBuildingTimeForNextLevel(), true))?> +

    +
    +
    diff --git a/src/application/design/frontend/base/default/scripts/empire/planet/buildings/queue.phtml b/src/application/design/frontend/base/default/scripts/empire/planet/buildings/queue.phtml new file mode 100644 index 0000000..0549d6c --- /dev/null +++ b/src/application/design/frontend/base/default/scripts/empire/planet/buildings/queue.phtml @@ -0,0 +1,6 @@ +isEmpty()):?> +
    +

    __('Work in progress')?>

    +renderPartial('item-list') ?> +
    + diff --git a/src/application/design/frontend/base/default/scripts/empire/planet/buildings/queue/item.phtml b/src/application/design/frontend/base/default/scripts/empire/planet/buildings/queue/item.phtml new file mode 100644 index 0000000..827f75f --- /dev/null +++ b/src/application/design/frontend/base/default/scripts/empire/planet/buildings/queue/item.phtml @@ -0,0 +1,11 @@ + +
    +

    + + escape($this->getName())?> (renderNumber($this->getItemQueuedLevel())?>) +

    +

    __('Lasts %s', $this->renderTime($this->getBuildingRemainingTime()))?>

    + +
    diff --git a/src/application/design/frontend/base/default/scripts/empire/planet/research-lab.phtml b/src/application/design/frontend/base/default/scripts/empire/planet/research-lab.phtml new file mode 100644 index 0000000..d5a743a --- /dev/null +++ b/src/application/design/frontend/base/default/scripts/empire/planet/research-lab.phtml @@ -0,0 +1,19 @@ +
    +

    __('Research Laboratory')?>

    + getPartial('item-list.items')->render()?> +
    +
    + \ No newline at end of file diff --git a/src/application/design/frontend/base/default/scripts/empire/planet/research-lab/item.phtml b/src/application/design/frontend/base/default/scripts/empire/planet/research-lab/item.phtml new file mode 100644 index 0000000..552f840 --- /dev/null +++ b/src/application/design/frontend/base/default/scripts/empire/planet/research-lab/item.phtml @@ -0,0 +1,30 @@ + +
    +
    +

    escape($this->getName())?>

    +

    __('Level %d', $this->renderNumber($this->getLevel()))?>

    +
    +
    + + +
    +

    getDescription()?>

    +
      + getResourcesConfigForNextLevel() as $resourceId => $resourceConfig):?> +
    • + getResourceName($resourceId)?> + renderNumber($resourceConfig->getData('value'))?> + hasData('requirement')):?> + (renderNumber($resourceConfig->getData('requirement'))?>) + + (renderNumber($resourceConfig->getData('overflow'))?>) + +
    • + +
    +

    __('Building time: %s', $this->renderTime($this->getBuildingTimeForNextLevel(), false))?> +

    +
    +
    diff --git a/includes/application/design/scripts/empire/planet/buildings/queue.phtml b/src/application/design/frontend/base/default/scripts/empire/planet/research-lab/queue.phtml similarity index 100% rename from includes/application/design/scripts/empire/planet/buildings/queue.phtml rename to src/application/design/frontend/base/default/scripts/empire/planet/research-lab/queue.phtml diff --git a/src/application/design/frontend/base/default/scripts/empire/planet/research-lab/queue/item.phtml b/src/application/design/frontend/base/default/scripts/empire/planet/research-lab/queue/item.phtml new file mode 100644 index 0000000..ac60627 --- /dev/null +++ b/src/application/design/frontend/base/default/scripts/empire/planet/research-lab/queue/item.phtml @@ -0,0 +1,11 @@ + +
    +

    + + escape($this->getName())?> (renderNumber($this->getItemQueuedLevel())?>) +

    +

    __('Lasts %s', $this->renderTime($this->getBuildingRemainingTime()))?>

    + +
    diff --git a/src/application/design/frontend/base/default/scripts/empire/planet/shipyard.phtml b/src/application/design/frontend/base/default/scripts/empire/planet/shipyard.phtml new file mode 100644 index 0000000..6b75a1a --- /dev/null +++ b/src/application/design/frontend/base/default/scripts/empire/planet/shipyard.phtml @@ -0,0 +1,31 @@ +
    +

    __('Shipyard')?>

    + + getPartial('item-list.items')->render()?> + + +
    + +
    diff --git a/src/application/design/frontend/base/default/scripts/empire/planet/shipyard/item.phtml b/src/application/design/frontend/base/default/scripts/empire/planet/shipyard/item.phtml new file mode 100644 index 0000000..ec6e2b0 --- /dev/null +++ b/src/application/design/frontend/base/default/scripts/empire/planet/shipyard/item.phtml @@ -0,0 +1,35 @@ + +
    +
    +

    escape($this->getName())?>

    +

    __('Class %s', $this->escape($this->getClass()))?>

    +

    __('Current count: %s', $this->renderNumber($this->getQty()))?>

    +
    +
    + +
    +

    + +
    + +
    +

    getDescription()?>

    +
      + getResourcesConfigForQty(1) as $resourceId => $resourceConfig):?> +
    • + getResourceName($resourceId)?> + renderNumber($resourceConfig->getData('value'))?> + hasData('requirement')):?> + (renderNumber($resourceConfig->getData('requirement'))?>) + + (renderNumber($resourceConfig->getData('overflow'))?>) + +
    • + +
    +

    __('Building time: %s', $this->renderTime($this->getBuildingTime(1), false))?> +

    +
    +
    diff --git a/includes/application/design/scripts/empire/planet/research-lab/queue.phtml b/src/application/design/frontend/base/default/scripts/empire/planet/shipyard/queue.phtml similarity index 92% rename from includes/application/design/scripts/empire/planet/research-lab/queue.phtml rename to src/application/design/frontend/base/default/scripts/empire/planet/shipyard/queue.phtml index d11b574..c63a203 100644 --- a/includes/application/design/scripts/empire/planet/research-lab/queue.phtml +++ b/src/application/design/frontend/base/default/scripts/empire/planet/shipyard/queue.phtml @@ -3,4 +3,4 @@

    __('Work in progress')?>

    getPartial('item-list')->render() ?> - \ No newline at end of file + diff --git a/src/application/design/frontend/base/default/scripts/empire/planet/shipyard/queue/item.phtml b/src/application/design/frontend/base/default/scripts/empire/planet/shipyard/queue/item.phtml new file mode 100644 index 0000000..5592945 --- /dev/null +++ b/src/application/design/frontend/base/default/scripts/empire/planet/shipyard/queue/item.phtml @@ -0,0 +1,8 @@ + +
    +

    + + escape($this->getName())?> (renderNumber($this->getItemQueuedQty())?>) +

    +

    __('Lasts %s', $this->renderTime($this->getBuildingRemainingTime()))?>

    +
    diff --git a/includes/application/design/scripts/empire/resources/default.phtml b/src/application/design/frontend/base/default/scripts/empire/resources/default.phtml similarity index 100% rename from includes/application/design/scripts/empire/resources/default.phtml rename to src/application/design/frontend/base/default/scripts/empire/resources/default.phtml diff --git a/includes/application/design/scripts/empire/resources/energy.phtml b/src/application/design/frontend/base/default/scripts/empire/resources/energy.phtml similarity index 100% rename from includes/application/design/scripts/empire/resources/energy.phtml rename to src/application/design/frontend/base/default/scripts/empire/resources/energy.phtml diff --git a/src/application/design/frontend/base/default/scripts/empire/topnav.phtml b/src/application/design/frontend/base/default/scripts/empire/topnav.phtml new file mode 100644 index 0000000..cd3877b --- /dev/null +++ b/src/application/design/frontend/base/default/scripts/empire/topnav.phtml @@ -0,0 +1,95 @@ +getCurrentPlanet();?> +
    +
    +getPlanetCollection() as $planet):?> + getId() != $currentPlanet->getId()):?> + + +
    +

    escape($planet->getName())?>

    +
    + getMoon()) !== null): ?> + + + + + + + +
    +

    [escape($planet->getCoords())?>]

    +
    + + +
    +
    +
    +
    +
    +
    + <?php echo $this->__('Metal')?> +

    + getCurrentPlanet()->isResourceCapped(Legacies_Empire::RESOURCE_METAL)):?> + renderNumber($this->getCurrentPlanet()->getResourceAmount(Legacies_Empire::RESOURCE_METAL))?> + + renderNumber($this->getCurrentPlanet()->getResourceAmount(Legacies_Empire::RESOURCE_METAL))?> + +

    +
    +
    + <?php echo $this->__('Cristal')?> +

    + getCurrentPlanet()->isResourceCapped(Legacies_Empire::RESOURCE_CRISTAL)):?> + renderNumber($this->getCurrentPlanet()->getResourceAmount(Legacies_Empire::RESOURCE_CRISTAL))?> + + renderNumber($this->getCurrentPlanet()->getResourceAmount(Legacies_Empire::RESOURCE_CRISTAL))?> + +

    +
    +
    + <?php echo $this->__('Deuterium')?> +

    + getCurrentPlanet()->isResourceCapped(Legacies_Empire::RESOURCE_DEUTERIUM)):?> + renderNumber($this->getCurrentPlanet()->getResourceAmount(Legacies_Empire::RESOURCE_DEUTERIUM))?> + + renderNumber($this->getCurrentPlanet()->getResourceAmount(Legacies_Empire::RESOURCE_DEUTERIUM))?> + +

    +
    +
    + <?php echo $this->__('Energy')?> +

    + getCurrentPlanet()->isResourceCapped(Legacies_Empire::RESOURCE_ENERGY)):?> + renderNumber($this->getCurrentPlanet()->getResourceAmount(Legacies_Empire::RESOURCE_ENERGY))?> / renderNumber($this->getCurrentPlanet()->getResourceCap(Legacies_Empire::RESOURCE_ENERGY))?> + + renderNumber($this->getCurrentPlanet()->getResourceAmount(Legacies_Empire::RESOURCE_ENERGY))?> / renderNumber($this->getCurrentPlanet()->getResourceCap(Legacies_Empire::RESOURCE_ENERGY))?> + +

    +
    +
    + <?php echo $this->__('Messages')?> +

    + getCurrentPlayer()->getNewMessagesCount()) > 1):?> + __('%1$d messages.', $count)?> + + __('1 message.')?> + + __('No message.')?> + +

    +
    +
    +
    diff --git a/src/application/design/frontend/base/default/scripts/page/1column.phtml b/src/application/design/frontend/base/default/scripts/page/1column.phtml new file mode 100644 index 0000000..ffaa1c8 --- /dev/null +++ b/src/application/design/frontend/base/default/scripts/page/1column.phtml @@ -0,0 +1,15 @@ + + + head->render()?> + + getBodyClasses()):?> class="escape($classes)?>"> +
    +
    + header->render()?> +
    +
    + content->render()?> +
    +
    + + diff --git a/src/application/design/frontend/base/default/scripts/page/2columns-left.phtml b/src/application/design/frontend/base/default/scripts/page/2columns-left.phtml new file mode 100644 index 0000000..c2a4134 --- /dev/null +++ b/src/application/design/frontend/base/default/scripts/page/2columns-left.phtml @@ -0,0 +1,21 @@ + + + head->render()?> + + getBodyClasses()):?> class="escape($classes)?>"> +
    +
    + header->render()?> +
    +
    +
    + left->render()?> +
    +
    + content->render()?> +
    +
    +
    +
    + + diff --git a/src/application/design/frontend/base/default/scripts/page/2columns-right.phtml b/src/application/design/frontend/base/default/scripts/page/2columns-right.phtml new file mode 100644 index 0000000..946e2c1 --- /dev/null +++ b/src/application/design/frontend/base/default/scripts/page/2columns-right.phtml @@ -0,0 +1,21 @@ + + + head->render()?> + + getBodyClasses()):?> class="escape($classes)?>"> +
    +
    + header->render()?> +
    +
    +
    + content->render()?> +
    +
    + left->render()?> +
    +
    +
    +
    + + diff --git a/src/application/design/frontend/base/default/scripts/page/3columns.phtml b/src/application/design/frontend/base/default/scripts/page/3columns.phtml new file mode 100644 index 0000000..1b1248a --- /dev/null +++ b/src/application/design/frontend/base/default/scripts/page/3columns.phtml @@ -0,0 +1,24 @@ + + + head->render()?> + + getBodyClasses()):?> class="escape($classes)?>"> +
    +
    + header->render()?> +
    +
    +
    + left->render()?> +
    +
    + content->render()?> +
    +
    + left->render()?> +
    +
    +
    +
    + + diff --git a/src/application/design/frontend/base/default/scripts/page/html/head.phtml b/src/application/design/frontend/base/default/scripts/page/html/head.phtml new file mode 100644 index 0000000..cb74234 --- /dev/null +++ b/src/application/design/frontend/base/default/scripts/page/html/head.phtml @@ -0,0 +1,34 @@ +<?php echo $this->escape($this->getTitle())?> + +getCss() as $css):?> + + +getInlineCss() as $css):?> + + + +getJs() as $js):?> + + +getSkinJs() as $js):?> + + +getInlineJs() as $js):?> + + + \ No newline at end of file diff --git a/src/application/design/frontend/base/default/scripts/page/html/home.phtml b/src/application/design/frontend/base/default/scripts/page/html/home.phtml new file mode 100644 index 0000000..2970804 --- /dev/null +++ b/src/application/design/frontend/base/default/scripts/page/html/home.phtml @@ -0,0 +1,7 @@ + +getLayout()->getMessagesBlock()->renderGroupedHtml()?> +
    +

    getTitle()?>

    +

    getFormatedWelcomeText()?>

    + +
    diff --git a/src/application/design/frontend/base/default/scripts/page/html/message.phtml b/src/application/design/frontend/base/default/scripts/page/html/message.phtml new file mode 100644 index 0000000..1f3c4c9 --- /dev/null +++ b/src/application/design/frontend/base/default/scripts/page/html/message.phtml @@ -0,0 +1,4 @@ +
    +

    escape($this->getData('title'))?>

    +

    escape($this->getData('message'))?>

    +
    \ No newline at end of file diff --git a/src/application/design/frontend/base/default/scripts/page/html/navigation.phtml b/src/application/design/frontend/base/default/scripts/page/html/navigation.phtml new file mode 100644 index 0000000..612ee09 --- /dev/null +++ b/src/application/design/frontend/base/default/scripts/page/html/navigation.phtml @@ -0,0 +1,28 @@ + diff --git a/src/application/design/frontend/base/default/scripts/page/html/navigation/link.phtml b/src/application/design/frontend/base/default/scripts/page/html/navigation/link.phtml new file mode 100644 index 0000000..4fa6fc8 --- /dev/null +++ b/src/application/design/frontend/base/default/scripts/page/html/navigation/link.phtml @@ -0,0 +1,3 @@ + + getAttributes() as $attributeName => $attributeValue):?> ="">escape($this->getLabel())?> + diff --git a/src/application/design/frontend/base/default/scripts/page/html/navigation/node.phtml b/src/application/design/frontend/base/default/scripts/page/html/navigation/node.phtml new file mode 100644 index 0000000..266fae4 --- /dev/null +++ b/src/application/design/frontend/base/default/scripts/page/html/navigation/node.phtml @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/src/application/design/frontend/base/default/scripts/page/html/no-route.phtml b/src/application/design/frontend/base/default/scripts/page/html/no-route.phtml new file mode 100644 index 0000000..9a65c8b --- /dev/null +++ b/src/application/design/frontend/base/default/scripts/page/html/no-route.phtml @@ -0,0 +1,5 @@ +
    +

    __('Not found')?>

    +

    __('The page you requested could not be found, please check your input.')?>

    +

    __('Back to the home page.')?>

    +
    \ No newline at end of file diff --git a/src/application/design/frontend/base/default/scripts/page/html/top-bar.phtml b/src/application/design/frontend/base/default/scripts/page/html/top-bar.phtml new file mode 100644 index 0000000..8fffea9 --- /dev/null +++ b/src/application/design/frontend/base/default/scripts/page/html/top-bar.phtml @@ -0,0 +1,14 @@ +
    +
    + isLoggedIn()):?> + + __('Register')?> + __('There are %d registered players', $this->getPlayerCount())?> + + __('Logged in as %s', $this->escape($this->getPlayer()->getUsername()))?> + __('Logout')?> + __('Back to the game')?> + + __('There are %d online players', $this->getOnlinePlayerCount())?> +
    +
    \ No newline at end of file diff --git a/src/application/design/frontend/base/default/scripts/player/login.phtml b/src/application/design/frontend/base/default/scripts/player/login.phtml new file mode 100644 index 0000000..c4222de --- /dev/null +++ b/src/application/design/frontend/base/default/scripts/player/login.phtml @@ -0,0 +1,24 @@ +getLayout()->getMessagesBlock()->renderGroupedHtml()?> +
    +
    + __('Login')?> +

    + + +

    +

    + + +

    +

    + + +

    +

    + __('I have lost my password.')?> +

    +
    +

    + +

    + diff --git a/src/application/design/frontend/base/default/scripts/player/lost-password.phtml b/src/application/design/frontend/base/default/scripts/player/lost-password.phtml new file mode 100644 index 0000000..f44b287 --- /dev/null +++ b/src/application/design/frontend/base/default/scripts/player/lost-password.phtml @@ -0,0 +1,17 @@ +getLayout()->getMessagesBlock()->renderGroupedHtml()?> +
    +
    + __('Lost your password?')?> +

    + + +

    + +
    +

    + +

    + diff --git a/src/application/design/frontend/base/default/scripts/player/overview.phtml b/src/application/design/frontend/base/default/scripts/player/overview.phtml new file mode 100644 index 0000000..67eb785 --- /dev/null +++ b/src/application/design/frontend/base/default/scripts/player/overview.phtml @@ -0,0 +1,11 @@ +getLayout()->getMessagesBlock()->renderGroupedHtml()?> +
    +

    __('Overview')?>

    +
    + renderPartial('overview.left')?> +
    +
    + renderPartial('overview.center')?> +
    +
    +
    diff --git a/src/application/design/frontend/base/default/scripts/player/overview/fleet/item.phtml b/src/application/design/frontend/base/default/scripts/player/overview/fleet/item.phtml new file mode 100644 index 0000000..f66e128 --- /dev/null +++ b/src/application/design/frontend/base/default/scripts/player/overview/fleet/item.phtml @@ -0,0 +1,39 @@ +
    + renderDateTime($this->getStartTime())?> + renderDateTime($this->getActionTime())?> + renderDateTime($this->getArrivalTime())?> +
    + getPlayer() ?> + isOwner() && ($this->isMission(Legacies_Empire::ID_MISSION_TRANSPORT) || $this->isMission(Legacies_Empire::ID_MISSION_STATION) || $this->isMission(Legacies_Empire::ID_MISSION_STATION_ALLY))):?> + + __('An hostile fleet sent by %1$s, coming from %2$s[%3$s], reaches your planet %4$s[%5$s]. It has been sent with the mission: %6$s', + implode(', ', $this->getFleetOwnerUsernames()), + $this->getOriginPlanetName(), $this->getOriginPlanetCoords(), + $this->getDestinationPlanetName(), $this->getDestinationPlanetCoords(), + $this->getMissionLabel())?> + + isOwner() && ($this->isMission(Legacies_Empire::ID_MISSION_ATTACK) || $this->isMission(Legacies_Empire::ID_MISSION_GROUP_ATTACK) || $this->isMission(Legacies_Empire::ID_MISSION_DESTROY) || $this->isMission(Legacies_Empire::ID_MISSION_MISSILES) || $this->isMission(Legacies_Empire::ID_MISSION_SPY))):?> + + __('Your hostile fleet sent from %1$s[%2$s], reaches %3$s\'s planet %4$s[%5$s]. It has been sent with the mission: %6$s', + $this->getOriginPlanetName(), $this->getOriginPlanetCoords(), + implode(', ', $this->getFleetOwnerUsernames()), + $this->getDestinationPlanetName(), $this->getDestinationPlanetCoords(), + $this->getMissionLabel())?> + + isOwner()):?> + + __('Your peaceful fleet sent from %1$s[%2$s], reaches the planet %3$s[%4$s]. It has been sent with the mission: %5$s', + $this->getOriginPlanetName(), $this->getOriginPlanetCoords(), + $this->getDestinationPlanetName(), $this->getDestinationPlanetCoords(), + $this->getMissionLabel())?> + + + + __('A peaceful fleet sent by %1$s, coming from %2$s[%3$s], reaches the planet %4$s[%5$s]. It has been sent with the mission: %6$s', + implode(', ', $this->getFleetOwnerUsernames()), + $this->getOriginPlanetName(), $this->getOriginPlanetCoords(), + $this->getDestinationPlanetName(), $this->getDestinationPlanetCoords(), + $this->getMissionLabel())?> + +
    +
    diff --git a/src/application/design/frontend/base/default/scripts/player/overview/fleet/list.phtml b/src/application/design/frontend/base/default/scripts/player/overview/fleet/list.phtml new file mode 100644 index 0000000..d5d0e4e --- /dev/null +++ b/src/application/design/frontend/base/default/scripts/player/overview/fleet/list.phtml @@ -0,0 +1,9 @@ +
    +

    __('Fleets') ?>

    + getFleetCollection()?> + getSize() > 0): ?> + renderPartial('item-list')?> + +

    __('There are currently no fleets.')?>

    + +
    diff --git a/includes/application/design/scripts/empire/overview/form/destroy-planet.phtml b/src/application/design/frontend/base/default/scripts/player/overview/form/destroy-planet.phtml similarity index 100% rename from includes/application/design/scripts/empire/overview/form/destroy-planet.phtml rename to src/application/design/frontend/base/default/scripts/player/overview/form/destroy-planet.phtml diff --git a/src/application/design/frontend/base/default/scripts/player/overview/form/rename-planet.phtml b/src/application/design/frontend/base/default/scripts/player/overview/form/rename-planet.phtml new file mode 100644 index 0000000..94f0148 --- /dev/null +++ b/src/application/design/frontend/base/default/scripts/player/overview/form/rename-planet.phtml @@ -0,0 +1,16 @@ +
    +
    + +

    + + +

    +

    + + +

    +

    + +

    +
    + \ No newline at end of file diff --git a/includes/application/design/scripts/empire/overview/messages.phtml b/src/application/design/frontend/base/default/scripts/player/overview/messages.phtml similarity index 100% rename from includes/application/design/scripts/empire/overview/messages.phtml rename to src/application/design/frontend/base/default/scripts/player/overview/messages.phtml diff --git a/src/application/design/frontend/base/default/scripts/player/overview/planet/list/item.phtml b/src/application/design/frontend/base/default/scripts/player/overview/planet/list/item.phtml new file mode 100644 index 0000000..44b2fd5 --- /dev/null +++ b/src/application/design/frontend/base/default/scripts/player/overview/planet/list/item.phtml @@ -0,0 +1,14 @@ +
    + + + diff --git a/src/application/design/frontend/base/default/scripts/player/overview/planet/mini.phtml b/src/application/design/frontend/base/default/scripts/player/overview/planet/mini.phtml new file mode 100644 index 0000000..c30fdda --- /dev/null +++ b/src/application/design/frontend/base/default/scripts/player/overview/planet/mini.phtml @@ -0,0 +1,7 @@ +
    +

    escape($this->getPlanetName())?>

    +

    escape($this->getPlanetCoords())?>

    +

    + +

    +
    diff --git a/src/application/design/frontend/base/default/scripts/player/overview/planet/view.phtml b/src/application/design/frontend/base/default/scripts/player/overview/planet/view.phtml new file mode 100644 index 0000000..c4a724d --- /dev/null +++ b/src/application/design/frontend/base/default/scripts/player/overview/planet/view.phtml @@ -0,0 +1 @@ +renderPartial('planet-list') ?> diff --git a/src/application/design/frontend/base/default/scripts/player/overview/stats/mini.phtml b/src/application/design/frontend/base/default/scripts/player/overview/stats/mini.phtml new file mode 100644 index 0000000..6ca6d7d --- /dev/null +++ b/src/application/design/frontend/base/default/scripts/player/overview/stats/mini.phtml @@ -0,0 +1,8 @@ +
    +

    __('Your statistics')?>

    +
      + getPlayerStatData() as $stat): ?> +
    • + +
    +
    diff --git a/includes/application/design/scripts/user/registration.phtml b/src/application/design/frontend/base/default/scripts/player/registration.phtml similarity index 68% rename from includes/application/design/scripts/user/registration.phtml rename to src/application/design/frontend/base/default/scripts/player/registration.phtml index f2503bc..efdea56 100644 --- a/includes/application/design/scripts/user/registration.phtml +++ b/src/application/design/frontend/base/default/scripts/player/registration.phtml @@ -1,36 +1,40 @@ - +getLayout()->getMessagesBlock()->renderGroupedHtml()?> + +

    __('Register')?>

    __('User data:')?> -

    +

    -

    +

    -

    +

    __('Password:')?> -

    +

    -

    +

    __('Planet:')?> -

    +

    - - \ No newline at end of file +

    + +

    + diff --git a/src/application/design/install/base/default/layouts/install.php b/src/application/design/install/base/default/layouts/install.php new file mode 100644 index 0000000..4778442 --- /dev/null +++ b/src/application/design/install/base/default/layouts/install.php @@ -0,0 +1,165 @@ + array( + 'update' => array('2columns-left'), + 'reference' => array( + 'content' => array( + 'children' => array( + 'status' => array( + 'type' => 'core/template', + 'template' => 'status.phtml' + ) + ) + ) + ) + ), + + 'install.intro' => array( + 'update' => array('install'), + 'reference' => array( + 'content' => array( + 'children' => array( + 'overview' => array( + 'type' => 'core/template', + 'template' => 'intro.phtml' + ), + ) + ), + 'status' => array( + 'actions' => array( + array( + 'method' => 'setData', + 'params' => array( + 'key' => 'step', + 'value' => 0 + ) + ) + ) + ) + ) + ), + + 'install.step.system' => array( + 'update' => array('install'), + 'reference' => array( + 'content' => array( + 'children' => array( + 'overview' => array( + 'type' => 'core/template', + 'template' => 'step/system.phtml' + ), + ) + ), + 'status' => array( + 'actions' => array( + array( + 'method' => 'setData', + 'params' => array( + 'key' => 'step', + 'value' => 1 + ) + ) + ) + ) + ) + ), + + 'install.step.database' => array( + 'update' => array('install'), + 'reference' => array( + 'content' => array( + 'children' => array( + 'overview' => array( + 'type' => 'core/template', + 'template' => 'step/database.phtml' + ), + ) + ), + 'status' => array( + 'actions' => array( + array( + 'method' => 'setData', + 'params' => array( + 'key' => 'step', + 'value' => 2 + ) + ) + ) + ) + ) + ), + + 'install.step.universe' => array( + 'update' => array('install'), + 'reference' => array( + 'content' => array( + 'children' => array( + 'overview' => array( + 'type' => 'core/template', + 'template' => 'step/universe.phtml' + ), + ) + ), + 'status' => array( + 'actions' => array( + array( + 'method' => 'setData', + 'params' => array( + 'key' => 'step', + 'value' => 3 + ) + ) + ) + ) + ) + ), + + 'install.step.profile' => array( + 'update' => array('install'), + 'reference' => array( + 'content' => array( + 'children' => array( + 'overview' => array( + 'type' => 'core/template', + 'template' => 'step/profile.phtml' + ), + ) + ), + 'status' => array( + 'actions' => array( + array( + 'method' => 'setData', + 'params' => array( + 'key' => 'step', + 'value' => 4 + ) + ) + ) + ) + ) + ), + + 'install.summary' => array( + 'update' => array('install'), + 'reference' => array( + 'content' => array( + 'children' => array( + 'overview' => array( + 'type' => 'core/template', + 'template' => 'summary.phtml' + ), + ) + ), + 'status' => array( + 'actions' => array( + array( + 'method' => 'setData', + 'params' => array( + 'key' => 'step', + 'value' => 5 + ) + ) + ) + ) + ) + ), + ); diff --git a/src/application/design/install/base/default/layouts/page.xml b/src/application/design/install/base/default/layouts/page.xml new file mode 100644 index 0000000..e0837eb --- /dev/null +++ b/src/application/design/install/base/default/layouts/page.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + page/2columns-left.phtml + + + + + + + + + + page/2columns-right.phtml + + + + + + + + + + page/3columns.phtml + + + + + + + + + + css/base.css + + + scripts/jquery/jquery-1.6.4.js + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/application/design/install/base/default/scripts/intro.phtml b/src/application/design/install/base/default/scripts/intro.phtml new file mode 100644 index 0000000..59beb4c --- /dev/null +++ b/src/application/design/install/base/default/scripts/intro.phtml @@ -0,0 +1,7 @@ +
    +

    __('Welcome to the Wootook! installer')?>

    + getLayout()->getMessagesblock()->renderGroupedHtml()?> +

    __('This page will guide you through the installation proces of Wootook! the MMO game engine platform.')?>

    +

    __('Feel free to ask for help at any time at wootook.org.', 'http://wootook.org/board/')?>

    +

    +
    \ No newline at end of file diff --git a/includes/application/design/scripts/page/1column.phtml b/src/application/design/install/base/default/scripts/page/1column.phtml similarity index 100% rename from includes/application/design/scripts/page/1column.phtml rename to src/application/design/install/base/default/scripts/page/1column.phtml diff --git a/includes/application/design/scripts/page/2columns-left.phtml b/src/application/design/install/base/default/scripts/page/2columns-left.phtml similarity index 100% rename from includes/application/design/scripts/page/2columns-left.phtml rename to src/application/design/install/base/default/scripts/page/2columns-left.phtml diff --git a/includes/application/design/scripts/page/2columns-right.phtml b/src/application/design/install/base/default/scripts/page/2columns-right.phtml similarity index 100% rename from includes/application/design/scripts/page/2columns-right.phtml rename to src/application/design/install/base/default/scripts/page/2columns-right.phtml diff --git a/includes/application/design/scripts/page/3columns.phtml b/src/application/design/install/base/default/scripts/page/3columns.phtml similarity index 100% rename from includes/application/design/scripts/page/3columns.phtml rename to src/application/design/install/base/default/scripts/page/3columns.phtml diff --git a/src/application/design/install/base/default/scripts/page/html/head.phtml b/src/application/design/install/base/default/scripts/page/html/head.phtml new file mode 100644 index 0000000..b98b464 --- /dev/null +++ b/src/application/design/install/base/default/scripts/page/html/head.phtml @@ -0,0 +1,26 @@ +<?php echo $this->escape($this->getTitle())?> + +getCss() as $css):?> + + +getInlineCss() as $css):?> + + + +getJs() as $js):?> + + +getSkinJs() as $js):?> + + +getInlineJs() as $js):?> + + \ No newline at end of file diff --git a/src/application/design/install/base/default/scripts/page/html/message.phtml b/src/application/design/install/base/default/scripts/page/html/message.phtml new file mode 100644 index 0000000..1f3c4c9 --- /dev/null +++ b/src/application/design/install/base/default/scripts/page/html/message.phtml @@ -0,0 +1,4 @@ +
    +

    escape($this->getData('title'))?>

    +

    escape($this->getData('message'))?>

    +
    \ No newline at end of file diff --git a/src/application/design/install/base/default/scripts/page/html/navigation.phtml b/src/application/design/install/base/default/scripts/page/html/navigation.phtml new file mode 100644 index 0000000..1d00580 --- /dev/null +++ b/src/application/design/install/base/default/scripts/page/html/navigation.phtml @@ -0,0 +1,18 @@ + + diff --git a/src/application/design/install/base/default/scripts/page/html/navigation/link.phtml b/src/application/design/install/base/default/scripts/page/html/navigation/link.phtml new file mode 100644 index 0000000..4fa6fc8 --- /dev/null +++ b/src/application/design/install/base/default/scripts/page/html/navigation/link.phtml @@ -0,0 +1,3 @@ + + getAttributes() as $attributeName => $attributeValue):?> ="">escape($this->getLabel())?> + diff --git a/src/application/design/install/base/default/scripts/page/html/navigation/node.phtml b/src/application/design/install/base/default/scripts/page/html/navigation/node.phtml new file mode 100644 index 0000000..bce2e23 --- /dev/null +++ b/src/application/design/install/base/default/scripts/page/html/navigation/node.phtml @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/src/application/design/install/base/default/scripts/status.phtml b/src/application/design/install/base/default/scripts/status.phtml new file mode 100644 index 0000000..89d29d3 --- /dev/null +++ b/src/application/design/install/base/default/scripts/status.phtml @@ -0,0 +1,9 @@ +
    + getData('step')?> +

    __('Welcome')?>

    +

    __('System')?>

    +

    __('Database')?>

    +

    __('Universe')?>

    +

    __('Admin profile')?>

    +

    __('Summary')?>

    +
    \ No newline at end of file diff --git a/src/application/design/install/base/default/scripts/step/database.phtml b/src/application/design/install/base/default/scripts/step/database.phtml new file mode 100644 index 0000000..7adaf52 --- /dev/null +++ b/src/application/design/install/base/default/scripts/step/database.phtml @@ -0,0 +1,65 @@ + +
    +

    __('Welcome to the Wootook! installer')?>

    +

    __('Database Config')?>

    + getLayout()->getMessagesblock()->renderGroupedHtml()?> +
    + +

    + + +

    +

    + + +

    +

    + + +

    +

    + + +

    +

    + + +

    +

    + + +

    +

    + + +

    +
    + +
    + \ No newline at end of file diff --git a/src/application/design/install/base/default/scripts/step/profile.phtml b/src/application/design/install/base/default/scripts/step/profile.phtml new file mode 100644 index 0000000..b8cccf4 --- /dev/null +++ b/src/application/design/install/base/default/scripts/step/profile.phtml @@ -0,0 +1,30 @@ + +
    +

    __('Welcome to the Wootook! installer')?>

    +

    __('Admin Profile Config')?>

    + getLayout()->getMessagesblock()->renderGroupedHtml()?> +
    + +

    + + +

    +

    + + +

    +

    + + +

    +

    + + +

    +

    + + +

    +

    + +
    \ No newline at end of file diff --git a/src/application/design/install/base/default/scripts/step/system.phtml b/src/application/design/install/base/default/scripts/step/system.phtml new file mode 100644 index 0000000..7978c32 --- /dev/null +++ b/src/application/design/install/base/default/scripts/step/system.phtml @@ -0,0 +1,477 @@ + +
    +

    __('Welcome to the Wootook! installer')?>

    +

    __('System Config')?>

    + getLayout()->getMessagesblock()->renderGroupedHtml()?> +
    + +

    + + +

    +

    + + +

    +

    + +
    \ No newline at end of file diff --git a/src/application/design/install/base/default/scripts/step/universe.phtml b/src/application/design/install/base/default/scripts/step/universe.phtml new file mode 100644 index 0000000..9bcc975 --- /dev/null +++ b/src/application/design/install/base/default/scripts/step/universe.phtml @@ -0,0 +1,37 @@ + +
    +

    __('Welcome to the Wootook! installer')?>

    +

    __('Universe Config')?>

    + getLayout()->getMessagesblock()->renderGroupedHtml()?> +
    + +

    + + +

    +

    + + +

    +

    + + +

    +

    + + getFormData('allow_spy_drone_attacks', true)):?>checked="checked" name="allow_spy_drone_attacks" value="1" /> +

    +

    + + + getFormData('use_large_numbers', true)):?>checked="checked" name="use_large_numbers" value="1" /> + + getFormData('use_large_numbers', false)):?>checked="checked" name="use_large_numbers" value="1" /> + __("'BC Math' extension is unavailable. This option will have no effect until the extension isn't active.")?> + +

    +

    + +

    + +
    \ No newline at end of file diff --git a/src/application/design/install/base/default/scripts/summary.phtml b/src/application/design/install/base/default/scripts/summary.phtml new file mode 100644 index 0000000..662dfc3 --- /dev/null +++ b/src/application/design/install/base/default/scripts/summary.phtml @@ -0,0 +1,7 @@ +
    +

    __('Wootook! was successfully installed.')?>

    + getLayout()->getMessagesblock()->renderGroupedHtml()?> +

    __('You can now play at %s and tell your friends to come and play.', Wootook::getBaseUrl())?>

    +

    __('Feel free to ask for help at any time at wootook.org.', 'http://wootook.org/board/')?>

    +

    +
    \ No newline at end of file diff --git a/src/application/gamedata/default/default/combat.php b/src/application/gamedata/default/default/combat.php new file mode 100644 index 0000000..8d931c7 --- /dev/null +++ b/src/application/gamedata/default/default/combat.php @@ -0,0 +1 @@ + array( + 'core' => array('Wootook_Core_Block_' => 'Wootook/Core/Block'), + 'empire' => array('Wootook_Empire_Block_' => 'Wootook/Empire/Block') + ) + ); \ No newline at end of file diff --git a/src/application/gamedata/default/default/prices.php b/src/application/gamedata/default/default/prices.php new file mode 100644 index 0000000..dfd324f --- /dev/null +++ b/src/application/gamedata/default/default/prices.php @@ -0,0 +1,2 @@ + array(), + 'layout.prepare.after' => array( + array('Wootook_Player_Model_Entity', 'layoutPrepareAfterListener') + ), + 'login.failure' => array(), + 'login.success' => array(), + 'logout.success' => array(), + 'register.before' => array(), + 'register.failure' => array(), + 'register.success' => array(), + 'user.init' => array(), + 'planet.init' => array( + array('Wootook_Empire_Model_Galaxy_Position', 'initPlanetListerner') + ), + 'planet.update' => array( + array('Wootook_Empire_Model_Planet', 'planetUpdateListener'), + array('Legacies_Empire_Model_Planet_Building_Shipyard', 'planetUpdateListener'), + 'flyingFleetListener' + ), + 'planet.shipyard.check-availability' => array(), + 'planet.shipyard.update-queue.before' => array(), + 'planet.shipyard.update-queue.after' => array(), + 'planet.shipyard.append-queue.before' => array(), + 'planet.shipyard.append-queue.after' => array(), + 'planet.building.building-time' => array(), + 'planet.shipyard.building-time' => array(), + 'planet.building.speed-enhancement' => array( + array('Legacies_Empire_Model_Planet_Building_NaniteFactory', 'buildingEnhancementListener'), + array('Legacies_Empire_Model_Planet_Building_RoboticFactory', 'buildingEnhancementListener') + ), + 'planet.shipyard.speed-enhancement' => array( + array('Legacies_Empire_Model_Planet_Building_NaniteFactory', 'buildingEnhancementListener'), + array('Legacies_Empire_Model_Planet_Building_RoboticFactory', 'buildingEnhancementListener') + ), + 'planet.research-lab.technology.speed-enhancement' => array( + array('Legacies_Empire_Model_Player_Technology_IntergalacticResearchNetwork', 'researchTechnologyEnhancementListener') + ), + 'core.mvc.controller.front.pre-dispatch' => array( + array('Wootook_Empire_Model_Planet', 'planetChangeListener') + ) + ); diff --git a/includes/data/fields-alias.php b/src/application/gamedata/legacies/default/fields-alias.php similarity index 90% rename from includes/data/fields-alias.php rename to src/application/gamedata/legacies/default/fields-alias.php index 2a56eb1..788a72c 100644 --- a/includes/data/fields-alias.php +++ b/src/application/gamedata/legacies/default/fields-alias.php @@ -41,6 +41,7 @@ Legacies_Empire::ID_RESEARCH_INTERGALACTIC_RESEARCH_NETWORK => "intergalactic_tech", Legacies_Empire::ID_RESEARCH_EXPEDITION_TECHNOLOGY => "expedition_tech", Legacies_Empire::ID_RESEARCH_GRAVITON_TECHNOLOGY => "graviton_tech", + Legacies_Empire::ID_RESEARCH_ORE_MINING => "ore_mining_tech", // }}} // @@ -61,6 +62,7 @@ Legacies_Empire::ID_SHIP_DEATH_STAR => "dearth_star", Legacies_Empire::ID_SHIP_BATTLECRUISER => "battleship", Legacies_Empire::ID_SHIP_SUPERNOVA => "supernova", + Legacies_Empire::ID_SHIP_ORE_MININER => "ore_miner", // // @@ -78,24 +80,4 @@ Legacies_Empire::ID_SPECIAL_ANTIBALLISTIC_MISSILE => "interceptor_misil", Legacies_Empire::ID_SPECIAL_INTERPLANETARY_MISSILE => "interplanetary_misil", // }}} - -// -// Officers -// {{{ - 601 => "rpg_geologue", - 602 => "rpg_amiral", - 603 => "rpg_ingenieur", - 604 => "rpg_technocrate", - 605 => "rpg_constructeur", - 606 => "rpg_scientifique", - 607 => "rpg_stockeur", - 608 => "rpg_defenseur", - 609 => "rpg_bunker", - 610 => "rpg_espion", - 611 => "rpg_commandant", - 612 => "rpg_destructeur", - 613 => "rpg_general", - 614 => "rpg_raideur", - 615 => "rpg_empereur" -// }}} ); diff --git a/src/application/gamedata/legacies/default/locale/fr_FR/labels.php b/src/application/gamedata/legacies/default/locale/fr_FR/labels.php new file mode 100644 index 0000000..ab43b0a --- /dev/null +++ b/src/application/gamedata/legacies/default/locale/fr_FR/labels.php @@ -0,0 +1,415 @@ + array( + 'name' => 'Mine de métal', + 'description' => "

    La mine de métal exploite les profondeurs géologiques à la recherche de ressources riches en métaux, puis les raffine et crée ensuite les alliages les plus solides.

    Principales matières premières pour la construction de structures planétaires et de vaisseaux, les métaux permettent d'asseoir votre domination sur l'univers.

    ", + 'image' => 'medias/klore/images/building/metal-mine.jpg' + ), + + Legacies_Empire::ID_BUILDING_CRISTAL_MINE => array( + 'name' => 'Mine de cristal', + 'description' => "

    La mine de cristal développe l'exploitation des minéraux entrant dans la comosition des systèmes électroniques.

    Ces matériaux vous permettront d'augmenter la capacité de calculs de vos laboratoires ainsi que de ceux de vos systèmes de combat.

    ", + 'image' => 'medias/klore/images/building/cristal-mine.jpg' + ), + + Legacies_Empire::ID_BUILDING_DEUTERIUM_SYNTHETISER => array( + 'name' => "Synthétiseur de deutérium", + 'description' => "

    Le synthétiseur de deutérium permet d'exploiter les sources d'hydrogène lourd. Disponible en faible quantité sur les planètes telluriques et plus répandu sur les planètes géantes gazeuses, le deutérium et tritium composent votre principale source d'hydrogène lourd.

    ", + 'image' => 'medias/klore/images/building/deuterium-syntherizer.jpg' + ), + + Legacies_Empire::ID_BUILDING_SOLAR_PLANT => array( + 'name' => 'Centrale électrique solaire', + 'description' => "

    La centrale électrique solaire est la source d'énergie la plus abordable.

    ", + 'image' => 'medias/klore/images/building/solar-plant.jpg' + ), + + Legacies_Empire::ID_BUILDING_FUSION_REACTOR => array( + 'name' => 'Réacteur à fusion nucléaire', + 'description' => "

    Fruit de longues décénnies de recherche, le réacteur à fusion nucléaire est désormais une source d'énergie rentable.

    Nourrie par l'énergie engendrée par la fusion des isotopes d'hydrogène, cette centrale génère plus d'énergie que toutes les autres sources d'énergie. La contrepartie à cette surgénération d'énergie, est son côut en deutérium.

    ", + 'image' => 'medias/klore/images/building/fusion-reactor.jpg' + ), + + Legacies_Empire::ID_BUILDING_ROBOTIC_FACTORY => array( + 'name' => 'Usine de robots', + 'description' => "

    L'usine de robots permet à votre empire de se développer plus rapidement en accélarant la fabrication et l'évolution de vos structures.

    ", + 'image' => 'medias/klore/images/building/robotic-factory.jpg' + ), + + Legacies_Empire::ID_BUILDING_NANITE_FACTORY => array( + 'name' => 'Usine de nanites', + 'description' => "

    Fruit de la recherche des nano-technologies, l'usine de nanites produit en masse nano-robots capable de s'assembler pour former vos futures structures.

    ", + 'image' => 'medias/klore/images/building/nanite-factory.jpg' + ), + + Legacies_Empire::ID_BUILDING_SHIPYARD => array( + 'name' => 'Chantier spatial', + 'description' => "

    Elément central de la construction de vaisseaux spaciaux et de systèmes de défenses, le chantier spatial permettra à votre empire de s'étendre et d'asseaoir sa suprématie.

    ", + 'image' => 'medias/klore/images/building/shipyard.jpg' + ), + + Legacies_Empire::ID_BUILDING_METAL_STORAGE => array( + 'name' => 'Hangar de métal', + 'description' => '', + 'image' => 'medias/klore/images/building/metal-storage.jpg' + ), + + Legacies_Empire::ID_BUILDING_CRISTAL_STORAGE => array( + 'name' => 'Hangar de cristal', + 'description' => '', + 'image' => 'medias/klore/images/building/cristal-storage.jpg' + ), + + Legacies_Empire::ID_BUILDING_DEUTERIUM_TANK => array( + 'name' => 'Réservoir de deutérium', + 'description' => '', + 'image' => 'medias/klore/images/building/deuterium-tank.jpg' + ), + + Legacies_Empire::ID_BUILDING_RESEARCH_LAB => array( + 'name' => 'Laboratoire de recherche', + 'description' => '', + 'image' => 'medias/klore/images/building/research-lab.jpg' + ), + + Legacies_Empire::ID_BUILDING_TERRAFORMER => array( + 'name' => 'Terraformeur', + 'description' => '', + 'image' => 'medias/klore/images/building/terraformer.jpg' + ), + + Legacies_Empire::ID_BUILDING_ALLIANCE_DEPOT => array( + 'name' => 'Dépôt de ravitaillement', + 'description' => '', + 'image' => 'medias/klore/images/building/alliance-depot.jpg' + ), + + Legacies_Empire::ID_BUILDING_MISSILE_SILO => array( + 'name' => 'Silo de missiles', + 'description' => '', + 'image' => 'medias/klore/images/building/missile-silo.jpg' + ), +// }}} + +// +// Moon buildings labels +// {{{ + Legacies_Empire::ID_BUILDING_LUNAR_BASE => array( + 'name' => 'Base lunaire', + 'description' => '', + 'image' => 'medias/klore/images/ship/lunar-base.jpg' + ), + + Legacies_Empire::ID_BUILDING_SENSOR_PHALANX => array( + 'name' => 'Phalange de capteur', + 'description' => '', + 'image' => 'medias/klore/images/ship/sensor-phalanx.jpg' + ), + + Legacies_Empire::ID_BUILDING_JUMP_GATE => array( + 'name' => 'Porte de saut spatial', + 'description' => '', + 'image' => 'medias/klore/images/ship/jump-gate.jpg' + ), +// }}} + +// +// Technologies labels +// {{{ + Legacies_Empire::ID_RESEARCH_ESPIONAGE_TECHNOLOGY => array( + 'name' => 'Techniques d\'espionnage', + 'description' => '', + 'image' => 'medias/klore/images/technology/espionnage.jpg' + ), + + Legacies_Empire::ID_RESEARCH_COMPUTER_TECHNOLOGY => array( + 'name' => 'Recherche informatique', + 'description' => '', + 'image' => 'medias/klore/images/technology/computer.jpg' + ), + + Legacies_Empire::ID_RESEARCH_WEAPON_TECHNOLOGY => array( + 'name' => 'Technologies d\'armements', + 'description' => '', + 'image' => 'medias/klore/images/technology/weaponry.jpg' + ), + + Legacies_Empire::ID_RESEARCH_SHIELDING_TECHNOLOGY => array( + 'name' => 'Boucliers énergétiques', + 'description' => '', + 'image' => 'medias/klore/images/technology/shielding.jpg' + ), + + Legacies_Empire::ID_RESEARCH_ARMOUR_TECHNOLOGY => array( + 'name' => 'Structures spatiales', + 'description' => '', + 'image' => 'medias/klore/images/technology/armour.jpg' + ), + + Legacies_Empire::ID_RESEARCH_ENERGY_TECHNOLOGY => array( + 'name' => 'Nouvelles énergies', + 'description' => '', + 'image' => 'medias/klore/images/technology/energy.jpg' + ), + + Legacies_Empire::ID_RESEARCH_HYPERSPACE_TECHNOLOGY => array( + 'name' => 'Technologie hyperespace', + 'description' => '', + 'image' => 'medias/klore/images/technology/hyperspace-technology.jpg' + ), + + Legacies_Empire::ID_RESEARCH_COMBUSTION_DRIVE => array( + 'name' => 'Propulsion à combustion', + 'description' => '', + 'image' => 'medias/klore/images/technology/combustion-drive.jpg' + ), + + Legacies_Empire::ID_RESEARCH_IMPULSE_DRIVE => array( + 'name' => 'Propulsion à impulsion', + 'description' => '', + 'image' => 'medias/klore/images/technology/impulse-drive.jpg' + ), + + Legacies_Empire::ID_RESEARCH_HYPERSPACE_DRIVE => array( + 'name' => 'Propulsion hyperespace', + 'description' => '', + 'image' => 'medias/klore/images/technology/hyperspace-drive.jpg' + ), + + Legacies_Empire::ID_RESEARCH_LASER_TECHNOLOGY => array( + 'name' => 'Propriétés laser', + 'description' => '', + 'image' => 'medias/klore/images/technology/laser.jpg' + ), + + Legacies_Empire::ID_RESEARCH_ION_TECHNOLOGY => array( + 'name' => 'Propriétés des ions', + 'description' => '', + 'image' => 'medias/klore/images/technology/ion.jpg' + ), + + Legacies_Empire::ID_RESEARCH_PLASMA_TECHNOLOGY => array( + 'name' => 'Propriétés des plasma', + 'description' => '', + 'image' => 'medias/klore/images/technology/plasma.jpg' + ), + + Legacies_Empire::ID_RESEARCH_INTERGALACTIC_RESEARCH_NETWORK => array( + 'name' => 'Réseau de recherche intergalactique', + 'description' => '', + 'image' => 'medias/klore/images/technology/intergalactic-research-network.jpg' + ), + + Legacies_Empire::ID_RESEARCH_EXPEDITION_TECHNOLOGY => array( + 'name' => 'Technologie expéditions', + 'description' => '', + 'image' => 'medias/klore/images/technology/expedition.jpg' + ), + + Legacies_Empire::ID_RESEARCH_ORE_MINING => array( + 'name' => 'Exploitation minière', + 'description' => '', + 'image' => 'medias/klore/images/technology/ore-mining.jpg' + ), + + Legacies_Empire::ID_RESEARCH_GRAVITON_TECHNOLOGY => array( + 'name' => 'Graviton', + 'description' => '', + 'image' => 'medias/klore/images/technology/graviton.jpg' + ), +// }}} + +// +// Fleets labels +// {{{ + Legacies_Empire::ID_SHIP_LIGHT_TRANSPORT => array( + 'name' => 'Transporteur T5', + 'class' => 'Etalon', + 'description' => '', + 'image' => 'medias/klore/images/ship/light-transport.jpg' + ), + + Legacies_Empire::ID_SHIP_LARGE_TRANSPORT => array( + 'name' => 'Transporteur T25', + 'class' => 'Buffle', + 'description' => '', + 'image' => 'medias/klore/images/ship/large-transport.jpg' + ), + + Legacies_Empire::ID_SHIP_LIGHT_FIGHTER => array( + 'name' => 'Chasseur C50', + 'class' => 'Guêpe', + 'description' => '', + 'image' => 'medias/klore/images/ship/light-fighter.jpg' + ), + + Legacies_Empire::ID_SHIP_HEAVY_FIGHTER => array( + 'name' => 'Chasseur C150', + 'class' => 'Frelon', + 'description' => '', + 'image' => 'medias/klore/images/ship/heavy-fighter.jpg' + ), + + Legacies_Empire::ID_SHIP_CRUISER => array( + 'name' => 'Croiseur V400', + 'class' => 'Aigle', + 'description' => '', + 'image' => 'medias/klore/images/ship/cruiser.jpg' + ), + + Legacies_Empire::ID_SHIP_BATTLESHIP => array( + 'name' => 'Vaisseau de bataille V1000', + 'class' => 'Faucon', + 'description' => '', + 'image' => 'medias/klore/images/ship/battleship.jpg' + ), + + Legacies_Empire::ID_SHIP_COLONY_SHIP => array( + 'name' => 'Vaisseau de colonisation', + 'class' => 'Romulus', + 'description' => '', + 'image' => 'medias/klore/images/ship/colony-ship.jpg' + ), + + Legacies_Empire::ID_SHIP_RECYCLER => array( + 'name' => 'Recycleur', + 'class' => 'Goule', + 'description' => '', + 'image' => 'medias/klore/images/ship/recycler.jpg' + ), + + Legacies_Empire::ID_SHIP_SPY_DRONE => array( + 'name' => 'Sonde d\'espionnage', + 'class' => 'Moustique', + 'description' => '', + 'image' => 'medias/klore/images/ship/spy-drone.jpg' + ), + + Legacies_Empire::ID_SHIP_BOMBER => array( + 'name' => 'Bombarider', + 'class' => 'Vengeur', + 'description' => '', + 'image' => 'medias/klore/images/ship/bomber.jpg' + ), + + Legacies_Empire::ID_SHIP_SOLAR_SATELLITE => array( + 'name' => 'Satellite solaire', + 'class' => 'Râ', + 'description' => '', + 'image' => 'medias/klore/images/ship/solar-satellite.jpg' + ), + + Legacies_Empire::ID_SHIP_DESTRUCTOR => array( + 'name' => 'Vaisseau de bataille V2000', + 'class' => 'Destructeur', + 'description' => '', + 'image' => 'medias/klore/images/ship/destructor.jpg' + ), + + Legacies_Empire::ID_SHIP_DEATH_STAR => array( + 'name' => 'Vaisseau mère M1', + 'class' => 'Vengeur', + 'description' => '', + 'image' => 'medias/klore/images/ship/death-star.jpg' + ), + + Legacies_Empire::ID_SHIP_BATTLECRUISER => array( + 'name' => 'Vaisseau de bataille V700', + 'class' => 'Dragon', + 'description' => '', + 'image' => 'medias/klore/images/ship/battlecruiser.jpg' + ), + + Legacies_Empire::ID_SHIP_SUPERNOVA => array( + 'name' => 'Vaisseau mère M5', + 'class' => 'Annihilateur', + 'description' => '', + 'image' => 'medias/klore/images/ship/supernova.jpg' + ), + + Legacies_Empire::ID_SHIP_ORE_MININER => array( + 'name' => 'Vaisseau d\'exploitation', + 'class' => 'Onyx', + 'description' => '', + 'image' => 'medias/klore/images/ship/ore-miner.jpg' + ), +// }}} + +// +// Defenses labels +// {{{ + Legacies_Empire::ID_DEFENSE_ROCKET_LAUNCHER => array( + 'name' => 'Lance-missiles balistiques', + 'class' => 'Défenseur', + 'description' => '', + 'image' => 'medias/klore/images/defense/rocket-launcher.jpg' + ), + + Legacies_Empire::ID_DEFENSE_LIGHT_LASER => array( + 'name' => 'Artillerie laser légère', + 'class' => 'Lux', + 'description' => '', + 'image' => 'medias/klore/images/defense/light-laser.jpg' + ), + + Legacies_Empire::ID_DEFENSE_HEAVY_LASER => array( + 'name' => 'Artillerie laser lourde', + 'class' => 'Seraphin', + 'description' => '', + 'image' => 'medias/klore/images/defense/heavy-laser.jpg' + ), + + Legacies_Empire::ID_DEFENSE_ION_CANNON => array( + 'name' => 'Canon à ions', + 'class' => 'Découpeur', + 'description' => '', + 'image' => 'medias/klore/images/defense/ion-canon.jpg' + ), + + Legacies_Empire::ID_DEFENSE_GAUSS_CANNON => array( + 'name' => 'Canon à effet Gauss', + 'class' => 'Polaris', + 'description' => '', + 'image' => 'medias/klore/images/defense/gauss-canon.jpg' + ), + + Legacies_Empire::ID_DEFENSE_PLASMA_TURRET => array( + 'name' => 'Canon à plasma', + 'class' => 'Infernal', + 'description' => '', + 'image' => 'medias/klore/images/defense/plasma-turret.jpg' + ), + + Legacies_Empire::ID_DEFENSE_SMALL_SHIELD_DOME => array( + 'name' => 'Dôme bouclier', + 'class' => 'Sphere', + 'description' => '', + 'image' => 'medias/klore/images/defense/small-shield-dome.jpg' + ), + + Legacies_Empire::ID_DEFENSE_LARGE_SHIELD_DOME => array( + 'name' => 'Grand bouclier planétaire', + 'class' => 'Gaia', + 'description' => '', + 'image' => 'medias/klore/images/defense/large-shield-dome.jpg' + ), +// }}} + +// +// Special defenses labels +// {{{ + Legacies_Empire::ID_SPECIAL_ANTIBALLISTIC_MISSILE => array( + 'name' => 'Missile anti-balistique', + 'description' => '', + 'image' => 'medias/klore/images/defense/antiballistic-missile.jpg' + ), + + Legacies_Empire::ID_SPECIAL_INTERPLANETARY_MISSILE => array( + 'name' => 'Missile stratégique', + 'description' => '', + 'image' => 'medias/klore/images/defense/interplanetary-missile.jpg' + ) +// }}} +); diff --git a/src/application/gamedata/legacies/default/modules.php b/src/application/gamedata/legacies/default/modules.php new file mode 100644 index 0000000..b00c84f --- /dev/null +++ b/src/application/gamedata/legacies/default/modules.php @@ -0,0 +1,10 @@ + array( + 'core' => array('Wootook_Core_Block_' => 'Wootook/Core/Block'), + 'empire' => array('Wootook_Empire_Block_' => 'Wootook/Empire/Block'), + 'player' => array('Wootook_Player_Block_' => 'Wootook/Player/Block'), + 'legacies-core' => array('Legacies_Core_Block_' => 'Legacies/Core/Block'), + 'legacies-empire' => array('Legacies_Empire_Block_' => 'Legacies/Empire/Block'), + 'legacies-stats' => array('Legacies_Stats_Block_' => 'Legacies/Stats/Block') + ) + ); diff --git a/includes/data/prices.php b/src/application/gamedata/legacies/default/prices.php similarity index 100% rename from includes/data/prices.php rename to src/application/gamedata/legacies/default/prices.php diff --git a/src/application/gamedata/legacies/default/production.php b/src/application/gamedata/legacies/default/production.php new file mode 100644 index 0000000..545dcde --- /dev/null +++ b/src/application/gamedata/legacies/default/production.php @@ -0,0 +1,18 @@ + 'Legacies_Empire_Model_Planet_Building_MetalMine', + Legacies_Empire::ID_BUILDING_CRISTAL_MINE => 'Legacies_Empire_Model_Planet_Building_CristalMine', + Legacies_Empire::ID_BUILDING_DEUTERIUM_SYNTHETISER => 'Legacies_Empire_Model_Planet_Building_DeuteriumSynthetiser', + Legacies_Empire::ID_BUILDING_SOLAR_PLANT => 'Legacies_Empire_Model_Planet_Building_SolarPlant', + Legacies_Empire::ID_BUILDING_FUSION_REACTOR => 'Legacies_Empire_Model_Planet_Building_FusionReactor', +// }}} + +// +// Ships production +// {{{ + Legacies_Empire::ID_SHIP_SOLAR_SATELLITE => 'Legacies_Empire_Model_Planet_Ship_SolarSatellite', + Legacies_Empire::ID_SHIP_SUPERNOVA => 'Legacies_Empire_Model_Planet_Ship_Supernova' +// }}} + ); diff --git a/includes/data/requirements.php b/src/application/gamedata/legacies/default/requirements.php similarity index 95% rename from includes/data/requirements.php rename to src/application/gamedata/legacies/default/requirements.php index 838a930..2ed5430 100644 --- a/includes/data/requirements.php +++ b/src/application/gamedata/legacies/default/requirements.php @@ -114,6 +114,10 @@ Legacies_Empire::ID_RESEARCH_IMPULSE_DRIVE => 3 ), + Legacies_Empire::ID_RESEARCH_ORE_MINING => array( + Legacies_Empire::ID_BUILDING_RESEARCH_LAB => 2 + ), + Legacies_Empire::ID_RESEARCH_GRAVITON_TECHNOLOGY => array( Legacies_Empire::ID_BUILDING_RESEARCH_LAB => 12 ), @@ -207,6 +211,13 @@ Legacies_Empire::ID_RESEARCH_HYPERSPACE_TECHNOLOGY => 14, Legacies_Empire::ID_RESEARCH_GRAVITON_TECHNOLOGY => 3 ), + + Legacies_Empire::ID_SHIP_ORE_MININER => array( + Legacies_Empire::ID_BUILDING_SHIPYARD => 12, + Legacies_Empire::ID_RESEARCH_HYPERSPACE_DRIVE => 8, + Legacies_Empire::ID_RESEARCH_GRAVITON_TECHNOLOGY => 1, + Legacies_Empire::ID_RESEARCH_LASER_TECHNOLOGY => 16 + ), // }}} // diff --git a/includes/data/resources.php b/src/application/gamedata/legacies/default/resources.php similarity index 70% rename from includes/data/resources.php rename to src/application/gamedata/legacies/default/resources.php index 4bea873..0faa545 100644 --- a/includes/data/resources.php +++ b/src/application/gamedata/legacies/default/resources.php @@ -1,9 +1,9 @@ array( - 'template' => 'empire/resources/default.phtml', - 'renderer' => 'Legacies_Empire_Block_Resource_Default', +// 'template' => 'empire/resources/default.phtml', +// 'renderer' => 'legacies_empire/resource_default', - 'field' => Legacies_Empire::RESOURCE_METAL, + 'field' => 'metal', 'production_field' => 'metal_perhour', 'storage_field' => 'metal_max', 'production' => array( @@ -12,10 +12,10 @@ 'storage' => Legacies_Empire::ID_BUILDING_METAL_STORAGE ), Legacies_Empire::RESOURCE_CRISTAL => array( - 'template' => 'empire/resources/default.phtml', - 'renderer' => 'Legacies_Empire_Block_Resource_Default', +// 'template' => 'empire/resources/default.phtml', +// 'renderer' => 'legacies_empire/resource_default', - 'field' => Legacies_Empire::RESOURCE_CRISTAL, + 'field' => 'cristal', 'production_field' => 'cristal_perhour', 'storage_field' => 'cristal_max', 'production' => array( @@ -24,10 +24,10 @@ 'storage' => Legacies_Empire::ID_BUILDING_CRISTAL_STORAGE ), Legacies_Empire::RESOURCE_DEUTERIUM => array( - 'template' => 'empire/resources/default.phtml', - 'renderer' => 'Legacies_Empire_Block_Resource_Default', +// 'template' => 'empire/resources/default.phtml', +// 'renderer' => 'legacies_empire/resource_default', - 'field' => Legacies_Empire::RESOURCE_DEUTERIUM, + 'field' => 'deuterium', 'production_field' => 'deuterium_perhour', 'storage_field' => 'deuterium_max', 'production' => array( @@ -36,8 +36,8 @@ 'storage' => Legacies_Empire::ID_BUILDING_DEUTERIUM_TANK ), Legacies_Empire::RESOURCE_ENERGY => array( - 'template' => 'empire/resources/energy.phtml', - 'renderer' => 'Legacies_Empire_Block_Resource_Default', +// 'template' => 'empire/resources/energy.phtml', +// 'renderer' => 'legacies_empire/resource_energy', 'field' => 'energy_used', 'production_field' => 'energy_max', diff --git a/includes/data/types.php b/src/application/gamedata/legacies/default/types.php similarity index 97% rename from includes/data/types.php rename to src/application/gamedata/legacies/default/types.php index 76c773d..c67c74d 100644 --- a/includes/data/types.php +++ b/src/application/gamedata/legacies/default/types.php @@ -75,6 +75,7 @@ Legacies_Empire::ID_RESEARCH_PLASMA_TECHNOLOGY, Legacies_Empire::ID_RESEARCH_INTERGALACTIC_RESEARCH_NETWORK, Legacies_Empire::ID_RESEARCH_EXPEDITION_TECHNOLOGY, + Legacies_Empire::ID_RESEARCH_ORE_MINING, Legacies_Empire::ID_RESEARCH_GRAVITON_TECHNOLOGY ), // }}} @@ -97,7 +98,8 @@ Legacies_Empire::ID_SHIP_DESTRUCTOR, Legacies_Empire::ID_SHIP_DEATH_STAR, Legacies_Empire::ID_SHIP_BATTLECRUISER, - Legacies_Empire::ID_SHIP_SUPERNOVA + Legacies_Empire::ID_SHIP_SUPERNOVA, + Legacies_Empire::ID_SHIP_ORE_MININER ), // }}} diff --git a/src/application/gamedata/legacies/version.php b/src/application/gamedata/legacies/version.php new file mode 100644 index 0000000..1b6f705 --- /dev/null +++ b/src/application/gamedata/legacies/version.php @@ -0,0 +1,4 @@ + '1.5.0', + 'Legacies_Empire' => '1.5.0', +); \ No newline at end of file diff --git a/includes/application/locale/en_US/Legacies_User.csv b/src/application/locale/en_US/Legacies_User.csv similarity index 100% rename from includes/application/locale/en_US/Legacies_User.csv rename to src/application/locale/en_US/Legacies_User.csv diff --git a/src/application/locale/fr_FR/Legacies.csv b/src/application/locale/fr_FR/Legacies.csv new file mode 100644 index 0000000..a19064b --- /dev/null +++ b/src/application/locale/fr_FR/Legacies.csv @@ -0,0 +1,39 @@ +"Your session has expired, please login.","Votre session a expiré, veuillez vous reconnecter." +"Your username or credential is invalid, please check your input.","Votre nom d'utilisateur ou votre mot de passe n'est pas valide, veuillez vérifier votre saisie." +"No such user.","Cet utilisateur n'existe pas." +"You were banned, please contact admin for more information.","Vous ont été banni, veuillez contacter l'admin pour plus d'informations." +"You have 1 unread message.","Vous avez un message non lu." +"You have 1 new message.","Vous avez un nouveau message." +"You have no new message.","Vous n'avez pas de nouveau message." +"You have %1$d new messages","Vous avez %1$d nouveaux messages" +"You have %1$d unread messages.","Vous avez %1$d messages non lus." +"You have ""%1$d"" unread messages.","Vous avez ""%1$d"" messages non lus." +"No message.","Aucun message" +"1 messages.","Un message" +"%1$d messages.","%1$d messages." +"instantaneous","instantanné" +"Attack","Attaquer" +"Transport","Transporter" +"Station","Stationner" +"Settle","Coloniser" +"Recycle","Recycler" +"Destroy","Détruire" +"Missiles Launch","Attaque de missiles" +"Expedition","Expédition" +"Unknown","Inconnu" +"Planet is already destroyed","La planète est déjà détruite" +"Password:","Mot de passe :" +"I want to destroy this planet","Je confirme vouloir détruire cette planète" +"New name","Nouveau nom" +"Idle.","Inactif." +"Cancel","Annuler" +"Work in progress","Travail en cours" +"Buildings","Bâtiments" +"Research Laboratory","Laboratoire de recherches" +"Shipyard","Chantier spatial" +"Build","Construire" +"Metal","Métal" +"Cristal","Cristal" +"Deuterium","Deutérium" +"Energy","Energie" +"Messages","Messages" diff --git a/includes/application/locale/fr_FR/Legacies_User.csv b/src/application/locale/fr_FR/Legacies_User.csv similarity index 100% rename from includes/application/locale/fr_FR/Legacies_User.csv rename to src/application/locale/fr_FR/Legacies_User.csv diff --git a/includes/application/locale/fr_FR/Legacies_User.txt b/src/application/locale/fr_FR/Legacies_User.txt similarity index 100% rename from includes/application/locale/fr_FR/Legacies_User.txt rename to src/application/locale/fr_FR/Legacies_User.txt diff --git a/src/application/locale/fr_FR/Wootook_Core.csv b/src/application/locale/fr_FR/Wootook_Core.csv new file mode 100644 index 0000000..98a6fbf --- /dev/null +++ b/src/application/locale/fr_FR/Wootook_Core.csv @@ -0,0 +1,156 @@ +"Game is disabled.","Le jeu est clos." +"%1$d day(s) and %2$d hour(s)","%1$d jour(s) et %2$d heure(s)" +"%1$d hour(s), %2$d minute(s) and %3$d second(s)","%1$d heure(s), %2$d minute(s) et %3$d seconde(s)" +"%1$d minute(s) and %2$d second(s)","%1$d minute(s) et %2$d seconde(s)" +"%1$d second(s)","%1$d seconde(s)" +"%1$d per minute","%1$d par minute" +"instantaneous","instantanné" +"Attack","Attaquer" +"Transport","Transporter" +"Station","Stationner" +"Settle","Coloniser" +"Recycle","Recycler" +"Destroy","Detruire" +"Missiles Launch","Envoi de missiles" +"Expedition","Expédition" +"Unknown","Inconnu" +"Planet is already destroyed.","La planète a déjà été détruite." +"Could not delete planet until fleets aten't retuned.","Impossible de détruire la planète tant que toutes les flottes ne sont pas revenues." +"You can't destroy your home planet.","Vous ne pouvez pas détruire votre planète mère." +"No such user.","Cet utilisateur n'existe pas." +"You were banned, please contact admin for more information.","Vous avez été banni. Veuillez contacter l'administrateur pour plus d'informations." +"Your username or credential is invalid, please check your input.","Votre nom d'utilisateur ou votre mot de passe sont invalides, veuillez vérifier votre saisie." +"My %s message!","My %s message!" +"An hostile fleet sent by %1$s, coming from %2$s, reaches your planet %3$d. It has been sent with the mission: %4$d","Une flotte hostile envoyée par %1$s et prevenant de %2$s atteint votre planète %3$d. Sa mission est : %4$d." +"Your hostile fleet, sent from %1$s, reaches %2$d\'s planet %3$d. It has been sent with the mission: %4$d","Votre flotte hostile envoyée depuis %1$s, atteint la planète de %2$d : %3$d. Sa mission est : %4$d" +"Your peaceful fleet, sent from %2$s, reaches the planet %3$d. It has been sent with the mission: %4$d","Votre flotte envoyée depuis %2$s, atteint la planète %3$d. Sa mission est : %4$d" +"A peaceful fleet sent by %1$s, coming from %2$s, reaches your planet %3$d. It has been sent with the mission: %4$d","Une flotte pacifique envoyée par %1$s et venant de %2$s atteint votre palnète %3$d. Sa mission est : %4$d" +"I want to destroy this planet","Je veux détruire cette planète." +"New name:","Nouveau nom:" +"You have 1 unread message.","Vous avez un message non lu." +"You have %1$d unread messages.","Vous avez %1$d messages non lus." +"Idle.","Inactif." +"Level %d","Niveau %d" +"Current count: %s","Disponible : %s" +"Build max (%s)","Construire le max (%s)" +"Build next level (%s)","Construire au niveau %s" +"Building time: %s","Temps de construction : %s" +"Lasts %s","Il reste %s" +"Cancel","Annuler" +"Work in progress","En cours..." +"Buildings","Bâtiments" +"Research Laboratory","Laboratoire de recherche" +"Shipyard","Chantier spatial" +"Build","Build" +"Metal","Métal" +"Cristal","Cristal" +"Deuterium","Deutérium" +"Energy","Energie" +"Messages","Messages" +"1 message.","Un message." +"You have no new message.","Vous n'avez pas de nouveau message." +"No message.","Pas de message." +"Username","Nom d'utilisateur" +"Password","Mot de passe" +"Remember me","Se souvenir de moi" +"Log in!","Connexion!" +"I have lost my password.","J'ai perdu mon mot de passe." +"Register","Créer un compte" +"Boards","Forum" +"Contact","Contact" +"Welcome on %s!","Bienvenue sur %s!" +"%1$s make you an emperor. Conquer outer space and master other players on %1$s.","%1$s fait de vous un empereur. Parcourez l'espace sidéral et conquérez les territoires d'autres joueurs sur %1$s." +"Register now!","S'enregistrer maintenant!" +"Player count: ","Nombre de joueurs : " +"Latest player: ","Dernier inscrit : " +"Online players: ","Joueurs en ligne : " +"User data:","Votre compte :" +"Username:","Nom d'empire :" +"Email:","Email :" +"Confirm email:","Confirmez l'email :" +"Password:","Mot de passe :" +"Confirm password:","Confirmez le mot de passe :" +"Planet:","Planète :" +"Planet name:","Nom de votre planète :" +"Register!","S'enregistrer!" +"Welcome to the Wootook! installer","Bienvenue sur l'installation de Wootook!" +"This page will guide you through the installation proces of Wootook! the MMO game engine platform.","Cette page vous guidera à travers le processus d'installation de Wootook! la plateforme de jeux web MMO." +"Feel free to ask for help at any time at wootook.org.","Feel free to ask for help at any time at wootook.org." +"Next step","Etape suivante" +"Welcome","Bienvenue" +"System","Système" +"Database","Base de données" +"Universe","Univers" +"Admin profile","Profil administrateur" +"Summary","Finalisation" +"Database Config","Configuration de votre base de données" +"Database host address:","Adresse du serveur :" +"Database host port:","Port du serveur :" +"Database account name:","Compte utilisateur:" +"Database account password:","Mot de passe :" +"Database name:","Nom de la base de données :" +"Table name prefix:","Préfixe des noms des tables :" +"Test connection","Tester la connexion" +"Connection succeeded.","Connexion réussie." +"Connection error: ","Erreur de connexion : " +"Admin Profile Config","Configuration du compte administrateur" +"Root admin account name:","Nom d'utilisateur :" +"Root admin email:","Email du compte administrateur :" +"Root admin account password:","Mot de passe :" +"Root admin account password confirm:","Confirmez le mot de passe :" +"System Config","Configuration système" +"Base URL path for the game:","URL de base Base du jeu :" +"Game timezone:","Fuseau horaire du jeu :" +"Africa","Afrique" +"America","Amerique" +"Atlantic","Atlantique" +"Asia","Asie" +"Europe","Europe" +"Pacific","Pacifique" +"Universe Config","configuration de l'univers" +"Galaxies count:","Nombre de galaxies :" +"Systems count:","Nombre de systèmes solaires :" +"Positions in each system:","Nombre de planètes dans chaque système solaire :" +"Allow spy drone attacks","Autoriser la attaques de sondes d'espionnage" +"Activate large numbers handling","Activer la gestion des très grands nombres" +"'BC Math' extension is unavailable. This option will have no effect until the extension isn't active.","L'extension PHP 'BC Math' est indisponible sur votre machine. Cette option n'aura aucun effet tant que l'extension ne sera pas activée." +"Wootook! was successfully installed.","Wootook! a été correctmeent installé." +"You can now play at %s and tell your friends to come and play.","Vous pouvez maintenant jouer sur %s et dire à vos amis de venir." +"Feel free to ask for help at any time at wootook.org.","Feel free to ask for help at any time at wootook.org." +"Play!","Jouer!" +"Shipyard is required","Le chantier spatial est requis" +"In order to build ships you will need to build a shipyard building.","Pour construire des vaisseaux, vous devrez construire un chantier spatial." +"Research lab is required","Le laboratoire de recherche est requis" +"In order to do technological researches, you will need to build a research lab building.","Pour effectuer des recherches de nouvelles technologies, vous devrez construire un laboratoire de recherches." +"Unnamed","Sans nom" +"Name","Nom" +"Galaxy","Galaxie" +"System","Système" +"Planet","Planète" +"Debris","Débris" +"Moon","Lune" +"Reset","Réinitialiser" +"Save","Sauvegarder" +"The shortcut has been saved.","Le raccourci a été enregistré." +"The shortcut has been deleted","Le raccourdi a été supprimé" +"The shortcut has been updated.","Le raccourci a été mis à jour." +"Success","Succès" +"Colony","Colonie" +"Moon","Lune" +"Class %s","Classe %s" +"Build","Construire" +"Game data successfully initialized.","Game data successfully initialized." +"Passwords does not match.","Les mots de passe ne correpsondent pas." +"Both e-mails does not match.","Les emails ne correpsondent pas." +"Could not create user.","Impossible de créer le compte d'utilisateur." +"Could not set to vacation mode.","Impossible d'activer le mode vacances." +"You currently can't get to vacation mode, please check your flying fleets, and building queues.","You currently can't get to vacation mode, please check your flying fleets, and building queues." +"Password was not correct.","Le mot de passe est incorrect." +"Planet has been successfully destroyed.","LA planète a été détruite." +"Open the chat.","Ouvrir le chat." +"No root view declared.","Aucune vue racine n'est déclarée." +"Query failed: SQLSTATE %s: %s.","La requête a échoué : SQLSTATE %s: %s." +"Undefined method %s::%s.","La méthode %s::%s est inconnue." +"Ajax failure.","Erreur AJAX." +"Invalid security key.","code de sécurité invalide." +"Form data error.","données de formulaire erronnées." diff --git a/src/application/test/translate.csv b/src/application/test/translate.csv new file mode 100644 index 0000000..a873711 --- /dev/null +++ b/src/application/test/translate.csv @@ -0,0 +1,154 @@ +"Game is disabled.","Le jeu est clos." +"%1$d day(s) and %2$d hour(s)","%1$d jour(s) et %2$d heure(s)" +"%1$d hour(s), %2$d minute(s) and %3$d second(s)","%1$d heure(s), %2$d minute(s) et %3$d seconde(s)" +"%1$d minute(s) and %2$d second(s)","%1$d minute(s) et %2$d seconde(s)" +"%1$d second(s)","%1$d seconde(s)" +"%1$d per minute","%1$d par minute" +"instantaneous","instantanné" +"Attack","Attaquer" +"Transport","Transporter" +"Station","Stationner" +"Settle","Coloniser" +"Recycle","Recycler" +"Destroy","Detruire" +"Missiles Launch","Envoi de missiles" +"Expedition","Expédition" +"Unknown","Inconnu" +"Planet is already destroyed.","La planète a déjà été détruite." +"Could not delete planet until fleets aten't retuned.","Impossible de détruire la planète tant que toutes les flottes ne sont pas revenues." +"You can't destroy your home planet.","Vous ne pouvez pas détruire votre planète mère." +"No such user.","Cet utilisateur n'existe pas." +"You were banned, please contact admin for more information.","Vous avez été banni. Veuillez contacter l'administrateur pour plus d'informations." +"Your username or credential is invalid, please check your input.","Votre nom d'utilisateur ou votre mot de passe sont invalides, veuillez vérifier votre saisie." +"My %s message!","My %s message!" +"An hostile fleet sent by %1$s, coming from %2$s, reaches your planet %3$d. It has been sent with the mission: %4$d","Une flotte hostile envoyée par %1$s et prevenant de %2$s atteint votre planète %3$d. Sa mission est : %4$d." +"Your hostile fleet, sent from %1$s, reaches %2$d\'s planet %3$d. It has been sent with the mission: %4$d","Votre flotte hostile envoyée depuis %1$s, atteint la planète de %2$d : %3$d. Sa mission est : %4$d" +"Your peaceful fleet, sent from %2$s, reaches the planet %3$d. It has been sent with the mission: %4$d","Votre flotte envoyée depuis %2$s, atteint la planète %3$d. Sa mission est : %4$d" +"A peaceful fleet sent by %1$s, coming from %2$s, reaches your planet %3$d. It has been sent with the mission: %4$d","Une flotte pacifique envoyée par %1$s et venant de %2$s atteint votre palnète %3$d. Sa mission est : %4$d" +"I want to destroy this planet","Je veux détruire cette planète." +"New name:","Nouveau nom:" +"You have 1 unread message.","Vous avez un message non lu." +"You have %1$d unread messages.","Vous avez %1$d messages non lus." +"Idle.","Inactif." +"Level %d","Niveau %d" +"Current count: %s","Quantité actuelle : %s" +"Build max (%s)","Construire le max (%s)" +"Build next level (%s)","Construire le niveau suivant (%s)" +"Building time: %s","Temps de construction : %s" +"Lasts %s","Il reste %s" +"Cancel","Annuler" +"Work in progress","En cours..." +"Buildings","Bâtiments" +"Research Laboratory","Laboratoire de recherche" +"Shipyard","Chantier spatial" +"Build","Build" +"Metal","Métal" +"Cristal","Cristal" +"Deuterium","Deutérium" +"Energy","Energie" +"Messages","Messages" +"1 message.","Un message." +"You have no new message.","Vous n'avez pas de nouveau message." +"No message.","Pas de message." +"Username","Nom d'utilisateur" +"Password","Mot de passe" +"Remember me","Se souvenir de moi" +"Log in!","Connexion!" +"I have lost my password.","J'ai perdu mon mot de passe." +"Register","Créer un compte" +"Boards","Forum" +"Contact","Contact" +"Welcome on %s!","Bienvenue sur %s!" +"%1$s make you an emperor. Conquer outer space and master other players on %1$s.","%1$s fait de vous un empereur. Parcourez l'espace sidéral et conquérez les territoires d'autres joueurs sur %1$s." +"Register now!","S'enregistrer maintenant!" +"Player count: ","Nombre de joueurs : " +"Latest player: ","Dernier inscrit : " +"Online players: ","Joueurs en ligne : " +"User data:","Votre compte :" +"Username:","Nom d'empire :" +"Email:","Email :" +"Confirm email:","Confirmez l'email :" +"Password:","Mot de passe :" +"Confirm password:","Confirmez le mot de passe :" +"Planet:","Planète :" +"Planet name:","Nom de votre planète :" +"Register!","S'enregistrer!" +"Welcome to the Wootook! installer","Bienvenue sur l'installation de Wootook!" +"This page will guide you through the installation proces of Wootook! the MMO game engine platform.","Cette page vous guidera à travers le processus d'installation de Wootook! la plateforme de jeux web MMO." +"Feel free to ask for help at any time at wootook.org.","Feel free to ask for help at any time at wootook.org." +"Next step","Etape suivante" +"Welcome","Bienvenue" +"System","Système" +"Database","Base de données" +"Universe","Univers" +"Admin profile","Compte Admin" +"Summary","Finalisation" +"Database Config","Configuration de votre base de données" +"Database host address:","Adresse du serveur :" +"Database host port:","Port du serveur :" +"Database account name:","Compte utilisateur:" +"Database account password:","Mot de passe :" +"Database name:","Nom de la base de données :" +"Table name prefix:","Préfixe des noms des tables :" +"Test connection","Tester la connexion" +"Connection succeeded.","Connexion réussie." +"Connection error: ","Erreur de connexion : " +"Admin Profile Config","Configuration du compte administrateur" +"Root admin account name:","Nom d'utilisateur :" +"Root admin email:","Email du compte administrateur :" +"Root admin account password:","Mot de passe :" +"Root admin account password confirm:","Confirmez le mot de passe :" +"System Config","Configuration système" +"Base URL path for the game:","URL de base Base du jeu :" +"Game timezone:","Fuseau horaire du jeu :" +"Africa","Afrique" +"America","Amerique" +"Atlantic","Atlantique" +"Asia","Asie" +"Europe","Europe" +"Pacific","Pacifique" +"Universe Config","configuration de l'univers" +"Galaxies count:","Nombre de galaxies :" +"Systems count:","Nombre de systèmes solaires :" +"Positions in each system:","Nombre de planètes dans chaque système solaire :" +"Allow spy drone attacks","Autoriser la attaques de sondes d'espionnage" +"Activate large numbers handling","Activer la gestion des très grands nombres" +"'BC Math' extension is unavailable. This option will have no effect until the extension isn't active.","L'extension PHP 'BC Math' est indisponible sur votre machine. Cette option n'aura aucun effet tant que l'extension ne sera pas activée." +"Wootook! was successfully installed.","Wootook! a été correctmeent installé." +"You can now play at %s and tell your friends to come and play.","Vous pouvez maintenant jouer sur %s et dire à vos amis de venir." +"Feel free to ask for help at any time at wootook.org.","Feel free to ask for help at any time at wootook.org." +"Play!","Jouer!" +"Shipyard is required","Le chantier spatial est requis" +"In order to build ships you will need to build a shipyard building.","Pour construire des vaisseaux, vous devrez construire un chantier spatial." +"Research lab is required","Le laboratoire de recherche est requis" +"In order to do technological researches, you will need to build a research lab building.","Pour effectuer des recherches de nouvelles technologies, vous devrez construire un laboratoire de recherches." +"Unnamed","Sans nom" +"Name","Nom" +"Galaxy","Galaxie" +"System","Système" +"Planet","Planète" +"Debris","Débris" +"Moon","Lune" +"Reset","Réinitialiser" +"Save","Sauvegarder" +"The shortcut has been saved.","Le raccourci a été enregistré." +"The shortcut has been deleted","Le raccourdi a été supprimé" +"The shortcut has been updated.","Le raccourci a été mis à jour." +"Success","Succès" +"Colony","Colonie" +"Moon","Lune" +"Game data successfully initialized.","Game data successfully initialized." +"Passwords does not match.","Les mots de passe ne correpsondent pas." +"Both e-mails does not match.","Les emails ne correpsondent pas." +"Could not create user.","Impossible de créer le compte d'utilisateur." +"Could not set to vacation mode.","Impossible d'activer le mode vacances." +"You currently can't get to vacation mode, please check your flying fleets, and building queues.","You currently can't get to vacation mode, please check your flying fleets, and building queues." +"Password was not correct.","Le mot de passe est incorrect." +"Planet has been successfully destroyed.","LA planète a été détruite." +"Open the chat.","Ouvrir le chat." +"No root view declared.","Aucune vue racine n'est déclarée." +"Query failed: SQLSTATE %s: %s.","La requête a échoué : SQLSTATE %s: %s." +"Undefined method %s::%s.","La méthode %s::%s est inconnue." +"Ajax failure.","Erreur AJAX." +"Invalid security key.","code de sécurité invalide." +"Form data error.","données de formulaire erronnées." diff --git a/src/application/test/translate2.txt b/src/application/test/translate2.txt new file mode 100644 index 0000000..6731a74 Binary files /dev/null and b/src/application/test/translate2.txt differ diff --git a/banned.php b/src/banned.php similarity index 87% rename from banned.php rename to src/banned.php index 147493b..7874d75 100644 --- a/banned.php +++ b/src/banned.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,13 +24,13 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); -require_once dirname(__FILE__) .'/common.php'; +require_once dirname(__FILE__) .'/application/bootstrap.php'; includeLang('banned'); diff --git a/buddy.php b/src/buddy.php similarity index 95% rename from buddy.php rename to src/buddy.php index bdadc98..edc72dc 100644 --- a/buddy.php +++ b/src/buddy.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,13 +24,13 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); -require_once dirname(__FILE__) .'/common.php'; +require_once dirname(__FILE__) .'/application/bootstrap.php'; includeLang('buddy'); @@ -146,7 +146,7 @@ if ( $a == 1 ) { } $buddyrow = doquery( "SELECT * FROM {{table}} " . $query, 'buddy' ); -while ( $b = mysql_fetch_array( $buddyrow ) ) { +while ( $b = $buddyrow->fetch(PDO::FETCH_BOTH) ) { // para solicitudes if ( !isset( $i ) && isset( $a ) ) { $page .= " diff --git a/calc.php b/src/calc.php similarity index 97% rename from calc.php rename to src/calc.php index 2abcb2a..ab69276 100644 --- a/calc.php +++ b/src/calc.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/changelog.php b/src/changelog.php similarity index 84% rename from changelog.php rename to src/changelog.php index fb99527..ff78373 100644 --- a/changelog.php +++ b/src/changelog.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,13 +24,13 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); -require_once dirname(__FILE__) .'/common.php'; +require_once dirname(__FILE__) .'/application/bootstrap.php'; includeLang('changelog'); $template = gettemplate('changelog_table'); diff --git a/chat.php b/src/chat.php similarity index 79% rename from chat.php rename to src/chat.php index 76d4f06..a10f64b 100644 --- a/chat.php +++ b/src/chat.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,13 +24,13 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); -require_once dirname(__FILE__) .'/common.php'; +require_once dirname(__FILE__) .'/application/bootstrap.php'; includeLang('chat'); $BodyTPL = gettemplate('chat_body'); @@ -41,5 +41,5 @@ require_once dirname(__FILE__) .'/common.php'; $page = parsetemplate($BodyTPL, $parse); display($page, $lang['Chat'], false); -// Shoutbox by e-Zobar - Copyright XNova Team 2008 +// Shoutbox by e-Zobar - Copyright Wootook Team 2008 ?> \ No newline at end of file diff --git a/chat_add.php b/src/chat_add.php similarity index 83% rename from chat_add.php rename to src/chat_add.php index a6faba3..62381d4 100644 --- a/chat_add.php +++ b/src/chat_add.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,13 +24,13 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); -require_once dirname(__FILE__) .'/common.php'; +require_once dirname(__FILE__) .'/application/bootstrap.php'; // On récupère les informations du message et de l'envoyeur if (isset($_POST["msg"]) && isset($user['username'])) { @@ -49,5 +49,5 @@ require_once dirname(__FILE__) .'/common.php'; $query = doquery("INSERT INTO {{table}}(user, message, timestamp) VALUES ('".$nick."', '".$msg."', '".time()."')", "chat"); } -// Shoutbox by e-Zobar - Copyright XNova Team 2008 +// Shoutbox by e-Zobar - Copyright Wootook Team 2008 ?> \ No newline at end of file diff --git a/chat_msg.php b/src/chat_msg.php similarity index 89% rename from chat_msg.php rename to src/chat_msg.php index ea05b05..7228440 100644 --- a/chat_msg.php +++ b/src/chat_msg.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,13 +24,13 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); -require_once dirname(__FILE__) .'/common.php'; +require_once dirname(__FILE__) .'/application/bootstrap.php'; // On efface les anciens messages $timemoment=time(); @@ -62,12 +62,12 @@ while($v=mysql_fetch_object($query)){ $msg=preg_replace("#:\(#isU","\":(\"",$msg); $msg=preg_replace("#;\)#isU","\";)\"",$msg); $msg=preg_replace("#:s#isU","\":s\"",$msg); - $msg=preg_replace("#xnova#","XNova",$msg); + $msg=preg_replace("#xnova#","Wootook",$msg); // Affichage du message $msg="
    ".$nick." > ".$msg."
    "; print stripslashes($msg); } -// Shoutbox by e-Zobar - Copyright XNova Team 2008 +// Shoutbox by e-Zobar - Copyright Wootook Team 2008 ?> \ No newline at end of file diff --git a/contact.php b/src/contact.php similarity index 85% rename from contact.php rename to src/contact.php index 3f0ed16..437950c 100644 --- a/contact.php +++ b/src/contact.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,14 +24,14 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); define('DISABLE_IDENTITY_CHECK', true); -require_once dirname(__FILE__) .'/common.php'; +require_once dirname(__FILE__) .'/application/bootstrap.php'; includeLang('contact'); @@ -44,7 +44,7 @@ require_once dirname(__FILE__) .'/common.php'; $QrySelectUser .= "WHERE `authlevel` != '0' ORDER BY `authlevel` DESC;"; $GameOps = doquery ( $QrySelectUser, 'users'); - while( $Ops = mysql_fetch_assoc($GameOps) ) { + while( $Ops = $GameOps->fetch(PDO::FETCH_ASSOC) ) { $bloc['ctc_data_name'] = $Ops['username']; $bloc['ctc_data_auth'] = $lang['user_level'][$Ops['authlevel']]; $bloc['ctc_data_mail'] = "".$Ops['email'].""; diff --git a/emoticones/Oo.png b/src/emoticones/Oo.png similarity index 100% rename from emoticones/Oo.png rename to src/emoticones/Oo.png diff --git a/emoticones/Smile.png b/src/emoticones/Smile.png similarity index 100% rename from emoticones/Smile.png rename to src/emoticones/Smile.png diff --git a/emoticones/cool.png b/src/emoticones/cool.png similarity index 100% rename from emoticones/cool.png rename to src/emoticones/cool.png diff --git a/emoticones/grrr.png b/src/emoticones/grrr.png similarity index 100% rename from emoticones/grrr.png rename to src/emoticones/grrr.png diff --git a/emoticones/love.png b/src/emoticones/love.png similarity index 100% rename from emoticones/love.png rename to src/emoticones/love.png diff --git a/emoticones/msn.png b/src/emoticones/msn.png similarity index 100% rename from emoticones/msn.png rename to src/emoticones/msn.png diff --git a/emoticones/perdu.png b/src/emoticones/perdu.png similarity index 100% rename from emoticones/perdu.png rename to src/emoticones/perdu.png diff --git a/emoticones/wink.png b/src/emoticones/wink.png similarity index 100% rename from emoticones/wink.png rename to src/emoticones/wink.png diff --git a/emoticones/wow.png b/src/emoticones/wow.png similarity index 100% rename from emoticones/wow.png rename to src/emoticones/wow.png diff --git a/favicon.ico b/src/favicon.ico similarity index 100% rename from favicon.ico rename to src/favicon.ico diff --git a/src/fleet.php b/src/fleet.php new file mode 100644 index 0000000..e43bc39 --- /dev/null +++ b/src/fleet.php @@ -0,0 +1,286 @@ + + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License + * along with this program. If not, see . + * + * --> 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. + * + */ + +define('INSIDE' , true); +define('INSTALL' , false); +require_once dirname(__FILE__) .'/application/bootstrap.php'; +$labels = Wootook_Empire_Helper_Config_Labels::getSingleton(); + +//Compteur de flotte en expéditions et nombre d'expédition maximum +$maxExpedition = $user->getElement(Legacies_Empire::ID_RESEARCH_EXPEDITION_TECHNOLOGY); +$ExpeditionEnCours = 0; +$EnvoiMaxExpedition = 0; +if ($maxExpedition >= 1) { + $maxexpde = doquery("SELECT 1 FROM {{table}} WHERE `fleet_owner` = '".$user['id']."' AND `fleet_mission` = '15';", 'fleets'); + $ExpeditionEnCours = $maxexpde->rowCount(); + $maxexpde->closeCursor(); + + $EnvoiMaxExpedition = 1 + floor($maxExpedition / 3); +} + +$MaxFlottes = 1 + $user->getElement(Legacies_Empire::ID_RESEARCH_COMPUTER_TECHNOLOGY); + +includeLang('fleet'); + +$missionTypes = array( + Legacies_Empire::ID_MISSION_ATTACK => $lang['type_mission'][Legacies_Empire::ID_MISSION_ATTACK], + Legacies_Empire::ID_MISSION_GROUP_ATTACK => $lang['type_mission'][Legacies_Empire::ID_MISSION_GROUP_ATTACK], + Legacies_Empire::ID_MISSION_TRANSPORT => $lang['type_mission'][Legacies_Empire::ID_MISSION_TRANSPORT], + Legacies_Empire::ID_MISSION_STATION => $lang['type_mission'][Legacies_Empire::ID_MISSION_STATION], + Legacies_Empire::ID_MISSION_STATION_ALLY => $lang['type_mission'][Legacies_Empire::ID_MISSION_STATION_ALLY], + Legacies_Empire::ID_MISSION_SPY => $lang['type_mission'][Legacies_Empire::ID_MISSION_SPY], + Legacies_Empire::ID_MISSION_SETTLE_COLONY => $lang['type_mission'][Legacies_Empire::ID_MISSION_SETTLE_COLONY], + Legacies_Empire::ID_MISSION_RECYCLE => $lang['type_mission'][Legacies_Empire::ID_MISSION_RECYCLE], + Legacies_Empire::ID_MISSION_DESTROY => $lang['type_mission'][Legacies_Empire::ID_MISSION_DESTROY], + Legacies_Empire::ID_MISSION_EXPEDITION => $lang['type_mission'][Legacies_Empire::ID_MISSION_EXPEDITION] +); + +// Histoire de recuperer les infos passées par galaxy +$galaxy = isset($_GET['galaxy']) ? intval($_GET['galaxy']) : 0; +$system = isset($_GET['system']) ? intval($_GET['system']) : 0; +$position = isset($_GET['planet']) ? intval($_GET['planet']) : 0; +$planetType = isset($_GET['planettype']) ? intval($_GET['planettype']) : 0; +$targetMission = isset($_GET['target_mission']) ? intval($_GET['target_mission']) : 0; + +$user = Wootook_Player_Model_Session::getSingleton()->getPlayer(); +$planet = $user->getCurrentPlanet(); + +$MaxFlyingFleets = $user->getFleetCount(); + +if ($galaxy <= 0 || $galaxy > Wootook::getGameConfig('engine/universe/galaxies')) { + $galaxy = $planet['galaxy']; +} +if ($system <= 0 || $system > Wootook::getGameConfig('engine/universe/systems')) { + $system = $planet['system']; +} +if ($position <= 0 || $position > Wootook::getGameConfig('engine/universe/positions')) { + $position = $planet['planet']; +} + +$allowedPlanetTypes = array( + Wootook_Empire_Model_Planet::TYPE_PLANET, + Wootook_Empire_Model_Planet::TYPE_DEBRIS, + Wootook_Empire_Model_Planet::TYPE_MOON + ); + +if (!in_array($planetType, $allowedPlanetTypes)) { + $planetType = $planet['planet_type']; +} + +$page = "\n"; +$page .= "\n"; +$page .= "
    "; +$page .= "
    getData('deuterium_type')?> getData('energy_type')?> + getData('option') != ''):?> +
    +

    escape($this['planet']->getData('name'))?>

    +

    + +

    + count() > 0):?> +

    escape($this['queue_item']->getData('building_id'))?>

    + +

    __('Idle.')?>

    + +
    "; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +//$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; + +$i = 0; +foreach ($user->getFleetCollection() as $f) { + $i++; + $page .= ""; + // (01) Fleet ID + $page .= ""; + // (02) Fleet Mission + $page .= ""; + // (03) Fleet Mission + $page .= ""; + // (04) Fleet From (Planete d'origine) + $page .= ""; + // (05) Fleet Start Time + $page .= ""; + // (06) Fleet Target (Planete de destination) + $page .= ""; + // (07) Fleet Target Time + $page .= ""; + // (08) Fleet Back Time +// $page .= ""; + // (09) Fleet Back In + $page .= ""; + // (10) Orders + $page .= ""; + // Fin de ligne + $page .= ""; +} + + // Y a pas de flottes en vol ... on met des '-' +if ($i == 0) { + $page .= ""; + $page .= ""; + $page .= ""; + $page .= ""; + $page .= ""; + $page .= ""; + $page .= ""; + $page .= ""; +// $page .= ""; + $page .= ""; + $page .= ""; + $page .= ""; +} + +if ($MaxFlottes == $MaxFlyingFleets) { + $page .= ""; +} + +$page .= "
    "; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= "
    "; +$page .= $lang['fl_title']." ".$MaxFlyingFleets." ".$lang['fl_sur']." ".$MaxFlottes; +$page .= ""; +$page .= $ExpeditionEnCours."/".$EnvoiMaxExpedition." ".$lang['fl_expttl']; +$page .= "
    "; +$page .= "
    ".$lang['fl_id']."".$lang['fl_mission']."".$lang['fl_count']."".$lang['fl_from']."".$lang['fl_start_t']."".$lang['fl_dest']."".$lang['fl_dest_t']."".$lang['fl_back_t']."".$lang['fl_back_in']."".$lang['fl_order']."
    ".$i.""; + $page .= "". $missionTypes[$f['fleet_mission']] .""; + if (($f['fleet_start_time'] + 1) == $f['fleet_end_time']) { + $page .= "
    ".$lang['fl_back_to'].""; + } else { + $page .= "
    ".$lang['fl_get_to'].""; + } + $page .= "
    $b) { + if ($b != '') { + $e++; + $a = explode(",", $b); + $page .= $lang['tech'][$a[0]]. ":". $a[1] ."\n"; + if ($e > 1) { + $page .= "\t"; + } + } + } + $page .= "\">". pretty_number($f['fleet_amount']) ."[".$f[fleet_start_galaxy].":".$f['fleet_start_system'].":".$f['fleet_start_planet']."]". gmdate("d. M Y H:i:s", $f['fleet_start_time']) ."[".$f['fleet_end_galaxy'].":".$f['fleet_end_system'].":".$f['fleet_end_planet']."]". gmdate("d. M Y H:i:s", $f['fleet_end_time']) ."
    ". pretty_time(floor($f['fleet_end_time'] + 1 - time())) ."
    ". pretty_time(floor($f['fleet_end_time'] + 1 - time())) ."
    "; + if ($f['fleet_mess'] == 0) { + $page .= "
    "; + $page .= ""; + $page .= ""; + $page .= "
    "; + if ($f[fleet_mission] == 1) { + $page .= "
    "; + $page .= ""; + $page .= ""; + $page .= "
    "; + } + } else { + $page .= " - "; + } + $page .= "
    ----------
    ".$lang['fl_noslotfree']."
    "; + +$page .= "
    "; + +// Selection d'une nouvelle mission +$page .= "
    "; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; + +if (!$planet) { + message($lang['fl_noplanetrow'], $lang['fl_error']); +} + +$ShipData = ""; + +$have_ships = false; +foreach ($reslist['fleet'] as $n => $i) { + if ($planet->getElement($i) > 0) { + $page .= ""; + $page .= ""; + $page .= ""; + // Satelitte Solaire (eux ne peuvent pas bouger !) + if ($i == 212) { + $page .= ""; + } else { + $page .= ""; + $page .= ""; + } + $page .= ""; + $have_ships = true; + } +} + +$btncontinue = ""; +$page .= ""; +if (!$have_ships) { + // Il n'y a pas de vaisseaux sur cette planete + $page .= ""; + $page .= ""; + $page .= $btncontinue; +} else { + $page .= ""; + $page .= ""; + $page .= ""; + + if ($MaxFlottes > $MaxFlyingFleets) { + $page .= $btncontinue; + } +} +$page .= ""; +$page .= "
    ".$lang['fl_new_miss']."
    ".$lang['fl_fleet_typ']."".$lang['fl_fleet_disp']."--
    " . $labels[$i]['name'] . "". pretty_number ($planet->getElement($i)); + $ShipData .= "getElement($i) ."\" />"; + $ShipData .= ""; + $ShipData .= ""; + $ShipData .= ""; + $page .= "".$lang['fl_selmax']." getElement($i) ."\" onChange=\"shortInfo()\" onKeyUp=\"shortInfo()\" />
    ". $lang['fl_noships'] ."
    ". $lang['fl_unselectall'] ."". $lang['fl_selectall'] ."
    "; +$page .= $ShipData; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= "
    "; +$page .= "
    "; + +display($page, $lang['fl_title']); + diff --git a/src/fleetback.php b/src/fleetback.php new file mode 100644 index 0000000..4075674 --- /dev/null +++ b/src/fleetback.php @@ -0,0 +1,77 @@ + +Website: http://project.galacticnova.vinilox.eu/ +Last revision: 13/07/11 + +*/ + +define('INSIDE' , true); +define('INSTALL' , false); +require_once dirname(__FILE__) .'/application/bootstrap.php'; +includeLang('fleet'); + +$BoxTitle = $lang['fl_error']; +$TxtColor = "red"; +$BoxMessage = $lang['fl_notback']; +if (isset($_POST['fleetid']) && is_numeric($_POST['fleetid'])) { + $fleetid = intval($_POST['fleetid']); + + $readAdapter = Wootook_Core_Database_ConnectionManager::getSingleton()->getConnection('core_write'); + $FleetRow = $readAdapter->select() + ->from(array('fleet' => $readAdapter->getTable('fleets'))) + ->where('fleet_id', $fleetid) + ->prepare() + ->fetch() + ; + $i = 0; + + if ($FleetRow['fleet_owner'] == $user['id']) { + if ($FleetRow['fleet_mess'] == 0 || $FleetRow['fleet_mess'] == 2) { + if ($FleetRow['fleet_end_stay'] != 0) { + // Faut calculer le temps reel de retour + if ($FleetRow['fleet_start_time'] > time()) { + // On a pas encore entamé le stationnement + // Il faut calculer la parcelle de temps ecoulée depuis le lancement de la flotte + $CurrentFlyingTime = time() - $FleetRow['start_time']; + } else { + // On est deja en stationnement + // Il faut donc directement calculer la durée d'un vol aller ou retour + $CurrentFlyingTime = $FleetRow['fleet_start_time'] - $FleetRow['start_time']; + } + } else { + // C'est quoi le stationnement ?? + // On calcule sagement la parcelle de temps ecoulée depuis le depart + $CurrentFlyingTime = time() - $FleetRow['start_time']; + } + $ReturnFlyingTime = $CurrentFlyingTime + time(); + + $writeAdapter = Wootook_Core_Database_ConnectionManager::getSingleton()->getConnection('core_write'); + $writeAdapter->update() + ->into($writeAdapter->getTable('fleets')) + ->set('fleet_start_time', time()) + ->set('fleet_end_stay', 0) + ->set('fleet_end_time', $ReturnFlyingTime) + ->set('fleet_target_owner', $user->getId()) + ->set('fleet_mess', 1) + ->where('fleet_id', $fleetid) + ->execute() + ; + + $BoxTitle = $lang['fl_sback']; + $TxtColor = "lime"; + $BoxMessage = $lang['fl_isback']; + } elseif ($FleetRow['fleet_mess'] == 1) { + $BoxMessage = $lang['fl_notback']; + } + } else { + $BoxMessage = $lang['fl_onlyyours']; + } +} + +message ($BoxMessage, $BoxTitle, "fleet.". PHPEXT, 2); diff --git a/src/fleetshortcut.php b/src/fleetshortcut.php new file mode 100644 index 0000000..016de90 --- /dev/null +++ b/src/fleetshortcut.php @@ -0,0 +1,208 @@ + + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License + * along with this program. If not, see . + * + * --> 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. + * + */ + +define('INSIDE' , true); +define('INSTALL' , false); +require_once dirname(__FILE__) .'/application/bootstrap.php'; + + +$mode = isset($_GET['mode']) ? $_GET['mode'] : null; +$a = isset($_GET['a']) ? $_GET['a'] : null; + +$user = Wootook_Player_Model_Session::getSingleton()->getPlayer(); + +if ($mode) { + if ($_POST) { + //Pegamos el texto :P + if (!isset($_POST["n"]) || empty($_POST["n"])) { + $name = Wootook::__("Unnamed"); + } else { + $name = $_POST["n"]; + } + + if (($offset = strpos($name, "\n")) !== false) { + $name = substr($name, 0, $offset); + } + if (($offset = strpos($name, "\r")) !== false) { + $name = substr($name, 0, $offset); + } + if (($offset = strpos($name, ",")) !== false) { + $name = substr($name, 0, $offset); + } + $planetTypes = array( + Wootook_Empire_Model_Planet::TYPE_PLANET, + Wootook_Empire_Model_Planet::TYPE_DEBRIS, + Wootook_Empire_Model_Planet::TYPE_MOON + ); + + $r = array(); + $r[0] = preg_replace('#[^[:alnum:]\s\-\_\']#', '', $name); + $r[1] = (isset($_POST['g']) && intval($_POST['g']) > 0 && intval($_POST['g']) <= Wootook::getGameConfig('engine/universe/galaxies')) ? intval($_POST['g']) : '1'; + $r[2] = (isset($_POST['s']) && intval($_POST['s']) > 0 && intval($_POST['s']) <= Wootook::getGameConfig('engine/universe/systems')) ? intval($_POST['s']) : '1'; + $r[3] = (isset($_POST['p']) && intval($_POST['p']) > 0 && intval($_POST['p']) <= Wootook::getGameConfig('engine/universe/positions')) ? intval($_POST['p']) : '1'; + $r[4] = (isset($_POST['t']) && intval($_POST['t']) > 0 && in_array(intval($_POST['t']), $planetTypes)) ? intval($_POST['t']) : '1'; + + $user['fleet_shortcut'] .= implode(",", $r); + $user->save(); + message(Wootook::__("The shortcut has been saved."), Wootook::__("Success"), "fleetshortcut.php"); + } + $page = "
    + + + + "; + $page .= '
    Nom [Galaxie/Système solaire/Planète]
    + + + + + +
    "; + //Muestra un (L) si el destino pertenece a luna, lo mismo para escombros + $page .= "
    Effacer
    '; +} else if ($a !== null) { + if ($_POST) { + //Armamos el array... + $scarray = explode("\r\n", $user['fleet_shortcut']); + if (isset($_POST["delete"])) { + unset($scarray[$a]); + $user['fleet_shortcut'] = implode("\r\n", $scarray); + doquery("UPDATE {{table}} SET fleet_shortcut={$db->quote($user['fleet_shortcut'])} WHERE id={$user['id']}", "users"); + message(Wootook::__("The shortcut has been deleted"), Wootook::__("Success"), "fleetshortcut.php"); + } else { + $r = explode(",", $scarray[$a]); + if (!isset($_POST["n"]) || empty($_POST["n"])) { + $name = $r[0]; + } else { + $name = $_POST["n"]; + } + + if (($offset = strpos($name, "\n")) !== false) { + $name = substr($name, 0, $offset); + } + if (($offset = strpos($name, "\r")) !== false) { + $name = substr($name, 0, $offset); + } + if (($offset = strpos($name, ",")) !== false) { + $name = substr($name, 0, $offset); + } + $planetTypes = array( + Wootook_Empire_Model_Planet::TYPE_PLANET, + Wootook_Empire_Model_Planet::TYPE_DEBRIS, + Wootook_Empire_Model_Planet::TYPE_MOON + ); + $r[0] = preg_replace('#[^[:alnum:]\s\-\_\']#', '', $name); + $r[1] = (isset($_POST['g']) && intval($_POST['g']) > 0 && intval($_POST['g']) <= Wootook::getGameConfig('engine/universe/galaxies')) ? intval($_POST['g']) : $r[1]; + $r[2] = (isset($_POST['s']) && intval($_POST['s']) > 0 && intval($_POST['s']) <= Wootook::getGameConfig('engine/universe/systems')) ? intval($_POST['s']) : $r[2]; + $r[3] = (isset($_POST['p']) && intval($_POST['p']) > 0 && intval($_POST['p']) <= Wootook::getGameConfig('engine/universe/positions')) ? intval($_POST['p']) : $r[3]; + $r[4] = (isset($_POST['t']) && intval($_POST['t']) > 0 && in_array(intval($_POST['t']), $planetTypes)) ? intval($_POST['t']) : $r[4]; + + $scarray[$a] = implode(",", $r); + $user['fleet_shortcut'] = implode("\r\n", $scarray); + $user->save(); + message(Wootook::__("The shortcut has been updated."), Wootook::__("Success"), "fleetshortcut.php"); + } + } + + if ($user['fleet_shortcut']) { + + $scarray = explode("\r\n",$user['fleet_shortcut']); + $c = explode(',',$scarray[$a]); + + $page = "
    + + + "; + //if($i==0){$page .= "";} + $page .= " + "; + + } else { + $page .= message("Le raccourcis a été enregistré !","Enregistrer","fleetshortcut.php"); + } + + $page .= '
    Editer: {$c[0]} [{$c[1]}:{$c[2]}:{$c[3]}]
    + + + + + + +
    "; + $page .= "
    Retour
    '; + + +} else { + + $page = ' + + + '; + + if($user['fleet_shortcut']){ + /* + Dentro de fleet_shortcut, se pueden almacenar las diferentes direcciones + de acceso directo, el formato es el siguiente. + Nombre, Galaxia,Sistema,Planeta,Tipo + */ + $scarray = explode("\r\n",$user['fleet_shortcut']); + $i=$e=0; + foreach($scarray as $a => $b){ + if($b!=""){ + $c = explode(',',$b); + if($i==0){$page .= "";} + $page .= ""; + if($i==1){$page .= "";} + if($i==1){$i=0;}else{$i=1;} + } + + } + if($i==1){$page .= "";} + + }else{$page .= "";} + + $page .= '
    Raccourcis(Ajout)
    "; + $page .= "{$c[0]} {$c[1]}:{$c[2]}:{$c[3]}"; + //Muestra un (L) si el destino pertenece a luna, lo mismo para escombros + if($c[4]==2){$page .= " (E)";}elseif($c[4]==3){$page .= " (L)";} + $page .= "
    Pas de Raccourcis
    Retour
    '; +} +display($page,"Shortcutmanager"); + +// Created by Perberos. All rights reversed (C) 2006 +?> diff --git a/src/floten1.php b/src/floten1.php new file mode 100644 index 0000000..5c881a1 --- /dev/null +++ b/src/floten1.php @@ -0,0 +1,334 @@ + + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License + * along with this program. If not, see . + * + * --> 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. + * + */ + +define('INSIDE' , true); +define('INSTALL' , false); +require_once dirname(__FILE__) .'/application/bootstrap.php'; +includeLang('fleet'); + +$speed = array( + 10 => 100, + 9 => 90, + 8 => 80, + 7 => 70, + 6 => 60, + 5 => 50, + 4 => 40, + 3 => 30, + 2 => 20, + 1 => 10, + ); + +$user = Wootook_Player_Model_Session::getSingleton()->getPlayer(); +$planetrow = $user->getCurrentPlanet(); + +$g = isset($_POST['galaxy']) ? intval($_POST['galaxy']) : 0; +$s = isset($_POST['system']) ? intval($_POST['system']) : 0; +$p = isset($_POST['planet']) ? intval($_POST['planet']) : 0; +$t = isset($_POST['planet_type']) ? intval($_POST['planet_type']) : 0; + +if ($g <= 0 || $g > Wootook::getGameConfig('engine/universe/galaxies')) { + $g = $planetrow['galaxy']; +} +if ($s <= 0 || $s > Wootook::getGameConfig('engine/universe/systems')) { + $s = $planetrow['system']; +} +if ($p <= 0 || $p > Wootook::getGameConfig('engine/universe/positions')) { + $p = $planetrow['planet']; +} +$allowedPlanetTypes = array( + Wootook_Empire_Model_Planet::TYPE_PLANET, + Wootook_Empire_Model_Planet::TYPE_DEBRIS, + Wootook_Empire_Model_Planet::TYPE_MOON + ); + +if (!in_array($t, $allowedPlanetTypes)) { + $t = $planet['planet_type']; +} + +$session = Wootook::getSession('fleet'); +$session->clearData(); +$FleetHiddenBlock = ""; + +$fleetArray = array(); +$speedArray = array(); +$consumptionArray = array(); +$capacityArray = array(); +if (isset($_POST['ship']) && is_array($_POST['ship'])) { + $selectedShips = $_POST['ship']; +} +foreach ($reslist[Legacies_Empire::TYPE_SHIP] as $shipId) { + if (!isset($selectedShips[$shipId])) { + continue; + } + + $qty = intval($selectedShips[$shipId]); + if ($qty <= 0) { + continue; + } + + if ($qty > $planetrow->getElement($shipId)) { + $page .= $lang['fl_noenought']; + $speedalls[$shipId] = GetFleetMaxSpeed("", $shipId, $user); + } else { + $fleetArray[$shipId] = $qty; + $session['qty'] += $qty; + $speedArray[$shipId] = GetFleetMaxSpeed("", $shipId, $user); + $consumptionArray[$shipId] = GetShipConsumption($shipId, $user); + $capacityArray[$shipId] = $pricelist[$shipId]['capacity']; + + // Tableau des vitesses + $FleetHiddenBlock .= ""; + $FleetHiddenBlock .= ""; + $FleetHiddenBlock .= ""; + $FleetHiddenBlock .= ""; + $speedalls[$shipId] = GetFleetMaxSpeed("", $shipId, $user); + } +} +unset($selectedShips); + +$session['fleet'] = $fleetArray; +$session['speed'] = $speedArray; +$session['consumption'] = $consumptionArray; +$session['capacity'] = $capacityArray; + +if (empty($fleetArray)) { + message($lang['fl_unselectall'], $lang['fl_error'], "fleet." . PHPEXT, 1); +} else { + $speedallsmin = min($speedalls); +} + +$speedFactor = GetGameSpeedFactor(); +$session['speedallsmin'] = $speedallsmin; + +$scriptPath = Wootook::getStaticUrl('scripts/flotten.js'); +$page = ""; +$page .= "\n"; +$page .= "
    "; +$page .= $FleetHiddenBlock; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; + +$page .= "
    "; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; + +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +/* A faire assez rapidement (faut juste savoir comment) + $page .= ""; + $page .= ""; + $page .= ""; + $page .= ""; + $page .= ""; + $page .= ""; +*/ +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; + +// Gestion des raccourcis sur la galaxie +$page .= ""; +$page .= ""; +$page .= ""; +if ($user['fleet_shortcut']) { + $scarray = explode("\r\n", $user['fleet_shortcut']); + $i = 0; + foreach ($scarray as $a => $b) { + if ($b != "") { + $c = explode(',', $b); + if ($i == 0) { + $page .= ""; + } + $page .= ""; + $page .= ""; +} + +$page .= ""; +$page .= ""; +$page .= ""; + +// Gestion des raccourcis vers ses propres colonies ou planetes +$kolonien = $user->getPlanetCollection(); +$currentplanet = $user->getCurrentPlanet(); + +if ($kolonien->getSize() > 1) { + $i = 0; + $w = 0; + $tr = true; + foreach ($user->getPlanetCollection() as $userPlanet) { + /** @var Wootook_Empire_Model_Planet $userPlanet */ + if ($w == 0 && $tr) { + $page .= ""; + $tr = false; + } + if ($w == 2) { + $page .= ""; + $w = 0; + $tr = true; + } + + $name = $userPlanet->getName(); + if ($userPlanet->getType() == Wootook_Empire_Model_Planet::TYPE_MOON) { + $name .= " " . $lang['fl_shrtcup3']; + } + + if ($currentplanet->getId() != $userPlanet->getId()) { + $page .= ""; + $w++; + $i++; + } + } + + if ($i % 2 != 0) { + $page .= ""; + } elseif ($w == 2) { + $page .= ""; + } +} else { + $page .= ""; +} + +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= "
    ". $lang['fl_floten1_ttl'] ."
    ". $lang['fl_dest'] .""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= "
    ". $lang['fl_speed'] .""; +$page .= " %"; +$page .= "
    ". $lang['fl_dist'] ."
    -
    ". $lang['fl_fltime'] ."
    -
    ". $lang['fl_time_go'] ."
    ". gmdate("H:i:s") ."
    ". $lang['fl_time_back'] ."
    ". gmdate("H:i:s") ."
    ". $lang['fl_deute_need'] ."
    -
    ". $lang['fl_speed_max'] ."
    -
    ". $lang['fl_max_load'] ."
    -
    ". $lang['fl_shortcut'] ." ". $lang['fl_shortlnk'] ."
    "; + $page .= "". $lang['fl_noshortc'] ."
    ". $lang['fl_myplanets'] ."
    getGalaxy() .",". $userPlanet->getSystem() .",". $userPlanet->getPosition() .",". $userPlanet->getType() ."); shortInfo();\">". $name . " ". $userPlanet->getCoords() ." 
    ". $lang['fl_nocolonies'] ."
    ". $lang['fl_grattack'] ."
    -
    "; +$page .= "
    "; + +$maxExpedition = $user->getElement(Legacies_Empire::ID_RESEARCH_EXPEDITION_TECHNOLOGY); +$ExpeditionEnCours = 0; +$EnvoiMaxExpedition = 0; +if ($maxExpedition >= 1) { + $readAdapter = Wootook_Core_Database_ConnectionManager::getSingleton()->getConnection('core_read'); + $ExpeditionEnCours = $readAdapter->select() + ->column(new Wootook_Core_Database_Sql_Placeholder_Expression('COUNT(*)')) + ->from(array('fleet' => $readAdapter->getTable('fleets'))) + ->where('fleet_owner', $user->getId()) + ->where('fleet_mission', Legacies_Empire::ID_MISSION_EXPEDITION) + ->prepare() + ->fetchColumn() + ; + + $EnvoiMaxExpedition = 1 + floor($maxExpedition / 3); +} +$page .= ""; +$page .= ""; +$page .= ""; +$page .= "
    "; +$page .= ""; + +display($page, $lang['fl_title']); + diff --git a/src/floten2.php b/src/floten2.php new file mode 100644 index 0000000..1563070 --- /dev/null +++ b/src/floten2.php @@ -0,0 +1,322 @@ + + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License + * along with this program. If not, see . + * + * --> 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. + * + */ + +define('INSIDE' , true); +define('INSTALL' , false); +require_once dirname(__FILE__) .'/application/bootstrap.php'; +includeLang('fleet'); + +$session = Wootook::getSession('fleet'); + +$galaxy = isset($_POST['galaxy']) ? intval($_POST['galaxy']) : 0; +$system = isset($_POST['system']) ? intval($_POST['system']) : 0; +$position = isset($_POST['planet']) ? intval($_POST['planet']) : 0; +$planetType = isset($_POST['planettype']) ? intval($_POST['planettype']) : 0; +$speed = isset($_POST['speed']) ? intval($_POST['speed']) : 10; + +$coords = array( + 'galaxy' => $galaxy, + 'system' => $system, + 'position' => $position + ); +$destination = Wootook_Empire_Model_Planet::factoryFromCoords($coords, $planetType); +$session['planet_destination'] = $destination->getId(); + +$user = Wootook_Player_Model_Session::getSingleton()->getPlayer(); +$planet = $user->getCurrentPlanet(); + +$YourPlanet = false; +if ($destination->getUserId() == $user->getId()) { + $YourPlanet = true; +} +$UsedPlanet = false; +if ($destination->getId()) { + $UsedPlanet = true; +} + +$fleetArray = $session['fleet']; +if (empty($fleetArray)) { + Wootook::getResponse() + ->setRedirect(Wootook::getStaticUrl('fleet.php')) + ->sendHeaders(); + exit(0); +} + +$missionTypes = array(); +// Determinons les type de missions possibles par rapport a la planete cible + +if ($position == (Wootook::getGameConfig('engine/universe/positions') + 1)) { + $missionTypes[Legacies_Empire::ID_MISSION_EXPEDITION] = $lang['type_mission'][Legacies_Empire::ID_MISSION_EXPEDITION]; +} else { + if ($planetType == Wootook_Empire_Model_Planet::TYPE_DEBRIS) { + if (isset($fleetArray[Legacies_Empire::ID_SHIP_RECYCLER]) && $fleetArray[Legacies_Empire::ID_SHIP_RECYCLER] > 0) { + $missionTypes[Legacies_Empire::ID_MISSION_RECYCLE] = $lang['type_mission'][Legacies_Empire::ID_MISSION_RECYCLE]; + } + } else if ($planetType == Wootook_Empire_Model_Planet::TYPE_PLANET) { + if (isset($fleetArray[Legacies_Empire::ID_SHIP_COLONY_SHIP]) && $fleetArray[Legacies_Empire::ID_SHIP_COLONY_SHIP] > 0 && !$UsedPlanet) { + $missionTypes[Legacies_Empire::ID_MISSION_SETTLE_COLONY] = $lang['type_mission'][7]; + } + } else if ($planetType == Wootook_Empire_Model_Planet::TYPE_MOON) { + if (((isset($fleetArray[Legacies_Empire::ID_SHIP_DEATH_STAR]) && $fleetArray[Legacies_Empire::ID_SHIP_DEATH_STAR] > 0) || + (isset($fleetArray[Legacies_Empire::ID_SHIP_SUPERNOVA]) && $fleetArray[Legacies_Empire::ID_SHIP_SUPERNOVA] > 0)) && + !$YourPlanet && $UsedPlanet) { + $missionTypes[Legacies_Empire::ID_MISSION_DESTROY] = $lang['type_mission'][Legacies_Empire::ID_MISSION_DESTROY]; + } + } + + if (in_array($planetType, array(Wootook_Empire_Model_Planet::TYPE_MOON, Wootook_Empire_Model_Planet::TYPE_PLANET))) { + if (isset($fleetArray[Legacies_Empire::ID_SHIP_SPY_DRONE]) && $fleetArray[Legacies_Empire::ID_SHIP_SPY_DRONE] > 0 && !$YourPlanet) { + $missionTypes[Legacies_Empire::ID_MISSION_SPY] = $lang['type_mission'][Legacies_Empire::ID_MISSION_SPY]; + } + + if ((isset($fleetArray[Legacies_Empire::ID_SHIP_LIGHT_TRANSPORT]) && $fleetArray[Legacies_Empire::ID_SHIP_LIGHT_TRANSPORT] > 0) || + (isset($fleetArray[Legacies_Empire::ID_SHIP_LARGE_TRANSPORT]) && $fleetArray[Legacies_Empire::ID_SHIP_LARGE_TRANSPORT] > 0) || + (isset($fleetArray[Legacies_Empire::ID_SHIP_LIGHT_FIGHTER]) && $fleetArray[Legacies_Empire::ID_SHIP_LIGHT_FIGHTER] > 0) || + (isset($fleetArray[Legacies_Empire::ID_SHIP_HEAVY_FIGHTER]) && $fleetArray[Legacies_Empire::ID_SHIP_HEAVY_FIGHTER] > 0) || + (isset($fleetArray[Legacies_Empire::ID_SHIP_CRUISER]) && $fleetArray[Legacies_Empire::ID_SHIP_CRUISER] > 0) || + (isset($fleetArray[Legacies_Empire::ID_SHIP_BATTLESHIP]) && $fleetArray[Legacies_Empire::ID_SHIP_BATTLESHIP] > 0) || + (isset($fleetArray[Legacies_Empire::ID_SHIP_RECYCLER]) && $fleetArray[Legacies_Empire::ID_SHIP_RECYCLER] > 0) || + (isset($fleetArray[Legacies_Empire::ID_SHIP_SPY_DRONE]) && $fleetArray[Legacies_Empire::ID_SHIP_SPY_DRONE] > 0 && Wootook::getGameConfig('engine/combat/allow_spy_drone_attacks')) || + (isset($fleetArray[Legacies_Empire::ID_SHIP_BOMBER]) && $fleetArray[Legacies_Empire::ID_SHIP_BOMBER] > 0) || + (isset($fleetArray[Legacies_Empire::ID_SHIP_DESTRUCTOR]) && $fleetArray[Legacies_Empire::ID_SHIP_DESTRUCTOR] > 0) || + (isset($fleetArray[Legacies_Empire::ID_SHIP_DEATH_STAR]) && $fleetArray[Legacies_Empire::ID_SHIP_DEATH_STAR] > 0) || + (isset($fleetArray[Legacies_Empire::ID_SHIP_BATTLECRUISER]) && $fleetArray[Legacies_Empire::ID_SHIP_BATTLECRUISER] > 0) || + (isset($fleetArray[Legacies_Empire::ID_SHIP_SUPERNOVA]) && $fleetArray[Legacies_Empire::ID_SHIP_SUPERNOVA] > 0)) { + + if (!$YourPlanet) { + $missionTypes[Legacies_Empire::ID_MISSION_ATTACK] = $lang['type_mission'][Legacies_Empire::ID_MISSION_ATTACK]; + $missionTypes[Legacies_Empire::ID_MISSION_GROUP_ATTACK] = $lang['type_mission'][Legacies_Empire::ID_MISSION_GROUP_ATTACK]; + $missionTypes[Legacies_Empire::ID_MISSION_STATION_ALLY] = $lang['type_mission'][Legacies_Empire::ID_MISSION_STATION_ALLY]; + } + $missionTypes[Legacies_Empire::ID_MISSION_TRANSPORT] = $lang['type_mission'][Legacies_Empire::ID_MISSION_TRANSPORT]; + } + + if ($YourPlanet) { + $missionTypes[Legacies_Empire::ID_MISSION_STATION] = $lang['type_mission'][Legacies_Empire::ID_MISSION_STATION]; + } + } +} + +if (isset($fleetArray[Legacies_Empire::ID_SHIP_SOLAR_SATELLITE])) { + $missionTypes = array(); +} + +$mission = isset($_POST['target_mission']) ? $_POST['target_mission'] : 0; + +$SpeedFactor = Wootook::getGameConfig('game/speed/general'); +$AllFleetSpeed = GetFleetMaxSpeed($fleetArray, 0, $user); +$MaxFleetSpeed = min($AllFleetSpeed); + +$distance = GetTargetDistance($planet->getGalaxy(), $galaxy, $planet->getSystem(), $system, $planet->getPosition(), $position); +$duration = GetMissionDuration($speed, $MaxFleetSpeed, $distance, $SpeedFactor); +$consumption = GetFleetConsumption($fleetArray, $SpeedFactor, $duration, $distance, $MaxFleetSpeed, $user ); + +$session['distance'] = $distance; +$session['duration'] = $duration; +$session['consumption'] = $consumption; +$session['speed'] = $speed; +$session['galaxy'] = $galaxy; +$session['system'] = $system; +$session['position'] = $position; +$session['type'] = $planetType; + +$MissionSelector = ""; +if (count($missionTypes) > 0) { + if ($position == (Wootook::getGameConfig('engine/universe/positions') + 1)) { + $MissionSelector .= "
    "; + $MissionSelector .= "". $lang['type_mission'][Legacies_Empire::ID_MISSION_EXPEDITION] ."

    "; + $MissionSelector .= "". $lang['fl_expe_warning'] .""; + $MissionSelector .= "
    "; + $MissionSelector .= ""; + $MissionSelector .= "
    "; + $MissionSelector .= "
    "; + $MissionSelector .= "". $lang['fl_bad_mission'] .""; + $MissionSelector .= "
    \n"; +$page .= "\n"; +$page .= "\n"; +$page .= "\n"; +$page .= "\n"; +$page .= "\n"; +$page .= "\n"; +$page .= "\n"; +$page .= "\n"; +$page .= "\n"; +$page .= "\n"; +$page .= "\n"; +$page .= "
    ". $TableTitle ."
    \n"; +$page .= "\n"; +$page .= "\n"; +$page .= "\n"; +$page .= "\n"; +$page .= "\n"; +$page .= $MissionSelector; +$page .= "\n"; +$page .= "
    ". $lang['fl_mission'] ."
    \n"; +$page .= "
    \n"; +$page .= "\n"; +$page .= "\n"; +$page .= "\n"; +$page .= "\n"; +$page .= "\n"; +$page .= "\n"; +$page .= "\n"; +$page .= "\n"; +$page .= "\n"; +$page .= "\n"; +$page .= "\n"; +$page .= "\n"; +$page .= "\n"; +$page .= "\n"; +$page .= "\n"; +$page .= "\n"; +$page .= "\n"; +$page .= "\n"; +$page .= "\n"; +$page .= "\n"; +$page .= "\n"; +$page .= "\n"; +$page .= "\n"; +$page .= "\n"; +if ($position == (Wootook::getGameConfig('engine/universe/positions') + 1)) { + $page .= ""; + $page .= ""; + $page .= ""; + $page .= ""; + $page .= ""; + $page .= ""; +} else if (isset($missionTypes[Legacies_Empire::ID_MISSION_STATION_ALLY]) || isset($missionTypes[Legacies_Empire::ID_MISSION_ORE_MINING])) { + $page .= ""; + $page .= ""; + $page .= ""; + $page .= ""; + $page .= ""; + $page .= ""; +} +$page .= "\n"; +$page .= "
    ". $lang['fl_ressources'] ."
    ". $lang['Metal'] ."". $lang['fl_selmax'] ."
    ". $lang['Crystal'] ."". $lang['fl_selmax'] ."
    ". $lang['Deuterium'] ."". $lang['fl_selmax'] ."
    ". $lang['fl_space_left'] ."
    -
    ". $lang['fl_allressources'] ."
     
    ". $lang['fl_expe_staytime'] ."
    "; + $page .= ""; + $page .= $lang['fl_expe_hours']; + $page .= "
    ". $lang['fl_expe_staytime'] ."
    "; + $page .= ""; + $page .= $lang['fl_expe_hours']; + $page .= "
    \n"; +$page .= "
    \n"; +$page .= "
    \n"; + +display($page, $lang['fl_title']); diff --git a/src/floten3.php b/src/floten3.php new file mode 100644 index 0000000..23f3985 --- /dev/null +++ b/src/floten3.php @@ -0,0 +1,508 @@ + + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License + * along with this program. If not, see . + * + * --> 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. + * + */ + +define('INSIDE' , true); +define('INSTALL' , false); +require_once dirname(__FILE__) .'/application/bootstrap.php'; + +includeLang('fleet'); + +$session = Wootook::getSession('fleet'); + +$user = Wootook_Player_Model_Session::getSingleton()->getPlayer(); +$planet = $user->getCurrentPlanet(); + +$mission = isset($_POST['mission']) ? intval($_POST['mission']) : 0; +$galaxy = isset($session['galaxy']) ? $session['galaxy'] : 0; +$system = isset($session['system']) ? $session['system'] : 0; +$position = isset($session['position']) ? $session['position'] : 0; +$type = isset($session['type']) ? $session['type'] : 0; +$speed = isset($session['speed']) ? $session['speed'] : 10; + +$protection = Wootook::getGameConfig('game/noob-protection/active'); +$protectionPointsCap = Wootook::getGameConfig('game/noob-protection/points-cap'); +$protectionMultiplier = Wootook::getGameConfig('game/noob-protection/multiplier'); + +$readAdapter = Wootook_Core_Database_ConnectionManager::getSingleton() + ->getConnection('core_read'); +$writeAdapter = Wootook_Core_Database_ConnectionManager::getSingleton() + ->getConnection('core_write'); + +if ($protectionPointsCap < 1) { + $protectionPointsCap = 0x7FFFFFFF; +} + +$fleetArray = $session['fleet']; + +if (!is_array($fleetArray)) { + message($lang['fl_fleet_err'], $lang['fl_error'], "fleet.php", 2); +} + +// On verifie s'il y a assez de vaisseaux sur la planete ! +foreach ($fleetArray as $shipId => $count) { + if ($count > $planet->getElement($shipId)) { + message($lang['fl_fleet_err'], $lang['fl_error'], "fleet.php", 2); + } +} + +$allowedPlanetTypes = array( + Wootook_Empire_Model_Planet::TYPE_PLANET, + Wootook_Empire_Model_Planet::TYPE_DEBRIS, + Wootook_Empire_Model_Planet::TYPE_MOON + ); +if (!in_array($type, $allowedPlanetTypes)) { + message($lang['fl_fleet_err_pl'], $lang['fl_error'], "fleet.php", 2); +} + +if ($planet->getGalaxy() == $galaxy && + $planet->getSystem() == $system && + $planet->getPosition() == $position && + $planet->getType() == $type) { + message($lang['fl_ownpl_err'], $lang['fl_error'], "fleet.php", 2); +} + +$YourPlanet = false; +$UsedPlanet = false; +$coords = array( + 'galaxy' => $galaxy, + 'system' => $system, + 'position' => $position + ); +if ($mission == Legacies_Empire::ID_MISSION_RECYCLE) { + $destination = Wootook_Empire_Model_Planet::factoryFromCoords($coords); +} else { + $destination = Wootook_Empire_Model_Planet::factoryFromCoords($coords, $type); +} + +// Test d'existence de l'enregistrement dans la galaxie ! +if ($mission != Legacies_Empire::ID_MISSION_EXPEDITION) { + if (!$destination->getId()) { + if ($mission != Legacies_Empire::ID_MISSION_SETTLE_COLONY) { + message($lang['fl_unknow_target'], $lang['fl_error'], "fleet." . PHPEXT, 2); + } else if ($mission == Legacies_Empire::ID_MISSION_DESTROY) { + message($lang['fl_used_target'], $lang['fl_error'], "fleet." . PHPEXT, 2); + } + } else if ($mission == Legacies_Empire::ID_MISSION_DESTROY && !$destination->isMoon()) { + message($lang['fl_used_target'], $lang['fl_error'], "fleet." . PHPEXT, 2); + } +} else { + $EnvoiMaxExpedition = $user->getElement(Legacies_Empire::ID_RESEARCH_EXPEDITION_TECHNOLOGY); + $Expedition = 0; + if ($EnvoiMaxExpedition > 0) { + $statement = $readAdapter->select() + ->column(new Wootook_Core_Database_Sql_Placeholder_Expression('COUNT(*)')) + ->from(array('fleet' => $readAdapter->getTable('fleets'))) + ->where('fleet_owner', new Wootook_Core_Database_Sql_Placeholder_Param('player', $user->getId())) + ->where('fleet_mission', Legacies_Empire::ID_MISSION_EXPEDITION) + ->prepare() + ; + + $Expedition = $statement->fetchColumn(); + } + + if ($EnvoiMaxExpedition == 0 ) { + message ($lang['fl_expe_notech'], $lang['fl_error'], "fleet." . PHPEXT, 2); + } else if ($Expedition >= $EnvoiMaxExpedition ) { + message ($lang['fl_expe_max'], $lang['fl_error'], "fleet." . PHPEXT, 2); + } +} + +if ($destination->getUserId() == $user['id']) { + $YourPlanet = true; + $UsedPlanet = true; +} else if ($destination->getId()) { + $UsedPlanet = true; +} + +$missionTypes = array(); +// Determinons les type de missions possibles par rapport a la planete cible +if ($position == (Wootook::getGameConfig('engine/universe/positions') + 1)) { + $missionTypes[Legacies_Empire::ID_MISSION_EXPEDITION] = $lang['type_mission'][Legacies_Empire::ID_MISSION_EXPEDITION]; +} else { + if ($type == Wootook_Empire_Model_Planet::TYPE_DEBRIS) { + if (isset($fleetArray[Legacies_Empire::ID_SHIP_RECYCLER]) && $fleetArray[Legacies_Empire::ID_SHIP_RECYCLER] > 0) { + $missionTypes[Legacies_Empire::ID_MISSION_RECYCLE] = $lang['type_mission'][Legacies_Empire::ID_MISSION_RECYCLE]; + } + } else if ($type == Wootook_Empire_Model_Planet::TYPE_PLANET) { + if (isset($fleetArray[Legacies_Empire::ID_SHIP_COLONY_SHIP]) && $fleetArray[Legacies_Empire::ID_SHIP_COLONY_SHIP] > 0 && !$UsedPlanet) { + $missionTypes[Legacies_Empire::ID_MISSION_SETTLE_COLONY] = $lang['type_mission'][Legacies_Empire::ID_MISSION_SETTLE_COLONY]; + } + if (isset($fleetArray[Legacies_Empire::ID_SHIP_ORE_MININER]) && $fleetArray[Legacies_Empire::ID_SHIP_ORE_MININER] > 0 && !$UsedPlanet) { + $missionTypes[Legacies_Empire::ID_MISSION_ORE_MINING] = $lang['type_mission'][Legacies_Empire::ID_MISSION_ORE_MINING]; + } + } else if ($type == Wootook_Empire_Model_Planet::TYPE_MOON) { + if (((isset($fleetArray[Legacies_Empire::ID_SHIP_DEATH_STAR]) && $fleetArray[Legacies_Empire::ID_SHIP_DEATH_STAR] > 0) || + (isset($fleetArray[Legacies_Empire::ID_SHIP_SUPERNOVA]) && $fleetArray[Legacies_Empire::ID_SHIP_SUPERNOVA] > 0)) && + !$YourPlanet && $UsedPlanet) { + $missionTypes[Legacies_Empire::ID_MISSION_DESTROY] = $lang['type_mission'][Legacies_Empire::ID_MISSION_DESTROY]; + } + if (isset($fleetArray[Legacies_Empire::ID_SHIP_ORE_MININER]) && $fleetArray[Legacies_Empire::ID_SHIP_ORE_MININER] > 0 && !$YourPlanet) { + $missionTypes[Legacies_Empire::ID_MISSION_ORE_MINING] = $lang['type_mission'][Legacies_Empire::ID_MISSION_ORE_MINING]; + } + } + + if (in_array($type, array(Wootook_Empire_Model_Planet::TYPE_MOON, Wootook_Empire_Model_Planet::TYPE_PLANET))) { + if (isset($fleetArray[Legacies_Empire::ID_SHIP_SPY_DRONE]) && $fleetArray[Legacies_Empire::ID_SHIP_SPY_DRONE] > 0 && !$YourPlanet) { + $missionTypes[Legacies_Empire::ID_MISSION_SPY] = $lang['type_mission'][Legacies_Empire::ID_MISSION_SPY]; + } + + if ((isset($fleetArray[Legacies_Empire::ID_SHIP_LIGHT_TRANSPORT]) && $fleetArray[Legacies_Empire::ID_SHIP_LIGHT_TRANSPORT] > 0) || + (isset($fleetArray[Legacies_Empire::ID_SHIP_LARGE_TRANSPORT]) && $fleetArray[Legacies_Empire::ID_SHIP_LARGE_TRANSPORT] > 0) || + (isset($fleetArray[Legacies_Empire::ID_SHIP_LIGHT_FIGHTER]) && $fleetArray[Legacies_Empire::ID_SHIP_LIGHT_FIGHTER] > 0) || + (isset($fleetArray[Legacies_Empire::ID_SHIP_HEAVY_FIGHTER]) && $fleetArray[Legacies_Empire::ID_SHIP_HEAVY_FIGHTER] > 0) || + (isset($fleetArray[Legacies_Empire::ID_SHIP_CRUISER]) && $fleetArray[Legacies_Empire::ID_SHIP_CRUISER] > 0) || + (isset($fleetArray[Legacies_Empire::ID_SHIP_BATTLESHIP]) && $fleetArray[Legacies_Empire::ID_SHIP_BATTLESHIP] > 0) || + (isset($fleetArray[Legacies_Empire::ID_SHIP_COLONY_SHIP]) && $fleetArray[Legacies_Empire::ID_SHIP_COLONY_SHIP] > 0) || + (isset($fleetArray[Legacies_Empire::ID_SHIP_RECYCLER]) && $fleetArray[Legacies_Empire::ID_SHIP_RECYCLER] > 0) || + (isset($fleetArray[Legacies_Empire::ID_SHIP_SPY_DRONE]) && $fleetArray[Legacies_Empire::ID_SHIP_SPY_DRONE] > 0 && Wootook::getGameConfig('engine/combat/allow_spy_drone_attacks')) || + (isset($fleetArray[Legacies_Empire::ID_SHIP_BOMBER]) && $fleetArray[Legacies_Empire::ID_SHIP_BOMBER] > 0) || + (isset($fleetArray[Legacies_Empire::ID_SHIP_DESTRUCTOR]) && $fleetArray[Legacies_Empire::ID_SHIP_DESTRUCTOR] > 0) || + (isset($fleetArray[Legacies_Empire::ID_SHIP_DEATH_STAR]) && $fleetArray[Legacies_Empire::ID_SHIP_DEATH_STAR] > 0) || + (isset($fleetArray[Legacies_Empire::ID_SHIP_BATTLECRUISER]) && $fleetArray[Legacies_Empire::ID_SHIP_BATTLECRUISER] > 0) || + (isset($fleetArray[Legacies_Empire::ID_SHIP_SUPERNOVA]) && $fleetArray[Legacies_Empire::ID_SHIP_SUPERNOVA] > 0)) { + + if (!$YourPlanet) { + $missionTypes[Legacies_Empire::ID_MISSION_ATTACK] = $lang['type_mission'][Legacies_Empire::ID_MISSION_ATTACK]; + $missionTypes[Legacies_Empire::ID_MISSION_GROUP_ATTACK] = $lang['type_mission'][Legacies_Empire::ID_MISSION_GROUP_ATTACK]; + $missionTypes[Legacies_Empire::ID_MISSION_STATION_ALLY] = $lang['type_mission'][Legacies_Empire::ID_MISSION_STATION_ALLY]; + } + $missionTypes[Legacies_Empire::ID_MISSION_TRANSPORT] = $lang['type_mission'][Legacies_Empire::ID_MISSION_TRANSPORT]; + } + + if ($YourPlanet) { + $missionTypes[Legacies_Empire::ID_MISSION_STATION] = $lang['type_mission'][Legacies_Empire::ID_MISSION_STATION]; + } + } +} + +if (isset($fleetArray[Legacies_Empire::ID_SHIP_SOLAR_SATELLITE])) { + $missionTypes = array(); +} + +if (!isset($missionTypes[$mission])) { + message($lang['fl_bad_mission'], $lang['fl_error'], "fleet." . PHPEXT, 2); +} + +if (!$destination->getId()) { + $destinationUser = $user; +} else { + $destinationUser = $destination->getUser(); +} + +$myGameLevel = $readAdapter->select() + ->column('total_points') + ->from(array('statpoints' => $readAdapter->getTable('statpoints'))) + ->where('stat_type', 1) + ->where('stat_code', 1) + ->where('id_owner', new Wootook_Core_Database_Sql_Placeholder_Param('player', $user->getId())) + ->prepare() + ->fetchColumn() +; +if ($destinationUser->getId()) { + $hisGameLevel = $readAdapter->select() + ->column('total_points') + ->from(array('statpoints' => $readAdapter->getTable('statpoints'))) + ->where('stat_type', 1) + ->where('stat_code', 1) + ->where('id_owner', new Wootook_Core_Database_Sql_Placeholder_Param('player', $destinationUser->getId())) + ->prepare() + ->fetchColumn() + ; +} else { + $hisGameLevel = 0; +} + +$vacationMode = $destinationUser->isVacation(); + +if ($protection) { + $protectedMissions = array( + Legacies_Empire::ID_MISSION_ATTACK, + Legacies_Empire::ID_MISSION_GROUP_ATTACK, + Legacies_Empire::ID_MISSION_STATION_ALLY, + Legacies_Empire::ID_MISSION_SPY, + Legacies_Empire::ID_MISSION_DESTROY + ); + if ($destinationUser->getId() && in_array($mission, $protectedMissions)) { + if ($myGameLevel > ($hisGameLevel * $protectionMultiplier) && $hisGameLevel < ($protectionPointsCap * 1000)) { + message($lang['fl_noob_mess_n'], $lang['fl_noob_title'], "fleet." . PHPEXT, 2); + } else if (($myGameLevel * $protectionMultiplier) < $hisGameLevel && $myGameLevel < ($protectionPointsCap * 1000)) { + message($lang['fl_noob_mess_n'], $lang['fl_noob_title'], "fleet." . PHPEXT, 2); + } + } +} + +if ($vacationMode && $mission != Legacies_Empire::ID_MISSION_RECYCLE) { + message($lang['fl_vacation_pla'], $lang['fl_vacation_ttl'], "fleet." . PHPEXT, 2); +} + +$currentFleets = $user->getFleets()->getSize(); + +if (($user->getElement(Legacies_Empire::ID_RESEARCH_COMPUTER_TECHNOLOGY) + 1) <= $currentFleets) { + message("Pas de slot disponible", "Erreur", "fleet." . PHPEXT, 1); +} + +$metal = isset($_POST['resource1']) ? intval($_POST['resource1']) : 0; +$cristal = isset($_POST['resource2']) ? intval($_POST['resource2']) : 0; +$deuterium = isset($_POST['resource3']) ? intval($_POST['resource3']) : 0; + +if ($metal + $cristal + $deuterium < 1 && $mission == Legacies_Empire::ID_MISSION_TRANSPORT) { + message("".$lang['fl_noenoughtgoods']."", $lang['type_mission'][3], "fleet." . PHPEXT, 1); +} +if ($mission != Legacies_Empire::ID_MISSION_EXPEDITION) { + $userMissions = array( + Legacies_Empire::ID_MISSION_ATTACK, + Legacies_Empire::ID_MISSION_GROUP_ATTACK, + Legacies_Empire::ID_MISSION_TRANSPORT, + Legacies_Empire::ID_MISSION_STATION, + Legacies_Empire::ID_MISSION_STATION_ALLY, + Legacies_Empire::ID_MISSION_SPY + ); + if (!$destination->getUserId() && in_array($mission, $userMissions)) { + message ($lang['fl_bad_planet01'], $lang['fl_error'], "fleet." . PHPEXT, 2); + } + if ($destination->getId() && $mission == Legacies_Empire::ID_MISSION_SETTLE_COLONY) { + message ($lang['fl_bad_planet02'], $lang['fl_error'], "fleet." . PHPEXT, 2); + } + if ($destination->getId() != $planet->getId() && $mission == Legacies_Empire::ID_MISSION_STATION) { + message ($lang['fl_dont_stay_here'], $lang['fl_error'], "fleet." . PHPEXT, 2); + } + if ($destination->getElement(Legacies_Empire::ID_BUILDING_ALLIANCE_DEPOT) < 1 && $destinationUser->getId() != $user->getId() && $mission == Legacies_Empire::ID_MISSION_STATION_ALLY) { + message ($lang['fl_no_allydeposit'], $lang['fl_error'], "fleet." . PHPEXT, 2); + } + if ($destinationUser->getId() == $user->getId() && ($mission == Legacies_Empire::ID_MISSION_ATTACK)) { + message ($lang['fl_no_self_attack'], $lang['fl_error'], "fleet." . PHPEXT, 2); + } + if ($destinationUser->getId() == $user->getId() && ($mission == Legacies_Empire::ID_MISSION_SPY)) { + message ($lang['fl_no_self_spy'], $lang['fl_error'], "fleet." . PHPEXT, 2); + } + if ($destinationUser->getId() != $user->getId() && $mission == Legacies_Empire::ID_MISSION_STATION) { + message ($lang['fl_only_stay_at_home'], $lang['fl_error'], "fleet." . PHPEXT, 2); + } +} + +$possibleSpeeds = array(10, 9, 8, 7, 6, 5, 4, 3, 2, 1); + +$AllFleetSpeed = GetFleetMaxSpeed($fleetArray, 0, $user); +$SpeedFactor = Wootook::getGameConfig('game/speed/general'); +$MaxFleetSpeed = min($AllFleetSpeed); + +if (!in_array($speed, $possibleSpeeds)) { + message ($lang['fl_cheat_speed'], $lang['fl_error'], "fleet." . PHPEXT, 2); +} + +$error = 0; +$errorlist = ""; +if ($galaxy > Wootook::getGameConfig('engine/universe/galaxies') || $galaxy < 1) { + $error++; + $errorlist .= $lang['fl_limit_galaxy']; +} +if ($system > Wootook::getGameConfig('engine/universe/systems') || $system < 1) { + $error++; + $errorlist .= $lang['fl_limit_system']; +} +if ($position > (Wootook::getGameConfig('engine/universe/positions') + 1) || $position < 1) { + $error++; + $errorlist .= $lang['fl_limit_planet']; +} + +if ($error > 0) { + message($errorlist, $lang['fl_error'], "fleet." . PHPEXT, 2); +} + +if (!isset($fleetArray)) { + message($lang['fl_no_fleetarray'], $lang['fl_error'], "fleet." . PHPEXT, 2); +} + +$distance = GetTargetDistance($planet->getGalaxy(), $galaxy, $planet->getSystem(), $system, $planet->getPosition(), $position); +$duration = GetMissionDuration($speed, $MaxFleetSpeed, $distance, $SpeedFactor); +$consumption = GetFleetConsumption($fleetArray, $SpeedFactor, $duration, $distance, $MaxFleetSpeed, $user); + +$startTime = time() + $duration; +if ($mission == Legacies_Empire::ID_MISSION_EXPEDITION && isset($_POST['expeditiontime']) && is_int($_POST['expeditiontime']) + && ($expeditionTime = intval($_POST['expeditiontime'])) >= 1 && $expeditionTime <= 10) { + $StayDuration = $expeditionTime * 3600; + $StayTime = $startTime + $expeditionTime * 3600; +} elseif ($mission == Legacies_Empire::ID_MISSION_STATION_ALLY || $mission == Legacies_Empire::ID_MISSION_ORE_MINING && is_int($_POST['holdingtime']) + && ($holdingTime = intval($_POST['holdingtime'])) >= 1 && $holdingTime <= 10) { + $StayDuration = $holdingTime * 3600; + $StayTime = $startTime + $holdingTime * 3600; +} else { + $StayDuration = 0; + $StayTime = 0; +} + +/* END Refactoring */ +$endTime = $StayDuration + (2 * $duration) + time(); +$FleetStorage = 0; +$FleetShipCount = array_sum($fleetArray); +$serializedFleetArray = ''; + +foreach ($fleetArray as $shipId => $count) { + $FleetStorage += $pricelist[$shipId]["capacity"] * $count; + $serializedFleetArray .= $shipId .",". $count .";"; + $planet->setElement($shipId, $planet->getElement($shipId) - $count); +} + +$StockMetal = $planet['metal']; +$StockCrystal = $planet['cristal']; +$StockDeuterium = $planet['deuterium'] - $consumption; + +$FleetStorage -= $consumption; +$StorageNeeded = 0; +if (!isset($_POST['resource1']) || intval($_POST['resource1']) < 1) { + $TransMetal = 0; +} else { + $TransMetal = intval($_POST['resource1']); + if (Math::comp($StockMetal, $TransMetal) < 0) { + $TransMetal = $StockMetal; + } + $StorageNeeded = Math::add($TransMetal, $StorageNeeded); +} +if (!isset($_POST['resource2']) || intval($_POST['resource2']) < 1) { + $TransCrystal = 0; +} else { + $TransCrystal = intval($_POST['resource2']); + if (Math::comp($StockCrystal, $TransCrystal) < 0) { + $TransCrystal = $StockCrystal; + } + $StorageNeeded = Math::add($TransCrystal, $StorageNeeded); +} +if (!isset($_POST['resource3']) || intval($_POST['resource3']) < 1) { + $TransDeuterium = 0; +} else { + $TransDeuterium = intval($_POST['resource3']); + if (Math::comp($StockDeuterium, $TransDeuterium) < 0) { + $TransDeuterium = $StockDeuterium; + } + $StorageNeeded = Math::add($TransDeuterium, $StorageNeeded); +} + +if ($StorageNeeded > $FleetStorage) { + message($lang['fl_nostoragespa'] . pretty_number($StorageNeeded - $FleetStorage), $lang['fl_error'], "fleet." . PHPEXT, 2); +} + +if ($destinationUser['authlevel'] > $user['authlevel']) { + $specialMissions = array( + Legacies_Empire::ID_MISSION_ATTACK, + Legacies_Empire::ID_MISSION_GROUP_ATTACK, + Legacies_Empire::ID_MISSION_SPY, + Legacies_Empire::ID_MISSION_DESTROY + ); + + if (in_array($mission, $specialMissions)) { + message($lang['fl_adm_attak'], $lang['fl_warning'], "fleet." . PHPEXT, 2); + } +} + +/* BEGIN Refactoring */ +try { + $writeAdapter->beginTransaction(); + + $mapper = $writeAdapter->getDataMapper(); + $dateMapper = $mapper->load('date-time'); + + $writeAdapter->insert() + ->into($writeAdapter->getTable('fleets')) + ->set('fleet_owner', $user->getId()) + ->set('fleet_mission', $mission) + ->set('fleet_amount', $FleetShipCount) + ->set('fleet_array', $serializedFleetArray) + ->set('fleet_start_time', $dateMapper->encode($startTime)) + ->set('fleet_start_galaxy', $planet->getGalaxy()) + ->set('fleet_start_system', $planet->getSystem()) + ->set('fleet_start_planet', $planet->getPosition()) + ->set('fleet_start_type', $planet->getType()) + ->set('fleet_end_time', $dateMapper->encode($endTime)) + ->set('fleet_end_stay', $dateMapper->encode($StayTime)) + ->set('fleet_end_galaxy', $galaxy) + ->set('fleet_end_system', $system) + ->set('fleet_end_planet', $position) + ->set('fleet_end_type', $type) + ->set('fleet_resource_metal', intval($TransMetal)) + ->set('fleet_resource_crystal', intval($TransCrystal)) // FIXME: refactor field name + ->set('fleet_resource_deuterium', intval($TransDeuterium)) + ->set('fleet_target_owner', $destination['id_owner']) + ->set('start_time', $dateMapper->encode(time())) + ->execute() + ; + + $planet["metal"] = $planet["metal"] - $TransMetal; + $planet["cristal"] = $planet["cristal"] - $TransCrystal; + $planet["deuterium"] = $planet["deuterium"] - $TransDeuterium - $consumption; + $planet->save(); + + $writeAdapter->commit(); +} catch (Exception $e) { + Wootook_Core_ErrorProfiler::getSingleton()->addException($e); + $writeAdapter->rollback(); + message($errorlist, $lang['fl_error'], "fleet." . PHPEXT, 2); +} +/* END Refactoring */ + +$page = "
    "; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; +$page .= ""; + +$helper = Wootook_Empire_Helper_Config_Labels::getSingleton(); +foreach ($fleetArray as $shipId => $shipCount) { + $page .= ""; + $page .= ""; + $page .= ""; +} +$page .= "
    ". $lang['fl_fleet_send'] ."
    ". $lang['fl_mission'] ."". $missionTypes[$mission] ."
    ". $lang['fl_dist'] ."". pretty_number($distance) ."
    ". $lang['fl_speed'] ."". pretty_number($_POST['speedallsmin']) ."
    ". $lang['fl_deute_need'] ."". pretty_number($consumption) ."
    ". $lang['fl_from'] ."". $planet->getCoords() ."
    ". $lang['fl_dest'] ."". $galaxy . ':' . $system . ':' . $position ."
    ". $lang['fl_time_go'] ."". date("M D d H:i:s", $startTime) ."
    ". $lang['fl_time_back'] ."". date("M D d H:i:s", $endTime) ."
    ". $lang['fl_title'] ."
    ". $helper[$shipId]['name'] ."". pretty_number($shipCount) ."
    "; + +display($page, $lang['fl_title']); diff --git a/flotenajax.php b/src/flotenajax.php similarity index 95% rename from flotenajax.php rename to src/flotenajax.php index c81fd1e..8101ab0 100644 --- a/flotenajax.php +++ b/src/flotenajax.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,13 +24,13 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); -require_once dirname(__FILE__) .'/common.php'; +require_once dirname(__FILE__) .'/application/bootstrap.php'; includeLang('galaxy'); includeLang('fleet'); @@ -70,9 +70,9 @@ require_once dirname(__FILE__) .'/common.php'; } } - $PrNoob = $gameConfig['noobprotection']; - $PrNoobTime = $gameConfig['noobprotectiontime']; - $PrNoobMulti = $gameConfig['noobprotectionmulti']; + $PrNoob = Wootook::getGameConfig('game/noob-protection/active'); + $PrNoobTime = Wootook::getGameConfig('game/noob-protection/points-cap'); + $PrNoobMulti = Wootook::getGameConfig('game/noob-protection/multiplier'); // Petit Test de coherance $galaxy = intval($_POST['galaxy']); diff --git a/src/galaxy.php b/src/galaxy.php new file mode 100644 index 0000000..b3f8cb5 --- /dev/null +++ b/src/galaxy.php @@ -0,0 +1,159 @@ + + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License + * along with this program. If not, see . + * + * --> 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. + * + */ + +define('INSIDE' , true); +define('INSTALL' , false); +require_once dirname(__FILE__) .'/application/bootstrap.php'; + +includeLang('galaxy'); + +$CurrentPlanet = doquery("SELECT * FROM {{table}} WHERE `id` = '". $user['current_planet'] ."';", 'planets', true); +$lunarow = doquery("SELECT * FROM {{table}} WHERE `id` = '". $user['current_luna'] ."';", 'lunas', true); +$galaxyrow = doquery("SELECT * FROM {{table}} WHERE `id_planet` = '". $CurrentPlanet['id'] ."';", 'galaxy', true); + +$dpath = (!$user["dpath"]) ? DEFAULT_SKINPATH : $user["dpath"]; +$fleetmax = $user['computer_tech'] + 1; +$CurrentPlID = $CurrentPlanet['id']; +$CurrentMIP = $CurrentPlanet['interplanetary_misil']; +$CurrentRC = $CurrentPlanet['recycler']; +$CurrentSP = $CurrentPlanet['spy_sonde']; +$HavePhalanx = $CurrentPlanet['phalanx']; +$CurrentSystem = $CurrentPlanet['system']; +$CurrentGalaxy = $CurrentPlanet['galaxy']; +$CanDestroy = $CurrentPlanet[$resource[213]] + $CurrentPlanet[$resource[214]]; + +$maxfleet = doquery("SELECT * FROM {{table}} WHERE `fleet_owner` = '". $user['id'] ."';", 'fleets'); +$maxfleet_count = $maxfleet->rowCount(); + +if (!isset($mode)) { + if (isset($_GET['mode'])) { + $mode = intval($_GET['mode']); + } else { + $mode = 0; + } +} + +$galaxy = 1; +$system = 1; +$planet = null; + +if ($mode == 0) { + $galaxy = $CurrentGalaxy; + $system = $CurrentSystem; +} elseif ($mode == 1 || $mode == 3) { + if (isset($_POST["galaxyLeft"])) { + if (!isset($_POST["galaxy"]) || $_POST["galaxy"] <= 1 || $_POST["galaxy"] > Wootook::getGameConfig('engine/universe/galaxies')) { + $galaxy = 1; + } else { + $galaxy = intval($_POST["galaxy"]) - 1; + } + } elseif (isset($_POST["galaxyRight"])) { + if (!isset($_POST["galaxy"]) || $_POST["galaxy"] >= Wootook::getGameConfig('engine/universe/galaxies')) { + $galaxy = Wootook::getGameConfig('engine/universe/galaxies'); + } else { + $galaxy = intval($_POST["galaxy"]) + 1; + } + } else if (!isset($_POST["galaxy"]) || $_POST["galaxy"] <= 1 || $_POST["galaxy"] > Wootook::getGameConfig('engine/universe/galaxies')) { + $galaxy = 1; + } else { + $galaxy = intval($_POST["galaxy"]); + } + + if (isset($_POST["systemLeft"])) { + if (!isset($_POST["system"]) || $_POST["system"] <= 1 || $_POST["system"] > Wootook::getGameConfig('engine/universe/systems')) { + $system = 1; + } else { + $system = intval($_POST["system"]) - 1; + } + } elseif (isset($_POST["systemRight"])) { + if (!isset($_POST["system"]) || $_POST["system"] >= Wootook::getGameConfig('engine/universe/systems')) { + $system = Wootook::getGameConfig('engine/universe/systems'); + } else { + $system = intval($_POST["system"]) + 1; + } + } else if (!isset($_POST["system"]) || $_POST["system"] <= 1 || $_POST["system"] > Wootook::getGameConfig('engine/universe/systems')) { + $system = 1; + } else { + $system = intval($_POST["system"]); + } +} elseif ($mode == 2) { + if (!isset($_POST["galaxy"]) || $_POST["galaxy"] <= 0) { + $galaxy = 1; + } else if ($_POST["galaxy"] >= Wootook::getGameConfig('engine/universe/galaxies')) { + $galaxy = Wootook::getGameConfig('engine/universe/galaxies'); + } else { + $galaxy = intval($_POST["galaxy"]) + 1; + } + + if (!isset($_POST["system"]) || $_POST["system"] <= 0) { + $system = 1; + } else if ($_POST["system"] >= Wootook::getGameConfig('engine/universe/systems')) { + $system = Wootook::getGameConfig('engine/universe/systems'); + } else { + $system = intval($_POST["system"]) + 1; + } + + if (!isset($_POST["planet"]) || $_POST["planet"] <= 0) { + $planet = 1; + } else if ($_POST["planet"] >= Wootook::getGameConfig('engine/universe/positions')) { + $planet = Wootook::getGameConfig('engine/universe/positions'); + } else { + $planet = intval($_POST["planet"]) + 1; + } +} + +$planetcount = 0; +$lunacount = 0; + +$page = InsertGalaxyScripts($CurrentPlanet); + +$page .= ShowGalaxySelector ( $galaxy, $system ); + +if ($mode == 2) { + $page .= ShowGalaxyMISelector($galaxy, $system, $planet, $CurrentPlanet['id'], $CurrentMIP); +} + +$page .= ""; + +$page .= ShowGalaxyTitles($galaxy, $system); +$page .= ShowGalaxyRows($galaxy, $system); +$page .= ShowGalaxyFooter($galaxy, $system, $CurrentMIP, $CurrentRC, $CurrentSP); + +$page .= "
    "; + +display($page, $lang, false, '', false); + +// ----------------------------------------------------------------------------------------------------------- +// History version +// 1.0 - Created by Perberos +// 1.1 - Modified by -MoF- (UGamela germany) +// 1.2 - 1er Nettoyage Chlorel ... +// 1.3 - 2eme Nettoyage Chlorel ... Mise en fonction et debuging complet +?> \ No newline at end of file diff --git a/imperium.php b/src/imperium.php similarity index 78% rename from imperium.php rename to src/imperium.php index d881e13..fb89688 100644 --- a/imperium.php +++ b/src/imperium.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,13 +24,13 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); -require_once dirname(__FILE__) .'/common.php'; +require_once dirname(__FILE__) .'/application/bootstrap.php'; includeLang('imperium'); @@ -45,7 +45,7 @@ foreach ($planet as $p) { /* * Update planet resources and constructions */ - Legacies::dispatchEvent('planet.update', array( + Wootook::dispatchEvent('planet.update', array( 'planet' => $p )); $p->save(); @@ -77,13 +77,13 @@ foreach ($planet as $p) { foreach ($resource as $i => $res) { if (in_array($i, $reslist['build'])) - $data['text'] = ($p[$resource[$i]] == 0) ? '-' : "{$p[$resource[$i]]}"; + $data['text'] = ($p[$resource[$i]] == 0) ? '-' : '' . $p[$resource[$i]] . ''; elseif (in_array($i, $reslist['tech'])) - $data['text'] = ($user[$resource[$i]] == 0) ? '-' : "{$user[$resource[$i]]}"; + $data['text'] = ($p[$resource[$i]] == 0) ? '-' : '' . $p[$resource[$i]] . ''; elseif (in_array($i, $reslist['fleet'])) - $data['text'] = ($p[$resource[$i]] == 0) ? '-' : "{$p[$resource[$i]]}"; + $data['text'] = ($p[$resource[$i]] == 0) ? '-' : '' . $p[$resource[$i]] . ''; elseif (in_array($i, $reslist['defense'])) - $data['text'] = ($p[$resource[$i]] == 0) ? '-' : "{$p[$resource[$i]]}"; + $data['text'] = ($p[$resource[$i]] == 0) ? '-' : '' . $p[$resource[$i]] . ''; $r[$i] .= parsetemplate($row2, $data); } diff --git a/includes/CombatEngine.php b/src/includes/CombatEngine.php similarity index 91% rename from includes/CombatEngine.php rename to src/includes/CombatEngine.php index 8b852d0..5331d80 100644 --- a/includes/CombatEngine.php +++ b/src/includes/CombatEngine.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,11 +24,11 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ -$CombatCaps = Legacies_Empire_Model_Game_Combat::getSingleton(); +$CombatCaps = Wootook_Empire_Helper_Config_Combat::getSingleton(); $AtFleet = array ( 203 => 2 ); $AtTechn = array ( 109 => 3, 110 => 5, 111 => 3 ); diff --git a/includes/aks.php b/src/includes/aks.php similarity index 99% rename from includes/aks.php rename to src/includes/aks.php index bf36caf..fc984b4 100644 --- a/includes/aks.php +++ b/src/includes/aks.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/includes/ataki.php b/src/includes/ataki.php similarity index 90% rename from includes/ataki.php rename to src/includes/ataki.php index 8e209ba..1494005 100644 --- a/includes/ataki.php +++ b/src/includes/ataki.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,12 +24,12 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ function walka ($CurrentSet, $TargetSet, $CurrentTechno, $TargetTechno) { - global $pricelist, $CombatCaps, $gameConfig; + global $pricelist, $CombatCaps; $runda = array(); $atakujacy_n = array(); $wrog_n = array(); @@ -72,11 +72,11 @@ function walka ($CurrentSet, $TargetSet, $CurrentTechno, $TargetTechno) { if (!is_null($CurrentSet)) { foreach($CurrentSet as $a => $b) { - $CurrentSet[$a]["obrona"] = $CurrentSet[$a]['count'] * ($pricelist[$a]['metal'] + $pricelist[$a]['crystal']) / 10 * (1 + (0.1 * ($CurrentTechno["defence_tech"]) + (0.05 * $user['rpg_amiral']))); + $CurrentSet[$a]["obrona"] = $CurrentSet[$a]['count'] * ($pricelist[$a]['metal'] + $pricelist[$a]['crystal']) / 10 * (1 + (0.1 * $CurrentTechno["defence_tech"])); $rand = rand(80, 120) / 100; - $CurrentSet[$a]["tarcza"] = $CurrentSet[$a]['count'] * $CombatCaps[$a]['shield'] * (1 + (0.1 * $CurrentTechno["shield_tech"]) + (0.05 * $user['rpg_amiral'])) * $rand; + $CurrentSet[$a]["tarcza"] = $CurrentSet[$a]['count'] * $CombatCaps[$a]['shield'] * (1 + (0.1 * $CurrentTechno["shield_tech"])) * $rand; $atak_statku = $CombatCaps[$a]['attack']; - $technologie = (1 + (0.1 * $CurrentTechno["military_tech"]+(0.05 * $user['rpg_amiral']))); + $technologie = (1 + (0.1 * $CurrentTechno["military_tech"])); $rand = rand(80, 120) / 100; $ilosc = $CurrentSet[$a]['count']; $CurrentSet[$a]["atak"] = $ilosc * $atak_statku * $technologie * $rand; @@ -91,11 +91,11 @@ function walka ($CurrentSet, $TargetSet, $CurrentTechno, $TargetTechno) { if (!is_null($TargetSet)) { foreach($TargetSet as $a => $b) { - $TargetSet[$a]["obrona"] = $TargetSet[$a]['count'] * ($pricelist[$a]['metal'] + $pricelist[$a]['crystal']) / 10 * (1 + (0.1 * ($TargetTechno["defence_tech"]) + (0.05 * $user['rpg_amiral']))); + $TargetSet[$a]["obrona"] = $TargetSet[$a]['count'] * ($pricelist[$a]['metal'] + $pricelist[$a]['crystal']) / 10 * (1 + (0.1 * $TargetTechno["defence_tech"])); $rand = rand(80, 120) / 100; - $TargetSet[$a]["tarcza"] = $TargetSet[$a]['count'] * $CombatCaps[$a]['shield'] * (1 + (0.1 * $TargetTechno["shield_tech"])+ (0.05 * $user['rpg_amiral'])) * $rand; + $TargetSet[$a]["tarcza"] = $TargetSet[$a]['count'] * $CombatCaps[$a]['shield'] * (1 + (0.1 * $TargetTechno["shield_tech"])) * $rand; $atak_statku = $CombatCaps[$a]['attack']; - $technologie = (1 + (0.1 * $TargetTechno["military_tech"]) + (0.05 * $user['rpg_amiral'])); + $technologie = (1 + (0.1 * $TargetTechno["military_tech"])); $rand = rand(80, 120) / 100; $ilosc = $TargetSet[$a]['count']; $TargetSet[$a]["atak"] = $ilosc * $atak_statku * $technologie * $rand; @@ -259,11 +259,11 @@ function walka ($CurrentSet, $TargetSet, $CurrentTechno, $TargetTechno) { $wygrana = "w"; } - $zlom['metal'] = ((($atakujacy_zlom_poczatek['metal'] - $atakujacy_zlom_koniec['metal']) + ($wrog_zlom_poczatek['metal'] - $wrog_zlom_koniec['metal'])) * ($gameConfig['Fleet_Cdr'] / 100)); - $zlom['crystal'] = ((($atakujacy_zlom_poczatek['crystal'] - $atakujacy_zlom_koniec['crystal']) + ($wrog_zlom_poczatek['crystal'] - $wrog_zlom_koniec['crystal'])) * ($gameConfig['Fleet_Cdr'] / 100)); + $zlom['metal'] = ((($atakujacy_zlom_poczatek['metal'] - $atakujacy_zlom_koniec['metal']) + ($wrog_zlom_poczatek['metal'] - $wrog_zlom_koniec['metal'])) * (Wootook::getGameConfig('game/debris/fleet') ? (Wootook::getGameConfig('game/debris/metal-percent') / 100) : 0)); + $zlom['crystal'] = ((($atakujacy_zlom_poczatek['crystal'] - $atakujacy_zlom_koniec['crystal']) + ($wrog_zlom_poczatek['crystal'] - $wrog_zlom_koniec['crystal'])) * (Wootook::getGameConfig('game/debris/fleet') ? (Wootook::getGameConfig('game/debris/cristal-percent') / 100) : 0)); - $zlom['metal'] += ((($atakujacy_zlom_poczatek['metal'] - $atakujacy_zlom_koniec['metal']) + ($wrog_zlom_poczatek['metal'] - $wrog_zlom_koniec['metal'])) * ($gameConfig['Defs_Cdr'] / 100)); - $zlom['crystal'] += ((($atakujacy_zlom_poczatek['crystal'] - $atakujacy_zlom_koniec['crystal']) + ($wrog_zlom_poczatek['crystal'] - $wrog_zlom_koniec['crystal'])) * ($gameConfig['Defs_Cdr'] / 100)); + $zlom['metal'] += ((($atakujacy_zlom_poczatek['metal'] - $atakujacy_zlom_koniec['metal']) + ($wrog_zlom_poczatek['metal'] - $wrog_zlom_koniec['metal'])) * (Wootook::getGameConfig('game/debris/defense') ? (Wootook::getGameConfig('game/debris/metal-percent') / 100) : 0)); + $zlom['crystal'] += ((($atakujacy_zlom_poczatek['crystal'] - $atakujacy_zlom_koniec['crystal']) + ($wrog_zlom_poczatek['crystal'] - $wrog_zlom_koniec['crystal'])) * (Wootook::getGameConfig('game/debris/defense') ? (Wootook::getGameConfig('game/debris/cristal-percent') / 100) : 0)); $zlom["atakujacy"] = (($atakujacy_zlom_poczatek['metal'] - $atakujacy_zlom_koniec['metal']) + ($atakujacy_zlom_poczatek['crystal'] - $atakujacy_zlom_koniec['crystal'])); $zlom["wrog"] = (($wrog_zlom_poczatek['metal'] - $wrog_zlom_koniec['metal']) + ($wrog_zlom_poczatek['crystal'] - $wrog_zlom_koniec['crystal']) + $straty_obrona_wrog); diff --git a/includes/constants.php b/src/includes/constants.php similarity index 77% rename from includes/constants.php rename to src/includes/constants.php index ca56d7b..62c5591 100644 --- a/includes/constants.php +++ b/src/includes/constants.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,24 +24,25 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ defined('E_USER_DEPRECATED') || define('E_USER_DEPRECATED', E_USER_WARNING); // Defined in PHP 5.3 core -define('ADMINEMAIL', "admin@xnova-ng.org"); -define('GAMEURL', "http://".$_SERVER['HTTP_HOST']."/"); - -// Definition du monde connu ! -define('MAX_GALAXY_IN_WORLD', 3); -define('MAX_SYSTEM_IN_GALAXY', 100); -define('MAX_PLANET_IN_SYSTEM', 50); +define('ADMINEMAIL', "no-reply@wootook.org"); +/** + * User level constants + * {{{ + */ define('LEVEL_ADMIN', 3); define('LEVEL_OPERATOR', 2); define('LEVEL_MODERATOR', 1); define('LEVEL_PLAYER', 0); +/** + * }}} + */ // Nombre de colones pour les rapports d'espionnage define('SPY_REPORT_ROW', 2); @@ -66,9 +67,6 @@ define('SHOW_ADMIN_IN_RECORDS', false); // Valeurs de bases pour les colonies ou planetes fraichement crées define('BASE_STORAGE_SIZE', 100000); -define('BUILD_METAL', 500); -define('BUILD_CRISTAL', 500); -define('BUILD_DEUTERIUM', 0); // Chemin vers le skin de base -define('DEFAULT_SKINPATH', 'skin/default/'); +define('DEFAULT_SKINPATH', 'skin/frontend/base/default/'); diff --git a/src/includes/deprecated.php b/src/includes/deprecated.php new file mode 100644 index 0000000..e8bee69 --- /dev/null +++ b/src/includes/deprecated.php @@ -0,0 +1,822 @@ + + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License + * along with this program. If not, see . + * + * --> 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. + * + */ + +/** + * Deprecated method used to add a building to the planet building list. + * + * @deprecated + * @param Wootook_Empire_Model_Planet|array $currentPlanet + * @param Wootook_Player_Model_Entity|array $currentUser + * @param int $buildingId + * @param bool $AddMode + */ +function AddBuildingToQueue($currentPlanet, $currentUser, $buildingId, $AddMode = true) +{ + defined('DEPRECATION') || Wootook_Core_ErrorProfiler::getSingleton()->addException(new Wootook_Core_Exception_Deprecated(sprintf('Function "%s" is deprecated', __FUNCTION__))); + + if (!$currentPlanet instanceof Wootook_Empire_Model_Planet) { + trigger_error('$currentPlanet should be an instance of Wootook_Empire_Model_Planet', E_USER_WARNING); + $currentPlanet = Wootook_Empire_Model_Planet::factory($currentPlanet['id']); + } + + $currentPlanet->appendBuildingQueue($buildingId, !$AddMode); + + return $currentPlanet->getBuildingQueue()->count(); +} + +/** + * Deprecaed function used to save the planet record + * + * @deprecated + * @param Wootook_Empire_Model_Planet|array $currentPlanet + */ +function BuildingSavePlanetRecord($currentPlanet) +{ + defined('DEPRECATION') || Wootook_Core_ErrorProfiler::getSingleton()->addException(new Wootook_Core_Exception_Deprecated(sprintf('Function "%s" is deprecated', __FUNCTION__))); + + if (!$currentPlanet instanceof Wootook_Empire_Model_Planet) { + trigger_error('$currentPlanet should be an instance of Wootook_Empire_Model_Planet', E_USER_WARNING); + $currentPlanet = Wootook_Empire_Model_Planet::factory($currentPlanet['id']); + } + + $currentPlanet->save(); +} + +/** + * Deprecaed function used to save the user record + * + * @deprecated + * @param Wootook_Player_Model_Entity|array $currentUser + */ +function BuildingSaveUserRecord($currentUser) +{ + defined('DEPRECATION') || Wootook_Core_ErrorProfiler::getSingleton()->addException(new Wootook_Core_Exception_Deprecated(sprintf('Function "%s" is deprecated', __FUNCTION__))); + + if (!$currentUser instanceof Wootook_Player_Model_Entity) { + trigger_error('$currentUser should be an instance of Wootook_Player_Model_Entity', E_USER_WARNING); + $currentUser = Wootook_Player_Model_Entity::factory($currentUser['id']); + } + + $currentUser->save(); +} + +/** + * @deprecated + * @param Wootook_Empire_Model_Planet|array $currentPlanet + * @param Wootook_Player_Model_Entity|array $currentUser + */ +function CheckPlanetBuildingQueue($currentPlanet, $currentUser) +{ + defined('DEPRECATION') || Wootook_Core_ErrorProfiler::getSingleton()->addException(new Wootook_Core_Exception_Deprecated(sprintf('Function "%s" is deprecated', __FUNCTION__))); + + if (!$currentPlanet instanceof Wootook_Empire_Model_Planet) { + trigger_error('$currentPlanet should be an instance of Wootook_Empire_Model_Planet', E_USER_WARNING); + $currentPlanet = Wootook_Empire_Model_Planet::factory($currentPlanet['id']); + } + + if (!$currentUser instanceof Wootook_Player_Model_Entity) { + trigger_error('$currentUser should be an instance of Wootook_Player_Model_Entity', E_USER_WARNING); + $currentUser = Wootook_Player_Model_Entity::factory($currentUser['id']); + } + + $currentPlanet->updateBuildingQueue(); +} + +/** + * + * @deprecated + * @param Wootook_Empire_Model_Planet|array $currentPlanet + */ +function CheckPlanetUsedFields($currentPlanet) +{ + defined('DEPRECATION') || Wootook_Core_ErrorProfiler::getSingleton()->addException(new Wootook_Core_Exception_Deprecated(sprintf('Function "%s" is deprecated', __FUNCTION__))); + + if (!$currentPlanet instanceof Wootook_Empire_Model_Planet) { + trigger_error('$currentPlanet should be an instance of Wootook_Empire_Model_Planet', E_USER_WARNING); + $currentPlanet = Wootook_Empire_Model_Planet::factory($currentPlanet['id']); + } + + $currentPlanet->updateStorages()->save(); +} + +/** + * + * @deprecated + * @param Wootook_Player_Model_Entity|array $currentUser + * @param Wootook_Empire_Model_Planet|array $currentPlanet + * @param int $buildingId + * @param bool $incremental + * @param bool $destroy + */ +function GetBuildingPrice($currentUser, $currentPlanet, $buildingId, $incremental = true, $destroy = false) +{ + defined('DEPRECATION') || Wootook_Core_ErrorProfiler::getSingleton()->addException(new Wootook_Core_Exception_Deprecated(sprintf('Function "%s" is deprecated', __FUNCTION__))); + + if (!$currentPlanet instanceof Wootook_Empire_Model_Planet) { + trigger_error('$currentPlanet should be an instance of Wootook_Empire_Model_Planet', E_USER_WARNING); + $currentPlanet = Wootook_Empire_Model_Planet::factory($currentPlanet['id']); + } + + if (!$currentUser instanceof Wootook_Player_Model_Entity) { + trigger_error('$currentUser should be an instance of Wootook_Player_Model_Entity', E_USER_WARNING); + $currentUser = Wootook_Player_Model_Entity::factory($currentUser['id']); + } + + $types = Wootook_Empire_Helper_Config_Types::getSingleton(); + + if ($types->is($buildingId, Legacies_Empire::TYPE_BUILDING)) { + $level = $currentPlanet->getElement($buildingId); + + if ($incremental) { + if (!$destroy) { + $level++; + } else { + $level--; + } + } + + $resources = $currentPlanet->getResourcesNeeded($buildingId, $level); + return array( + 'metal' => $resources[Legacies_Empire::RESOURCE_METAL], + 'crystal' => $resources[Legacies_Empire::RESOURCE_CRISTAL], + 'deuterium' => $resources[Legacies_Empire::RESOURCE_DEUTERIUM], + 'energy_max' => $resources[Legacies_Empire::RESOURCE_ENERGY] + ); + } else if ($types->is($buildingId, Legacies_Empire::TYPE_RESEARCH)) { + // TODO + } + + return array( + 'metal' => 0, + 'crystal' => 0, + 'deuterium' => 0, + 'energy_max' => 0 + ); +} + +/** + * + * @deprecated + * @param Wootook_Player_Model_Entity|array $currentUser + * @param Wootook_Empire_Model_Planet|array $currentPlanet + * @param int $buildingId + */ +function GetBuildingTime($currentUser, $currentPlanet, $buildingId) +{ + defined('DEPRECATION') || Wootook_Core_ErrorProfiler::getSingleton()->addException(new Wootook_Core_Exception_Deprecated(sprintf('Function "%s" is deprecated', __FUNCTION__))); + + if (!$currentPlanet instanceof Wootook_Empire_Model_Planet) { + trigger_error('$currentPlanet should be an instance of Wootook_Empire_Model_Planet', E_USER_WARNING); + $currentPlanet = Wootook_Empire_Model_Planet::factory($currentPlanet['id']); + } + + if (!$currentUser instanceof Wootook_Player_Model_Entity) { + trigger_error('$currentUser should be an instance of Wootook_Player_Model_Entity', E_USER_WARNING); + $currentUser = Wootook_Player_Model_Entity::factory($currentUser['id']); + } + + $types = Wootook_Empire_Helper_Config_Types::getSingleton(); + + if ($types->is($buildingId, Legacies_Empire::TYPE_BUILDING)) { + return $currentPlanet->getBuildingTime($buildingId, 1); + } else if ($types->is($buildingId, Legacies_Empire::TYPE_RESEARCH)) { + return $currentPlanet->getResearchLab()->getBuildingTime($buildingId, 1); + } else if ($types->is($buildingId, Legacies_Empire::TYPE_SHIP) || $types->is($buildingId, Legacies_Empire::TYPE_DEFENSE)) { + return $currentPlanet->getShipyard()->getBuildingTime($buildingId, 1); + } + + return 0; +} + +/** + * + * @deprecated + * @param Wootook_Player_Model_Entity|array $currentUser + * @param Wootook_Empire_Model_Planet|array $currentPlanet + * @param int $Element + * @param int|string $level + */ +function GetBuildingTimeLevel($currentUser, $currentPlanet, $buildingId, $level) +{ + defined('DEPRECATION') || Wootook_Core_ErrorProfiler::getSingleton()->addException(new Wootook_Core_Exception_Deprecated(sprintf('Function "%s" is deprecated', __FUNCTION__))); + + if (!$currentPlanet instanceof Wootook_Empire_Model_Planet) { + trigger_error('$currentPlanet should be an instance of Wootook_Empire_Model_Planet', E_USER_WARNING); + $currentPlanet = Wootook_Empire_Model_Planet::factory($currentPlanet['id']); + } + + if (!$currentUser instanceof Wootook_Player_Model_Entity) { + trigger_error('$currentUser should be an instance of Wootook_Player_Model_Entity', E_USER_WARNING); + $currentUser = Wootook_Player_Model_Entity::factory($currentUser['id']); + } + + $types = Wootook_Empire_Helper_Config_Types::getSingleton(); + + if ($types->is($buildingId, Legacies_Empire::TYPE_BUILDING)) { + return $currentPlanet->getBuildingTime($buildingId, $level); + } else if ($types->is($buildingId, Legacies_Empire::TYPE_RESEARCH)) { + return $currentPlanet->getLaboratory()->getBuildingTime($buildingId, $level); + } else if ($types->is($buildingId, Legacies_Empire::TYPE_SHIP) || $types->is($buildingId, Legacies_Empire::TYPE_DEFENSE)) { + return $currentPlanet->getShipyard()->getBuildingTime($buildingId, $level); + } + + return 0; +} + +/** + * + * @deprecated + * @param Wootook_Player_Model_Entity|array $currentUser + * @param Wootook_Empire_Model_Planet|array $currentPlanet + * @param int $buildingId + * @param unknown_type $userfactor + */ +function GetElementPrice($currentUser, $currentPlanet, $buildingId, $userfactor = true) +{ + defined('DEPRECATION') || Wootook_Core_ErrorProfiler::getSingleton()->addException(new Wootook_Core_Exception_Deprecated(sprintf('Function "%s" is deprecated', __FUNCTION__))); + + if (!$currentPlanet instanceof Wootook_Empire_Model_Planet) { + trigger_error('$currentPlanet should be an instance of Wootook_Empire_Model_Planet', E_USER_WARNING); + $currentPlanet = Wootook_Empire_Model_Planet::factory($currentPlanet['id']); + } + + if (!$currentUser instanceof Wootook_Player_Model_Entity) { + trigger_error('$currentUser should be an instance of Wootook_Player_Model_Entity', E_USER_WARNING); + $currentUser = Wootook_Player_Model_Entity::factory($currentUser['id']); + } + + global $lang; + + $prices = Wootook_Empire_Helper_Config_Prices::getSingleton(); + $types = Wootook_Empire_Helper_Config_Types::getSingleton(); + + $array = array( + Legacies_Empire::RESOURCE_METAL => $lang["Metal"], + Legacies_Empire::RESOURCE_CRISTAL => $lang["Crystal"], + Legacies_Empire::RESOURCE_DEUTERIUM => $lang["Deuterium"], + Legacies_Empire::RESOURCE_ENERGY => $lang["Energy"] + ); + + if ($types->is($buildingId, Legacies_Empire::TYPE_BUILDING)) { + $cost = $currentPlanet->getResourcesNeeded($buildingId, $currentPlanet->getElement($buildingId) + 1); + } else if ($types->is($buildingId, Legacies_Empire::TYPE_RESEARCH)) { + // TODO + } else if ($types->is($buildingId, Legacies_Empire::TYPE_SHIP) || $types->is($buildingId, Legacies_Empire::TYPE_DEFENSE)) { + $cost = $currentPlanet->getShipyard()->getResourcesNeeded($buildingId, 1); + } else { + return null; + } + + $output = $lang['Requires'] . ": "; + foreach ($array as $resourceId => $resourceLabel) { + if (Math::isPositive($prices[$buildingId][$resourceId])) { + $output .= $resourceLabel . ": "; + + if (Math::comp($cost[$resourceId], $currentPlanet->getData($resourceId)) > 0) { + $text .= ''; + $text .= '' . Math::render($cost[$resourceId]) . ''; + } else { + $text .= ' ' . Math::render($cost[$resourceId]) . ''; + } + } + } + return $text; +} + +/** + * + * @deprecated + * @param int $elementId + * @param int|string $count + */ +function GetElementRessources($elementId, $count) +{ + defined('DEPRECATION') || Wootook_Core_ErrorProfiler::getSingleton()->addException(new Wootook_Core_Exception_Deprecated(sprintf('Function "%s" is deprecated', __FUNCTION__))); + + $currentUser = Wootook_Player_Model_Session::getSingleton()->getPlayer(); + $currentPlanet = $currentUser->getCurrentPlanet(); + + return $currentPlanet->getShipyard()->getResourcesNeeded($buildingId, $count); +} + +/** + * + * @deprecated + * @param Wootook_Player_Model_Entity|array $currentUser + * @param Wootook_Empire_Model_Planet|array $currentPlanet + * @param int $productionTime + * + * @see Lagecies_Empire_Model_Planet::updateBuildingQueue() + */ +function HandleElementBuildingQueue($currentUser, $currentPlanet, $productionTime) +{ + defined('DEPRECATION') || Wootook_Core_ErrorProfiler::getSingleton()->addException(new Wootook_Core_Exception_Deprecated(sprintf('Function "%s" is deprecated', __FUNCTION__))); + + return array(); +} + +/** + * + * @deprecated + * @param bool $isUserChecked + * + * @see Wootook_Player_Model_Session::getSingleton()->getPlayer() + */ +function CheckCookies($isUserChecked) +{ + defined('DEPRECATION') || Wootook_Core_ErrorProfiler::getSingleton()->addException(new Wootook_Core_Exception_Deprecated(sprintf('Function "%s" is deprecated', __FUNCTION__))); + + $user = Wootook_Player_Model_Session::getSingleton()->getPlayer(); + + if ($user instanceof Wootook_Player_Model_Entity) { + return array( + 'state' => true, + 'record' => $user + ); + } else { + return array( + 'state' => false, + 'record' => array() + ); + } +} + +/** + * + * @deprecated + * @param bool $isUserChecked + * + * @see Wootook_Player_Model_Session::getSingleton()->getPlayer() + */ +function CheckTheUser($isUserChecked) +{ + defined('DEPRECATION') || Wootook_Core_ErrorProfiler::getSingleton()->addException(new Wootook_Core_Exception_Deprecated(sprintf('Function "%s" is deprecated', __FUNCTION__))); + + $result = CheckCookies($isUserChecked); + + if ($result['record'] instanceof Wootook_Player_Model_Entity && $result['record']['bana']) { + die(parsetemplate(gettemplate('usr_banned'), $lang)); + } + + return $result; +} + +/** + * + * @deprecated + * @param Wootook_Empire_Model_Planet|array $currentPlanet + * @param Wootook_Player_Model_Entity|array $currentUser + * + * @see Wootook_Empire_Model_Planet::updateBuildingQueue() + */ +function UpdatePlanetBatimentQueueList($currentPlanet, $currentUser) +{ + defined('DEPRECATION') || Wootook_Core_ErrorProfiler::getSingleton()->addException(new Wootook_Core_Exception_Deprecated(sprintf('Function "%s" is deprecated', __FUNCTION__))); + + if (!$currentPlanet instanceof Wootook_Empire_Model_Planet) { + trigger_error('$currentPlanet should be an instance of Wootook_Empire_Model_Planet', E_USER_WARNING); + $currentPlanet = Wootook_Empire_Model_Planet::factory($currentPlanet['id']); + } + + $currentPlanet->updateBuildingQueue(Beyond::now()); + + return true; +} + +/** + * + * @deprecated + * @param Wootook_Empire_Model_Planet|array $currentPlanet + */ +function CalculateMaxPlanetFields($currentPlanet) +{ + defined('DEPRECATION') || Wootook_Core_ErrorProfiler::getSingleton()->addException(new Wootook_Core_Exception_Deprecated(sprintf('Function "%s" is deprecated', __FUNCTION__))); + + if (!$currentPlanet instanceof Wootook_Empire_Model_Planet) { + trigger_error('$currentPlanet should be an instance of Wootook_Empire_Model_Planet', E_USER_WARNING); + $currentPlanet = Wootook_Empire_Model_Planet::factory($currentPlanet['id']); + } + + return max(1, $currentPlanet['field_max'] + ($currentPlanet->getElement(Legacies_Empire::ID_BUILDING_TERRAFORMER) * 5)); +} + + +/** + * + * @deprecated + * @param Wootook_Player_Model_Entity|array $currentUser + * @param Wootook_Empire_Model_Planet|array $currentPlanet + */ +function AbandonColony($currentUser, $currentPlanet) +{ + defined('DEPRECATION') || Wootook_Core_ErrorProfiler::getSingleton()->addException(new Wootook_Core_Exception_Deprecated(sprintf('Function "%s" is deprecated', __FUNCTION__))); + + if (!$currentPlanet instanceof Wootook_Empire_Model_Planet) { + trigger_error('$currentPlanet should be an instance of Wootook_Empire_Model_Planet', E_USER_WARNING); + $currentPlanet = Wootook_Empire_Model_Planet::factory($currentPlanet['id']); + } + + try { + $currentPlanet->destroy(); + } catch (Wootook_Core_Model_Exception $e) { + Wootook_Core_Model_Session::factory('empire')->addCritical($e->getMessage()); + } catch (Wootook_Empire_Model_Planet_Exception $e) { + Wootook_Core_Model_Session::factory('empire')->addError($e->getMessage()); + } +} + +/** + * + * @deprecated + * @param Wootook_Empire_Model_Planet|array $currentPlanet + */ +function CheckFleets($currentPlanet) +{ + defined('DEPRECATION') || Wootook_Core_ErrorProfiler::getSingleton()->addException(new Wootook_Core_Exception_Deprecated(sprintf('Function "%s" is deprecated', __FUNCTION__))); + + if (!$currentPlanet instanceof Wootook_Empire_Model_Planet) { + trigger_error('$currentPlanet should be an instance of Wootook_Empire_Model_Planet', E_USER_WARNING); + $currentPlanet = Wootook_Empire_Model_Planet::factory($currentPlanet['id']); + } + + return (bool) ($currentPlanet->getFleetCollection()->count() > 0); +} + +/** + * + * @deprecated + * @param Wootook_Player_Model_Entity|array $currentUser + * @param Wootook_Empire_Model_Planet|array $currentPlanet + */ +function CancelBuildingFromQueue($currentPlanet, $currentUser) +{ + defined('DEPRECATION') || Wootook_Core_ErrorProfiler::getSingleton()->addException(new Wootook_Core_Exception_Deprecated(sprintf('Function "%s" is deprecated', __FUNCTION__))); + + if (!$currentPlanet instanceof Wootook_Empire_Model_Planet) { + trigger_error('$currentPlanet should be an instance of Wootook_Empire_Model_Planet', E_USER_WARNING); + $currentPlanet = Wootook_Empire_Model_Planet::factory($currentPlanet['id']); + } + + if ($currentPlanet->getBuildingQueue()->count() <= 0) { + return false; + } + + $currentPlanet->dequeueBuilding(); + + return true; +} + +class Deprecated +{ + /** + * @var Wootook_Core_Model_Layout $layout + */ + public static $layout = null; + + /** + * @return Wootook_Core_Model_Layout + */ + public static function getLayout($adminPage = false) + { + if (self::$layout === null) { + self::$layout = new Wootook_Core_Model_Layout(); + } + + return self::$layout; + } +} + +/** + * + * @deprecated + * @param string $page The page content + * @param string $title The page title + * @param bool $topnav Wether we show the top navigation or not + * @param null $metatags Extra meta tags + * @param bool $adminPage unused + */ +function display($page, $title = '', $topnav = true, $metatags = '', $adminPage = false) +{ + defined('DEPRECATION') || Wootook_Core_ErrorProfiler::getSingleton()->addException(new Wootook_Core_Exception_Deprecated(sprintf('Function "%s" is deprecated', __FUNCTION__))); + + // TODO: implement extra meta tags + $layout = Deprecated::getLayout($adminPage); + if ($adminPage === false) { + $layout->load('deprecated'); + } else { + $layout->setDomain(Wootook_Core_Model_Layout::DOMAIN_BACKEND); + $layout->load('admin'); + } + + $content = $layout->getBlock('content'); + if (!$content instanceof Wootook_Core_Mvc_View_View) { + exit(0); + } + $pageContent = $layout->createBlock('core/text', 'content'); + $pageContent->setContent($page); + $content->page = $pageContent; + + echo $layout->render(); + exit(0); +} + +/** + * + * @deprecated + * @param string $template The page template + * @param array $array The view data + */ +function parsetemplate($template, $array) +{ + defined('DEPRECATION') || Wootook_Core_ErrorProfiler::getSingleton()->addException(new Wootook_Core_Exception_Deprecated(sprintf('Function "%s" is deprecated', __FUNCTION__))); + + static $baseUrl = null; + if ($baseUrl === null) { + $user = Wootook_Player_Model_Session::getSingleton()->getPlayer(); + if ($user !== null && $user->getId() && ($baseUrl = $user->getSkinPath()) == '') { + $baseUrl = DEFAULT_SKINPATH; + } + } + $array['dpath'] = $baseUrl; + + $layout = Deprecated::getLayout(); + $view = $layout->createBlock('core/deprecated', uniqid(), $array); + $view->setTemplate('deprecated/' .$template . '.tpl'); + + return $view->render(); +} + +/** + * + * @deprecated + * @param string $filename + * @return string + */ +function ReadFromFile($filename) +{ + defined('DEPRECATION') || Wootook_Core_ErrorProfiler::getSingleton()->addException(new Wootook_Core_Exception_Deprecated(sprintf('Function "%s" is deprecated', __FUNCTION__))); + + return file_get_contents($filename); +} + +/** + * + * @deprecated + * @param string $filename + * @param string $content + * @return void + */ +function saveToFile($filename, $content) +{ + defined('DEPRECATION') || Wootook_Core_ErrorProfiler::getSingleton()->addException(new Wootook_Core_Exception_Deprecated(sprintf('Function "%s" is deprecated', __FUNCTION__))); + + file_put_contents($filename, $content); +} + +/** + * + * @deprecated + * @param string $templateName + * @return string + */ +function getTemplate($templateName) +{ + defined('DEPRECATION') || Wootook_Core_ErrorProfiler::getSingleton()->addException(new Wootook_Core_Exception_Deprecated(sprintf('Function "%s" is deprecated', __FUNCTION__))); + + return $templateName; +} + + +/** + * + * Enter description here ... + * @deprecated + * @param string $query + * @param string $table + * @param bool $fetch + */ +function doquery($query, $table, $fetch = false) +{ + defined('DEPRECATION') || Wootook_Core_ErrorProfiler::getSingleton()->addException(new Wootook_Core_Exception_Deprecated(sprintf('Function "%s" is deprecated', __FUNCTION__))); + + /** + * @var Wootook_Core_Database_Adapter_Pdo_Mysql $database + */ + $database = Wootook_Core_Database_ConnectionManager::getSingleton()->getConnection(Wootook_Core_Database_ConnectionManager::DEFAULT_CONNECTION_NAME); + + $sql = str_replace("{{table}}", $database->getTable($table), $query); + + /** + * @var PDOStatement $statement + */ + try { + $statement = $database->prepare($sql); + + $statement->execute(array()); + } catch (PDOException $e) { + trigger_error($e->getMessage() . PHP_EOL . "

    " . PHP_EOL, E_USER_WARNING); + } + + if ($fetch) { + return $statement->fetch(PDO::FETCH_BOTH); + } else { + return $statement; + } +} + +/** + * + * @deprecated + * @param unknown_type $UserID + */ +function ResetThisFuckingCheater($userId) +{ + defined('DEPRECATION') || Wootook_Core_ErrorProfiler::getSingleton()->addException(new Wootook_Core_Exception_Deprecated(sprintf('Function "%s" is deprecated', __FUNCTION__))); + + $user = Wootook_Player_Model_Entity::factory($userId); + $username = $user->getData('username'); + $email = $user->getData('email'); + $password = $user->getData('password'); + $user->delete(); + + $user = Wootook_Player_Model_Entity::register($TheUser['username'], $TheUser['email'], 'password'); + $user->setData('password', $password); + $user->save(); + return; +} + +/** + * Routine Affichage d'un message avec saut vers une autre page si souhaité + * @deprecated + */ +function message($message, $title = 'Error', $dest = null, $time = '3', $color = 'orange') +{ + defined('DEPRECATION') || Wootook_Core_ErrorProfiler::getSingleton()->addException(new Wootook_Core_Exception_Deprecated(sprintf('Function "%s" is deprecated', __FUNCTION__))); + + $layout = Deprecated::getLayout(false); + $layout->load('message'); + + $messageBlock = $layout->getBlock('message'); + if (!$messageBlock instanceof Wootook_Core_Mvc_View_View) { + exit(0); + } + $messageBlock['title'] = $title; + $messageBlock['message'] = $message; + + echo $layout->render(); + exit(0); +} + +/** + * Routine Affichage d'un message administrateur avec saut vers une autre page si souhaité + * @deprecated + */ +function AdminMessage($message, $title = 'Error', $dest = null, $time = '3', $color = 'orange') +{ + defined('DEPRECATION') || Wootook_Core_ErrorProfiler::getSingleton()->addException(new Wootook_Core_Exception_Deprecated(sprintf('Function "%s" is deprecated', __FUNCTION__))); + + $layout = Deprecated::getLayout(false); + $layout->load('message'); + + $messageBlock = $layout->getBlock('message'); + if (!$messageBlock instanceof Wootook_Core_Mvc_View_View) { + exit(0); + } + $messageBlock['title'] = $title; + $messageBlock['message'] = $message; + + echo $layout->render(); + exit(0); +} + +/** + * + * @deprecated + * @param Wootook_Empire_Model_Planet $planet + */ +function flyingFleetListener($event) +{ + // defined('DEPRECATION') || Wootook_Core_ErrorProfiler::getSingleton()->addException(new Wootook_Core_Exception_Deprecated(sprintf('Function "%s" is deprecated', __FUNCTION__))); + + $planet = $event->getData('planet'); + + FlyingFleetHandler($planet); +} + +/** + * + * @deprecated + * @param Wootook_Empire_Model_Planet $planet + */ +function FlyingFleetHandler($planet) +{ + // defined('DEPRECATION') || Wootook_Core_ErrorProfiler::getSingleton()->addException(new Wootook_Core_Exception_Deprecated(sprintf('Function "%s" is deprecated', __FUNCTION__))); + + foreach ($planet->getFleetCollection()->load() as $fleet) { + try { + $fleet->getWriteConnection()->beginTransaction(); + + switch ($fleet["fleet_mission"]) { + case Legacies_Empire::ID_MISSION_ATTACK: + // Attaquer + MissionCaseAttack($fleet); + break; + + case Legacies_Empire::ID_MISSION_TRANSPORT: + // Transporter + MissionCaseTransport($fleet); + break; + + case Legacies_Empire::ID_MISSION_STATION: + // Stationner + MissionCaseStay($fleet); + break; + + case Legacies_Empire::ID_MISSION_STATION_ALLY: + // Stationner chez un Allié + MissionCaseStayAlly($fleet); + break; + + case Legacies_Empire::ID_MISSION_SPY: + // Flotte d'espionnage + MissionCaseSpy($fleet); + break; + + case Legacies_Empire::ID_MISSION_SETTLE_COLONY: + // Coloniser + MissionCaseColonisation($fleet); + break; + + case Legacies_Empire::ID_MISSION_RECYCLE: + // Recyclage + MissionCaseRecycling($fleet); + break; + + case Legacies_Empire::ID_MISSION_DESTROY: + // Detruire ??? dans le code ogame c'est 9 !! + MissionCaseDestruction($fleet); + break; + + case Legacies_Empire::ID_MISSION_EXPEDITION: + // Expeditions + MissionCaseExpedition($fleet); + break; + + case Legacies_Empire::ID_MISSION_ORE_MINING: + // Exploitation + MissionCaseExploit($fleet); + break; + + case Legacies_Empire::ID_MISSION_GROUP_ATTACK: // TODO: implement mission type + case Legacies_Empire::ID_MISSION_MISSILES: // TODO: implement mission type + default: + $fleet->delete(); + break; + } + + $fleet->getWriteConnection()->commit(); + } catch (Wootook_Core_Exception_Exception $e) { + $fleet->getWriteConnection()->rollback(); + Wootook_Core_ErrorProfiler::getSingleton()->addException($e); + } + } +} + +/** + * + * @deprecated + * @param unknown_type $String + */ +function CheckInputStrings($string) +{ + defined('DEPRECATION') || Wootook_Core_ErrorProfiler::getSingleton()->addException(new Wootook_Core_Exception_Deprecated(sprintf('Function "%s" is deprecated', __FUNCTION__))); + + return htmlspecialchars($string, ENT_QUOTES, 'UTF-8'); +} diff --git a/includes/functions.php b/src/includes/functions.php similarity index 54% rename from includes/functions.php rename to src/includes/functions.php index 294c61f..d242a3d 100644 --- a/includes/functions.php +++ b/src/includes/functions.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ @@ -35,17 +35,15 @@ function check_urlaubmodus ($user) { } function check_urlaubmodus_time () { - global $user, $gameConfig; - if ($gameConfig['urlaubs_modus_erz'] == 1) { - $begrenzung = 86400; //24x60x60= 24h - $urlaub_modus_time = $user['urlaubs_modus_time']; - $urlaub_modus_time_soll = $urlaub_modus_time + $begrenzung; - $time_jetzt = time(); - if ($user['urlaubs_modus'] == 1 && $urlaub_modus_time_soll > $time_jetzt) { - $soll_datum = date("d.m.Y", $urlaub_modus_time_soll); - $soll_uhrzeit = date("H:i:s", $urlaub_modus_time_soll); - message("Vous �tes en mode vacances!
    Le mode vacance dure jusque $soll_datum $soll_uhrzeit
    Ce n'est qu'apr�s cette p�riode que vous pouvez changer vos options.", "Mode vacance"); - } + global $user; + $begrenzung = 86400; //24x60x60= 24h + $urlaub_modus_time = $user['urlaubs_modus_time']; + $urlaub_modus_time_soll = $urlaub_modus_time + $begrenzung; + $time_jetzt = time(); + if ($user['urlaubs_modus'] == 1 && $urlaub_modus_time_soll > $time_jetzt) { + $soll_datum = date("d.m.Y", $urlaub_modus_time_soll); + $soll_uhrzeit = date("H:i:s", $urlaub_modus_time_soll); + message("Vous �tes en mode vacances!
    Le mode vacance dure jusque $soll_datum $soll_uhrzeit
    Ce n'est qu'apr�s cette p�riode que vous pouvez changer vos options.", "Mode vacance"); } } @@ -57,30 +55,3 @@ function is_email($email) { return(preg_match("/^[-_.[:alnum:]]+@((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i", $email)); } -// ---------------------------------------------------------------------------------------------------------------- -// -// Routine Affichage d'un message administrateur avec saut vers une autre page si souhait� -// -function AdminMessage ($mes, $title = 'Error', $dest = '', $time = '3', $color= 'red') { - $parse['color'] = $color; - $parse['title'] = $title; - $parse['mes'] = $mes; - - $page = parsetemplate(gettemplate('admin/message_body'), $parse); - - display ($page, $title, false, (($dest != "") ? "" : ""), true); -} - -// ---------------------------------------------------------------------------------------------------------------- -// -// Routine Affichage d'un message avec saut vers une autre page si souhait� -// -function message($mes, $title = 'Error', $dest = "", $time = "3", $color = 'orange') { - $parse['color'] = $color; - $parse['title'] = $title; - $parse['mes'] = $mes; - - $page = parsetemplate(gettemplate('admin/message_body'), $parse); - - display ($page, $title, false, (($dest != "") ? "" : ""), true); -} diff --git a/includes/functions/BBcodeFunction.php b/src/includes/functions/BBcodeFunction.php similarity index 95% rename from includes/functions/BBcodeFunction.php rename to src/includes/functions/BBcodeFunction.php index 2763900..2d33df9 100644 --- a/includes/functions/BBcodeFunction.php +++ b/src/includes/functions/BBcodeFunction.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/includes/functions/BuildFleetEventTable.php b/src/includes/functions/BuildFleetEventTable.php similarity index 96% rename from includes/functions/BuildFleetEventTable.php rename to src/includes/functions/BuildFleetEventTable.php index 9d633d1..2bd9cbe 100644 --- a/includes/functions/BuildFleetEventTable.php +++ b/src/includes/functions/BuildFleetEventTable.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/includes/functions/BuildFlyingFleetTable.php b/src/includes/functions/BuildFlyingFleetTable.php similarity index 91% rename from includes/functions/BuildFlyingFleetTable.php rename to src/includes/functions/BuildFlyingFleetTable.php index 5ce94a7..c207793 100644 --- a/includes/functions/BuildFlyingFleetTable.php +++ b/src/includes/functions/BuildFlyingFleetTable.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ @@ -37,7 +37,7 @@ function BuildFlyingFleetTable () { $TableTPL = gettemplate('admin/fleet_rows'); $FlyingFleets = doquery ("SELECT * FROM {{table}} ORDER BY `fleet_end_time` ASC;", 'fleets'); - while ( $CurrentFleet = mysql_fetch_assoc( $FlyingFleets ) ) { + while ( $CurrentFleet = $FlyingFleets->fetch(PDO::FETCH_ASSOC) ) { $FleetOwner = doquery("SELECT `username` FROM {{table}} WHERE `id` = '". $CurrentFleet['fleet_owner'] ."';", 'users', true); $TargetOwner = doquery("SELECT `username` FROM {{table}} WHERE `id` = '". $CurrentFleet['fleet_target_owner'] ."';", 'users', true); $Bloc['Id'] = $CurrentFleet['fleet_id']; diff --git a/includes/functions/GalaxyCheckFunctions.php b/src/includes/functions/GalaxyCheckFunctions.php similarity index 88% rename from includes/functions/GalaxyCheckFunctions.php rename to src/includes/functions/GalaxyCheckFunctions.php index d5c3d66..505fc8f 100644 --- a/includes/functions/GalaxyCheckFunctions.php +++ b/src/includes/functions/GalaxyCheckFunctions.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/includes/functions/GalaxyLegendPopup.php b/src/includes/functions/GalaxyLegendPopup.php similarity index 79% rename from includes/functions/GalaxyLegendPopup.php rename to src/includes/functions/GalaxyLegendPopup.php index a397aa5..d354a78 100644 --- a/includes/functions/GalaxyLegendPopup.php +++ b/src/includes/functions/GalaxyLegendPopup.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ @@ -35,7 +35,7 @@ function GalaxyLegendPopup () { global $lang; - $Result = "".$lang['inactif_28_shortcut'].""; $Result .= ""; - $Result .= "AdminA"; + $Result .= "AdminA"; + $Result .= ""; + $Result .= "OperatorO"; + $Result .= ""; + $Result .= "ModeratorM"; $Result .= ""; $Result .= ""; $Result .= "\");' onmouseout='return nd();'>"; diff --git a/includes/functions/GalaxyRowActions.php b/src/includes/functions/GalaxyRowActions.php similarity index 76% rename from includes/functions/GalaxyRowActions.php rename to src/includes/functions/GalaxyRowActions.php index 27490b3..8e4efde 100644 --- a/includes/functions/GalaxyRowActions.php +++ b/src/includes/functions/GalaxyRowActions.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ @@ -41,6 +41,11 @@ */ function GalaxyRowActions ( $GalaxyRow, $GalaxyRowPlanet, $GalaxyRowPlayer, $Galaxy, $System, $Planet, $PlanetType ) { global $lang, $user, $dpath, $CurrentMIP, $CurrentSystem, $CurrentGalaxy; + + if (empty($GalaxyRowPlanet)) { + return ''; + } + // Icones action $Result = ""; if ($GalaxyRowPlayer['id'] != $user['id']) { @@ -77,26 +82,26 @@ function GalaxyRowActions ( $GalaxyRow, $GalaxyRowPlanet, $GalaxyRowPlayer, $Gal if ($user["settings_esp"] == "1" && $GalaxyRowPlayer['id']) { $Result .= ""; - $Result .= "\"".$lang['gl_espionner']."\""; + $Result .= ''.$lang['gl_espionner'].''; $Result .= " "; } if ($user["settings_wri"] == "1" && $GalaxyRowPlayer['id']) { $Result .= ""; - $Result .= "\"".$lang['gl_sendmess']."\""; + $Result .= ''.$lang['gl_sendmess'].''; $Result .= " "; } if ($user["settings_bud"] == "1" && $GalaxyRowPlayer['id']) { $Result .= ""; - $Result .= "\"".$lang['gl_buddyreq']."\""; + $Result .= ''.$lang['gl_buddyreq'].''; $Result .= " "; } if ($user["settings_mis"] == "1" AND $MissileBtn == true && $GalaxyRowPlayer['id']) { $Result .= ""; - $Result .= "\"".$lang['gl_mipattack']."\""; + $Result .= ''.$lang['gl_mipattack'].''; } } } diff --git a/includes/functions/GalaxyRowAlly.php b/src/includes/functions/GalaxyRowAlly.php similarity index 72% rename from includes/functions/GalaxyRowAlly.php rename to src/includes/functions/GalaxyRowAlly.php index e9a17a6..46bc3fa 100644 --- a/includes/functions/GalaxyRowAlly.php +++ b/src/includes/functions/GalaxyRowAlly.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ @@ -42,6 +42,10 @@ function GalaxyRowAlly ( $GalaxyRow, $GalaxyRowPlanet, $GalaxyRowUser, $Galaxy, $System, $Planet, $PlanetType ) { global $lang, $user; + if (empty($GalaxyRowPlanet)) { + return ''; + } + // Alliances $Result = ""; if ($GalaxyRowUser['ally_id'] && $GalaxyRowUser['ally_id'] != 0) { @@ -59,17 +63,17 @@ function GalaxyRowAlly ( $GalaxyRow, $GalaxyRowPlanet, $GalaxyRowUser, $Galaxy, $Result .= " onmouseover='return overlib(\""; $Result .= ""; $Result .= ""; - $Result .= ""; + $Result .= ""; $Result .= ""; $Result .= "
    ".$lang['Alliance']." ". $allyquery['ally_name'] ." ".$lang['gl_with']." ". $members_count[0] ." ". $lang['gl_membre'] . $add ."".htmlspecialchars($lang['Alliance'], ENT_QUOTES, 'UTF-8')." ". htmlspecialchars($allyquery['ally_name'], ENT_QUOTES, 'UTF-8') ." ".$lang['gl_with']." ". $members_count[0] ." ". $lang['gl_membre'] . $add ."
    "; $Result .= ""; $Result .= ""; - $Result .= ""; + $Result .= ""; $Result .= ""; $Result .= ""; if ($allyquery["ally_web"] != "") { $Result .= ""; - $Result .= ""; + $Result .= ""; } $Result .= ""; $Result .= "
    ".$lang['gl_ally_internal']."".$lang['gl_ally_internal']."
    ".$lang['gl_stats']."
    ".$lang['gl_ally_web']."".$lang['gl_ally_web']."
    "; @@ -77,8 +81,8 @@ function GalaxyRowAlly ( $GalaxyRow, $GalaxyRowPlanet, $GalaxyRowUser, $Galaxy, $Result .= "
    \""; $Result .= ", STICKY, MOUSEOFF, DELAY, 750, CENTER, OFFSETX, -40, OFFSETY, -40 );'"; $Result .= " onmouseout='return nd();'>"; - if ($user['ally_id'] == $GalaxyRowPlayer['ally_id']) { - $Result .= "". $allyquery['ally_tag'] .""; + if ($user['ally_id'] == $GalaxyRowUser['ally_id']) { + $Result .= "". htmlspecialchars($allyquery['ally_tag'], ENT_QUOTES, 'UTF-8') .""; } else { $Result .= $allyquery['ally_tag'] .""; } diff --git a/includes/functions/GalaxyRowDebris.php b/src/includes/functions/GalaxyRowDebris.php similarity index 94% rename from includes/functions/GalaxyRowDebris.php rename to src/includes/functions/GalaxyRowDebris.php index b31b0d2..3c50a43 100644 --- a/includes/functions/GalaxyRowDebris.php +++ b/src/includes/functions/GalaxyRowDebris.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/includes/functions/GalaxyRowMoon.php b/src/includes/functions/GalaxyRowMoon.php similarity index 90% rename from includes/functions/GalaxyRowMoon.php rename to src/includes/functions/GalaxyRowMoon.php index 950b68d..79b6045 100644 --- a/includes/functions/GalaxyRowMoon.php +++ b/src/includes/functions/GalaxyRowMoon.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ @@ -39,9 +39,13 @@ * @param unknown_type $Planet * @param unknown_type $PlanetType */ -function GalaxyRowMoon ( $GalaxyRow, $GalaxyRowPlanet, $GalaxyRowUser, $Galaxy, $System, $Planet, $PlanetType ) { +function GalaxyRowMoon($GalaxyRow, $GalaxyRowPlanet, $GalaxyRowUser, $Galaxy, $System, $Planet, $PlanetType ) { global $lang, $user, $dpath, $HavePhalanx, $CurrentSystem, $CurrentGalaxy, $CanDestroy; + if (empty($GalaxyRowPlanet)) { + return ''; + } + // Lune $Result = ""; if ($GalaxyRowUser['id'] != $user['id']) { @@ -78,7 +82,7 @@ function GalaxyRowMoon ( $GalaxyRow, $GalaxyRowPlanet, $GalaxyRowUser, $Galaxy, $MissionType3Link = "". $lang['type_mission'][3] ."
    "; - if ($GalaxyRow && $GalaxyRowPlanet["destruyed"] == 0 && $GalaxyRow["id_luna"] != 0) { + if ($GalaxyRow && (!isset($GalaxyRowPlanet["destruyed"]) || $GalaxyRowPlanet["destruyed"] == 0) && $GalaxyRow["id_luna"] != 0) { $Result .= " + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ @@ -42,6 +42,9 @@ function GalaxyRowPlanet ( $GalaxyRow, $GalaxyRowPlanet, $GalaxyRowUser, $Galaxy, $System, $Planet, $PlanetType ) { global $lang, $dpath, $user, $HavePhalanx, $CurrentSystem, $CurrentGalaxy; + if (empty($GalaxyRowPlanet)) { + return ''; + } // Planete (Image) $Result = ""; @@ -106,7 +109,7 @@ function GalaxyRowPlanet ( $GalaxyRow, $GalaxyRowPlanet, $GalaxyRowUser, $Galaxy $Result .= ""; $Result .= ""; $Result .= ""; - $Result .= ""; + $Result .= ""; $Result .= ""; $Result .= ""; $Result .= $MissionType6Link; @@ -121,7 +124,7 @@ function GalaxyRowPlanet ( $GalaxyRow, $GalaxyRowPlanet, $GalaxyRowUser, $Galaxy // $Result .= ", STICKY, MOUSEOFF, DELAY, ". ($user["settings_tooltiptime"] * 1000) .", CENTER, OFFSETX, -40, OFFSETY, -40 );'"; $Result .= ", STICKY, MOUSEOFF, DELAY, 750, CENTER, OFFSETX, -40, OFFSETY, -40 );'"; $Result .= " onmouseout='return nd();'>"; - $Result .= ""; + $Result .= ""; // $Result .= $GalaxyRowPlanet["name"]; $Result .= ""; } @@ -130,4 +133,4 @@ function GalaxyRowPlanet ( $GalaxyRow, $GalaxyRowPlanet, $GalaxyRowUser, $Galaxy return $Result; } -?> \ No newline at end of file +?> diff --git a/includes/functions/GalaxyRowPlanetName.php b/src/includes/functions/GalaxyRowPlanetName.php similarity index 66% rename from includes/functions/GalaxyRowPlanetName.php rename to src/includes/functions/GalaxyRowPlanetName.php index 1db22f6..5a108ce 100644 --- a/includes/functions/GalaxyRowPlanetName.php +++ b/src/includes/functions/GalaxyRowPlanetName.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ @@ -42,6 +42,10 @@ function GalaxyRowPlanetName ( $GalaxyRow, $GalaxyRowPlanet, $GalaxyRowUser, $Galaxy, $System, $Planet, $PlanetType ) { global $lang, $user, $HavePhalanx, $CurrentSystem, $CurrentGalaxy; + if (empty($GalaxyRowPlanet)) { + return ''; + } + // Planete (Nom) $Result = ""; @@ -58,9 +62,14 @@ function GalaxyRowPlanetName ( $GalaxyRow, $GalaxyRowPlanet, $GalaxyRowUser, $Ga $EndColor = ""; } - if ($GalaxyRowPlanet['last_update'] > (time()-59 * 60) AND - $GalaxyRowUser['id'] != $user['id']) { - $Inactivity = pretty_time_hour(time() - $GalaxyRowPlanet['last_update']); + $updateTimeLimit = new Wootook_Core_DateTime(); + $updateTimeLimit->sub(3600); + if ($updateTimeLimit->isLater($GalaxyRowPlanet['last_update']) && $GalaxyRowUser['id'] != $user['id']) { + if ($GalaxyRowPlanet['last_update'] instanceof Wootook_Core_DateTime) { + $Inactivity = pretty_time_hour(time() - $GalaxyRowPlanet['last_update']->getTimestamp()); + } else { + $Inactivity = pretty_time_hour(0); + } } if ($GalaxyRow && $GalaxyRowPlanet["destruyed"] == 0) { if ($HavePhalanx <> 0) { @@ -81,22 +90,25 @@ function GalaxyRowPlanetName ( $GalaxyRow, $GalaxyRowPlanet, $GalaxyRowUser, $Ga $Result .= $TextColor . $PhalanxTypeLink . $EndColor; - if ($GalaxyRowPlanet['last_update'] > (time()-59 * 60) AND - $GalaxyRowUser['id'] != $user['id']) { - if ($GalaxyRowPlanet['last_update'] > (time()-10 * 60) AND - $GalaxyRowUser['id'] != $user['id']) { - $Result .= "(*)"; - } else { - $Result .= " (".$Inactivity.")"; - } - } - } elseif ($GalaxyRowPlanet["destruyed"] != 0) { - $Result .= $lang['gl_destroyedplanet']; - } + if ($GalaxyRowUser->getId() && $updateTimeLimit->isLater($GalaxyRowPlanet['last_update']) && + $GalaxyRowUser['id'] != $user['id']) { + + $updateTimeLimit = new Wootook_Core_DateTime(); + $updateTimeLimit->sub(600); + if ($GalaxyRowUser->getId() && $updateTimeLimit->isLater($GalaxyRowPlanet['last_update']) && + $GalaxyRowUser['id'] != $user['id']) { + $Result .= "(*)"; + } else { + $Result .= " (".$Inactivity.")"; + } + } + } elseif ($GalaxyRowPlanet["destruyed"] != 0) { + $Result .= $lang['gl_destroyedplanet']; + } $Result .= ""; return $Result; } -?> \ No newline at end of file +?> diff --git a/includes/functions/GalaxyRowPos.php b/src/includes/functions/GalaxyRowPos.php similarity index 85% rename from includes/functions/GalaxyRowPos.php rename to src/includes/functions/GalaxyRowPos.php index d111681..a432d8c 100644 --- a/includes/functions/GalaxyRowPos.php +++ b/src/includes/functions/GalaxyRowPos.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/src/includes/functions/GalaxyRowUser.php b/src/includes/functions/GalaxyRowUser.php new file mode 100644 index 0000000..6e4f460 --- /dev/null +++ b/src/includes/functions/GalaxyRowUser.php @@ -0,0 +1,136 @@ + + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License + * along with this program. If not, see . + * + * --> 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. + * + */ + +/** + * + * @deprecated + * @param Wootook_Empire_Model_Planet $currentPlanet + * @param Wootook_Player_Model_Entity $currentPlayer + */ +function GalaxyRowUser($currentPlanet, $currentPlayer) { + global $user; + + if (is_array($currentPlayer)) { + $currentPlayer = new Wootook_Player_Model_Entity($currentPlayer); + } + if (is_array($currentPlanet)) { + $currentPlanet = new Wootook_Empire_Model_Planet($currentPlanet); + $currentPlanet->setData('last_update', new Wootook_Core_DateTime($currentPlanet->getData('last_update'))); + } + if (!$currentPlayer || !$currentPlayer->getId() || !$currentPlanet || $currentPlanet->isDestroyed()) { + return ''; + } + + $activeNoobProtection = Wootook::getGameConfig('game/noob-protection/active'); + $noobProtectionMultiplier = Wootook::getGameConfig('game/noob-protection/multiplier'); + $noobProtectionPointsLimit = Wootook::getGameConfig('game/noob-protection/points-cap'); + + $readAdapter = Wootook_Core_Database_ConnectionManager::getSingleton()->getConnection('core_read'); + + $statement = $readAdapter->select() + ->column('total_points') + ->column('total_rank') + ->from(array('stats' => $readAdapter->getTable('statpoints'))) + ->where('id_owner', new Wootook_Core_Database_Sql_Placeholder_Variable('player_id')) + ->where('stat_code', 1) + ->where('stat_type', 1) + ->prepare() + ; + + $statement->execute(array('player_id' => $user->getId())); + $playerPoints = $statement->fetchColumn(0); + + $statement->execute(array('player_id' => $currentPlayer->getId())); + $currentPlayerPoints = $statement->fetchColumn(0); + $currentPlayerRank = $statement->fetchColumn(1); + + $classes = array(); + if ($currentPlayer->isBanned()) { + $classes['banned'] = 'B'; + } + if ($currentPlayer->isVacation()) { + $classes['vacation'] = 'V'; + } + $pastDate = new Wootook_Core_DateTime(); + $pastDate->sub(8, Wootook_Core_DateTime::DAY); + if ($pastDate->isLater($currentPlayer->getLastLoginDate())) { + $classes['inactive'] = 'i'; + } + + $pastDate->sub(22, Wootook_Core_DateTime::DAY); + if ($pastDate->isLater($currentPlayer->getLastLoginDate())) { + $classes['long-inactive'] = 'I'; + } + if ($currentPlayer->isAuthorized(LEVEL_ADMIN)) { + $classes['admin'] = 'A'; + } else if ($currentPlayer->isAuthorized(LEVEL_OPERATOR)) { + $classes['operator'] = 'O'; + } else if ($currentPlayer->isAuthorized(LEVEL_MODERATOR)) { + $classes['moderator'] = 'M'; + } + + if ($activeNoobProtection) { + if ($playerPoints <= $noobProtectionPointsLimit && ($playerPoints * $noobProtectionMultiplier) < $currentPlayerPoints) { + $classes['strong'] = 'F'; + } else if ($currentPlayerPoints <= $noobProtectionPointsLimit && ($currentPlayerPoints * $noobProtectionMultiplier) < $playerPoints) { + $classes['strong'] = 'F'; + } + } + + $output = ''; + if (count($classes) > 0) { + $output .= '' . $currentPlayer->getUsername() . ''; + foreach ($classes as $class => $identifier) { + $output .= '' . $identifier . ''; + } + } else { + $output .= '' . $currentPlayer->getUsername() . ''; + } + + if (true || $currentPlayer->getId() !== $user->getId()) { + $translator = Wootook::getTranslator(); + $messageUrl = Wootook::getStaticUrl('messages.php', array('mode' => 'write', 'id' => $currentPlayer->getId())); + $buddyUrl = Wootook::getStaticUrl('buddy.php', array('a' => '2', 'u' => $currentPlayer->getId())); + $statsUrl = Wootook::getStaticUrl('stat.php', array('who' => 'player', 'start' => 100 * floor($currentPlayerRank / 100))); + + $output .=<< +

    {$translator->translate('Player: %s', $currentPlayer->getUsername())}

    +

    {$translator->translate('Rank: %d', $currentPlayerRank)}

    +

    {$translator->translate('Send a message')}

    +

    {$translator->translate('Add to buddy list')}

    +

    {$translator->translate('Statistics')}

    + +HTML_EOF; + } + + $output .= ''; + return $output; +} diff --git a/includes/functions/GetMissileRange.php b/src/includes/functions/GetMissileRange.php similarity index 85% rename from includes/functions/GetMissileRange.php rename to src/includes/functions/GetMissileRange.php index 955d2b3..e9854e3 100644 --- a/includes/functions/GetMissileRange.php +++ b/src/includes/functions/GetMissileRange.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/includes/functions/GetPhalanxRange.php b/src/includes/functions/GetPhalanxRange.php similarity index 87% rename from includes/functions/GetPhalanxRange.php rename to src/includes/functions/GetPhalanxRange.php index 1fbd16c..b1cb6ed 100644 --- a/includes/functions/GetPhalanxRange.php +++ b/src/includes/functions/GetPhalanxRange.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/includes/functions/InsertGalaxyScripts.php b/src/includes/functions/InsertGalaxyScripts.php similarity index 96% rename from includes/functions/InsertGalaxyScripts.php rename to src/includes/functions/InsertGalaxyScripts.php index 48109a1..e3ccd02 100644 --- a/includes/functions/InsertGalaxyScripts.php +++ b/src/includes/functions/InsertGalaxyScripts.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/includes/functions/InsertJavaScriptChronoApplet.php b/src/includes/functions/InsertJavaScriptChronoApplet.php similarity index 93% rename from includes/functions/InsertJavaScriptChronoApplet.php rename to src/includes/functions/InsertJavaScriptChronoApplet.php index 72dd2a9..45dc5c3 100644 --- a/includes/functions/InsertJavaScriptChronoApplet.php +++ b/src/includes/functions/InsertJavaScriptChronoApplet.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/includes/functions/MessageForm.php b/src/includes/functions/MessageForm.php similarity index 90% rename from includes/functions/MessageForm.php rename to src/includes/functions/MessageForm.php index 7e81c88..cf7100c 100644 --- a/includes/functions/MessageForm.php +++ b/src/includes/functions/MessageForm.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/includes/functions/MipCombatEngine.php b/src/includes/functions/MipCombatEngine.php similarity index 94% rename from includes/functions/MipCombatEngine.php rename to src/includes/functions/MipCombatEngine.php index 0835f4f..88df5d6 100644 --- a/includes/functions/MipCombatEngine.php +++ b/src/includes/functions/MipCombatEngine.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/src/includes/functions/MissionCaseAttack.php b/src/includes/functions/MissionCaseAttack.php new file mode 100644 index 0000000..44e32d1 --- /dev/null +++ b/src/includes/functions/MissionCaseAttack.php @@ -0,0 +1,458 @@ + + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License + * along with this program. If not, see . + * + * --> 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. + * + */ + +/** + * @deprecated + * @param unknown_type $FleetRow + */ +function MissionCaseAttack($FleetRow) +{ + global $lang; + + $pricelist = Wootook_Empire_Helper_Config_Prices::getSingleton(); + $resource = Wootook_Empire_Helper_Config_FieldsAlias::getSingleton(); + $CombatCaps = Wootook_Empire_Helper_Config_Combat::getSingleton(); + + if ($FleetRow['fleet_mess'] == 0 && $FleetRow['fleet_start_time'] <= time()) { + +// refactored parts +// {{{ + $targetPlanet = Wootook_Empire_Model_Planet::factoryFromCoords(array( + 'galaxy' => $FleetRow['fleet_end_galaxy'], + 'system' => $FleetRow['fleet_end_system'], + 'planet' => $FleetRow['fleet_end_planet'], + 'type' => $FleetRow['fleet_end_type'] + )); + + /* + * Update planet resources and constructions + */ + Wootook::dispatchEvent('planet.update', array( + 'planet' => $targetPlanet + )); + $targetPlanet->save(); + + $TargetUser = $targetPlanet->getUser(); + $CurrentUser = Wootook_Player_Model_Entity::factory($FleetRow['fleet_owner']); + + $TargetUserID = $TargetUser->getId(); + $CurrentUserID = $CurrentUser->getId(); + + $TargetTechno = array( + 'military_tech' => $TargetUser->getData('military_tech'), + 'defence_tech' => $TargetUser->getData('defence_tech'), + 'shield_tech' => $TargetUser->getData('shield_tech') + ); + + $CurrentTechno = array( + 'military_tech' => $CurrentUser->getData('military_tech'), + 'defence_tech' => $CurrentUser->getData('defence_tech'), + 'shield_tech' => $CurrentUser->getData('shield_tech') + ); +// }}} + for ($SetItem = 200; $SetItem < 500; $SetItem++) { + if ($targetPlanet[$resource[$SetItem]] > 0) { + $TargetSet[$SetItem]['count'] = $targetPlanet[$resource[$SetItem]]; + } + } + + $TheFleet = explode(";", $FleetRow['fleet_array']); + foreach($TheFleet as $a => $b) { + if ($b != '') { + $a = explode(",", $b); + $CurrentSet[$a[0]]['count'] = $a[1]; + } + } + + include_once($xnova_root_path . 'includes/ataki.' . PHPEXT); + // Calcul de la duree de traitement (initialisation) + $mtime = microtime(); + $mtime = explode(" ", $mtime); + $mtime = $mtime[1] + $mtime[0]; + $starttime = $mtime; + + $walka = walka($CurrentSet, $TargetSet, $CurrentTechno, $TargetTechno); + // Calcul de la duree de traitement (calcul) + $mtime = microtime(); + $mtime = explode(" ", $mtime); + $mtime = $mtime[1] + $mtime[0]; + $endtime = $mtime; + $totaltime = ($endtime - $starttime); + // Ce qu'il reste de l'attaquant + $CurrentSet = $walka["atakujacy"]; + // Ce qu'il reste de l'attaqué + $TargetSet = $walka["wrog"]; + // Le resultat de la bataille + $FleetResult = $walka["wygrana"]; + // Rapport long (rapport de bataille detaillé) + $dane_do_rw = $walka["dane_do_rw"]; + // Rapport court (cdr + unitées perdues) + $zlom = $walka["zlom"]; + + $FleetArray = ""; + $FleetAmount = 0; + $FleetStorage = 0; + foreach ($CurrentSet as $Ship => $Count) { + $FleetStorage += $pricelist[$Ship]["capacity"] * $Count['count']; + $FleetArray .= $Ship . "," . $Count['count'] . ";"; + $FleetAmount += $Count['count']; + } + // Au cas ou le p'tit rigolo qu'a envoyé la flotte y avait mis des ressources ... + $FleetStorage -= $FleetRow["fleet_resource_metal"]; + $FleetStorage -= $FleetRow["fleet_resource_crystal"]; + $FleetStorage -= $FleetRow["fleet_resource_deuterium"]; + + $targetPlanetUpd = ""; + if (!is_null($TargetSet)) { + foreach($TargetSet as $Ship => $Count) { + $targetPlanetUpd .= "`" . $resource[$Ship] . "` = '" . $Count['count'] . "', "; + } + } + // Determination des ressources pillées + $Mining['metal'] = 0; + $Mining['crystal'] = 0; + $Mining['deuter'] = 0; + if ($FleetResult == "a") { + if ($FleetStorage > 0) { + $metal = $targetPlanet['metal'] / 2; + $crystal = $targetPlanet['crystal'] / 2; + $deuter = $targetPlanet["deuterium"] / 2; + if (($metal) > $FleetStorage / 3) { + $Mining['metal'] = $FleetStorage / 3; + $FleetStorage = $FleetStorage - $Mining['metal']; + } else { + $Mining['metal'] = $metal; + $FleetStorage = $FleetStorage - $Mining['metal']; + } + + if (($crystal) > $FleetStorage / 2) { + $Mining['crystal'] = $FleetStorage / 2; + $FleetStorage = $FleetStorage - $Mining['crystal']; + } else { + $Mining['crystal'] = $crystal; + $FleetStorage = $FleetStorage - $Mining['crystal']; + } + + if (($deuter) > $FleetStorage) { + $Mining['deuter'] = $FleetStorage; + $FleetStorage = $FleetStorage - $Mining['deuter']; + } else { + $Mining['deuter'] = $deuter; + $FleetStorage = $FleetStorage - $Mining['deuter']; + } + } + } + $Mining['metal'] = round($Mining['metal']); + $Mining['crystal'] = round($Mining['crystal']); + $Mining['deuter'] = round($Mining['deuter']); + // Mise a jour de l'enregistrement de la planete attaquée + $QryUpdateTarget = "UPDATE {{table}} SET "; + $QryUpdateTarget .= $targetPlanetUpd; + $QryUpdateTarget .= "`metal` = `metal` - '" . $Mining['metal'] . "', "; + $QryUpdateTarget .= "`crystal` = `crystal` - '" . $Mining['crystal'] . "', "; + $QryUpdateTarget .= "`deuterium` = `deuterium` - '" . $Mining['deuter'] . "' "; + $QryUpdateTarget .= "WHERE "; + $QryUpdateTarget .= "`galaxy` = '" . $FleetRow['fleet_end_galaxy'] . "' AND "; + $QryUpdateTarget .= "`system` = '" . $FleetRow['fleet_end_system'] . "' AND "; + $QryUpdateTarget .= "`planet` = '" . $FleetRow['fleet_end_planet'] . "' AND "; + $QryUpdateTarget .= "`planet_type` = '" . $FleetRow['fleet_end_type'] . "' "; + $QryUpdateTarget .= "LIMIT 1;"; + doquery($QryUpdateTarget , 'planets'); + // Mise a jour du champ de ruine devant la planete attaquée + $QryUpdateGalaxy = "UPDATE {{table}} SET "; + $QryUpdateGalaxy .= "`metal` = `metal` + '" . $zlom['metal'] . "', "; + $QryUpdateGalaxy .= "`crystal` = `crystal` + '" . $zlom['crystal'] . "' "; + $QryUpdateGalaxy .= "WHERE "; + $QryUpdateGalaxy .= "`galaxy` = '" . $FleetRow['fleet_end_galaxy'] . "' AND "; + $QryUpdateGalaxy .= "`system` = '" . $FleetRow['fleet_end_system'] . "' AND "; + $QryUpdateGalaxy .= "`planet` = '" . $FleetRow['fleet_end_planet'] . "' "; + $QryUpdateGalaxy .= "LIMIT 1;"; + doquery($QryUpdateGalaxy , 'galaxy'); + // Là on va discuter le bout de gras pour voir s'il y a moyen d'avoir une Lune ! + $FleetDebris = $zlom['metal'] + $zlom['crystal']; + $StrAttackerUnits = sprintf ($lang['sys_attacker_lostunits'], pretty_number ($zlom["atakujacy"])); + $StrDefenderUnits = sprintf ($lang['sys_defender_lostunits'], pretty_number ($zlom["wrog"])); + $StrRuins = sprintf ($lang['sys_gcdrunits'], pretty_number ($zlom["metal"]), $lang['Metal'], pretty_number ($zlom['crystal']), $lang['Crystal']); + $DebrisField = $StrAttackerUnits . "
    " . $StrDefenderUnits . "
    " . $StrRuins; + $MoonChance = $FleetDebris / 100000; + if ($FleetDebris > 2000000) { + $MoonChance = 20; + } + if ($FleetDebris < 100000) { + $UserChance = 0; + $ChanceMoon = ""; + } elseif ($FleetDebris >= 100000) { + $UserChance = mt_rand(1, 100); + $ChanceMoon = sprintf ($lang['sys_moonproba'], $MoonChance); + } + + if (($UserChance > 0) and ($UserChance <= $MoonChance) and $galenemyrow['id_luna'] == 0) { + $user = Wootook_Player_Model_Entity::factory($TargetUserID); + $user->createNewPlanet( + intval($FleetRow['fleet_end_galaxy']), + intval($FleetRow['fleet_end_system']), + intval($FleetRow['fleet_end_planet']), + Wootook_Empire_Model_Planet::TYPE_MOON, + Wootook::__('Moon') + ); + $GottenMoon = Wootook::_('A moon has been created!'); + } elseif ($UserChance = 0 or $UserChance > $MoonChance) { + $GottenMoon = ""; + } + + $AttackDate = date("r", $FleetRow["fleet_start_time"]); + $title = sprintf ($lang['sys_attack_title'], $AttackDate); + $raport = "
    " . $title . "
    "; + $zniszczony = false; + $a_zestrzelona = 0; + $AttackTechon['A'] = $CurrentTechno["military_tech"] * 10; + $AttackTechon['B'] = $CurrentTechno["defence_tech"] * 10; + $AttackTechon['C'] = $CurrentTechno["shield_tech"] * 10; + $AttackerData = sprintf ($lang['sys_attack_attacker_pos'], $CurrentUser["username"], $FleetRow['fleet_start_galaxy'], $FleetRow['fleet_start_system'], $FleetRow['fleet_start_planet']); + $AttackerTech = sprintf ($lang['sys_attack_techologies'], $AttackTechon['A'], $AttackTechon['B'], $AttackTechon['C']); + + $DefendTechon['A'] = $TargetTechno["military_tech"] * 10; + $DefendTechon['B'] = $TargetTechno["defence_tech"] * 10; + $DefendTechon['C'] = $TargetTechno["shield_tech"] * 10; + $DefenderData = sprintf ($lang['sys_attack_defender_pos'], $TargetUser["username"], $FleetRow['fleet_end_galaxy'], $FleetRow['fleet_end_system'], $FleetRow['fleet_end_planet']); + $DefenderTech = sprintf ($lang['sys_attack_techologies'], $DefendTechon['A'], $DefendTechon['B'], $DefendTechon['C']); + + foreach ($dane_do_rw as $a => $b) { + $raport .= "

    " . $AttackerData . "
    " . $AttackerTech . ""; + if ($b["atakujacy"]['count'] > 0) { + $raport1 = ""; + $raport2 = ""; + $raport3 = ""; + $raport4 = ""; + $raport5 = ""; + foreach ($b["atakujacy"] as $Ship => $Data) { + if (is_numeric($Ship)) { + if ($Data['count'] > 0) { + $raport1 .= ""; + $raport2 .= ""; + $raport3 .= ""; + $raport4 .= ""; + $raport5 .= ""; + } + } + } + $raport1 .= ""; + $raport2 .= ""; + $raport3 .= ""; + $raport4 .= ""; + $raport5 .= ""; + $raport .= $raport1 . $raport2 . $raport3 . $raport4 . $raport5; + } else { + if ($a == 2) { + $a_zestrzelona = 1; + } + $zniszczony = true; + $raport .= "
    " . $lang['sys_destroyed']; + } + + $raport .= "
    " . $lang['sys_ship_type'] . "
    " . $lang['sys_ship_count'] . "
    " . $lang['sys_ship_weapon'] . "
    " . $lang['sys_ship_shield'] . "
    " . $lang['sys_ship_armour'] . "" . $lang["tech_rc"][$Ship] . "" . pretty_number ($Data['count']) . "" . pretty_number (round($Data["atak"] / $Data['count'])) . "" . pretty_number (round($Data["tarcza"] / $Data['count'])) . "" . pretty_number (round($Data["obrona"] / $Data['count'])) . "
    "; + $raport .= "

    " . $DefenderData . "
    " . $DefenderTech . ""; + if ($b["wrog"]['count'] > 0) { + $raport1 = ""; + $raport2 = ""; + $raport3 = ""; + $raport4 = ""; + $raport5 = ""; + foreach ($b["wrog"] as $Ship => $Data) { + if (is_numeric($Ship)) { + if ($Data['count'] > 0) { + $raport1 .= ""; + $raport2 .= ""; + $raport3 .= ""; + $raport4 .= ""; + $raport5 .= ""; + } + } + } + $raport1 .= ""; + $raport2 .= ""; + $raport3 .= ""; + $raport4 .= ""; + $raport5 .= ""; + $raport .= $raport1 . $raport2 . $raport3 . $raport4 . $raport5; + } else { + $zniszczony = true; + $raport .= "
    " . $lang['sys_destroyed']; + } + $raport .= "
    " . $lang['sys_ship_type'] . "
    " . $lang['sys_ship_count'] . "
    " . $lang['sys_ship_weapon'] . "
    " . $lang['sys_ship_shield'] . "
    " . $lang['sys_ship_armour'] . "" . $lang["tech_rc"][$Ship] . "" . pretty_number ($Data['count']) . "" . pretty_number (round($Data["atak"] / $Data['count'])) . "" . pretty_number (round($Data["tarcza"] / $Data['count'])) . "" . pretty_number (round($Data["obrona"] / $Data['count'])) . "
    "; + + if (($zniszczony == false) and !($a == 8)) { + $AttackWaveStat = sprintf ($lang['sys_attack_attack_wave'], pretty_number (floor($b["atakujacy"]["atak"])), pretty_number (floor($b["wrog"]["tarcza"]))); + $DefendWavaStat = sprintf ($lang['sys_attack_defend_wave'], pretty_number (floor($b["wrog"]["atak"])), pretty_number (floor($b["atakujacy"]["tarcza"]))); + $raport .= "
    " . $AttackWaveStat . "
    " . $DefendWavaStat . "
    "; + } + } + switch ($FleetResult) { + case "a": + $Pillage = sprintf ($lang['sys_stealed_ressources'], pretty_number ($Mining['metal']), $lang['metal'], pretty_number ($Mining['crystal']), $lang['crystal'], pretty_number ($Mining['deuter']), $lang['Deuterium']); + $raport .= $lang['sys_attacker_won'] . "
    " . $Pillage . "
    "; + $raport .= $DebrisField . "
    "; + $raport .= $ChanceMoon . "
    "; + $raport .= $GottenMoon . "
    "; + break; + case "r": + $raport .= $lang['sys_both_won'] . "
    "; + $raport .= $DebrisField . "
    "; + $raport .= $ChanceMoon . "
    "; + $raport .= $GottenMoon . "
    "; + break; + case "w": + $raport .= $lang['sys_defender_won'] . "
    "; + $raport .= $DebrisField . "
    "; + $raport .= $ChanceMoon . "
    "; + $raport .= $GottenMoon . "
    "; + doquery("DELETE FROM {{table}} WHERE `fleet_id` = '" . $FleetRow["fleet_id"] . "';", 'fleets'); + break; + default: + break; + } + $SimMessage = sprintf ($lang['sys_rapport_build_time'], $totaltime); + $raport .= $SimMessage . "
    "; + + $rid = md5($raport); + $QryInsertRapport = "INSERT INTO {{table}} SET "; + $QryInsertRapport .= "`time` = UNIX_TIMESTAMP(), "; + $QryInsertRapport .= "`id_owner1` = '" . $FleetRow['fleet_owner'] . "', "; + $QryInsertRapport .= "`id_owner2` = '" . $TargetUserID . "', "; + $QryInsertRapport .= "`rid` = '" . $rid . "', "; + $QryInsertRapport .= "`a_zestrzelona` = '" . $a_zestrzelona . "', "; + $QryInsertRapport .= "`raport` = '" . addslashes ($raport) . "';"; + doquery($QryInsertRapport , 'rw'); + // Colorisation du résumé de rapport pour l'attaquant + $raport = ""; + $raport .= "
    "; + if ($FleetResult == "a") { + $raport .= ""; + } elseif ($FleetResult == "r") { + $raport .= ""; + } elseif ($FleetResult == "w") { + $raport .= ""; + } + $raport .= $lang['sys_mess_attack_report'] . " [" . $FleetRow['fleet_end_galaxy'] . ":" . $FleetRow['fleet_end_system'] . ":" . $FleetRow['fleet_end_planet'] . "]

    "; + $raport .= "" . $lang['sys_perte_attaquant'] . ": " . pretty_number ($zlom["atakujacy"]) . ""; + $raport .= " " . $lang['sys_perte_defenseur'] . ":" . pretty_number ($zlom["wrog"]) . "
    " ; + $raport .= $lang['sys_gain'] . " " . $lang['Metal'] . ":" . pretty_number ($Mining['metal']) . " " . $lang['Crystal'] . ":" . pretty_number ($Mining['crystal']) . " " . $lang['Deuterium'] . ":" . pretty_number ($Mining['deuter']) . "
    "; + $raport .= $lang['sys_debris'] . " " . $lang['Metal'] . ":" . pretty_number ($zlom['metal']) . " " . $lang['Crystal'] . ":" . pretty_number ($zlom['crystal']) . "
    "; + + $Mining['metal'] = $Mining['metal'] + $FleetRow["fleet_resource_metal"]; + $Mining['crystal'] = $Mining['crystal'] + $FleetRow["fleet_resource_crystal"]; + $Mining['deuter'] = $Mining['deuter'] + $FleetRow["fleet_resource_deuterium"]; + + $QryUpdateFleet = "UPDATE {{table}} SET "; + $QryUpdateFleet .= "`fleet_amount` = '" . $FleetAmount . "', "; + $QryUpdateFleet .= "`fleet_array` = '" . $FleetArray . "', "; + $QryUpdateFleet .= "`fleet_mess` = '1', "; + $QryUpdateFleet .= "`fleet_resource_metal` = '" . $Mining['metal'] . "', "; + $QryUpdateFleet .= "`fleet_resource_crystal` = '" . $Mining['crystal'] . "', "; + $QryUpdateFleet .= "`fleet_resource_deuterium` = '" . $Mining['deuter'] . "' "; + $QryUpdateFleet .= "WHERE fleet_id = '" . $FleetRow['fleet_id'] . "' "; + $QryUpdateFleet .= "LIMIT 1 ;"; + doquery($QryUpdateFleet , 'fleets'); + + SendSimpleMessage ($CurrentUserID, '', $FleetRow['fleet_start_time'], 3, $lang['sys_mess_tower'], $lang['sys_mess_attack_report'], $raport); + // Ajout du petit point raideur + $AddPoint = $CurrentUser['xpraid'] + 1; + + $QryUpdateOfficier = "UPDATE {{table}} SET "; + $QryUpdateOfficier .= "`xpraid` = '" . $AddPoint . "' "; + $QryUpdateOfficier .= "WHERE id = '" . $CurrentUserID . "' "; + $QryUpdateOfficier .= "LIMIT 1 ;"; + doquery($QryUpdateOfficier, 'users'); + // Ajout d'un point au compteur de raids + $RaidsTotal = $CurrentUser['raids'] + 1; + if ($FleetResult == "a") { + $RaidsWin = $CurrentUser['raidswin'] + 1; + $QryUpdateRaidsCompteur = "UPDATE {{table}} SET "; + $QryUpdateRaidsCompteur .= "`raidswin` ='" . $RaidsWin . "', "; + $QryUpdateRaidsCompteur .= "`raids` ='" . $RaidsTotal . "' "; + $QryUpdateRaidsCompteur .= "WHERE id = '" . $CurrentUserID . "' "; + $QryUpdateRaidsCompteur .= "LIMIT 1 ;"; + doquery($QryUpdateRaidsCompteur, 'users'); + } elseif ($FleetResult == "r" || $FleetResult == "w") { + $RaidsLoose = $CurrentUser['raidsloose'] + 1; + $QryUpdateRaidsCompteur = "UPDATE {{table}} SET "; + $QryUpdateRaidsCompteur .= "`raidswin` ='" . $RaidsLoose . "', "; + $QryUpdateRaidsCompteur .= "`raids` ='" . $RaidsTotal . "' "; + $QryUpdateRaidsCompteur .= "WHERE id = '" . $CurrentUserID . "' "; + $QryUpdateRaidsCompteur .= "LIMIT 1 ;"; + doquery($QryUpdateRaidsCompteur, 'users'); + } + // Colorisation du résumé de rapport pour l'attaquant + $raport2 = ""; + $raport2 .= "
    "; + if ($FleetResult == "a") { + $raport2 .= ""; + } elseif ($FleetResult == "r") { + $raport2 .= ""; + } elseif ($FleetResult == "w") { + $raport2 .= ""; + } + $raport2 .= $lang['sys_mess_attack_report'] . " [" . $FleetRow['fleet_end_galaxy'] . ":" . $FleetRow['fleet_end_system'] . ":" . $FleetRow['fleet_end_planet'] . "]

    "; + + SendSimpleMessage ($TargetUserID, '', $FleetRow['fleet_start_time'], 3, $lang['sys_mess_tower'], $lang['sys_mess_attack_report'], $raport2); + } +// Retour de flotte (s'il en reste) + $fquery = ""; + if ($FleetRow['fleet_end_time'] <= time()) { + if (!is_null($CurrentSet)) { + foreach($CurrentSet as $Ship => $Count) { + $fquery .= "`" . $resource[$Ship] . "` = `" . $resource[$Ship] . "` + '" . $Count['count'] . "', "; + } + } else { + $fleet = explode(";", $FleetRow['fleet_array']); + foreach($fleet as $a => $b) { + if ($b != '') { + $a = explode(",", $b); + $fquery .= "{$resource[$a[0]]}={$resource[$a[0]]} + {$a[1]}, \n"; + } + } + } + + doquery ("DELETE FROM {{table}} WHERE `fleet_id` = " . $FleetRow["fleet_id"], 'fleets'); + if (!($FleetResult == "w")) { + $QryUpdatePlanet = "UPDATE {{table}} SET "; + $QryUpdatePlanet .= $fquery; + $QryUpdatePlanet .= "`metal` = `metal` + " . $FleetRow['fleet_resource_metal'] . ", "; + $QryUpdatePlanet .= "`crystal` = `crystal` + " . $FleetRow['fleet_resource_crystal'] . ", "; + $QryUpdatePlanet .= "`deuterium` = `deuterium` + " . $FleetRow['fleet_resource_deuterium'] . " "; + $QryUpdatePlanet .= "WHERE "; + $QryUpdatePlanet .= "`galaxy` = " . $FleetRow['fleet_start_galaxy'] . " AND "; + $QryUpdatePlanet .= "`system` = " . $FleetRow['fleet_start_system'] . " AND "; + $QryUpdatePlanet .= "`planet` = " . $FleetRow['fleet_start_planet'] . " AND "; + $QryUpdatePlanet .= "`planet_type` = " . $FleetRow['fleet_start_type'] . " LIMIT 1 ;"; + doquery($QryUpdatePlanet, 'planets'); + } + } +} diff --git a/src/includes/functions/MissionCaseColonisation.php b/src/includes/functions/MissionCaseColonisation.php new file mode 100644 index 0000000..b736091 --- /dev/null +++ b/src/includes/functions/MissionCaseColonisation.php @@ -0,0 +1,138 @@ + + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License + * along with this program. If not, see . + * + * --> 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. + * + */ + +/** + * + * @deprecated + * @param Wootook_Empire_Model_Fleet|array $fleet + */ +function MissionCaseColonisation($fleet) +{ + $readConnection = Wootook_Core_Database_ConnectionManager::getSingleton()->getConnection('core_read'); + + $player = new Wootook_Player_Model_Entity(); + $player->load($fleet->getData('fleet_owner')); + if (!$player->getId()) { + $fleet->delete(); + return; + } + + $event = Wootook::dispatchEvent('fleet.mission.colonize.max-allowed-planets', array( + 'base_count' => MAX_PLAYER_PLANETS, + 'count' => MAX_PLAYER_PLANETS, + 'player' => $player, + 'fleet' => $fleet + )); + + $maxAllowedPlanetCount = $event->getData('count'); + + /* first trip */ + if ($fleet->getData('fleet_mess') == 0) { + if ($fleet->getActionTime()->isEarlier()) { + return; + } + if ($player->getPlanetCollection()->getSize() >= $maxAllowedPlanetCount && !$player->isAuthorized(array(LEVEL_ADMIN))) { + /* no more planets to colonize */ + + $coords = sprintf('%d:%d:%d', $fleet->getData('fleet_end_galaxy'), $fleet->getData('fleet_end_system'), $fleet->getData('fleet_end_planet')); + SendSimpleMessage($player->getId(), null, $fleet['fleet_end_time'], 0, + Wootook::__('Colonization'), Wootook::__('Colonization report'), + Wootook::__("The fleet has arrived at the coordinates [%1\$s], but unfortunatly colonization cannot happen : you can't have more than %2\$d colonies.", $coords, $maxAllowedPlanetCount)); + + $fleet->goBack(); + return; + } + + $statement = $readConnection->select() + ->column(new Wootook_Core_Database_Sql_Placeholder_Expression('COUNT(*)')) + ->from($readConnection->getTable('planets')) + ->where('galaxy', $fleet->getData('fleet_end_galaxy')) + ->where('system', $fleet->getData('fleet_end_system')) + ->where('planet', $fleet->getData('fleet_end_planet')) + ->prepare() + ; + + $statement->execute(); + if ($statement->fetchColumn() > 0) { + $coords = sprintf('%d:%d:%d', $fleet->getData('fleet_end_galaxy'), $fleet->getData('fleet_end_system'), $fleet->getData('fleet_end_planet')); + SendSimpleMessage($player->getId(), null, $fleet['fleet_end_time'], 0, + Wootook::__('Colonization'), Wootook::__('Colonization report'), + Wootook::__("The fleet has arrived at the coordinates [%1\$s], but unfortunatly colonization cannot happen : the planet is already colonized.", $coords)); + + $fleet->goBack(); + return; + } + + if (mt_rand(0, 100) >= 75) { + $baseSize = Wootook::getGameConfig('planet/initial/fields'); + $factor = 2 * $position / (1 + log($position)); + $fuzz = 2 * $factor * pow(sin($factor), 2) / 2 + $factor / 4; + $size = ($baseSize * mt_rand(floor($factor / 10), ceil($factor * 5 / 4))) + mt_rand(0, $fuzz); + + $player->createNewPlanet( + $fleet->getData('fleet_end_galaxy'), + $fleet->getData('fleet_end_system'), + $fleet->getData('fleet_end_planet'), + Wootook_Empire_Model_Planet::TYPE_PLANET, + Wootook::__('Colony'), + $size + ); + + $coords = sprintf('%d:%d:%d', $fleet->getData('fleet_end_galaxy'), $fleet->getData('fleet_end_system'), $fleet->getData('fleet_end_planet')); + SendSimpleMessage($player->getId(), null, $fleet['fleet_end_time'], 0, + Wootook::__('Colonization'), Wootook::__('Colonization report'), + Wootook::__("The fleet has arrived at the coordinates [%1\$s], the settlers succeeded creating your new colony.", $coords)); + + $fleet->delete(); + return; + } else { + $coords = sprintf('%d:%d:%d', $fleet->getData('fleet_end_galaxy'), $fleet->getData('fleet_end_system'), $fleet->getData('fleet_end_planet')); + SendSimpleMessage($player->getId(), null, $fleet['fleet_end_time'], 0, + Wootook::__('Colonization'), Wootook::__('Colonization report'), + Wootook::__("The fleet has arrived at the coordinates [%1\$s], the settlers failed creating your new colony, no planet was there.", $coords)); + + $fleet->goBack(); + return; + } + } + + /* back trip */ + if ($fleet->getArrivalTime()->isEarlier()) { + return; + } + + $fleet->dock($fleet->getOriginPlanet()); + + $coords = sprintf('%d:%d:%d', $fleet->getData('fleet_end_galaxy'), $fleet->getData('fleet_end_system'), $fleet->getData('fleet_end_planet')); + SendSimpleMessage($player->getId(), null, $fleet['fleet_end_time'], 0, + Wootook::__('Colonization'), Wootook::__('Colonization report'), + Wootook::__("The fleet went back from the coordinates [%1\$s], the settlers failed creating your new colony.", $coords)); + return; +} \ No newline at end of file diff --git a/includes/functions/MissionCaseDestruction.php b/src/includes/functions/MissionCaseDestruction.php similarity index 96% rename from includes/functions/MissionCaseDestruction.php rename to src/includes/functions/MissionCaseDestruction.php index dd95285..4c2fc23 100644 --- a/includes/functions/MissionCaseDestruction.php +++ b/src/includes/functions/MissionCaseDestruction.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ @@ -35,7 +35,7 @@ */ function MissionCaseDestruction($FleetRow) { - global $user, $pricelist, $lang, $resource, $CombatCaps, $gameConfig; + global $user, $pricelist, $lang, $resource, $CombatCaps; includeLang('system'); @@ -156,7 +156,7 @@ function MissionCaseDestruction($FleetRow) $gravitonPower = 1 + pow(1 - $gravitonLevel, 2); $rawChances = pow(sqrt(1 / floatval($TargetPlanet['diameter'])) * $destructionPower * $gravitonPower, 2); - $chances = (1 - (1 / ((2500 / floatval($gameConfig['game_speed'])) * pow(1 + $rawChances, 2)))) * .5; + $chances = (1 - (1 / ((2500 / floatval(Wootook::getGameConfig('game/speed/general'))) * pow(1 + $rawChances, 2)))) * .5; $tirage = mt_rand(0, 100000000); $probalune = sprintf($lang['sys_destruc_lune'], (int) ($chances * 100)); @@ -252,266 +252,143 @@ function MissionCaseDestruction($FleetRow) $introdestruc = sprintf ($lang['sys_destruc_mess'], $DepName , $FleetRow['fleet_start_galaxy'], $FleetRow['fleet_start_system'], $FleetRow['fleet_start_planet'], $FleetRow['fleet_end_galaxy'], $FleetRow['fleet_end_system'], $FleetRow['fleet_end_planet']); // Mise a jour de l'enregistrement de la planete attaqu�e - $QryUpdateTarget = "UPDATE {{table}} SET "; - $QryUpdateTarget .= $TargetPlanetUpd; - $QryUpdateTarget .= "`metal` = `metal` - '". $Mining['metal'] ."', "; - $QryUpdateTarget .= "`crystal` = `crystal` - '". $Mining['crystal'] ."', "; - $QryUpdateTarget .= "`deuterium` = `deuterium` - '". $Mining['deuter'] ."' "; - $QryUpdateTarget .= "WHERE "; - $QryUpdateTarget .= "`galaxy` = '". $FleetRow['fleet_end_galaxy'] ."' AND "; - $QryUpdateTarget .= "`system` = '". $FleetRow['fleet_end_system'] ."' AND "; - $QryUpdateTarget .= "`planet` = '". $FleetRow['fleet_end_planet'] ."' AND "; - $QryUpdateTarget .= "`planet_type` = '". $FleetRow['fleet_end_type'] ."' "; - $QryUpdateTarget .= "LIMIT 1;"; - doquery( $QryUpdateTarget , 'planets'); - - // Mise a jour du champ de ruine devant la planete attaqu�e - $QryUpdateGalaxy = "UPDATE {{table}} SET "; - $QryUpdateGalaxy .= "`metal` = `metal` + '". $zlom['metal'] ."', "; - $QryUpdateGalaxy .= "`crystal` = `crystal` + '". $zlom['crystal'] ."' "; - $QryUpdateGalaxy .= "WHERE "; - $QryUpdateGalaxy .= "`galaxy` = '". $FleetRow['fleet_end_galaxy'] ."' AND "; - $QryUpdateGalaxy .= "`system` = '". $FleetRow['fleet_end_system'] ."' AND "; - $QryUpdateGalaxy .= "`planet` = '". $FleetRow['fleet_end_planet'] ."' "; - $QryUpdateGalaxy .= "LIMIT 1;"; - doquery( $QryUpdateGalaxy , 'galaxy'); - - // L� on va discuter le bout de gras pour voir s'il y a moyen d'avoir une Lune ! - $FleetDebris = $zlom['metal'] + $zlom['crystal']; - $StrAttackerUnits = sprintf ($lang['sys_attacker_lostunits'], $zlom["atakujacy"]); - $StrDefenderUnits = sprintf ($lang['sys_defender_lostunits'], $zlom["wrog"]); - $StrRuins = sprintf ($lang['sys_gcdrunits'], $zlom["metal"], $lang['Metal'], $zlom['crystal'], $lang['Crystal']); - $DebrisField = $StrAttackerUnits ."
    ". $StrDefenderUnits ."
    ". $StrRuins; - $MoonChance = $FleetDebris / 100000; - if ($FleetDebris > 2000000) { - $MoonChance = 20; - } - if ($FleetDebris < 100000) { - $UserChance = 0; - $ChanceMoon = ""; - } elseif ($FleetDebris >= 100000) { - $UserChance = mt_rand(1, 100); - $ChanceMoon = sprintf ($lang['sys_moonproba'], $MoonChance); - } - - if (($UserChance > 0) and ($UserChance <= $MoonChance) and $galenemyrow['id_luna'] == 0) { - - $TargetPlanetName = CreateOneMoonRecord ( $FleetRow['fleet_end_galaxy'], $FleetRow['fleet_end_system'], $FleetRow['fleet_end_planet'], $TargetUserID, $FleetRow['fleet_start_time'], '', $MoonChance ); - - $GottenMoon = sprintf ($lang['sys_moonbuilt'], $TargetPlanetName, $FleetRow['fleet_end_galaxy'], $FleetRow['fleet_end_system'], $FleetRow['fleet_end_planet']); - + $user = Wootook_Player_Model_Entity::factory($TargetUserID); + $user->createNewPlanet( + intval($FleetRow['fleet_end_galaxy']), + intval($FleetRow['fleet_end_system']), + intval($FleetRow['fleet_end_planet']), + Wootook_Empire_Model_Planet::TYPE_MOON, + Wootook::__('Moon') + ); + $GottenMoon = Wootook::_('A moon has been created!'); } elseif ($UserChance = 0 or $UserChance > $MoonChance) { - $GottenMoon = ""; - } - - $AttackDate = date("r", $FleetRow["fleet_start_time"]); - $title = sprintf ($lang['sys_destruc_title'], $AttackDate); - $raport = "
    '; + continue; + } + + $output .= ""; + if ($galaxyPosition->getData('galaxy') && $galaxyPosition["id_planet"] != 0) { + if ($planetStatement->execute(array('planet_id' => $galaxyPosition["id_planet"]))) { + /** @var Wootook_Empire_Model_Planet $currentPlanet */ + $currentPlanet = $planetStatement->fetchEntity('Wootook_Empire_Model_Planet'); + } else { + $currentPlanet = new Wootook_Empire_Model_Planet(); + } + + if ($currentPlanet->getId() && !$currentPlanet->isDestroyed()) { + $planetcount++; + $currentPlayer = $currentPlanet->getPlayer(); + } else { + CheckAbandonPlanetState($currentPlanet); + $currentPlayer = new Wootook_Player_Model_Entity(); + } + + if ($galaxyPosition["id_luna"] != 0) { + if ($planetStatement->execute(array('planet_id' => $galaxyPosition["id_luna"]))) { + /** @var Wootook_Empire_Model_Planet $currentMoon */ + $currentMoon = $planetStatement->fetchEntity('Wootook_Empire_Model_Planet'); + } else { + $currentMoon = new Wootook_Empire_Model_Planet(); + } + + if ($currentMoon->isDestroyed()) { + CheckAbandonMoonState($currentMoon); + } + } else { + $currentMoon = new Wootook_Empire_Model_Planet(); + } + } else { + $currentPlanet = new Wootook_Empire_Model_Planet(); + $currentPlayer = new Wootook_Player_Model_Entity(); + $currentMoon = new Wootook_Empire_Model_Planet(); + } + $output .= GalaxyRowPos($Planet, $galaxyPosition); + $output .= GalaxyRowPlanet($galaxyPosition, $currentPlanet, $currentPlayer, $Galaxy, $System, $Planet, 1); + $output .= GalaxyRowPlanetName($galaxyPosition, $currentPlanet, $currentPlayer, $Galaxy, $System, $Planet, 1); + $output .= GalaxyRowMoon($galaxyPosition, $currentMoon , $currentPlayer, $Galaxy, $System, $Planet, 3); + $output .= GalaxyRowDebris($galaxyPosition, $currentPlanet, $currentPlayer, $Galaxy, $System, $Planet, 2); + $output .= GalaxyRowUser($currentPlanet, $currentPlayer); + $output .= GalaxyRowAlly($galaxyPosition, $currentPlanet, $currentPlayer, $Galaxy, $System, $Planet, 0); + $output .= GalaxyRowActions($galaxyPosition, $currentPlanet, $currentPlayer, $Galaxy, $System, $Planet, 0); + $output .= ""; + } + + return $output; +} + +?> \ No newline at end of file diff --git a/includes/functions/ShowGalaxySelector.php b/src/includes/functions/ShowGalaxySelector.php similarity index 85% rename from includes/functions/ShowGalaxySelector.php rename to src/includes/functions/ShowGalaxySelector.php index c2e6cf8..f9d4827 100644 --- a/includes/functions/ShowGalaxySelector.php +++ b/src/includes/functions/ShowGalaxySelector.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ @@ -37,14 +37,14 @@ function ShowGalaxySelector ( $Galaxy, $System ) { global $lang; - if ($Galaxy > MAX_GALAXY_IN_WORLD) { - $Galaxy = MAX_GALAXY_IN_WORLD; + if ($Galaxy > Wootook::getGameConfig('engine/universe/galaxies')) { + $Galaxy = Wootook::getGameConfig('engine/universe/galaxies'); } if ($Galaxy < 1) { $Galaxy = 1; } - if ($System > MAX_SYSTEM_IN_GALAXY) { - $System = MAX_SYSTEM_IN_GALAXY; + if ($System > Wootook::getGameConfig('engine/universe/systems')) { + $System = Wootook::getGameConfig('engine/universe/systems'); } if ($System < 1) { $System = 1; diff --git a/includes/functions/ShowGalaxyTitles.php b/src/includes/functions/ShowGalaxyTitles.php similarity index 88% rename from includes/functions/ShowGalaxyTitles.php rename to src/includes/functions/ShowGalaxyTitles.php index 09f745f..9619aab 100644 --- a/includes/functions/ShowGalaxyTitles.php +++ b/src/includes/functions/ShowGalaxyTitles.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/includes/functions/SpyTarget.php b/src/includes/functions/SpyTarget.php similarity index 94% rename from includes/functions/SpyTarget.php rename to src/includes/functions/SpyTarget.php index 2b983db..5e21bad 100644 --- a/includes/functions/SpyTarget.php +++ b/src/includes/functions/SpyTarget.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/includes/functions/StoreGoodsToPlanet.php b/src/includes/functions/StoreGoodsToPlanet.php similarity index 91% rename from includes/functions/StoreGoodsToPlanet.php rename to src/includes/functions/StoreGoodsToPlanet.php index 79647c1..c1c8b11 100644 --- a/includes/functions/StoreGoodsToPlanet.php +++ b/src/includes/functions/StoreGoodsToPlanet.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/includes/raketenangriff.php b/src/includes/raketenangriff.php similarity index 96% rename from includes/raketenangriff.php rename to src/includes/raketenangriff.php index d31a2df..d961c09 100644 --- a/includes/raketenangriff.php +++ b/src/includes/raketenangriff.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/includes/strings.php b/src/includes/strings.php similarity index 87% rename from includes/strings.php rename to src/includes/strings.php index fa0b69e..f1abfb8 100644 --- a/includes/strings.php +++ b/src/includes/strings.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/src/includes/todofleetcontrol.php b/src/includes/todofleetcontrol.php new file mode 100644 index 0000000..819c79f --- /dev/null +++ b/src/includes/todofleetcontrol.php @@ -0,0 +1,74 @@ + + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License + * along with this program. If not, see . + * + * --> 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. + * + */ + +require_once ROOT_PATH . 'includes/deprecated.php'; + +/** + * @deprecated + * {{{ + */ +include(ROOT_PATH . 'includes/functions/MissionCaseAttack.'.PHPEXT); +include(ROOT_PATH . 'includes/functions/MissionCaseStay.'.PHPEXT); +include(ROOT_PATH . 'includes/functions/MissionCaseStayAlly.'.PHPEXT); +include(ROOT_PATH . 'includes/functions/MissionCaseTransport.'.PHPEXT); +include(ROOT_PATH . 'includes/functions/MissionCaseSpy.'.PHPEXT); +include(ROOT_PATH . 'includes/functions/MissionCaseRecycling.'.PHPEXT); +include(ROOT_PATH . 'includes/functions/MissionCaseDestruction.'.PHPEXT); +include(ROOT_PATH . 'includes/functions/MissionCaseColonisation.'.PHPEXT); +include(ROOT_PATH . 'includes/functions/MissionCaseExpedition.'.PHPEXT); +include(ROOT_PATH . 'includes/functions/SendSimpleMessage.'.PHPEXT); +include(ROOT_PATH . 'includes/functions/SpyTarget.'.PHPEXT); +include(ROOT_PATH . 'includes/functions/RestoreFleetToPlanet.'.PHPEXT); +include(ROOT_PATH . 'includes/functions/StoreGoodsToPlanet.'.PHPEXT); // includes/functions/StoreGoodsToPlanet.php +include(ROOT_PATH . 'includes/functions/InsertJavaScriptChronoApplet.'.PHPEXT); // infos.php, includes/functions/BuildFleetEventTable.php +include(ROOT_PATH . 'includes/functions/InsertGalaxyScripts.'.PHPEXT); // galaxy.php +include(ROOT_PATH . 'includes/functions/GalaxyCheckFunctions.'.PHPEXT); // galaxy.php +include(ROOT_PATH . 'includes/functions/ShowGalaxyRows.'.PHPEXT); // galaxy.php +include(ROOT_PATH . 'includes/functions/GetPhalanxRange.'.PHPEXT); // <- TODO: delete +include(ROOT_PATH . 'includes/functions/GetMissileRange.'.PHPEXT); // <- TODO: delete +include(ROOT_PATH . 'includes/functions/GalaxyRowPos.'.PHPEXT); // galaxy.php +include(ROOT_PATH . 'includes/functions/GalaxyRowPlanet.'.PHPEXT); // galaxy.php +include(ROOT_PATH . 'includes/functions/GalaxyRowPlanetName.'.PHPEXT); // galaxy.php +include(ROOT_PATH . 'includes/functions/GalaxyRowMoon.'.PHPEXT); // galaxy.php +include(ROOT_PATH . 'includes/functions/GalaxyRowDebris.'.PHPEXT); // galaxy.php +include(ROOT_PATH . 'includes/functions/GalaxyRowUser.'.PHPEXT); // galaxy.php +include(ROOT_PATH . 'includes/functions/GalaxyRowAlly.'.PHPEXT); // galaxy.php +include(ROOT_PATH . 'includes/functions/GalaxyRowActions.'.PHPEXT); // galaxy.php +include(ROOT_PATH . 'includes/functions/ShowGalaxySelector.'.PHPEXT); // galaxy.php +include(ROOT_PATH . 'includes/functions/ShowGalaxyMISelector.'.PHPEXT); // galaxy.php +include(ROOT_PATH . 'includes/functions/ShowGalaxyTitles.'.PHPEXT); // galaxy.php +include(ROOT_PATH . 'includes/functions/GalaxyLegendPopup.'.PHPEXT); // galaxy.php +include(ROOT_PATH . 'includes/functions/ShowGalaxyFooter.'.PHPEXT); // galaxy.php +include(ROOT_PATH . 'includes/functions/MessageForm.'.PHPEXT); // alliance.php +include(ROOT_PATH . 'includes/functions/MipCombatEngine.'.PHPEXT); // mipattack.php +include(ROOT_PATH . 'includes/functions/BuildFleetEventTable.'.PHPEXT); // phalanx.php +/** + * }}} + */ diff --git a/includes/unlocalised.php b/src/includes/unlocalised.php similarity index 87% rename from includes/unlocalised.php rename to src/includes/unlocalised.php index 82244dd..a0ba847 100644 --- a/includes/unlocalised.php +++ b/src/includes/unlocalised.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ @@ -46,7 +46,6 @@ function GetTargetDistance($OrigGalaxy, $DestGalaxy, $OrigSystem, $DestSystem, $ // Calcul de la durée de vol d'une flotte par rapport a sa vitesse max function GetMissionDuration ($GameSpeed, $MaxFleetSpeed, $Distance, $SpeedFactor) { - $Duration = 0; $Duration = round(((35000 / $GameSpeed * sqrt($Distance * 10 / $MaxFleetSpeed) + 10) / $SpeedFactor)); return $Duration; @@ -54,47 +53,58 @@ function GetMissionDuration ($GameSpeed, $MaxFleetSpeed, $Distance, $SpeedFactor // Retourne la valeur ajustée de vitesse des flottes function GetGameSpeedFactor () { - global $gameConfig; - - return $gameConfig['fleet_speed'] / 2500; + return Wootook::getGameConfig('game/speed/fleet') / 2500; } /** * Calcul de la vitesse de la flotte par rapport aux technos du joueur * Avec prise en compte */ -function GetFleetMaxSpeed ($FleetArray, $Fleet, $Player) { +function GetFleetMaxSpeed($FleetArray, $Fleet, $Player) { global $reslist, $pricelist; + if (!is_array($FleetArray)) { + $FleetArray = array(); + } + if ($Fleet != 0) { $FleetArray[$Fleet] = 1; } + + $speedalls = array(); foreach ($FleetArray as $Ship => $Count) { - if ($Ship == 202) { + if ($Ship == Legacies_Empire::ID_SHIP_SOLAR_SATELLITE) { + $speedalls[$Ship] = 0; + } + if ($Ship == Legacies_Empire::ID_SHIP_LIGHT_TRANSPORT) { if ($Player['impulse_motor_tech'] >= 5) { $speedalls[$Ship] = $pricelist[$Ship]['speed2'] + (($pricelist[$Ship]['speed'] * $Player['impulse_motor_tech']) * 0.2); } else { $speedalls[$Ship] = $pricelist[$Ship]['speed'] + (($pricelist[$Ship]['speed'] * $Player['combustion_tech']) * 0.1); } } - if ($Ship == 203 or $Ship == 204 or $Ship == 209 or $Ship == 210) { + if ($Ship == Legacies_Empire::ID_SHIP_LARGE_TRANSPORT || $Ship == Legacies_Empire::ID_SHIP_LIGHT_FIGHTER || + $Ship == Legacies_Empire::ID_SHIP_RECYCLER || $Ship == Legacies_Empire::ID_SHIP_SPY_DRONE) { $speedalls[$Ship] = $pricelist[$Ship]['speed'] + (($pricelist[$Ship]['speed'] * $Player['combustion_tech']) * 0.1); } - if ($Ship == 205 or $Ship == 206 or $Ship == 208) { + if ($Ship == Legacies_Empire::ID_SHIP_HEAVY_FIGHTER || $Ship == Legacies_Empire::ID_SHIP_CRUISER || + $Ship == Legacies_Empire::ID_SHIP_COLONY_SHIP) { $speedalls[$Ship] = $pricelist[$Ship]['speed'] + (($pricelist[$Ship]['speed'] * $Player['impulse_motor_tech']) * 0.2); } - if ($Ship == 211) { + if ($Ship == Legacies_Empire::ID_SHIP_BOMBER) { if ($Player['hyperspace_motor_tech'] >= 8) { $speedalls[$Ship] = $pricelist[$Ship]['speed2'] + (($pricelist[$Ship]['speed'] * $Player['hyperspace_motor_tech']) * 0.3); } else { $speedalls[$Ship] = $pricelist[$Ship]['speed'] + (($pricelist[$Ship]['speed'] * $Player['impulse_motor_tech']) * 0.2); } } - if ($Ship == 207 or $Ship == 213 or $Ship == 214 or $Ship == 215 or $Ship == 216) { + if ($Ship == Legacies_Empire::ID_SHIP_BATTLESHIP || $Ship == Legacies_Empire::ID_SHIP_DESTRUCTOR || + $Ship == Legacies_Empire::ID_SHIP_DEATH_STAR || $Ship == Legacies_Empire::ID_SHIP_BATTLECRUISER || + $Ship == Legacies_Empire::ID_SHIP_SUPERNOVA) { $speedalls[$Ship] = $pricelist[$Ship]['speed'] + (($pricelist[$Ship]['speed'] * $Player['hyperspace_motor_tech']) * 0.3); } } - if ($Fleet != 0) { + if ($Fleet != 0 && isset($speedalls[$Ship])) { $ShipSpeed = $speedalls[$Ship]; $speedalls = $ShipSpeed; } @@ -104,12 +114,13 @@ function GetFleetMaxSpeed ($FleetArray, $Fleet, $Player) { // ---------------------------------------------------------------------------------------------------------------- // Calcul de la consommation de base d'un vaisseau au regard des technologies -function GetShipConsumption ( $Ship, $Player ) { - global $pricelist; - if ($Player['impulse_motor_tech'] >= 5) { - $Consumption = $pricelist[$Ship]['consumption2']; +function GetShipConsumption($shipId, $player) +{ + $pricelist = Wootook_Empire_Helper_Config_Prices::getSingleton(); + if ($shipId == Legacies_Empire::ID_SHIP_LIGHT_TRANSPORT && $player->getElement(Legacies_Empire::ID_RESEARCH_IMPULSE_DRIVE) >= 5) { + $Consumption = $pricelist[$shipId]['consumption2']; } else { - $Consumption = $pricelist[$Ship]['consumption']; + $Consumption = $pricelist[$shipId]['consumption']; } return $Consumption; diff --git a/includes/vars.php b/src/includes/vars.php similarity index 69% rename from includes/vars.php rename to src/includes/vars.php index fa1acbd..3df91aa 100644 --- a/includes/vars.php +++ b/src/includes/vars.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2010, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ @@ -46,14 +46,14 @@ $messfields = array ( 100 => "new_message" ); -$resource = Legacies_Empire_Model_Game_FieldsAlias::getSingleton(); +$resource = Wootook_Empire_Helper_Config_FieldsAlias::getSingleton(); -$requirements = Legacies_Empire_Model_Game_Requirements::getSingleton(); +$requirements = Wootook_Empire_Helper_Config_Requirements::getSingleton(); -$pricelist = Legacies_Empire_Model_Game_Prices::getSingleton(); +$pricelist = Wootook_Empire_Helper_Config_Prices::getSingleton(); -$CombatCaps = Legacies_Empire_Model_Game_Combat::getSingleton(); +$CombatCaps = Wootook_Empire_Helper_Config_Combat::getSingleton(); -$ProdGrid = Legacies_Empire_Model_Game_Production::getSingleton(); +$ProdGrid = Wootook_Empire_Helper_Config_Production::getSingleton(); -$reslist = Legacies_Empire_Model_Game_Types::getSingleton(); +$reslist = Wootook_Empire_Helper_Config_Types::getSingleton(); diff --git a/src/index.php b/src/index.php new file mode 100644 index 0000000..7454dc0 --- /dev/null +++ b/src/index.php @@ -0,0 +1,42 @@ + + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License + * along with this program. If not, see . + * + * --> 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. + * + */ + +define('DISABLE_IDENTITY_CHECK', true); +require_once dirname(__FILE__) .'/application/bootstrap.php'; + +$frontController = new Wootook_Core_Mvc_Controller_Front(Wootook::getRequest(), Wootook::getResponse()); + +$frontController + ->addModule('core', 'Wootook_Core_Controller_', 'Wootook/Core/Controller') + ->addModule('player', 'Wootook_Player_Controller_', 'Wootook/Player/Controller') + ->addModule('empire', 'Wootook_Empire_Controller_', 'Wootook/Empire/Controller') + ->addModule('legacies-empire', 'Legacies_Empire_Controller_', 'Legacies/Empire/Controller') + ->dispatch() + ->send(); diff --git a/infos.php b/src/infos.php similarity index 93% rename from infos.php rename to src/infos.php index 91cad5f..3c982a7 100644 --- a/infos.php +++ b/src/infos.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,13 +24,13 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); -require_once dirname(__FILE__) .'/common.php'; +require_once dirname(__FILE__) .'/application/bootstrap.php'; // ---------------------------------------------------------------------------------------------------------- // Creation de la Liste de flotte disponible sur la lune @@ -82,17 +82,18 @@ function BuildJumpableMoonCombo ( $CurrentUser, $CurrentPlanet ) { // Tient compte aussi du multiplicateur de ressources // function ShowProductionTable ($CurrentUser, $CurrentPlanet, $BuildID, $Template) { - global $ProdGrid, $resource, $gameConfig; + global $ProdGrid, $resource; $BuildLevelFactor = $CurrentPlanet[ $resource[$BuildID]."_porcent" ]; $BuildTemp = $CurrentPlanet[ 'temp_max' ]; $CurrentBuildtLvl = $CurrentPlanet[ $resource[$BuildID] ]; $BuildLevel = ($CurrentBuildtLvl > 0) ? $CurrentBuildtLvl : 1; - $Prod[1] = (floor(eval($ProdGrid[$BuildID]['formule']['metal']) * $gameConfig['resource_multiplier']) * (1 + ($CurrentUser['rpg_geologue'] * 0.05))); - $Prod[2] = (floor(eval($ProdGrid[$BuildID]['formule']['crystal']) * $gameConfig['resource_multiplier']) * (1 + ($CurrentUser['rpg_geologue'] * 0.05))); - $Prod[3] = (floor(eval($ProdGrid[$BuildID]['formule']['deuterium']) * $gameConfig['resource_multiplier']) * (1 + ($CurrentUser['rpg_geologue'] * 0.05))); - $Prod[4] = (floor(eval($ProdGrid[$BuildID]['formule']['energy']) * $gameConfig['resource_multiplier']) * (1 + ($CurrentUser['rpg_ingenieur'] * 0.05))); + $multiplier = Wootook::getGameConfig('game/resource/multiplier'); + $Prod[1] = (floor(eval($ProdGrid[$BuildID]['formule']['metal']) * $multiplier)); + $Prod[2] = (floor(eval($ProdGrid[$BuildID]['formule']['crystal']) * $multiplier)); + $Prod[3] = (floor(eval($ProdGrid[$BuildID]['formule']['deuterium']) * $multiplier)); + $Prod[4] = (floor(eval($ProdGrid[$BuildID]['formule']['energy']) * $multiplier)); $BuildLevel = ""; $ActualProd = floor($Prod[$BuildID]); @@ -110,10 +111,10 @@ function ShowProductionTable ($CurrentUser, $CurrentPlanet, $BuildID, $Template) $ProdFirst = 0; for ( $BuildLevel = $BuildStartLvl; $BuildLevel < $BuildStartLvl + 10; $BuildLevel++ ) { if ($BuildID != 42) { - $Prod[1] = (floor(eval($ProdGrid[$BuildID]['formule']['metal']) * $gameConfig['resource_multiplier']) * (1 + ($CurrentUser['rpg_geologue'] * 0.05))); - $Prod[2] = (floor(eval($ProdGrid[$BuildID]['formule']['crystal']) * $gameConfig['resource_multiplier']) * (1 + ($CurrentUser['rpg_geologue'] * 0.05))); - $Prod[3] = (floor(eval($ProdGrid[$BuildID]['formule']['deuterium']) * $gameConfig['resource_multiplier']) * (1 + ($CurrentUser['rpg_geologue'] * 0.05))); - $Prod[4] = (floor(eval($ProdGrid[$BuildID]['formule']['energy']) * $gameConfig['resource_multiplier']) * (1 + ($CurrentUser['rpg_ingenieur'] * 0.05))); + $Prod[1] = (floor(eval($ProdGrid[$BuildID]['formule']['metal']) * $multiplier)); + $Prod[2] = (floor(eval($ProdGrid[$BuildID]['formule']['crystal']) * $multiplier)); + $Prod[3] = (floor(eval($ProdGrid[$BuildID]['formule']['deuterium']) * $multiplier)); + $Prod[4] = (floor(eval($ProdGrid[$BuildID]['formule']['energy']) * $multiplier)); $bloc['build_lvl'] = ($CurrentBuildtLvl == $BuildLevel) ? "".$BuildLevel."" : $BuildLevel; if ($ProdFirst > 0) { @@ -326,7 +327,7 @@ function ShowBuildingInfoPage ($CurrentUser, $CurrentPlanet, $BuildID) { // ---- Destruction $NeededRessources = GetBuildingPrice ($CurrentUser, $CurrentPlanet, $BuildID, true, true); $DestroyTime = GetBuildingTime ($CurrentUser, $CurrentPlanet, $BuildID) / 2; - $parse['destroyurl'] = "buildings.php?cmd=destroy&building=".$BuildID; // Non balisé les balises sont dans le tpl + $parse['destroyurl'] = Wootook::getUrl('empire/buildings/destroy', array('id' => $BuildID)); // Non balisé les balises sont dans le tpl $parse['levelvalue'] = $CurrentPlanet[$resource[$BuildID]]; // Niveau du batiment a detruire $parse['nfo_metal'] = $lang['Metal']; $parse['nfo_crysta'] = $lang['Crystal']; @@ -357,4 +358,4 @@ function ShowBuildingInfoPage ($CurrentUser, $CurrentPlanet, $BuildID) { // History version // 1.0 - Réécriture (réinventation de l'eau tiède) // 1.1 - Ajout JumpGate pour la porte de saut comme la présente OGame ... Enfin un peu mieux quand meme ! -?> \ No newline at end of file +?> diff --git a/src/install/gameplays.php b/src/install/gameplays.php new file mode 100644 index 0000000..ab036c5 --- /dev/null +++ b/src/install/gameplays.php @@ -0,0 +1,26 @@ + 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' + ), +*/ + ) + ) + ); diff --git a/src/install/index.php b/src/install/index.php new file mode 100644 index 0000000..d96aacc --- /dev/null +++ b/src/install/index.php @@ -0,0 +1,592 @@ + + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License + * along with this program. If not, see . + * + * --> 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. + * + */ + +define('DEBUG', true); +define('DEPRECATION', true); + +define('STEP_SYSTEM', 1); +define('STEP_DATABASE', 2); +define('STEP_UNIVERSE', 3); +define('STEP_PROFILE', 4); +define('STEP_CONFIG', 5); + +if (!defined('DEBUG') && ($env = getenv('DEBUG')) !== false && in_array(strtolower($env), array('1', 'on', 'true'))) { + define('DEBUG', true); +} else if (!defined('DEBUG') && isset($_SERVER['DEBUG']) && in_array(strtolower($_SERVER['DEBUG']), array('1', 'on', 'true'))) { + define('DEBUG', true); +} + +if (!defined('DEPRECATION') && ($env = getenv('DEPRECATION')) !== false && in_array(strtolower($env), array('1', 'on', 'true'))) { + define('DEPRECATION', true); +} else if (!defined('DEPRECATION') && isset($_SERVER['DEPRECATION']) && in_array(strtolower($_SERVER['DEPRECATION']), array('1', 'on', 'true'))) { + define('DEPRECATION', true); +} + +if (!defined('BCNUMBERS') && ($env = getenv('BCNUMBERS')) !== false && in_array(strtolower($env), array('1', 'on', 'true'))) { + define('BCNUMBERS', true); +} else if (!defined('BCNUMBERS') && isset($_SERVER['BCNUMBERS']) && in_array(strtolower($_SERVER['BCNUMBERS']), array('1', 'on', 'true'))) { + define('BCNUMBERS', true); +} + +if (!defined('DEBUG')) { + @ini_set('display_errors', false); +} else { + @ini_set('display_errors', true); + @error_reporting(E_ALL | E_STRICT); +} + +defined('ROOT_PATH') || define('ROOT_PATH', dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR); +defined('APPLICATION_PATH') || define('APPLICATION_PATH', ROOT_PATH . 'application' . DIRECTORY_SEPARATOR); + +defined('PHPEXT') || define('PHPEXT', 'php'); + +defined('VERSION') || define('VERSION', '1.5.0-beta2'); + +set_include_path(implode(PATH_SEPARATOR, array( + APPLICATION_PATH . DIRECTORY_SEPARATOR . 'code' . DIRECTORY_SEPARATOR . 'libraries', + APPLICATION_PATH . DIRECTORY_SEPARATOR . 'code' . DIRECTORY_SEPARATOR . 'local', + APPLICATION_PATH . DIRECTORY_SEPARATOR . 'code' . DIRECTORY_SEPARATOR . 'community', + APPLICATION_PATH . DIRECTORY_SEPARATOR . 'code' . DIRECTORY_SEPARATOR . 'core', + get_include_path() + ))); + +function __autoload($class) { + include_once str_replace('_', '/', $class) . '.php'; +} + +Wootook::$isInstalled = false; + +include ROOT_PATH . 'includes' . DIRECTORY_SEPARATOR . 'constants.php'; + +Wootook_Core_ErrorProfiler::register(); +Wootook_Core_Helper_Config_Events::registerEvents(); + +$mode = isset($_GET['mode']) ? strval($_GET['mode']) : 'intro'; +$step = isset($_GET['step']) ? intval($_GET['step']) : 1; +$prevStep = $step - 1; +$nextStep = $step + 1; + +$baseUrl = (isset($_SERVER["HTTPS"]) && strtolower($_SERVER["HTTPS"]) == "on" ? 'https://' : 'http://') + . $_SERVER["SERVER_NAME"] . ($_SERVER["SERVER_PORT"] != "80" ? ":{$_SERVER["SERVER_PORT"]}" : ''); + +if (isset($_SERVER['REQUEST_URI'])) { + $pathOffset = strrpos($_SERVER['REQUEST_URI'], 'install/'); + $baseUrl .= substr($_SERVER['REQUEST_URI'], 0, strpos(substr($_SERVER['REQUEST_URI'], 0, -1), '/')) . '/'; +} +$session = Wootook::getSession('install'); + +$website = new Wootook_Core_Model_Website(); +$website->setId(0)->setData('code', Wootook_Core_Model_Website::DEFAULT_CODE); +Wootook::setDefaultWebsite($website); + +$game = new Wootook_Core_Model_Game(); +$game->setId(0)->setData('code', Wootook_Core_Model_Game::DEFAULT_CODE); +Wootook::setDefaultGame($game); + +$configRewrites = array( + 'default' => array( + 'web' => array( + 'url' => array( + 'base' => $baseUrl, + 'link' => $baseUrl, + 'skin' => $baseUrl . 'skin/', + 'js' => $baseUrl . 'js/', + 'css' => $baseUrl . 'css/' + ) + ), + 'system' => array( + 'path' => array( + 'base' => ROOT_PATH, + 'design' => APPLICATION_PATH . 'design' . DIRECTORY_SEPARATOR, + 'skin' => ROOT_PATH . 'skin' . DIRECTORY_SEPARATOR, + ) + ), + 'package' => 'default', + 'theme' => 'default', + 'layout' => array( + 'page' => 'page.xml', + 'install' => 'install.php' + ), + 'engine' => array( + 'storyline' => array( + 'universe' => 'legacies', + 'episode' => 'default', + ) + ), + 'resources' => array( + 'initial' => array( + 'metal' => 500, + 'cristal' => 500, + 'deuterium' => 0, + 'energy' => 0, + ), + 'base-income' => array( + 'metal' => 20, + 'cristal' => 10, + 'deuterium' => 0, + 'energy' => 0, + ), + ), + 'planet' => array( + 'initial' => array( + 'fields' => 163 + ) + ) + ) + ); + +$config = unserialize($session->getData('config')); +if (is_array($config)) { + Wootook::loadConfig(array_merge_recursive($config, $configRewrites)); +} else { + Wootook::loadConfig($configRewrites); +} +unset($config); + +$layout = new Wootook_Core_Model_Layout('install'); + +$request = new Wootook_Core_Mvc_Controller_Request_Http(); +$response = new Wootook_Core_Mvc_Controller_Response_Http(); + +switch ($mode) { +case 'intro': + $layout->load('install.intro'); + $layout->getMessagesBlock()->prepareMessages('install'); + $session->setData('step', 1); + break; + +case 'install': + if ($step > $session->getData('step')) { + $session->setData('step', 0); + $response->setRedirect("?mode=intro", Wootook_Core_Mvc_Controller_Response_Http::REDIRECT_TEMPORARY); + $response->sendHeaders(); + exit(0); + } + + switch ($step) { + case STEP_SYSTEM: + if ($request->isPost()) { + $form = new Wootook_Core_Form($session, array( + 'url_path' => 'text', + 'timezone' => 'text' + )); + $form->setRequest($request); + $form->populate(); + + if (!$form->validate()) { + $session->setData('step', STEP_SYSTEM); + $session->setFormData($form->getData()); + $response->setRedirect(Wootook::getStaticUrl('install/index.php', array('mode' => 'install', 'step' => STEP_SYSTEM))); + $response->sendHeaders(); + exit(0); + } + + $urlPath = $request->getPost('url_path'); + + $config = array( + 'global' => array( + 'resource' => array() + ), + 'backend' => array( + 'web' => array( + 'url' => array( + 'base' => $request->getPost('url_path'), + 'link' => $request->getPost('url_path') . 'admin/', + 'skin' => $request->getPost('url_path') . 'skin/', + 'js' => $request->getPost('url_path') . 'js/', + 'css' => $request->getPost('url_path') . 'css/', + ) + ), + 'system' => array( + 'path' => array( + 'base' => ROOT_PATH, + 'skin' => ROOT_PATH . 'skin' . DIRECTORY_SEPARATOR, + 'design' => ROOT_PATH . 'application' . DIRECTORY_SEPARATOR . 'design' . DIRECTORY_SEPARATOR, + ), + 'date' => array( + 'timezone' => $request->getPost('timezone') + ) + ), + ), + 'frontend' => array( + 'web' => array( + 'url' => array( + 'base' => $request->getPost('url_path'), + 'link' => $request->getPost('url_path'), + 'skin' => $request->getPost('url_path') . 'skin/', + 'js' => $request->getPost('url_path') . 'js/', + 'css' => $request->getPost('url_path') . 'css/', + ) + ), + 'system' => array( + 'path' => array( + 'base' => ROOT_PATH, + 'skin' => ROOT_PATH . 'skin' . DIRECTORY_SEPARATOR, + 'design' => ROOT_PATH . 'application' . DIRECTORY_SEPARATOR . 'design' . DIRECTORY_SEPARATOR, + ), + 'date' => array( + 'timezone' => $request->getPost('timezone') + ) + ), + 'engine' => array( + 'storyline' => array( + 'universe' => 'legacies', + 'episode' => 'default', + ), + 'core' => array( + 'use_large_numbers' => true + ), + 'universe' => array( + 'galaxies' => 3, + 'systems' => 100, + 'positions' => 15 + ), + 'combat' => array( + 'allow_spy_drone_attacks' => true + ) + ), + 'locales' => array( + 'fr' => 'fr_FR', + 'fr_FR' => 'fr_FR', + 'en' => 'en_US', + 'en_US' => 'en_US' + ) + ) + ); + $session->setData('config', serialize($config)); + + $session->setData('step', STEP_DATABASE); + $response->setRedirect(Wootook::getStaticUrl('install/index.php', array('mode' => 'install', 'step' => STEP_DATABASE))); + $response->sendHeaders(); + exit(0); + } + + $layout->load('install.step.system'); + $layout->getMessagesBlock()->prepareMessages('install'); + break; + + case STEP_DATABASE: + $config = unserialize($session->getData('config')); + if (isset($config['global']['database'])) { + $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', + 'port' => 'text', + 'user' => 'text', + 'password' => 'text', + 'dbname' => 'text', + 'prefix' => 'text', + )); + $form->setRequest($request); + $form->populate(); + + if (!$form->validate()) { + $session->setData('step', STEP_DATABASE); + $session->setFormData($request->getAllDatas()); + $response->setRedirect(Wootook::getStaticUrl('install/index.php', array('mode' => 'install', 'step' => STEP_DATABASE))); + $response->sendHeaders(); + exit(0); + } + + if ($request->getPost('test')) { + $data = array( + 'status' => 'pending', + 'message' => '' + ); + + try { + $hostname = $request->getPost('host'); + $username = $request->getPost('user'); + $password = $request->getPost('password'); + $database = $request->getPost('dbname'); + $port = $request->getPost('port'); + + $connection = new Wootook_Core_Database_Adapter_Pdo_Mysql("mysql:dbname={$database};host={$hostname};port={$port}", $username, $password); + $data['status'] = 'success'; + } catch (PDOException $e) { + $data['status'] = 'error'; + $data['message'] = $e->getMessage(); + } + + Wootook_Core_ErrorProfiler::unregister(true); + $response->setHeader('Content-Type', 'application/json'); + $response->setBody(json_encode($data)); + + $response->sendHeaders(); + echo $response->sendBody(); + exit(0); + } + + $config = unserialize($session->getData('config')); + $config['global']['resource']['database'] = array( + 'default' => array( + 'engine' => 'pdo.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'), + ), + 'core_setup' => array( + 'use' => 'default' + ), + 'core_read' => array( + 'use' => 'default' + ), + 'core_write' => array( + 'use' => 'default' + ), + ); + $session->setData('config', serialize($config)); + + $session->setData('step', STEP_UNIVERSE); + $response->setRedirect(Wootook::getStaticUrl('install/index.php', array('mode' => 'install', 'step' => STEP_UNIVERSE))); + $response->sendHeaders(); + exit(0); + } + + $layout->load('install.step.database'); + $layout->getMessagesBlock()->prepareMessages('install'); + break; + + case STEP_UNIVERSE: + if ($request->isPost()) { + $form = new Wootook_Core_Form($session, array( + 'galaxies' => 'text', + 'systems' => 'text', + 'positions' => 'text', + + 'allow_spy_drone_attacks' => 'text', + 'use_large_numbers' => 'text' + )); + $form->setRequest($request); + $form->populate(); + + if (!$form->validate()) { + $session->setData('step', STEP_UNIVERSE); + $session->setFormData($request->getAllDatas()); + $response->setRedirect(Wootook::getStaticUrl('install/index.php', array('mode' => 'install', 'step' => STEP_PROFILE))); + $response->sendHeaders(); + exit(0); + } + + $config = unserialize($session->getData('config')); + $config['default'] = array( + 'engine' => array( + 'core' => array( + 'use_large_numbers' => (bool) $request->getPost('use_large_numbers') + ), + 'universe' => array( + 'galaxies' => $request->getPost('galaxies'), + 'systems' => $request->getPost('systems'), + 'positions' => $request->getPost('positions') + ), + 'combat' => array( + 'allow_spy_drone_attacks' => (bool) $request->getPost('allow_spy_drone_attacks') + ) + ), + ); + $session->setData('config', serialize($config)); + $writer = new Wootook_Core_Config_Adapter_Array(); + $writer->setData($config); + $writer->save(APPLICATION_PATH . 'configs' . DIRECTORY_SEPARATOR . 'local.php'); + + Wootook::loadConfig(array_merge_recursive($writer->toArray(), $configRewrites)); + + $galaxyCount = Wootook::getConfig('engine/universe/galaxies'); + $systemCount = Wootook::getConfig('engine/universe/systems'); + + $gameplays = include dirname(__FILE__) . DIRECTORY_SEPARATOR . 'gameplays.php'; + $gameplayKey = Wootook::getConfig('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) { + $session->addError($e->getMessage()); + Wootook_Core_ErrorProfiler::getSingleton()->exceptionManager($e); + + $response->setRedirect(Wootook::getStaticUrl('install/index.php', array('mode' => 'install', 'step' => STEP_UNIVERSE))); + $response->sendHeaders(); + exit(0); + break; + } + } + $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::getStaticUrl('install/index.php', array('mode' => 'install', 'step' => STEP_PROFILE))); + $response->sendHeaders(); + exit(0); + } + + $layout->load('install.step.universe'); + $layout->getMessagesBlock()->prepareMessages('install'); + break; + + case STEP_PROFILE: + if ($request->isPost()) { + $form = new Wootook_Core_Form($session, array( + 'username' => 'text', + 'email' => 'text', + 'email_confirm' => 'text', + 'password' => 'text', + 'password_confirm' => 'text', + )); + $form->setRequest($request); + $form->populate(); + + if (!$form->validate()) { + $session->setData('step', STEP_PROFILE); + $session->setFormData($request->getAllDatas()); + $session->addError(Wootook::__('Form data error.')); + $response->setRedirect(Wootook::getStaticUrl('install/index.php', array('mode' => 'install', 'step' => STEP_PROFILE))); + $response->sendHeaders(); + exit(0); + } + + if ($request->getPost('password') != $request->getPost('password_confirm')) { + $session->setData('step', STEP_PROFILE); + $session->setFormData($request->getAllDatas()); + $session->addError(Wootook::__('Passwords does not match.')); + $response->setRedirect(Wootook::getStaticUrl('install/index.php', array('mode' => 'install', 'step' => STEP_PROFILE))); + $response->sendHeaders(); + exit(0); + } + + if ($request->getPost('email') != $request->getPost('email_confirm')) { + $session->setData('step', STEP_PROFILE); + $session->setFormData($request->getAllDatas()); + $session->addError(Wootook::__('Both e-mails does not match.')); + $response->setRedirect(Wootook::getStaticUrl('install/index.php', array('mode' => 'install', 'step' => STEP_PROFILE))); + $response->sendHeaders(); + exit(0); + } + + try { + $user = Wootook_Player_Model_Entity::register($request->getPost('username'), $request->getPost('email'), $request->getPost('password')); + } catch (Wootook_Empire_Exception_RuntimeException $e) { + } + + $layout->getMessagesBlock()->prepareMessages('user'); + if (!$user || !$user->getId()) { + $session->setData('step', STEP_PROFILE); + $session->setFormData($request->getAllDatas()); + $session->addError(Wootook::__('Could not create user.')); + $response->setRedirect(Wootook::getStaticUrl('install/index.php', array('mode' => 'install', 'step' => STEP_PROFILE))); + $response->sendHeaders(); + exit(0); + } else { + Wootook_Player_Model_Session::getSingleton()->setLoggedIn($user); + + $user->setData('authlevel', LEVEL_ADMIN)->save(); + + $user->getHomePlanet()->setName(Wootook::__('Planet'))->save(); + } + + $session->setData('step', STEP_CONFIG); + $response->setRedirect(Wootook::getStaticUrl('install/index.php', array('mode' => 'install', 'step' => STEP_CONFIG))); + $response->setRedirect(Wootook::getStaticUrl('install/index.php', array('mode' => 'summary'))); + $response->sendHeaders(); + exit(0); + } + + $layout->load('install.step.profile'); + $layout->getMessagesBlock()->prepareMessages('install'); + break; + + case STEP_CONFIG: + //* + $response->setRedirect(Wootook::getStaticUrl('install/index.php', array('mode' => 'summary'))); + $response->sendHeaders(); + exit(0); + /*/ + if ($request->isPost()) { + $session->setData('step', $step); + $response->setRedirect("?mode=install&step={$nextStep}"); + $response->sendHeaders(); + exit(0); + } + + $layout->getMessagesBlock()->prepareMessages('install'); + $layout->load('install.step.config'); + //*/ + break; + } + break; +case 'summary': + $layout->load('install.summary'); + $layout->getMessagesBlock()->prepareMessages('install'); + break; +} +echo $layout->render(); diff --git a/install/migration.mysql b/src/install/migration.mysql similarity index 79% rename from install/migration.mysql rename to src/install/migration.mysql index 2c4dcc5..25b67e5 100644 --- a/install/migration.mysql +++ b/src/install/migration.mysql @@ -15,4 +15,11 @@ ALTER TABLE `game_planets` CHANGE `crystal_mine_porcent` `cristal_mine_porcent` INT( 11 ) NOT NULL DEFAULT '10'; ALTER TABLE `game_messages` - ADD `message_read_at` INT UNSIGNED NOT NULL AFTER `message_time`; \ No newline at end of file + ADD `message_read_at` INT UNSIGNED NOT NULL AFTER `message_time`; + +ALTER TABLE `game_users` + `last_update` `last_update` DATETIME NOT NULL, + `b_building` `b_building` DATETIME NOT NULL, + `b_tech` `b_tech` DATETIME NOT NULL, + `b_tech_id` `b_tech_id` TEXT NOT NULL, + `b_hangar` `b_hangar` DATETIME NOT NULL; diff --git a/jumpgate.php b/src/jumpgate.php similarity index 94% rename from jumpgate.php rename to src/jumpgate.php index cfa43f8..d4da63e 100644 --- a/jumpgate.php +++ b/src/jumpgate.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,13 +24,13 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); -require_once dirname(__FILE__) .'/common.php'; +require_once dirname(__FILE__) .'/application/bootstrap.php'; function DoFleetJump ( $CurrentUser, $CurrentPlanet ) { global $lang, $resource; diff --git a/language/en/admin.mo b/src/language/en/admin.mo similarity index 95% rename from language/en/admin.mo rename to src/language/en/admin.mo index 56f70dd..12ea558 100644 --- a/language/en/admin.mo +++ b/src/language/en/admin.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/admin/Queries.mo b/src/language/en/admin/Queries.mo similarity index 82% rename from language/en/admin/Queries.mo rename to src/language/en/admin/Queries.mo index b0f22a9..f7dafe4 100644 --- a/language/en/admin/Queries.mo +++ b/src/language/en/admin/Queries.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/admin/add_fleet.mo b/src/language/en/admin/add_fleet.mo similarity index 83% rename from language/en/admin/add_fleet.mo rename to src/language/en/admin/add_fleet.mo index eb6375e..d859d34 100644 --- a/language/en/admin/add_fleet.mo +++ b/src/language/en/admin/add_fleet.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/admin/addmoon.mo b/src/language/en/admin/addmoon.mo similarity index 82% rename from language/en/admin/addmoon.mo rename to src/language/en/admin/addmoon.mo index 76cbf64..c8c08e9 100644 --- a/language/en/admin/addmoon.mo +++ b/src/language/en/admin/addmoon.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/admin/adminpanel.mo b/src/language/en/admin/adminpanel.mo similarity index 89% rename from language/en/admin/adminpanel.mo rename to src/language/en/admin/adminpanel.mo index e02fb1c..27e814c 100644 --- a/language/en/admin/adminpanel.mo +++ b/src/language/en/admin/adminpanel.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/src/language/en/admin/banned.mo b/src/language/en/admin/banned.mo new file mode 100644 index 0000000..01f6d62 --- /dev/null +++ b/src/language/en/admin/banned.mo @@ -0,0 +1,49 @@ + + * Copyright (c) 2011-Present, Wootook Contributors + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License + * along with this program. If not, see . + * + * --> 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. + * + */ + + +$lang['ip_ban_sys'] = 'IP banning system'; +$lang['nr'] = 'Number'; +$lang['IP'] = 'IP'; +$lang['cause'] = 'Reason'; +$lang['ban_time'] = 'Duration'; +$lang['ip_ban'] = 'IP Ban'; +$lang['add_ip_ban_ok'] = 'The IP address %s was successfully banned.'; +$lang['add_ip_ban'] = 'Add IP address'; +$lang['addb'] = 'Add'; +$lang['rem_ip_ban_ok'] = 'The IP address %s was successfully removed.'; +$lang['rem_ip_ban'] = 'Remove IP address'; +$lang['remb'] = 'Remove'; +$lang['error'] = 'Error'; +$lang['add_no_ip'] = 'You should add at least one IP address'; +$lang['rem_no_ip'] = 'You should select which IP address to remove'; +$lang['no_admin'] = 'You are not an administrator or you dont have the right permissions.'; +?> \ No newline at end of file diff --git a/language/en/admin/changepass.mo b/src/language/en/admin/changepass.mo similarity index 81% rename from language/en/admin/changepass.mo rename to src/language/en/admin/changepass.mo index 6aa37e6..3a61667 100644 --- a/language/en/admin/changepass.mo +++ b/src/language/en/admin/changepass.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/admin/fleets.mo b/src/language/en/admin/fleets.mo similarity index 83% rename from language/en/admin/fleets.mo rename to src/language/en/admin/fleets.mo index b407989..2504167 100644 --- a/language/en/admin/fleets.mo +++ b/src/language/en/admin/fleets.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/admin/md5enc.mo b/src/language/en/admin/md5enc.mo similarity index 81% rename from language/en/admin/md5enc.mo rename to src/language/en/admin/md5enc.mo index 7527f25..5fad3ec 100644 --- a/language/en/admin/md5enc.mo +++ b/src/language/en/admin/md5enc.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/admin/messagelist.mo b/src/language/en/admin/messagelist.mo similarity index 87% rename from language/en/admin/messagelist.mo rename to src/language/en/admin/messagelist.mo index 05a503b..a8e1b62 100644 --- a/language/en/admin/messagelist.mo +++ b/src/language/en/admin/messagelist.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/admin/multi.mo b/src/language/en/admin/multi.mo similarity index 81% rename from language/en/admin/multi.mo rename to src/language/en/admin/multi.mo index ef1aeb2..14c9bae 100644 --- a/language/en/admin/multi.mo +++ b/src/language/en/admin/multi.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/index.php b/src/language/en/admin/server.mo similarity index 65% rename from index.php rename to src/language/en/admin/server.mo index a58d9f2..df07596 100644 --- a/index.php +++ b/src/language/en/admin/server.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,13 +25,12 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ -if (filesize('config.php') == 0) { - header('location: install/'); - exit(); -} - -header('location: frames.php'); +$lang['server_information'] = 'Server information'; +$lang['serverip'] = 'Server IP address'; +$lang['server_software'] ='Server software'; +$lang['server_system'] = ' Server operating system'; +$lang['php_version'] = 'PHP version'; diff --git a/language/en/admin/settings.mo b/src/language/en/admin/settings.mo similarity index 92% rename from language/en/admin/settings.mo rename to src/language/en/admin/settings.mo index 93d8dae..c1f0333 100644 --- a/language/en/admin/settings.mo +++ b/src/language/en/admin/settings.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/admin/statconfig.mo b/src/language/en/admin/statconfig.mo similarity index 82% rename from language/en/admin/statconfig.mo rename to src/language/en/admin/statconfig.mo index 197af7d..3604b13 100644 --- a/language/en/admin/statconfig.mo +++ b/src/language/en/admin/statconfig.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/alliance.mo b/src/language/en/alliance.mo similarity index 95% rename from language/en/alliance.mo rename to src/language/en/alliance.mo index 5aa343a..4dc5ba0 100644 --- a/language/en/alliance.mo +++ b/src/language/en/alliance.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/src/language/en/announce.mo b/src/language/en/announce.mo new file mode 100644 index 0000000..3a19f0b --- /dev/null +++ b/src/language/en/announce.mo @@ -0,0 +1,52 @@ + + * Copyright (c) 2011-Present, Wootook Contributors + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License + * along with this program. If not, see . + * + * --> 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. + * + */ + +$lang['add_announce'] = 'Add an trade'; +$lang['metal'] = 'Metal'; +$lang['crystal'] = 'Crystal'; +$lang['deuterium'] = 'Deuterium'; +$lang['Resources_to_be_sold'] = 'Resources to be sold'; +$lang['Desired_resources'] = 'Wanted resources'; +$lang['send'] = 'Send'; +$lang['Your_announce_was_recorded'] = 'Your trade was sent successfully'; +$lang['return_to_announce'] = 'Return to trade'; +$lang['Classifieds'] = 'Published trade'; +$lang['Action'] = 'Action'; +$lang['Galaxy'] = 'Galaxy'; +$lang['Solar_system'] = 'Solar system'; +$lang['Infos_of_delivery'] = 'trader information'; +$lang['Salesman'] = 'User'; +$lang['Delete'] = 'Delete'; +$lang['announce_status'] = 'Announce status'; +$lang['Your_announce_not_recorded'] = 'Your trade was not sent'; +$lang['Your_announce_was_deleted'] = 'Your trade was successfully deleted'; + +?> diff --git a/language/en/banned.mo b/src/language/en/banned.mo similarity index 82% rename from language/en/banned.mo rename to src/language/en/banned.mo index 7ab1bd8..a66b2a4 100644 --- a/language/en/banned.mo +++ b/src/language/en/banned.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/buddy.mo b/src/language/en/buddy.mo similarity index 88% rename from language/en/buddy.mo rename to src/language/en/buddy.mo index 78c5e3a..cfa1b88 100644 --- a/language/en/buddy.mo +++ b/src/language/en/buddy.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/buildings.mo b/src/language/en/buildings.mo similarity index 90% rename from language/en/buildings.mo rename to src/language/en/buildings.mo index 6c9e5a0..3814baa 100644 --- a/language/en/buildings.mo +++ b/src/language/en/buildings.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/changelog.mo b/src/language/en/changelog.mo similarity index 97% rename from language/en/changelog.mo rename to src/language/en/changelog.mo index 279486e..7892663 100644 --- a/language/en/changelog.mo +++ b/src/language/en/changelog.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/chat.mo b/src/language/en/chat.mo similarity index 81% rename from language/en/chat.mo rename to src/language/en/chat.mo index 8106fce..8ebdbf1 100644 --- a/language/en/chat.mo +++ b/src/language/en/chat.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/contact.mo b/src/language/en/contact.mo similarity index 81% rename from language/en/contact.mo rename to src/language/en/contact.mo index 5376b35..7d0e97c 100644 --- a/language/en/contact.mo +++ b/src/language/en/contact.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/cookies.mo b/src/language/en/cookies.mo similarity index 84% rename from language/en/cookies.mo rename to src/language/en/cookies.mo index a7217dd..6bfa294 100644 --- a/language/en/cookies.mo +++ b/src/language/en/cookies.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/credit.mo b/src/language/en/credit.mo similarity index 89% rename from language/en/credit.mo rename to src/language/en/credit.mo index 84c14b3..3bfa590 100644 --- a/language/en/credit.mo +++ b/src/language/en/credit.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/fleet.mo b/src/language/en/fleet.mo similarity index 95% rename from language/en/fleet.mo rename to src/language/en/fleet.mo index 93b768b..74261a4 100644 --- a/language/en/fleet.mo +++ b/src/language/en/fleet.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/galaxy.mo b/src/language/en/galaxy.mo similarity index 95% rename from language/en/galaxy.mo rename to src/language/en/galaxy.mo index 4928fb9..a4f100c 100644 --- a/language/en/galaxy.mo +++ b/src/language/en/galaxy.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/imperium.mo b/src/language/en/imperium.mo similarity index 84% rename from language/en/imperium.mo rename to src/language/en/imperium.mo index ea48cc3..2794c6e 100644 --- a/language/en/imperium.mo +++ b/src/language/en/imperium.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/index.mo b/src/language/en/index.mo similarity index 79% rename from language/en/index.mo rename to src/language/en/index.mo index de56c28..823ad29 100644 --- a/language/en/index.mo +++ b/src/language/en/index.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/infos.mo b/src/language/en/infos.mo similarity index 99% rename from language/en/infos.mo rename to src/language/en/infos.mo index 541e0b9..03379ee 100644 --- a/language/en/infos.mo +++ b/src/language/en/infos.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/install/install.mo b/src/language/en/install/install.mo similarity index 94% rename from language/en/install/install.mo rename to src/language/en/install/install.mo index 06707bf..a0441a1 100644 --- a/language/en/install/install.mo +++ b/src/language/en/install/install.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/it/lang_info.cfg b/src/language/en/lang_info.cfg similarity index 75% rename from language/it/lang_info.cfg rename to src/language/en/lang_info.cfg index c108461..127828b 100644 --- a/language/it/lang_info.cfg +++ b/src/language/en/lang_info.cfg @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,10 +25,10 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ $langInfos['ENCODING'] = 'UTF-8'; -$langInfos['DIRECTION'] = 'http://www.xnova-ng.org/'; +$langInfos['DIRECTION'] = 'http://wootook.org/'; diff --git a/language/en/leftmenu.mo b/src/language/en/leftmenu.mo similarity index 93% rename from language/en/leftmenu.mo rename to src/language/en/leftmenu.mo index 1ddf9a4..b25378e 100644 --- a/language/en/leftmenu.mo +++ b/src/language/en/leftmenu.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/login.mo b/src/language/en/login.mo similarity index 88% rename from language/en/login.mo rename to src/language/en/login.mo index 1077cc5..74e3f8f 100644 --- a/language/en/login.mo +++ b/src/language/en/login.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/logout.mo b/src/language/en/logout.mo similarity index 79% rename from language/en/logout.mo rename to src/language/en/logout.mo index 32a674d..4220433 100644 --- a/language/en/logout.mo +++ b/src/language/en/logout.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/lostpassword.mo b/src/language/en/lostpassword.mo similarity index 83% rename from language/en/lostpassword.mo rename to src/language/en/lostpassword.mo index 9b721cb..215f011 100644 --- a/language/en/lostpassword.mo +++ b/src/language/en/lostpassword.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/marchand.mo b/src/language/en/marchand.mo similarity index 84% rename from language/en/marchand.mo rename to src/language/en/marchand.mo index adfd975..61953f2 100644 --- a/language/en/marchand.mo +++ b/src/language/en/marchand.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/messages.mo b/src/language/en/messages.mo similarity index 91% rename from language/en/messages.mo rename to src/language/en/messages.mo index f87e8c9..e9bc612 100644 --- a/language/en/messages.mo +++ b/src/language/en/messages.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/news.mo b/src/language/en/news.mo similarity index 77% rename from language/en/news.mo rename to src/language/en/news.mo index cf233c5..77ec2c7 100644 --- a/language/en/news.mo +++ b/src/language/en/news.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/notes.mo b/src/language/en/notes.mo similarity index 88% rename from language/en/notes.mo rename to src/language/en/notes.mo index 1cf1edf..3a4acad 100644 --- a/language/en/notes.mo +++ b/src/language/en/notes.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/officier.mo b/src/language/en/officier.mo similarity index 96% rename from language/en/officier.mo rename to src/language/en/officier.mo index 1a3181f..25bb17f 100644 --- a/language/en/officier.mo +++ b/src/language/en/officier.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/options.mo b/src/language/en/options.mo similarity index 93% rename from language/en/options.mo rename to src/language/en/options.mo index 737973c..ae04b29 100644 --- a/language/en/options.mo +++ b/src/language/en/options.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/overview.mo b/src/language/en/overview.mo similarity index 94% rename from language/en/overview.mo rename to src/language/en/overview.mo index e1faa7b..cfc4d88 100644 --- a/language/en/overview.mo +++ b/src/language/en/overview.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/phalanx.mo b/src/language/en/phalanx.mo similarity index 88% rename from language/en/phalanx.mo rename to src/language/en/phalanx.mo index 05ad31f..6b7a073 100644 --- a/language/en/phalanx.mo +++ b/src/language/en/phalanx.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/player.mo b/src/language/en/player.mo similarity index 80% rename from language/en/player.mo rename to src/language/en/player.mo index 8fa7837..c486a8a 100644 --- a/language/en/player.mo +++ b/src/language/en/player.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/records.mo b/src/language/en/records.mo similarity index 82% rename from language/en/records.mo rename to src/language/en/records.mo index 56ce54a..22b4e51 100644 --- a/language/en/records.mo +++ b/src/language/en/records.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/reg.mo b/src/language/en/reg.mo similarity index 92% rename from language/en/reg.mo rename to src/language/en/reg.mo index 4f0ae19..b3a3891 100644 --- a/language/en/reg.mo +++ b/src/language/en/reg.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/resources.mo b/src/language/en/resources.mo similarity index 85% rename from language/en/resources.mo rename to src/language/en/resources.mo index 4134ec3..9c0e91c 100644 --- a/language/en/resources.mo +++ b/src/language/en/resources.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/fr/rules.mo b/src/language/en/rules.mo similarity index 97% rename from language/fr/rules.mo rename to src/language/en/rules.mo index fe2e1bd..7b41113 100644 --- a/language/fr/rules.mo +++ b/src/language/en/rules.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/search.mo b/src/language/en/search.mo similarity index 86% rename from language/en/search.mo rename to src/language/en/search.mo index 37ecdb9..1367738 100644 --- a/language/en/search.mo +++ b/src/language/en/search.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/stat.mo b/src/language/en/stat.mo similarity index 86% rename from language/en/stat.mo rename to src/language/en/stat.mo index 6d3c5a6..2ada9dd 100644 --- a/language/en/stat.mo +++ b/src/language/en/stat.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/src/language/en/supp.mo b/src/language/en/supp.mo new file mode 100644 index 0000000..0ca8f96 --- /dev/null +++ b/src/language/en/supp.mo @@ -0,0 +1,52 @@ + + * Copyright (c) 2011-Present, Wootook Contributors + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License + * along with this program. If not, see . + * + * --> 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. + * + */ + +$lang['supp_header'] = "Suport"; +$lang['ticket_id'] = "#Ticket-ID"; +$lang['subject'] = "Subject"; +$lang['status'] = "Status"; +$lang['ticket_posted'] = "Posted in:"; +$lang['ticket_new'] = "New Ticket"; +$lang['input_text'] = "Problem description:"; +$lang['answer_new'] = "Answer:"; +$lang['text'] = "Text:"; +$lang['message_a'] = "Message status:"; +$lang['sendit_a'] = "Your message was sent"; +$lang['message_t'] = "Ticket status:"; +$lang['sendit_t'] = "The ticket was sent."; +$lang['close_t'] = "The ticket was closed."; +$lang['sendit_error'] = "Error:"; +$lang['sendit_error_msg'] = "You didnt fill all the data!"; +$lang['supp_admin_system'] = "Support System Administration"; +$lang['close_ticket'] = "Close Ticket"; +$lang['player'] = "Player"; +$lang['input_text'] = "Send"; + diff --git a/language/en/system.mo b/src/language/en/system.mo similarity index 96% rename from language/en/system.mo rename to src/language/en/system.mo index ea4b1b4..8d87972 100644 --- a/language/en/system.mo +++ b/src/language/en/system.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/tech.mo b/src/language/en/tech.mo similarity index 97% rename from language/en/tech.mo rename to src/language/en/tech.mo index 2735e27..b0e42c2 100644 --- a/language/en/tech.mo +++ b/src/language/en/tech.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/en/tradingscrapmetal.mo b/src/language/en/tradingscrapmetal.mo similarity index 83% rename from language/en/tradingscrapmetal.mo rename to src/language/en/tradingscrapmetal.mo index 8dfb3aa..557e6f8 100644 --- a/language/en/tradingscrapmetal.mo +++ b/src/language/en/tradingscrapmetal.mo @@ -1,11 +1,12 @@ + * Copyright (c) 2009-2011, XNova Support Team + * Copyright (c) 2011-Present, Wootook Contributors * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +25,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/language/fr/admin.mo b/src/language/fr/admin.mo similarity index 97% rename from language/fr/admin.mo rename to src/language/fr/admin.mo index de630c6..07f8d7d 100644 --- a/language/fr/admin.mo +++ b/src/language/fr/admin.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/admin/Queries.mo b/src/language/fr/admin/Queries.mo similarity index 90% rename from language/fr/admin/Queries.mo rename to src/language/fr/admin/Queries.mo index 5cdcc79..027d4eb 100644 --- a/language/fr/admin/Queries.mo +++ b/src/language/fr/admin/Queries.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/admin/add_fleet.mo b/src/language/fr/admin/add_fleet.mo similarity index 91% rename from language/fr/admin/add_fleet.mo rename to src/language/fr/admin/add_fleet.mo index 9e83418..9cd8c57 100644 --- a/language/fr/admin/add_fleet.mo +++ b/src/language/fr/admin/add_fleet.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/admin/addmoon.mo b/src/language/fr/admin/addmoon.mo similarity index 90% rename from language/fr/admin/addmoon.mo rename to src/language/fr/admin/addmoon.mo index 8d0b3a2..a4b3c12 100644 --- a/language/fr/admin/addmoon.mo +++ b/src/language/fr/admin/addmoon.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/admin/adminpanel.mo b/src/language/fr/admin/adminpanel.mo similarity index 94% rename from language/fr/admin/adminpanel.mo rename to src/language/fr/admin/adminpanel.mo index 0103779..ac724ef 100644 --- a/language/fr/admin/adminpanel.mo +++ b/src/language/fr/admin/adminpanel.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/admin/changepass.mo b/src/language/fr/admin/changepass.mo similarity index 89% rename from language/fr/admin/changepass.mo rename to src/language/fr/admin/changepass.mo index 47a9159..1061e77 100644 --- a/language/fr/admin/changepass.mo +++ b/src/language/fr/admin/changepass.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/admin/fleets.mo b/src/language/fr/admin/fleets.mo similarity index 90% rename from language/fr/admin/fleets.mo rename to src/language/fr/admin/fleets.mo index 897af77..8c4407b 100644 --- a/language/fr/admin/fleets.mo +++ b/src/language/fr/admin/fleets.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/admin/md5enc.mo b/src/language/fr/admin/md5enc.mo similarity index 89% rename from language/fr/admin/md5enc.mo rename to src/language/fr/admin/md5enc.mo index 951d587..4310a13 100644 --- a/language/fr/admin/md5enc.mo +++ b/src/language/fr/admin/md5enc.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/admin/messagelist.mo b/src/language/fr/admin/messagelist.mo similarity index 93% rename from language/fr/admin/messagelist.mo rename to src/language/fr/admin/messagelist.mo index e52e2a3..139d58f 100644 --- a/language/fr/admin/messagelist.mo +++ b/src/language/fr/admin/messagelist.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/admin/multi.mo b/src/language/fr/admin/multi.mo similarity index 89% rename from language/fr/admin/multi.mo rename to src/language/fr/admin/multi.mo index 68e6117..b4ce801 100644 --- a/language/fr/admin/multi.mo +++ b/src/language/fr/admin/multi.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/admin/settings.mo b/src/language/fr/admin/settings.mo similarity index 96% rename from language/fr/admin/settings.mo rename to src/language/fr/admin/settings.mo index 5bae71e..c853b04 100644 --- a/language/fr/admin/settings.mo +++ b/src/language/fr/admin/settings.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/admin/statconfig.mo b/src/language/fr/admin/statconfig.mo similarity index 90% rename from language/fr/admin/statconfig.mo rename to src/language/fr/admin/statconfig.mo index 3860b3a..f491b9d 100644 --- a/language/fr/admin/statconfig.mo +++ b/src/language/fr/admin/statconfig.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/alliance.mo b/src/language/fr/alliance.mo similarity index 97% rename from language/fr/alliance.mo rename to src/language/fr/alliance.mo index b68fa8a..7bf1a57 100644 --- a/language/fr/alliance.mo +++ b/src/language/fr/alliance.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/banned.mo b/src/language/fr/banned.mo similarity index 90% rename from language/fr/banned.mo rename to src/language/fr/banned.mo index 42ae83e..83d26dc 100644 --- a/language/fr/banned.mo +++ b/src/language/fr/banned.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/buddy.mo b/src/language/fr/buddy.mo similarity index 93% rename from language/fr/buddy.mo rename to src/language/fr/buddy.mo index 122747f..a4c2bab 100644 --- a/language/fr/buddy.mo +++ b/src/language/fr/buddy.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/buildings.mo b/src/language/fr/buildings.mo similarity index 95% rename from language/fr/buildings.mo rename to src/language/fr/buildings.mo index 6a7d773..c09a12b 100644 --- a/language/fr/buildings.mo +++ b/src/language/fr/buildings.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/changelog.mo b/src/language/fr/changelog.mo similarity index 98% rename from language/fr/changelog.mo rename to src/language/fr/changelog.mo index 5ca9a0e..773f39a 100644 --- a/language/fr/changelog.mo +++ b/src/language/fr/changelog.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/chat.mo b/src/language/fr/chat.mo similarity index 89% rename from language/fr/chat.mo rename to src/language/fr/chat.mo index 95f0930..c18d215 100644 --- a/language/fr/chat.mo +++ b/src/language/fr/chat.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/contact.mo b/src/language/fr/contact.mo similarity index 89% rename from language/fr/contact.mo rename to src/language/fr/contact.mo index 3e0c3ab..9828f1f 100644 --- a/language/fr/contact.mo +++ b/src/language/fr/contact.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/cookies.mo b/src/language/fr/cookies.mo similarity index 91% rename from language/fr/cookies.mo rename to src/language/fr/cookies.mo index bf21928..a291668 100644 --- a/language/fr/cookies.mo +++ b/src/language/fr/cookies.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/credit.mo b/src/language/fr/credit.mo similarity index 94% rename from language/fr/credit.mo rename to src/language/fr/credit.mo index 97973e3..4caf669 100644 --- a/language/fr/credit.mo +++ b/src/language/fr/credit.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/fleet.mo b/src/language/fr/fleet.mo similarity index 97% rename from language/fr/fleet.mo rename to src/language/fr/fleet.mo index 5d4b982..cf96255 100644 --- a/language/fr/fleet.mo +++ b/src/language/fr/fleet.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/galaxy.mo b/src/language/fr/galaxy.mo similarity index 97% rename from language/fr/galaxy.mo rename to src/language/fr/galaxy.mo index afd35fd..c6c99ff 100644 --- a/language/fr/galaxy.mo +++ b/src/language/fr/galaxy.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/imperium.mo b/src/language/fr/imperium.mo similarity index 91% rename from language/fr/imperium.mo rename to src/language/fr/imperium.mo index eb4c51b..9b988a8 100644 --- a/language/fr/imperium.mo +++ b/src/language/fr/imperium.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/index.mo b/src/language/fr/index.mo similarity index 88% rename from language/fr/index.mo rename to src/language/fr/index.mo index b4c66a4..5ed998d 100644 --- a/language/fr/index.mo +++ b/src/language/fr/index.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/infos.mo b/src/language/fr/infos.mo similarity index 99% rename from language/fr/infos.mo rename to src/language/fr/infos.mo index 26dcd69..43bc366 100644 --- a/language/fr/infos.mo +++ b/src/language/fr/infos.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/install/install.mo b/src/language/fr/install/install.mo similarity index 96% rename from language/fr/install/install.mo rename to src/language/fr/install/install.mo index 61bbaa8..5fa5b67 100644 --- a/language/fr/install/install.mo +++ b/src/language/fr/install/install.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/en/lang_info.cfg b/src/language/fr/lang_info.cfg similarity index 83% rename from language/en/lang_info.cfg rename to src/language/fr/lang_info.cfg index c108461..910fb92 100644 --- a/language/en/lang_info.cfg +++ b/src/language/fr/lang_info.cfg @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -30,4 +30,4 @@ $langInfos['ENCODING'] = 'UTF-8'; -$langInfos['DIRECTION'] = 'http://www.xnova-ng.org/'; +$langInfos['DIRECTION'] = 'http://wootook.org/'; diff --git a/language/fr/leftmenu.mo b/src/language/fr/leftmenu.mo similarity index 96% rename from language/fr/leftmenu.mo rename to src/language/fr/leftmenu.mo index bf5474f..1521577 100644 --- a/language/fr/leftmenu.mo +++ b/src/language/fr/leftmenu.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/login.mo b/src/language/fr/login.mo similarity index 94% rename from language/fr/login.mo rename to src/language/fr/login.mo index 9df9d70..fea0730 100644 --- a/language/fr/login.mo +++ b/src/language/fr/login.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/logout.mo b/src/language/fr/logout.mo similarity index 88% rename from language/fr/logout.mo rename to src/language/fr/logout.mo index c0894ac..9e60a92 100644 --- a/language/fr/logout.mo +++ b/src/language/fr/logout.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/lostpassword.mo b/src/language/fr/lostpassword.mo similarity index 91% rename from language/fr/lostpassword.mo rename to src/language/fr/lostpassword.mo index acb7523..d073e28 100644 --- a/language/fr/lostpassword.mo +++ b/src/language/fr/lostpassword.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/marchand.mo b/src/language/fr/marchand.mo similarity index 91% rename from language/fr/marchand.mo rename to src/language/fr/marchand.mo index e9f9208..5abb1c6 100644 --- a/language/fr/marchand.mo +++ b/src/language/fr/marchand.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/messages.mo b/src/language/fr/messages.mo similarity index 95% rename from language/fr/messages.mo rename to src/language/fr/messages.mo index 23f5cd0..6623e1e 100644 --- a/language/fr/messages.mo +++ b/src/language/fr/messages.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/news.mo b/src/language/fr/news.mo similarity index 87% rename from language/fr/news.mo rename to src/language/fr/news.mo index cf233c5..9536fac 100644 --- a/language/fr/news.mo +++ b/src/language/fr/news.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/notes.mo b/src/language/fr/notes.mo similarity index 93% rename from language/fr/notes.mo rename to src/language/fr/notes.mo index b7c1d23..6de6d3c 100644 --- a/language/fr/notes.mo +++ b/src/language/fr/notes.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/officier.mo b/src/language/fr/officier.mo similarity index 98% rename from language/fr/officier.mo rename to src/language/fr/officier.mo index 7ec5d12..4b7d34e 100644 --- a/language/fr/officier.mo +++ b/src/language/fr/officier.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/options.mo b/src/language/fr/options.mo similarity index 97% rename from language/fr/options.mo rename to src/language/fr/options.mo index 1e0d95d..6279608 100644 --- a/language/fr/options.mo +++ b/src/language/fr/options.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/overview.mo b/src/language/fr/overview.mo similarity index 97% rename from language/fr/overview.mo rename to src/language/fr/overview.mo index 98d5098..4e213be 100644 --- a/language/fr/overview.mo +++ b/src/language/fr/overview.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/phalanx.mo b/src/language/fr/phalanx.mo similarity index 94% rename from language/fr/phalanx.mo rename to src/language/fr/phalanx.mo index cf33d0e..564ba0e 100644 --- a/language/fr/phalanx.mo +++ b/src/language/fr/phalanx.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/player.mo b/src/language/fr/player.mo similarity index 89% rename from language/fr/player.mo rename to src/language/fr/player.mo index fdc39a0..e4b0c82 100644 --- a/language/fr/player.mo +++ b/src/language/fr/player.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/records.mo b/src/language/fr/records.mo similarity index 90% rename from language/fr/records.mo rename to src/language/fr/records.mo index 93f482f..670f41c 100644 --- a/language/fr/records.mo +++ b/src/language/fr/records.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/reg.mo b/src/language/fr/reg.mo similarity index 95% rename from language/fr/reg.mo rename to src/language/fr/reg.mo index a6f75e1..e0be92b 100644 --- a/language/fr/reg.mo +++ b/src/language/fr/reg.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/resources.mo b/src/language/fr/resources.mo similarity index 92% rename from language/fr/resources.mo rename to src/language/fr/resources.mo index 8ab5e12..20d5c70 100644 --- a/language/fr/resources.mo +++ b/src/language/fr/resources.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/en/rules.mo b/src/language/fr/rules.mo similarity index 98% rename from language/en/rules.mo rename to src/language/fr/rules.mo index fe2e1bd..363a3ce 100644 --- a/language/en/rules.mo +++ b/src/language/fr/rules.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/search.mo b/src/language/fr/search.mo similarity index 92% rename from language/fr/search.mo rename to src/language/fr/search.mo index 9b65918..f94bf99 100644 --- a/language/fr/search.mo +++ b/src/language/fr/search.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/stat.mo b/src/language/fr/stat.mo similarity index 92% rename from language/fr/stat.mo rename to src/language/fr/stat.mo index e7579ab..ca48e64 100644 --- a/language/fr/stat.mo +++ b/src/language/fr/stat.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/system.mo b/src/language/fr/system.mo similarity index 98% rename from language/fr/system.mo rename to src/language/fr/system.mo index 4ac3c92..109fe93 100644 --- a/language/fr/system.mo +++ b/src/language/fr/system.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/fr/tech.mo b/src/language/fr/tech.mo similarity index 75% rename from language/fr/tech.mo rename to src/language/fr/tech.mo index bf2e1fe..eb712fa 100644 --- a/language/fr/tech.mo +++ b/src/language/fr/tech.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -52,106 +52,7 @@ $lang['type_mission'][8] = "Recycler"; $lang['type_mission'][9] = "Détruire"; $lang['type_mission'][15] = "Expéditions"; -// Short names for fight report -$lang['tech_rc'] = array ( -202 => 'P.transp.', -203 => 'G.transp.', -204 => 'Ch.léger', -205 => 'Ch.lourd', -206 => 'Croiseur', -207 => 'V.bataille', -208 => 'V.colo.', -209 => 'Recycleur', -210 => 'Sonde', -211 => 'Bombardier', -212 => 'Sat.sol.', -213 => 'Destr.', -214 => 'Rip', -215 => 'Traqueur', -216 => 'Supernova', - -401 => 'Missile', -402 => 'L.léger.', -403 => 'L.lourd', -404 => 'Can.Gauss', -405 => 'Art.ions', -406 => 'Lanc.plasma', -407 => 'P.bouclier', -408 => 'G.bouclier', -); - $lang['tech'] = array( - 0 => "Bâtiments", - 1 => "Mine de métal", - 2 => "Mine de cristal", - 3 => "Synthétiseur de deutérium", - 4 => "Centrale électrique solaire", - 12 => "Centrale électrique de fusion", - 14 => "Usine de robots", - 15 => "Usine de nanites", - 21 => "Chantier spatial", - 22 => "Hangar de métal", - 23 => "Hangar de cristal", - 24 => "Réservoir de deutérium", - 31 => "Laboratoire de recherche", - 33 => "Terraformeur", - 34 => "Dépôt de ravitaillement", - - 40 => 'Bâtiments spéciaux', - 41 => 'Base lunaire', - 42 => 'Phalange de capteur', - 43 => 'Porte de saut spatial', - - 44 => "Silo de missiles", - -// Technologies -100 => 'Recherches', -106 => 'Technologie Espionnage', -108 => 'Technologie Ordinateur', -109 => 'Technologie Armes', -110 => 'Technologie Bouclier', -111 => 'Technologie Protection des vaisseaux spatiaux', -113 => 'Technologie Energie', -114 => 'Technologie Hyperespace', -115 => 'Réacteur à combustion', -117 => 'Réacteur à impulsion', -118 => 'Propulsion hyperespace', -120 => 'Technologie Laser', -121 => 'Technologie Ions', -122 => 'Technologie Plasma', -123 => 'Réseau de recherche intergalactique', -124 => 'Technologie Expéditions', -199 => 'Technologie Graviton', - -200 => 'Vaisseaux', -202 => 'Petit transporteur', -203 => 'Grand transporteur', -204 => 'Chasseur léger', -205 => 'Chasseur lourd', -206 => 'Croiseur', -207 => 'Vaisseau de bataille', -208 => 'Vaisseau de colonisation', -209 => 'Recycleur', -210 => 'Sonde espionnage', -211 => 'Bombardier', -212 => 'Satellite solaire', -213 => 'Destructeur', -214 => 'Etoile de la mort', -215 => 'Traqueur', -216 => 'Supernova', - -400 => 'Défense', -401 => 'Lanceur de missiles', -402 => 'Artillerie laser légère', -403 => 'Artillerie laser lourde', -404 => 'Canon de Gauss', -405 => 'Artillerie à ions', -406 => 'Lanceur de plasma', -407 => 'Petit bouclier', -408 => 'Grand bouclier', -502 => 'Missile Interception', -503 => 'Missile Interplanétaire', - 600 => "Officier", 601 => "Géologue", 602 => "Amiral", @@ -168,13 +69,9 @@ $lang['tech'] = array( 613 => "General", 614 => "Raideur", 615 => "Empereur" - ); $lang['res']['descriptions'] = array( -1 => "Principal fournisseur de matières premières pour la construction de structures portantes et de vaisseaux.", -2 => "Fournisseur principal de ressources pour les installations électroniques et pour les alliages.", -3 => "Extrait la petite quantité de deutérium de l'eau d'une planète.", 4 => "Les centrales électriques solaires transforment les rayons de soleil en énergie. Presque tous les bâtiments ont besoin d'énergie pour fonctionner.", 12 => "La centrale électrique de fusion produit de l'énergie en fusionnant 2 atomes d'hydrogène en un atome d'hélium.", 14 => "Les usines de robots produisent des robots ouvriers qui servent à la construction de l'infrastructure planétaire. Chaque niveau augmente la vitesse de construction des différents bâtiments.", @@ -193,12 +90,12 @@ $lang['res']['descriptions'] = array( 106 => "Cette technologie permet d'obtenir des informations sur les autres planètes de l'univers.", 108 => "Avec l'augmentation des capacités des ordinateurs, plus de flottes peuvent être commandées. Chaque niveau de technologie ordinateur augmente d'une le nombre total de flottes commandables.", -109 => "La technologie armes rend les systèmes d'armes plus efficaces. Chaque niveau de technologie armes augmente la puissance des armes des unités par tranche de 10% de la valeur de base.", -110 => "Chaque niveau de la technologie de bouclier augmente l'efficacité des boucliers par tranche de 10%.", -111 => "Des alliages spéciaux rendent les vaisseaux spatiaux de plus en plus résistants. L'efficacité des protections peut être augmentée de 10% par niveau.", +109 => "La technologie armes rend les systèmes d'armes plus efficaces. Chaque niveau de technologie armes augmente la puissance des armes des unités par tranche de 10%% de la valeur de base.", +110 => "Chaque niveau de la technologie de bouclier augmente l'efficacité des boucliers par tranche de 10%%.", +111 => "Des alliages spéciaux rendent les vaisseaux spatiaux de plus en plus résistants. L'efficacité des protections peut être augmentée de 10%% par niveau.", 113 => "Maîtriser les différents types d'énergie est nécessaire pour de nombreuses technologies.", 114 => "L'intégration de la 4eme et de la 5eme dimension permet le développement d'un nouveau genre de propulsion plus puissant et efficace.", -115 => "Le développement de ces réacteurs rend les vaisseaux plus rapides mais chaque niveau n'augmente la vitesse que de 10%.", +115 => "Le développement de ces réacteurs rend les vaisseaux plus rapides mais chaque niveau n'augmente la vitesse que de 10%%.", 117 => "Le réacteur à impulsion est basé sur le principe de réaction disant que la plus grande part de la masse du rayon est gagnée comme sous-produit de la fusion d'atomes qui sert à produire l'énergie nécessaire.", 118 => "Par une déformation spatiale et temporelle dans l'environnement du vaisseau, l'espace est comprimé ce qui permet de parcourir de longues distances dans un minimum de temps.", 120 => "La concentration de lumière crée un rayon pouvant créer des dégâts importants en touchant un objet.", @@ -237,4 +134,4 @@ $lang['res']['descriptions'] = array( ); -?> \ No newline at end of file +?> diff --git a/language/fr/tradingscrapmetal.mo b/src/language/fr/tradingscrapmetal.mo similarity index 90% rename from language/fr/tradingscrapmetal.mo rename to src/language/fr/tradingscrapmetal.mo index 070ebff..9cf4a10 100644 --- a/language/fr/tradingscrapmetal.mo +++ b/src/language/fr/tradingscrapmetal.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/admin.mo b/src/language/it/admin.mo similarity index 97% rename from language/it/admin.mo rename to src/language/it/admin.mo index 6b97684..dfce72a 100644 --- a/language/it/admin.mo +++ b/src/language/it/admin.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/admin/Queries.mo b/src/language/it/admin/Queries.mo similarity index 90% rename from language/it/admin/Queries.mo rename to src/language/it/admin/Queries.mo index dfb3332..1e71921 100644 --- a/language/it/admin/Queries.mo +++ b/src/language/it/admin/Queries.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/admin/add_fleet.mo b/src/language/it/admin/add_fleet.mo similarity index 91% rename from language/it/admin/add_fleet.mo rename to src/language/it/admin/add_fleet.mo index 685bdf8..08bb5e8 100644 --- a/language/it/admin/add_fleet.mo +++ b/src/language/it/admin/add_fleet.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/admin/addmoon.mo b/src/language/it/admin/addmoon.mo similarity index 90% rename from language/it/admin/addmoon.mo rename to src/language/it/admin/addmoon.mo index d33be7d..04785a4 100644 --- a/language/it/admin/addmoon.mo +++ b/src/language/it/admin/addmoon.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/admin/adminpanel.mo b/src/language/it/admin/adminpanel.mo similarity index 94% rename from language/it/admin/adminpanel.mo rename to src/language/it/admin/adminpanel.mo index 361aca1..522f129 100644 --- a/language/it/admin/adminpanel.mo +++ b/src/language/it/admin/adminpanel.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/admin/changepass.mo b/src/language/it/admin/changepass.mo similarity index 89% rename from language/it/admin/changepass.mo rename to src/language/it/admin/changepass.mo index a908cfb..cc0f75d 100644 --- a/language/it/admin/changepass.mo +++ b/src/language/it/admin/changepass.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/admin/fleets.mo b/src/language/it/admin/fleets.mo similarity index 90% rename from language/it/admin/fleets.mo rename to src/language/it/admin/fleets.mo index 579e9df..756f6e6 100644 --- a/language/it/admin/fleets.mo +++ b/src/language/it/admin/fleets.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/admin/md5enc.mo b/src/language/it/admin/md5enc.mo similarity index 89% rename from language/it/admin/md5enc.mo rename to src/language/it/admin/md5enc.mo index c69bf64..3949915 100644 --- a/language/it/admin/md5enc.mo +++ b/src/language/it/admin/md5enc.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/admin/messagelist.mo b/src/language/it/admin/messagelist.mo similarity index 93% rename from language/it/admin/messagelist.mo rename to src/language/it/admin/messagelist.mo index 780b81e..1e65f36 100644 --- a/language/it/admin/messagelist.mo +++ b/src/language/it/admin/messagelist.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/admin/multi.mo b/src/language/it/admin/multi.mo similarity index 89% rename from language/it/admin/multi.mo rename to src/language/it/admin/multi.mo index de0dff0..3ee5094 100644 --- a/language/it/admin/multi.mo +++ b/src/language/it/admin/multi.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/admin/settings.mo b/src/language/it/admin/settings.mo similarity index 96% rename from language/it/admin/settings.mo rename to src/language/it/admin/settings.mo index d6a2cf3..ddbea94 100644 --- a/language/it/admin/settings.mo +++ b/src/language/it/admin/settings.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/admin/statconfig.mo b/src/language/it/admin/statconfig.mo similarity index 89% rename from language/it/admin/statconfig.mo rename to src/language/it/admin/statconfig.mo index 0cdcd13..988e739 100644 --- a/language/it/admin/statconfig.mo +++ b/src/language/it/admin/statconfig.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/alliance.mo b/src/language/it/alliance.mo similarity index 97% rename from language/it/alliance.mo rename to src/language/it/alliance.mo index 97206ff..c2bf12a 100644 --- a/language/it/alliance.mo +++ b/src/language/it/alliance.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/banned.mo b/src/language/it/banned.mo similarity index 90% rename from language/it/banned.mo rename to src/language/it/banned.mo index db61be1..c099d8f 100644 --- a/language/it/banned.mo +++ b/src/language/it/banned.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/buddy.mo b/src/language/it/buddy.mo similarity index 93% rename from language/it/buddy.mo rename to src/language/it/buddy.mo index 30f49e4..2abb825 100644 --- a/language/it/buddy.mo +++ b/src/language/it/buddy.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/buildings.mo b/src/language/it/buildings.mo similarity index 94% rename from language/it/buildings.mo rename to src/language/it/buildings.mo index 55bcd6f..95fdc46 100644 --- a/language/it/buildings.mo +++ b/src/language/it/buildings.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/changelog.mo b/src/language/it/changelog.mo similarity index 98% rename from language/it/changelog.mo rename to src/language/it/changelog.mo index 99e7c44..0219ebc 100644 --- a/language/it/changelog.mo +++ b/src/language/it/changelog.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/chat.mo b/src/language/it/chat.mo similarity index 89% rename from language/it/chat.mo rename to src/language/it/chat.mo index f1a5013..8002453 100644 --- a/language/it/chat.mo +++ b/src/language/it/chat.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/contact.mo b/src/language/it/contact.mo similarity index 89% rename from language/it/contact.mo rename to src/language/it/contact.mo index c3e4722..e0cc908 100644 --- a/language/it/contact.mo +++ b/src/language/it/contact.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/cookies.mo b/src/language/it/cookies.mo similarity index 91% rename from language/it/cookies.mo rename to src/language/it/cookies.mo index 93cdb86..1f660c0 100644 --- a/language/it/cookies.mo +++ b/src/language/it/cookies.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/credit.mo b/src/language/it/credit.mo similarity index 93% rename from language/it/credit.mo rename to src/language/it/credit.mo index 57c08e6..6ea9852 100644 --- a/language/it/credit.mo +++ b/src/language/it/credit.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/install/fleet.mo b/src/language/it/fleet.mo similarity index 97% rename from language/it/install/fleet.mo rename to src/language/it/fleet.mo index e580be6..e82c637 100644 --- a/language/it/install/fleet.mo +++ b/src/language/it/fleet.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/galaxy.mo b/src/language/it/galaxy.mo similarity index 97% rename from language/it/galaxy.mo rename to src/language/it/galaxy.mo index c94301c..cd7468a 100644 --- a/language/it/galaxy.mo +++ b/src/language/it/galaxy.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/imperium.mo b/src/language/it/imperium.mo similarity index 91% rename from language/it/imperium.mo rename to src/language/it/imperium.mo index 9991b04..8c047c7 100644 --- a/language/it/imperium.mo +++ b/src/language/it/imperium.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/index.mo b/src/language/it/index.mo similarity index 88% rename from language/it/index.mo rename to src/language/it/index.mo index c24c0d6..edac451 100644 --- a/language/it/index.mo +++ b/src/language/it/index.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/infos.mo b/src/language/it/infos.mo similarity index 99% rename from language/it/infos.mo rename to src/language/it/infos.mo index 6518907..298c880 100644 --- a/language/it/infos.mo +++ b/src/language/it/infos.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/install.php b/src/language/it/install.php similarity index 100% rename from language/it/install.php rename to src/language/it/install.php diff --git a/language/it/install/admin.mo b/src/language/it/install/admin.mo similarity index 97% rename from language/it/install/admin.mo rename to src/language/it/install/admin.mo index c83d32c..21971f7 100644 --- a/language/it/install/admin.mo +++ b/src/language/it/install/admin.mo @@ -1,11 +1,11 @@  + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/install/alliance.mo b/src/language/it/install/alliance.mo similarity index 97% rename from language/it/install/alliance.mo rename to src/language/it/install/alliance.mo index 0e3d8ac..9371053 100644 --- a/language/it/install/alliance.mo +++ b/src/language/it/install/alliance.mo @@ -1,13 +1,13 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * diff --git a/language/it/install/banned.mo b/src/language/it/install/banned.mo similarity index 90% rename from language/it/install/banned.mo rename to src/language/it/install/banned.mo index 26b8c5f..dfa7db0 100644 --- a/language/it/install/banned.mo +++ b/src/language/it/install/banned.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/install/buddy.mo b/src/language/it/install/buddy.mo similarity index 93% rename from language/it/install/buddy.mo rename to src/language/it/install/buddy.mo index 30f49e4..2abb825 100644 --- a/language/it/install/buddy.mo +++ b/src/language/it/install/buddy.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/install/buildings.mo b/src/language/it/install/buildings.mo similarity index 94% rename from language/it/install/buildings.mo rename to src/language/it/install/buildings.mo index ecfb4c9..3e7503f 100644 --- a/language/it/install/buildings.mo +++ b/src/language/it/install/buildings.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/install/changelog.mo b/src/language/it/install/changelog.mo similarity index 98% rename from language/it/install/changelog.mo rename to src/language/it/install/changelog.mo index d40507d..022383b 100644 --- a/language/it/install/changelog.mo +++ b/src/language/it/install/changelog.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/install/chat.mo b/src/language/it/install/chat.mo similarity index 89% rename from language/it/install/chat.mo rename to src/language/it/install/chat.mo index d1e07d7..edab822 100644 --- a/language/it/install/chat.mo +++ b/src/language/it/install/chat.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/install/contact.mo b/src/language/it/install/contact.mo similarity index 89% rename from language/it/install/contact.mo rename to src/language/it/install/contact.mo index 4e85c5d..0a33987 100644 --- a/language/it/install/contact.mo +++ b/src/language/it/install/contact.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/install/cookies.mo b/src/language/it/install/cookies.mo similarity index 91% rename from language/it/install/cookies.mo rename to src/language/it/install/cookies.mo index 93cdb86..1f660c0 100644 --- a/language/it/install/cookies.mo +++ b/src/language/it/install/cookies.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/install/credit.mo b/src/language/it/install/credit.mo similarity index 94% rename from language/it/install/credit.mo rename to src/language/it/install/credit.mo index 4bba0e3..10f5d89 100644 --- a/language/it/install/credit.mo +++ b/src/language/it/install/credit.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/fleet.mo b/src/language/it/install/fleet.mo similarity index 97% rename from language/it/fleet.mo rename to src/language/it/install/fleet.mo index e580be6..e82c637 100644 --- a/language/it/fleet.mo +++ b/src/language/it/install/fleet.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/install/galaxy.mo b/src/language/it/install/galaxy.mo similarity index 97% rename from language/it/install/galaxy.mo rename to src/language/it/install/galaxy.mo index bc4a927..ecb8f7e 100644 --- a/language/it/install/galaxy.mo +++ b/src/language/it/install/galaxy.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/install/imperium.mo b/src/language/it/install/imperium.mo similarity index 91% rename from language/it/install/imperium.mo rename to src/language/it/install/imperium.mo index 6d94ff1..b9a71cc 100644 --- a/language/it/install/imperium.mo +++ b/src/language/it/install/imperium.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/install/index.mo b/src/language/it/install/index.mo similarity index 88% rename from language/it/install/index.mo rename to src/language/it/install/index.mo index 01a8154..14ba37f 100644 --- a/language/it/install/index.mo +++ b/src/language/it/install/index.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/install/infos.mo b/src/language/it/install/infos.mo similarity index 99% rename from language/it/install/infos.mo rename to src/language/it/install/infos.mo index 3701629..d3cc9b8 100644 --- a/language/it/install/infos.mo +++ b/src/language/it/install/infos.mo @@ -1,11 +1,11 @@  + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/install/install.mo b/src/language/it/install/install.mo similarity index 96% rename from language/it/install/install.mo rename to src/language/it/install/install.mo index 9879784..4e9b29b 100644 --- a/language/it/install/install.mo +++ b/src/language/it/install/install.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/install/lang_info.cfg b/src/language/it/install/lang_info.cfg similarity index 83% rename from language/it/install/lang_info.cfg rename to src/language/it/install/lang_info.cfg index c108461..910fb92 100644 --- a/language/it/install/lang_info.cfg +++ b/src/language/it/install/lang_info.cfg @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -30,4 +30,4 @@ $langInfos['ENCODING'] = 'UTF-8'; -$langInfos['DIRECTION'] = 'http://www.xnova-ng.org/'; +$langInfos['DIRECTION'] = 'http://wootook.org/'; diff --git a/language/it/install/leftmenu.mo b/src/language/it/install/leftmenu.mo similarity index 96% rename from language/it/install/leftmenu.mo rename to src/language/it/install/leftmenu.mo index 9dcc338..1ffc122 100644 --- a/language/it/install/leftmenu.mo +++ b/src/language/it/install/leftmenu.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/install/login.mo b/src/language/it/install/login.mo similarity index 94% rename from language/it/install/login.mo rename to src/language/it/install/login.mo index a10d1b7..16aacb2 100644 --- a/language/it/install/login.mo +++ b/src/language/it/install/login.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/install/logout.mo b/src/language/it/install/logout.mo similarity index 88% rename from language/it/install/logout.mo rename to src/language/it/install/logout.mo index e59e9a0..1aa8b2e 100644 --- a/language/it/install/logout.mo +++ b/src/language/it/install/logout.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/install/lostpassword.mo b/src/language/it/install/lostpassword.mo similarity index 91% rename from language/it/install/lostpassword.mo rename to src/language/it/install/lostpassword.mo index 2f100cf..5f338d7 100644 --- a/language/it/install/lostpassword.mo +++ b/src/language/it/install/lostpassword.mo @@ -1,15 +1,15 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. diff --git a/language/it/install/marchand.mo b/src/language/it/install/marchand.mo similarity index 91% rename from language/it/install/marchand.mo rename to src/language/it/install/marchand.mo index d559a90..18f331e 100644 --- a/language/it/install/marchand.mo +++ b/src/language/it/install/marchand.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/install/messages.mo b/src/language/it/install/messages.mo similarity index 95% rename from language/it/install/messages.mo rename to src/language/it/install/messages.mo index 375b84c..c3b6775 100644 --- a/language/it/install/messages.mo +++ b/src/language/it/install/messages.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/install/news.mo b/src/language/it/install/news.mo similarity index 87% rename from language/it/install/news.mo rename to src/language/it/install/news.mo index f3b1ff4..05aa1e8 100644 --- a/language/it/install/news.mo +++ b/src/language/it/install/news.mo @@ -1,14 +1,14 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. diff --git a/language/it/install/notes.mo b/src/language/it/install/notes.mo similarity index 93% rename from language/it/install/notes.mo rename to src/language/it/install/notes.mo index f458bca..5e216c1 100644 --- a/language/it/install/notes.mo +++ b/src/language/it/install/notes.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/install/officier.mo b/src/language/it/install/officier.mo similarity index 98% rename from language/it/install/officier.mo rename to src/language/it/install/officier.mo index c43e525..78b8d9b 100644 --- a/language/it/install/officier.mo +++ b/src/language/it/install/officier.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/install/options.mo b/src/language/it/install/options.mo similarity index 96% rename from language/it/install/options.mo rename to src/language/it/install/options.mo index 0f95e79..3e7bd3f 100644 --- a/language/it/install/options.mo +++ b/src/language/it/install/options.mo @@ -1,14 +1,14 @@  + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. diff --git a/language/it/install/overview.mo b/src/language/it/install/overview.mo similarity index 97% rename from language/it/install/overview.mo rename to src/language/it/install/overview.mo index fc257f3..1c2bc1b 100644 --- a/language/it/install/overview.mo +++ b/src/language/it/install/overview.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/install/phalanx.mo b/src/language/it/install/phalanx.mo similarity index 93% rename from language/it/install/phalanx.mo rename to src/language/it/install/phalanx.mo index 64333ae..414a2cd 100644 --- a/language/it/install/phalanx.mo +++ b/src/language/it/install/phalanx.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/install/player.mo b/src/language/it/install/player.mo similarity index 89% rename from language/it/install/player.mo rename to src/language/it/install/player.mo index ef37b99..bdc5b6a 100644 --- a/language/it/install/player.mo +++ b/src/language/it/install/player.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/install/records.mo b/src/language/it/install/records.mo similarity index 90% rename from language/it/install/records.mo rename to src/language/it/install/records.mo index 366bae3..103b526 100644 --- a/language/it/install/records.mo +++ b/src/language/it/install/records.mo @@ -1,15 +1,15 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. diff --git a/language/it/install/reg.mo b/src/language/it/install/reg.mo similarity index 95% rename from language/it/install/reg.mo rename to src/language/it/install/reg.mo index 0ee096f..c12e103 100644 --- a/language/it/install/reg.mo +++ b/src/language/it/install/reg.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/install/resources.mo b/src/language/it/install/resources.mo similarity index 92% rename from language/it/install/resources.mo rename to src/language/it/install/resources.mo index 973215b..1f150db 100644 --- a/language/it/install/resources.mo +++ b/src/language/it/install/resources.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/install/rules.mo b/src/language/it/install/rules.mo similarity index 98% rename from language/it/install/rules.mo rename to src/language/it/install/rules.mo index 7f42a41..041b305 100644 --- a/language/it/install/rules.mo +++ b/src/language/it/install/rules.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/install/search.mo b/src/language/it/install/search.mo similarity index 92% rename from language/it/install/search.mo rename to src/language/it/install/search.mo index e6a4297..48bf7ee 100644 --- a/language/it/install/search.mo +++ b/src/language/it/install/search.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/install/stat.mo b/src/language/it/install/stat.mo similarity index 92% rename from language/it/install/stat.mo rename to src/language/it/install/stat.mo index 9881338..d81d098 100644 --- a/language/it/install/stat.mo +++ b/src/language/it/install/stat.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/install/system.mo b/src/language/it/install/system.mo similarity index 98% rename from language/it/install/system.mo rename to src/language/it/install/system.mo index bad7a69..9042922 100644 --- a/language/it/install/system.mo +++ b/src/language/it/install/system.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/install/tech.mo b/src/language/it/install/tech.mo similarity index 98% rename from language/it/install/tech.mo rename to src/language/it/install/tech.mo index abfacbf..e87420e 100644 --- a/language/it/install/tech.mo +++ b/src/language/it/install/tech.mo @@ -1,11 +1,11 @@  + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/install/tradingscrapmetal.mo b/src/language/it/install/tradingscrapmetal.mo similarity index 90% rename from language/it/install/tradingscrapmetal.mo rename to src/language/it/install/tradingscrapmetal.mo index 844d1e4..bbfc2b4 100644 --- a/language/it/install/tradingscrapmetal.mo +++ b/src/language/it/install/tradingscrapmetal.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/iso.txt b/src/language/it/iso.txt similarity index 100% rename from language/it/iso.txt rename to src/language/it/iso.txt diff --git a/language/fr/lang_info.cfg b/src/language/it/lang_info.cfg similarity index 83% rename from language/fr/lang_info.cfg rename to src/language/it/lang_info.cfg index c108461..910fb92 100644 --- a/language/fr/lang_info.cfg +++ b/src/language/it/lang_info.cfg @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -30,4 +30,4 @@ $langInfos['ENCODING'] = 'UTF-8'; -$langInfos['DIRECTION'] = 'http://www.xnova-ng.org/'; +$langInfos['DIRECTION'] = 'http://wootook.org/'; diff --git a/language/it/leftmenu.mo b/src/language/it/leftmenu.mo similarity index 96% rename from language/it/leftmenu.mo rename to src/language/it/leftmenu.mo index f89a959..7f24c85 100644 --- a/language/it/leftmenu.mo +++ b/src/language/it/leftmenu.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/login.mo b/src/language/it/login.mo similarity index 94% rename from language/it/login.mo rename to src/language/it/login.mo index 2771a74..192a9f6 100644 --- a/language/it/login.mo +++ b/src/language/it/login.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/logout.mo b/src/language/it/logout.mo similarity index 88% rename from language/it/logout.mo rename to src/language/it/logout.mo index 9c7f0d4..4e33103 100644 --- a/language/it/logout.mo +++ b/src/language/it/logout.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/lostpassword.mo b/src/language/it/lostpassword.mo similarity index 91% rename from language/it/lostpassword.mo rename to src/language/it/lostpassword.mo index 95bd80a..d56522b 100644 --- a/language/it/lostpassword.mo +++ b/src/language/it/lostpassword.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/marchand.mo b/src/language/it/marchand.mo similarity index 91% rename from language/it/marchand.mo rename to src/language/it/marchand.mo index 90d1335..1f44213 100644 --- a/language/it/marchand.mo +++ b/src/language/it/marchand.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/messages.mo b/src/language/it/messages.mo similarity index 95% rename from language/it/messages.mo rename to src/language/it/messages.mo index 29b2761..e269069 100644 --- a/language/it/messages.mo +++ b/src/language/it/messages.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/news.mo b/src/language/it/news.mo similarity index 87% rename from language/it/news.mo rename to src/language/it/news.mo index cf233c5..9536fac 100644 --- a/language/it/news.mo +++ b/src/language/it/news.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/notes.mo b/src/language/it/notes.mo similarity index 93% rename from language/it/notes.mo rename to src/language/it/notes.mo index 3979999..cf2c3b3 100644 --- a/language/it/notes.mo +++ b/src/language/it/notes.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/officier.mo b/src/language/it/officier.mo similarity index 97% rename from language/it/officier.mo rename to src/language/it/officier.mo index 4b06922..5875138 100644 --- a/language/it/officier.mo +++ b/src/language/it/officier.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/options.mo b/src/language/it/options.mo similarity index 96% rename from language/it/options.mo rename to src/language/it/options.mo index eee7e56..7e01925 100644 --- a/language/it/options.mo +++ b/src/language/it/options.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/overview.mo b/src/language/it/overview.mo similarity index 97% rename from language/it/overview.mo rename to src/language/it/overview.mo index a51f394..efbe148 100644 --- a/language/it/overview.mo +++ b/src/language/it/overview.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/phalanx.mo b/src/language/it/phalanx.mo similarity index 93% rename from language/it/phalanx.mo rename to src/language/it/phalanx.mo index 59cf3c8..991e7a1 100644 --- a/language/it/phalanx.mo +++ b/src/language/it/phalanx.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/player.mo b/src/language/it/player.mo similarity index 89% rename from language/it/player.mo rename to src/language/it/player.mo index ef37b99..bdc5b6a 100644 --- a/language/it/player.mo +++ b/src/language/it/player.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/records.mo b/src/language/it/records.mo similarity index 90% rename from language/it/records.mo rename to src/language/it/records.mo index 6cd4fc1..e10975e 100644 --- a/language/it/records.mo +++ b/src/language/it/records.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/reg.mo b/src/language/it/reg.mo similarity index 96% rename from language/it/reg.mo rename to src/language/it/reg.mo index 7222775..efffa88 100644 --- a/language/it/reg.mo +++ b/src/language/it/reg.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/resources.mo b/src/language/it/resources.mo similarity index 92% rename from language/it/resources.mo rename to src/language/it/resources.mo index ccf2231..10cff9b 100644 --- a/language/it/resources.mo +++ b/src/language/it/resources.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/rules.mo b/src/language/it/rules.mo similarity index 98% rename from language/it/rules.mo rename to src/language/it/rules.mo index e4c753e..4556a4a 100644 --- a/language/it/rules.mo +++ b/src/language/it/rules.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/search.mo b/src/language/it/search.mo similarity index 92% rename from language/it/search.mo rename to src/language/it/search.mo index 2fb42f9..a825052 100644 --- a/language/it/search.mo +++ b/src/language/it/search.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/search.php b/src/language/it/search.php similarity index 100% rename from language/it/search.php rename to src/language/it/search.php diff --git a/language/it/settings.mo b/src/language/it/settings.mo similarity index 96% rename from language/it/settings.mo rename to src/language/it/settings.mo index 0cb17b4..e2bb8f5 100644 --- a/language/it/settings.mo +++ b/src/language/it/settings.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/stat.mo b/src/language/it/stat.mo similarity index 92% rename from language/it/stat.mo rename to src/language/it/stat.mo index 2fc64ea..22bd3d5 100644 --- a/language/it/stat.mo +++ b/src/language/it/stat.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/system.mo b/src/language/it/system.mo similarity index 98% rename from language/it/system.mo rename to src/language/it/system.mo index c6e86ad..09d1bba 100644 --- a/language/it/system.mo +++ b/src/language/it/system.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/tech.mo b/src/language/it/tech.mo similarity index 98% rename from language/it/tech.mo rename to src/language/it/tech.mo index 564ad73..ddbab83 100644 --- a/language/it/tech.mo +++ b/src/language/it/tech.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/language/it/tradingscrapmetal.mo b/src/language/it/tradingscrapmetal.mo similarity index 90% rename from language/it/tradingscrapmetal.mo rename to src/language/it/tradingscrapmetal.mo index 1dcf4eb..0a419c0 100644 --- a/language/it/tradingscrapmetal.mo +++ b/src/language/it/tradingscrapmetal.mo @@ -1,11 +1,11 @@ + * Copyright (c) 2009-2011, XNova Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/lostpassword.php b/src/lostpassword.php similarity index 83% rename from lostpassword.php rename to src/lostpassword.php index 294c2ac..d27b146 100644 --- a/lostpassword.php +++ b/src/lostpassword.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,19 +24,19 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ -define('INSIDE' , true); -define('INSTALL' , false); +define('INSIDE', true); +define('INSTALL', false); define('DISABLE_IDENTITY_CHECK', true); -require_once dirname(__FILE__) . '/common.php'; +require_once dirname(__FILE__) . '/application/bootstrap.php'; $mailData = array( 'recipient' => NULL, - 'sender' => 'no-reply', - 'subject' => 'XNova:Legacies - Changement de mot de passe' + 'sender' => 'no-reply@wootook.org', + 'subject' => 'Wootook:Legacies - Changement de mot de passe' ); includeLang('lostpassword'); @@ -87,7 +87,7 @@ Votre mot de passe a été modifié, veuillez trouver ci-dessous vos information login : $username mot de passe : $randomPass -A bientôt sur XNova:Legacies +A bientôt sur Wootook:Legacies EOF; $version = VERSION; @@ -110,6 +110,7 @@ EOF; } } -$parse = $lang; -$page = parsetemplate(gettemplate('lostpassword'), $parse); -display($page, $lang['registry']); +$layout = new Wootook_Core_Model_Layout(); +$layout->getMessagesBlock()->prepareMessages(Wootook_Player_Model_Entity::SESSION_KEY); +$layout->load('lost-password'); +echo $layout->render(); diff --git a/marchand.php b/src/marchand.php similarity index 83% rename from marchand.php rename to src/marchand.php index 2a0a818..ed76401 100644 --- a/marchand.php +++ b/src/marchand.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,13 +24,13 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); -require_once dirname(__FILE__) .'/common.php'; +require_once dirname(__FILE__) .'/application/bootstrap.php'; function ModuleMarchand ( $CurrentUser, &$CurrentPlanet ) { global $lang, $_POST; @@ -39,13 +39,13 @@ function ModuleMarchand ( $CurrentUser, &$CurrentPlanet ) { $parse = $lang; - if ($_POST['ress'] != '') { + if (isset($_POST['ress']) && $_POST['ress'] != '') { $PageTPL = gettemplate('message_body'); $Error = false; $CheatTry = false; - $Metal = $_POST['metal']; - $Crystal = $_POST['cristal']; - $Deuterium = $_POST['deut']; + $Metal = isset($_POST['metal']) ? $_POST['metal'] : 0; + $Crystal = isset($_POST['cristal']) ? $_POST['cristal'] : 0; + $Deuterium = isset($_POST['deut']) ? $_POST['deut'] : 0; if ($Metal < 0) { $Metal *= -1; $CheatTry = true; @@ -72,8 +72,8 @@ function ModuleMarchand ( $CurrentUser, &$CurrentPlanet ) { case 'cristal': $Necessaire = (( $Metal * 0.5) + ( $Deuterium * 2)); - if ($CurrentPlanet['crystal'] > $Necessaire) { - $CurrentPlanet['crystal'] -= $Necessaire; + if ($CurrentPlanet['cristal'] > $Necessaire) { + $CurrentPlanet['cristal'] -= $Necessaire; } else { $Message = $lang['mod_ma_noten'] ." ". $lang['Crystal'] ."! "; $Error = true; @@ -94,17 +94,17 @@ function ModuleMarchand ( $CurrentUser, &$CurrentPlanet ) { if ($Error == false) { if ($CheatTry == true) { $CurrentPlanet['metal'] = 0; - $CurrentPlanet['crystal'] = 0; + $CurrentPlanet['cristal'] = 0; $CurrentPlanet['deuterium'] = 0; } else { $CurrentPlanet['metal'] += $Metal; - $CurrentPlanet['crystal'] += $Crystal; + $CurrentPlanet['cristal'] += $Crystal; $CurrentPlanet['deuterium'] += $Deuterium; } $QryUpdatePlanet = "UPDATE {{table}} SET "; $QryUpdatePlanet .= "`metal` = '". $CurrentPlanet['metal'] ."', "; - $QryUpdatePlanet .= "`crystal` = '". $CurrentPlanet['crystal'] ."', "; + $QryUpdatePlanet .= "`cristal` = '". $CurrentPlanet['cristal'] ."', "; $QryUpdatePlanet .= "`deuterium` = '". $CurrentPlanet['deuterium'] ."' "; $QryUpdatePlanet .= "WHERE "; $QryUpdatePlanet .= "`id` = '". $CurrentPlanet['id'] ."';"; @@ -118,7 +118,7 @@ function ModuleMarchand ( $CurrentUser, &$CurrentPlanet ) { } $parse['mes'] = $Message; } else { - if ($_POST['action'] != 2) { + if (!isset($_POST['action']) || $_POST['action'] != 2) { $PageTPL = gettemplate('marchand_main'); } else { $parse['mod_ma_res'] = "1"; @@ -145,8 +145,7 @@ function ModuleMarchand ( $CurrentUser, &$CurrentPlanet ) { $Page = parsetemplate ( $PageTPL, $parse ); return $Page; } - - $Page = ModuleMarchand ( $user, $planetrow ); + $Page = ModuleMarchand ( $user, $planet ); display ( $Page, $lang['mod_marchand'], true, '', false ); // ----------------------------------------------------------------------------------------------------------- diff --git a/src/medias/klore/images/building/alliance-depot.jpg b/src/medias/klore/images/building/alliance-depot.jpg new file mode 100644 index 0000000..e7b7f7f Binary files /dev/null and b/src/medias/klore/images/building/alliance-depot.jpg differ diff --git a/src/medias/klore/images/building/cristal-mine.jpg b/src/medias/klore/images/building/cristal-mine.jpg new file mode 100644 index 0000000..fcdf957 Binary files /dev/null and b/src/medias/klore/images/building/cristal-mine.jpg differ diff --git a/src/medias/klore/images/building/cristal-storage.jpg b/src/medias/klore/images/building/cristal-storage.jpg new file mode 100644 index 0000000..777707c Binary files /dev/null and b/src/medias/klore/images/building/cristal-storage.jpg differ diff --git a/src/medias/klore/images/building/deuterium-syntherizer.jpg b/src/medias/klore/images/building/deuterium-syntherizer.jpg new file mode 100644 index 0000000..31f2637 Binary files /dev/null and b/src/medias/klore/images/building/deuterium-syntherizer.jpg differ diff --git a/src/medias/klore/images/building/deuterium-tank.jpg b/src/medias/klore/images/building/deuterium-tank.jpg new file mode 100644 index 0000000..7908e9f Binary files /dev/null and b/src/medias/klore/images/building/deuterium-tank.jpg differ diff --git a/src/medias/klore/images/building/fusion-reactor.jpg b/src/medias/klore/images/building/fusion-reactor.jpg new file mode 100644 index 0000000..e4e28ee Binary files /dev/null and b/src/medias/klore/images/building/fusion-reactor.jpg differ diff --git a/src/medias/klore/images/building/jump-gate.jpg b/src/medias/klore/images/building/jump-gate.jpg new file mode 100644 index 0000000..df95db9 Binary files /dev/null and b/src/medias/klore/images/building/jump-gate.jpg differ diff --git a/src/medias/klore/images/building/lunar-base.jpg b/src/medias/klore/images/building/lunar-base.jpg new file mode 100644 index 0000000..7345110 Binary files /dev/null and b/src/medias/klore/images/building/lunar-base.jpg differ diff --git a/src/medias/klore/images/building/metal-mine.jpg b/src/medias/klore/images/building/metal-mine.jpg new file mode 100644 index 0000000..b11c616 Binary files /dev/null and b/src/medias/klore/images/building/metal-mine.jpg differ diff --git a/src/medias/klore/images/building/metal-storage.jpg b/src/medias/klore/images/building/metal-storage.jpg new file mode 100644 index 0000000..9199a8a Binary files /dev/null and b/src/medias/klore/images/building/metal-storage.jpg differ diff --git a/src/medias/klore/images/building/missile-silo.jpg b/src/medias/klore/images/building/missile-silo.jpg new file mode 100644 index 0000000..cc59a21 Binary files /dev/null and b/src/medias/klore/images/building/missile-silo.jpg differ diff --git a/src/medias/klore/images/building/nanite-factory.jpg b/src/medias/klore/images/building/nanite-factory.jpg new file mode 100644 index 0000000..c15b9c5 Binary files /dev/null and b/src/medias/klore/images/building/nanite-factory.jpg differ diff --git a/src/medias/klore/images/building/research-lab.jpg b/src/medias/klore/images/building/research-lab.jpg new file mode 100644 index 0000000..bbabfa6 Binary files /dev/null and b/src/medias/klore/images/building/research-lab.jpg differ diff --git a/src/medias/klore/images/building/robotic-factory.jpg b/src/medias/klore/images/building/robotic-factory.jpg new file mode 100644 index 0000000..83f1ec0 Binary files /dev/null and b/src/medias/klore/images/building/robotic-factory.jpg differ diff --git a/src/medias/klore/images/building/sensor-phalanx.jpg b/src/medias/klore/images/building/sensor-phalanx.jpg new file mode 100644 index 0000000..03f3031 Binary files /dev/null and b/src/medias/klore/images/building/sensor-phalanx.jpg differ diff --git a/src/medias/klore/images/building/shipyard.jpg b/src/medias/klore/images/building/shipyard.jpg new file mode 100644 index 0000000..2d81393 Binary files /dev/null and b/src/medias/klore/images/building/shipyard.jpg differ diff --git a/src/medias/klore/images/building/solar-plant.jpg b/src/medias/klore/images/building/solar-plant.jpg new file mode 100644 index 0000000..23e9d59 Binary files /dev/null and b/src/medias/klore/images/building/solar-plant.jpg differ diff --git a/src/medias/klore/images/building/terraformer.jpg b/src/medias/klore/images/building/terraformer.jpg new file mode 100644 index 0000000..e12efdd Binary files /dev/null and b/src/medias/klore/images/building/terraformer.jpg differ diff --git a/src/medias/klore/images/defense/antiballistic-missile.jpg b/src/medias/klore/images/defense/antiballistic-missile.jpg new file mode 100644 index 0000000..f35eb79 Binary files /dev/null and b/src/medias/klore/images/defense/antiballistic-missile.jpg differ diff --git a/src/medias/klore/images/defense/gauss-canon.jpg b/src/medias/klore/images/defense/gauss-canon.jpg new file mode 100644 index 0000000..7540d90 Binary files /dev/null and b/src/medias/klore/images/defense/gauss-canon.jpg differ diff --git a/src/medias/klore/images/defense/heavy-laser.jpg b/src/medias/klore/images/defense/heavy-laser.jpg new file mode 100644 index 0000000..870f852 Binary files /dev/null and b/src/medias/klore/images/defense/heavy-laser.jpg differ diff --git a/src/medias/klore/images/defense/interplanetary-missile.jpg b/src/medias/klore/images/defense/interplanetary-missile.jpg new file mode 100644 index 0000000..a037494 Binary files /dev/null and b/src/medias/klore/images/defense/interplanetary-missile.jpg differ diff --git a/src/medias/klore/images/defense/ion-canon.jpg b/src/medias/klore/images/defense/ion-canon.jpg new file mode 100644 index 0000000..6885f94 Binary files /dev/null and b/src/medias/klore/images/defense/ion-canon.jpg differ diff --git a/src/medias/klore/images/defense/large-shield-dome.jpg b/src/medias/klore/images/defense/large-shield-dome.jpg new file mode 100644 index 0000000..52b93f0 Binary files /dev/null and b/src/medias/klore/images/defense/large-shield-dome.jpg differ diff --git a/src/medias/klore/images/defense/light-laser.jpg b/src/medias/klore/images/defense/light-laser.jpg new file mode 100644 index 0000000..541b22e Binary files /dev/null and b/src/medias/klore/images/defense/light-laser.jpg differ diff --git a/src/medias/klore/images/defense/plasma-turret.jpg b/src/medias/klore/images/defense/plasma-turret.jpg new file mode 100644 index 0000000..e0a14a2 Binary files /dev/null and b/src/medias/klore/images/defense/plasma-turret.jpg differ diff --git a/src/medias/klore/images/defense/rocket-launcher.jpg b/src/medias/klore/images/defense/rocket-launcher.jpg new file mode 100644 index 0000000..d1eebc5 Binary files /dev/null and b/src/medias/klore/images/defense/rocket-launcher.jpg differ diff --git a/src/medias/klore/images/defense/small-shield-dome.jpg b/src/medias/klore/images/defense/small-shield-dome.jpg new file mode 100644 index 0000000..74d8744 Binary files /dev/null and b/src/medias/klore/images/defense/small-shield-dome.jpg differ diff --git a/src/medias/klore/images/ship/battlecruiser.jpg b/src/medias/klore/images/ship/battlecruiser.jpg new file mode 100644 index 0000000..51e8b34 Binary files /dev/null and b/src/medias/klore/images/ship/battlecruiser.jpg differ diff --git a/src/medias/klore/images/ship/battleship.jpg b/src/medias/klore/images/ship/battleship.jpg new file mode 100644 index 0000000..395caff Binary files /dev/null and b/src/medias/klore/images/ship/battleship.jpg differ diff --git a/src/medias/klore/images/ship/bomber.jpg b/src/medias/klore/images/ship/bomber.jpg new file mode 100644 index 0000000..e0bbe5c Binary files /dev/null and b/src/medias/klore/images/ship/bomber.jpg differ diff --git a/src/medias/klore/images/ship/colony-ship.jpg b/src/medias/klore/images/ship/colony-ship.jpg new file mode 100644 index 0000000..2f932ea Binary files /dev/null and b/src/medias/klore/images/ship/colony-ship.jpg differ diff --git a/src/medias/klore/images/ship/cruiser.jpg b/src/medias/klore/images/ship/cruiser.jpg new file mode 100644 index 0000000..97729cd Binary files /dev/null and b/src/medias/klore/images/ship/cruiser.jpg differ diff --git a/src/medias/klore/images/ship/death-star.jpg b/src/medias/klore/images/ship/death-star.jpg new file mode 100644 index 0000000..453372a Binary files /dev/null and b/src/medias/klore/images/ship/death-star.jpg differ diff --git a/src/medias/klore/images/ship/destructor.jpg b/src/medias/klore/images/ship/destructor.jpg new file mode 100644 index 0000000..aac6d6b Binary files /dev/null and b/src/medias/klore/images/ship/destructor.jpg differ diff --git a/src/medias/klore/images/ship/heavy-fighter.jpg b/src/medias/klore/images/ship/heavy-fighter.jpg new file mode 100644 index 0000000..4fbb6e7 Binary files /dev/null and b/src/medias/klore/images/ship/heavy-fighter.jpg differ diff --git a/src/medias/klore/images/ship/large-transport.jpg b/src/medias/klore/images/ship/large-transport.jpg new file mode 100644 index 0000000..aba4772 Binary files /dev/null and b/src/medias/klore/images/ship/large-transport.jpg differ diff --git a/src/medias/klore/images/ship/light-fighter.jpg b/src/medias/klore/images/ship/light-fighter.jpg new file mode 100644 index 0000000..e59a213 Binary files /dev/null and b/src/medias/klore/images/ship/light-fighter.jpg differ diff --git a/src/medias/klore/images/ship/light-transport.jpg b/src/medias/klore/images/ship/light-transport.jpg new file mode 100644 index 0000000..ceb9434 Binary files /dev/null and b/src/medias/klore/images/ship/light-transport.jpg differ diff --git a/src/medias/klore/images/ship/ore-miner.jpg b/src/medias/klore/images/ship/ore-miner.jpg new file mode 100644 index 0000000..e83a7ec Binary files /dev/null and b/src/medias/klore/images/ship/ore-miner.jpg differ diff --git a/src/medias/klore/images/ship/recycler.jpg b/src/medias/klore/images/ship/recycler.jpg new file mode 100644 index 0000000..046617d Binary files /dev/null and b/src/medias/klore/images/ship/recycler.jpg differ diff --git a/src/medias/klore/images/ship/solar-satellite.jpg b/src/medias/klore/images/ship/solar-satellite.jpg new file mode 100644 index 0000000..af690e5 Binary files /dev/null and b/src/medias/klore/images/ship/solar-satellite.jpg differ diff --git a/src/medias/klore/images/ship/spy-drone.jpg b/src/medias/klore/images/ship/spy-drone.jpg new file mode 100644 index 0000000..bb9b3fd Binary files /dev/null and b/src/medias/klore/images/ship/spy-drone.jpg differ diff --git a/src/medias/klore/images/ship/supernova.jpg b/src/medias/klore/images/ship/supernova.jpg new file mode 100644 index 0000000..3ebb876 Binary files /dev/null and b/src/medias/klore/images/ship/supernova.jpg differ diff --git a/src/medias/klore/images/technology/armour.jpg b/src/medias/klore/images/technology/armour.jpg new file mode 100644 index 0000000..1028560 Binary files /dev/null and b/src/medias/klore/images/technology/armour.jpg differ diff --git a/src/medias/klore/images/technology/combustion-drive.jpg b/src/medias/klore/images/technology/combustion-drive.jpg new file mode 100644 index 0000000..3711874 Binary files /dev/null and b/src/medias/klore/images/technology/combustion-drive.jpg differ diff --git a/src/medias/klore/images/technology/computer.jpg b/src/medias/klore/images/technology/computer.jpg new file mode 100644 index 0000000..01bca1b Binary files /dev/null and b/src/medias/klore/images/technology/computer.jpg differ diff --git a/src/medias/klore/images/technology/energy.jpg b/src/medias/klore/images/technology/energy.jpg new file mode 100644 index 0000000..08049f6 Binary files /dev/null and b/src/medias/klore/images/technology/energy.jpg differ diff --git a/src/medias/klore/images/technology/espionnage.jpg b/src/medias/klore/images/technology/espionnage.jpg new file mode 100644 index 0000000..81201c5 Binary files /dev/null and b/src/medias/klore/images/technology/espionnage.jpg differ diff --git a/src/medias/klore/images/technology/expedition.jpg b/src/medias/klore/images/technology/expedition.jpg new file mode 100644 index 0000000..0cbee64 Binary files /dev/null and b/src/medias/klore/images/technology/expedition.jpg differ diff --git a/src/medias/klore/images/technology/graviton.jpg b/src/medias/klore/images/technology/graviton.jpg new file mode 100644 index 0000000..68fac77 Binary files /dev/null and b/src/medias/klore/images/technology/graviton.jpg differ diff --git a/src/medias/klore/images/technology/hyperspace-drive.jpg b/src/medias/klore/images/technology/hyperspace-drive.jpg new file mode 100644 index 0000000..fa8f4cd Binary files /dev/null and b/src/medias/klore/images/technology/hyperspace-drive.jpg differ diff --git a/src/medias/klore/images/technology/hyperspace-technology.jpg b/src/medias/klore/images/technology/hyperspace-technology.jpg new file mode 100644 index 0000000..343cea3 Binary files /dev/null and b/src/medias/klore/images/technology/hyperspace-technology.jpg differ diff --git a/src/medias/klore/images/technology/impulse-drive.jpg b/src/medias/klore/images/technology/impulse-drive.jpg new file mode 100644 index 0000000..085ed02 Binary files /dev/null and b/src/medias/klore/images/technology/impulse-drive.jpg differ diff --git a/src/medias/klore/images/technology/intergalactic-research-network.jpg b/src/medias/klore/images/technology/intergalactic-research-network.jpg new file mode 100644 index 0000000..39a2821 Binary files /dev/null and b/src/medias/klore/images/technology/intergalactic-research-network.jpg differ diff --git a/src/medias/klore/images/technology/interplanetary-missile.jpg b/src/medias/klore/images/technology/interplanetary-missile.jpg new file mode 100644 index 0000000..a037494 Binary files /dev/null and b/src/medias/klore/images/technology/interplanetary-missile.jpg differ diff --git a/src/medias/klore/images/technology/ion.jpg b/src/medias/klore/images/technology/ion.jpg new file mode 100644 index 0000000..ad65150 Binary files /dev/null and b/src/medias/klore/images/technology/ion.jpg differ diff --git a/src/medias/klore/images/technology/laser.jpg b/src/medias/klore/images/technology/laser.jpg new file mode 100644 index 0000000..4cdbf1f Binary files /dev/null and b/src/medias/klore/images/technology/laser.jpg differ diff --git a/src/medias/klore/images/technology/ore-mining.jpg b/src/medias/klore/images/technology/ore-mining.jpg new file mode 100644 index 0000000..a10af80 Binary files /dev/null and b/src/medias/klore/images/technology/ore-mining.jpg differ diff --git a/src/medias/klore/images/technology/plasma.jpg b/src/medias/klore/images/technology/plasma.jpg new file mode 100644 index 0000000..15baf33 Binary files /dev/null and b/src/medias/klore/images/technology/plasma.jpg differ diff --git a/src/medias/klore/images/technology/shielding.jpg b/src/medias/klore/images/technology/shielding.jpg new file mode 100644 index 0000000..070f02a Binary files /dev/null and b/src/medias/klore/images/technology/shielding.jpg differ diff --git a/src/medias/klore/images/technology/weaponry.jpg b/src/medias/klore/images/technology/weaponry.jpg new file mode 100644 index 0000000..16ef740 Binary files /dev/null and b/src/medias/klore/images/technology/weaponry.jpg differ diff --git a/messages.php b/src/messages.php similarity index 93% rename from messages.php rename to src/messages.php index 84d4e33..9d080e5 100644 --- a/messages.php +++ b/src/messages.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,13 +24,13 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); -require_once dirname(__FILE__) .'/common.php'; +require_once dirname(__FILE__) .'/application/bootstrap.php'; include(ROOT_PATH . 'includes/functions/BBcodeFunction.' . PHPEXT); if(!isset($user['authlevel'])) { @@ -40,11 +40,11 @@ if(!isset($user['authlevel'])) { includeLang('messages'); -$OwnerID = $_GET['id']; -$MessCategory = $_GET['messcat']; -$MessPageMode = (string) $_GET['mode']; -$DeleteWhat = $_POST['deletemessages']; -if (isset ($DeleteWhat)) { +$OwnerID = isset($_GET['id']) ? $_GET['id'] : null; +$MessCategory = isset($_GET['messcat']) ? $_GET['messcat'] : null; +$MessPageMode = isset($_GET['mode']) ? (string) $_GET['mode'] : null; +$DeleteWhat = isset($_POST['deletemessages']) ? $_POST['deletemessages'] : null; +if (!empty($DeleteWhat)) { $MessPageMode = "delete"; } @@ -55,6 +55,9 @@ $MessageType = array (0, 1, 2, 3, 4, 5, 15, 99, 100 ); $TitleColor = array (0 => '#FFFF00', 1 => '#FF6699', 2 => '#FF3300', 3 => '#FF9900', 4 => '#773399', 5 => '#009933', 15 => '#030070', 99 => '#007070', 100 => '#ABABAB'); $BackGndColor = array (0 => '#663366', 1 => '#336666', 2 => '#000099', 3 => '#666666', 4 => '#999999', 5 => '#999999', 15 => '#999999', 99 => '#999999', 100 => '#999999'); +$page = null; +$text = null; + for ($MessType = 0; $MessType < 101; $MessType++) { if (in_array($MessType, $MessageType) ) { $WaitingMess[$MessType] = $UnRead[$messfields[$MessType]]; @@ -107,7 +110,7 @@ while ($CurMess = $UsrMess->fetch(PDO::FETCH_BOTH)) { $Sender = $user['id']; $From = $user['username'] ." [".$user['galaxy'].":".$user['system'].":".$user['planet']."]"; $Subject = $_POST['subject']; - if($gameConfig['enable_bbcode'] == 1) { + if (Wootook::getGameConfig('engine/options/bbcode')) { $Message = trim ( nl2br (bbcode ( image ( strip_tags ( $_POST['text'], '
    ' ) ) ) ) ); } else { @@ -128,7 +131,7 @@ $Message = trim ( nl2br ( strip_tags ( $_POST['text'], '
    ' ) ) ); } $parse['to'] = $OwnerRecord['username'] ." [".$OwnerHome['galaxy'].":".$OwnerHome['system'].":".$OwnerHome['planet']."]"; $parse['subject'] = (!isset($subject)) ? $lang['mess_no_subject'] : $subject ; $parse['text'] = $text; - if($gameConfig['enable_bbcode'] == 1) { + if(Wootook::getGameConfig('engine/options/bbcode')) { $page .= parsetemplate(gettemplate('messages_pm_form_bb'), $parse); } else { $page .= parsetemplate(gettemplate('messages_pm_form'), $parse); } @@ -230,7 +233,7 @@ $Message = trim ( nl2br ( strip_tags ( $_POST['text'], '
    ' ) ) ); } $page .= "
    "; + $page .= "\"".$lang['mess_answer']."\""; } else { $page .= ""; } @@ -254,12 +257,12 @@ $Message = trim ( nl2br ( strip_tags ( $_POST['text'], '
    ' ) ) ); } $page .= "\n"; $page .= ""; $page .= ""; - $page .= ""; + $page .= ""; $page .= ""; $page .= ""; + $page .= "\"".$lang['mess_answer']."\""; } else { $page .= ""; } diff --git a/mipattack.php b/src/mipattack.php similarity index 91% rename from mipattack.php rename to src/mipattack.php index 4b7396b..aad59fb 100644 --- a/mipattack.php +++ b/src/mipattack.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,13 +24,13 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); -require_once dirname(__FILE__) .'/common.php'; +require_once dirname(__FILE__) .'/application/bootstrap.php'; // Recup des variables $Attaquant = $_GET['current']; $NbreMip = $_POST['SendMI']; diff --git a/multi.php b/src/multi.php similarity index 85% rename from multi.php rename to src/multi.php index 24fa2d0..633de79 100644 --- a/multi.php +++ b/src/multi.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,13 +24,13 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); -require_once dirname(__FILE__) .'/common.php'; +require_once dirname(__FILE__) .'/application/bootstrap.php'; includeLang('messages'); includeLang('system'); @@ -62,6 +62,6 @@ if ($mode == 'add') { } // D�claration des multi compte -// Par Tom pour XNova +// Par Tom pour Wootook ?> diff --git a/neusuw.php b/src/neusuw.php similarity index 96% rename from neusuw.php rename to src/neusuw.php index 2c278f4..51f872c 100644 --- a/neusuw.php +++ b/src/neusuw.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,13 +24,13 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); -require_once dirname(__FILE__) .'/common.php'; +require_once dirname(__FILE__) .'/application/bootstrap.php'; includeLang('usuw'); diff --git a/notes.php b/src/notes.php similarity index 95% rename from notes.php rename to src/notes.php index 02823d2..52d85d4 100644 --- a/notes.php +++ b/src/notes.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,13 +24,13 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); -require_once dirname(__FILE__) .'/common.php'; +require_once dirname(__FILE__) .'/application/bootstrap.php'; $dpath = (!$user["dpath"]) ? DEFAULT_SKINPATH : $user["dpath"]; diff --git a/options.php b/src/options.php similarity index 68% rename from options.php rename to src/options.php index be6f5fe..8490b7a 100644 --- a/options.php +++ b/src/options.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,64 +24,44 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); -require_once dirname(__FILE__) .'/common.php'; - includeLang('options'); +require_once dirname(__FILE__) .'/application/bootstrap.php'; - $lang['PHP_SELF'] = 'options.' . PHPEXT; +$user = Wootook_Player_Model_Session::getSingleton()->getPlayer(); - $dpath = (!$user["dpath"]) ? DEFAULT_SKINPATH : $user["dpath"]; - $mode = $_GET['mode']; +includeLang('options'); - if ($_POST && $mode == "exit") { // Array ( [db_character] - if (isset($_POST["exit_modus"]) && $_POST["exit_modus"] == 'on' and $user['urlaubs_until'] <= time()){ - $urlaubs_modus = "0"; - doquery("UPDATE {{table}} SET - `urlaubs_modus` = '0', - `urlaubs_until` = '0' - WHERE `id` = '".$user['id']."' LIMIT 1", "users"); +$lang['PHP_SELF'] = 'options.' . PHPEXT; -//Remise des mines au retour du mod vacance +$mode = isset($_GET['mode']) ? $_GET['mode'] : null; - $query = doquery("SELECT * FROM {{table}} WHERE id_owner = '{$user['id']}'", 'planets'); - while ($id = $query->fetch(PDO::FETCH_BOTH)){ - doquery("UPDATE {{table}} SET - energy_used = '10', - energy_max = '10', - metal_mine_porcent = '10', - crystal_mine_porcent = '10', - deuterium_sintetizer_porcent = '10', - solar_plant_porcent = '10', - fusion_plant_porcent = '10', - solar_satelit_porcent = '10' - WHERE id = '{$id['id']}' AND `planet_type` = 1 ", 'planets');} - - $dpath = (!$user["dpath"]) ? DEFAULT_SKINPATH : $user["dpath"]; - message($lang['succeful_save'], $lang['Options'],"options.php",1); - }else{ - $urlaubs_modus = "1"; - $dpath = (!$user["dpath"]) ? DEFAULT_SKINPATH : $user["dpath"]; - message($lang['You_cant_exit_vmode'], $lan['Error'] ,"options.php",1); + if (!empty($_POST) && $mode == "exit") { // Array ( [db_character] + if (isset($_POST["exit_modus"]) && !empty($_POST["exit_modus"]) && $user->getVacation() && $user->getVacationEndDate() <= time()) { + $user->setVacation(false); + message($lang['succeful_save'], $lang['Options'],"options.php",1); + } else { + message($lang['You_cant_exit_vmode'], $lan['Error'] ,"options.php",1); } } - if ($_POST && $mode == "change") { // Array ( [db_character] - $iduser = $user["id"]; - $avatar = $_POST["avatar"]; + + $dpath = (!$user["dpath"]) ? DEFAULT_SKINPATH : $user["dpath"]; - if ($_POST["dpath"] != "") - $dpath = $_POST["dpath"]; - else - $dpath = (!$user["dpath"]) ? DEFAULT_SKINPATH : $user["dpath"]; + if ($_POST && $mode == "change") { // Array ( [db_character] + $iduser = $user["id"]; + $avatar = $_POST["avatar"]; + + if ($_POST["dpath"] != "") + $dpath = $_POST["dpath"]; // Gestion des options speciales pour les admins if ($user['authlevel'] != LEVEL_PLAYER) { - if ($_POST['adm_pl_prot'] == 'on') { + if (isset($_POST['adm_pl_prot']) && $_POST['adm_pl_prot'] == 'on') { doquery ("UPDATE {{table}} SET `id_level` = '".$user['authlevel']."' WHERE `id_owner` = '".$user['id']."';", 'planets'); } else { doquery ("UPDATE {{table}} SET `id_level` = '0' WHERE `id_owner` = '".$user['id']."';", 'planets'); @@ -167,44 +147,22 @@ require_once dirname(__FILE__) .'/common.php'; $settings_rep = "0"; } // Modo vacaciones - if (isset($_POST["urlaubs_modus"]) && $_POST["urlaubs_modus"] == 'on') { - //Selectionne si le joueur a des flottes en vol - $fleet = doquery("SELECT COUNT(fleet_owner) AS `actcnt` FROM {{table}} WHERE `fleet_owner` = '".$user['id']."';", 'fleets', true); - //Selectionne si le joueur a des batiments en construction - $build = doquery("SELECT COUNT(id_owner) AS `building` FROM {{table}} WHERE `id_owner` = '".$user['id']."' and `b_building`!=0;", 'planets', true); - //Selectionne si le joueur a des techno en cours - $tech = doquery("SELECT COUNT(id) AS `tech` FROM {{table}} WHERE `id` = '".$user['id']."' and `b_tech_planet`!=0;", 'users', true); - //Selectionne si le joueur est en train de se faire attaquer - $attack = doquery("SELECT COUNT(fleet_taget_owner) AS `attack` FROM {{table}} WHERE `fleet_taget_owner` = '".$user['id']."';", 'fleets', true); - if($fleet['actcnt']=='0' && $build['building']=='0' && $tech['tech']=='0' && $attack['attack']=='0') { - $urlaubs_modus = "1"; - $time = time() + 172800; - doquery("UPDATE {{table}} SET - `urlaubs_modus` = '$urlaubs_modus', - `urlaubs_until` = '$time' - WHERE `id` = '$iduser' LIMIT 1", "users"); - } else { - message ( 'Verifiez vos flottes, technologies et batiments','
    Vous avez des actions en cours
    ' ); - } + if (isset($_POST["urlaubs_modus"]) && !empty($_POST["urlaubs_modus"]) && !$user->getVacation()) { + //Selectionne si le joueur a des flottes en vol + $fleet = doquery("SELECT COUNT(fleet_owner) AS `actcnt` FROM {{table}} WHERE `fleet_owner` = '".$user['id']."';", 'fleets', true); + //Selectionne si le joueur a des batiments en construction + $build = doquery("SELECT COUNT(id_owner) AS `building` FROM {{table}} WHERE `id_owner` = '".$user['id']."' and `b_building`!=0;", 'planets', true); + //Selectionne si le joueur a des techno en cours + $tech = doquery("SELECT COUNT(id) AS `tech` FROM {{table}} WHERE `id` = '".$user['id']."' and `b_tech_planet`!=0;", 'users', true); + //Selectionne si le joueur est en train de se faire attaquer + $attack = doquery("SELECT COUNT(fleet_target_owner) AS `attack` FROM {{table}} WHERE `fleet_target_owner` = '".$user['id']."';", 'fleets', true); - $query = doquery("SELECT * FROM {{table}} WHERE id_owner = '{$user['id']}'", 'planets'); - while ($id = $query->fetch(PDO::FETCH_BOTH)){ - doquery("UPDATE {{table}} SET - metal_perhour = '".$gameConfig['metal_basic_income']."', - crystal_perhour = '".$gameConfig['metal_basic_income']."', - deuterium_perhour = '".$gameConfig['metal_basic_income']."', - energy_used = '0', - energy_max = '0', - metal_mine_porcent = '0', - crystal_mine_porcent = '0', - deuterium_sintetizer_porcent = '0', - solar_plant_porcent = '0', - fusion_plant_porcent = '0', - solar_satelit_porcent = '0' - WHERE id = '{$id['id']}' AND `planet_type` = 1 ", 'planets'); - } - } else { - $urlaubs_modus = "0"; + if ($fleet['actcnt'] == 0 && $build['building'] == 0 && $tech['tech'] == 0 && $attack['attack'] == 0) { + $user->setVacation(); + } else { + message(Wootook::__('Could not set to vacation mode.'), + Wootook::__("You currently can't get to vacation mode, please check your flying fleets, and building queues.")); + } } // Borrar cuenta @@ -233,11 +191,7 @@ require_once dirname(__FILE__) .'/common.php'; `settings_bud` = '$settings_bud', `settings_mis` = '$settings_mis', `settings_rep` = '$settings_rep', - `urlaubs_modus` = '$urlaubs_modus', - `db_deaktjava` = '$db_deaktjava', - `kolorminus` = '$kolorminus', - `kolorplus` = '$kolorplus', - `kolorpoziom` = '$kolorpoziom' + `db_deaktjava` = '$db_deaktjava' WHERE `id` = '$iduser' LIMIT 1", "users"); if (isset($_POST["db_password"]) && md5($_POST["db_password"]) == $user["password"]) { @@ -293,7 +247,7 @@ require_once dirname(__FILE__) .'/common.php'; $parse['opt_modev_data'] = ($user['urlaubs_modus'] == 1)?" checked='checked'/":''; $parse['opt_modev_exit'] = ($user['urlaubs_modus'] == 0)?" checked='1'/":''; $parse['Vaccation_mode'] = $lang['Vaccation_mode']; - $parse['vacation_until'] = date("d.m.Y G:i:s",$user['urlaubs_until']); + $parse['vacation_until'] = date("d.m.Y G:i:s",$user['urlaubs_until']->getTimestamp()); $parse['user_settings_rep'] = ($user['settings_rep'] == 1) ? " checked='checked'/":''; $parse['user_settings_esp'] = ($user['settings_esp'] == 1) ? " checked='checked'/":''; $parse['user_settings_wri'] = ($user['settings_wri'] == 1) ? " checked='checked'/":''; diff --git a/phalanx.php b/src/phalanx.php similarity index 93% rename from phalanx.php rename to src/phalanx.php index 7fd032a..e960ab2 100644 --- a/phalanx.php +++ b/src/phalanx.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,13 +24,13 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); -require_once dirname(__FILE__) .'/common.php'; +require_once dirname(__FILE__) .'/application/bootstrap.php'; includeLang('overview'); includeLang('phalanx'); @@ -81,7 +81,7 @@ require_once dirname(__FILE__) .'/common.php'; $FleetToTarget = doquery( $QryLookFleets, 'fleets' ); - if (mysql_num_rows($FleetToTarget) <> 0 ) { + if ($FleetToTarget->rowCount() > 0 ) { while ($FleetRow = $FleetToTarget->fetch(PDO::FETCH_BOTH)) { $Record++; diff --git a/quickfleet.php b/src/quickfleet.php similarity index 95% rename from quickfleet.php rename to src/quickfleet.php index a9b22c4..e845611 100644 --- a/quickfleet.php +++ b/src/quickfleet.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,13 +24,13 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); -require_once dirname(__FILE__) .'/common.php'; +require_once dirname(__FILE__) .'/application/bootstrap.php'; includeLang('fleet'); @@ -76,7 +76,7 @@ includeLang('fleet'); } $distance = GetTargetDistance ( $planetrow['galaxy'], $Galaxy, $planetrow['system'], $System, $planetrow['planet'], $Planet ); - $SpeedFactor = $gameConfig['fleet_speed'] / 2500; + $SpeedFactor = Wootook::getGameConfig('game/speed/fleet') / 2500; $GenFleetSpeed = 10; // a 100% $duration = GetMissionDuration ( $GenFleetSpeed, $RecyclerSpeed, $distance, $SpeedFactor ); diff --git a/rak.php b/src/rak.php similarity index 92% rename from rak.php rename to src/rak.php index 6fdf912..3e52a53 100644 --- a/rak.php +++ b/src/rak.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ @@ -53,12 +53,12 @@ if (isset($resource) && !empty($resource[401])) { $select_owner = doquery("SELECT military_tech FROM {{table}} WHERE id = '" . $selected_row['owner'] . "'", 'users'); - if (mysql_num_rows($planetrow) != 1 OR mysql_num_rows($select_ziel) != 1) { + if ($planetrow->rowCount() != 1 || $select_ziel->rowCount() != 1) { doquery("DELETE FROM {{table}} WHERE id = '" . $selected_row['id'] . "'", 'iraks'); } else { - $verteidiger = mysql_fetch_array($select_ziel); - $angreifer = mysql_fetch_array($select_owner); - $planet = mysql_fetch_array($planetrow); + $verteidiger = $select_ziel->fetch(PDO::FETCH_BOTH); + $angreifer = $select_owner->fetch(PDO::FETCH_BOTH); + $planet = $planetrow->fetch(PDO::FETCH_BOTH); $ids = array(0 => 401, 1 => 402, @@ -136,7 +136,7 @@ if (isset($resource) && !empty($resource[401])) { system = '" . $selected_row['system_angreifer'] . "' AND planet = '" . $selected_row['planet_angreifer'] . "'", 'planets'); - if (mysql_num_rows($planet_) == 1) { + if ($planet_->rowCount() == 1) { $array = mysql_fetch_array($planet_); $name = $array['name']; @@ -147,7 +147,7 @@ if (isset($resource) && !empty($resource[401])) { system = '" . $selected_row['system'] . "' AND planet = '" . $selected_row['planet'] . "'", 'planets'); - if (mysql_num_rows($planet_2) == 1) { + if ($planet_2->rowCount() == 1) { $array = mysql_fetch_array($planet_2); $name_deffer = $array['name']; diff --git a/raketenangriff.php b/src/raketenangriff.php similarity index 93% rename from raketenangriff.php rename to src/raketenangriff.php index f76f8b7..58a6aba 100644 --- a/raketenangriff.php +++ b/src/raketenangriff.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,13 +24,13 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); -require_once dirname(__FILE__) .'/common.php'; +require_once dirname(__FILE__) .'/application/bootstrap.php'; $planet = doquery("SELECT * FROM {{table}} WHERE `id` = '".$user['current_planet']."';", 'planets', true); $iraks = $planet['interplanetary_misil']; @@ -65,7 +65,7 @@ elseif ($user['impulse_motor_tech'] == 0) {; elseif ($tempvar1 >= $tempvar2 || $g != $currentplanet['galaxy']) { $error = 1; } -elseif (mysql_num_rows($tempvar3) != 1) { +elseif ($tempvar3->rowCount() != 1) { $error = 1; } elseif ($anz > $iraks) { @@ -144,7 +144,7 @@ $select = doquery("SELECT * FROM {{table}} WHERE id = ".$ziel_id, 'users', true) -$flugzeit = round(((30 + (60 * $tempvar1)) * 2500) / $gameConfig['game_speed']); +$flugzeit = round(((30 + (60 * $tempvar1)) * 2500) / Wootook::getGameConfig('game/speed/general')); diff --git a/records.php b/src/records.php similarity index 95% rename from records.php rename to src/records.php index 7316c8a..b7d8079 100644 --- a/records.php +++ b/src/records.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,13 +24,13 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); -require_once dirname(__FILE__) .'/common.php'; +require_once dirname(__FILE__) .'/application/bootstrap.php'; $cacheFile = ROOT_PATH . '/cache/' . basename(__FILE__) . '.cache'; $timeDelay = 21600; // 21600s = 6h diff --git a/src/resources.php b/src/resources.php new file mode 100644 index 0000000..0d0ff77 --- /dev/null +++ b/src/resources.php @@ -0,0 +1,260 @@ + + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License + * along with this program. If not, see . + * + * --> 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. + * + */ + +define('INSIDE' , true); +define('INSTALL' , false); +require_once dirname(__FILE__) .'/application/bootstrap.php'; + +function BuildRessourcePage($CurrentUser, $CurrentPlanet ) { + global $lang; + + includeLang('resources'); + + $RessBodyTPL = gettemplate('resources'); + $RessRowTPL = gettemplate('resources_row'); + + $request = Wootook::getRequest(); + if ($request->isPost()) { + foreach ($request->getPost() as $buildingField => $value) { + $ratioField = "{$buildingField}_porcent"; + if ($CurrentPlanet->hasData($ratioField)) { + if ($value < 0 && $value > 100) { + continue; + } + + $CurrentPlanet->setData($ratioField, $value / 10); + } + } + $CurrentPlanet->save(); + } + + $parse = $lang; + + $parse['production_level'] = 100; + if ($CurrentPlanet['energy_max'] == 0 && $CurrentPlanet['energy_used'] > 0) { + $post_porcent = 0; + } elseif ($CurrentPlanet['energy_max'] > 0 && ($CurrentPlanet['energy_used'] + $CurrentPlanet['energy_max']) < 0 ) { + $post_porcent = floor(($CurrentPlanet['energy_max']) / $CurrentPlanet['energy_used'] * 100); + } else { + $post_porcent = 100; + } + + if ($post_porcent > 100) { + $post_porcent = 100; + } + if ($post_porcent < 0) { + $post_porcent = 0; + } + // ------------------------------------------------------------------------------------------------------- + $parse['resource_row'] = ""; + $BuildTemp = $CurrentPlanet[ 'temp_max' ]; + + $types = Wootook_Empire_Helper_Config_Types::getSingleton(); + $productions = Wootook_Empire_Helper_Config_Production::getSingleton(); + $fields = Wootook_Empire_Helper_Config_FieldsAlias::getSingleton(); + foreach ($types['prod'] as $element) { + // $ProdID => $element + // $ProdGrid => $productions + if ($CurrentPlanet->getElement($element) > 0/* && isset($productions[$element])*/) { + $building = $CurrentPlanet->getProductionElementInstance($element); + + $Field = $fields[$element] ."_porcent"; + $CurrRow = array(); + $CurrRow['name'] = $fields[$element]; + $CurrRow['porcent'] = $CurrentPlanet[$Field]; + $level = $CurrentPlanet->getElement($element); + if ($CurrentPlanet->hasData($Field)) { + for ($Option = 10; $Option >= 0; $Option--) { + $OptValue = $Option * 10; + if ($Option == $CurrRow['porcent']) { + $OptSelected = " selected=selected"; + } else { + $OptSelected = ""; + } + $CurrRow['option'] .= ""; + } + $productions = $building->getProductionRatios($level, $CurrentPlanet[$Field], $CurrentPlanet, $CurrentUser); + } else { + $productions = $building->getProductionRatios($level, 10, $CurrentPlanet, $CurrentUser); + } + + $CurrRow['type'] = $lang['tech'][$element]; + $CurrRow['level'] = !$types->is($element, Legacies_Empire::TYPE_BUILDING) ? $lang['quantity'] : $lang['level']; + $CurrRow['level_type'] = $level; + $CurrRow['metal_type'] = colorNumber(Math::render($productions[Legacies_Empire::RESOURCE_METAL])); + $CurrRow['crystal_type'] = colorNumber(Math::render($productions[Legacies_Empire::RESOURCE_CRISTAL])); + $CurrRow['deuterium_type'] = colorNumber(Math::render($productions[Legacies_Empire::RESOURCE_DEUTERIUM])); + $CurrRow['energy_type'] = colorNumber(Math::render($productions[Legacies_Empire::RESOURCE_ENERGY])); + + $parse['resource_row'] .= parsetemplate($RessRowTPL, $CurrRow ); + } + } + + $parse['Production_of_resources_in_the_planet'] = + str_replace('%s', $CurrentPlanet['name'], $lang['Production_of_resources_in_the_planet']); + if ($CurrentPlanet['energy_max'] == 0 && + $CurrentPlanet['energy_used'] > 0) { + $parse['production_level'] = 0; + } elseif ($CurrentPlanet['energy_max'] > 0 && + abs($CurrentPlanet['energy_used']) > $CurrentPlanet['energy_max']) { + $parse['production_level'] = floor(($CurrentPlanet['energy_max']) / $CurrentPlanet['energy_used'] * 100); + } elseif ($CurrentPlanet['energy_max'] == 0 && + abs($CurrentPlanet['energy_used']) > $CurrentPlanet['energy_max']) { + $parse['production_level'] = 0; + } else { + $parse['production_level'] = 100; + } + if ($parse['production_level'] > 100) { + $parse['production_level'] = 100; + } + + if ($CurrentPlanet['planet_type'] == Wootook_Empire_Model_Planet::TYPE_PLANET) { + $multiplier = Wootook::getGameConfig('game/resource/multiplier'); + $parse['metal_basic_income'] = Wootook::getGameConfig('resource/base-income/metal') * $multiplier; + $parse['crystal_basic_income'] = Wootook::getGameConfig('resource/base-income/cristal') * $multiplier; + $parse['deuterium_basic_income'] = Wootook::getGameConfig('resource/base-income/deuterium') * $multiplier; + $parse['energy_basic_income'] = Wootook::getGameConfig('resource/base-income/energy') * $multiplier; + } else { + $parse['metal_basic_income'] = 0; + $parse['crystal_basic_income'] = 0; + $parse['deuterium_basic_income'] = 0; + $parse['energy_basic_income'] = 0; + } + + if ($CurrentPlanet['metal_max'] < $CurrentPlanet['metal']) { + $parse['metal_max'] = ""; + } else { + $parse['metal_max'] = ""; + } + $parse['metal_max'] .= pretty_number($CurrentPlanet['metal_max'] / 1000) ." ". $lang['k'].""; + + if ($CurrentPlanet['cristal_max'] < $CurrentPlanet['cristal']) { + $parse['crystal_max'] = ""; + } else { + $parse['crystal_max'] = ""; + } + $parse['crystal_max'] .= pretty_number($CurrentPlanet['cristal_max'] / 1000) ." ". $lang['k'].""; + + if ($CurrentPlanet['deuterium_max'] < $CurrentPlanet['deuterium']) { + $parse['deuterium_max'] = ""; + } else { + $parse['deuterium_max'] = ""; + } + $parse['deuterium_max'] .= pretty_number($CurrentPlanet['deuterium_max'] / 1000) ." ". $lang['k'].""; + + $parse['metal_total'] = colorNumber( pretty_number( floor( ( $CurrentPlanet['metal_perhour'] * 0.01 * $parse['production_level'] ) + $parse['metal_basic_income']))); + $parse['crystal_total'] = colorNumber( pretty_number( floor( ( $CurrentPlanet['cristal_perhour'] * 0.01 * $parse['production_level'] ) + $parse['crystal_basic_income']))); + $parse['deuterium_total'] = colorNumber( pretty_number( floor( ( $CurrentPlanet['deuterium_perhour'] * 0.01 * $parse['production_level'] ) + $parse['deuterium_basic_income']))); + $parse['energy_total'] = colorNumber( pretty_number( floor( ( $CurrentPlanet['energy_max'] + $parse['energy_basic_income'] ) + $CurrentPlanet['energy_used'] ) ) ); + + $parse['daily_metal'] = floor($CurrentPlanet['metal_perhour'] * 24 * 0.01 * $parse['production_level'] + $parse['metal_basic_income'] * 24 ); + $parse['weekly_metal'] = floor($CurrentPlanet['metal_perhour'] * 24 * 7 * 0.01 * $parse['production_level'] + $parse['metal_basic_income'] * 24 * 7 ); + $parse['monthly_metal'] = floor($CurrentPlanet['metal_perhour'] * 24 * 30 * 0.01 * $parse['production_level'] + $parse['metal_basic_income'] * 24 * 30 ); + + $parse['daily_crystal'] = floor($CurrentPlanet['cristal_perhour'] * 24 * 0.01 * $parse['production_level'] + $parse['crystal_basic_income'] * 24 ); + $parse['weekly_crystal'] = floor($CurrentPlanet['cristal_perhour'] * 24 * 7 * 0.01 * $parse['production_level'] + $parse['crystal_basic_income'] * 24 * 7 ); + $parse['monthly_crystal'] = floor($CurrentPlanet['cristal_perhour'] * 24 * 30 * 0.01 * $parse['production_level'] + $parse['crystal_basic_income'] * 24 * 30 ); + + $parse['daily_deuterium'] = floor($CurrentPlanet['deuterium_perhour'] * 24 * 0.01 * $parse['production_level'] + $parse['deuterium_basic_income'] * 24 ); + $parse['weekly_deuterium'] = floor($CurrentPlanet['deuterium_perhour'] * 24 * 7 * 0.01 * $parse['production_level'] + $parse['deuterium_basic_income'] * 24 * 7 ); + $parse['monthly_deuterium'] = floor($CurrentPlanet['deuterium_perhour'] * 24 * 30 * 0.01 * $parse['production_level'] + $parse['deuterium_basic_income'] * 24 * 30 ); + + $parse['daily_metal'] = colorNumber(pretty_number($parse['daily_metal'])); + $parse['weekly_metal'] = colorNumber(pretty_number($parse['weekly_metal'])); + $parse['monthly_metal'] = colorNumber(pretty_number($parse['monthly_metal'])); + + $parse['daily_crystal'] = colorNumber(pretty_number($parse['daily_crystal'])); + $parse['weekly_crystal'] = colorNumber(pretty_number($parse['weekly_crystal'])); + $parse['monthly_crystal'] = colorNumber(pretty_number($parse['monthly_crystal'])); + + $parse['daily_deuterium'] = colorNumber(pretty_number($parse['daily_deuterium'])); + $parse['weekly_deuterium'] = colorNumber(pretty_number($parse['weekly_deuterium'])); + $parse['monthly_deuterium'] = colorNumber(pretty_number($parse['monthly_deuterium'])); + + $parse['metal_storage'] = floor($CurrentPlanet['metal'] / $CurrentPlanet['metal_max'] * 100) . $lang['o/o']; + $parse['crystal_storage'] = floor($CurrentPlanet['cristal'] / $CurrentPlanet['cristal_max'] * 100) . $lang['o/o']; + $parse['deuterium_storage'] = floor($CurrentPlanet['deuterium'] / $CurrentPlanet['deuterium_max'] * 100) . $lang['o/o']; + $parse['metal_storage_bar'] = floor(($CurrentPlanet['metal'] / $CurrentPlanet['metal_max'] * 100) * 2.5); + $parse['crystal_storage_bar'] = floor(($CurrentPlanet['cristal'] / $CurrentPlanet['cristal_max'] * 100) * 2.5); + $parse['deuterium_storage_bar'] = floor(($CurrentPlanet['deuterium'] / $CurrentPlanet['deuterium_max'] * 100) * 2.5); + + if ($parse['metal_storage_bar'] > (100 * 2.5)) { + $parse['metal_storage_bar'] = 250; + $parse['metal_storage_barcolor'] = '#C00000'; + } elseif ($parse['metal_storage_bar'] > (80 * 2.5)) { + $parse['metal_storage_barcolor'] = '#C0C000'; + } else { + $parse['metal_storage_barcolor'] = '#00C000'; + } + + if ($parse['crystal_storage_bar'] > (100 * 2.5)) { + $parse['crystal_storage_bar'] = 250; + $parse['crystal_storage_barcolor'] = '#C00000'; + } elseif ($parse['crystal_storage_bar'] > (80 * 2.5)) { + $parse['crystal_storage_barcolor'] = '#C0C000'; + } else { + $parse['crystal_storage_barcolor'] = '#00C000'; + } + + if ($parse['deuterium_storage_bar'] > (100 * 2.5)) { + $parse['deuterium_storage_bar'] = 250; + $parse['deuterium_storage_barcolor'] = '#C00000'; + } elseif ($parse['deuterium_storage_bar'] > (80 * 2.5)) { + $parse['deuterium_storage_barcolor'] = '#C0C000'; + } else { + $parse['deuterium_storage_barcolor'] = '#00C000'; + } + + $parse['production_level_bar'] = $parse['production_level'] * 2.5; + $parse['production_level'] = "{$parse['production_level']}%"; + $parse['production_level_barcolor'] = '#00ff00'; + + $QryUpdatePlanet = "UPDATE {{table}} SET "; + $QryUpdatePlanet .= "`id` = '". $CurrentPlanet['id'] ."' "; + $QryUpdatePlanet .= $SubQry; + $QryUpdatePlanet .= "WHERE "; + $QryUpdatePlanet .= "`id` = '". $CurrentPlanet['id'] ."';"; + doquery( $QryUpdatePlanet, 'planets'); + + $page = parsetemplate( $RessBodyTPL, $parse ); + + return $page; +} + +$user = Wootook_Player_Model_Session::getSingleton()->getPlayer(); +$planet = $user->getCurrentPlanet(); + +$Page = BuildRessourcePage($user, $planet); +display($Page, 'Resources', false); + +// ----------------------------------------------------------------------------------------------------------- +// History version +// 1.0 - Passage en fonction pour utilisation Wootook +?> diff --git a/robots.txt b/src/robots.txt similarity index 100% rename from robots.txt rename to src/robots.txt diff --git a/rules.php b/src/rules.php similarity index 67% rename from rules.php rename to src/rules.php index c8a9a5d..195682c 100644 --- a/rules.php +++ b/src/rules.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,23 +24,20 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); -require_once dirname(__FILE__) .'/common.php'; +require_once dirname(__FILE__) .'/application/bootstrap.php'; - includeLang('rules'); +includeLang('rules'); - $parse = $lang; - $parse['servername'] = $gameConfig['game_name']; +$parse = $lang; +$parse['servername'] = Wootook::getGameConfig('game/general/name'); - $PageTPL = gettemplate('rules_body'); - $page = parsetemplate( $PageTPL, $parse); +$PageTPL = gettemplate('rules_body'); +$page = parsetemplate( $PageTPL, $parse); - display($page, $lang['rules'], false); - - -?> \ No newline at end of file +display($page, $lang['rules'], false); diff --git a/rw.php b/src/rw.php similarity index 89% rename from rw.php rename to src/rw.php index aacae26..3e1603d 100644 --- a/rw.php +++ b/src/rw.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,13 +24,13 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ define('INSIDE' , true); define('INSTALL' , false); -require_once dirname(__FILE__) .'/common.php'; +require_once dirname(__FILE__) .'/application/bootstrap.php'; $open = true; diff --git a/scripts/7_nieaktywni.user.js b/src/scripts/7_nieaktywni.user.js similarity index 100% rename from scripts/7_nieaktywni.user.js rename to src/scripts/7_nieaktywni.user.js diff --git a/scripts/chat.js b/src/scripts/chat.js similarity index 100% rename from scripts/chat.js rename to src/scripts/chat.js diff --git a/scripts/cnt.js b/src/scripts/cnt.js similarity index 100% rename from scripts/cnt.js rename to src/scripts/cnt.js diff --git a/scripts/cntchar.js b/src/scripts/cntchar.js similarity index 100% rename from scripts/cntchar.js rename to src/scripts/cntchar.js diff --git a/scripts/cntfe.js b/src/scripts/cntfe.js similarity index 100% rename from scripts/cntfe.js rename to src/scripts/cntfe.js diff --git a/scripts/cntfs.js b/src/scripts/cntfs.js similarity index 100% rename from scripts/cntfs.js rename to src/scripts/cntfs.js diff --git a/scripts/cntneu.js b/src/scripts/cntneu.js similarity index 100% rename from scripts/cntneu.js rename to src/scripts/cntneu.js diff --git a/scripts/cntneu2.js b/src/scripts/cntneu2.js similarity index 100% rename from scripts/cntneu2.js rename to src/scripts/cntneu2.js diff --git a/src/scripts/createbanner.php b/src/scripts/createbanner.php new file mode 100644 index 0000000..3520f82 --- /dev/null +++ b/src/scripts/createbanner.php @@ -0,0 +1,107 @@ + 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. + * + */ +define('DISABLE_IDENTITY_CHECK', true); +require_once dirname(dirname(__FILE__)) . '/application/bootstrap.php'; + +define('FONT_FILE', dirname(__FILE__) . '/resources/fonts/visitor/visitor.ttf'); +define('BACKGROUND_FILE', dirname(__FILE__) . '/resources/backgrounds/default.png'); +define('TIMEZONE', 'Europe/Paris'); + +date_default_timezone_set(TIMEZONE); + +if (isset($_GET['id'])) { + $id = (int) $_GET['id']; +} else { + header('HTTP/1.1 412 Precondition Failed'); + die(); +} + +$textColor = array( + Wootook_Core_Model_Image_Png::COLOR_RED => 0xEF, + Wootook_Core_Model_Image_Png::COLOR_GREEN => 0xEF, + Wootook_Core_Model_Image_Png::COLOR_BLUE => 0xEF + ); + +$db = Wootook_Core_Database_ConnectionManager::getSingleton()->getConnection(Wootook_Core_Database_ConnectionManager::DEFAULT_CONNECTION_NAME); +$statement = $db->select() + ->column(array('username' => 'username'), 'user') + ->column(array('planet_name' => 'name'), 'planet') + ->column(array('build_points' => 'build_points', 'fleet_points' => 'fleet_points', 'tech_points' => 'tech_points', 'total_points' => 'total_points'), 'stats') + ->from(array('user' => $db->getTable('users'))) + ->joinLeft(array('stats' => $db->getTable('statpoints')), 'stats.id_owner=users.id') + ->joinLeft(array('planet' => $db->getTable('planets')), 'planet.id_owner=users.id') + ->where('user.id', $id) + ->prepare() +; + + +$data = array_merge( + array( + 'game_name' => Wootook::getGameConfig('game/general/name'), + 'date' => date('d M Y') + ), + $statement->fetch() + ); + +$image = new Wootook_Core_Model_Image_Png(); +$image + ->setBackground(BACKGROUND_FILE) + ->addText($data['game_name'], 24, FONT_FILE, 5, 37, 0, $textColor) + ->addText($data['username'], 24, FONT_FILE, 250, 37, 0, $textColor) + + ->addText('Batiments:', + 14, FONT_FILE, 5, 50, 0, $textColor) + ->addText(Math::render($data['build_points']), 14, FONT_FILE, 100, 50, 0, $textColor) + ->addText('Flottes:', 14, FONT_FILE, 5, 70, 0, $textColor) + ->addText(Math::render($data['fleet_points']), 14, FONT_FILE, 100, 70, 0, $textColor) + + ->addText('Technologies:', 14, FONT_FILE, 205, 50, 0, $textColor) + ->addText(Math::render($data['tech_points']), 14, FONT_FILE, 320, 50, 0, $textColor) + ->addText('Total:', 14, FONT_FILE, 205, 70, 0, $textColor) + ->addText(Math::render($data['total_points']), 14, FONT_FILE, 320, 70, 0, $textColor) +; + +foreach ($image->getHeaders() as $headerName => $headerValue) { + header(sprintf('%s: %s', $headerName, $headerValue)); +} + +echo $image->render(); diff --git a/scripts/cst.js b/src/scripts/cst.js similarity index 100% rename from scripts/cst.js rename to src/scripts/cst.js diff --git a/scripts/flotten.js b/src/scripts/flotten.js similarity index 94% rename from scripts/flotten.js rename to src/scripts/flotten.js index cccd8be..7169506 100644 --- a/scripts/flotten.js +++ b/src/scripts/flotten.js @@ -52,10 +52,10 @@ function min(a, b) { function maxspeed() { var msp = 1000000000; for (i = 200; i < 220; i++) { - if (document.getElementsByName("ship" + i)[0]) { - if ((document.getElementsByName("speed" + i)[0].value * 1) >= 1 - && (document.getElementsByName("ship" + i)[0].value * 1) >= 1) { - msp = min(msp, document.getElementsByName("speed" + i)[0].value); + if (document.getElementsByName("ship[" + i + "]")[0]) { + if ((document.getElementsByName("speed[" + i + "]")[0].value * 1) >= 1 + && (document.getElementsByName("ship[" + i + "]")[0].value * 1) >= 1) { + msp = min(msp, document.getElementsByName("speed[" + i + "]")[0].value); } } } @@ -113,10 +113,10 @@ function consumption2() { var basicConsumption = 0; for (i = 200; i < 220; i++) { - if (document.getElementsByName("ship" + i)[0]) { + if (document.getElementsByName("ship[" + i + "]")[0]) { basicConsumption = basicConsumption + - document.getElementsByName("consumption" + i)[0].value - * document.getElementsByName("ship" + i)[0].value; + document.getElementsByName("consumption[" + i + "]")[0].value + * document.getElementsByName("ship[" + i + "]")[0].value; } } @@ -143,16 +143,16 @@ function consumption() { speedfactor = document.getElementsByName("speedfactor")[0].value; for (i = 200; i < 220; i++) { - if (document.getElementsByName("ship" + i)[0]) { - shipspeed = document.getElementsByName("speed" + i)[0].value; + if (document.getElementsByName("ship[" + i + "]")[0]) { + shipspeed = document.getElementsByName("speed[" + i + "]")[0].value; spd = 35000 / (dur * speedfactor - 10) * Math.sqrt(dist * 10 / shipspeed); //spd = Math.max(msp / document.getElementsByName("speed" + i)[0].value, 0.1); //spd = Math.min(spd, 1.0); //spd = spd * sp; //spd = 10; - basicConsumption = document.getElementsByName("consumption" + i)[0].value - * document.getElementsByName("ship" + i)[0].value; + basicConsumption = document.getElementsByName("consumption[" + i + "]")[0].value + * document.getElementsByName("ship[" + i + "]")[0].value; consumption += basicConsumption * dist / 35000 * ((spd / 10) + 1) * ((spd / 10) + 1); // values = values + " " + spd; } @@ -208,11 +208,11 @@ function storage() { for (i = 200; i < 300; i++) { - if (document.getElementsByName("ship" + i)[0]) { - if ((document.getElementsByName("ship" + i)[0].value * 1) >= 1) { + if (document.getElementsByName("ship[" + i + "]")[0]) { + if ((document.getElementsByName("ship[" + i + "]")[0].value * 1) >= 1) { storage - += document.getElementsByName("ship" + i)[0].value - * document.getElementsByName("capacity" + i)[0].value + += document.getElementsByName("ship[" + i + "]")[0].value + * document.getElementsByName("capacity[" + i + "]")[0].value } } } @@ -359,7 +359,7 @@ function maxShip(id) { function maxShips() { var id; for (i = 200; i < 220; i++) { - id = "ship"+i; + id = "ship["+i+"]"; maxShip(id); } } @@ -375,7 +375,7 @@ function noShip(id) { function noShips (){ var id; for (i = 200; i < 220; i++) { - id = "ship"+i; + id = "ship["+i+"]"; noShip(id); } } diff --git a/scripts/functions.js b/src/scripts/functions.js similarity index 100% rename from scripts/functions.js rename to src/scripts/functions.js diff --git a/scripts/gsc.1.js b/src/scripts/gsc.1.js similarity index 100% rename from scripts/gsc.1.js rename to src/scripts/gsc.1.js diff --git a/scripts/jquery.js b/src/scripts/jquery.js similarity index 100% rename from scripts/jquery.js rename to src/scripts/jquery.js diff --git a/src/scripts/jquery/jquery-1.6.4.js b/src/scripts/jquery/jquery-1.6.4.js new file mode 100644 index 0000000..11e6d06 --- /dev/null +++ b/src/scripts/jquery/jquery-1.6.4.js @@ -0,0 +1,9046 @@ +/*! + * jQuery JavaScript Library v1.6.4 + * http://jquery.com/ + * + * Copyright 2011, John Resig + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * Includes Sizzle.js + * http://sizzlejs.com/ + * Copyright 2011, The Dojo Foundation + * Released under the MIT, BSD, and GPL Licenses. + * + * Date: Mon Sep 12 18:54:48 2011 -0400 + */ +(function( window, undefined ) { + +// Use the correct document accordingly with window argument (sandbox) +var document = window.document, + navigator = window.navigator, + location = window.location; +var jQuery = (function() { + +// Define a local copy of jQuery +var jQuery = function( selector, context ) { + // The jQuery object is actually just the init constructor 'enhanced' + return new jQuery.fn.init( selector, context, rootjQuery ); + }, + + // Map over jQuery in case of overwrite + _jQuery = window.jQuery, + + // Map over the $ in case of overwrite + _$ = window.$, + + // A central reference to the root jQuery(document) + rootjQuery, + + // A simple way to check for HTML strings or ID strings + // Prioritize #id over to avoid XSS via location.hash (#9521) + quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/, + + // Check if a string has a non-whitespace character in it + rnotwhite = /\S/, + + // Used for trimming whitespace + trimLeft = /^\s+/, + trimRight = /\s+$/, + + // Check for digits + rdigit = /\d/, + + // Match a standalone tag + rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/, + + // JSON RegExp + rvalidchars = /^[\],:{}\s]*$/, + rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, + rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, + rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g, + + // Useragent RegExp + rwebkit = /(webkit)[ \/]([\w.]+)/, + ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/, + rmsie = /(msie) ([\w.]+)/, + rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/, + + // Matches dashed string for camelizing + rdashAlpha = /-([a-z]|[0-9])/ig, + rmsPrefix = /^-ms-/, + + // Used by jQuery.camelCase as callback to replace() + fcamelCase = function( all, letter ) { + return ( letter + "" ).toUpperCase(); + }, + + // Keep a UserAgent string for use with jQuery.browser + userAgent = navigator.userAgent, + + // For matching the engine and version of the browser + browserMatch, + + // The deferred used on DOM ready + readyList, + + // The ready event handler + DOMContentLoaded, + + // Save a reference to some core methods + toString = Object.prototype.toString, + hasOwn = Object.prototype.hasOwnProperty, + push = Array.prototype.push, + slice = Array.prototype.slice, + trim = String.prototype.trim, + indexOf = Array.prototype.indexOf, + + // [[Class]] -> type pairs + class2type = {}; + +jQuery.fn = jQuery.prototype = { + constructor: jQuery, + init: function( selector, context, rootjQuery ) { + var match, elem, ret, doc; + + // Handle $(""), $(null), or $(undefined) + if ( !selector ) { + return this; + } + + // Handle $(DOMElement) + if ( selector.nodeType ) { + this.context = this[0] = selector; + this.length = 1; + return this; + } + + // The body element only exists once, optimize finding it + if ( selector === "body" && !context && document.body ) { + this.context = document; + this[0] = document.body; + this.selector = selector; + this.length = 1; + return this; + } + + // Handle HTML strings + if ( typeof selector === "string" ) { + // Are we dealing with HTML string or an ID? + if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) { + // Assume that strings that start and end with <> are HTML and skip the regex check + match = [ null, selector, null ]; + + } else { + match = quickExpr.exec( selector ); + } + + // Verify a match, and that no context was specified for #id + if ( match && (match[1] || !context) ) { + + // HANDLE: $(html) -> $(array) + if ( match[1] ) { + context = context instanceof jQuery ? context[0] : context; + doc = (context ? context.ownerDocument || context : document); + + // If a single string is passed in and it's a single tag + // just do a createElement and skip the rest + ret = rsingleTag.exec( selector ); + + if ( ret ) { + if ( jQuery.isPlainObject( context ) ) { + selector = [ document.createElement( ret[1] ) ]; + jQuery.fn.attr.call( selector, context, true ); + + } else { + selector = [ doc.createElement( ret[1] ) ]; + } + + } else { + ret = jQuery.buildFragment( [ match[1] ], [ doc ] ); + selector = (ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment).childNodes; + } + + return jQuery.merge( this, selector ); + + // HANDLE: $("#id") + } else { + elem = document.getElementById( match[2] ); + + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + if ( elem && elem.parentNode ) { + // Handle the case where IE and Opera return items + // by name instead of ID + if ( elem.id !== match[2] ) { + return rootjQuery.find( selector ); + } + + // Otherwise, we inject the element directly into the jQuery object + this.length = 1; + this[0] = elem; + } + + this.context = document; + this.selector = selector; + return this; + } + + // HANDLE: $(expr, $(...)) + } else if ( !context || context.jquery ) { + return (context || rootjQuery).find( selector ); + + // HANDLE: $(expr, context) + // (which is just equivalent to: $(context).find(expr) + } else { + return this.constructor( context ).find( selector ); + } + + // HANDLE: $(function) + // Shortcut for document ready + } else if ( jQuery.isFunction( selector ) ) { + return rootjQuery.ready( selector ); + } + + if (selector.selector !== undefined) { + this.selector = selector.selector; + this.context = selector.context; + } + + return jQuery.makeArray( selector, this ); + }, + + // Start with an empty selector + selector: "", + + // The current version of jQuery being used + jquery: "1.6.4", + + // The default length of a jQuery object is 0 + length: 0, + + // The number of elements contained in the matched element set + size: function() { + return this.length; + }, + + toArray: function() { + return slice.call( this, 0 ); + }, + + // Get the Nth element in the matched element set OR + // Get the whole matched element set as a clean array + get: function( num ) { + return num == null ? + + // Return a 'clean' array + this.toArray() : + + // Return just the object + ( num < 0 ? this[ this.length + num ] : this[ num ] ); + }, + + // Take an array of elements and push it onto the stack + // (returning the new matched element set) + pushStack: function( elems, name, selector ) { + // Build a new jQuery matched element set + var ret = this.constructor(); + + if ( jQuery.isArray( elems ) ) { + push.apply( ret, elems ); + + } else { + jQuery.merge( ret, elems ); + } + + // Add the old object onto the stack (as a reference) + ret.prevObject = this; + + ret.context = this.context; + + if ( name === "find" ) { + ret.selector = this.selector + (this.selector ? " " : "") + selector; + } else if ( name ) { + ret.selector = this.selector + "." + name + "(" + selector + ")"; + } + + // Return the newly-formed element set + return ret; + }, + + // Execute a callback for every element in the matched set. + // (You can seed the arguments with an array of args, but this is + // only used internally.) + each: function( callback, args ) { + return jQuery.each( this, callback, args ); + }, + + ready: function( fn ) { + // Attach the listeners + jQuery.bindReady(); + + // Add the callback + readyList.done( fn ); + + return this; + }, + + eq: function( i ) { + return i === -1 ? + this.slice( i ) : + this.slice( i, +i + 1 ); + }, + + first: function() { + return this.eq( 0 ); + }, + + last: function() { + return this.eq( -1 ); + }, + + slice: function() { + return this.pushStack( slice.apply( this, arguments ), + "slice", slice.call(arguments).join(",") ); + }, + + map: function( callback ) { + return this.pushStack( jQuery.map(this, function( elem, i ) { + return callback.call( elem, i, elem ); + })); + }, + + end: function() { + return this.prevObject || this.constructor(null); + }, + + // For internal use only. + // Behaves like an Array's method, not like a jQuery method. + push: push, + sort: [].sort, + splice: [].splice +}; + +// Give the init function the jQuery prototype for later instantiation +jQuery.fn.init.prototype = jQuery.fn; + +jQuery.extend = jQuery.fn.extend = function() { + var options, name, src, copy, copyIsArray, clone, + target = arguments[0] || {}, + i = 1, + length = arguments.length, + deep = false; + + // Handle a deep copy situation + if ( typeof target === "boolean" ) { + deep = target; + target = arguments[1] || {}; + // skip the boolean and the target + i = 2; + } + + // Handle case when target is a string or something (possible in deep copy) + if ( typeof target !== "object" && !jQuery.isFunction(target) ) { + target = {}; + } + + // extend jQuery itself if only one argument is passed + if ( length === i ) { + target = this; + --i; + } + + for ( ; i < length; i++ ) { + // Only deal with non-null/undefined values + if ( (options = arguments[ i ]) != null ) { + // Extend the base object + for ( name in options ) { + src = target[ name ]; + copy = options[ name ]; + + // Prevent never-ending loop + if ( target === copy ) { + continue; + } + + // Recurse if we're merging plain objects or arrays + if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) { + if ( copyIsArray ) { + copyIsArray = false; + clone = src && jQuery.isArray(src) ? src : []; + + } else { + clone = src && jQuery.isPlainObject(src) ? src : {}; + } + + // Never move original objects, clone them + target[ name ] = jQuery.extend( deep, clone, copy ); + + // Don't bring in undefined values + } else if ( copy !== undefined ) { + target[ name ] = copy; + } + } + } + } + + // Return the modified object + return target; +}; + +jQuery.extend({ + noConflict: function( deep ) { + if ( window.$ === jQuery ) { + window.$ = _$; + } + + if ( deep && window.jQuery === jQuery ) { + window.jQuery = _jQuery; + } + + return jQuery; + }, + + // Is the DOM ready to be used? Set to true once it occurs. + isReady: false, + + // A counter to track how many items to wait for before + // the ready event fires. See #6781 + readyWait: 1, + + // Hold (or release) the ready event + holdReady: function( hold ) { + if ( hold ) { + jQuery.readyWait++; + } else { + jQuery.ready( true ); + } + }, + + // Handle when the DOM is ready + ready: function( wait ) { + // Either a released hold or an DOMready/load event and not yet ready + if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) { + // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). + if ( !document.body ) { + return setTimeout( jQuery.ready, 1 ); + } + + // Remember that the DOM is ready + jQuery.isReady = true; + + // If a normal DOM Ready event fired, decrement, and wait if need be + if ( wait !== true && --jQuery.readyWait > 0 ) { + return; + } + + // If there are functions bound, to execute + readyList.resolveWith( document, [ jQuery ] ); + + // Trigger any bound ready events + if ( jQuery.fn.trigger ) { + jQuery( document ).trigger( "ready" ).unbind( "ready" ); + } + } + }, + + bindReady: function() { + if ( readyList ) { + return; + } + + readyList = jQuery._Deferred(); + + // Catch cases where $(document).ready() is called after the + // browser event has already occurred. + if ( document.readyState === "complete" ) { + // Handle it asynchronously to allow scripts the opportunity to delay ready + return setTimeout( jQuery.ready, 1 ); + } + + // Mozilla, Opera and webkit nightlies currently support this event + if ( document.addEventListener ) { + // Use the handy event callback + document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false ); + + // A fallback to window.onload, that will always work + window.addEventListener( "load", jQuery.ready, false ); + + // If IE event model is used + } else if ( document.attachEvent ) { + // ensure firing before onload, + // maybe late but safe also for iframes + document.attachEvent( "onreadystatechange", DOMContentLoaded ); + + // A fallback to window.onload, that will always work + window.attachEvent( "onload", jQuery.ready ); + + // If IE and not a frame + // continually check to see if the document is ready + var toplevel = false; + + try { + toplevel = window.frameElement == null; + } catch(e) {} + + if ( document.documentElement.doScroll && toplevel ) { + doScrollCheck(); + } + } + }, + + // See test/unit/core.js for details concerning isFunction. + // Since version 1.3, DOM methods and functions like alert + // aren't supported. They return false on IE (#2968). + isFunction: function( obj ) { + return jQuery.type(obj) === "function"; + }, + + isArray: Array.isArray || function( obj ) { + return jQuery.type(obj) === "array"; + }, + + // A crude way of determining if an object is a window + isWindow: function( obj ) { + return obj && typeof obj === "object" && "setInterval" in obj; + }, + + isNaN: function( obj ) { + return obj == null || !rdigit.test( obj ) || isNaN( obj ); + }, + + type: function( obj ) { + return obj == null ? + String( obj ) : + class2type[ toString.call(obj) ] || "object"; + }, + + isPlainObject: function( obj ) { + // Must be an Object. + // Because of IE, we also have to check the presence of the constructor property. + // Make sure that DOM nodes and window objects don't pass through, as well + if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { + return false; + } + + try { + // Not own constructor property must be Object + if ( obj.constructor && + !hasOwn.call(obj, "constructor") && + !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { + return false; + } + } catch ( e ) { + // IE8,9 Will throw exceptions on certain host objects #9897 + return false; + } + + // Own properties are enumerated firstly, so to speed up, + // if last one is own, then all properties are own. + + var key; + for ( key in obj ) {} + + return key === undefined || hasOwn.call( obj, key ); + }, + + isEmptyObject: function( obj ) { + for ( var name in obj ) { + return false; + } + return true; + }, + + error: function( msg ) { + throw msg; + }, + + parseJSON: function( data ) { + if ( typeof data !== "string" || !data ) { + return null; + } + + // Make sure leading/trailing whitespace is removed (IE can't handle it) + data = jQuery.trim( data ); + + // Attempt to parse using the native JSON parser first + if ( window.JSON && window.JSON.parse ) { + return window.JSON.parse( data ); + } + + // Make sure the incoming data is actual JSON + // Logic borrowed from http://json.org/json2.js + if ( rvalidchars.test( data.replace( rvalidescape, "@" ) + .replace( rvalidtokens, "]" ) + .replace( rvalidbraces, "")) ) { + + return (new Function( "return " + data ))(); + + } + jQuery.error( "Invalid JSON: " + data ); + }, + + // Cross-browser xml parsing + parseXML: function( data ) { + var xml, tmp; + try { + if ( window.DOMParser ) { // Standard + tmp = new DOMParser(); + xml = tmp.parseFromString( data , "text/xml" ); + } else { // IE + xml = new ActiveXObject( "Microsoft.XMLDOM" ); + xml.async = "false"; + xml.loadXML( data ); + } + } catch( e ) { + xml = undefined; + } + if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) { + jQuery.error( "Invalid XML: " + data ); + } + return xml; + }, + + noop: function() {}, + + // Evaluates a script in a global context + // Workarounds based on findings by Jim Driscoll + // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context + globalEval: function( data ) { + if ( data && rnotwhite.test( data ) ) { + // We use execScript on Internet Explorer + // We use an anonymous function so that context is window + // rather than jQuery in Firefox + ( window.execScript || function( data ) { + window[ "eval" ].call( window, data ); + } )( data ); + } + }, + + // Convert dashed to camelCase; used by the css and data modules + // Microsoft forgot to hump their vendor prefix (#9572) + camelCase: function( string ) { + return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); + }, + + nodeName: function( elem, name ) { + return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase(); + }, + + // args is for internal usage only + each: function( object, callback, args ) { + var name, i = 0, + length = object.length, + isObj = length === undefined || jQuery.isFunction( object ); + + if ( args ) { + if ( isObj ) { + for ( name in object ) { + if ( callback.apply( object[ name ], args ) === false ) { + break; + } + } + } else { + for ( ; i < length; ) { + if ( callback.apply( object[ i++ ], args ) === false ) { + break; + } + } + } + + // A special, fast, case for the most common use of each + } else { + if ( isObj ) { + for ( name in object ) { + if ( callback.call( object[ name ], name, object[ name ] ) === false ) { + break; + } + } + } else { + for ( ; i < length; ) { + if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) { + break; + } + } + } + } + + return object; + }, + + // Use native String.trim function wherever possible + trim: trim ? + function( text ) { + return text == null ? + "" : + trim.call( text ); + } : + + // Otherwise use our own trimming functionality + function( text ) { + return text == null ? + "" : + text.toString().replace( trimLeft, "" ).replace( trimRight, "" ); + }, + + // results is for internal usage only + makeArray: function( array, results ) { + var ret = results || []; + + if ( array != null ) { + // The window, strings (and functions) also have 'length' + // The extra typeof function check is to prevent crashes + // in Safari 2 (See: #3039) + // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930 + var type = jQuery.type( array ); + + if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) { + push.call( ret, array ); + } else { + jQuery.merge( ret, array ); + } + } + + return ret; + }, + + inArray: function( elem, array ) { + if ( !array ) { + return -1; + } + + if ( indexOf ) { + return indexOf.call( array, elem ); + } + + for ( var i = 0, length = array.length; i < length; i++ ) { + if ( array[ i ] === elem ) { + return i; + } + } + + return -1; + }, + + merge: function( first, second ) { + var i = first.length, + j = 0; + + if ( typeof second.length === "number" ) { + for ( var l = second.length; j < l; j++ ) { + first[ i++ ] = second[ j ]; + } + + } else { + while ( second[j] !== undefined ) { + first[ i++ ] = second[ j++ ]; + } + } + + first.length = i; + + return first; + }, + + grep: function( elems, callback, inv ) { + var ret = [], retVal; + inv = !!inv; + + // Go through the array, only saving the items + // that pass the validator function + for ( var i = 0, length = elems.length; i < length; i++ ) { + retVal = !!callback( elems[ i ], i ); + if ( inv !== retVal ) { + ret.push( elems[ i ] ); + } + } + + return ret; + }, + + // arg is for internal usage only + map: function( elems, callback, arg ) { + var value, key, ret = [], + i = 0, + length = elems.length, + // jquery objects are treated as arrays + isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ; + + // Go through the array, translating each of the items to their + if ( isArray ) { + for ( ; i < length; i++ ) { + value = callback( elems[ i ], i, arg ); + + if ( value != null ) { + ret[ ret.length ] = value; + } + } + + // Go through every key on the object, + } else { + for ( key in elems ) { + value = callback( elems[ key ], key, arg ); + + if ( value != null ) { + ret[ ret.length ] = value; + } + } + } + + // Flatten any nested arrays + return ret.concat.apply( [], ret ); + }, + + // A global GUID counter for objects + guid: 1, + + // Bind a function to a context, optionally partially applying any + // arguments. + proxy: function( fn, context ) { + if ( typeof context === "string" ) { + var tmp = fn[ context ]; + context = fn; + fn = tmp; + } + + // Quick check to determine if target is callable, in the spec + // this throws a TypeError, but we will just return undefined. + if ( !jQuery.isFunction( fn ) ) { + return undefined; + } + + // Simulated bind + var args = slice.call( arguments, 2 ), + proxy = function() { + return fn.apply( context, args.concat( slice.call( arguments ) ) ); + }; + + // Set the guid of unique handler to the same of original handler, so it can be removed + proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++; + + return proxy; + }, + + // Mutifunctional method to get and set values to a collection + // The value/s can optionally be executed if it's a function + access: function( elems, key, value, exec, fn, pass ) { + var length = elems.length; + + // Setting many attributes + if ( typeof key === "object" ) { + for ( var k in key ) { + jQuery.access( elems, k, key[k], exec, fn, value ); + } + return elems; + } + + // Setting one attribute + if ( value !== undefined ) { + // Optionally, function values get executed if exec is true + exec = !pass && exec && jQuery.isFunction(value); + + for ( var i = 0; i < length; i++ ) { + fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass ); + } + + return elems; + } + + // Getting an attribute + return length ? fn( elems[0], key ) : undefined; + }, + + now: function() { + return (new Date()).getTime(); + }, + + // Use of jQuery.browser is frowned upon. + // More details: http://docs.jquery.com/Utilities/jQuery.browser + uaMatch: function( ua ) { + ua = ua.toLowerCase(); + + var match = rwebkit.exec( ua ) || + ropera.exec( ua ) || + rmsie.exec( ua ) || + ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) || + []; + + return { browser: match[1] || "", version: match[2] || "0" }; + }, + + sub: function() { + function jQuerySub( selector, context ) { + return new jQuerySub.fn.init( selector, context ); + } + jQuery.extend( true, jQuerySub, this ); + jQuerySub.superclass = this; + jQuerySub.fn = jQuerySub.prototype = this(); + jQuerySub.fn.constructor = jQuerySub; + jQuerySub.sub = this.sub; + jQuerySub.fn.init = function init( selector, context ) { + if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) { + context = jQuerySub( context ); + } + + return jQuery.fn.init.call( this, selector, context, rootjQuerySub ); + }; + jQuerySub.fn.init.prototype = jQuerySub.fn; + var rootjQuerySub = jQuerySub(document); + return jQuerySub; + }, + + browser: {} +}); + +// Populate the class2type map +jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) { + class2type[ "[object " + name + "]" ] = name.toLowerCase(); +}); + +browserMatch = jQuery.uaMatch( userAgent ); +if ( browserMatch.browser ) { + jQuery.browser[ browserMatch.browser ] = true; + jQuery.browser.version = browserMatch.version; +} + +// Deprecated, use jQuery.browser.webkit instead +if ( jQuery.browser.webkit ) { + jQuery.browser.safari = true; +} + +// IE doesn't match non-breaking spaces with \s +if ( rnotwhite.test( "\xA0" ) ) { + trimLeft = /^[\s\xA0]+/; + trimRight = /[\s\xA0]+$/; +} + +// All jQuery objects should point back to these +rootjQuery = jQuery(document); + +// Cleanup functions for the document ready method +if ( document.addEventListener ) { + DOMContentLoaded = function() { + document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false ); + jQuery.ready(); + }; + +} else if ( document.attachEvent ) { + DOMContentLoaded = function() { + // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). + if ( document.readyState === "complete" ) { + document.detachEvent( "onreadystatechange", DOMContentLoaded ); + jQuery.ready(); + } + }; +} + +// The DOM ready check for Internet Explorer +function doScrollCheck() { + if ( jQuery.isReady ) { + return; + } + + try { + // If IE is used, use the trick by Diego Perini + // http://javascript.nwbox.com/IEContentLoaded/ + document.documentElement.doScroll("left"); + } catch(e) { + setTimeout( doScrollCheck, 1 ); + return; + } + + // and execute any waiting functions + jQuery.ready(); +} + +return jQuery; + +})(); + + +var // Promise methods + promiseMethods = "done fail isResolved isRejected promise then always pipe".split( " " ), + // Static reference to slice + sliceDeferred = [].slice; + +jQuery.extend({ + // Create a simple deferred (one callbacks list) + _Deferred: function() { + var // callbacks list + callbacks = [], + // stored [ context , args ] + fired, + // to avoid firing when already doing so + firing, + // flag to know if the deferred has been cancelled + cancelled, + // the deferred itself + deferred = { + + // done( f1, f2, ...) + done: function() { + if ( !cancelled ) { + var args = arguments, + i, + length, + elem, + type, + _fired; + if ( fired ) { + _fired = fired; + fired = 0; + } + for ( i = 0, length = args.length; i < length; i++ ) { + elem = args[ i ]; + type = jQuery.type( elem ); + if ( type === "array" ) { + deferred.done.apply( deferred, elem ); + } else if ( type === "function" ) { + callbacks.push( elem ); + } + } + if ( _fired ) { + deferred.resolveWith( _fired[ 0 ], _fired[ 1 ] ); + } + } + return this; + }, + + // resolve with given context and args + resolveWith: function( context, args ) { + if ( !cancelled && !fired && !firing ) { + // make sure args are available (#8421) + args = args || []; + firing = 1; + try { + while( callbacks[ 0 ] ) { + callbacks.shift().apply( context, args ); + } + } + finally { + fired = [ context, args ]; + firing = 0; + } + } + return this; + }, + + // resolve with this as context and given arguments + resolve: function() { + deferred.resolveWith( this, arguments ); + return this; + }, + + // Has this deferred been resolved? + isResolved: function() { + return !!( firing || fired ); + }, + + // Cancel + cancel: function() { + cancelled = 1; + callbacks = []; + return this; + } + }; + + return deferred; + }, + + // Full fledged deferred (two callbacks list) + Deferred: function( func ) { + var deferred = jQuery._Deferred(), + failDeferred = jQuery._Deferred(), + promise; + // Add errorDeferred methods, then and promise + jQuery.extend( deferred, { + then: function( doneCallbacks, failCallbacks ) { + deferred.done( doneCallbacks ).fail( failCallbacks ); + return this; + }, + always: function() { + return deferred.done.apply( deferred, arguments ).fail.apply( this, arguments ); + }, + fail: failDeferred.done, + rejectWith: failDeferred.resolveWith, + reject: failDeferred.resolve, + isRejected: failDeferred.isResolved, + pipe: function( fnDone, fnFail ) { + return jQuery.Deferred(function( newDefer ) { + jQuery.each( { + done: [ fnDone, "resolve" ], + fail: [ fnFail, "reject" ] + }, function( handler, data ) { + var fn = data[ 0 ], + action = data[ 1 ], + returned; + if ( jQuery.isFunction( fn ) ) { + deferred[ handler ](function() { + returned = fn.apply( this, arguments ); + if ( returned && jQuery.isFunction( returned.promise ) ) { + returned.promise().then( newDefer.resolve, newDefer.reject ); + } else { + newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] ); + } + }); + } else { + deferred[ handler ]( newDefer[ action ] ); + } + }); + }).promise(); + }, + // Get a promise for this deferred + // If obj is provided, the promise aspect is added to the object + promise: function( obj ) { + if ( obj == null ) { + if ( promise ) { + return promise; + } + promise = obj = {}; + } + var i = promiseMethods.length; + while( i-- ) { + obj[ promiseMethods[i] ] = deferred[ promiseMethods[i] ]; + } + return obj; + } + }); + // Make sure only one callback list will be used + deferred.done( failDeferred.cancel ).fail( deferred.cancel ); + // Unexpose cancel + delete deferred.cancel; + // Call given func if any + if ( func ) { + func.call( deferred, deferred ); + } + return deferred; + }, + + // Deferred helper + when: function( firstParam ) { + var args = arguments, + i = 0, + length = args.length, + count = length, + deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ? + firstParam : + jQuery.Deferred(); + function resolveFunc( i ) { + return function( value ) { + args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value; + if ( !( --count ) ) { + // Strange bug in FF4: + // Values changed onto the arguments object sometimes end up as undefined values + // outside the $.when method. Cloning the object into a fresh array solves the issue + deferred.resolveWith( deferred, sliceDeferred.call( args, 0 ) ); + } + }; + } + if ( length > 1 ) { + for( ; i < length; i++ ) { + if ( args[ i ] && jQuery.isFunction( args[ i ].promise ) ) { + args[ i ].promise().then( resolveFunc(i), deferred.reject ); + } else { + --count; + } + } + if ( !count ) { + deferred.resolveWith( deferred, args ); + } + } else if ( deferred !== firstParam ) { + deferred.resolveWith( deferred, length ? [ firstParam ] : [] ); + } + return deferred.promise(); + } +}); + + + +jQuery.support = (function() { + + var div = document.createElement( "div" ), + documentElement = document.documentElement, + all, + a, + select, + opt, + input, + marginDiv, + support, + fragment, + body, + testElementParent, + testElement, + testElementStyle, + tds, + events, + eventName, + i, + isSupported; + + // Preliminary tests + div.setAttribute("className", "t"); + div.innerHTML = "
    ". $title ."
    "; - $zniszczony = false; - $a_zestrzelona = 0; - $AttackTechon['A'] = $CurrentTechno["military_tech"] * 10; - $AttackTechon['B'] = $CurrentTechno["defence_tech"] * 10; - $AttackTechon['C'] = $CurrentTechno["shield_tech"] * 10; - $AttackerData = sprintf ($lang['sys_attack_attacker_pos'], $CurrentUser["username"], $FleetRow['fleet_start_galaxy'], $FleetRow['fleet_start_system'], $FleetRow['fleet_start_planet'] ); - $AttackerTech = sprintf ($lang['sys_attack_techologies'], $AttackTechon['A'], $AttackTechon['B'], $AttackTechon['C']); - - $DefendTechon['A'] = $TargetTechno["military_tech"] * 10; - $DefendTechon['B'] = $TargetTechno["defence_tech"] * 10; - $DefendTechon['C'] = $TargetTechno["shield_tech"] * 10; - $DefenderData = sprintf ($lang['sys_attack_defender_pos'], $TargetUser["username"], $FleetRow['fleet_end_galaxy'], $FleetRow['fleet_end_system'], $FleetRow['fleet_end_planet'] ); - $DefenderTech = sprintf ($lang['sys_attack_techologies'], $DefendTechon['A'], $DefendTechon['B'], $DefendTechon['C']); - - foreach ($dane_do_rw as $a => $b) { - $raport .= "

    ".$AttackerData."
    ".$AttackerTech.""; - if ($b["atakujacy"]['count'] > 0) { - $raport1 = ""; - $raport2 = ""; - $raport3 = ""; - $raport4 = ""; - $raport5 = ""; - foreach ($b["atakujacy"] as $Ship => $Data) { - if (is_numeric($Ship)) { - if ($Data['count'] > 0) { - $raport1 .= ""; - $raport2 .= ""; - $raport3 .= ""; - $raport4 .= ""; - $raport5 .= ""; - } - } - } - $raport1 .= ""; - $raport2 .= ""; - $raport3 .= ""; - $raport4 .= ""; - $raport5 .= ""; - $raport .= $raport1 . $raport2 . $raport3 . $raport4 . $raport5; - } else { - if ($a == 2) { - $a_zestrzelona = 1; - } - $zniszczony = true; - $raport .= "
    ". $lang['sys_destroyed']; - } - - $raport .= "
    ".$lang['sys_ship_type']."
    ".$lang['sys_ship_count']."
    ".$lang['sys_ship_weapon']."
    ".$lang['sys_ship_shield']."
    ".$lang['sys_ship_armour']."". $lang["tech_rc"][$Ship] ."". $Data['count'] ."". round($Data["atak"] / $Data['count']) ."". round($Data["tarcza"] / $Data['count']) ."". round($Data["obrona"] / $Data['count']) ."
    "; - $raport .= "

    ".$DefenderData."
    ".$DefenderTech.""; - if ($b["wrog"]['count'] > 0) { - $raport1 = ""; - $raport2 = ""; - $raport3 = ""; - $raport4 = ""; - $raport5 = ""; - foreach ($b["wrog"] as $Ship => $Data) { - if (is_numeric($Ship)) { - if ($Data['count'] > 0) { - $raport1 .= ""; - $raport2 .= ""; - $raport3 .= ""; - $raport4 .= ""; - $raport5 .= ""; - } - } - } - $raport1 .= ""; - $raport2 .= ""; - $raport3 .= ""; - $raport4 .= ""; - $raport5 .= ""; - $raport .= $raport1 . $raport2 . $raport3 . $raport4 . $raport5; - } else { - $zniszczony = true; - $raport .= "
    ". $lang['sys_destroyed']; - } $raport .= "
    ".$lang['sys_ship_type']."
    ".$lang['sys_ship_count']."
    ".$lang['sys_ship_weapon']."
    ".$lang['sys_ship_shield']."
    ".$lang['sys_ship_armour']."". $lang["tech_rc"][$Ship] ."". $Data['count'] ."". round($Data["atak"] / $Data['count']) ."". round($Data["tarcza"] / $Data['count']) ."". round($Data["obrona"] / $Data['count']) ."
    "; - - if (($zniszczony == false) and !($a == 8)) { $AttackWaveStat = sprintf ($lang['sys_attack_attack_wave'], floor($b["atakujacy"]["atak"]), floor($b["wrog"]["tarcza"])); $DefendWavaStat = sprintf ($lang['sys_attack_defend_wave'], floor($b["wrog"]["atak"]), floor($b["atakujacy"]["tarcza"])); diff --git a/includes/functions/MissionCaseExpedition.php b/src/includes/functions/MissionCaseExpedition.php similarity index 97% rename from includes/functions/MissionCaseExpedition.php rename to src/includes/functions/MissionCaseExpedition.php index 59fab4f..d2b264c 100644 --- a/includes/functions/MissionCaseExpedition.php +++ b/src/includes/functions/MissionCaseExpedition.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/src/includes/functions/MissionCaseExploit.php b/src/includes/functions/MissionCaseExploit.php new file mode 100644 index 0000000..5b424c6 --- /dev/null +++ b/src/includes/functions/MissionCaseExploit.php @@ -0,0 +1,137 @@ + + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License + * along with this program. If not, see . + * + * --> 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. + * + */ + +/** + * + * @deprecated + * @param unknown_type $fleet + */ +function MissionCaseExploit($fleet) +{ + global $lang; + + $prices = Wootook_Empire_Helper_Config_Prices::getSingleton(); + $player = Wootook_Player_Model_Session::getSingleton()->getPlayer(); + $writeAdapter = Wootook_Core_Database_ConnectionManager::getSingleton()->getConnection('core_write'); + + $userId = $fleet['fleet_owner']; + $MessSender = $lang['sys_mess_qg']; + $MessTitle = $lang['sys_expe_report']; + + if ($fleet['fleet_mess'] == 0) { + if ($fleet['fleet_end_stay'] < time()) { + $stayDuration = ($fleet['fleet_end_stay'] - $fleet['fleet_start_time']); + + $shipList = array(); + $fleetCapacity = array(); + $storageShips = array( + Legacies_Empire::ID_SHIP_ORE_MININER, + Legacies_Empire::ID_SHIP_DEATH_STAR, + Legacies_Empire::ID_SHIP_LIGHT_TRANSPORT, + Legacies_Empire::ID_SHIP_LARGE_TRANSPORT, + Legacies_Empire::ID_SHIP_SUPERNOVA, + ); + foreach (explode(";", $fleet['fleet_array']) as $shipData) { + if ($shipData) { + $shipData = explode(',', $shipData); + if (count($shipData) != 2) { + continue; + } + + $shipList[$shipData[0]] = $shipData[1]; + + if (in_array($shipData[0], $storageShips) && isset($prices[$shipData[0]]) && isset($prices[$shipData[0]]['capacity'])) { + $fleetCapacity += $prices[$shipData[0]]['capacity']; + } + } + } + + if (!isset($shipList[Legacies_Empire::ID_SHIP_ORE_MININER])) { + return; + } + + $fleetSentResources = $fleet['fleet_resource_metal'] + $fleet['fleet_resource_crystal'] + $fleet['fleet_resource_deuterium']; + $fleetAvailableCapacity = $fleetCapacity - $fleetSentResources; + + $minerCount = $shipList[Legacies_Empire::ID_SHIP_ORE_MININER]; + + mt_srand(); + $miningAmount = Math::mul(Math::mul($minerCount, $stayDuration), Math::pow(1.2, $player->getElement(Legacies_Empire::ID_RESEARCH_ORE_MINING))); + + $random = mt_rand(1, 10000); + $metalOreAmount = Math::mul($miningAmount, Math::div($random, 10000)); + + $random = mt_rand(1, 10000); + $cristalOreAmount = Math::mul($miningAmount, Math::div($random, 10000)); + + $totalOreAmount = Math::add($metalOreAmount, $cristalOreAmount); + if (Math::comp($totalOreAmount, $fleetAvailableCapacity) > 0) { + $ratio = Math::div($fleetAvailableCapacity, $totalOreAmount); + + $metalOreAmount = Math::mul($metalOreAmount, $ratio); + $cristalOreAmount = Math::mul($cristalOreAmount, $ratio); + } + + $statement = $writeAdapter->update() + ->into($writeAdapter->getTable('fleets')) + ->set('fleet_resource_metal', Math::add($fleet['fleet_resource_metal'], $metalOreAmount)) + ->set('fleet_resource_crystal', Math::add($fleet['fleet_resource_crystal'], $cristalOreAmount)) + ->prepare() + ; + $statement->execute(); + } + } else { + // La Flotte est de retour a quai + if ($fleet['fleet_end_time'] < time()) { + $coords = array( + 'galaxy' => $fleet['fleet_start_galaxy'], + 'system' => $fleet['fleet_start_system'], + 'position' => $fleet['fleet_start_planet'] + ); + $planet = Wootook_Empire_Model_Planet::factoryFromCoords($coords, $fleet['fleet_start_type']); + if (!$planet->getId() || $planet->getPlayerId() != $player->getId()) + foreach (explode(";", $fleet['fleet_array']) as $shipData) { + if ($shipData) { + $shipData = explode(',', $shipData); + if (count($shipData) != 2) { + continue; + } + + $planet->setElement($shipData[0], Math::add($planet->getElement($shipData[0]), $shipData[1])); + } + } + $planet->save(); + + SendSimpleMessage($userId, '', $fleet['fleet_end_time'], 15, $MessSender, $MessTitle, $lang['sys_expe_back_home']); + + $writeAdapter->delete()->from($writeAdapter->getTable('fleets'))->where('fleet_id', $fleet['fleet_id']); + } + } +} diff --git a/includes/functions/MissionCaseRecycling.php b/src/includes/functions/MissionCaseRecycling.php similarity index 96% rename from includes/functions/MissionCaseRecycling.php rename to src/includes/functions/MissionCaseRecycling.php index 32da545..37de570 100644 --- a/includes/functions/MissionCaseRecycling.php +++ b/src/includes/functions/MissionCaseRecycling.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/includes/functions/MissionCaseSpy.php b/src/includes/functions/MissionCaseSpy.php similarity index 96% rename from includes/functions/MissionCaseSpy.php rename to src/includes/functions/MissionCaseSpy.php index ea19b9f..8c4f343 100644 --- a/includes/functions/MissionCaseSpy.php +++ b/src/includes/functions/MissionCaseSpy.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ @@ -37,7 +37,7 @@ function MissionCaseSpy($FleetRow) { global $lang; - $resource = Legacies_Empire_Model_Game_FieldsAlias::getSingleton(); + $resource = Wootook_Empire_Helper_Config_FieldsAlias::getSingleton(); if ($FleetRow['fleet_start_time'] <= time()) { // refactored parts @@ -61,7 +61,7 @@ function MissionCaseSpy($FleetRow) /* * Update planet resources and constructions */ - Legacies::dispatchEvent('planet.update', array( + Wootook::dispatchEvent('planet.update', array( 'planet' => $TargetPlanet )); $TargetPlanet->save(); diff --git a/includes/functions/MissionCaseStay.php b/src/includes/functions/MissionCaseStay.php similarity index 95% rename from includes/functions/MissionCaseStay.php rename to src/includes/functions/MissionCaseStay.php index 721f23c..1e2fe63 100644 --- a/includes/functions/MissionCaseStay.php +++ b/src/includes/functions/MissionCaseStay.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/includes/functions/MissionCaseStayAlly.php b/src/includes/functions/MissionCaseStayAlly.php similarity index 94% rename from includes/functions/MissionCaseStayAlly.php rename to src/includes/functions/MissionCaseStayAlly.php index 039ec23..2a41ab1 100644 --- a/includes/functions/MissionCaseStayAlly.php +++ b/src/includes/functions/MissionCaseStayAlly.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/includes/functions/MissionCaseTransport.php b/src/includes/functions/MissionCaseTransport.php similarity index 95% rename from includes/functions/MissionCaseTransport.php rename to src/includes/functions/MissionCaseTransport.php index 5b2e698..ec9dea5 100644 --- a/includes/functions/MissionCaseTransport.php +++ b/src/includes/functions/MissionCaseTransport.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/includes/functions/RestoreFleetToPlanet.php b/src/includes/functions/RestoreFleetToPlanet.php similarity index 92% rename from includes/functions/RestoreFleetToPlanet.php rename to src/includes/functions/RestoreFleetToPlanet.php index e187b29..d2c9041 100644 --- a/includes/functions/RestoreFleetToPlanet.php +++ b/src/includes/functions/RestoreFleetToPlanet.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/includes/functions/RevisionTime.php b/src/includes/functions/RevisionTime.php similarity index 90% rename from includes/functions/RevisionTime.php rename to src/includes/functions/RevisionTime.php index 652bec8..69581b1 100644 --- a/includes/functions/RevisionTime.php +++ b/src/includes/functions/RevisionTime.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/includes/functions/SendSimpleMessage.php b/src/includes/functions/SendSimpleMessage.php similarity index 90% rename from includes/functions/SendSimpleMessage.php rename to src/includes/functions/SendSimpleMessage.php index 249e08f..3d2b0ab 100644 --- a/includes/functions/SendSimpleMessage.php +++ b/src/includes/functions/SendSimpleMessage.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ @@ -49,7 +49,7 @@ function SendSimpleMessage ( $Owner, $Sender, $Time, $Type, $From, $Subject, $Me $QryInsertMessage = "INSERT INTO {{table}} SET "; $QryInsertMessage .= "`message_owner` = '". $Owner ."', "; $QryInsertMessage .= "`message_sender` = '". $Sender ."', "; - $QryInsertMessage .= "`message_time` = '" . $Time . "', "; +// $QryInsertMessage .= "`message_time` = '" . $Time . "', "; $QryInsertMessage .= "`message_type` = '". $Type ."', "; $QryInsertMessage .= "`message_from` = '". addslashes( $From ) ."', "; $QryInsertMessage .= "`message_subject` = '". addslashes( $Subject ) ."', "; diff --git a/includes/functions/ShowGalaxyFooter.php b/src/includes/functions/ShowGalaxyFooter.php similarity index 94% rename from includes/functions/ShowGalaxyFooter.php rename to src/includes/functions/ShowGalaxyFooter.php index 7b70103..8c0636e 100644 --- a/includes/functions/ShowGalaxyFooter.php +++ b/src/includes/functions/ShowGalaxyFooter.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/includes/functions/ShowGalaxyMISelector.php b/src/includes/functions/ShowGalaxyMISelector.php similarity index 92% rename from includes/functions/ShowGalaxyMISelector.php rename to src/includes/functions/ShowGalaxyMISelector.php index a2ec2d0..ae64ee4 100644 --- a/includes/functions/ShowGalaxyMISelector.php +++ b/src/includes/functions/ShowGalaxyMISelector.php @@ -1,11 +1,11 @@ + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ * --> 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 XNova. + * documentation for further information about customizing Wootook. * */ diff --git a/src/includes/functions/ShowGalaxyRows.php b/src/includes/functions/ShowGalaxyRows.php new file mode 100644 index 0000000..fa5eef7 --- /dev/null +++ b/src/includes/functions/ShowGalaxyRows.php @@ -0,0 +1,121 @@ + + * All rights reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License + * along with this program. If not, see . + * + * --> 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. + * + */ + +/** + * + * @deprecated + * @param int $Galaxy + * @param int $System + */ +function ShowGalaxyRows($Galaxy, $System) +{ + global $planetcount; + + $readAdapter = Wootook_Core_Database_ConnectionManager::getSingleton()->getConnection('core_read'); + + $galaxyStatement = $readAdapter->select() + ->column('*') + ->from($readAdapter->getTable('galaxy')) + ->where('galaxy', $Galaxy) + ->where('system', $System) + ->where('planet', new Wootook_Core_Database_Sql_Placeholder_Variable('planet')) + ->limit(1) + ->prepare() + ; + + $planetStatement = $readAdapter->select() + ->column('*') + ->from($readAdapter->getTable('planets')) + ->where('id', new Wootook_Core_Database_Sql_Placeholder_Variable('planet_id')) + ->limit(1) + ->prepare() + ; + + $output = ""; + for ($Planet = 1; $Planet <= Wootook::getGameConfig('engine/universe/positions'); $Planet++) { + if ($galaxyStatement->execute(array('planet' => $Planet))) { + /** @var Wootook_Empire_Model_Galaxy_Position $galaxyPosition */ + $galaxyPosition = $galaxyStatement->fetchEntity('Wootook_Empire_Model_Galaxy_Position'); + } else { + $output .= '
    ". stripslashes( $CurMess['message_subject'] ) ." "; if ($CurMess['message_type'] == 1) { $page .= ""; - $page .= "\"".$lang['mess_answer']."\"
    ". date("m-d H:i:s O", $CurMess['message_time']) ."". date("d-m-Y H:i:s", strtotime($CurMess['message_time'])) ."". stripslashes( $CurMess['message_from'] ) ."". stripslashes( $CurMess['message_subject'] ) ." "; if ($CurMess['message_type'] == 1) { $page .= ""; - $page .= "\"".$lang['mess_answer']."\"
    a"; + + + all = div.getElementsByTagName( "*" ); + a = div.getElementsByTagName( "a" )[ 0 ]; + + // Can't get basic test support + if ( !all || !all.length || !a ) { + return {}; + } + + // First batch of supports tests + select = document.createElement( "select" ); + opt = select.appendChild( document.createElement("option") ); + input = div.getElementsByTagName( "input" )[ 0 ]; + + support = { + // IE strips leading whitespace when .innerHTML is used + leadingWhitespace: ( div.firstChild.nodeType === 3 ), + + // Make sure that tbody elements aren't automatically inserted + // IE will insert them into empty tables + tbody: !div.getElementsByTagName( "tbody" ).length, + + // Make sure that link elements get serialized correctly by innerHTML + // This requires a wrapper element in IE + htmlSerialize: !!div.getElementsByTagName( "link" ).length, + + // Get the style information from getAttribute + // (IE uses .cssText instead) + style: /top/.test( a.getAttribute("style") ), + + // Make sure that URLs aren't manipulated + // (IE normalizes it by default) + hrefNormalized: ( a.getAttribute( "href" ) === "/a" ), + + // Make sure that element opacity exists + // (IE uses filter instead) + // Use a regex to work around a WebKit issue. See #5145 + opacity: /^0.55$/.test( a.style.opacity ), + + // Verify style float existence + // (IE uses styleFloat instead of cssFloat) + cssFloat: !!a.style.cssFloat, + + // Make sure that if no value is specified for a checkbox + // that it defaults to "on". + // (WebKit defaults to "" instead) + checkOn: ( input.value === "on" ), + + // Make sure that a selected-by-default option has a working selected property. + // (WebKit defaults to false instead of true, IE too, if it's in an optgroup) + optSelected: opt.selected, + + // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7) + getSetAttribute: div.className !== "t", + + // Will be defined later + submitBubbles: true, + changeBubbles: true, + focusinBubbles: false, + deleteExpando: true, + noCloneEvent: true, + inlineBlockNeedsLayout: false, + shrinkWrapBlocks: false, + reliableMarginRight: true + }; + + // Make sure checked status is properly cloned + input.checked = true; + support.noCloneChecked = input.cloneNode( true ).checked; + + // Make sure that the options inside disabled selects aren't marked as disabled + // (WebKit marks them as disabled) + select.disabled = true; + support.optDisabled = !opt.disabled; + + // Test to see if it's possible to delete an expando from an element + // Fails in Internet Explorer + try { + delete div.test; + } catch( e ) { + support.deleteExpando = false; + } + + if ( !div.addEventListener && div.attachEvent && div.fireEvent ) { + div.attachEvent( "onclick", function() { + // Cloning a node shouldn't copy over any + // bound event handlers (IE does this) + support.noCloneEvent = false; + }); + div.cloneNode( true ).fireEvent( "onclick" ); + } + + // Check if a radio maintains it's value + // after being appended to the DOM + input = document.createElement("input"); + input.value = "t"; + input.setAttribute("type", "radio"); + support.radioValue = input.value === "t"; + + input.setAttribute("checked", "checked"); + div.appendChild( input ); + fragment = document.createDocumentFragment(); + fragment.appendChild( div.firstChild ); + + // WebKit doesn't clone checked state correctly in fragments + support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked; + + div.innerHTML = ""; + + // Figure out if the W3C box model works as expected + div.style.width = div.style.paddingLeft = "1px"; + + body = document.getElementsByTagName( "body" )[ 0 ]; + // We use our own, invisible, body unless the body is already present + // in which case we use a div (#9239) + testElement = document.createElement( body ? "div" : "body" ); + testElementStyle = { + visibility: "hidden", + width: 0, + height: 0, + border: 0, + margin: 0, + background: "none" + }; + if ( body ) { + jQuery.extend( testElementStyle, { + position: "absolute", + left: "-1000px", + top: "-1000px" + }); + } + for ( i in testElementStyle ) { + testElement.style[ i ] = testElementStyle[ i ]; + } + testElement.appendChild( div ); + testElementParent = body || documentElement; + testElementParent.insertBefore( testElement, testElementParent.firstChild ); + + // Check if a disconnected checkbox will retain its checked + // value of true after appended to the DOM (IE6/7) + support.appendChecked = input.checked; + + support.boxModel = div.offsetWidth === 2; + + if ( "zoom" in div.style ) { + // Check if natively block-level elements act like inline-block + // elements when setting their display to 'inline' and giving + // them layout + // (IE < 8 does this) + div.style.display = "inline"; + div.style.zoom = 1; + support.inlineBlockNeedsLayout = ( div.offsetWidth === 2 ); + + // Check if elements with layout shrink-wrap their children + // (IE 6 does this) + div.style.display = ""; + div.innerHTML = "
    "; + support.shrinkWrapBlocks = ( div.offsetWidth !== 2 ); + } + + div.innerHTML = "
    t
    "; + tds = div.getElementsByTagName( "td" ); + + // Check if table cells still have offsetWidth/Height when they are set + // to display:none and there are still other visible table cells in a + // table row; if so, offsetWidth/Height are not reliable for use when + // determining if an element has been hidden directly using + // display:none (it is still safe to use offsets if a parent element is + // hidden; don safety goggles and see bug #4512 for more information). + // (only IE 8 fails this test) + isSupported = ( tds[ 0 ].offsetHeight === 0 ); + + tds[ 0 ].style.display = ""; + tds[ 1 ].style.display = "none"; + + // Check if empty table cells still have offsetWidth/Height + // (IE < 8 fail this test) + support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 ); + div.innerHTML = ""; + + // Check if div with explicit width and no margin-right incorrectly + // gets computed margin-right based on width of container. For more + // info see bug #3333 + // Fails in WebKit before Feb 2011 nightlies + // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right + if ( document.defaultView && document.defaultView.getComputedStyle ) { + marginDiv = document.createElement( "div" ); + marginDiv.style.width = "0"; + marginDiv.style.marginRight = "0"; + div.appendChild( marginDiv ); + support.reliableMarginRight = + ( parseInt( ( document.defaultView.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0; + } + + // Remove the body element we added + testElement.innerHTML = ""; + testElementParent.removeChild( testElement ); + + // Technique from Juriy Zaytsev + // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/ + // We only care about the case where non-standard event systems + // are used, namely in IE. Short-circuiting here helps us to + // avoid an eval call (in setAttribute) which can cause CSP + // to go haywire. See: https://developer.mozilla.org/en/Security/CSP + if ( div.attachEvent ) { + for( i in { + submit: 1, + change: 1, + focusin: 1 + } ) { + eventName = "on" + i; + isSupported = ( eventName in div ); + if ( !isSupported ) { + div.setAttribute( eventName, "return;" ); + isSupported = ( typeof div[ eventName ] === "function" ); + } + support[ i + "Bubbles" ] = isSupported; + } + } + + // Null connected elements to avoid leaks in IE + testElement = fragment = select = opt = body = marginDiv = div = input = null; + + return support; +})(); + +// Keep track of boxModel +jQuery.boxModel = jQuery.support.boxModel; + + + + +var rbrace = /^(?:\{.*\}|\[.*\])$/, + rmultiDash = /([A-Z])/g; + +jQuery.extend({ + cache: {}, + + // Please use with caution + uuid: 0, + + // Unique for each copy of jQuery on the page + // Non-digits removed to match rinlinejQuery + expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ), + + // The following elements throw uncatchable exceptions if you + // attempt to add expando properties to them. + noData: { + "embed": true, + // Ban all objects except for Flash (which handle expandos) + "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000", + "applet": true + }, + + hasData: function( elem ) { + elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ]; + + return !!elem && !isEmptyDataObject( elem ); + }, + + data: function( elem, name, data, pvt /* Internal Use Only */ ) { + if ( !jQuery.acceptData( elem ) ) { + return; + } + + var thisCache, ret, + internalKey = jQuery.expando, + getByName = typeof name === "string", + + // We have to handle DOM nodes and JS objects differently because IE6-7 + // can't GC object references properly across the DOM-JS boundary + isNode = elem.nodeType, + + // Only DOM nodes need the global jQuery cache; JS object data is + // attached directly to the object so GC can occur automatically + cache = isNode ? jQuery.cache : elem, + + // Only defining an ID for JS objects if its cache already exists allows + // the code to shortcut on the same path as a DOM node with no cache + id = isNode ? elem[ jQuery.expando ] : elem[ jQuery.expando ] && jQuery.expando; + + // Avoid doing any more work than we need to when trying to get data on an + // object that has no data at all + if ( (!id || (pvt && id && (cache[ id ] && !cache[ id ][ internalKey ]))) && getByName && data === undefined ) { + return; + } + + if ( !id ) { + // Only DOM nodes need a new unique ID for each element since their data + // ends up in the global cache + if ( isNode ) { + elem[ jQuery.expando ] = id = ++jQuery.uuid; + } else { + id = jQuery.expando; + } + } + + if ( !cache[ id ] ) { + cache[ id ] = {}; + + // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery + // metadata on plain JS objects when the object is serialized using + // JSON.stringify + if ( !isNode ) { + cache[ id ].toJSON = jQuery.noop; + } + } + + // An object can be passed to jQuery.data instead of a key/value pair; this gets + // shallow copied over onto the existing cache + if ( typeof name === "object" || typeof name === "function" ) { + if ( pvt ) { + cache[ id ][ internalKey ] = jQuery.extend(cache[ id ][ internalKey ], name); + } else { + cache[ id ] = jQuery.extend(cache[ id ], name); + } + } + + thisCache = cache[ id ]; + + // Internal jQuery data is stored in a separate object inside the object's data + // cache in order to avoid key collisions between internal data and user-defined + // data + if ( pvt ) { + if ( !thisCache[ internalKey ] ) { + thisCache[ internalKey ] = {}; + } + + thisCache = thisCache[ internalKey ]; + } + + if ( data !== undefined ) { + thisCache[ jQuery.camelCase( name ) ] = data; + } + + // TODO: This is a hack for 1.5 ONLY. It will be removed in 1.6. Users should + // not attempt to inspect the internal events object using jQuery.data, as this + // internal data object is undocumented and subject to change. + if ( name === "events" && !thisCache[name] ) { + return thisCache[ internalKey ] && thisCache[ internalKey ].events; + } + + // Check for both converted-to-camel and non-converted data property names + // If a data property was specified + if ( getByName ) { + + // First Try to find as-is property data + ret = thisCache[ name ]; + + // Test for null|undefined property data + if ( ret == null ) { + + // Try to find the camelCased property + ret = thisCache[ jQuery.camelCase( name ) ]; + } + } else { + ret = thisCache; + } + + return ret; + }, + + removeData: function( elem, name, pvt /* Internal Use Only */ ) { + if ( !jQuery.acceptData( elem ) ) { + return; + } + + var thisCache, + + // Reference to internal data cache key + internalKey = jQuery.expando, + + isNode = elem.nodeType, + + // See jQuery.data for more information + cache = isNode ? jQuery.cache : elem, + + // See jQuery.data for more information + id = isNode ? elem[ jQuery.expando ] : jQuery.expando; + + // If there is already no cache entry for this object, there is no + // purpose in continuing + if ( !cache[ id ] ) { + return; + } + + if ( name ) { + + thisCache = pvt ? cache[ id ][ internalKey ] : cache[ id ]; + + if ( thisCache ) { + + // Support interoperable removal of hyphenated or camelcased keys + if ( !thisCache[ name ] ) { + name = jQuery.camelCase( name ); + } + + delete thisCache[ name ]; + + // If there is no data left in the cache, we want to continue + // and let the cache object itself get destroyed + if ( !isEmptyDataObject(thisCache) ) { + return; + } + } + } + + // See jQuery.data for more information + if ( pvt ) { + delete cache[ id ][ internalKey ]; + + // Don't destroy the parent cache unless the internal data object + // had been the only thing left in it + if ( !isEmptyDataObject(cache[ id ]) ) { + return; + } + } + + var internalCache = cache[ id ][ internalKey ]; + + // Browsers that fail expando deletion also refuse to delete expandos on + // the window, but it will allow it on all other JS objects; other browsers + // don't care + // Ensure that `cache` is not a window object #10080 + if ( jQuery.support.deleteExpando || !cache.setInterval ) { + delete cache[ id ]; + } else { + cache[ id ] = null; + } + + // We destroyed the entire user cache at once because it's faster than + // iterating through each key, but we need to continue to persist internal + // data if it existed + if ( internalCache ) { + cache[ id ] = {}; + // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery + // metadata on plain JS objects when the object is serialized using + // JSON.stringify + if ( !isNode ) { + cache[ id ].toJSON = jQuery.noop; + } + + cache[ id ][ internalKey ] = internalCache; + + // Otherwise, we need to eliminate the expando on the node to avoid + // false lookups in the cache for entries that no longer exist + } else if ( isNode ) { + // IE does not allow us to delete expando properties from nodes, + // nor does it have a removeAttribute function on Document nodes; + // we must handle all of these cases + if ( jQuery.support.deleteExpando ) { + delete elem[ jQuery.expando ]; + } else if ( elem.removeAttribute ) { + elem.removeAttribute( jQuery.expando ); + } else { + elem[ jQuery.expando ] = null; + } + } + }, + + // For internal use only. + _data: function( elem, name, data ) { + return jQuery.data( elem, name, data, true ); + }, + + // A method for determining if a DOM node can handle the data expando + acceptData: function( elem ) { + if ( elem.nodeName ) { + var match = jQuery.noData[ elem.nodeName.toLowerCase() ]; + + if ( match ) { + return !(match === true || elem.getAttribute("classid") !== match); + } + } + + return true; + } +}); + +jQuery.fn.extend({ + data: function( key, value ) { + var data = null; + + if ( typeof key === "undefined" ) { + if ( this.length ) { + data = jQuery.data( this[0] ); + + if ( this[0].nodeType === 1 ) { + var attr = this[0].attributes, name; + for ( var i = 0, l = attr.length; i < l; i++ ) { + name = attr[i].name; + + if ( name.indexOf( "data-" ) === 0 ) { + name = jQuery.camelCase( name.substring(5) ); + + dataAttr( this[0], name, data[ name ] ); + } + } + } + } + + return data; + + } else if ( typeof key === "object" ) { + return this.each(function() { + jQuery.data( this, key ); + }); + } + + var parts = key.split("."); + parts[1] = parts[1] ? "." + parts[1] : ""; + + if ( value === undefined ) { + data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]); + + // Try to fetch any internally stored data first + if ( data === undefined && this.length ) { + data = jQuery.data( this[0], key ); + data = dataAttr( this[0], key, data ); + } + + return data === undefined && parts[1] ? + this.data( parts[0] ) : + data; + + } else { + return this.each(function() { + var $this = jQuery( this ), + args = [ parts[0], value ]; + + $this.triggerHandler( "setData" + parts[1] + "!", args ); + jQuery.data( this, key, value ); + $this.triggerHandler( "changeData" + parts[1] + "!", args ); + }); + } + }, + + removeData: function( key ) { + return this.each(function() { + jQuery.removeData( this, key ); + }); + } +}); + +function dataAttr( elem, key, data ) { + // If nothing was found internally, try to fetch any + // data from the HTML5 data-* attribute + if ( data === undefined && elem.nodeType === 1 ) { + + var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase(); + + data = elem.getAttribute( name ); + + if ( typeof data === "string" ) { + try { + data = data === "true" ? true : + data === "false" ? false : + data === "null" ? null : + !jQuery.isNaN( data ) ? parseFloat( data ) : + rbrace.test( data ) ? jQuery.parseJSON( data ) : + data; + } catch( e ) {} + + // Make sure we set the data so it isn't changed later + jQuery.data( elem, key, data ); + + } else { + data = undefined; + } + } + + return data; +} + +// TODO: This is a hack for 1.5 ONLY to allow objects with a single toJSON +// property to be considered empty objects; this property always exists in +// order to make sure JSON.stringify does not expose internal metadata +function isEmptyDataObject( obj ) { + for ( var name in obj ) { + if ( name !== "toJSON" ) { + return false; + } + } + + return true; +} + + + + +function handleQueueMarkDefer( elem, type, src ) { + var deferDataKey = type + "defer", + queueDataKey = type + "queue", + markDataKey = type + "mark", + defer = jQuery.data( elem, deferDataKey, undefined, true ); + if ( defer && + ( src === "queue" || !jQuery.data( elem, queueDataKey, undefined, true ) ) && + ( src === "mark" || !jQuery.data( elem, markDataKey, undefined, true ) ) ) { + // Give room for hard-coded callbacks to fire first + // and eventually mark/queue something else on the element + setTimeout( function() { + if ( !jQuery.data( elem, queueDataKey, undefined, true ) && + !jQuery.data( elem, markDataKey, undefined, true ) ) { + jQuery.removeData( elem, deferDataKey, true ); + defer.resolve(); + } + }, 0 ); + } +} + +jQuery.extend({ + + _mark: function( elem, type ) { + if ( elem ) { + type = (type || "fx") + "mark"; + jQuery.data( elem, type, (jQuery.data(elem,type,undefined,true) || 0) + 1, true ); + } + }, + + _unmark: function( force, elem, type ) { + if ( force !== true ) { + type = elem; + elem = force; + force = false; + } + if ( elem ) { + type = type || "fx"; + var key = type + "mark", + count = force ? 0 : ( (jQuery.data( elem, key, undefined, true) || 1 ) - 1 ); + if ( count ) { + jQuery.data( elem, key, count, true ); + } else { + jQuery.removeData( elem, key, true ); + handleQueueMarkDefer( elem, type, "mark" ); + } + } + }, + + queue: function( elem, type, data ) { + if ( elem ) { + type = (type || "fx") + "queue"; + var q = jQuery.data( elem, type, undefined, true ); + // Speed up dequeue by getting out quickly if this is just a lookup + if ( data ) { + if ( !q || jQuery.isArray(data) ) { + q = jQuery.data( elem, type, jQuery.makeArray(data), true ); + } else { + q.push( data ); + } + } + return q || []; + } + }, + + dequeue: function( elem, type ) { + type = type || "fx"; + + var queue = jQuery.queue( elem, type ), + fn = queue.shift(), + defer; + + // If the fx queue is dequeued, always remove the progress sentinel + if ( fn === "inprogress" ) { + fn = queue.shift(); + } + + if ( fn ) { + // Add a progress sentinel to prevent the fx queue from being + // automatically dequeued + if ( type === "fx" ) { + queue.unshift("inprogress"); + } + + fn.call(elem, function() { + jQuery.dequeue(elem, type); + }); + } + + if ( !queue.length ) { + jQuery.removeData( elem, type + "queue", true ); + handleQueueMarkDefer( elem, type, "queue" ); + } + } +}); + +jQuery.fn.extend({ + queue: function( type, data ) { + if ( typeof type !== "string" ) { + data = type; + type = "fx"; + } + + if ( data === undefined ) { + return jQuery.queue( this[0], type ); + } + return this.each(function() { + var queue = jQuery.queue( this, type, data ); + + if ( type === "fx" && queue[0] !== "inprogress" ) { + jQuery.dequeue( this, type ); + } + }); + }, + dequeue: function( type ) { + return this.each(function() { + jQuery.dequeue( this, type ); + }); + }, + // Based off of the plugin by Clint Helfers, with permission. + // http://blindsignals.com/index.php/2009/07/jquery-delay/ + delay: function( time, type ) { + time = jQuery.fx ? jQuery.fx.speeds[time] || time : time; + type = type || "fx"; + + return this.queue( type, function() { + var elem = this; + setTimeout(function() { + jQuery.dequeue( elem, type ); + }, time ); + }); + }, + clearQueue: function( type ) { + return this.queue( type || "fx", [] ); + }, + // Get a promise resolved when queues of a certain type + // are emptied (fx is the type by default) + promise: function( type, object ) { + if ( typeof type !== "string" ) { + object = type; + type = undefined; + } + type = type || "fx"; + var defer = jQuery.Deferred(), + elements = this, + i = elements.length, + count = 1, + deferDataKey = type + "defer", + queueDataKey = type + "queue", + markDataKey = type + "mark", + tmp; + function resolve() { + if ( !( --count ) ) { + defer.resolveWith( elements, [ elements ] ); + } + } + while( i-- ) { + if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) || + ( jQuery.data( elements[ i ], queueDataKey, undefined, true ) || + jQuery.data( elements[ i ], markDataKey, undefined, true ) ) && + jQuery.data( elements[ i ], deferDataKey, jQuery._Deferred(), true ) )) { + count++; + tmp.done( resolve ); + } + } + resolve(); + return defer.promise(); + } +}); + + + + +var rclass = /[\n\t\r]/g, + rspace = /\s+/, + rreturn = /\r/g, + rtype = /^(?:button|input)$/i, + rfocusable = /^(?:button|input|object|select|textarea)$/i, + rclickable = /^a(?:rea)?$/i, + rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i, + nodeHook, boolHook; + +jQuery.fn.extend({ + attr: function( name, value ) { + return jQuery.access( this, name, value, true, jQuery.attr ); + }, + + removeAttr: function( name ) { + return this.each(function() { + jQuery.removeAttr( this, name ); + }); + }, + + prop: function( name, value ) { + return jQuery.access( this, name, value, true, jQuery.prop ); + }, + + removeProp: function( name ) { + name = jQuery.propFix[ name ] || name; + return this.each(function() { + // try/catch handles cases where IE balks (such as removing a property on window) + try { + this[ name ] = undefined; + delete this[ name ]; + } catch( e ) {} + }); + }, + + addClass: function( value ) { + var classNames, i, l, elem, + setClass, c, cl; + + if ( jQuery.isFunction( value ) ) { + return this.each(function( j ) { + jQuery( this ).addClass( value.call(this, j, this.className) ); + }); + } + + if ( value && typeof value === "string" ) { + classNames = value.split( rspace ); + + for ( i = 0, l = this.length; i < l; i++ ) { + elem = this[ i ]; + + if ( elem.nodeType === 1 ) { + if ( !elem.className && classNames.length === 1 ) { + elem.className = value; + + } else { + setClass = " " + elem.className + " "; + + for ( c = 0, cl = classNames.length; c < cl; c++ ) { + if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) { + setClass += classNames[ c ] + " "; + } + } + elem.className = jQuery.trim( setClass ); + } + } + } + } + + return this; + }, + + removeClass: function( value ) { + var classNames, i, l, elem, className, c, cl; + + if ( jQuery.isFunction( value ) ) { + return this.each(function( j ) { + jQuery( this ).removeClass( value.call(this, j, this.className) ); + }); + } + + if ( (value && typeof value === "string") || value === undefined ) { + classNames = (value || "").split( rspace ); + + for ( i = 0, l = this.length; i < l; i++ ) { + elem = this[ i ]; + + if ( elem.nodeType === 1 && elem.className ) { + if ( value ) { + className = (" " + elem.className + " ").replace( rclass, " " ); + for ( c = 0, cl = classNames.length; c < cl; c++ ) { + className = className.replace(" " + classNames[ c ] + " ", " "); + } + elem.className = jQuery.trim( className ); + + } else { + elem.className = ""; + } + } + } + } + + return this; + }, + + toggleClass: function( value, stateVal ) { + var type = typeof value, + isBool = typeof stateVal === "boolean"; + + if ( jQuery.isFunction( value ) ) { + return this.each(function( i ) { + jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal ); + }); + } + + return this.each(function() { + if ( type === "string" ) { + // toggle individual class names + var className, + i = 0, + self = jQuery( this ), + state = stateVal, + classNames = value.split( rspace ); + + while ( (className = classNames[ i++ ]) ) { + // check each className given, space seperated list + state = isBool ? state : !self.hasClass( className ); + self[ state ? "addClass" : "removeClass" ]( className ); + } + + } else if ( type === "undefined" || type === "boolean" ) { + if ( this.className ) { + // store className if set + jQuery._data( this, "__className__", this.className ); + } + + // toggle whole className + this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || ""; + } + }); + }, + + hasClass: function( selector ) { + var className = " " + selector + " "; + for ( var i = 0, l = this.length; i < l; i++ ) { + if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) { + return true; + } + } + + return false; + }, + + val: function( value ) { + var hooks, ret, + elem = this[0]; + + if ( !arguments.length ) { + if ( elem ) { + hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ]; + + if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { + return ret; + } + + ret = elem.value; + + return typeof ret === "string" ? + // handle most common string cases + ret.replace(rreturn, "") : + // handle cases where value is null/undef or number + ret == null ? "" : ret; + } + + return undefined; + } + + var isFunction = jQuery.isFunction( value ); + + return this.each(function( i ) { + var self = jQuery(this), val; + + if ( this.nodeType !== 1 ) { + return; + } + + if ( isFunction ) { + val = value.call( this, i, self.val() ); + } else { + val = value; + } + + // Treat null/undefined as ""; convert numbers to string + if ( val == null ) { + val = ""; + } else if ( typeof val === "number" ) { + val += ""; + } else if ( jQuery.isArray( val ) ) { + val = jQuery.map(val, function ( value ) { + return value == null ? "" : value + ""; + }); + } + + hooks = jQuery.valHooks[ this.nodeName.toLowerCase() ] || jQuery.valHooks[ this.type ]; + + // If set returns undefined, fall back to normal setting + if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) { + this.value = val; + } + }); + } +}); + +jQuery.extend({ + valHooks: { + option: { + get: function( elem ) { + // attributes.value is undefined in Blackberry 4.7 but + // uses .value. See #6932 + var val = elem.attributes.value; + return !val || val.specified ? elem.value : elem.text; + } + }, + select: { + get: function( elem ) { + var value, + index = elem.selectedIndex, + values = [], + options = elem.options, + one = elem.type === "select-one"; + + // Nothing was selected + if ( index < 0 ) { + return null; + } + + // Loop through all the selected options + for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) { + var option = options[ i ]; + + // Don't return options that are disabled or in a disabled optgroup + if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) && + (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) { + + // Get the specific value for the option + value = jQuery( option ).val(); + + // We don't need an array for one selects + if ( one ) { + return value; + } + + // Multi-Selects return an array + values.push( value ); + } + } + + // Fixes Bug #2551 -- select.val() broken in IE after form.reset() + if ( one && !values.length && options.length ) { + return jQuery( options[ index ] ).val(); + } + + return values; + }, + + set: function( elem, value ) { + var values = jQuery.makeArray( value ); + + jQuery(elem).find("option").each(function() { + this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0; + }); + + if ( !values.length ) { + elem.selectedIndex = -1; + } + return values; + } + } + }, + + attrFn: { + val: true, + css: true, + html: true, + text: true, + data: true, + width: true, + height: true, + offset: true + }, + + attrFix: { + // Always normalize to ensure hook usage + tabindex: "tabIndex" + }, + + attr: function( elem, name, value, pass ) { + var nType = elem.nodeType; + + // don't get/set attributes on text, comment and attribute nodes + if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { + return undefined; + } + + if ( pass && name in jQuery.attrFn ) { + return jQuery( elem )[ name ]( value ); + } + + // Fallback to prop when attributes are not supported + if ( !("getAttribute" in elem) ) { + return jQuery.prop( elem, name, value ); + } + + var ret, hooks, + notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); + + // Normalize the name if needed + if ( notxml ) { + name = jQuery.attrFix[ name ] || name; + + hooks = jQuery.attrHooks[ name ]; + + if ( !hooks ) { + // Use boolHook for boolean attributes + if ( rboolean.test( name ) ) { + hooks = boolHook; + + // Use nodeHook if available( IE6/7 ) + } else if ( nodeHook ) { + hooks = nodeHook; + } + } + } + + if ( value !== undefined ) { + + if ( value === null ) { + jQuery.removeAttr( elem, name ); + return undefined; + + } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) { + return ret; + + } else { + elem.setAttribute( name, "" + value ); + return value; + } + + } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) { + return ret; + + } else { + + ret = elem.getAttribute( name ); + + // Non-existent attributes return null, we normalize to undefined + return ret === null ? + undefined : + ret; + } + }, + + removeAttr: function( elem, name ) { + var propName; + if ( elem.nodeType === 1 ) { + name = jQuery.attrFix[ name ] || name; + + jQuery.attr( elem, name, "" ); + elem.removeAttribute( name ); + + // Set corresponding property to false for boolean attributes + if ( rboolean.test( name ) && (propName = jQuery.propFix[ name ] || name) in elem ) { + elem[ propName ] = false; + } + } + }, + + attrHooks: { + type: { + set: function( elem, value ) { + // We can't allow the type property to be changed (since it causes problems in IE) + if ( rtype.test( elem.nodeName ) && elem.parentNode ) { + jQuery.error( "type property can't be changed" ); + } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) { + // Setting the type on a radio button after the value resets the value in IE6-9 + // Reset value to it's default in case type is set after value + // This is for element creation + var val = elem.value; + elem.setAttribute( "type", value ); + if ( val ) { + elem.value = val; + } + return value; + } + } + }, + // Use the value property for back compat + // Use the nodeHook for button elements in IE6/7 (#1954) + value: { + get: function( elem, name ) { + if ( nodeHook && jQuery.nodeName( elem, "button" ) ) { + return nodeHook.get( elem, name ); + } + return name in elem ? + elem.value : + null; + }, + set: function( elem, value, name ) { + if ( nodeHook && jQuery.nodeName( elem, "button" ) ) { + return nodeHook.set( elem, value, name ); + } + // Does not return so that setAttribute is also used + elem.value = value; + } + } + }, + + propFix: { + tabindex: "tabIndex", + readonly: "readOnly", + "for": "htmlFor", + "class": "className", + maxlength: "maxLength", + cellspacing: "cellSpacing", + cellpadding: "cellPadding", + rowspan: "rowSpan", + colspan: "colSpan", + usemap: "useMap", + frameborder: "frameBorder", + contenteditable: "contentEditable" + }, + + prop: function( elem, name, value ) { + var nType = elem.nodeType; + + // don't get/set properties on text, comment and attribute nodes + if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { + return undefined; + } + + var ret, hooks, + notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); + + if ( notxml ) { + // Fix name and attach hooks + name = jQuery.propFix[ name ] || name; + hooks = jQuery.propHooks[ name ]; + } + + if ( value !== undefined ) { + if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) { + return ret; + + } else { + return (elem[ name ] = value); + } + + } else { + if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) { + return ret; + + } else { + return elem[ name ]; + } + } + }, + + propHooks: { + tabIndex: { + get: function( elem ) { + // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set + // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ + var attributeNode = elem.getAttributeNode("tabindex"); + + return attributeNode && attributeNode.specified ? + parseInt( attributeNode.value, 10 ) : + rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? + 0 : + undefined; + } + } + } +}); + +// Add the tabindex propHook to attrHooks for back-compat +jQuery.attrHooks.tabIndex = jQuery.propHooks.tabIndex; + +// Hook for boolean attributes +boolHook = { + get: function( elem, name ) { + // Align boolean attributes with corresponding properties + // Fall back to attribute presence where some booleans are not supported + var attrNode; + return jQuery.prop( elem, name ) === true || ( attrNode = elem.getAttributeNode( name ) ) && attrNode.nodeValue !== false ? + name.toLowerCase() : + undefined; + }, + set: function( elem, value, name ) { + var propName; + if ( value === false ) { + // Remove boolean attributes when set to false + jQuery.removeAttr( elem, name ); + } else { + // value is true since we know at this point it's type boolean and not false + // Set boolean attributes to the same name and set the DOM property + propName = jQuery.propFix[ name ] || name; + if ( propName in elem ) { + // Only set the IDL specifically if it already exists on the element + elem[ propName ] = true; + } + + elem.setAttribute( name, name.toLowerCase() ); + } + return name; + } +}; + +// IE6/7 do not support getting/setting some attributes with get/setAttribute +if ( !jQuery.support.getSetAttribute ) { + + // Use this for any attribute in IE6/7 + // This fixes almost every IE6/7 issue + nodeHook = jQuery.valHooks.button = { + get: function( elem, name ) { + var ret; + ret = elem.getAttributeNode( name ); + // Return undefined if nodeValue is empty string + return ret && ret.nodeValue !== "" ? + ret.nodeValue : + undefined; + }, + set: function( elem, value, name ) { + // Set the existing or create a new attribute node + var ret = elem.getAttributeNode( name ); + if ( !ret ) { + ret = document.createAttribute( name ); + elem.setAttributeNode( ret ); + } + return (ret.nodeValue = value + ""); + } + }; + + // Set width and height to auto instead of 0 on empty string( Bug #8150 ) + // This is for removals + jQuery.each([ "width", "height" ], function( i, name ) { + jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { + set: function( elem, value ) { + if ( value === "" ) { + elem.setAttribute( name, "auto" ); + return value; + } + } + }); + }); +} + + +// Some attributes require a special call on IE +if ( !jQuery.support.hrefNormalized ) { + jQuery.each([ "href", "src", "width", "height" ], function( i, name ) { + jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { + get: function( elem ) { + var ret = elem.getAttribute( name, 2 ); + return ret === null ? undefined : ret; + } + }); + }); +} + +if ( !jQuery.support.style ) { + jQuery.attrHooks.style = { + get: function( elem ) { + // Return undefined in the case of empty string + // Normalize to lowercase since IE uppercases css property names + return elem.style.cssText.toLowerCase() || undefined; + }, + set: function( elem, value ) { + return (elem.style.cssText = "" + value); + } + }; +} + +// Safari mis-reports the default selected property of an option +// Accessing the parent's selectedIndex property fixes it +if ( !jQuery.support.optSelected ) { + jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, { + get: function( elem ) { + var parent = elem.parentNode; + + if ( parent ) { + parent.selectedIndex; + + // Make sure that it also works with optgroups, see #5701 + if ( parent.parentNode ) { + parent.parentNode.selectedIndex; + } + } + return null; + } + }); +} + +// Radios and checkboxes getter/setter +if ( !jQuery.support.checkOn ) { + jQuery.each([ "radio", "checkbox" ], function() { + jQuery.valHooks[ this ] = { + get: function( elem ) { + // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified + return elem.getAttribute("value") === null ? "on" : elem.value; + } + }; + }); +} +jQuery.each([ "radio", "checkbox" ], function() { + jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], { + set: function( elem, value ) { + if ( jQuery.isArray( value ) ) { + return (elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0); + } + } + }); +}); + + + + +var rnamespaces = /\.(.*)$/, + rformElems = /^(?:textarea|input|select)$/i, + rperiod = /\./g, + rspaces = / /g, + rescape = /[^\w\s.|`]/g, + fcleanup = function( nm ) { + return nm.replace(rescape, "\\$&"); + }; + +/* + * A number of helper functions used for managing events. + * Many of the ideas behind this code originated from + * Dean Edwards' addEvent library. + */ +jQuery.event = { + + // Bind an event to an element + // Original by Dean Edwards + add: function( elem, types, handler, data ) { + if ( elem.nodeType === 3 || elem.nodeType === 8 ) { + return; + } + + if ( handler === false ) { + handler = returnFalse; + } else if ( !handler ) { + // Fixes bug #7229. Fix recommended by jdalton + return; + } + + var handleObjIn, handleObj; + + if ( handler.handler ) { + handleObjIn = handler; + handler = handleObjIn.handler; + } + + // Make sure that the function being executed has a unique ID + if ( !handler.guid ) { + handler.guid = jQuery.guid++; + } + + // Init the element's event structure + var elemData = jQuery._data( elem ); + + // If no elemData is found then we must be trying to bind to one of the + // banned noData elements + if ( !elemData ) { + return; + } + + var events = elemData.events, + eventHandle = elemData.handle; + + if ( !events ) { + elemData.events = events = {}; + } + + if ( !eventHandle ) { + elemData.handle = eventHandle = function( e ) { + // Discard the second event of a jQuery.event.trigger() and + // when an event is called after a page has unloaded + return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ? + jQuery.event.handle.apply( eventHandle.elem, arguments ) : + undefined; + }; + } + + // Add elem as a property of the handle function + // This is to prevent a memory leak with non-native events in IE. + eventHandle.elem = elem; + + // Handle multiple events separated by a space + // jQuery(...).bind("mouseover mouseout", fn); + types = types.split(" "); + + var type, i = 0, namespaces; + + while ( (type = types[ i++ ]) ) { + handleObj = handleObjIn ? + jQuery.extend({}, handleObjIn) : + { handler: handler, data: data }; + + // Namespaced event handlers + if ( type.indexOf(".") > -1 ) { + namespaces = type.split("."); + type = namespaces.shift(); + handleObj.namespace = namespaces.slice(0).sort().join("."); + + } else { + namespaces = []; + handleObj.namespace = ""; + } + + handleObj.type = type; + if ( !handleObj.guid ) { + handleObj.guid = handler.guid; + } + + // Get the current list of functions bound to this event + var handlers = events[ type ], + special = jQuery.event.special[ type ] || {}; + + // Init the event handler queue + if ( !handlers ) { + handlers = events[ type ] = []; + + // Check for a special event handler + // Only use addEventListener/attachEvent if the special + // events handler returns false + if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { + // Bind the global event handler to the element + if ( elem.addEventListener ) { + elem.addEventListener( type, eventHandle, false ); + + } else if ( elem.attachEvent ) { + elem.attachEvent( "on" + type, eventHandle ); + } + } + } + + if ( special.add ) { + special.add.call( elem, handleObj ); + + if ( !handleObj.handler.guid ) { + handleObj.handler.guid = handler.guid; + } + } + + // Add the function to the element's handler list + handlers.push( handleObj ); + + // Keep track of which events have been used, for event optimization + jQuery.event.global[ type ] = true; + } + + // Nullify elem to prevent memory leaks in IE + elem = null; + }, + + global: {}, + + // Detach an event or set of events from an element + remove: function( elem, types, handler, pos ) { + // don't do events on text and comment nodes + if ( elem.nodeType === 3 || elem.nodeType === 8 ) { + return; + } + + if ( handler === false ) { + handler = returnFalse; + } + + var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType, + elemData = jQuery.hasData( elem ) && jQuery._data( elem ), + events = elemData && elemData.events; + + if ( !elemData || !events ) { + return; + } + + // types is actually an event object here + if ( types && types.type ) { + handler = types.handler; + types = types.type; + } + + // Unbind all events for the element + if ( !types || typeof types === "string" && types.charAt(0) === "." ) { + types = types || ""; + + for ( type in events ) { + jQuery.event.remove( elem, type + types ); + } + + return; + } + + // Handle multiple events separated by a space + // jQuery(...).unbind("mouseover mouseout", fn); + types = types.split(" "); + + while ( (type = types[ i++ ]) ) { + origType = type; + handleObj = null; + all = type.indexOf(".") < 0; + namespaces = []; + + if ( !all ) { + // Namespaced event handlers + namespaces = type.split("."); + type = namespaces.shift(); + + namespace = new RegExp("(^|\\.)" + + jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)"); + } + + eventType = events[ type ]; + + if ( !eventType ) { + continue; + } + + if ( !handler ) { + for ( j = 0; j < eventType.length; j++ ) { + handleObj = eventType[ j ]; + + if ( all || namespace.test( handleObj.namespace ) ) { + jQuery.event.remove( elem, origType, handleObj.handler, j ); + eventType.splice( j--, 1 ); + } + } + + continue; + } + + special = jQuery.event.special[ type ] || {}; + + for ( j = pos || 0; j < eventType.length; j++ ) { + handleObj = eventType[ j ]; + + if ( handler.guid === handleObj.guid ) { + // remove the given handler for the given type + if ( all || namespace.test( handleObj.namespace ) ) { + if ( pos == null ) { + eventType.splice( j--, 1 ); + } + + if ( special.remove ) { + special.remove.call( elem, handleObj ); + } + } + + if ( pos != null ) { + break; + } + } + } + + // remove generic event handler if no more handlers exist + if ( eventType.length === 0 || pos != null && eventType.length === 1 ) { + if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) { + jQuery.removeEvent( elem, type, elemData.handle ); + } + + ret = null; + delete events[ type ]; + } + } + + // Remove the expando if it's no longer used + if ( jQuery.isEmptyObject( events ) ) { + var handle = elemData.handle; + if ( handle ) { + handle.elem = null; + } + + delete elemData.events; + delete elemData.handle; + + if ( jQuery.isEmptyObject( elemData ) ) { + jQuery.removeData( elem, undefined, true ); + } + } + }, + + // Events that are safe to short-circuit if no handlers are attached. + // Native DOM events should not be added, they may have inline handlers. + customEvent: { + "getData": true, + "setData": true, + "changeData": true + }, + + trigger: function( event, data, elem, onlyHandlers ) { + // Event object or event type + var type = event.type || event, + namespaces = [], + exclusive; + + if ( type.indexOf("!") >= 0 ) { + // Exclusive events trigger only for the exact event (no namespaces) + type = type.slice(0, -1); + exclusive = true; + } + + if ( type.indexOf(".") >= 0 ) { + // Namespaced trigger; create a regexp to match event type in handle() + namespaces = type.split("."); + type = namespaces.shift(); + namespaces.sort(); + } + + if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) { + // No jQuery handlers for this event type, and it can't have inline handlers + return; + } + + // Caller can pass in an Event, Object, or just an event type string + event = typeof event === "object" ? + // jQuery.Event object + event[ jQuery.expando ] ? event : + // Object literal + new jQuery.Event( type, event ) : + // Just the event type (string) + new jQuery.Event( type ); + + event.type = type; + event.exclusive = exclusive; + event.namespace = namespaces.join("."); + event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)"); + + // triggerHandler() and global events don't bubble or run the default action + if ( onlyHandlers || !elem ) { + event.preventDefault(); + event.stopPropagation(); + } + + // Handle a global trigger + if ( !elem ) { + // TODO: Stop taunting the data cache; remove global events and always attach to document + jQuery.each( jQuery.cache, function() { + // internalKey variable is just used to make it easier to find + // and potentially change this stuff later; currently it just + // points to jQuery.expando + var internalKey = jQuery.expando, + internalCache = this[ internalKey ]; + if ( internalCache && internalCache.events && internalCache.events[ type ] ) { + jQuery.event.trigger( event, data, internalCache.handle.elem ); + } + }); + return; + } + + // Don't do events on text and comment nodes + if ( elem.nodeType === 3 || elem.nodeType === 8 ) { + return; + } + + // Clean up the event in case it is being reused + event.result = undefined; + event.target = elem; + + // Clone any incoming data and prepend the event, creating the handler arg list + data = data != null ? jQuery.makeArray( data ) : []; + data.unshift( event ); + + var cur = elem, + // IE doesn't like method names with a colon (#3533, #8272) + ontype = type.indexOf(":") < 0 ? "on" + type : ""; + + // Fire event on the current element, then bubble up the DOM tree + do { + var handle = jQuery._data( cur, "handle" ); + + event.currentTarget = cur; + if ( handle ) { + handle.apply( cur, data ); + } + + // Trigger an inline bound script + if ( ontype && jQuery.acceptData( cur ) && cur[ ontype ] && cur[ ontype ].apply( cur, data ) === false ) { + event.result = false; + event.preventDefault(); + } + + // Bubble up to document, then to window + cur = cur.parentNode || cur.ownerDocument || cur === event.target.ownerDocument && window; + } while ( cur && !event.isPropagationStopped() ); + + // If nobody prevented the default action, do it now + if ( !event.isDefaultPrevented() ) { + var old, + special = jQuery.event.special[ type ] || {}; + + if ( (!special._default || special._default.call( elem.ownerDocument, event ) === false) && + !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) { + + // Call a native DOM method on the target with the same name name as the event. + // Can't use an .isFunction)() check here because IE6/7 fails that test. + // IE<9 dies on focus to hidden element (#1486), may want to revisit a try/catch. + try { + if ( ontype && elem[ type ] ) { + // Don't re-trigger an onFOO event when we call its FOO() method + old = elem[ ontype ]; + + if ( old ) { + elem[ ontype ] = null; + } + + jQuery.event.triggered = type; + elem[ type ](); + } + } catch ( ieError ) {} + + if ( old ) { + elem[ ontype ] = old; + } + + jQuery.event.triggered = undefined; + } + } + + return event.result; + }, + + handle: function( event ) { + event = jQuery.event.fix( event || window.event ); + // Snapshot the handlers list since a called handler may add/remove events. + var handlers = ((jQuery._data( this, "events" ) || {})[ event.type ] || []).slice(0), + run_all = !event.exclusive && !event.namespace, + args = Array.prototype.slice.call( arguments, 0 ); + + // Use the fix-ed Event rather than the (read-only) native event + args[0] = event; + event.currentTarget = this; + + for ( var j = 0, l = handlers.length; j < l; j++ ) { + var handleObj = handlers[ j ]; + + // Triggered event must 1) be non-exclusive and have no namespace, or + // 2) have namespace(s) a subset or equal to those in the bound event. + if ( run_all || event.namespace_re.test( handleObj.namespace ) ) { + // Pass in a reference to the handler function itself + // So that we can later remove it + event.handler = handleObj.handler; + event.data = handleObj.data; + event.handleObj = handleObj; + + var ret = handleObj.handler.apply( this, args ); + + if ( ret !== undefined ) { + event.result = ret; + if ( ret === false ) { + event.preventDefault(); + event.stopPropagation(); + } + } + + if ( event.isImmediatePropagationStopped() ) { + break; + } + } + } + return event.result; + }, + + props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "), + + fix: function( event ) { + if ( event[ jQuery.expando ] ) { + return event; + } + + // store a copy of the original event object + // and "clone" to set read-only properties + var originalEvent = event; + event = jQuery.Event( originalEvent ); + + for ( var i = this.props.length, prop; i; ) { + prop = this.props[ --i ]; + event[ prop ] = originalEvent[ prop ]; + } + + // Fix target property, if necessary + if ( !event.target ) { + // Fixes #1925 where srcElement might not be defined either + event.target = event.srcElement || document; + } + + // check if target is a textnode (safari) + if ( event.target.nodeType === 3 ) { + event.target = event.target.parentNode; + } + + // Add relatedTarget, if necessary + if ( !event.relatedTarget && event.fromElement ) { + event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement; + } + + // Calculate pageX/Y if missing and clientX/Y available + if ( event.pageX == null && event.clientX != null ) { + var eventDocument = event.target.ownerDocument || document, + doc = eventDocument.documentElement, + body = eventDocument.body; + + event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0); + event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0); + } + + // Add which for key events + if ( event.which == null && (event.charCode != null || event.keyCode != null) ) { + event.which = event.charCode != null ? event.charCode : event.keyCode; + } + + // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs) + if ( !event.metaKey && event.ctrlKey ) { + event.metaKey = event.ctrlKey; + } + + // Add which for click: 1 === left; 2 === middle; 3 === right + // Note: button is not normalized, so don't use it + if ( !event.which && event.button !== undefined ) { + event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) )); + } + + return event; + }, + + // Deprecated, use jQuery.guid instead + guid: 1E8, + + // Deprecated, use jQuery.proxy instead + proxy: jQuery.proxy, + + special: { + ready: { + // Make sure the ready event is setup + setup: jQuery.bindReady, + teardown: jQuery.noop + }, + + live: { + add: function( handleObj ) { + jQuery.event.add( this, + liveConvert( handleObj.origType, handleObj.selector ), + jQuery.extend({}, handleObj, {handler: liveHandler, guid: handleObj.handler.guid}) ); + }, + + remove: function( handleObj ) { + jQuery.event.remove( this, liveConvert( handleObj.origType, handleObj.selector ), handleObj ); + } + }, + + beforeunload: { + setup: function( data, namespaces, eventHandle ) { + // We only want to do this special case on windows + if ( jQuery.isWindow( this ) ) { + this.onbeforeunload = eventHandle; + } + }, + + teardown: function( namespaces, eventHandle ) { + if ( this.onbeforeunload === eventHandle ) { + this.onbeforeunload = null; + } + } + } + } +}; + +jQuery.removeEvent = document.removeEventListener ? + function( elem, type, handle ) { + if ( elem.removeEventListener ) { + elem.removeEventListener( type, handle, false ); + } + } : + function( elem, type, handle ) { + if ( elem.detachEvent ) { + elem.detachEvent( "on" + type, handle ); + } + }; + +jQuery.Event = function( src, props ) { + // Allow instantiation without the 'new' keyword + if ( !this.preventDefault ) { + return new jQuery.Event( src, props ); + } + + // Event object + if ( src && src.type ) { + this.originalEvent = src; + this.type = src.type; + + // Events bubbling up the document may have been marked as prevented + // by a handler lower down the tree; reflect the correct value. + this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false || + src.getPreventDefault && src.getPreventDefault()) ? returnTrue : returnFalse; + + // Event type + } else { + this.type = src; + } + + // Put explicitly provided properties onto the event object + if ( props ) { + jQuery.extend( this, props ); + } + + // timeStamp is buggy for some events on Firefox(#3843) + // So we won't rely on the native value + this.timeStamp = jQuery.now(); + + // Mark it as fixed + this[ jQuery.expando ] = true; +}; + +function returnFalse() { + return false; +} +function returnTrue() { + return true; +} + +// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding +// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html +jQuery.Event.prototype = { + preventDefault: function() { + this.isDefaultPrevented = returnTrue; + + var e = this.originalEvent; + if ( !e ) { + return; + } + + // if preventDefault exists run it on the original event + if ( e.preventDefault ) { + e.preventDefault(); + + // otherwise set the returnValue property of the original event to false (IE) + } else { + e.returnValue = false; + } + }, + stopPropagation: function() { + this.isPropagationStopped = returnTrue; + + var e = this.originalEvent; + if ( !e ) { + return; + } + // if stopPropagation exists run it on the original event + if ( e.stopPropagation ) { + e.stopPropagation(); + } + // otherwise set the cancelBubble property of the original event to true (IE) + e.cancelBubble = true; + }, + stopImmediatePropagation: function() { + this.isImmediatePropagationStopped = returnTrue; + this.stopPropagation(); + }, + isDefaultPrevented: returnFalse, + isPropagationStopped: returnFalse, + isImmediatePropagationStopped: returnFalse +}; + +// Checks if an event happened on an element within another element +// Used in jQuery.event.special.mouseenter and mouseleave handlers +var withinElement = function( event ) { + + // Check if mouse(over|out) are still within the same parent element + var related = event.relatedTarget, + inside = false, + eventType = event.type; + + event.type = event.data; + + if ( related !== this ) { + + if ( related ) { + inside = jQuery.contains( this, related ); + } + + if ( !inside ) { + + jQuery.event.handle.apply( this, arguments ); + + event.type = eventType; + } + } +}, + +// In case of event delegation, we only need to rename the event.type, +// liveHandler will take care of the rest. +delegate = function( event ) { + event.type = event.data; + jQuery.event.handle.apply( this, arguments ); +}; + +// Create mouseenter and mouseleave events +jQuery.each({ + mouseenter: "mouseover", + mouseleave: "mouseout" +}, function( orig, fix ) { + jQuery.event.special[ orig ] = { + setup: function( data ) { + jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig ); + }, + teardown: function( data ) { + jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement ); + } + }; +}); + +// submit delegation +if ( !jQuery.support.submitBubbles ) { + + jQuery.event.special.submit = { + setup: function( data, namespaces ) { + if ( !jQuery.nodeName( this, "form" ) ) { + jQuery.event.add(this, "click.specialSubmit", function( e ) { + // Avoid triggering error on non-existent type attribute in IE VML (#7071) + var elem = e.target, + type = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.type : ""; + + if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) { + trigger( "submit", this, arguments ); + } + }); + + jQuery.event.add(this, "keypress.specialSubmit", function( e ) { + var elem = e.target, + type = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.type : ""; + + if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) { + trigger( "submit", this, arguments ); + } + }); + + } else { + return false; + } + }, + + teardown: function( namespaces ) { + jQuery.event.remove( this, ".specialSubmit" ); + } + }; + +} + +// change delegation, happens here so we have bind. +if ( !jQuery.support.changeBubbles ) { + + var changeFilters, + + getVal = function( elem ) { + var type = jQuery.nodeName( elem, "input" ) ? elem.type : "", + val = elem.value; + + if ( type === "radio" || type === "checkbox" ) { + val = elem.checked; + + } else if ( type === "select-multiple" ) { + val = elem.selectedIndex > -1 ? + jQuery.map( elem.options, function( elem ) { + return elem.selected; + }).join("-") : + ""; + + } else if ( jQuery.nodeName( elem, "select" ) ) { + val = elem.selectedIndex; + } + + return val; + }, + + testChange = function testChange( e ) { + var elem = e.target, data, val; + + if ( !rformElems.test( elem.nodeName ) || elem.readOnly ) { + return; + } + + data = jQuery._data( elem, "_change_data" ); + val = getVal(elem); + + // the current data will be also retrieved by beforeactivate + if ( e.type !== "focusout" || elem.type !== "radio" ) { + jQuery._data( elem, "_change_data", val ); + } + + if ( data === undefined || val === data ) { + return; + } + + if ( data != null || val ) { + e.type = "change"; + e.liveFired = undefined; + jQuery.event.trigger( e, arguments[1], elem ); + } + }; + + jQuery.event.special.change = { + filters: { + focusout: testChange, + + beforedeactivate: testChange, + + click: function( e ) { + var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : ""; + + if ( type === "radio" || type === "checkbox" || jQuery.nodeName( elem, "select" ) ) { + testChange.call( this, e ); + } + }, + + // Change has to be called before submit + // Keydown will be called before keypress, which is used in submit-event delegation + keydown: function( e ) { + var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : ""; + + if ( (e.keyCode === 13 && !jQuery.nodeName( elem, "textarea" ) ) || + (e.keyCode === 32 && (type === "checkbox" || type === "radio")) || + type === "select-multiple" ) { + testChange.call( this, e ); + } + }, + + // Beforeactivate happens also before the previous element is blurred + // with this event you can't trigger a change event, but you can store + // information + beforeactivate: function( e ) { + var elem = e.target; + jQuery._data( elem, "_change_data", getVal(elem) ); + } + }, + + setup: function( data, namespaces ) { + if ( this.type === "file" ) { + return false; + } + + for ( var type in changeFilters ) { + jQuery.event.add( this, type + ".specialChange", changeFilters[type] ); + } + + return rformElems.test( this.nodeName ); + }, + + teardown: function( namespaces ) { + jQuery.event.remove( this, ".specialChange" ); + + return rformElems.test( this.nodeName ); + } + }; + + changeFilters = jQuery.event.special.change.filters; + + // Handle when the input is .focus()'d + changeFilters.focus = changeFilters.beforeactivate; +} + +function trigger( type, elem, args ) { + // Piggyback on a donor event to simulate a different one. + // Fake originalEvent to avoid donor's stopPropagation, but if the + // simulated event prevents default then we do the same on the donor. + // Don't pass args or remember liveFired; they apply to the donor event. + var event = jQuery.extend( {}, args[ 0 ] ); + event.type = type; + event.originalEvent = {}; + event.liveFired = undefined; + jQuery.event.handle.call( elem, event ); + if ( event.isDefaultPrevented() ) { + args[ 0 ].preventDefault(); + } +} + +// Create "bubbling" focus and blur events +if ( !jQuery.support.focusinBubbles ) { + jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { + + // Attach a single capturing handler while someone wants focusin/focusout + var attaches = 0; + + jQuery.event.special[ fix ] = { + setup: function() { + if ( attaches++ === 0 ) { + document.addEventListener( orig, handler, true ); + } + }, + teardown: function() { + if ( --attaches === 0 ) { + document.removeEventListener( orig, handler, true ); + } + } + }; + + function handler( donor ) { + // Donor event is always a native one; fix it and switch its type. + // Let focusin/out handler cancel the donor focus/blur event. + var e = jQuery.event.fix( donor ); + e.type = fix; + e.originalEvent = {}; + jQuery.event.trigger( e, null, e.target ); + if ( e.isDefaultPrevented() ) { + donor.preventDefault(); + } + } + }); +} + +jQuery.each(["bind", "one"], function( i, name ) { + jQuery.fn[ name ] = function( type, data, fn ) { + var handler; + + // Handle object literals + if ( typeof type === "object" ) { + for ( var key in type ) { + this[ name ](key, data, type[key], fn); + } + return this; + } + + if ( arguments.length === 2 || data === false ) { + fn = data; + data = undefined; + } + + if ( name === "one" ) { + handler = function( event ) { + jQuery( this ).unbind( event, handler ); + return fn.apply( this, arguments ); + }; + handler.guid = fn.guid || jQuery.guid++; + } else { + handler = fn; + } + + if ( type === "unload" && name !== "one" ) { + this.one( type, data, fn ); + + } else { + for ( var i = 0, l = this.length; i < l; i++ ) { + jQuery.event.add( this[i], type, handler, data ); + } + } + + return this; + }; +}); + +jQuery.fn.extend({ + unbind: function( type, fn ) { + // Handle object literals + if ( typeof type === "object" && !type.preventDefault ) { + for ( var key in type ) { + this.unbind(key, type[key]); + } + + } else { + for ( var i = 0, l = this.length; i < l; i++ ) { + jQuery.event.remove( this[i], type, fn ); + } + } + + return this; + }, + + delegate: function( selector, types, data, fn ) { + return this.live( types, data, fn, selector ); + }, + + undelegate: function( selector, types, fn ) { + if ( arguments.length === 0 ) { + return this.unbind( "live" ); + + } else { + return this.die( types, null, fn, selector ); + } + }, + + trigger: function( type, data ) { + return this.each(function() { + jQuery.event.trigger( type, data, this ); + }); + }, + + triggerHandler: function( type, data ) { + if ( this[0] ) { + return jQuery.event.trigger( type, data, this[0], true ); + } + }, + + toggle: function( fn ) { + // Save reference to arguments for access in closure + var args = arguments, + guid = fn.guid || jQuery.guid++, + i = 0, + toggler = function( event ) { + // Figure out which function to execute + var lastToggle = ( jQuery.data( this, "lastToggle" + fn.guid ) || 0 ) % i; + jQuery.data( this, "lastToggle" + fn.guid, lastToggle + 1 ); + + // Make sure that clicks stop + event.preventDefault(); + + // and execute the function + return args[ lastToggle ].apply( this, arguments ) || false; + }; + + // link all the functions, so any of them can unbind this click handler + toggler.guid = guid; + while ( i < args.length ) { + args[ i++ ].guid = guid; + } + + return this.click( toggler ); + }, + + hover: function( fnOver, fnOut ) { + return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); + } +}); + +var liveMap = { + focus: "focusin", + blur: "focusout", + mouseenter: "mouseover", + mouseleave: "mouseout" +}; + +jQuery.each(["live", "die"], function( i, name ) { + jQuery.fn[ name ] = function( types, data, fn, origSelector /* Internal Use Only */ ) { + var type, i = 0, match, namespaces, preType, + selector = origSelector || this.selector, + context = origSelector ? this : jQuery( this.context ); + + if ( typeof types === "object" && !types.preventDefault ) { + for ( var key in types ) { + context[ name ]( key, data, types[key], selector ); + } + + return this; + } + + if ( name === "die" && !types && + origSelector && origSelector.charAt(0) === "." ) { + + context.unbind( origSelector ); + + return this; + } + + if ( data === false || jQuery.isFunction( data ) ) { + fn = data || returnFalse; + data = undefined; + } + + types = (types || "").split(" "); + + while ( (type = types[ i++ ]) != null ) { + match = rnamespaces.exec( type ); + namespaces = ""; + + if ( match ) { + namespaces = match[0]; + type = type.replace( rnamespaces, "" ); + } + + if ( type === "hover" ) { + types.push( "mouseenter" + namespaces, "mouseleave" + namespaces ); + continue; + } + + preType = type; + + if ( liveMap[ type ] ) { + types.push( liveMap[ type ] + namespaces ); + type = type + namespaces; + + } else { + type = (liveMap[ type ] || type) + namespaces; + } + + if ( name === "live" ) { + // bind live handler + for ( var j = 0, l = context.length; j < l; j++ ) { + jQuery.event.add( context[j], "live." + liveConvert( type, selector ), + { data: data, selector: selector, handler: fn, origType: type, origHandler: fn, preType: preType } ); + } + + } else { + // unbind live handler + context.unbind( "live." + liveConvert( type, selector ), fn ); + } + } + + return this; + }; +}); + +function liveHandler( event ) { + var stop, maxLevel, related, match, handleObj, elem, j, i, l, data, close, namespace, ret, + elems = [], + selectors = [], + events = jQuery._data( this, "events" ); + + // Make sure we avoid non-left-click bubbling in Firefox (#3861) and disabled elements in IE (#6911) + if ( event.liveFired === this || !events || !events.live || event.target.disabled || event.button && event.type === "click" ) { + return; + } + + if ( event.namespace ) { + namespace = new RegExp("(^|\\.)" + event.namespace.split(".").join("\\.(?:.*\\.)?") + "(\\.|$)"); + } + + event.liveFired = this; + + var live = events.live.slice(0); + + for ( j = 0; j < live.length; j++ ) { + handleObj = live[j]; + + if ( handleObj.origType.replace( rnamespaces, "" ) === event.type ) { + selectors.push( handleObj.selector ); + + } else { + live.splice( j--, 1 ); + } + } + + match = jQuery( event.target ).closest( selectors, event.currentTarget ); + + for ( i = 0, l = match.length; i < l; i++ ) { + close = match[i]; + + for ( j = 0; j < live.length; j++ ) { + handleObj = live[j]; + + if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) && !close.elem.disabled ) { + elem = close.elem; + related = null; + + // Those two events require additional checking + if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) { + event.type = handleObj.preType; + related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0]; + + // Make sure not to accidentally match a child element with the same selector + if ( related && jQuery.contains( elem, related ) ) { + related = elem; + } + } + + if ( !related || related !== elem ) { + elems.push({ elem: elem, handleObj: handleObj, level: close.level }); + } + } + } + } + + for ( i = 0, l = elems.length; i < l; i++ ) { + match = elems[i]; + + if ( maxLevel && match.level > maxLevel ) { + break; + } + + event.currentTarget = match.elem; + event.data = match.handleObj.data; + event.handleObj = match.handleObj; + + ret = match.handleObj.origHandler.apply( match.elem, arguments ); + + if ( ret === false || event.isPropagationStopped() ) { + maxLevel = match.level; + + if ( ret === false ) { + stop = false; + } + if ( event.isImmediatePropagationStopped() ) { + break; + } + } + } + + return stop; +} + +function liveConvert( type, selector ) { + return (type && type !== "*" ? type + "." : "") + selector.replace(rperiod, "`").replace(rspaces, "&"); +} + +jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " + + "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + + "change select submit keydown keypress keyup error").split(" "), function( i, name ) { + + // Handle event binding + jQuery.fn[ name ] = function( data, fn ) { + if ( fn == null ) { + fn = data; + data = null; + } + + return arguments.length > 0 ? + this.bind( name, data, fn ) : + this.trigger( name ); + }; + + if ( jQuery.attrFn ) { + jQuery.attrFn[ name ] = true; + } +}); + + + +/*! + * Sizzle CSS Selector Engine + * Copyright 2011, The Dojo Foundation + * Released under the MIT, BSD, and GPL Licenses. + * More information: http://sizzlejs.com/ + */ +(function(){ + +var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g, + done = 0, + toString = Object.prototype.toString, + hasDuplicate = false, + baseHasDuplicate = true, + rBackslash = /\\/g, + rNonWord = /\W/; + +// Here we check if the JavaScript engine is using some sort of +// optimization where it does not always call our comparision +// function. If that is the case, discard the hasDuplicate value. +// Thus far that includes Google Chrome. +[0, 0].sort(function() { + baseHasDuplicate = false; + return 0; +}); + +var Sizzle = function( selector, context, results, seed ) { + results = results || []; + context = context || document; + + var origContext = context; + + if ( context.nodeType !== 1 && context.nodeType !== 9 ) { + return []; + } + + if ( !selector || typeof selector !== "string" ) { + return results; + } + + var m, set, checkSet, extra, ret, cur, pop, i, + prune = true, + contextXML = Sizzle.isXML( context ), + parts = [], + soFar = selector; + + // Reset the position of the chunker regexp (start from head) + do { + chunker.exec( "" ); + m = chunker.exec( soFar ); + + if ( m ) { + soFar = m[3]; + + parts.push( m[1] ); + + if ( m[2] ) { + extra = m[3]; + break; + } + } + } while ( m ); + + if ( parts.length > 1 && origPOS.exec( selector ) ) { + + if ( parts.length === 2 && Expr.relative[ parts[0] ] ) { + set = posProcess( parts[0] + parts[1], context ); + + } else { + set = Expr.relative[ parts[0] ] ? + [ context ] : + Sizzle( parts.shift(), context ); + + while ( parts.length ) { + selector = parts.shift(); + + if ( Expr.relative[ selector ] ) { + selector += parts.shift(); + } + + set = posProcess( selector, set ); + } + } + + } else { + // Take a shortcut and set the context if the root selector is an ID + // (but not if it'll be faster if the inner selector is an ID) + if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML && + Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) { + + ret = Sizzle.find( parts.shift(), context, contextXML ); + context = ret.expr ? + Sizzle.filter( ret.expr, ret.set )[0] : + ret.set[0]; + } + + if ( context ) { + ret = seed ? + { expr: parts.pop(), set: makeArray(seed) } : + Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML ); + + set = ret.expr ? + Sizzle.filter( ret.expr, ret.set ) : + ret.set; + + if ( parts.length > 0 ) { + checkSet = makeArray( set ); + + } else { + prune = false; + } + + while ( parts.length ) { + cur = parts.pop(); + pop = cur; + + if ( !Expr.relative[ cur ] ) { + cur = ""; + } else { + pop = parts.pop(); + } + + if ( pop == null ) { + pop = context; + } + + Expr.relative[ cur ]( checkSet, pop, contextXML ); + } + + } else { + checkSet = parts = []; + } + } + + if ( !checkSet ) { + checkSet = set; + } + + if ( !checkSet ) { + Sizzle.error( cur || selector ); + } + + if ( toString.call(checkSet) === "[object Array]" ) { + if ( !prune ) { + results.push.apply( results, checkSet ); + + } else if ( context && context.nodeType === 1 ) { + for ( i = 0; checkSet[i] != null; i++ ) { + if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) { + results.push( set[i] ); + } + } + + } else { + for ( i = 0; checkSet[i] != null; i++ ) { + if ( checkSet[i] && checkSet[i].nodeType === 1 ) { + results.push( set[i] ); + } + } + } + + } else { + makeArray( checkSet, results ); + } + + if ( extra ) { + Sizzle( extra, origContext, results, seed ); + Sizzle.uniqueSort( results ); + } + + return results; +}; + +Sizzle.uniqueSort = function( results ) { + if ( sortOrder ) { + hasDuplicate = baseHasDuplicate; + results.sort( sortOrder ); + + if ( hasDuplicate ) { + for ( var i = 1; i < results.length; i++ ) { + if ( results[i] === results[ i - 1 ] ) { + results.splice( i--, 1 ); + } + } + } + } + + return results; +}; + +Sizzle.matches = function( expr, set ) { + return Sizzle( expr, null, null, set ); +}; + +Sizzle.matchesSelector = function( node, expr ) { + return Sizzle( expr, null, null, [node] ).length > 0; +}; + +Sizzle.find = function( expr, context, isXML ) { + var set; + + if ( !expr ) { + return []; + } + + for ( var i = 0, l = Expr.order.length; i < l; i++ ) { + var match, + type = Expr.order[i]; + + if ( (match = Expr.leftMatch[ type ].exec( expr )) ) { + var left = match[1]; + match.splice( 1, 1 ); + + if ( left.substr( left.length - 1 ) !== "\\" ) { + match[1] = (match[1] || "").replace( rBackslash, "" ); + set = Expr.find[ type ]( match, context, isXML ); + + if ( set != null ) { + expr = expr.replace( Expr.match[ type ], "" ); + break; + } + } + } + } + + if ( !set ) { + set = typeof context.getElementsByTagName !== "undefined" ? + context.getElementsByTagName( "*" ) : + []; + } + + return { set: set, expr: expr }; +}; + +Sizzle.filter = function( expr, set, inplace, not ) { + var match, anyFound, + old = expr, + result = [], + curLoop = set, + isXMLFilter = set && set[0] && Sizzle.isXML( set[0] ); + + while ( expr && set.length ) { + for ( var type in Expr.filter ) { + if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) { + var found, item, + filter = Expr.filter[ type ], + left = match[1]; + + anyFound = false; + + match.splice(1,1); + + if ( left.substr( left.length - 1 ) === "\\" ) { + continue; + } + + if ( curLoop === result ) { + result = []; + } + + if ( Expr.preFilter[ type ] ) { + match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter ); + + if ( !match ) { + anyFound = found = true; + + } else if ( match === true ) { + continue; + } + } + + if ( match ) { + for ( var i = 0; (item = curLoop[i]) != null; i++ ) { + if ( item ) { + found = filter( item, match, i, curLoop ); + var pass = not ^ !!found; + + if ( inplace && found != null ) { + if ( pass ) { + anyFound = true; + + } else { + curLoop[i] = false; + } + + } else if ( pass ) { + result.push( item ); + anyFound = true; + } + } + } + } + + if ( found !== undefined ) { + if ( !inplace ) { + curLoop = result; + } + + expr = expr.replace( Expr.match[ type ], "" ); + + if ( !anyFound ) { + return []; + } + + break; + } + } + } + + // Improper expression + if ( expr === old ) { + if ( anyFound == null ) { + Sizzle.error( expr ); + + } else { + break; + } + } + + old = expr; + } + + return curLoop; +}; + +Sizzle.error = function( msg ) { + throw "Syntax error, unrecognized expression: " + msg; +}; + +var Expr = Sizzle.selectors = { + order: [ "ID", "NAME", "TAG" ], + + match: { + ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, + CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, + NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/, + ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/, + TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/, + CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/, + POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/, + PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/ + }, + + leftMatch: {}, + + attrMap: { + "class": "className", + "for": "htmlFor" + }, + + attrHandle: { + href: function( elem ) { + return elem.getAttribute( "href" ); + }, + type: function( elem ) { + return elem.getAttribute( "type" ); + } + }, + + relative: { + "+": function(checkSet, part){ + var isPartStr = typeof part === "string", + isTag = isPartStr && !rNonWord.test( part ), + isPartStrNotTag = isPartStr && !isTag; + + if ( isTag ) { + part = part.toLowerCase(); + } + + for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) { + if ( (elem = checkSet[i]) ) { + while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {} + + checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ? + elem || false : + elem === part; + } + } + + if ( isPartStrNotTag ) { + Sizzle.filter( part, checkSet, true ); + } + }, + + ">": function( checkSet, part ) { + var elem, + isPartStr = typeof part === "string", + i = 0, + l = checkSet.length; + + if ( isPartStr && !rNonWord.test( part ) ) { + part = part.toLowerCase(); + + for ( ; i < l; i++ ) { + elem = checkSet[i]; + + if ( elem ) { + var parent = elem.parentNode; + checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false; + } + } + + } else { + for ( ; i < l; i++ ) { + elem = checkSet[i]; + + if ( elem ) { + checkSet[i] = isPartStr ? + elem.parentNode : + elem.parentNode === part; + } + } + + if ( isPartStr ) { + Sizzle.filter( part, checkSet, true ); + } + } + }, + + "": function(checkSet, part, isXML){ + var nodeCheck, + doneName = done++, + checkFn = dirCheck; + + if ( typeof part === "string" && !rNonWord.test( part ) ) { + part = part.toLowerCase(); + nodeCheck = part; + checkFn = dirNodeCheck; + } + + checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML ); + }, + + "~": function( checkSet, part, isXML ) { + var nodeCheck, + doneName = done++, + checkFn = dirCheck; + + if ( typeof part === "string" && !rNonWord.test( part ) ) { + part = part.toLowerCase(); + nodeCheck = part; + checkFn = dirNodeCheck; + } + + checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML ); + } + }, + + find: { + ID: function( match, context, isXML ) { + if ( typeof context.getElementById !== "undefined" && !isXML ) { + var m = context.getElementById(match[1]); + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + return m && m.parentNode ? [m] : []; + } + }, + + NAME: function( match, context ) { + if ( typeof context.getElementsByName !== "undefined" ) { + var ret = [], + results = context.getElementsByName( match[1] ); + + for ( var i = 0, l = results.length; i < l; i++ ) { + if ( results[i].getAttribute("name") === match[1] ) { + ret.push( results[i] ); + } + } + + return ret.length === 0 ? null : ret; + } + }, + + TAG: function( match, context ) { + if ( typeof context.getElementsByTagName !== "undefined" ) { + return context.getElementsByTagName( match[1] ); + } + } + }, + preFilter: { + CLASS: function( match, curLoop, inplace, result, not, isXML ) { + match = " " + match[1].replace( rBackslash, "" ) + " "; + + if ( isXML ) { + return match; + } + + for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) { + if ( elem ) { + if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) { + if ( !inplace ) { + result.push( elem ); + } + + } else if ( inplace ) { + curLoop[i] = false; + } + } + } + + return false; + }, + + ID: function( match ) { + return match[1].replace( rBackslash, "" ); + }, + + TAG: function( match, curLoop ) { + return match[1].replace( rBackslash, "" ).toLowerCase(); + }, + + CHILD: function( match ) { + if ( match[1] === "nth" ) { + if ( !match[2] ) { + Sizzle.error( match[0] ); + } + + match[2] = match[2].replace(/^\+|\s*/g, ''); + + // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6' + var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec( + match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" || + !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]); + + // calculate the numbers (first)n+(last) including if they are negative + match[2] = (test[1] + (test[2] || 1)) - 0; + match[3] = test[3] - 0; + } + else if ( match[2] ) { + Sizzle.error( match[0] ); + } + + // TODO: Move to normal caching system + match[0] = done++; + + return match; + }, + + ATTR: function( match, curLoop, inplace, result, not, isXML ) { + var name = match[1] = match[1].replace( rBackslash, "" ); + + if ( !isXML && Expr.attrMap[name] ) { + match[1] = Expr.attrMap[name]; + } + + // Handle if an un-quoted value was used + match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" ); + + if ( match[2] === "~=" ) { + match[4] = " " + match[4] + " "; + } + + return match; + }, + + PSEUDO: function( match, curLoop, inplace, result, not ) { + if ( match[1] === "not" ) { + // If we're dealing with a complex expression, or a simple one + if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) { + match[3] = Sizzle(match[3], null, null, curLoop); + + } else { + var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not); + + if ( !inplace ) { + result.push.apply( result, ret ); + } + + return false; + } + + } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) { + return true; + } + + return match; + }, + + POS: function( match ) { + match.unshift( true ); + + return match; + } + }, + + filters: { + enabled: function( elem ) { + return elem.disabled === false && elem.type !== "hidden"; + }, + + disabled: function( elem ) { + return elem.disabled === true; + }, + + checked: function( elem ) { + return elem.checked === true; + }, + + selected: function( elem ) { + // Accessing this property makes selected-by-default + // options in Safari work properly + if ( elem.parentNode ) { + elem.parentNode.selectedIndex; + } + + return elem.selected === true; + }, + + parent: function( elem ) { + return !!elem.firstChild; + }, + + empty: function( elem ) { + return !elem.firstChild; + }, + + has: function( elem, i, match ) { + return !!Sizzle( match[3], elem ).length; + }, + + header: function( elem ) { + return (/h\d/i).test( elem.nodeName ); + }, + + text: function( elem ) { + var attr = elem.getAttribute( "type" ), type = elem.type; + // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) + // use getAttribute instead to test this case + return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null ); + }, + + radio: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type; + }, + + checkbox: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type; + }, + + file: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "file" === elem.type; + }, + + password: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "password" === elem.type; + }, + + submit: function( elem ) { + var name = elem.nodeName.toLowerCase(); + return (name === "input" || name === "button") && "submit" === elem.type; + }, + + image: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "image" === elem.type; + }, + + reset: function( elem ) { + var name = elem.nodeName.toLowerCase(); + return (name === "input" || name === "button") && "reset" === elem.type; + }, + + button: function( elem ) { + var name = elem.nodeName.toLowerCase(); + return name === "input" && "button" === elem.type || name === "button"; + }, + + input: function( elem ) { + return (/input|select|textarea|button/i).test( elem.nodeName ); + }, + + focus: function( elem ) { + return elem === elem.ownerDocument.activeElement; + } + }, + setFilters: { + first: function( elem, i ) { + return i === 0; + }, + + last: function( elem, i, match, array ) { + return i === array.length - 1; + }, + + even: function( elem, i ) { + return i % 2 === 0; + }, + + odd: function( elem, i ) { + return i % 2 === 1; + }, + + lt: function( elem, i, match ) { + return i < match[3] - 0; + }, + + gt: function( elem, i, match ) { + return i > match[3] - 0; + }, + + nth: function( elem, i, match ) { + return match[3] - 0 === i; + }, + + eq: function( elem, i, match ) { + return match[3] - 0 === i; + } + }, + filter: { + PSEUDO: function( elem, match, i, array ) { + var name = match[1], + filter = Expr.filters[ name ]; + + if ( filter ) { + return filter( elem, i, match, array ); + + } else if ( name === "contains" ) { + return (elem.textContent || elem.innerText || Sizzle.getText([ elem ]) || "").indexOf(match[3]) >= 0; + + } else if ( name === "not" ) { + var not = match[3]; + + for ( var j = 0, l = not.length; j < l; j++ ) { + if ( not[j] === elem ) { + return false; + } + } + + return true; + + } else { + Sizzle.error( name ); + } + }, + + CHILD: function( elem, match ) { + var type = match[1], + node = elem; + + switch ( type ) { + case "only": + case "first": + while ( (node = node.previousSibling) ) { + if ( node.nodeType === 1 ) { + return false; + } + } + + if ( type === "first" ) { + return true; + } + + node = elem; + + case "last": + while ( (node = node.nextSibling) ) { + if ( node.nodeType === 1 ) { + return false; + } + } + + return true; + + case "nth": + var first = match[2], + last = match[3]; + + if ( first === 1 && last === 0 ) { + return true; + } + + var doneName = match[0], + parent = elem.parentNode; + + if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) { + var count = 0; + + for ( node = parent.firstChild; node; node = node.nextSibling ) { + if ( node.nodeType === 1 ) { + node.nodeIndex = ++count; + } + } + + parent.sizcache = doneName; + } + + var diff = elem.nodeIndex - last; + + if ( first === 0 ) { + return diff === 0; + + } else { + return ( diff % first === 0 && diff / first >= 0 ); + } + } + }, + + ID: function( elem, match ) { + return elem.nodeType === 1 && elem.getAttribute("id") === match; + }, + + TAG: function( elem, match ) { + return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match; + }, + + CLASS: function( elem, match ) { + return (" " + (elem.className || elem.getAttribute("class")) + " ") + .indexOf( match ) > -1; + }, + + ATTR: function( elem, match ) { + var name = match[1], + result = Expr.attrHandle[ name ] ? + Expr.attrHandle[ name ]( elem ) : + elem[ name ] != null ? + elem[ name ] : + elem.getAttribute( name ), + value = result + "", + type = match[2], + check = match[4]; + + return result == null ? + type === "!=" : + type === "=" ? + value === check : + type === "*=" ? + value.indexOf(check) >= 0 : + type === "~=" ? + (" " + value + " ").indexOf(check) >= 0 : + !check ? + value && result !== false : + type === "!=" ? + value !== check : + type === "^=" ? + value.indexOf(check) === 0 : + type === "$=" ? + value.substr(value.length - check.length) === check : + type === "|=" ? + value === check || value.substr(0, check.length + 1) === check + "-" : + false; + }, + + POS: function( elem, match, i, array ) { + var name = match[2], + filter = Expr.setFilters[ name ]; + + if ( filter ) { + return filter( elem, i, match, array ); + } + } + } +}; + +var origPOS = Expr.match.POS, + fescape = function(all, num){ + return "\\" + (num - 0 + 1); + }; + +for ( var type in Expr.match ) { + Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) ); + Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) ); +} + +var makeArray = function( array, results ) { + array = Array.prototype.slice.call( array, 0 ); + + if ( results ) { + results.push.apply( results, array ); + return results; + } + + return array; +}; + +// Perform a simple check to determine if the browser is capable of +// converting a NodeList to an array using builtin methods. +// Also verifies that the returned array holds DOM nodes +// (which is not the case in the Blackberry browser) +try { + Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType; + +// Provide a fallback method if it does not work +} catch( e ) { + makeArray = function( array, results ) { + var i = 0, + ret = results || []; + + if ( toString.call(array) === "[object Array]" ) { + Array.prototype.push.apply( ret, array ); + + } else { + if ( typeof array.length === "number" ) { + for ( var l = array.length; i < l; i++ ) { + ret.push( array[i] ); + } + + } else { + for ( ; array[i]; i++ ) { + ret.push( array[i] ); + } + } + } + + return ret; + }; +} + +var sortOrder, siblingCheck; + +if ( document.documentElement.compareDocumentPosition ) { + sortOrder = function( a, b ) { + if ( a === b ) { + hasDuplicate = true; + return 0; + } + + if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) { + return a.compareDocumentPosition ? -1 : 1; + } + + return a.compareDocumentPosition(b) & 4 ? -1 : 1; + }; + +} else { + sortOrder = function( a, b ) { + // The nodes are identical, we can exit early + if ( a === b ) { + hasDuplicate = true; + return 0; + + // Fallback to using sourceIndex (in IE) if it's available on both nodes + } else if ( a.sourceIndex && b.sourceIndex ) { + return a.sourceIndex - b.sourceIndex; + } + + var al, bl, + ap = [], + bp = [], + aup = a.parentNode, + bup = b.parentNode, + cur = aup; + + // If the nodes are siblings (or identical) we can do a quick check + if ( aup === bup ) { + return siblingCheck( a, b ); + + // If no parents were found then the nodes are disconnected + } else if ( !aup ) { + return -1; + + } else if ( !bup ) { + return 1; + } + + // Otherwise they're somewhere else in the tree so we need + // to build up a full list of the parentNodes for comparison + while ( cur ) { + ap.unshift( cur ); + cur = cur.parentNode; + } + + cur = bup; + + while ( cur ) { + bp.unshift( cur ); + cur = cur.parentNode; + } + + al = ap.length; + bl = bp.length; + + // Start walking down the tree looking for a discrepancy + for ( var i = 0; i < al && i < bl; i++ ) { + if ( ap[i] !== bp[i] ) { + return siblingCheck( ap[i], bp[i] ); + } + } + + // We ended someplace up the tree so do a sibling check + return i === al ? + siblingCheck( a, bp[i], -1 ) : + siblingCheck( ap[i], b, 1 ); + }; + + siblingCheck = function( a, b, ret ) { + if ( a === b ) { + return ret; + } + + var cur = a.nextSibling; + + while ( cur ) { + if ( cur === b ) { + return -1; + } + + cur = cur.nextSibling; + } + + return 1; + }; +} + +// Utility function for retreiving the text value of an array of DOM nodes +Sizzle.getText = function( elems ) { + var ret = "", elem; + + for ( var i = 0; elems[i]; i++ ) { + elem = elems[i]; + + // Get the text from text nodes and CDATA nodes + if ( elem.nodeType === 3 || elem.nodeType === 4 ) { + ret += elem.nodeValue; + + // Traverse everything else, except comment nodes + } else if ( elem.nodeType !== 8 ) { + ret += Sizzle.getText( elem.childNodes ); + } + } + + return ret; +}; + +// Check to see if the browser returns elements by name when +// querying by getElementById (and provide a workaround) +(function(){ + // We're going to inject a fake input element with a specified name + var form = document.createElement("div"), + id = "script" + (new Date()).getTime(), + root = document.documentElement; + + form.innerHTML = ""; + + // Inject it into the root element, check its status, and remove it quickly + root.insertBefore( form, root.firstChild ); + + // The workaround has to do additional checks after a getElementById + // Which slows things down for other browsers (hence the branching) + if ( document.getElementById( id ) ) { + Expr.find.ID = function( match, context, isXML ) { + if ( typeof context.getElementById !== "undefined" && !isXML ) { + var m = context.getElementById(match[1]); + + return m ? + m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? + [m] : + undefined : + []; + } + }; + + Expr.filter.ID = function( elem, match ) { + var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); + + return elem.nodeType === 1 && node && node.nodeValue === match; + }; + } + + root.removeChild( form ); + + // release memory in IE + root = form = null; +})(); + +(function(){ + // Check to see if the browser returns only elements + // when doing getElementsByTagName("*") + + // Create a fake element + var div = document.createElement("div"); + div.appendChild( document.createComment("") ); + + // Make sure no comments are found + if ( div.getElementsByTagName("*").length > 0 ) { + Expr.find.TAG = function( match, context ) { + var results = context.getElementsByTagName( match[1] ); + + // Filter out possible comments + if ( match[1] === "*" ) { + var tmp = []; + + for ( var i = 0; results[i]; i++ ) { + if ( results[i].nodeType === 1 ) { + tmp.push( results[i] ); + } + } + + results = tmp; + } + + return results; + }; + } + + // Check to see if an attribute returns normalized href attributes + div.innerHTML = ""; + + if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" && + div.firstChild.getAttribute("href") !== "#" ) { + + Expr.attrHandle.href = function( elem ) { + return elem.getAttribute( "href", 2 ); + }; + } + + // release memory in IE + div = null; +})(); + +if ( document.querySelectorAll ) { + (function(){ + var oldSizzle = Sizzle, + div = document.createElement("div"), + id = "__sizzle__"; + + div.innerHTML = "

    "; + + // Safari can't handle uppercase or unicode characters when + // in quirks mode. + if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { + return; + } + + Sizzle = function( query, context, extra, seed ) { + context = context || document; + + // Only use querySelectorAll on non-XML documents + // (ID selectors don't work in non-HTML documents) + if ( !seed && !Sizzle.isXML(context) ) { + // See if we find a selector to speed up + var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query ); + + if ( match && (context.nodeType === 1 || context.nodeType === 9) ) { + // Speed-up: Sizzle("TAG") + if ( match[1] ) { + return makeArray( context.getElementsByTagName( query ), extra ); + + // Speed-up: Sizzle(".CLASS") + } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) { + return makeArray( context.getElementsByClassName( match[2] ), extra ); + } + } + + if ( context.nodeType === 9 ) { + // Speed-up: Sizzle("body") + // The body element only exists once, optimize finding it + if ( query === "body" && context.body ) { + return makeArray( [ context.body ], extra ); + + // Speed-up: Sizzle("#ID") + } else if ( match && match[3] ) { + var elem = context.getElementById( match[3] ); + + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + if ( elem && elem.parentNode ) { + // Handle the case where IE and Opera return items + // by name instead of ID + if ( elem.id === match[3] ) { + return makeArray( [ elem ], extra ); + } + + } else { + return makeArray( [], extra ); + } + } + + try { + return makeArray( context.querySelectorAll(query), extra ); + } catch(qsaError) {} + + // qSA works strangely on Element-rooted queries + // We can work around this by specifying an extra ID on the root + // and working up from there (Thanks to Andrew Dupont for the technique) + // IE 8 doesn't work on object elements + } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { + var oldContext = context, + old = context.getAttribute( "id" ), + nid = old || id, + hasParent = context.parentNode, + relativeHierarchySelector = /^\s*[+~]/.test( query ); + + if ( !old ) { + context.setAttribute( "id", nid ); + } else { + nid = nid.replace( /'/g, "\\$&" ); + } + if ( relativeHierarchySelector && hasParent ) { + context = context.parentNode; + } + + try { + if ( !relativeHierarchySelector || hasParent ) { + return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra ); + } + + } catch(pseudoError) { + } finally { + if ( !old ) { + oldContext.removeAttribute( "id" ); + } + } + } + } + + return oldSizzle(query, context, extra, seed); + }; + + for ( var prop in oldSizzle ) { + Sizzle[ prop ] = oldSizzle[ prop ]; + } + + // release memory in IE + div = null; + })(); +} + +(function(){ + var html = document.documentElement, + matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector; + + if ( matches ) { + // Check to see if it's possible to do matchesSelector + // on a disconnected node (IE 9 fails this) + var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ), + pseudoWorks = false; + + try { + // This should fail with an exception + // Gecko does not error, returns false instead + matches.call( document.documentElement, "[test!='']:sizzle" ); + + } catch( pseudoError ) { + pseudoWorks = true; + } + + Sizzle.matchesSelector = function( node, expr ) { + // Make sure that attribute selectors are quoted + expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']"); + + if ( !Sizzle.isXML( node ) ) { + try { + if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) { + var ret = matches.call( node, expr ); + + // IE 9's matchesSelector returns false on disconnected nodes + if ( ret || !disconnectedMatch || + // As well, disconnected nodes are said to be in a document + // fragment in IE 9, so check for that + node.document && node.document.nodeType !== 11 ) { + return ret; + } + } + } catch(e) {} + } + + return Sizzle(expr, null, null, [node]).length > 0; + }; + } +})(); + +(function(){ + var div = document.createElement("div"); + + div.innerHTML = "
    "; + + // Opera can't find a second classname (in 9.6) + // Also, make sure that getElementsByClassName actually exists + if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) { + return; + } + + // Safari caches class attributes, doesn't catch changes (in 3.2) + div.lastChild.className = "e"; + + if ( div.getElementsByClassName("e").length === 1 ) { + return; + } + + Expr.order.splice(1, 0, "CLASS"); + Expr.find.CLASS = function( match, context, isXML ) { + if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { + return context.getElementsByClassName(match[1]); + } + }; + + // release memory in IE + div = null; +})(); + +function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { + for ( var i = 0, l = checkSet.length; i < l; i++ ) { + var elem = checkSet[i]; + + if ( elem ) { + var match = false; + + elem = elem[dir]; + + while ( elem ) { + if ( elem.sizcache === doneName ) { + match = checkSet[elem.sizset]; + break; + } + + if ( elem.nodeType === 1 && !isXML ){ + elem.sizcache = doneName; + elem.sizset = i; + } + + if ( elem.nodeName.toLowerCase() === cur ) { + match = elem; + break; + } + + elem = elem[dir]; + } + + checkSet[i] = match; + } + } +} + +function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { + for ( var i = 0, l = checkSet.length; i < l; i++ ) { + var elem = checkSet[i]; + + if ( elem ) { + var match = false; + + elem = elem[dir]; + + while ( elem ) { + if ( elem.sizcache === doneName ) { + match = checkSet[elem.sizset]; + break; + } + + if ( elem.nodeType === 1 ) { + if ( !isXML ) { + elem.sizcache = doneName; + elem.sizset = i; + } + + if ( typeof cur !== "string" ) { + if ( elem === cur ) { + match = true; + break; + } + + } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) { + match = elem; + break; + } + } + + elem = elem[dir]; + } + + checkSet[i] = match; + } + } +} + +if ( document.documentElement.contains ) { + Sizzle.contains = function( a, b ) { + return a !== b && (a.contains ? a.contains(b) : true); + }; + +} else if ( document.documentElement.compareDocumentPosition ) { + Sizzle.contains = function( a, b ) { + return !!(a.compareDocumentPosition(b) & 16); + }; + +} else { + Sizzle.contains = function() { + return false; + }; +} + +Sizzle.isXML = function( elem ) { + // documentElement is verified for cases where it doesn't yet exist + // (such as loading iframes in IE - #4833) + var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement; + + return documentElement ? documentElement.nodeName !== "HTML" : false; +}; + +var posProcess = function( selector, context ) { + var match, + tmpSet = [], + later = "", + root = context.nodeType ? [context] : context; + + // Position selectors must be done after the filter + // And so must :not(positional) so we move all PSEUDOs to the end + while ( (match = Expr.match.PSEUDO.exec( selector )) ) { + later += match[0]; + selector = selector.replace( Expr.match.PSEUDO, "" ); + } + + selector = Expr.relative[selector] ? selector + "*" : selector; + + for ( var i = 0, l = root.length; i < l; i++ ) { + Sizzle( selector, root[i], tmpSet ); + } + + return Sizzle.filter( later, tmpSet ); +}; + +// EXPOSE +jQuery.find = Sizzle; +jQuery.expr = Sizzle.selectors; +jQuery.expr[":"] = jQuery.expr.filters; +jQuery.unique = Sizzle.uniqueSort; +jQuery.text = Sizzle.getText; +jQuery.isXMLDoc = Sizzle.isXML; +jQuery.contains = Sizzle.contains; + + +})(); + + +var runtil = /Until$/, + rparentsprev = /^(?:parents|prevUntil|prevAll)/, + // Note: This RegExp should be improved, or likely pulled from Sizzle + rmultiselector = /,/, + isSimple = /^.[^:#\[\.,]*$/, + slice = Array.prototype.slice, + POS = jQuery.expr.match.POS, + // methods guaranteed to produce a unique set when starting from a unique set + guaranteedUnique = { + children: true, + contents: true, + next: true, + prev: true + }; + +jQuery.fn.extend({ + find: function( selector ) { + var self = this, + i, l; + + if ( typeof selector !== "string" ) { + return jQuery( selector ).filter(function() { + for ( i = 0, l = self.length; i < l; i++ ) { + if ( jQuery.contains( self[ i ], this ) ) { + return true; + } + } + }); + } + + var ret = this.pushStack( "", "find", selector ), + length, n, r; + + for ( i = 0, l = this.length; i < l; i++ ) { + length = ret.length; + jQuery.find( selector, this[i], ret ); + + if ( i > 0 ) { + // Make sure that the results are unique + for ( n = length; n < ret.length; n++ ) { + for ( r = 0; r < length; r++ ) { + if ( ret[r] === ret[n] ) { + ret.splice(n--, 1); + break; + } + } + } + } + } + + return ret; + }, + + has: function( target ) { + var targets = jQuery( target ); + return this.filter(function() { + for ( var i = 0, l = targets.length; i < l; i++ ) { + if ( jQuery.contains( this, targets[i] ) ) { + return true; + } + } + }); + }, + + not: function( selector ) { + return this.pushStack( winnow(this, selector, false), "not", selector); + }, + + filter: function( selector ) { + return this.pushStack( winnow(this, selector, true), "filter", selector ); + }, + + is: function( selector ) { + return !!selector && ( typeof selector === "string" ? + jQuery.filter( selector, this ).length > 0 : + this.filter( selector ).length > 0 ); + }, + + closest: function( selectors, context ) { + var ret = [], i, l, cur = this[0]; + + // Array + if ( jQuery.isArray( selectors ) ) { + var match, selector, + matches = {}, + level = 1; + + if ( cur && selectors.length ) { + for ( i = 0, l = selectors.length; i < l; i++ ) { + selector = selectors[i]; + + if ( !matches[ selector ] ) { + matches[ selector ] = POS.test( selector ) ? + jQuery( selector, context || this.context ) : + selector; + } + } + + while ( cur && cur.ownerDocument && cur !== context ) { + for ( selector in matches ) { + match = matches[ selector ]; + + if ( match.jquery ? match.index( cur ) > -1 : jQuery( cur ).is( match ) ) { + ret.push({ selector: selector, elem: cur, level: level }); + } + } + + cur = cur.parentNode; + level++; + } + } + + return ret; + } + + // String + var pos = POS.test( selectors ) || typeof selectors !== "string" ? + jQuery( selectors, context || this.context ) : + 0; + + for ( i = 0, l = this.length; i < l; i++ ) { + cur = this[i]; + + while ( cur ) { + if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) { + ret.push( cur ); + break; + + } else { + cur = cur.parentNode; + if ( !cur || !cur.ownerDocument || cur === context || cur.nodeType === 11 ) { + break; + } + } + } + } + + ret = ret.length > 1 ? jQuery.unique( ret ) : ret; + + return this.pushStack( ret, "closest", selectors ); + }, + + // Determine the position of an element within + // the matched set of elements + index: function( elem ) { + + // No argument, return index in parent + if ( !elem ) { + return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1; + } + + // index in selector + if ( typeof elem === "string" ) { + return jQuery.inArray( this[0], jQuery( elem ) ); + } + + // Locate the position of the desired element + return jQuery.inArray( + // If it receives a jQuery object, the first element is used + elem.jquery ? elem[0] : elem, this ); + }, + + add: function( selector, context ) { + var set = typeof selector === "string" ? + jQuery( selector, context ) : + jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ), + all = jQuery.merge( this.get(), set ); + + return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ? + all : + jQuery.unique( all ) ); + }, + + andSelf: function() { + return this.add( this.prevObject ); + } +}); + +// A painfully simple check to see if an element is disconnected +// from a document (should be improved, where feasible). +function isDisconnected( node ) { + return !node || !node.parentNode || node.parentNode.nodeType === 11; +} + +jQuery.each({ + parent: function( elem ) { + var parent = elem.parentNode; + return parent && parent.nodeType !== 11 ? parent : null; + }, + parents: function( elem ) { + return jQuery.dir( elem, "parentNode" ); + }, + parentsUntil: function( elem, i, until ) { + return jQuery.dir( elem, "parentNode", until ); + }, + next: function( elem ) { + return jQuery.nth( elem, 2, "nextSibling" ); + }, + prev: function( elem ) { + return jQuery.nth( elem, 2, "previousSibling" ); + }, + nextAll: function( elem ) { + return jQuery.dir( elem, "nextSibling" ); + }, + prevAll: function( elem ) { + return jQuery.dir( elem, "previousSibling" ); + }, + nextUntil: function( elem, i, until ) { + return jQuery.dir( elem, "nextSibling", until ); + }, + prevUntil: function( elem, i, until ) { + return jQuery.dir( elem, "previousSibling", until ); + }, + siblings: function( elem ) { + return jQuery.sibling( elem.parentNode.firstChild, elem ); + }, + children: function( elem ) { + return jQuery.sibling( elem.firstChild ); + }, + contents: function( elem ) { + return jQuery.nodeName( elem, "iframe" ) ? + elem.contentDocument || elem.contentWindow.document : + jQuery.makeArray( elem.childNodes ); + } +}, function( name, fn ) { + jQuery.fn[ name ] = function( until, selector ) { + var ret = jQuery.map( this, fn, until ), + // The variable 'args' was introduced in + // https://github.com/jquery/jquery/commit/52a0238 + // to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed. + // http://code.google.com/p/v8/issues/detail?id=1050 + args = slice.call(arguments); + + if ( !runtil.test( name ) ) { + selector = until; + } + + if ( selector && typeof selector === "string" ) { + ret = jQuery.filter( selector, ret ); + } + + ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret; + + if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) { + ret = ret.reverse(); + } + + return this.pushStack( ret, name, args.join(",") ); + }; +}); + +jQuery.extend({ + filter: function( expr, elems, not ) { + if ( not ) { + expr = ":not(" + expr + ")"; + } + + return elems.length === 1 ? + jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] : + jQuery.find.matches(expr, elems); + }, + + dir: function( elem, dir, until ) { + var matched = [], + cur = elem[ dir ]; + + while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) { + if ( cur.nodeType === 1 ) { + matched.push( cur ); + } + cur = cur[dir]; + } + return matched; + }, + + nth: function( cur, result, dir, elem ) { + result = result || 1; + var num = 0; + + for ( ; cur; cur = cur[dir] ) { + if ( cur.nodeType === 1 && ++num === result ) { + break; + } + } + + return cur; + }, + + sibling: function( n, elem ) { + var r = []; + + for ( ; n; n = n.nextSibling ) { + if ( n.nodeType === 1 && n !== elem ) { + r.push( n ); + } + } + + return r; + } +}); + +// Implement the identical functionality for filter and not +function winnow( elements, qualifier, keep ) { + + // Can't pass null or undefined to indexOf in Firefox 4 + // Set to 0 to skip string check + qualifier = qualifier || 0; + + if ( jQuery.isFunction( qualifier ) ) { + return jQuery.grep(elements, function( elem, i ) { + var retVal = !!qualifier.call( elem, i, elem ); + return retVal === keep; + }); + + } else if ( qualifier.nodeType ) { + return jQuery.grep(elements, function( elem, i ) { + return (elem === qualifier) === keep; + }); + + } else if ( typeof qualifier === "string" ) { + var filtered = jQuery.grep(elements, function( elem ) { + return elem.nodeType === 1; + }); + + if ( isSimple.test( qualifier ) ) { + return jQuery.filter(qualifier, filtered, !keep); + } else { + qualifier = jQuery.filter( qualifier, filtered ); + } + } + + return jQuery.grep(elements, function( elem, i ) { + return (jQuery.inArray( elem, qualifier ) >= 0) === keep; + }); +} + + + + +var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, + rleadingWhitespace = /^\s+/, + rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig, + rtagName = /<([\w:]+)/, + rtbody = /", "" ], + legend: [ 1, "
    ", "
    " ], + thead: [ 1, "", "
    " ], + tr: [ 2, "", "
    " ], + td: [ 3, "", "
    " ], + col: [ 2, "", "
    " ], + area: [ 1, "", "" ], + _default: [ 0, "", "" ] + }; + +wrapMap.optgroup = wrapMap.option; +wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; +wrapMap.th = wrapMap.td; + +// IE can't serialize and
    $sql