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 29a0909..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 Wootook. - * - */ - -define('INSIDE' , true); -define('INSTALL' , false); -require_once dirname(__FILE__) .'/application/bootstrap.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 e8bf1b5..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 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))) { - 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 96d8a21..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 Wootook. - * - */ - -define('INSIDE' , true); -define('INSTALL' , false); -define('IN_ADMIN', true); -require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php'; - - if ($user['authlevel'] >= 1) { - includeLang('admin/add_fleet'); - $mode = $_GET['mode']; - - 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/mass_message.php b/admin/mass_message.php deleted file mode 100644 index 43998cf..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 Wootook. - * - */ - -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 fb7b834..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 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 ($_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 1a7c5d3..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 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 ($_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 = $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['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 5466aa1..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 Wootook. - * - */ - -define('INSIDE' , true); -define('INSTALL' , false); -define('IN_ADMIN', true); -require_once dirname(dirname(__FILE__)) .'/application/bootstrap.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 4f12f4f..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 Wootook. - * - */ - -define('INSIDE' , true); -define('INSTALL' , false); -require_once dirname(__FILE__) .'/application/bootstrap.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/application/code/core/Legacies/Empire/Model/Planet/Building/ResearchLab/Builder.php b/application/code/core/Legacies/Empire/Model/Planet/Building/ResearchLab/Builder.php deleted file mode 100644 index 82777f1..0000000 --- a/application/code/core/Legacies/Empire/Model/Planet/Building/ResearchLab/Builder.php +++ /dev/null @@ -1,252 +0,0 @@ - - * 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 -{ - /** - * @var int - */ - protected $_maxLength = 0; - - public function init() - { - $this->_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 = Wootook_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 = Wootook_Empire_Model_Game_Prices::getSingleton(); - $types = Wootook_Empire_Model_Game_Types::getSingleton(); - $gameConfig = Wootook_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 = Wootook_Empire_Model_Game_Prices::getSingleton(); - $resources = Wootook_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 = Wootook_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 = Wootook_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/application/code/core/Legacies/Officers/Model/Observer.php b/application/code/core/Legacies/Officers/Model/Observer.php deleted file mode 100644 index 65b6dc0..0000000 --- a/application/code/core/Legacies/Officers/Model/Observer.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 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_Officers_Model_Observer -{ - public static function planetUpdateListener($eventData) - { - if (isset($eventData['planet'])) { - $planet = $eventData['planet']; - - $user = $planet->getUser(); - - $level = floor(sqrt($user->getData('xpminier') / 500)); - if ($user->getData('lvl_minier') < $level) { - $difference = $level - $user->getData('lvl_minier'); - if ($difference == 1) { - Wootook::getSession(Legacies_Empire_Model_User::SESSION_KEY) - ->addInfo('You gained 1 miner level.'); - } else { - Wootook::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) { - Wootook::getSession(Legacies_Empire_Model_User::SESSION_KEY) - ->addInfo('You gained 1 raider level.'); - } else { - Wootook::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/application/code/core/Wootook.php b/application/code/core/Wootook.php deleted file mode 100644 index d2fbe94..0000000 --- a/application/code/core/Wootook.php +++ /dev/null @@ -1,285 +0,0 @@ - - * 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 - */ - 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'; - - /** - * - * Enter description here ... - * @var array - */ - protected static $_config = null; - - /** - * 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 Legacies_Core_Model_Session - */ - public static function getSession($namespace) - { - return Wootook_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 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::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 Wootook_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 Wootook_Core_Controller_Response_Http(); - } - return self::$_response; - } - - public static function setResponse($response) - { - self::$_response = $response; - } - - public static function getConfig($path = null) - { - if (self::$_config === null) { - self::$_config = include ROOT_PATH . DIRECTORY_SEPARATOR . 'config.php'; - } - - if ($path === null || !is_string($path)) { - return self::$_config; - } - $config = self::$_config; - foreach (explode('/', $path) as $chunk) { - if (!isset($config[$chunk])) { - return null; - } - $config = $config[$chunk]; - } - return $config; - } - - public static function getBaseUrl() - { - return self::getConfig('global/web/base_url'); - } - - public static function getSkinUrl($package, $theme, $uri, Array $params = array()) - { - return self::getUrl("skin/{$package}/{$theme}/{$uri}", $params); - } - - public static function getUrl($uri, Array $params = array()) - { - $baseUrl = self::getBaseUrl(); - - $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; - } - - if (($fp = @fopen($path, 'r', true)) === false) { - return false; - } - fclose($fp); - return true; - } -} \ No newline at end of file diff --git a/application/code/core/Wootook/Core/Block/Html/Head.php b/application/code/core/Wootook/Core/Block/Html/Head.php deleted file mode 100644 index 15a9107..0000000 --- a/application/code/core/Wootook/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($js['type'])) { - $js['type'] = 'text/javascript'; - } - $render .=<< -HTML_EOF; - } - return $render; - } -} \ No newline at end of file diff --git a/application/code/core/Wootook/Core/Block/Html/Navigation.php b/application/code/core/Wootook/Core/Block/Html/Navigation.php deleted file mode 100644 index 3959f6d..0000000 --- a/application/code/core/Wootook/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 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); - } -} \ No newline at end of file diff --git a/application/code/core/Wootook/Core/Block/Html/Navigation/Link.php b/application/code/core/Wootook/Core/Block/Html/Navigation/Link.php deleted file mode 100644 index cd288e4..0000000 --- a/application/code/core/Wootook/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/application/code/core/Wootook/Core/Block/Template.php b/application/code/core/Wootook/Core/Block/Template.php deleted file mode 100644 index 673440f..0000000 --- a/application/code/core/Wootook/Core/Block/Template.php +++ /dev/null @@ -1,36 +0,0 @@ -getScriptPath()}/%s/%s/scripts/{$file}"; - if (($layout = $this->getLayout()) !== null) { - $package = $this->getLayout()->getPackage(); - $theme = $this->getLayout()->getTheme(); - - if ($package !== Wootook_Core_Layout::DEFAULT_PACKAGE) { - if ($theme !== Wootook_Core_Layout::DEFAULT_THEME) { - $path = sprintf($pattern, $package, $theme); - if (Wootook::fileExists($path)) { - return $path; - } - } - - $path = sprintf($pattern, $package, Wootook_Core_Layout::DEFAULT_THEME); - if (Wootook::fileExists($path)) { - return $path; - } - } - } - - $path = sprintf($pattern, Wootook_Core_Layout::DEFAULT_PACKAGE, Wootook_Core_Layout::DEFAULT_THEME); - if (Wootook::fileExists($path)) { - return $path; - } - - trigger_error("Template '{$file}' could not be found.", E_USER_ERROR); - return null; - } -} \ No newline at end of file diff --git a/application/code/core/Wootook/Core/Collection.php b/application/code/core/Wootook/Core/Collection.php deleted file mode 100644 index 16ecde0..0000000 --- a/application/code/core/Wootook/Core/Collection.php +++ /dev/null @@ -1,366 +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 = Wootook_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 = Wootook_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 = Wootook_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 = Wootook_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('1'); - - $sql = $clone->_prepareSql(); - - $database = Wootook_Database::getSingleton(); - $statement = $database->prepare($sql); - - $args = func_get_args(); - $statement->execute(array_shift($args)); - $count = $statement->rowCount(); - $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 (!$this->_) - 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; - } -} \ No newline at end of file diff --git a/application/code/core/Wootook/Core/Controller/Action.php b/application/code/core/Wootook/Core/Controller/Action.php deleted file mode 100644 index 58aa8ec..0000000 --- a/application/code/core/Wootook/Core/Controller/Action.php +++ /dev/null @@ -1,50 +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()->setRedirect($url); - - return $this; - } -} \ No newline at end of file diff --git a/application/code/core/Wootook/Core/Controller/Request/Http.php b/application/code/core/Wootook/Core/Controller/Request/Http.php deleted file mode 100644 index 611294f..0000000 --- a/application/code/core/Wootook/Core/Controller/Request/Http.php +++ /dev/null @@ -1,102 +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]; - } - - public function isPost() - { - if (strtoupper($this->getServer('REQUEST_METHOD')) == 'POST') { - return true; - } - return false; - } - - public function isGet() - { - if (strtoupper($this->getServer('REQUEST_METHOD')) == 'GET') { - return true; - } - return false; - } -} \ No newline at end of file diff --git a/application/code/core/Wootook/Core/Email.php b/application/code/core/Wootook/Core/Email.php deleted file mode 100644 index 0dfcba4..0000000 --- a/application/code/core/Wootook/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 . ' Wootook/' . 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/application/code/core/Wootook/Core/Entity.php b/application/code/core/Wootook/Core/Entity.php deleted file mode 100644 index 9c736ee..0000000 --- a/application/code/core/Wootook/Core/Entity.php +++ /dev/null @@ -1,153 +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 = Wootook_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 Wootook_Core_Exception_DataAccessException('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 = Wootook_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 = Wootook_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 = Wootook_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/application/code/core/Wootook/Core/EntityInterface.php b/application/code/core/Wootook/Core/EntityInterface.php deleted file mode 100644 index 9843e61..0000000 --- a/application/code/core/Wootook/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) - { - if (!self::$_listen) { - return; - } - $this->_exceptions[] = $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 <<'; - 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(++$index, $error);
-            }
-            foreach ($this->_warnings as $error) {
-                echo $this->_renderError(++$index, $error);
-            }
-            foreach ($this->_notices as $error) {
-                echo $this->_renderError(++$index, $error);
-            }
-            foreach ($this->_otherErrors as $errorList) {
-                foreach ($errorList as $error) {
-                    echo $this->_renderError(++$index, $error);
-                }
-            }
-            foreach ($this->_exceptions as $exception) {
-                $index++;
-                echo "Message #{$index}". PHP_EOL;
-                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')); - } - } - - public static function sleep() - { - self::$_listen = false; - } - - public static function wakeup() - { - self::$_listen = true; - } -} diff --git a/application/code/core/Wootook/Core/Event.php b/application/code/core/Wootook/Core/Event.php deleted file mode 100644 index 42d5c92..0000000 --- a/application/code/core/Wootook/Core/Event.php +++ /dev/null @@ -1,6 +0,0 @@ - array( - 'Wootook_Core_Block_' => 'Wootook/core/Block' - ) - ); - - public function _init() - { - $modules = Wootook_Core_Model_Config_Modules::getSingleton(); - - foreach ($modules['block'] as $module => $moduleNamespaces) { - foreach ($moduleNamespaces as $namespace => $path) { - $this->registerBlockNamespace($module, $namespace, $path); - } - } - - $config = include ROOT_PATH . 'config.php'; - $fileList = array(); - if (isset($config['global'])) { - if (isset($config['global']['layout'])) { - $fileList = $config['global']['layout']; - } - if (isset($config['global']['package'])) { - $this->setPackage($config['global']['package']); - } - if (isset($config['global']['theme'])) { - $this->setTheme($config['global']['theme']); - } - } - - foreach ($fileList as $layoutFile) { - foreach (include $this->_getLayoutPath($layoutFile) as $layoutId => $layoutConfig) { - if ($this->hasData($layoutId)) { - $declared = $this->getData($layoutId); - - $layoutConfig = array_merge($declared, $layoutConfig); - } - - $this->setData($layoutId, $layoutConfig); - } - } - - return $this; - } - - protected 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']); - - if (isset($layoutConfig['type'])) { - $type = $layoutConfig['type']; - $name = isset($layoutConfig['name']) ? $layoutConfig['name'] : 'root'; - - $this->_view = $this->_createBlock($type, $name, $layoutConfig); - } else if (!isset($this->_view)) { - 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']); - } - } - } - - foreach ($this->_blocks as $block) { - $block->prepareLayout(); - } - } - - protected function _save() - { - } - - protected 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))); - - 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::sleep(); - if (!($fp = @fopen($fileName, 'r', true))) { - Wootook_Core_ErrorProfiler::wakeup(); - continue; - } - Wootook_Core_ErrorProfiler::wakeup(); - fclose($fp); - - if (!class_exists($className, true)) { - continue; - } - - return $className; - } - } - - trigger_error(Wootook::__('Class type "%s" could not be resolved.', $type), E_USER_INFO); - return null; - } - - 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; - } - - public function unregisterBlockNamespace($module, $namespace) - { - if (isset($this->_namespaces[$module]) && isset($this->_namespaces[$module][$namespace])) { - unset($this->_namespaces[$module][$namespace]); - } - - return $this; - } - - 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); - - 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_View($config); - } else { - $instance->$alias = $this->_createBlock($config['type'], $name, $config); - } - } - } catch (ReflectionException $e) { - trigger_error($e->getMessage(), E_USER_INFO); - 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 Wootook_Core_Exception_RuntimeException(); - } - } - - $reflectionMethod->invokeArgs($block, $callParamaters); - } catch (ReflectionException $e) { - trigger_error($e->getMessage(), E_USER_INFO); - continue; - } catch (RuntimeException $e) { - trigger_error($e->getMessage(), E_USER_WARNING); - continue; - } - } - } - - public function getPackage() - { - return $this->_package; - } - - public function setPackage($package) - { - $this->_package = $package; - - return $this; - } - - public function getTheme() - { - return $this->_theme; - } - - public function setTheme($theme) - { - $this->_theme = $theme; - - return $this; - } - - public function getScriptPath() - { - return APPLICATION_PATH . DIRECTORY_SEPARATOR . 'design'; - } - - public function getBlock($code) - { - if (isset($this->_blocks[$code])) { - return $this->_blocks[$code]; - } - return null; - } - - public function render() - { - $scriptPath = $this->getScriptPath(); - foreach ($this->_blocks as $block) { - if ($block instanceof Wootook_Core_Block_Template) { - $block->setScriptPath($scriptPath); - } - $block->beforeToHtml(); - } - unset($block); - - return $this->_view->render(); - } - - protected function _getLayoutPath($file) - { - $package = $this->getPackage(); - $theme = $this->getTheme(); - $pattern = "{$this->getScriptPath()}/%s/%s/layouts/{$file}"; - - $path = sprintf($pattern, $package, $theme); - if (Wootook::fileExists($path)) { - return $path; - } - - $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; - } - - trigger_error(Legacies::__("Layout file '%s' does not exist.", $file), E_USER_INFO); - - return null; - } -} \ No newline at end of file diff --git a/application/code/core/Wootook/Core/Model/Config.php b/application/code/core/Wootook/Core/Model/Config.php deleted file mode 100644 index 26dda47..0000000 --- a/application/code/core/Wootook/Core/Model/Config.php +++ /dev/null @@ -1,88 +0,0 @@ -load(); - } - - protected function _load() - { - $database = Wootook_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 = Wootook_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/application/code/core/Wootook/Core/Model/Session.php b/application/code/core/Wootook/Core/Model/Session.php deleted file mode 100644 index 5199542..0000000 --- a/application/code/core/Wootook/Core/Model/Session.php +++ /dev/null @@ -1,145 +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/application/code/core/Wootook/Core/Singleton.php b/application/code/core/Wootook/Core/Singleton.php deleted file mode 100644 index be1d3dc..0000000 --- a/application/code/core/Wootook/Core/Singleton.php +++ /dev/null @@ -1,6 +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 = Wootook::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); - - Wootook::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/application/code/core/Wootook/Empire/Block/Topnav.php b/application/code/core/Wootook/Empire/Block/Topnav.php deleted file mode 100644 index 841df96..0000000 --- a/application/code/core/Wootook/Empire/Block/Topnav.php +++ /dev/null @@ -1,32 +0,0 @@ -getCurrentUser()->getCurrentPlanet(); - } - - /** - * - * @return Wootook_Core_Collection - */ - public function getPlanetCollection() - { - return $this->getCurrentUser()->getPlanetCollection(); - } -} \ No newline at end of file diff --git a/application/code/core/Wootook/Empire/Exception.php b/application/code/core/Wootook/Empire/Exception.php deleted file mode 100644 index 73de227..0000000 --- a/application/code/core/Wootook/Empire/Exception.php +++ /dev/null @@ -1,3 +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/application/code/core/Wootook/Empire/Model/Planet/Exception.php b/application/code/core/Wootook/Empire/Model/Planet/Exception.php deleted file mode 100644 index 206a600..0000000 --- a/application/code/core/Wootook/Empire/Model/Planet/Exception.php +++ /dev/null @@ -1,3 +0,0 @@ -_currentUser = $currentUser; - $this->_currentPlanet = $currentPlanet; - } - - protected function _load($className, $useSingleton) - { - $reflection = new ClassReflection($className); - if ($useSingleton && $reflection->implementsInterface('Wootook_Core_Singleton')) { - $method = $reflection->getMethod('getSingleton'); - $method->invoke(); - } - - try { - return $reflection->invoke($this->_currentPlanet, $this->_currentUser); - } catch (ReflectionException $e) { - return null; - } - } -} diff --git a/application/code/core/Wootook/Empire/Model/Planet/ShipAbstract.php b/application/code/core/Wootook/Empire/Model/Planet/ShipAbstract.php deleted file mode 100644 index 6b74645..0000000 --- a/application/code/core/Wootook/Empire/Model/Planet/ShipAbstract.php +++ /dev/null @@ -1,27 +0,0 @@ -getElement(Legacies_Empire::ID_RESEARCH_COMBUSTION_DRIVE)); - } - - public function getActualSpeed(Wootook_Empire_Model_User $user) - { - return $this->getBaseSpeed($user) * $this->getSpeedMultiplier($user); - } - - public function getActualConsumption(Wootook_Empire_Model_User $user, $speed) - { - return $this->getBaseConsumption($user) * ($speed / 100) * $this->getSpeedMultiplier($user); - } -} \ No newline at end of file diff --git a/application/code/core/Wootook/Empire/Model/Planet/ShipInterface.php b/application/code/core/Wootook/Empire/Model/Planet/ShipInterface.php deleted file mode 100644 index 81c54cc..0000000 --- a/application/code/core/Wootook/Empire/Model/Planet/ShipInterface.php +++ /dev/null @@ -1,11 +0,0 @@ -getData('username'); - } - - public static function getSingleton() - { - if (self::$_singleton === null) { - $session = Wootook::getSession(self::SESSION_KEY); - if ($session->hasData('user_id')) { - $id = intval($session->getData('user_id')); - } else if (Wootook::getRequest() !== null && ($cookie = Wootook::getRequest()->getCookie(self::$_cookieName)) !== null) { - $cookieData = unserialize(stripslashes($cookie)); - if (is_array($cookieData)) { - $collection = new Wootook_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 (Wootook_Core_Exception_DataAccessException $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() - { - Wootook::getResponse()->unsetCookie(self::$_cookieName); - Wootook_Core_Model_Session::destroy(); - } - - public static function login($username, $password, $remember = false) - { - $session = Wootook::getSession(self::SESSION_KEY); - - try { - $collection = new Wootook_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 (Wootook_Core_Exception_DataAccessException $e) { - Wootook_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"]) && Wootook::getRequest() !== null) { - Wootook::$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 = Wootook::getRequest(); - $user = new self(array( - 'username' => $username, - 'password' => md5($password), - 'email' => $email, - 'email_2' => $email, - - 'register_time' => Wootook::now(), - 'onlinetime' => Wootook::now(), - 'ip_at_reg' => $request->getServer('REMOTE_ADDR'), - 'user_lastip' => $request->getServer('REMOTE_ADDR'), - 'user_agent' => $request->getServer('HTTP_USER_AGENT') - )); - - $user->save(); - - Wootook::dispatchEvent('user.init', array( - 'user' => $user - )); - - $user->save(); - } catch (Wootook_Core_Exception_DataAccessException $e) { - echo $e->getTraceAsString(); - $session->addError($e->getMessage()); - return null; - } - - return $user; - } - - /** - * - * 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->getUserId() != $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->getUserId() != $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->getUserId() != $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->getUserId() != $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(); - $this->setData('current_planet', $this->_currentPlanet->getId())->save(); - - return $this->_currentPlanet; - } - - $planet = Wootook_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 Wootook_Core_Collection(array('planet' => 'planets'), 'Wootook_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; - } - - protected function _prepareFleetCollection() - { - $collection = new Wootook_Core_Collection(array('fleet' => 'fleets')); - $collection - ->setEntityClassName('Wootook_Empire_Model_Fleet') - ->where('fleet_owner <= :user_id') - ; - return $collection; - } - - public function getFleets() - { - return $this->_prepareFleetCollection()->load(array('user_id' => $this->getId())); - } - - public function getFleetCount() - { - return $this->_prepareFleetCollection()->getSize(array('user_id' => $this->getId())); - } - - public function getVisibleFleets() - { - - $user = Wootook_Empire_Model_User::getSingleton(); - $firstCollection = new Wootook_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 Wootook_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 Wootook_Core_Collection(); - $collection - ->setEntityClassName('Wootook_Empire_Model_Fleet') - ->union($firstCollection) - ->union($backCollection) - ->load(array('now' => time())); - - return $collection; - } - - public function getElement($elementId) - { - $fields = Wootook_Empire_Model_Game_FieldsAlias::getSingleton(); - - return $this->getData($fields[$elementId]); - } - - public function setElement($elementId, $level) - { - $fields = Wootook_Empire_Model_Game_FieldsAlias::getSingleton(); - - return $this->setData($fields[$elementId], $level); - } - - public function hasElement($elementId, $levelRequired = 0) - { - $fields = Wootook_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 Wootook_Core_Collection(array('fleet' => 'fleets')); - $firstCollection - ->column('*') - ->where('fleet.fleet_owner = :user') - ; - $backCollection = new Wootook_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 Wootook_Core_Collection(); - $collection - ->setEntityClassName('Wootook_Empire_Model_Fleet') - ->union($firstCollection) - ->union($backCollection) - ->load($options) - ; - - return $collection; - } - - public function getNewMessagesCount() - { - $messageCollection = new Wootook_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/application/code/core/Wootook/Exception.php b/application/code/core/Wootook/Exception.php deleted file mode 100644 index b20ebf1..0000000 --- a/application/code/core/Wootook/Exception.php +++ /dev/null @@ -1,3 +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' => 'legacies_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' => 'legacies_empire/planet.shipyard.item' - ) - ), - ) - ), - 'queue' => array( - 'type' => 'legacies_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' => 'legacies_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' => 'legacies_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' => 'legacies_empire/planet.research-lab.item' - ) - ), - ) - ), - 'queue' => array( - 'type' => 'legacies_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' => 'legacies_empire/planet.research-lab.queue.item' - ) - ) - ) - ) - ) - ) - ) - ) - ); diff --git a/application/design/base/default/layouts/page.php b/application/design/base/default/layouts/page.php deleted file mode 100644 index df732a1..0000000 --- a/application/design/base/default/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/application/design/base/default/scripts/deprecated/admin/overview_body.tpl b/application/design/base/default/scripts/deprecated/admin/overview_body.tpl deleted file mode 100644 index bcc3642..0000000 --- a/application/design/base/default/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/application/design/base/default/scripts/deprecated/agreement.tpl b/application/design/base/default/scripts/deprecated/agreement.tpl deleted file mode 100644 index 44c2012..0000000 --- a/application/design/base/default/scripts/deprecated/agreement.tpl +++ /dev/null @@ -1 +0,0 @@ -N/A \ No newline at end of file diff --git a/application/design/base/default/scripts/deprecated/alliance_admin_laws.tpl b/application/design/base/default/scripts/deprecated/alliance_admin_laws.tpl deleted file mode 100644 index 2935d69..0000000 --- a/application/design/base/default/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/application/design/base/default/scripts/deprecated/alliance_admin_laws_head.tpl b/application/design/base/default/scripts/deprecated/alliance_admin_laws_head.tpl deleted file mode 100644 index 131303d..0000000 --- a/application/design/base/default/scripts/deprecated/alliance_admin_laws_head.tpl +++ /dev/null @@ -1,15 +0,0 @@ -
-
- - - getData('Range_name')?> - - - - - - - - - - diff --git a/application/design/base/default/scripts/deprecated/alliance_admin_laws_row.tpl b/application/design/base/default/scripts/deprecated/alliance_admin_laws_row.tpl deleted file mode 100644 index 014a5c6..0000000 --- a/application/design/base/default/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/application/design/base/default/scripts/deprecated/buildings_builds.tpl b/application/design/base/default/scripts/deprecated/buildings_builds.tpl deleted file mode 100644 index d6085b8..0000000 --- a/application/design/base/default/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/application/design/base/default/scripts/deprecated/buildings_builds_queue_script.tpl b/application/design/base/default/scripts/deprecated/buildings_builds_queue_script.tpl deleted file mode 100644 index 7d042ac..0000000 --- a/application/design/base/default/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/application/design/base/default/scripts/deprecated/buildings_builds_row.tpl b/application/design/base/default/scripts/deprecated/buildings_builds_row.tpl deleted file mode 100644 index 86c0f05..0000000 --- a/application/design/base/default/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/application/design/base/default/scripts/deprecated/buildings_builds_script.tpl b/application/design/base/default/scripts/deprecated/buildings_builds_script.tpl deleted file mode 100644 index 480c5dd..0000000 --- a/application/design/base/default/scripts/deprecated/buildings_builds_script.tpl +++ /dev/null @@ -1,8 +0,0 @@ - -
\ No newline at end of file diff --git a/application/design/base/default/scripts/deprecated/buildings_defense.tpl b/application/design/base/default/scripts/deprecated/buildings_defense.tpl deleted file mode 100644 index ee402c5..0000000 --- a/application/design/base/default/scripts/deprecated/buildings_defense.tpl +++ /dev/null @@ -1,19 +0,0 @@ -
-
- - - - - -
-
- - getData('buildlist')?> - - - -
-
-
-getData('buildinglist')?> -
\ No newline at end of file diff --git a/application/design/base/default/scripts/deprecated/buildings_fleet.tpl b/application/design/base/default/scripts/deprecated/buildings_fleet.tpl deleted file mode 100644 index 0ab1b2f..0000000 --- a/application/design/base/default/scripts/deprecated/buildings_fleet.tpl +++ /dev/null @@ -1,19 +0,0 @@ -
-
- - - - - -
-
- - getData('buildlist')?> - - - -
-
-
-getData('buildinglist')?> -
\ No newline at end of file diff --git a/application/design/base/default/scripts/deprecated/buildings_research.tpl b/application/design/base/default/scripts/deprecated/buildings_research.tpl deleted file mode 100644 index 080cc49..0000000 --- a/application/design/base/default/scripts/deprecated/buildings_research.tpl +++ /dev/null @@ -1,15 +0,0 @@ -
-getData('noresearch')?> -
- - - - -
- - - getData('technolist')?> - -
-
-
\ No newline at end of file diff --git a/application/design/base/default/scripts/deprecated/buildings_research_row.tpl b/application/design/base/default/scripts/deprecated/buildings_research_row.tpl deleted file mode 100644 index a7247a3..0000000 --- a/application/design/base/default/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/application/design/base/default/scripts/deprecated/buildings_research_script.tpl b/application/design/base/default/scripts/deprecated/buildings_research_script.tpl deleted file mode 100644 index af1cb87..0000000 --- a/application/design/base/default/scripts/deprecated/buildings_research_script.tpl +++ /dev/null @@ -1,23 +0,0 @@ -
- \ No newline at end of file diff --git a/application/design/base/default/scripts/deprecated/buildings_script.tpl b/application/design/base/default/scripts/deprecated/buildings_script.tpl deleted file mode 100644 index 9e251a6..0000000 --- a/application/design/base/default/scripts/deprecated/buildings_script.tpl +++ /dev/null @@ -1,39 +0,0 @@ -
Production Actuelle: - -
- \ No newline at end of file diff --git a/application/design/base/default/scripts/deprecated/install/ins_acc.tpl b/application/design/base/default/scripts/deprecated/install/ins_acc.tpl deleted file mode 100644 index 990f8db..0000000 --- a/application/design/base/default/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/application/design/base/default/scripts/deprecated/install/ins_acc_done.tpl b/application/design/base/default/scripts/deprecated/install/ins_acc_done.tpl deleted file mode 100644 index 2e14361..0000000 --- a/application/design/base/default/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/application/design/base/default/scripts/deprecated/install/ins_body.tpl b/application/design/base/default/scripts/deprecated/install/ins_body.tpl deleted file mode 100644 index 295e294..0000000 --- a/application/design/base/default/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/application/design/base/default/scripts/deprecated/install/ins_form.tpl b/application/design/base/default/scripts/deprecated/install/ins_form.tpl deleted file mode 100644 index 9b3b364..0000000 --- a/application/design/base/default/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/application/design/base/default/scripts/deprecated/install/ins_form_done.tpl b/application/design/base/default/scripts/deprecated/install/ins_form_done.tpl deleted file mode 100644 index 3d9426d..0000000 --- a/application/design/base/default/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/application/design/base/default/scripts/deprecated/install/ins_goto_done.tpl b/application/design/base/default/scripts/deprecated/install/ins_goto_done.tpl deleted file mode 100644 index 55d1b13..0000000 --- a/application/design/base/default/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/application/design/base/default/scripts/deprecated/install/ins_goto_form.tpl b/application/design/base/default/scripts/deprecated/install/ins_goto_form.tpl deleted file mode 100644 index 0539d11..0000000 --- a/application/design/base/default/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/application/design/base/default/scripts/deprecated/install/ins_goto_intro.tpl b/application/design/base/default/scripts/deprecated/install/ins_goto_intro.tpl deleted file mode 100644 index 16c01e9..0000000 --- a/application/design/base/default/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/application/design/base/default/scripts/deprecated/install/ins_intro.tpl b/application/design/base/default/scripts/deprecated/install/ins_intro.tpl deleted file mode 100644 index fe25771..0000000 --- a/application/design/base/default/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/application/design/base/default/scripts/deprecated/left_menu.tpl b/application/design/base/default/scripts/deprecated/left_menu.tpl deleted file mode 100644 index 1a5a0be..0000000 --- a/application/design/base/default/scripts/deprecated/left_menu.tpl +++ /dev/null @@ -1,97 +0,0 @@ -
- - -
- -
- -
\ No newline at end of file diff --git a/application/design/base/default/scripts/empire/overview/fleet/item.phtml b/application/design/base/default/scripts/empire/overview/fleet/item.phtml deleted file mode 100644 index f01fb8e..0000000 --- a/application/design/base/default/scripts/empire/overview/fleet/item.phtml +++ /dev/null @@ -1,21 +0,0 @@ -getData('fleet')?> -getData('user')?> - - getData('fleet_javai')?> - -
-
- getArrivalTime()?> - - - isOwnedBy($user) || $fleet->isMission(Legacies_Empire::ID_MISSION_TRANSPORT) || $fleet->isMission(Legacies_Empire::ID_MISSION_STATION) || $fleet->isMission(Legacies_Empire::ID_MISSION_STATION_ALLY)):?> - __('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', $fleet->getOwner()->getUsername(), $fleet->getOriginPlanet()->getName(), $fleet->getDestinationPlanet()->getName(), $fleet->getMissionLabel())?> - isOwnedBy($user) || $fleet->isMission(Legacies_Empire::ID_MISSION_ATTACK) || $fleet->isMission(Legacies_Empire::ID_MISSION_GROUP_ATTACK) || $fleet->isMission(Legacies_Empire::ID_MISSION_DESTROY) || $fleet->isMission(Legacies_Empire::ID_MISSION_MISSILES) || $fleet->isMission(Legacies_Empire::ID_MISSION_SPY)):?> - __('Your hostile fleet, sent from %1$s, reaches %2$d\'s planet %3$d. It has been sent with the mission: %4$d', $fleet->getOriginPlanet()->getName(), $fleet->getDestinationPlanet()->getUser()->getUsername(), $fleet->getDestinationPlanet()->getName(), $fleet->getMissionLabel())?> - isOwnedBy($user)):?> - __('Your peaceful fleet, sent from %2$s, reaches the planet %3$d. It has been sent with the mission: %4$d', $fleet->getOwner()->getUsername(), $fleet->getOriginPlanet()->getName(), $fleet->getDestinationPlanet()->getName(), $fleet->getMissionLabel())?> - - __('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', $fleet->getOwner()->getUsername(), $fleet->getOriginPlanet()->getName(), $fleet->getDestinationPlanet()->getName(), $fleet->getMissionLabel())?> - - - getData('fleet_javas')?> - \ No newline at end of file diff --git a/application/design/base/default/scripts/empire/overview/form/rename-planet.phtml b/application/design/base/default/scripts/empire/overview/form/rename-planet.phtml deleted file mode 100644 index 45ba7da..0000000 --- a/application/design/base/default/scripts/empire/overview/form/rename-planet.phtml +++ /dev/null @@ -1,10 +0,0 @@ -
-
- - - - - - -
-
\ No newline at end of file diff --git a/application/design/base/default/scripts/empire/overview/planet/list/item.phtml b/application/design/base/default/scripts/empire/overview/planet/list/item.phtml deleted file mode 100644 index 7d778ea..0000000 --- a/application/design/base/default/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/application/design/base/default/scripts/empire/overview/planet/view.phtml b/application/design/base/default/scripts/empire/overview/planet/view.phtml deleted file mode 100644 index 8230a16..0000000 --- a/application/design/base/default/scripts/empire/overview/planet/view.phtml +++ /dev/null @@ -1 +0,0 @@ -planetList->render() ?> diff --git a/application/design/base/default/scripts/empire/planet/buildings.phtml b/application/design/base/default/scripts/empire/planet/buildings.phtml deleted file mode 100644 index c8e4fd9..0000000 --- a/application/design/base/default/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/application/design/base/default/scripts/empire/planet/buildings/item.phtml b/application/design/base/default/scripts/empire/planet/buildings/item.phtml deleted file mode 100644 index 30c6f33..0000000 --- a/application/design/base/default/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/application/design/base/default/scripts/empire/planet/buildings/queue/item.phtml b/application/design/base/default/scripts/empire/planet/buildings/queue/item.phtml deleted file mode 100644 index 0825de3..0000000 --- a/application/design/base/default/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/application/design/base/default/scripts/empire/planet/research-lab.phtml b/application/design/base/default/scripts/empire/planet/research-lab.phtml deleted file mode 100644 index 78be4c0..0000000 --- a/application/design/base/default/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/application/design/base/default/scripts/empire/planet/research-lab/item.phtml b/application/design/base/default/scripts/empire/planet/research-lab/item.phtml deleted file mode 100644 index 9fd2017..0000000 --- a/application/design/base/default/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/application/design/base/default/scripts/empire/planet/research-lab/queue/item.phtml b/application/design/base/default/scripts/empire/planet/research-lab/queue/item.phtml deleted file mode 100644 index 0825de3..0000000 --- a/application/design/base/default/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/application/design/base/default/scripts/empire/planet/shipyard.phtml b/application/design/base/default/scripts/empire/planet/shipyard.phtml deleted file mode 100644 index 9a7d684..0000000 --- a/application/design/base/default/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/application/design/base/default/scripts/empire/planet/shipyard/item.phtml b/application/design/base/default/scripts/empire/planet/shipyard/item.phtml deleted file mode 100644 index 184683e..0000000 --- a/application/design/base/default/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/application/design/base/default/scripts/empire/planet/shipyard/queue.phtml~HEAD b/application/design/base/default/scripts/empire/planet/shipyard/queue.phtml~HEAD deleted file mode 100644 index b3d9bbc..0000000 --- a/application/design/base/default/scripts/empire/planet/shipyard/queue.phtml~HEAD +++ /dev/null @@ -1 +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/application/design/base/default/scripts/page/html/navigation.phtml b/application/design/base/default/scripts/page/html/navigation.phtml deleted file mode 100644 index 7552419..0000000 --- a/application/design/base/default/scripts/page/html/navigation.phtml +++ /dev/null @@ -1,5 +0,0 @@ - diff --git a/application/design/base/default/scripts/page/html/navigation/link.phtml b/application/design/base/default/scripts/page/html/navigation/link.phtml deleted file mode 100644 index 8e44687..0000000 --- a/application/design/base/default/scripts/page/html/navigation/link.phtml +++ /dev/null @@ -1 +0,0 @@ -escape($link->getLabel())?> diff --git a/application/design/base/default/scripts/page/html/navigation/node.phtml b/application/design/base/default/scripts/page/html/navigation/node.phtml deleted file mode 100644 index adebdab..0000000 --- a/application/design/base/default/scripts/page/html/navigation/node.phtml +++ /dev/null @@ -1,5 +0,0 @@ - \ No newline at end of file diff --git a/application/design/base/default/scripts/user/login.phtml b/application/design/base/default/scripts/user/login.phtml deleted file mode 100644 index 4e51e00..0000000 --- a/application/design/base/default/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/application/gamedata/legacies/default/events.php b/application/gamedata/legacies/default/events.php deleted file mode 100644 index 379ac37..0000000 --- a/application/gamedata/legacies/default/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('Wootook_Empire_Model_Planet', 'registrationListener') - ), - 'planet.update' => array( - array('Wootook_Empire_Model_Planet', 'planetUpdateListener'), - array('Legacies_Empire_Model_Planet_Building_Shipyard', 'planetUpdateListener') - ), - 'user.init' => array( - array('Wootook_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/application/gamedata/legacies/default/modules.php b/application/gamedata/legacies/default/modules.php deleted file mode 100644 index 5a2bd48..0000000 --- a/application/gamedata/legacies/default/modules.php +++ /dev/null @@ -1,9 +0,0 @@ - array( - 'core' => array('Wootook_Core_Block_' => 'Wootook/Core/Block'), - 'empire' => array('Wootook_Empire_Block_' => 'Wootook/Empire/Block'), - 'legacies_core' => array('Legacies_Core_Block_' => 'Legacies/Core/Block'), - 'legacies_empire' => array('Legacies_Empire_Block_' => 'Legacies/Empire/Block'), - 'legacies_officers' => array('Legacies_Officers_Block_' => 'Legacies/Officers/Block') - ) - ); \ No newline at end of file diff --git a/application/gamedata/legacies/default/production.php b/application/gamedata/legacies/default/production.php deleted file mode 100644 index 125faa4..0000000 --- a/application/gamedata/legacies/default/production.php +++ /dev/null @@ -1,71 +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_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_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_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_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_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_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_CLASS => 'Legacies_Empire_Model_Planet_Ship_Supernova' - ) -// }}} - ); diff --git a/application/scripts/legacies/client.js b/application/scripts/legacies/client.js deleted file mode 100644 index 203285c..0000000 --- a/application/scripts/legacies/client.js +++ /dev/null @@ -1,265 +0,0 @@ -/** - * This file is part of Wootook - * - * @license http://www.gnu.org/licenses/gpl-3.0.txt -* @see http://www.wootook.com/ - * - * 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/application/scripts/sizzle.js b/application/scripts/sizzle.js deleted file mode 100644 index 07654d5..0000000 --- a/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/application/test/UpdatePlanet.php b/application/test/UpdatePlanet.php deleted file mode 100644 index f91e5af..0000000 --- a/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(); - -Wootook::dispatchEvent('planet.update', array( - 'planet' => $planet, - 'time' => 5400 - )); - -var_dump(array_diff($planet->getAllDatas(), $data)); -$data = $planet->getAllDatas(); - -Wootook::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(); - -Wootook::dispatchEvent('planet.update', array( - 'planet' => $planet, - 'time' => (3600 * 30) - )); - -var_dump(array_diff($planet->getAllDatas(), $data)); -$data = $planet->getAllDatas(); - -Wootook::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); - -Wootook::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/application/test/bootstrap.php b/application/test/bootstrap.php deleted file mode 100644 index 3eb5410..0000000 --- a/application/test/bootstrap.php +++ /dev/null @@ -1,46 +0,0 @@ - $listenerList) { - foreach ($listenerList as $listener) { - Wootook::registerListener($event, $listener); - } -} - -include ROOT_PATH . 'includes/constants.php'; \ No newline at end of file diff --git a/application/test/registration.php b/application/test/registration.php deleted file mode 100644 index e02fbe7..0000000 --- a/application/test/registration.php +++ /dev/null @@ -1,43 +0,0 @@ - array(), - 'system' => array(), - ); -*/ -for ($i = 0; $i < 10000; $i++) { - $collection = Legacies_Empire_Model_Planet::searchMostFreeSystems(); - $collection->limit(1)->load(); - $systemInfo = $collection->current(); - - //var_dump($systemInfo->getallDatas()); - echo $systemInfo->getData('galaxy') . ';' . $systemInfo->getData('system') . PHP_EOL; -/* - $galaxy = $systemInfo->getData('galaxy'); - if (!isset($datas['galaxy'][$galaxy])) { - $datas['galaxy'][$galaxy] = 1; - } else { - $datas['galaxy'][$galaxy]++; - } - - $system = $systemInfo->getData('system'); - if (!isset($datas['system'][$system])) { - $datas['system'][$system] = 1; - } else { - $datas['system'][$system]++; - } -*/ -} -/* -asort($datas['galaxy'], SORT_NUMERIC); -asort($datas['system'], SORT_NUMERIC); - -var_dump($datas); -*/ \ 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 babc392..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 Wootook. - * - */ - -define('INSIDE' , true); -define('INSTALL' , false); -require_once dirname(__FILE__) .'/application/bootstrap.php'; - -includeLang('buildings'); - -$user = Wootook_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) < 1) { - $layout = new Wootook_Core_Layout(); - $layout->load('message'); - - $block = $layout->getBlock('message'); - $block['title'] = Wootook::__('Shipyard is required'); - $block['message'] = Wootook::__('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 Wootook_Core_Layout(); - $layout->load('planet.shipyard'); - - echo $layout->render(); - break; - -case 'research': - if ($planet->getElement(Legacies_Empire::ID_BUILDING_RESEARCH_LAB) < 1) { - $layout = new Wootook_Core_Layout(); - $layout->load('message'); - - $block = $layout->getBlock('message'); - $block['title'] = Wootook::__('Research lab is required'); - $block['title'] = Wootook::__('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 Wootook_Core_Layout(); - $layout->load('planet.research-lab'); - - echo $layout->render(); - break; - -case 'defense': - if ($planet->getElement(Legacies_Empire::ID_BUILDING_SHIPYARD) < 1) { - $layout = new Wootook_Core_Layout(); - $layout->load('message'); - - $block = $layout->getBlock('message'); - $block['title'] = Wootook::__('Shipyard is required'); - $block['title'] = Wootook::__('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 Wootook_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 Wootook_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 782d3d5..0000000 --- a/config.php.default +++ /dev/null @@ -1,28 +0,0 @@ - array( - 'storyline' => array( - 'universe' => 'legacies', - 'episode' => 'default', - ), - 'web' => array( - 'base_url' => 'http://testing.xnova-legacies.org/' - ), - '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/extension.inc b/extension.inc deleted file mode 100644 index 4c28188..0000000 --- a/extension.inc +++ /dev/null @@ -1 +0,0 @@ - -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 ( 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 538c8ae..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 Wootook. - * - */ - -define('INSIDE' , true); -define('INSTALL' , false); -require_once dirname(__FILE__) .'/application/bootstrap.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/floten3.php b/floten3.php deleted file mode 100644 index 88889a3..0000000 --- a/floten3.php +++ /dev/null @@ -1,502 +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 Wootook. - * - */ - -define('INSIDE' , true); -define('INSTALL' , false); -require_once dirname(__FILE__) .'/application/bootstrap.php'; - -includeLang('fleet'); - -$session = Wootook::getSession('fleet'); - -$user = Wootook_Empire_Model_User::getSingleton(); -$planet = $user->getCurrentPlanet(); - -$galaxy = isset($_POST['galaxy']) ? intval($_POST['galaxy']) : 0; -$system = isset($_POST['system']) ? intval($_POST['system']) : 0; -$position = isset($_POST['planet']) ? intval($_POST['planet']) : 0; -$type = isset($_POST['planettype']) ? intval($_POST['planettype']) : 0; -$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 = $gameConfig['noobprotection']; -$protectiontime = $gameConfig['noobprotectiontime']; -$protectionmulti = $gameConfig['noobprotectionmulti']; - -if ($protectiontime < 1) { - $protectiontime = 9999999999999999; -} - -$fleetArray = $session['fleet']; - -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 $shipId => $count) { - if ($Count > $planet->getElement($shipId)) { - message ("". $lang['fl_fleet_err'] ."", $lang['fl_error'], "fleet." . PHPEXT, 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." . PHPEXT, 2); -} - -if ($planet->getGalaxy() == $galaxy && - $planet->getSystem() == $system && - $planet->getPosition() == $position && - $planet->getType() == $type) { - message ("". $lang['fl_ownpl_err'] ."", $lang['fl_error'], "fleet." . PHPEXT, 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) { - $maxexpde = doquery("SELECT 1 FROM {{table}} WHERE `fleet_owner` = '".$user['id']."' AND `fleet_mission` = '15';", 'fleets'); - $Expedition = $maxexpde->rowCount(); - $maxexpde->closeCursor(); - } - - 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 == (MAX_PLANET_IN_SYSTEM + 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'][7]; - } - } 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 (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 && 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(); -} - -$userPoints = doquery("SELECT total_points FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner`='{$user->getId()}'", 'statpoints', true); -$myGameLevel = $userPoints['total_points']; -if ($destinationUser->getId()) { - $destinationPoints = doquery("SELECT total_points FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '{$destinationUser->getId()}';", 'statpoints', true); - $hisGameLevel = $destinationPoints['total_points']; -} else { - $hisGameLevel = 0; -} - -$vacationMode = $destinationUser['urlaubs_modus']; - -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 ($myGameLevel > ($hisGameLevel * $protectionmulti) && $destinationUser->getId() && - in_array($mission, $protectedMissions) && $hisGameLevel < ($protectiontime * 1000)) { - message("".$lang['fl_noob_mess_n']."", $lang['fl_noob_title'], "fleet." . PHPEXT, 2); - } - - if (($myGameLevel * $protectionmulti) < $hisGameLevel && $destinationUser->getId() && - in_array($mission, $protectedMissions) && $myGameLevel < ($protectiontime * 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()->count(); - -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 = GetGameSpeedFactor(); -$MaxFleetSpeed = min($AllFleetSpeed); - -if (!in_array($speed, $possibleSpeeds)) { - message ("". $lang['fl_cheat_speed'] ."", $lang['fl_error'], "fleet." . PHPEXT, 2); -} - -$error = 0; -$errorlist = ""; -if ($galaxy > MAX_GALAXY_IN_WORLD || $galaxy < 1) { - $error++; - $errorlist .= $lang['fl_limit_galaxy']; -} -if ($system > MAX_SYSTEM_IN_GALAXY || $system < 1) { - $error++; - $errorlist .= $lang['fl_limit_system']; -} -if ($position > (MAX_PLANET_IN_SYSTEM + 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); - -/***************/ - $fleet['start_time'] = $duration + time(); - if ($mission == Legacies_Empire::ID_MISSION_EXPEDITION) { - $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 = $planet['metal']; - $StockCrystal = $planet['cristal']; - $StockDeuterium = $planet['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 ($destination['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_cristal` = '". intval($TransCrystal) ."', "; - $QryInsertFleet .= "`fleet_resource_deuterium` = '". intval($TransDeuterium) ."', "; - $QryInsertFleet .= "`fleet_target_owner` = '". $destination['id_owner'] ."', "; - $QryInsertFleet .= "`start_time` = '". time() ."';"; - doquery( $QryInsertFleet, 'fleets'); - - - $planet["metal"] = $planet["metal"] - $TransMetal; - $planet["cristal"] = $planet["cristal"] - $TransCrystal; - $planet["deuterium"] = $planet["deuterium"] - $TransDeuterium; - $planet["deuterium"] = $planet["deuterium"] - $consumption; - - $QryUpdatePlanet = "UPDATE {{table}} SET "; - $QryUpdatePlanet .= $FleetSubQRY; - $QryUpdatePlanet .= "`metal` = '". $planet["metal"] ."', "; - $QryUpdatePlanet .= "`cristal` = '". $planet["cristal"] ."', "; - $QryUpdatePlanet .= "`deuterium` = '". $planet["deuterium"] ."' "; - $QryUpdatePlanet .= "WHERE "; - $QryUpdatePlanet .= "`id` = '". $planet['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'] ."". $missionTypes[$_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` = '". $planet['id'] ."';", 'planets', true); - - display($page, $lang['fl_title']); diff --git a/frames.php b/frames.php deleted file mode 100644 index f3229ce..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 Wootook. - * - */ - -defined('DEPRECATION') || define('DEPRECATION', false); -defined('DEBUG') || define('DEBUG', false); - -require_once dirname(__FILE__) .'/application/bootstrap.php'; - -Wootook_Core_ErrorProfiler::unregister(true); -?> - - - - - Wootook: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 9266635..0000000 --- a/galaxy.php +++ /dev/null @@ -1,162 +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 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(); - - 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 .= 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/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/databaseinfos.php b/includes/databaseinfos.php deleted file mode 100644 index 4d8ff84..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 Wootook. - * - */ - - $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' , 'Wootook Legacies'), "; - $QryInsertConfig .= "('game_name' , 'Wootook 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 Wootook 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 685dd4b..0000000 --- a/includes/debug.class.php +++ /dev/null @@ -1,156 +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 Wootook. - * - */ - -/** - * 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 - */ - public function error($message, $title) - { - $gameConfig = Legacies_Core_Model_Config::getSingleton(); - - if ($gameConfig['debug'] == 1) { - echo "

    $title


    $message

    "; - echo "".$this->log."
    "; - } - - $user = Legacies_Empire_Model_User::getSingleton(); - - $db = Legacies_Database::getSingleton(); - $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 {$db->getTable('errors')} SET - `error_sender` = {$user->getId()} , - `error_time` = {$db->quote(time())}, - `error_type` = {$db->quote($title)}, - `error_text` = {$db->quote($message)}"; - - $db->query($query); - $id = $db->lastInsertId($db->getTable('errors')); - if (!function_exists('message')) { - echo "Erreur, merci de contacter l'admin. Erreur n�: ".$id.""; - } else { - message("Erreur, merci de contacter l'admin. Erreur n�: ".$id."", "Erreur"); - } - } -} diff --git a/includes/functions/CheckInputStrings.php b/includes/functions/CheckInputStrings.php deleted file mode 100644 index a8041c6..0000000 --- a/includes/functions/CheckInputStrings.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 Wootook. - * - */ - -/** - * - * @deprecated - * @param unknown_type $String - */ -function CheckInputStrings($string) -{ - return htmlspecialchars($string, ENT_QUOTES, 'UTF-8'); -} \ No newline at end of file diff --git a/includes/functions/CreateOneMoonRecord.php b/includes/functions/CreateOneMoonRecord.php deleted file mode 100644 index 1b4bf8b..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 Wootook. - * - */ - -/** - * - * @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 b54c2eb..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 Wootook. - * - */ - -/** - * - * @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 64daccc..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 Wootook. - * - */ - -/** - * - * @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 = $ThePlanets->fetch(PDO::FETCH_ASSOC) ) { - 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 3646e19..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 Wootook. - * - */ - -/** - * - * @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 8ed967c..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 Wootook. - * - */ - -/** - * - * @deprecated - * @param unknown_type $planet - */ -function FlyingFleetHandler($planet) { - global $resource; - - $sql =<<getFleetCollection(Wootook::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 4c1a8b1..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 Wootook. - * - */ - -/** - * - * @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 ffa2056..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 Wootook. - * - */ - -/** - * - * @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 012a1d5..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 Wootook. - * - */ - -/** - * - * @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 8588ce3..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 Wootook. - * - */ - -/** - * - * @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/IsOfficierAccessible.php b/includes/functions/IsOfficierAccessible.php deleted file mode 100644 index 50a4322..0000000 --- a/includes/functions/IsOfficierAccessible.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 Wootook. - * - */ - -/** - * - * @deprecated - * @param unknown_type $CurrentUser - * @param unknown_type $Officier - */ -function IsOfficierAccessible ($CurrentUser, $Officier) { - global $requirements, $resource, $pricelist; - - if (isset($requirements[$Officier])) { - $enabled = true; - foreach($requirements[$Officier] as $ReqOfficier => $OfficierLevel) { - if ($CurrentUser[$resource[$ReqOfficier]] && - $CurrentUser[$resource[$ReqOfficier]] >= $OfficierLevel) { - $enabled = 1; - } else { - return 0; - } - } - } - if ($CurrentUser[$resource[$Officier]] < $pricelist[$Officier]['max'] ) { - return 1; - } else { - return -1; - } -} - -?> \ No newline at end of file diff --git a/includes/functions/IsTechnologieAccessible.php b/includes/functions/IsTechnologieAccessible.php deleted file mode 100644 index f12dc66..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 Wootook. - * - */ - -/** - * - * @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 8a53a69..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 Wootook. - * - */ - -/** - * - * @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 d58dff9..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 Wootook. - * - */ - -/** - * @deprecated - * @param unknown_type $FleetRow - */ -function MissionCaseAttack($FleetRow) -{ - global $lang; - - $pricelist = Wootook_Empire_Model_Game_Prices::getSingleton(); - $resource = Wootook_Empire_Model_Game_FieldsAlias::getSingleton(); - $CombatCaps = Wootook_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 Wootook_Core_Collection(array('planet' => 'planets'), 'Wootook_Empire_Model_Planet'); - $planetCollection - ->where('galaxy=:galaxy') - ->where('system=:system') - ->where('planet=:planet') - ->where('planet_type=:type') - ->limit(1) - ->load(array( - 'galaxy' => $FleetRow['fleet_end_galaxy'], - 'system' => $FleetRow['fleet_end_system'], - 'planet' => $FleetRow['fleet_end_planet'], - 'type' => $FleetRow['fleet_end_type'] - )) - ; - $TargetPlanet = $planetCollection->current(); - - /* - * Update planet resources and constructions - */ - Wootook::dispatchEvent('planet.update', array( - 'planet' => $TargetPlanet - )); - $TargetPlanet->save(); - - $TargetUser = $TargetPlanet->getUser(); - $CurrentUser = Wootook_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 8f85bff..0000000 --- a/includes/functions/MissionCaseColonisation.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 Wootook. - * - */ - -/** - * - * @deprecated - * @param unknown_type $FleetRow - */ -function MissionCaseColonisation ( $FleetRow ) { - global $lang, $resource; - - $statement = doquery ("SELECT count(*) FROM {{table}} WHERE `id_owner` = '". $FleetRow['fleet_owner'] ."' AND `planet_type` = '1'", 'planets'); - $iPlanetCount = $statement->fetch(PDO::FETCH_ASSOC); - if ($FleetRow['fleet_mess'] == 0) { - // Déjà, sommes nous a l'aller ?? - $statement2 = doquery ("SELECT count(*) FROM {{table}} WHERE `galaxy` = '". $FleetRow['fleet_end_galaxy']."' AND `system` = '". $FleetRow['fleet_end_system']."' AND `planet` = '". $FleetRow['fleet_end_planet']."';", 'galaxy'); - $iGalaxyPlace = $statement2->fetch(PDO::FETCH_ASSOC); - $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 c31874b..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 Wootook. - * - */ - -/** - * - * @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 - */ - Wootook::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 63944db..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 Wootook. - * - */ - -/** - * - * @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 89a1e6a..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 Wootook. - * - */ - -/** - * - * @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 = "Wootook : 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 18bf1ef..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 Wootook. - * - */ - -/** - * - * @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 0cbb12d..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 Wootook. - * - */ - -/** - * - * @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 68b38ca..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 Wootook. - * - */ - -/** - * - * @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 b4bc680..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 Wootook. - * - */ - -$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 Wootook!'), -('OverviewExternChat', '0'), -('OverviewExternChatCmd', ''), -('OverviewBanner', '0'), -('OverviewClickBanner', ''), -('ExtCopyFrame', '0'), -('ExtCopyOwner', ''), -('ExtCopyFunct', ''), -('ForumBannerFrame', '0');", -"UPDATE `{{prefix}}config` SET `config_value`='Wootook' WHERE `config_name`='COOKIE_NAME';", -"UPDATE `{{prefix}}config` SET `config_value`='Wootook' 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 dd842e4..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 Wootook. - * - */ - -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 52870b9..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 Wootook. - * - */ - -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/language/it/lang_info.cfg b/language/it/lang_info.cfg deleted file mode 100644 index c0a5e13..0000000 --- a/language/it/lang_info.cfg +++ /dev/null @@ -1,33 +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. - * - */ - - -$langInfos['ENCODING'] = 'UTF-8'; -$langInfos['DIRECTION'] = 'http://www.xnova-ng.org/'; diff --git a/leftmenu.php b/leftmenu.php deleted file mode 100644 index cbed2b5..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 Wootook. - * - */ - -define('INSIDE' , true); -define('INSTALL' , false); -require_once dirname(__FILE__) .'/application/bootstrap.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['WootookRelease'] = 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 Wootook version future -// 1.1 - Modification pour gestion Admin / Game OP / Modo -?> diff --git a/login.php b/login.php deleted file mode 100644 index 87e5b49..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 Wootook. - * - */ - -define('INSIDE', true); -define('INSTALL', false); -define('DISABLE_IDENTITY_CHECK', true); -require_once dirname(__FILE__) . '/application/bootstrap.php'; - -includeLang('login'); - -if (!empty($_POST) && isset($_POST['username']) && isset($_POST['password'])) { - $user = Wootook_Empire_Model_User::login($_POST['username'], $_POST['password'], isset($_POST['rememberme']) && !empty($_POST['rememberme'])); - - $session = Wootook::getSession(Wootook_Empire_Model_User::SESSION_KEY); - if ($user !== null && $user->getId()) { - header("Location: frames.php"); - } else { - header("Location: login.php"); - } - Wootook_Core_ErrorProfiler::unregister(true); - exit(0); -} - -$db = Wootook_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(Wootook_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(Wootook_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(Wootook_Database::FETCH_COLUMN, 0); - -$layout = new Wootook_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/officier.php b/officier.php deleted file mode 100644 index 163ec0a..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 Wootook. - * - */ - -define('INSIDE' , true); -define('INSTALL' , false); -require_once dirname(__FILE__) .'/application/bootstrap.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 Wootook -?> \ No newline at end of file diff --git a/overview.php b/overview.php deleted file mode 100644 index 0fec9c4..0000000 --- a/overview.php +++ /dev/null @@ -1,373 +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 Wootook. - * - */ - -define('INSTALL' , false); -require_once dirname(__FILE__) .'/application/bootstrap.php'; - -$user = Wootook_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 == Wootook::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'])) { - Wootook::getSession('user') - ->addError(Wootook::__('Password was not correct.')); - - header('302 Found'); - header('Location: ' . basename(__FILE__)); - exit(0); - } - - try { - $user->getCurrentPlanet()->destroy(); - - Wootook::getSession('user') - ->addSucces(Wootook::__('Planet has been successfully destroyed.')); - } catch (Wootook_Empire_Model_Planet_Exception $e) { - Wootook::getSession('user') - ->addError($e->getMessage()); - } - - header('302 Found'); - header('Location: ' . basename(__FILE__)); - exit(0); - } - } else { - Wootook::getSession('user') - ->addError(Wootook::__('Invalid security key.')); - } -} else if ($action == 'rename') { - $layout = new Wootook_Core_Layout(); - $layout->load('overview.rename-planet'); - - echo $layout->render(); - exit(0); -} else if ($action == 'destroy') { - $layout = new Wootook_Core_Layout(); - $layout->load('overview.destroy-planet'); - - echo $layout->render(); - exit(0); -} else { - includeLang('resources'); - includeLang('overview'); - - $layout = new Wootook_Core_Layout(); - $layout->load('overview'); - - if ($user->getId()) { - $planetCollection = $user->getPlanetCollection(); - $planetBlock = $layout->createBlock('core/deprecated', 'planet.view'); - $planetBlock->setTemplate('empire/overview/planet/view.phtml'); - - $planetList = $layout->createBlock('core/concat', 'planet.list'); - $planetBlock->planetList = $planetList; - - foreach ($planetCollection as $userPlanet) { - if ($userPlanet->getId() == $planet->getId()) { - continue; - } - - /* - * Update planet resources and constructions - */ - Wootook::dispatchEvent('planet.update', array( - 'planet' => $userPlanet - )); - $userPlanet->save(); - - if ($userPlanet->getId() != $user->getCurrentPlanet()->getId() && $userPlanet->isPlanet()) { - $id = uniqid(); - $block = $layout->createBlock('core/deprecated', "planet.list.item.{$id}"); - $block->setTemplate('empire/overview/planet/list/item.phtml'); - $block['planet'] = $userPlanet; - - $buildingQueue = $userPlanet->getBuildingQueue(); - $buildingQueue->rewind(); - $currentItem = $buildingQueue->current(); - $block['queue_item'] = $currentItem; - - $planetList->$id = $block; - } - } - - /** - * 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 ($planet_start->rowCount() == 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 - */ - Wootook::dispatchEvent('fleet.update', array( - 'user' => $user - )); - - $fleetList = $layout->createBlock('core/concat', 'fleet.list'); - $fleetCollection = $user->getFleetCollection(); - foreach ($fleetCollection as $fleet) { - $id = uniqid(); - $block = $layout->createBlock('core/deprecated', "fleet.list.item.{$id}"); - $block->setTemplate('empire/overview/fleet/item.phtml'); - - $block['class'] = $fleet->getRowClass(); - $block['fleet'] = $fleet; - $block['user'] = $user; - - $fleetList->setPartial($id, $block); - } - - $messageCollection = new Wootook_Core_Collection('messages'); - $messageCollection->where('message_owner=:user'); - $messageCollection->where('message_read_at<=0'); - - $count = $messageCollection->getSize(array('user' => $user->getId())); - $newMessages = $layout->createBlock('core/deprecated', 'overview.messages'); - $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 7876a77..0000000 --- a/reg.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 Wootook. - * - */ - -define('INSIDE', true); -define('INSTALL', false); -define('DISABLE_IDENTITY_CHECK', true); -require_once dirname(__FILE__) .'/application/bootstrap.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 = Wootook::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"); - header("Location: frames.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/skin/base/default/css/legacies.css b/skin/base/default/css/legacies.css deleted file mode 100644 index 1e53e26..0000000 --- a/skin/base/default/css/legacies.css +++ /dev/null @@ -1,39 +0,0 @@ -@CHARSET "UTF-8"; - -.global .content .planet-carrousel {width:950px;height:100px;margin:0 auto;padding:0 30px;color:#000;background:#FFF;border:1px solid #FFF;border-top:none;box-shadow:0 -4px 8px #115566 inset, 20px 20px 40px #115566, -20px 20px 40px #115566, 0 -20px 40px #115566;border-bottom-left-radius:50px;border-bottom-right-radius:50px;} -.global .content .planet-carrousel .items {width:900px;height:100px;overflow:hidden;float:left;} -.global .content .planet-carrousel .arrow {height:40px;width:25px;float:left;font-size:20px;font-weight:bold;margin:30px 0;} -.global .content .planet-carrousel .planet {color:#000;height:100px;width:100px;float:left;} -.global .content .planet-carrousel .planet a {color:#000;} - -.global .content .resources-display {width:770px;height:40px;margin:0 auto 30px;padding:0 50px;color:#000;background:#FFF;box-shadow:0 -4px 6px #115566 inset, 0 20px 40px #115566;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 8px #115566 inset, 20px 20px 40px #115566, -20px 20px 40px #115566, 0 -20px 40px #115566;} -.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;} - -/** - * Galaxy user name display colors - */ -.allymember {color:lime;} -.noob {color:darkgreen;} -.strong {color:darkred;} -.vacation {color:lightblue;} -.inactive {color:grey;} -.longinactive {color:darkgrey;} -.banned {color:red;text-decoration:line-through;} 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 96% rename from admin/ElementQueueFixer.php rename to src/admin/ElementQueueFixer.php index 542b7f9..be19843 100644 --- a/admin/ElementQueueFixer.php +++ b/src/admin/ElementQueueFixer.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/admin/QueryExecute.php b/src/admin/QueryExecute.php similarity index 93% rename from admin/QueryExecute.php rename to src/admin/QueryExecute.php index 6ec9889..9e75ebf 100644 --- a/admin/QueryExecute.php +++ b/src/admin/QueryExecute.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/admin/autounban.php b/src/admin/ShowFlyingFleets.php similarity index 66% rename from admin/autounban.php rename to src/admin/ShowFlyingFleets.php index c5afbe6..c41270d 100644 --- a/admin/autounban.php +++ b/src/admin/ShowFlyingFleets.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -33,16 +33,18 @@ define('INSTALL' , false); define('IN_ADMIN', true); 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 98% rename from admin/XNovaResetUnivers.php rename to src/admin/XNovaResetUnivers.php index e8d1026..e789d4d 100644 --- a/admin/XNovaResetUnivers.php +++ b/src/admin/XNovaResetUnivers.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify 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/admin/add_money.php b/src/admin/add_money.php similarity index 52% rename from admin/add_money.php rename to src/admin/add_money.php index 142acd7..7bca4b4 100644 --- a/admin/add_money.php +++ b/src/admin/add_money.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -33,35 +33,36 @@ define('INSTALL' , false); define('IN_ADMIN', true); require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php'; - if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) { - includeLang('admin'); +$user = Wootook_Player_Model_Session::getSingleton()->getPlayer(); - $mode = $_POST['mode']; +if (!in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) { + message( $lang['sys_noalloaw'], $lang['sys_noaccess'] ); + exit(0); +} - $PageTpl = gettemplate("admin/add_money"); - $parse = $lang; +includeLang('admin'); - if ($mode == 'addit') { - $id = $_POST['id']; - $metal = $_POST['metal']; - $cristal = $_POST['cristal']; - $deut = $_POST['deut']; +$mode = $_POST['mode']; - $QryUpdatePlanet = "UPDATE {{table}} SET "; - $QryUpdatePlanet .= "`metal` = `metal` + '". $metal ."', "; - $QryUpdatePlanet .= "`crystal` = `crystal` + '". $cristal ."', "; - $QryUpdatePlanet .= "`deuterium` = `deuterium` + '". $deut ."' "; - $QryUpdatePlanet .= "WHERE "; - $QryUpdatePlanet .= "`id` = '". $id ."' "; - doquery( $QryUpdatePlanet, "planets"); +$PageTpl = gettemplate("admin/add_money"); +$parse = $lang; - AdminMessage ( $lang['adm_am_done'], $lang['adm_am_ttle'] ); - } - $Page = parsetemplate($PageTpl, $parse); +if ($mode == 'addit') { + $id = $_POST['id']; + $metal = $_POST['metal']; + $cristal = $_POST['cristal']; + $deut = $_POST['deut']; - display ($Page, $lang['adm_am_ttle'], false, '', true); - } else { - AdminMessage ( $lang['sys_noalloaw'], $lang['sys_noaccess'] ); - } + $QryUpdatePlanet = "UPDATE {{table}} SET "; + $QryUpdatePlanet .= "`metal` = `metal` + '". $metal ."', "; + $QryUpdatePlanet .= "`crystal` = `crystal` + '". $cristal ."', "; + $QryUpdatePlanet .= "`deuterium` = `deuterium` + '". $deut ."' "; + $QryUpdatePlanet .= "WHERE "; + $QryUpdatePlanet .= "`id` = '". $id ."' "; + doquery( $QryUpdatePlanet, "planets"); -?> \ No newline at end of file + 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 95% rename from admin/add_moon.php rename to src/admin/add_moon.php index 6607d27..63c2851 100644 --- a/admin/add_moon.php +++ b/src/admin/add_moon.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/admin/ShowFlyingFleets.php b/src/admin/autounban.php similarity index 68% rename from admin/ShowFlyingFleets.php rename to src/admin/autounban.php index 89f1eb1..5d9a6a9 100644 --- a/admin/ShowFlyingFleets.php +++ b/src/admin/autounban.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -33,18 +33,15 @@ 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/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 96% rename from admin/banned.php rename to src/admin/banned.php index f053aa8..89b6f01 100644 --- a/admin/banned.php +++ b/src/admin/banned.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/admin/changelog.php b/src/admin/changelog.php similarity index 93% rename from admin/changelog.php rename to src/admin/changelog.php index 5b63eaa..6ef7ced 100644 --- a/admin/changelog.php +++ b/src/admin/changelog.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/admin/chat.php b/src/admin/chat.php similarity index 95% rename from admin/chat.php rename to src/admin/chat.php index 3618898..b6ca379 100644 --- a/admin/chat.php +++ b/src/admin/chat.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/admin/credit.php b/src/admin/credit.php similarity index 96% rename from admin/credit.php rename to src/admin/credit.php index bccba11..00c282d 100644 --- a/admin/credit.php +++ b/src/admin/credit.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/admin/declare_list.php b/src/admin/declare_list.php similarity index 90% rename from admin/declare_list.php rename to src/admin/declare_list.php index 961bf04..6ecc761 100644 --- a/admin/declare_list.php +++ b/src/admin/declare_list.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -36,7 +36,11 @@ 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/deletuser.php b/src/admin/deletuser.php similarity index 93% rename from admin/deletuser.php rename to src/admin/deletuser.php index 70b9966..370ddcb 100644 --- a/admin/deletuser.php +++ b/src/admin/deletuser.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/admin/errors.php b/src/admin/errors.php similarity index 95% rename from admin/errors.php rename to src/admin/errors.php index c57083c..0ff6a7b 100644 --- a/admin/errors.php +++ b/src/admin/errors.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/admin/leftmenu.php b/src/admin/leftmenu.php similarity index 79% rename from admin/leftmenu.php rename to src/admin/leftmenu.php index 180034a..cce8699 100644 --- a/admin/leftmenu.php +++ b/src/admin/leftmenu.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -36,13 +36,13 @@ 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 = $lang; + $parse['mf'] = "Hauptframe"; + $parse['dpath'] = $dpath; $parse['WootookRelease'] = VERSION; - $parse['servername'] = Wootook; - $Page = parsetemplate(gettemplate('admin/left_menu'), $parse); - display( $Page, "", false, '', true); + $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 94% rename from admin/md5changepass.php rename to src/admin/md5changepass.php index 46c43d5..71bf636 100644 --- a/admin/md5changepass.php +++ b/src/admin/md5changepass.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/admin/md5enc.php b/src/admin/md5enc.php similarity index 94% rename from admin/md5enc.php rename to src/admin/md5enc.php index b4a96b7..ba3c4e5 100644 --- a/admin/md5enc.php +++ b/src/admin/md5enc.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/admin/messagelist.php b/src/admin/messagelist.php similarity index 98% rename from admin/messagelist.php rename to src/admin/messagelist.php index 49c207c..a4c75cf 100644 --- a/admin/messagelist.php +++ b/src/admin/messagelist.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify 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 95% rename from admin/moonlist.php rename to src/admin/moonlist.php index 645d086..932e607 100644 --- a/admin/moonlist.php +++ b/src/admin/moonlist.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/admin/multi.php b/src/admin/multi.php similarity index 94% rename from admin/multi.php rename to src/admin/multi.php index e174971..4b41308 100644 --- a/admin/multi.php +++ b/src/admin/multi.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify 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 98% rename from admin/paneladmina.php rename to src/admin/paneladmina.php index f4097b7..1ea59d8 100644 --- a/admin/paneladmina.php +++ b/src/admin/paneladmina.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/admin/planetlist.php b/src/admin/planetlist.php similarity index 95% rename from admin/planetlist.php rename to src/admin/planetlist.php index 0d3eacc..4a154a5 100644 --- a/admin/planetlist.php +++ b/src/admin/planetlist.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify 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 90% rename from admin/statbuilder.php rename to src/admin/statbuilder.php index 7f02140..97caec7 100644 --- a/admin/statbuilder.php +++ b/src/admin/statbuilder.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -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 90% rename from admin/statfunctions.php rename to src/admin/statfunctions.php index 36cfe93..db1a760 100644 --- a/admin/statfunctions.php +++ b/src/admin/statfunctions.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -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 94% rename from admin/unbanned.php rename to src/admin/unbanned.php index cfc9027..8b0967d 100644 --- a/admin/unbanned.php +++ b/src/admin/unbanned.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/admin/userlist.php b/src/admin/userlist.php similarity index 91% rename from admin/userlist.php rename to src/admin/userlist.php index ecb19df..84fb74f 100644 --- a/admin/userlist.php +++ b/src/admin/userlist.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -36,7 +36,11 @@ 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 93% rename from admin/variables.php rename to src/admin/variables.php index 527af4c..bcc6642 100644 --- a/admin/variables.php +++ b/src/admin/variables.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/alliance.php b/src/alliance.php similarity index 89% rename from alliance.php rename to src/alliance.php index 3c90d3c..6b815fd 100644 --- a/alliance.php +++ b/src/alliance.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -32,8 +32,8 @@ define('INSTALL' , false); define('INSIDE' , true); require_once dirname(__FILE__) .'/application/bootstrap.php'; -$user = Wootook_Empire_Model_User::getSingleton(); -$db = Wootook_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`"; @@ -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 68% rename from annonce.php rename to src/annonce.php index 169ca4d..9c0b506 100644 --- a/annonce.php +++ b/src/annonce.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -31,35 +31,26 @@ define('INSIDE' , true); define('INSTALL' , false); require_once dirname(__FILE__) .'/application/bootstrap.php'; -$users = doquery("SELECT * FROM {{table}} WHERE id='".$user['id']."';", 'users'); -$annonce = doquery("SELECT * FROM {{table}} ", 'annonce'); -$action = $_GET['action']; + +$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 95% rename from annonce2.php rename to src/annonce2.php index 7f90582..29baec1 100644 --- a/annonce2.php +++ b/src/annonce2.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/application/bootstrap.php b/src/application/bootstrap.php similarity index 66% rename from application/bootstrap.php rename to src/application/bootstrap.php index b6eda0d..b0b3c9c 100644 --- a/application/bootstrap.php +++ b/src/application/bootstrap.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -28,9 +28,11 @@ * */ -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); @@ -60,9 +62,9 @@ if (!defined('DEBUG')) { 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,25 +78,36 @@ function __autoload($class) { include_once str_replace('_', '/', $class) . '.php'; } -Wootook_Core_Time::init(); -Wootook_Core_ErrorProfiler::register(); -Wootook_Core_Model_Config_Events::registerEvents(); +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); +} + +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); @@ -102,20 +115,26 @@ include(ROOT_PATH . 'language/' . DEFAULT_LANG . '/lang_info.cfg'); include(ROOT_PATH . 'includes/vars.' . PHPEXT); include(ROOT_PATH . 'includes/strings.' . PHPEXT); -$gameConfig = Wootook_Core_Model_Config::getSingleton(); -if (isset($gameConfig['cookie_name']) && !empty($gameConfig['cookie_name'])) { - Wootook_Empire_Model_User::setCookieName($gameConfig['cookie_name']); -} -$user = Wootook_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); } } @@ -141,4 +160,4 @@ if (($user !== null && $user->getId())) { 'planet' => $planet )); $planet->save(); -} \ No newline at end of file +} diff --git a/application/code/community/.placeholder b/src/application/cache/.placeholder similarity index 100% rename from application/code/community/.placeholder rename to src/application/cache/.placeholder diff --git a/application/code/local/.placeholder b/src/application/code/community/.placeholder similarity index 100% rename from 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 @@ + * All rights reserved. @@ -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 = Wootook_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/application/code/core/Legacies/Empire/Block/Planet/ResearchLab.php b/src/application/code/core/Legacies/Empire/Block/Planet/ResearchLab.php similarity index 92% rename from application/code/core/Legacies/Empire/Block/Planet/ResearchLab.php rename to src/application/code/core/Legacies/Empire/Block/Planet/ResearchLab.php index 841f1a1..1c995b4 100644 --- a/application/code/core/Legacies/Empire/Block/Planet/ResearchLab.php +++ b/src/application/code/core/Legacies/Empire/Block/Planet/ResearchLab.php @@ -3,7 +3,7 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/agpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * * Copyright (c) 2011-Present, Grégory PLANCHAT * All rights reserved. @@ -49,7 +49,7 @@ class Legacies_Empire_Block_Planet_ResearchLab public function getPlanet() { if ($this->_planet === null) { - $this->_planet = Wootook_Empire_Model_User::getSingleton() + $this->_planet = Wootook_Player_Model_Session::getSingleton()->getPlayer() ->getCurrentPlanet() ; } @@ -58,7 +58,7 @@ class Legacies_Empire_Block_Planet_ResearchLab public function _initChildBlocks() { - $types = Wootook_Empire_Model_Game_Types::getSingleton(); + $types = Wootook_Empire_Helper_Config_Types::getSingleton(); /** @var Wootook_Core_Block_Concat $parentBlock */ $parentBlock = $this->getLayout()->getBlock('item-list.items'); diff --git a/application/code/core/Legacies/Empire/Block/Planet/ResearchLab/Item.php b/src/application/code/core/Legacies/Empire/Block/Planet/ResearchLab/Item.php similarity index 96% rename from application/code/core/Legacies/Empire/Block/Planet/ResearchLab/Item.php rename to src/application/code/core/Legacies/Empire/Block/Planet/ResearchLab/Item.php index 4068617..8d5e448 100644 --- a/application/code/core/Legacies/Empire/Block/Planet/ResearchLab/Item.php +++ b/src/application/code/core/Legacies/Empire/Block/Planet/ResearchLab/Item.php @@ -3,7 +3,7 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/agpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * * Copyright (c) 2011-Present, Grégory PLANCHAT * All rights reserved. @@ -27,6 +27,7 @@ * documentation for further information about customizing Wootook. * */ + /** * * Enter description here ... @@ -38,7 +39,7 @@ class Legacies_Empire_Block_Planet_ResearchLab_Item { public function getLevel() { - return $this->getUser()->getElement($this->getItemId()); + return $this->getPlayer()->getElement($this->getItemId()); } public function getResourcesNeeded($level) diff --git a/application/code/core/Legacies/Empire/Block/Planet/ResearchLab/Queue.php b/src/application/code/core/Legacies/Empire/Block/Planet/ResearchLab/Queue.php similarity index 97% rename from application/code/core/Legacies/Empire/Block/Planet/ResearchLab/Queue.php rename to src/application/code/core/Legacies/Empire/Block/Planet/ResearchLab/Queue.php index f69418e..a880688 100644 --- a/application/code/core/Legacies/Empire/Block/Planet/ResearchLab/Queue.php +++ b/src/application/code/core/Legacies/Empire/Block/Planet/ResearchLab/Queue.php @@ -3,7 +3,7 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/agpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * * Copyright (c) 2011-Present, Grégory PLANCHAT * All rights reserved. diff --git a/application/code/core/Legacies/Empire/Block/Planet/ResearchLab/Queue/Item.php b/src/application/code/core/Legacies/Empire/Block/Planet/ResearchLab/Queue/Item.php similarity index 86% rename from application/code/core/Legacies/Empire/Block/Planet/ResearchLab/Queue/Item.php rename to src/application/code/core/Legacies/Empire/Block/Planet/ResearchLab/Queue/Item.php index a95ee9a..a825cfa 100644 --- a/application/code/core/Legacies/Empire/Block/Planet/ResearchLab/Queue/Item.php +++ b/src/application/code/core/Legacies/Empire/Block/Planet/ResearchLab/Queue/Item.php @@ -3,7 +3,7 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/agpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * * Copyright (c) 2011-Present, Grégory PLANCHAT * All rights reserved. @@ -37,11 +37,11 @@ class Legacies_Empire_Block_Planet_ResearchLab_Queue_Item extends Wootook_Empire_Block_Planet_Builder_Queue_ItemAbstract { - protected $_itemIdField = 'research_id'; + protected $_itemIdField = 'technology_id'; public function getLevel() { - return $this->getUser()->getElement($this->getItemId()); + return $this->getPlayer()->getElement($this->getItemId()); } public function getResourcesNeeded($level) @@ -49,11 +49,6 @@ class Legacies_Empire_Block_Planet_ResearchLab_Queue_Item 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()); @@ -64,6 +59,15 @@ class Legacies_Empire_Block_Planet_ResearchLab_Queue_Item 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); @@ -94,4 +98,4 @@ class Legacies_Empire_Block_Planet_ResearchLab_Queue_Item { return $this->getBuildingTime($this->getNextLevel()); } -} \ No newline at end of file +} diff --git a/application/code/core/Legacies/Empire/Block/Planet/Shipyard.php b/src/application/code/core/Legacies/Empire/Block/Planet/Shipyard.php similarity index 91% rename from application/code/core/Legacies/Empire/Block/Planet/Shipyard.php rename to src/application/code/core/Legacies/Empire/Block/Planet/Shipyard.php index f84b8d1..c33a6e4 100644 --- a/application/code/core/Legacies/Empire/Block/Planet/Shipyard.php +++ b/src/application/code/core/Legacies/Empire/Block/Planet/Shipyard.php @@ -3,7 +3,7 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/agpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * * Copyright (c) 2011-Present, Grégory PLANCHAT * All rights reserved. @@ -54,7 +54,7 @@ class Legacies_Empire_Block_Planet_Shipyard public function getPlanet() { if ($this->_planet === null) { - $this->_planet = Wootook_Empire_Model_User::getSingleton() + $this->_planet = Wootook_Player_Model_Session::getSingleton()->getPlayer() ->getCurrentPlanet() ; } @@ -97,7 +97,11 @@ class Legacies_Empire_Block_Planet_Shipyard public function _initChildBlocks() { - $types = Wootook_Empire_Model_Game_Types::getSingleton(); + $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'); @@ -112,4 +116,4 @@ class Legacies_Empire_Block_Planet_Shipyard return $this; } -} \ No newline at end of file +} diff --git a/application/code/core/Legacies/Empire/Block/Planet/Shipyard/Item.php b/src/application/code/core/Legacies/Empire/Block/Planet/Shipyard/Item.php similarity index 95% rename from application/code/core/Legacies/Empire/Block/Planet/Shipyard/Item.php rename to src/application/code/core/Legacies/Empire/Block/Planet/Shipyard/Item.php index e5d9768..0b42ac2 100644 --- a/application/code/core/Legacies/Empire/Block/Planet/Shipyard/Item.php +++ b/src/application/code/core/Legacies/Empire/Block/Planet/Shipyard/Item.php @@ -3,7 +3,7 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/agpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * * Copyright (c) 2011-Present, Grégory PLANCHAT * All rights reserved. @@ -42,6 +42,11 @@ class Legacies_Empire_Block_Planet_Shipyard_Item 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); @@ -77,4 +82,4 @@ class Legacies_Empire_Block_Planet_Shipyard_Item } return $resourceConfig; } -} \ No newline at end of file +} diff --git a/application/code/core/Legacies/Empire/Block/Planet/Shipyard/Queue.php b/src/application/code/core/Legacies/Empire/Block/Planet/Shipyard/Queue.php similarity index 97% rename from application/code/core/Legacies/Empire/Block/Planet/Shipyard/Queue.php rename to src/application/code/core/Legacies/Empire/Block/Planet/Shipyard/Queue.php index 1bcd0c0..ea621fa 100644 --- a/application/code/core/Legacies/Empire/Block/Planet/Shipyard/Queue.php +++ b/src/application/code/core/Legacies/Empire/Block/Planet/Shipyard/Queue.php @@ -3,7 +3,7 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/agpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * * Copyright (c) 2011-Present, Grégory PLANCHAT * All rights reserved. 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/application/code/core/Legacies/Empire/Exception.php b/src/application/code/core/Legacies/Empire/Exception.php similarity index 97% rename from application/code/core/Legacies/Empire/Exception.php rename to src/application/code/core/Legacies/Empire/Exception.php index 70fcf02..6527b43 100644 --- a/application/code/core/Legacies/Empire/Exception.php +++ b/src/application/code/core/Legacies/Empire/Exception.php @@ -3,7 +3,7 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/agpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * * Copyright (c) 2011-Present, Grégory PLANCHAT * All rights reserved. diff --git a/application/code/core/Legacies/Empire/Model/Planet/Building/CristalMine.php b/src/application/code/core/Legacies/Empire/Model/Planet/Building/CristalMine.php similarity index 97% rename from application/code/core/Legacies/Empire/Model/Planet/Building/CristalMine.php rename to src/application/code/core/Legacies/Empire/Model/Planet/Building/CristalMine.php index 2cd8971..ef720df 100644 --- a/application/code/core/Legacies/Empire/Model/Planet/Building/CristalMine.php +++ b/src/application/code/core/Legacies/Empire/Model/Planet/Building/CristalMine.php @@ -3,7 +3,7 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/agpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * * Copyright (c) 2011-Present, Grégory PLANCHAT * All rights reserved. @@ -36,7 +36,7 @@ class Legacies_Empire_Model_Planet_Building_CristalMine implements Wootook_Empire_Model_Planet_ResourceProductionInterface, Wootook_Empire_Model_Planet_BuildingInterface { - public function getProductionRatios($level, $produtionRatio, $planet, $user) + 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), diff --git a/application/code/core/Legacies/Empire/Model/Planet/Building/DeuteriumSynthetiser.php b/src/application/code/core/Legacies/Empire/Model/Planet/Building/DeuteriumSynthetiser.php similarity index 97% rename from application/code/core/Legacies/Empire/Model/Planet/Building/DeuteriumSynthetiser.php rename to src/application/code/core/Legacies/Empire/Model/Planet/Building/DeuteriumSynthetiser.php index 69447dc..5556a4c 100644 --- a/application/code/core/Legacies/Empire/Model/Planet/Building/DeuteriumSynthetiser.php +++ b/src/application/code/core/Legacies/Empire/Model/Planet/Building/DeuteriumSynthetiser.php @@ -3,7 +3,7 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/agpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * * Copyright (c) 2011-Present, Grégory PLANCHAT * All rights reserved. @@ -36,7 +36,7 @@ class Legacies_Empire_Model_Planet_Building_DeuteriumSynthetiser implements Wootook_Empire_Model_Planet_ResourceProductionInterface, Wootook_Empire_Model_Planet_BuildingInterface { - public function getProductionRatios($level, $produtionRatio, $planet, $user) + public function getProductionRatios($level, $produtionRatio, $planet, $player) { return array( Legacies_Empire::RESOURCE_DEUTERIUM => 10 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio), diff --git a/application/code/core/Legacies/Empire/Model/Planet/Building/FusionReactor.php b/src/application/code/core/Legacies/Empire/Model/Planet/Building/FusionReactor.php similarity index 97% rename from application/code/core/Legacies/Empire/Model/Planet/Building/FusionReactor.php rename to src/application/code/core/Legacies/Empire/Model/Planet/Building/FusionReactor.php index 923a6eb..e3d32aa 100644 --- a/application/code/core/Legacies/Empire/Model/Planet/Building/FusionReactor.php +++ b/src/application/code/core/Legacies/Empire/Model/Planet/Building/FusionReactor.php @@ -3,7 +3,7 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/agpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * * Copyright (c) 2011-Present, Grégory PLANCHAT * All rights reserved. @@ -36,7 +36,7 @@ class Legacies_Empire_Model_Planet_Building_FusionReactor implements Wootook_Empire_Model_Planet_ResourceProductionInterface, Wootook_Empire_Model_Planet_BuildingInterface { - public function getProductionRatios($level, $produtionRatio, $planet, $user) + public function getProductionRatios($level, $produtionRatio, $planet, $player) { return array( Legacies_Empire::RESOURCE_DEUTERIUM => -10 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio), diff --git a/application/code/core/Legacies/Empire/Model/Planet/Building/MetalMine.php b/src/application/code/core/Legacies/Empire/Model/Planet/Building/MetalMine.php similarity index 97% rename from application/code/core/Legacies/Empire/Model/Planet/Building/MetalMine.php rename to src/application/code/core/Legacies/Empire/Model/Planet/Building/MetalMine.php index 884a964..e67f459 100644 --- a/application/code/core/Legacies/Empire/Model/Planet/Building/MetalMine.php +++ b/src/application/code/core/Legacies/Empire/Model/Planet/Building/MetalMine.php @@ -3,7 +3,7 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/agpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * * Copyright (c) 2011-Present, Grégory PLANCHAT * All rights reserved. @@ -37,7 +37,7 @@ class Legacies_Empire_Model_Planet_Building_MetalMine implements Wootook_Empire_Model_Planet_ResourceProductionInterface, Wootook_Empire_Model_Planet_BuildingInterface { - public function getProductionRatios($level, $produtionRatio, $planet, $user) + 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), diff --git a/application/code/core/Legacies/Empire/Model/Planet/Building/NaniteFactory.php b/src/application/code/core/Legacies/Empire/Model/Planet/Building/NaniteFactory.php similarity index 76% rename from application/code/core/Legacies/Empire/Model/Planet/Building/NaniteFactory.php rename to src/application/code/core/Legacies/Empire/Model/Planet/Building/NaniteFactory.php index 08554ec..05f1163 100644 --- a/application/code/core/Legacies/Empire/Model/Planet/Building/NaniteFactory.php +++ b/src/application/code/core/Legacies/Empire/Model/Planet/Building/NaniteFactory.php @@ -3,7 +3,7 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/agpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * * Copyright (c) 2011-Present, Grégory PLANCHAT * All rights reserved. @@ -36,17 +36,16 @@ class Legacies_Empire_Model_Planet_Building_NaniteFactory implements Wootook_Empire_Model_Planet_BuildingInterface { - public static function buildingTimeListener($event) + 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'); - if (!$planet->getId() || ($level = $planet->getElement(Legacies_Empire::ID_BUILDING_NANITE_FACTORY)) <= 0) { - return; - } + $level = $planet->getElement(Legacies_Empire::ID_BUILDING_NANITE_FACTORY); - $time = $event->getData('time'); - - $speedFactor = pow(2, $level); - $event->setData('time', $time / $speedFactor); + $event->setData('enhancement', $enhancement * pow(.5, $level)); } -} \ No newline at end of file +} diff --git a/application/code/core/Legacies/Empire/Model/Planet/Building/ResearchLab.php b/src/application/code/core/Legacies/Empire/Model/Planet/Building/ResearchLab.php similarity index 78% rename from application/code/core/Legacies/Empire/Model/Planet/Building/ResearchLab.php rename to src/application/code/core/Legacies/Empire/Model/Planet/Building/ResearchLab.php index 31789d2..6c5ff41 100644 --- a/application/code/core/Legacies/Empire/Model/Planet/Building/ResearchLab.php +++ b/src/application/code/core/Legacies/Empire/Model/Planet/Building/ResearchLab.php @@ -3,7 +3,7 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/agpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * * Copyright (c) 2011-Present, Grégory PLANCHAT * All rights reserved. @@ -38,7 +38,8 @@ * @subpackage Legacies_Empire */ class Legacies_Empire_Model_Planet_Building_ResearchLab - implements Wootook_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,16 +120,14 @@ 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 = Wootook::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 @@ -138,7 +137,7 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab 'time' => &$time, 'laboratory' => $this, 'planet' => $this->_currentPlanet, - 'user' => $this->_currentUser + 'player' => $this->_currentPlayer )); $this->_builder->appendQueue($researchId, $level, $time); @@ -150,7 +149,7 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab 'time' => $time, 'laboratory' => $this, 'planet' => $this->_currentPlanet, - 'user' => $this->_currentUser + 'player' => $this->_currentPlayer )); return $this; @@ -161,10 +160,10 @@ 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 = Wootook::now(); + $time = new Wootook_Core_DateTime(); } // Dispatch event @@ -172,7 +171,7 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab 'time' => &$time, 'laboratory' => $this, 'planet' => $this->_currentPlanet, - 'user' => $this->_currentUser + 'player' => $this->_currentPlayer )); $this->_builder->updateQueue($time); @@ -182,7 +181,7 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab '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 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/application/code/core/Legacies/Empire/Model/Planet/Building/ResearchLab/Item.php b/src/application/code/core/Legacies/Empire/Model/Planet/Building/ResearchLab/Item.php similarity index 97% rename from application/code/core/Legacies/Empire/Model/Planet/Building/ResearchLab/Item.php rename to src/application/code/core/Legacies/Empire/Model/Planet/Building/ResearchLab/Item.php index 557c257..c70a8fa 100644 --- a/application/code/core/Legacies/Empire/Model/Planet/Building/ResearchLab/Item.php +++ b/src/application/code/core/Legacies/Empire/Model/Planet/Building/ResearchLab/Item.php @@ -3,7 +3,7 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/agpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * * Copyright (c) 2011-Present, Grégory PLANCHAT * All rights reserved. diff --git a/application/code/core/Legacies/Empire/Model/Planet/Building/RoboticFactory.php b/src/application/code/core/Legacies/Empire/Model/Planet/Building/RoboticFactory.php similarity index 76% rename from application/code/core/Legacies/Empire/Model/Planet/Building/RoboticFactory.php rename to src/application/code/core/Legacies/Empire/Model/Planet/Building/RoboticFactory.php index 574156b..5e6b3c8 100644 --- a/application/code/core/Legacies/Empire/Model/Planet/Building/RoboticFactory.php +++ b/src/application/code/core/Legacies/Empire/Model/Planet/Building/RoboticFactory.php @@ -3,7 +3,7 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/agpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * * Copyright (c) 2011-Present, Grégory PLANCHAT * All rights reserved. @@ -36,17 +36,16 @@ class Legacies_Empire_Model_Planet_Building_RoboticFactory implements Wootook_Empire_Model_Planet_BuildingInterface { - public static function buildingTimeListener($event) + 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'); - if (!$planet->getId() || ($level = $planet->getElement(Legacies_Empire::ID_BUILDING_ROBOTIC_FACTORY)) <= 0) { - return; - } + $level = $planet->getElement(Legacies_Empire::ID_BUILDING_ROBOTIC_FACTORY); - $time = $event->getData('time'); - - $speedFactor = 1 + $level; - $event->setData('time', $time / $speedFactor); + $event->setData('enhancement', $enhancement * (2 / (1 + $level))); } -} \ No newline at end of file +} diff --git a/application/code/core/Legacies/Empire/Model/Planet/Building/Shipyard.php b/src/application/code/core/Legacies/Empire/Model/Planet/Building/Shipyard.php similarity index 84% rename from application/code/core/Legacies/Empire/Model/Planet/Building/Shipyard.php rename to src/application/code/core/Legacies/Empire/Model/Planet/Building/Shipyard.php index c41bcca..b8c93b9 100644 --- a/application/code/core/Legacies/Empire/Model/Planet/Building/Shipyard.php +++ b/src/application/code/core/Legacies/Empire/Model/Planet/Building/Shipyard.php @@ -3,7 +3,7 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/agpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * * Copyright (c) 2011-Present, Grégory PLANCHAT * All rights reserved. @@ -38,7 +38,8 @@ * @subpackage Legacies_Empire */ class Legacies_Empire_Model_Planet_Building_Shipyard - implements Wootook_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 Wootook::now(); + $this->_builder = new Legacies_Empire_Model_Planet_Building_Shipyard_Builder($currentPlanet, $currentPlayer); } /** @@ -142,10 +132,10 @@ 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 = Wootook::now(); + $time = new Wootook_Core_DateTime(); } // Dispatch event @@ -155,7 +145,7 @@ class Legacies_Empire_Model_Planet_Building_Shipyard 'time' => &$time, 'shipyard' => $this, 'planet' => $this->_currentPlanet, - 'user' => $this->_currentUser + 'player' => $this->_currentPlayer )); $this->_builder->appendQueue($shipId, $qty, $time); @@ -167,7 +157,7 @@ class Legacies_Empire_Model_Planet_Building_Shipyard 'time' => $time, 'shipyard' => $this, 'planet' => $this->_currentPlanet, - 'user' => $this->_currentUser + 'player' => $this->_currentPlayer )); return $this; @@ -178,10 +168,10 @@ 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 = Wootook::now(); + $time = new Wootook_Core_DateTime(); } // Dispatch event @@ -189,7 +179,7 @@ class Legacies_Empire_Model_Planet_Building_Shipyard 'time' => &$time, 'shipyard' => $this, 'planet' => $this->_currentPlanet, - 'user' => $this->_currentUser + 'player' => $this->_currentPlayer )); $this->_builder->updateQueue($time); @@ -199,7 +189,7 @@ class Legacies_Empire_Model_Planet_Building_Shipyard 'time' => $time, 'shipyard' => $this, 'planet' => $this->_currentPlanet, - 'user' => $this->_currentUser + 'player' => $this->_currentPlayer )); return $this; @@ -231,7 +221,7 @@ class Legacies_Empire_Model_Planet_Building_Shipyard '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/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 82% rename from 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 f5a7299..a9bee0b 100644 --- a/application/code/core/Legacies/Empire/Model/Planet/Building/Shipyard/Builder.php +++ b/src/application/code/core/Legacies/Empire/Model/Planet/Building/Shipyard/Builder.php @@ -3,7 +3,7 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/agpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * * Copyright (c) 2011-Present, Grégory PLANCHAT * All rights reserved. @@ -42,6 +42,11 @@ class Legacies_Empire_Model_Planet_Building_Shipyard_Builder */ protected $_maxLength = 0; + /** + * @var float + */ + protected $_speedEnhancement = null; + public function init() { $this->_unserializeQueue($this->_currentPlanet->getData('b_hangar_id')); @@ -61,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']; } @@ -79,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. @@ -88,15 +108,13 @@ class Legacies_Empire_Model_Planet_Building_Shipyard_Builder */ public function checkAvailability($shipId) { - $types = Wootook_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); } /** @@ -108,9 +126,9 @@ class Legacies_Empire_Model_Planet_Building_Shipyard_Builder */ public function getMaximumBuildableElementsCount($shipId) { - $prices = Wootook_Empire_Model_Game_Prices::getSingleton(); - $fields = Wootook_Empire_Model_Game_FieldsAlias::getSingleton(); - $resources = Wootook_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 => $_) { @@ -184,22 +202,20 @@ class Legacies_Empire_Model_Planet_Building_Shipyard_Builder */ public function getBuildingTime($shipId, $qty) { - $prices = Wootook_Empire_Model_Game_Prices::getSingleton(); - $gameConfig = Wootook_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 = 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 )); @@ -213,8 +229,8 @@ class Legacies_Empire_Model_Planet_Building_Shipyard_Builder */ public function getResourcesNeeded($shipId, $qty) { - $prices = Wootook_Empire_Model_Game_Prices::getSingleton(); - $resources = Wootook_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(); @@ -250,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 = Wootook_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'); @@ -271,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; @@ -290,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; @@ -300,7 +316,7 @@ class Legacies_Empire_Model_Planet_Building_Shipyard_Builder return $this; } - $types = Wootook_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; } @@ -325,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) { @@ -334,4 +355,4 @@ class Legacies_Empire_Model_Planet_Building_Shipyard_Builder return $this; } -} \ No newline at end of file +} diff --git a/application/code/core/Legacies/Empire/Model/Planet/Building/Shipyard/Item.php b/src/application/code/core/Legacies/Empire/Model/Planet/Building/Shipyard/Item.php similarity index 97% rename from application/code/core/Legacies/Empire/Model/Planet/Building/Shipyard/Item.php rename to src/application/code/core/Legacies/Empire/Model/Planet/Building/Shipyard/Item.php index 9bc8df3..6dac60d 100644 --- a/application/code/core/Legacies/Empire/Model/Planet/Building/Shipyard/Item.php +++ b/src/application/code/core/Legacies/Empire/Model/Planet/Building/Shipyard/Item.php @@ -3,7 +3,7 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/agpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * * Copyright (c) 2011-Present, Grégory PLANCHAT * All rights reserved. diff --git a/application/code/core/Legacies/Empire/Model/Planet/Building/SolarPlant.php b/src/application/code/core/Legacies/Empire/Model/Planet/Building/SolarPlant.php similarity index 96% rename from application/code/core/Legacies/Empire/Model/Planet/Building/SolarPlant.php rename to src/application/code/core/Legacies/Empire/Model/Planet/Building/SolarPlant.php index 7e57176..e4cab3b 100644 --- a/application/code/core/Legacies/Empire/Model/Planet/Building/SolarPlant.php +++ b/src/application/code/core/Legacies/Empire/Model/Planet/Building/SolarPlant.php @@ -3,7 +3,7 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/agpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * * Copyright (c) 2011-Present, Grégory PLANCHAT * All rights reserved. @@ -31,7 +31,7 @@ class Legacies_Empire_Model_Planet_Building_SolarPlant implements Wootook_Empire_Model_Planet_ResourceProductionInterface, Wootook_Empire_Model_Planet_BuildingInterface { - public function getProductionRatios($level, $produtionRatio, $planet, $user) + public function getProductionRatios($level, $produtionRatio, $planet, $player) { return array( Legacies_Empire::RESOURCE_ENERGY => 20 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio) diff --git a/application/code/core/Legacies/Empire/Model/Planet/Ship/LargeTransport.php b/src/application/code/core/Legacies/Empire/Model/Planet/Ship/LargeTransport.php similarity index 81% rename from application/code/core/Legacies/Empire/Model/Planet/Ship/LargeTransport.php rename to src/application/code/core/Legacies/Empire/Model/Planet/Ship/LargeTransport.php index 6e2c7db..f0d31e4 100644 --- a/application/code/core/Legacies/Empire/Model/Planet/Ship/LargeTransport.php +++ b/src/application/code/core/Legacies/Empire/Model/Planet/Ship/LargeTransport.php @@ -3,7 +3,7 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/agpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * * Copyright (c) 2011-Present, Grégory PLANCHAT * All rights reserved. @@ -39,15 +39,15 @@ class Legacies_Empire_Model_Planet_Ship_LargeTransport { const REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_IMPULSE_DRIVE = 4; - public function getBaseSpeed(Wootook_Empire_Model_User $user) + public function getBaseSpeed(Wootook_Player_Model_Entity $player) { - $prices = Wootook_Empire_Model_Game_Prices::getSingleton(); + $prices = Wootook_Empire_Helper_Config_Prices::getSingleton(); return $prices[Legacies_Empire::ID_SHIP_LARGE_TRANSPORT][Legacies_Empire::SHIPS_CELERITY_PRIMARY]; } - public function getSpeedMultiplier(Wootook_Empire_Model_User $user) + public function getSpeedMultiplier(Wootook_Player_Model_Entity $player) { - return pow(1.1, $user->getElement(Legacies_Empire::ID_RESEARCH_COMBUSTION_DRIVE)); + return pow(1.1, $player->getElement(Legacies_Empire::ID_RESEARCH_COMBUSTION_DRIVE)); } } \ No newline at end of file diff --git a/application/code/core/Legacies/Empire/Model/Planet/Ship/LightTransport.php b/src/application/code/core/Legacies/Empire/Model/Planet/Ship/LightTransport.php similarity index 70% rename from application/code/core/Legacies/Empire/Model/Planet/Ship/LightTransport.php rename to src/application/code/core/Legacies/Empire/Model/Planet/Ship/LightTransport.php index e08f79e..15be57f 100644 --- a/application/code/core/Legacies/Empire/Model/Planet/Ship/LightTransport.php +++ b/src/application/code/core/Legacies/Empire/Model/Planet/Ship/LightTransport.php @@ -3,7 +3,7 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/agpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * * Copyright (c) 2011-Present, Grégory PLANCHAT * All rights reserved. @@ -39,23 +39,23 @@ class Legacies_Empire_Model_Planet_Ship_LightTransport { const REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_IMPULSE_DRIVE = 4; - public function getBaseSpeed(Wootook_Empire_Model_User $user) + public function getBaseSpeed(Wootook_Player_Model_Entity $player) { - $prices = Wootook_Empire_Model_Game_Prices::getSingleton(); + $prices = Wootook_Empire_Helper_Config_Prices::getSingleton(); - if ($user->getElement(Legacies_Empire::ID_RESEARCH_IMPULSE_DRIVE) < self::REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_IMPULSE_DRIVE) { + 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_Empire_Model_User $user) + public function getSpeedMultiplier(Wootook_Player_Model_Entity $player) { - 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)); + 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, $user->getElement(Legacies_Empire::ID_RESEARCH_IMPULSE_DRIVE)); + return pow(1.2, $player->getElement(Legacies_Empire::ID_RESEARCH_IMPULSE_DRIVE)); } } } \ No newline at end of file diff --git a/application/code/core/Legacies/Empire/Model/Planet/Ship/SolarSatellite.php b/src/application/code/core/Legacies/Empire/Model/Planet/Ship/SolarSatellite.php similarity index 83% rename from application/code/core/Legacies/Empire/Model/Planet/Ship/SolarSatellite.php rename to src/application/code/core/Legacies/Empire/Model/Planet/Ship/SolarSatellite.php index 39848de..b6f132c 100644 --- a/application/code/core/Legacies/Empire/Model/Planet/Ship/SolarSatellite.php +++ b/src/application/code/core/Legacies/Empire/Model/Planet/Ship/SolarSatellite.php @@ -3,7 +3,7 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/agpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * * Copyright (c) 2011-Present, Grégory PLANCHAT * All rights reserved. @@ -37,29 +37,29 @@ 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, $user) + 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_Empire_Model_User $user) + public function getBaseSpeed(Wootook_Player_Model_Entity $player) { return 0; } - public function getSpeedMultiplier(Wootook_Empire_Model_User $user) + public function getSpeedMultiplier(Wootook_Player_Model_Entity $player) { return 0; } - public function getActualSpeed(Wootook_Empire_Model_User $user) + public function getActualSpeed(Wootook_Player_Model_Entity $player) { return 0; } - public function getBaseConsumption(Wootook_Empire_Model_User $user) + public function getBaseConsumption(Wootook_Player_Model_Entity $player) { return 0; } diff --git a/application/code/core/Legacies/Empire/Model/Planet/Ship/Supernova.php b/src/application/code/core/Legacies/Empire/Model/Planet/Ship/Supernova.php similarity index 63% rename from application/code/core/Legacies/Empire/Model/Planet/Ship/Supernova.php rename to src/application/code/core/Legacies/Empire/Model/Planet/Ship/Supernova.php index ade59ad..7025166 100644 --- a/application/code/core/Legacies/Empire/Model/Planet/Ship/Supernova.php +++ b/src/application/code/core/Legacies/Empire/Model/Planet/Ship/Supernova.php @@ -3,7 +3,7 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/agpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * * Copyright (c) 2011-Present, Grégory PLANCHAT * All rights reserved. @@ -40,37 +40,37 @@ class Legacies_Empire_Model_Planet_Ship_Supernova const REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_HYPERSPACE_DRIVE = 20; const REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_HYPERSPACE_TECHNOLOGY = 15; - public function getProductionRatios($quantity, $produtionRatio, $planet, $user) + 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_Empire_Model_User $user) + public function getBaseSpeed(Wootook_Player_Model_Entity $player) { - $prices = Wootook_Empire_Model_Game_Prices::getSingleton(); + $prices = Wootook_Empire_Helper_Config_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) { + 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_Empire_Model_User $user) + public function getSpeedMultiplier(Wootook_Player_Model_Entity $player) { - 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)); + 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, $user->getElement(Legacies_Empire::ID_RESEARCH_HYPERSPACE_DRIVE)) * - pow(1.1, $user->getElement(Legacies_Empire::ID_RESEARCH_HYPERSPACE_TECHNOLOGY)); + 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_Empire_Model_User $user) + public function getBaseConsumption(Wootook_Player_Model_Entity $player) { return 0; } 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/application/code/core/Wootook/Core/install/mysql5/install-2011.1.0.php b/src/application/code/core/Legacies/Empire/install/mysql5/install-1.5.0.php similarity index 63% rename from application/code/core/Wootook/Core/install/mysql5/install-2011.1.0.php rename to src/application/code/core/Legacies/Empire/install/mysql5/install-1.5.0.php index 51a956e..ba30531 100644 --- a/application/code/core/Wootook/Core/install/mysql5/install-2011.1.0.php +++ b/src/application/code/core/Legacies/Empire/install/mysql5/install-1.5.0.php @@ -2,48 +2,36 @@ /** * This file is part of Wootook * - * @license Modified BSD - * @see https://github.com/gplanchat/one.platform + * @license http://www.gnu.org/licenses/agpl-3.0.txt + * @see http://wootook.org/ * - * Copyright (c) 2009-2010, Grégory PLANCHAT + * 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', 'Wootook: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 Wootook 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/application/code/core/Wootook/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 application/code/core/Wootook/Core/install/mysql5/uninstall-2011.1.0.php rename to src/application/code/core/Legacies/Empire/install/mysql5/uninstall-1.5.0.php index 74ec834..040f676 100644 --- a/application/code/core/Wootook/Core/install/mysql5/uninstall-2011.1.0.php +++ b/src/application/code/core/Legacies/Empire/install/mysql5/uninstall-1.5.0.php @@ -40,124 +40,112 @@ * */ -$this->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/application/code/core/Legacies/Exception.php b/src/application/code/core/Legacies/Exception.php similarity index 97% rename from application/code/core/Legacies/Exception.php rename to src/application/code/core/Legacies/Exception.php index 95d7b9a..a86c60b 100644 --- a/application/code/core/Legacies/Exception.php +++ b/src/application/code/core/Legacies/Exception.php @@ -3,7 +3,7 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/agpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * * Copyright (c) 2011-Present, Grégory PLANCHAT * All rights reserved. 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/application/code/core/Wootook/Core/Block/Concat.php b/src/application/code/core/Wootook/Core/Block/Concat.php similarity index 85% rename from application/code/core/Wootook/Core/Block/Concat.php rename to src/application/code/core/Wootook/Core/Block/Concat.php index 5c9afc5..cb8dc89 100644 --- a/application/code/core/Wootook/Core/Block/Concat.php +++ b/src/application/code/core/Wootook/Core/Block/Concat.php @@ -1,7 +1,7 @@ _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/application/code/core/Wootook/Core/Block/Html/Navigation/Node.php b/src/application/code/core/Wootook/Core/Block/Html/Navigation/Node.php similarity index 100% rename from application/code/core/Wootook/Core/Block/Html/Navigation/Node.php rename to src/application/code/core/Wootook/Core/Block/Html/Navigation/Node.php diff --git a/application/code/core/Wootook/Core/Block/Html/Page.php b/src/application/code/core/Wootook/Core/Block/Html/Page.php similarity index 99% rename from application/code/core/Wootook/Core/Block/Html/Page.php rename to src/application/code/core/Wootook/Core/Block/Html/Page.php index b2879f8..12c7775 100644 --- a/application/code/core/Wootook/Core/Block/Html/Page.php +++ b/src/application/code/core/Wootook/Core/Block/Html/Page.php @@ -16,4 +16,4 @@ class Wootook_Core_Block_Html_Page return $this; } -} \ No newline at end of file +} diff --git a/src/application/code/core/Wootook/Core/Block/Messages.php b/src/application/code/core/Wootook/Core/Block/Messages.php new file mode 100644 index 0000000..5aa7cb4 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Block/Messages.php @@ -0,0 +1,47 @@ +_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/application/code/core/Wootook/Core/Block/Text.php b/src/application/code/core/Wootook/Core/Block/Text.php similarity index 91% rename from application/code/core/Wootook/Core/Block/Text.php rename to src/application/code/core/Wootook/Core/Block/Text.php index 129df11..dabe336 100644 --- a/application/code/core/Wootook/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/application/code/core/Legacies/Officers/Exception.php b/src/application/code/core/Wootook/Core/Event.php similarity index 93% rename from application/code/core/Legacies/Officers/Exception.php rename to src/application/code/core/Wootook/Core/Event.php index a389e3b..42b4de7 100644 --- a/application/code/core/Legacies/Officers/Exception.php +++ b/src/application/code/core/Wootook/Core/Event.php @@ -3,7 +3,7 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/agpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * * Copyright (c) 2011-Present, Grégory PLANCHAT * All rights reserved. @@ -27,11 +27,14 @@ * documentation for further information about customizing Wootook. * */ + /** * * Enter description here ... * @author Greg * */ - -interface Legacies_Officers_Exception {} \ No newline at end of file +class Wootook_Core_Event + extends Wootook_Object +{ +} \ No newline at end of file diff --git a/application/code/core/Wootook/Core/Event/Break.php b/src/application/code/core/Wootook/Core/Event/Break.php similarity index 100% rename from application/code/core/Wootook/Core/Event/Break.php rename to src/application/code/core/Wootook/Core/Event/Break.php diff --git a/src/application/code/core/Wootook/Core/Exception.php b/src/application/code/core/Wootook/Core/Exception.php new file mode 100644 index 0000000..7a9030d --- /dev/null +++ b/src/application/code/core/Wootook/Core/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_Core_Exception extends Wootook_Exception {} \ No newline at end of file diff --git a/application/code/core/Wootook/Core/Exception/DataAccessException.php b/src/application/code/core/Wootook/Core/Exception/DataAccessException.php similarity index 100% rename from application/code/core/Wootook/Core/Exception/DataAccessException.php rename to src/application/code/core/Wootook/Core/Exception/DataAccessException.php diff --git a/src/application/code/core/Wootook/Core/Exception/Database/AdapterError.php b/src/application/code/core/Wootook/Core/Exception/Database/AdapterError.php new file mode 100644 index 0000000..a399398 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Exception/Database/AdapterError.php @@ -0,0 +1,20 @@ +_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/application/code/core/Wootook/Core/Model/Config/Abstract.php b/src/application/code/core/Wootook/Core/Helper/Config/ConfigHandler.php similarity index 56% rename from application/code/core/Wootook/Core/Model/Config/Abstract.php rename to src/application/code/core/Wootook/Core/Helper/Config/ConfigHandler.php index 05227d1..7421bad 100644 --- a/application/code/core/Wootook/Core/Model/Config/Abstract.php +++ b/src/application/code/core/Wootook/Core/Helper/Config/ConfigHandler.php @@ -1,17 +1,24 @@ '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); @@ -49,4 +56,4 @@ abstract class Wootook_Core_Model_Config_Abstract { reset($this->_data); } -} \ No newline at end of file +} diff --git a/application/code/core/Wootook/Core/Model/Config/Events.php b/src/application/code/core/Wootook/Core/Helper/Config/Events.php similarity index 91% rename from application/code/core/Wootook/Core/Model/Config/Events.php rename to src/application/code/core/Wootook/Core/Helper/Config/Events.php index 1ab794b..30b0528 100644 --- a/application/code/core/Wootook/Core/Model/Config/Events.php +++ b/src/application/code/core/Wootook/Core/Helper/Config/Events.php @@ -7,8 +7,8 @@ * @uses Wootook_Object * @uses Legacies_Empire */ -class Wootook_Core_Model_Config_Events - extends Wootook_Core_Model_Config_Abstract +class Wootook_Core_Helper_Config_Events + extends Wootook_Core_Helper_Config_ConfigHandler implements Wootook_Core_Singleton { private static $_singleton = null; diff --git a/application/code/core/Wootook/Core/Model/Config/Modules.php b/src/application/code/core/Wootook/Core/Helper/Config/Modules.php similarity index 88% rename from application/code/core/Wootook/Core/Model/Config/Modules.php rename to src/application/code/core/Wootook/Core/Helper/Config/Modules.php index 8ad43f6..17d1a46 100644 --- a/application/code/core/Wootook/Core/Model/Config/Modules.php +++ b/src/application/code/core/Wootook/Core/Helper/Config/Modules.php @@ -7,8 +7,8 @@ * @uses Wootook_Object * @uses Legacies_Empire */ -class Wootook_Core_Model_Config_Modules - extends Wootook_Core_Model_Config_Abstract +class Wootook_Core_Helper_Config_Modules + extends Wootook_Core_Helper_Config_ConfigHandler implements Wootook_Core_Singleton { private static $_singleton = null; 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 80bf0d9..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 Wootook. - * - */ - -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 = << 'Wootook: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/application/code/core/Wootook/Core/Model/Translator.php b/src/application/code/core/Wootook/Core/Model/Translator.php similarity index 100% rename from application/code/core/Wootook/Core/Model/Translator.php rename to src/application/code/core/Wootook/Core/Model/Translator.php diff --git a/src/application/code/core/Wootook/Core/Model/Website.php b/src/application/code/core/Wootook/Core/Model/Website.php new file mode 100644 index 0000000..018edac --- /dev/null +++ b/src/application/code/core/Wootook/Core/Model/Website.php @@ -0,0 +1,23 @@ +_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/application/code/core/Wootook/Core/Controller/Response/Http.php b/src/application/code/core/Wootook/Core/Mvc/Controller/Response/Http.php similarity index 73% rename from application/code/core/Wootook/Core/Controller/Response/Http.php rename to src/application/code/core/Wootook/Core/Mvc/Controller/Response/Http.php index d463fa5..3025249 100644 --- a/application/code/core/Wootook/Core/Controller/Response/Http.php +++ b/src/application/code/core/Wootook/Core/Mvc/Controller/Response/Http.php @@ -1,24 +1,23 @@ 'Moved Permanently', - REDIRECT_FOUND => 'Found', - REDIRECT_SEE_OTHER => 'See Other', - REDIRECT_TEMPORARY => 'Temporary Redirect' + self::REDIRECT_MOVED_PERMANENTLY => 'Moved Permanently', + self::REDIRECT_FOUND => 'Found', + self::REDIRECT_SEE_OTHER => 'See Other', + self::REDIRECT_TEMPORARY => 'Temporary Redirect' ); - public function __construct() - { - parent::__construct(array()); - } + protected $_returnCode = self::STATUS_OK; public function setBody($data) { @@ -46,6 +45,9 @@ class Wootook_Core_Controller_Response_Http public function sendBody() { + if (!isset($this->_data['body']) || empty($this->_data['body'])) { + return ''; + } return implode('', $this->_data['body']); } @@ -81,7 +83,7 @@ class Wootook_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(); @@ -108,22 +110,9 @@ class Wootook_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) @@ -138,7 +127,10 @@ class Wootook_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; } @@ -148,11 +140,22 @@ class Wootook_Core_Controller_Response_Http $code = self::REDIRECT_FOUND; } + $this->_returnCode = $code; + $statusText = self::$_redirectCodes[$code]; $this->setRawHeader("HTTP/1.1 {$code} {$statusText}") - ->setHeader('Location', $url) - ->setIsRedirect(true); + ->setHeader('Location', $url); return $this; } -} \ No newline at end of file + + 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/application/code/core/Wootook/Core/Entity/SubTable.php b/src/application/code/core/Wootook/Core/Mvc/Model/Entity/SubTable.php similarity index 75% rename from application/code/core/Wootook/Core/Entity/SubTable.php rename to src/application/code/core/Wootook/Core/Mvc/Model/Entity/SubTable.php index 470b89c..791d481 100644 --- a/application/code/core/Wootook/Core/Entity/SubTable.php +++ b/src/application/code/core/Wootook/Core/Mvc/Model/Entity/SubTable.php @@ -4,13 +4,12 @@ * * @uses Wootook_Object * @uses Legacies_Empire - * @uses Wootook_Empire_Model_User + * @uses Wootook_Player_Model_Entity */ -abstract class Wootook_Core_Entity_SubTable - extends Wootook_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 Wootook_Core_Entity_SubTable $idFields = '(' . implode(') AND (', $idFields) . ')'; $fields = implode(', ', $fields); - $database = Wootook_Database::getSingleton(); + $database = $this->getWriteConnection(); $sql =<<getTable(self::getTableName())} SET {$fields} @@ -51,7 +50,7 @@ SQL_EOF; } $tokens = implode(', ', $tokens); - $database = Wootook_Database::getSingleton(); + $database = $this->getWriteConnection(); $sql =<<getTable(self::getTableName())} ($fields) VALUES ({$tokens}) @@ -66,20 +65,18 @@ SQL_EOF; protected function _load() { $idValues = func_get_arg(0); - $database = Wootook_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); @@ -87,7 +84,9 @@ SQL_EOF; 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 = Wootook_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/application/code/core/Wootook/Core/Model.php b/src/application/code/core/Wootook/Core/Mvc/Model/Model.php similarity index 71% rename from application/code/core/Wootook/Core/Model.php rename to src/application/code/core/Wootook/Core/Mvc/Model/Model.php index 087f511..e91265f 100644 --- a/application/code/core/Wootook/Core/Model.php +++ b/src/application/code/core/Wootook/Core/Mvc/Model/Model.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. + * + */ -abstract class Wootook_Core_Model +/** + * + * Enter description here ... + * @author Greg + * + */ +abstract class Wootook_Core_Mvc_Model_Model extends Wootook_Object { protected $_originalData = array(); @@ -13,14 +47,27 @@ abstract class Wootook_Core_Model $this->_data = $data; $this->_init(); - $this->_setOriginalData($this->_data); + $this->_setOriginalData(); } abstract protected function _init(); - protected function _setOriginalData(Array $data) + protected function _setOriginalData() { - $this->_originalData = $data; + $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() @@ -70,7 +117,7 @@ abstract class Wootook_Core_Model 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); + throw new Wootook_Core_Exception_DataAccessException('Could not load data: ' . $e->getMessage(), 0, $e); } return $this; } @@ -155,4 +202,4 @@ abstract class Wootook_Core_Model { return $this->hasData($key); } -} \ No newline at end of file +} diff --git a/application/code/core/Wootook/Core/View.php b/src/application/code/core/Wootook/Core/Mvc/View/View.php similarity index 56% rename from application/code/core/Wootook/Core/View.php rename to src/application/code/core/Wootook/Core/Mvc/View/View.php index e7b0cc6..4847061 100644 --- a/application/code/core/Wootook/Core/View.php +++ b/src/application/code/core/Wootook/Core/Mvc/View/View.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 Wootook_Core_View +/** + * + * Enter description here ... + * @author Greg + * + */ +class Wootook_Core_Mvc_View_View extends Wootook_Object { protected $_template = null; @@ -56,11 +90,27 @@ class Wootook_Core_View } } - protected function escape($unescaped) + 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(); @@ -93,6 +143,14 @@ class Wootook_Core_View 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; @@ -124,25 +182,58 @@ class Wootook_Core_View return Wootook::getUrl($uri, $params); } - public function getSkinUrl($uri, Array $params = array()) + public function getStaticUrl($uri, Array $params = array()) { - $package = $this->getLayout()->getPackage(); - if (empty($package)) { - $package = Wootook_Core_Layout::DEFAULT_PACKAGE; - } + return Wootook::getStaticUrl($uri, $params); + } - $user = Wootook_Empire_Model_User::getSingleton(); - if ($user !== null && $user->getId()) { - $theme = $user->getSkinPath(); + 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 (empty($theme)) { + if ($theme === null || empty($theme)) { $theme = $this->getLayout()->getTheme(); } - if (empty($theme)) { - $theme = Wootook_Core_Layout::DEFAULT_THEME; + if ($theme === null || empty($theme)) { + $theme = Wootook_Core_Model_Layout::DEFAULT_THEME; } - return Wootook::getSkinUrl($package, $theme, $uri, $params); + 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) @@ -158,6 +249,9 @@ class Wootook_Core_View public function getPartial($name) { + if (!$this->hasPartial($name)) { + return null; + } return $this->_partials[$name]; } @@ -211,7 +305,7 @@ class Wootook_Core_View /** * - * @return Wootook_Core_Layout + * @return Wootook_Core_Model_Layout */ public function getLayout() { @@ -249,4 +343,4 @@ class Wootook_Core_View { return $this->_scriptPath; } -} \ No newline at end of file +} diff --git a/application/code/core/Wootook/Core/Plugin/LoaderAbstract.php b/src/application/code/core/Wootook/Core/PluginLoader/PluginLoader.php similarity index 64% rename from application/code/core/Wootook/Core/Plugin/LoaderAbstract.php rename to src/application/code/core/Wootook/Core/PluginLoader/PluginLoader.php index 211f572..eaaff7a 100644 --- a/application/code/core/Wootook/Core/Plugin/LoaderAbstract.php +++ b/src/application/code/core/Wootook/Core/PluginLoader/PluginLoader.php @@ -1,21 +1,25 @@ _pluginInstances[$pluginName])) { return $this->_pluginInstances[$pluginName]; } - foreach ($this->_namespaces as $namespace => $path) { - $className = $namespace . ucfirst($pluginName); - $fileName = $path . DIRECTORY_SEPARATOR . ucfirst($pluginName) . '.php'; + $pluginName = str_replace(' ', '_', ucwords(str_replace('.', ' ', $pluginName))); + $pluginName = str_replace(' ', '', ucwords(str_replace('-', ' ', $pluginName))); - if (!file_exists($fileName)) { + foreach ($this->_namespaces as $namespace => $path) { + $className = $namespace . $pluginName; + $fileName = $path . DIRECTORY_SEPARATOR . + str_replace('_', DIRECTORY_SEPARATOR, $pluginName) . '.php'; + + if (!Wootook::fileExists($fileName)) { continue; } @@ -23,10 +27,10 @@ abstract class Wootook_Core_Plugin_LoaderAbstract continue; } - return $this->_load($className, $useSingleton); + return $this->_load($className, $useSingleton, $constructorParams); } - return $this; + return null; } public function registerNamespace($namespace, $path = null) @@ -48,7 +52,7 @@ abstract class Wootook_Core_Plugin_LoaderAbstract return $this; } - abstract protected function _load($className); + abstract protected function _load($className, $useSingleton, Array $constructorParams = array()); public function getPlugin($pluginName) { 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/application/code/core/Wootook/Core/Setup/Updater/ScriptQueue.php b/src/application/code/core/Wootook/Core/Setup/Updater/ScriptQueue.php similarity index 89% rename from application/code/core/Wootook/Core/Setup/Updater/ScriptQueue.php rename to src/application/code/core/Wootook/Core/Setup/Updater/ScriptQueue.php index ff6e309..e0ce1d5 100644 --- a/application/code/core/Wootook/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 Wootook_Core_Setup_Model_Updater_ScriptQueue } if ($fromVersion === null) { - $fromVersion = '0.0.0'; + $fromVersion = array( + 'version' => self::VERSION_NULL, + 'stage' => self::STAGE_STABLE, + 'level' => 0, + ); + } else { + preg_match(self::PCRE_VERSION_PATTERN, $fromVersion, $matches); + $fromVersion = array( + 'version' => isset($matches['version']) ? $matches['version'] : self::VERSION_NULL, + 'stage' => isset($matches['stage']) && !empty($matches['stage']) ? $matches['stage'] : self::STAGE_STABLE, + 'level' => isset($matches['level']) && !empty($matches['level']) ? (int) $matches['level'] : 0, + ); } if ($toVersion === null) { - $toVersion = '0.0.0'; + $toVersion = array( + 'version' => self::VERSION_NULL, + 'stage' => self::STAGE_STABLE, + 'level' => 0, + ); + } else { + preg_match(self::PCRE_VERSION_PATTERN, $toVersion, $matches); + $toVersion = array( + 'version' => isset($matches['version']) ? $matches['version'] : self::VERSION_NULL, + 'stage' => isset($matches['stage']) && !empty($matches['stage']) ? $matches['stage'] : self::STAGE_STABLE, + 'level' => isset($matches['level']) && !empty($matches['level']) ? (int) $matches['level'] : 0, + ); } - preg_match(self::PCRE_VERSION_PATTERN, $fromVersion, $matches); - $fromVersion = array( - 'version' => isset($matches['version']) ? $matches['version'] : self::VERSION_NULL, - 'stage' => isset($matches['stage']) && !empty($matches['stage']) ? $matches['stage'] : self::STAGE_STABLE, - 'level' => isset($matches['level']) && !empty($matches['level']) ? (int) $matches['level'] : 0, - ); - - preg_match(self::PCRE_VERSION_PATTERN, $toVersion, $matches); - $toVersion = array( - 'version' => isset($matches['version']) ? $matches['version'] : self::VERSION_NULL, - 'stage' => isset($matches['stage']) && !empty($matches['stage']) ? $matches['stage'] : self::STAGE_STABLE, - 'level' => isset($matches['level']) && !empty($matches['level']) ? (int) $matches['level'] : 0, - ); - switch (version_compare($toVersion['version'], $fromVersion['version'])) { case 1: $this->_upgradeToVersion($fromVersion, $toVersion); @@ -110,7 +118,7 @@ class Wootook_Core_Setup_Model_Updater_ScriptQueue $this->_upgradeToVersion($fromVersion, $toVersion); } } else { - throw new Wootook_Core_Exception_RuntimeException("Invalid version stage."); + throw new Wootook_Core_Setup_Exception_VersionStageError("Invalid version stage."); } break; } @@ -123,6 +131,13 @@ class Wootook_Core_Setup_Model_Updater_ScriptQueue return $this->_finalVersion; } + public function getCurrentVersion() + { + $current = $this->current(); + + return $current['version']; + } + protected function _installHighestInstaller($currentVersion, $toVersion) { $highestVersion = self::VERSION_NULL; @@ -143,14 +158,16 @@ class Wootook_Core_Setup_Model_Updater_ScriptQueue return $version; } - if (isset($this->_installVersions[$highestVersion][self::STAGE_RC])) { + if (isset($this->_installVersions[$highestVersion][self::STAGE_STABLE])) { + $stage = self::STAGE_STABLE; + } else if (isset($this->_installVersions[$highestVersion][self::STAGE_RC])) { $stage = self::STAGE_RC; } else if (isset($this->_installVersions[$highestVersion][self::STAGE_BETA])) { $stage = self::STAGE_BETA; } else if (isset($this->_installVersions[$highestVersion][self::STAGE_ALPHA])) { $stage = self::STAGE_ALPHA; } else { - throw new Wootook_Core_Exception_RuntimeException("Invalid version stage."); + throw new Wootook_Core_Setup_Exception_VersionStageError("Invalid version stage."); } $levelList = array_keys($this->_installVersions[$highestVersion][$stage]); @@ -232,7 +249,7 @@ class Wootook_Core_Setup_Model_Updater_ScriptQueue $level = max(array_keys($versionPointer[$highestVersion][$stage])); } else { - throw new Wootook_Core_Exception_RuntimeException("Invalid version value."); + throw new Wootook_Core_Setup_Exception_VersionValueError("Invalid version value."); } $currentVersion = array( diff --git a/src/application/code/core/Wootook/Core/Singleton.php b/src/application/code/core/Wootook/Core/Singleton.php new file mode 100644 index 0000000..c136e82 --- /dev/null +++ b/src/application/code/core/Wootook/Core/Singleton.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 + * + */ +interface Wootook_Core_Singleton +{ + 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/application/code/core/Wootook/Empire/Block/Overview/DestroyPlanet.php b/src/application/code/core/Wootook/Empire/Block/Overview/DestroyPlanet.php similarity index 100% rename from application/code/core/Wootook/Empire/Block/Overview/DestroyPlanet.php rename to src/application/code/core/Wootook/Empire/Block/Overview/DestroyPlanet.php diff --git a/src/application/code/core/Wootook/Empire/Block/Overview/Fleet/List.php b/src/application/code/core/Wootook/Empire/Block/Overview/Fleet/List.php new file mode 100644 index 0000000..770fcbb --- /dev/null +++ b/src/application/code/core/Wootook/Empire/Block/Overview/Fleet/List.php @@ -0,0 +1,77 @@ +_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/application/code/core/Wootook/Empire/Block/Overview/RenamePlanet.php b/src/application/code/core/Wootook/Empire/Block/Overview/RenamePlanet.php similarity index 100% rename from application/code/core/Wootook/Empire/Block/Overview/RenamePlanet.php rename to src/application/code/core/Wootook/Empire/Block/Overview/RenamePlanet.php diff --git a/application/code/core/Wootook/Empire/Block/Planet/Builder/ItemAbstract.php b/src/application/code/core/Wootook/Empire/Block/Planet/Builder/ItemAbstract.php similarity index 52% rename from application/code/core/Wootook/Empire/Block/Planet/Builder/ItemAbstract.php rename to src/application/code/core/Wootook/Empire/Block/Planet/Builder/ItemAbstract.php index b936a71..dfffacd 100644 --- a/application/code/core/Wootook/Empire/Block/Planet/Builder/ItemAbstract.php +++ b/src/application/code/core/Wootook/Empire/Block/Planet/Builder/ItemAbstract.php @@ -3,24 +3,31 @@ abstract class Wootook_Empire_Block_Planet_Builder_ItemAbstract extends Wootook_Core_Block_Template { - protected $_user = null; + protected $_player = null; protected $_planet = null; protected $_itemId = null; - public function setUser(Wootook_Empire_Model_User $user) + protected $_labels = null; + + public function __construct() { - $this->_user = $user; + $this->_labels = Wootook_Empire_Helper_Config_Labels::getSingleton(); + } + + public function setPlayer(Wootook_Player_Model_Entity $player) + { + $this->_player = $player; return $this; } - public function getUser() + public function getPlayer() { - if ($this->_user === null) { - $this->_user = Wootook_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(Wootook_Empire_Model_Planet $planet) @@ -33,7 +40,7 @@ abstract class Wootook_Empire_Block_Planet_Builder_ItemAbstract public function getPlanet() { if ($this->_planet === null) { - $this->_planet = $this->getUser()->getCurrentPlanet(); + $this->_planet = $this->getPlayer()->getCurrentPlanet(); } return $this->_planet; @@ -53,41 +60,27 @@ abstract class Wootook_Empire_Block_Planet_Builder_ItemAbstract public function getItemInfoUrl() { - return $this->getUrl('infos.php', array('gid' => $this->getItemId())); + return $this->getStaticUrl('infos.php', array('gid' => $this->getItemId())); + } + + public function getLabel($type) + { + return $this->_labels[$this->getItemId()][$type]; } public function getItemImageUrl() { - // TODO : Upgrade theme - return $this->getSkinUrl('graphics/gebaeude/' . $this->getItemId() . '.gif'); + return $this->getStaticUrl($this->getLabel('image')); } 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 ''; + return $this->getLabel('name'); } 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 ''; + return $this->getLabel('description'); } public function getResourceName($resourceId) @@ -98,7 +91,7 @@ abstract class Wootook_Empire_Block_Planet_Builder_ItemAbstract $lang = includeLang('imperium'); } if ($resourceId == 'cristal') { - $resourceId = 'crystal'; + $resourceId = 'crystal'; // FIXME: backward compatibility } if (isset($lang[$resourceId])) { @@ -115,4 +108,4 @@ abstract class Wootook_Empire_Block_Planet_Builder_ItemAbstract abstract public function getResourcesNeeded($level); abstract public function getBuildingTime($level); -} \ No newline at end of file +} diff --git a/application/code/core/Wootook/Empire/Block/Planet/Builder/Queue/ItemAbstract.php b/src/application/code/core/Wootook/Empire/Block/Planet/Builder/Queue/ItemAbstract.php similarity index 100% rename from application/code/core/Wootook/Empire/Block/Planet/Builder/Queue/ItemAbstract.php rename to src/application/code/core/Wootook/Empire/Block/Planet/Builder/Queue/ItemAbstract.php diff --git a/application/code/core/Wootook/Empire/Block/Planet/Builder/QueueAbstract.php b/src/application/code/core/Wootook/Empire/Block/Planet/Builder/QueueAbstract.php similarity index 82% rename from application/code/core/Wootook/Empire/Block/Planet/Builder/QueueAbstract.php rename to src/application/code/core/Wootook/Empire/Block/Planet/Builder/QueueAbstract.php index d6122d3..baf9c71 100644 --- a/application/code/core/Wootook/Empire/Block/Planet/Builder/QueueAbstract.php +++ b/src/application/code/core/Wootook/Empire/Block/Planet/Builder/QueueAbstract.php @@ -3,25 +3,25 @@ abstract class Wootook_Empire_Block_Planet_Builder_QueueAbstract extends Wootook_Core_Block_Template { - protected $_user = null; + protected $_player = null; protected $_planet = null; protected $_itemTemplate = null; protected $_itemBlock = null; - public function setUser(Wootook_Empire_Model_User $user) + public function setPlayer(Wootook_Player_Model_Entity $player) { - $this->_user = $user; + $this->_player = $player; return $this; } - public function getUser() + public function getPlayer() { - if ($this->_user === null) { - $this->_user = Wootook_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(Wootook_Empire_Model_Planet $planet) @@ -34,7 +34,7 @@ abstract class Wootook_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; diff --git a/application/code/core/Wootook/Empire/Block/Planet/BuilderAbstract.php b/src/application/code/core/Wootook/Empire/Block/Planet/BuilderAbstract.php similarity index 100% rename from application/code/core/Wootook/Empire/Block/Planet/BuilderAbstract.php rename to src/application/code/core/Wootook/Empire/Block/Planet/BuilderAbstract.php diff --git a/application/code/core/Wootook/Empire/Block/Planet/Buildings.php b/src/application/code/core/Wootook/Empire/Block/Planet/Buildings.php similarity index 87% rename from application/code/core/Wootook/Empire/Block/Planet/Buildings.php rename to src/application/code/core/Wootook/Empire/Block/Planet/Buildings.php index e777cdd..77d4a86 100644 --- a/application/code/core/Wootook/Empire/Block/Planet/Buildings.php +++ b/src/application/code/core/Wootook/Empire/Block/Planet/Buildings.php @@ -15,7 +15,7 @@ class Wootook_Empire_Block_Planet_Buildings public function getPlanet() { if ($this->_planet === null) { - $this->_planet = Wootook_Empire_Model_User::getSingleton() + $this->_planet = Wootook_Player_Model_Session::getSingleton()->getPlayer() ->getCurrentPlanet() ; } @@ -24,7 +24,7 @@ class Wootook_Empire_Block_Planet_Buildings public function _initChildBlocks() { - $types = Wootook_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; diff --git a/application/code/core/Wootook/Empire/Block/Planet/Buildings/Item.php b/src/application/code/core/Wootook/Empire/Block/Planet/Buildings/Item.php similarity index 78% rename from application/code/core/Wootook/Empire/Block/Planet/Buildings/Item.php rename to src/application/code/core/Wootook/Empire/Block/Planet/Buildings/Item.php index b24a819..1c4a970 100644 --- a/application/code/core/Wootook/Empire/Block/Planet/Buildings/Item.php +++ b/src/application/code/core/Wootook/Empire/Block/Planet/Buildings/Item.php @@ -13,6 +13,22 @@ class Wootook_Empire_Block_Planet_Buildings_Item return $this->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()); diff --git a/application/code/core/Wootook/Empire/Block/Planet/Buildings/Queue.php b/src/application/code/core/Wootook/Empire/Block/Planet/Buildings/Queue.php similarity index 100% rename from application/code/core/Wootook/Empire/Block/Planet/Buildings/Queue.php rename to src/application/code/core/Wootook/Empire/Block/Planet/Buildings/Queue.php diff --git a/application/code/core/Wootook/Empire/Block/Planet/Buildings/Queue/Item.php b/src/application/code/core/Wootook/Empire/Block/Planet/Buildings/Queue/Item.php similarity index 55% rename from application/code/core/Wootook/Empire/Block/Planet/Buildings/Queue/Item.php rename to src/application/code/core/Wootook/Empire/Block/Planet/Buildings/Queue/Item.php index e3721e3..6941b62 100644 --- a/application/code/core/Wootook/Empire/Block/Planet/Buildings/Queue/Item.php +++ b/src/application/code/core/Wootook/Empire/Block/Planet/Buildings/Queue/Item.php @@ -1,5 +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 Wootook_Empire_Block_Planet_Buildings_Queue_Item extends Wootook_Empire_Block_Planet_Builder_Queue_ItemAbstract { @@ -30,6 +64,14 @@ class Wootook_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); 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/application/code/core/Wootook/Empire/Block/PlanetList.php b/src/application/code/core/Wootook/Empire/Block/PlanetList.php similarity index 100% rename from application/code/core/Wootook/Empire/Block/PlanetList.php rename to src/application/code/core/Wootook/Empire/Block/PlanetList.php diff --git a/src/application/code/core/Wootook/Empire/Block/Topnav.php b/src/application/code/core/Wootook/Empire/Block/Topnav.php new file mode 100644 index 0000000..72a6d5b --- /dev/null +++ b/src/application/code/core/Wootook/Empire/Block/Topnav.php @@ -0,0 +1,34 @@ +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/application/code/core/Wootook/Empire/Model/Game/Combat.php b/src/application/code/core/Wootook/Empire/Helper/Config/Combat.php similarity index 88% rename from application/code/core/Wootook/Empire/Model/Game/Combat.php rename to src/application/code/core/Wootook/Empire/Helper/Config/Combat.php index 48a9e1b..26a1bc8 100644 --- a/application/code/core/Wootook/Empire/Model/Game/Combat.php +++ b/src/application/code/core/Wootook/Empire/Helper/Config/Combat.php @@ -7,8 +7,8 @@ * @uses Wootook_Object * @uses Legacies_Empire */ -class Wootook_Empire_Model_Game_Combat - extends Wootook_Core_Model_Config_Abstract +class Wootook_Empire_Helper_Config_Combat + extends Wootook_Core_Helper_Config_ConfigHandler implements Wootook_Core_Singleton { private static $_singleton = null; diff --git a/application/code/core/Wootook/Empire/Model/Game/FieldsAlias.php b/src/application/code/core/Wootook/Empire/Helper/Config/FieldsAlias.php similarity index 87% rename from application/code/core/Wootook/Empire/Model/Game/FieldsAlias.php rename to src/application/code/core/Wootook/Empire/Helper/Config/FieldsAlias.php index 9a4ab2b..101bc5f 100644 --- a/application/code/core/Wootook/Empire/Model/Game/FieldsAlias.php +++ b/src/application/code/core/Wootook/Empire/Helper/Config/FieldsAlias.php @@ -7,8 +7,8 @@ * @uses Wootook_Object * @uses Legacies_Empire */ -class Wootook_Empire_Model_Game_FieldsAlias - extends Wootook_Core_Model_Config_Abstract +class Wootook_Empire_Helper_Config_FieldsAlias + extends Wootook_Core_Helper_Config_ConfigHandler implements Wootook_Core_Singleton { private static $_singleton = null; 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/application/code/core/Wootook/Empire/Model/Game/Prices.php b/src/application/code/core/Wootook/Empire/Helper/Config/Prices.php similarity index 88% rename from application/code/core/Wootook/Empire/Model/Game/Prices.php rename to src/application/code/core/Wootook/Empire/Helper/Config/Prices.php index 9133d34..1a328de 100644 --- a/application/code/core/Wootook/Empire/Model/Game/Prices.php +++ b/src/application/code/core/Wootook/Empire/Helper/Config/Prices.php @@ -7,8 +7,8 @@ * @uses Wootook_Object * @uses Legacies_Empire */ -class Wootook_Empire_Model_Game_Prices - extends Wootook_Core_Model_Config_Abstract +class Wootook_Empire_Helper_Config_Prices + extends Wootook_Core_Helper_Config_ConfigHandler implements Wootook_Core_Singleton { private static $_singleton = null; diff --git a/application/code/core/Wootook/Empire/Model/Game/Production.php b/src/application/code/core/Wootook/Empire/Helper/Config/Production.php similarity index 87% rename from application/code/core/Wootook/Empire/Model/Game/Production.php rename to src/application/code/core/Wootook/Empire/Helper/Config/Production.php index 60ab21c..d4539fc 100644 --- a/application/code/core/Wootook/Empire/Model/Game/Production.php +++ b/src/application/code/core/Wootook/Empire/Helper/Config/Production.php @@ -7,8 +7,8 @@ * @uses Wootook_Object * @uses Legacies_Empire */ -class Wootook_Empire_Model_Game_Production - extends Wootook_Core_Model_Config_Abstract +class Wootook_Empire_Helper_Config_Production + extends Wootook_Core_Helper_Config_ConfigHandler implements Wootook_Core_Singleton { private static $_singleton = null; diff --git a/application/code/core/Wootook/Empire/Model/Game/Requirements.php b/src/application/code/core/Wootook/Empire/Helper/Config/Requirements.php similarity index 87% rename from application/code/core/Wootook/Empire/Model/Game/Requirements.php rename to src/application/code/core/Wootook/Empire/Helper/Config/Requirements.php index 9f09689..04ea042 100644 --- a/application/code/core/Wootook/Empire/Model/Game/Requirements.php +++ b/src/application/code/core/Wootook/Empire/Helper/Config/Requirements.php @@ -7,8 +7,8 @@ * @uses Wootook_Object * @uses Legacies_Empire */ -class Wootook_Empire_Model_Game_Requirements - extends Wootook_Core_Model_Config_Abstract +class Wootook_Empire_Helper_Config_Requirements + extends Wootook_Core_Helper_Config_ConfigHandler implements Wootook_Core_Singleton { private static $_singleton = null; diff --git a/application/code/core/Wootook/Empire/Model/Game/Resources.php b/src/application/code/core/Wootook/Empire/Helper/Config/Resources.php similarity index 87% rename from application/code/core/Wootook/Empire/Model/Game/Resources.php rename to src/application/code/core/Wootook/Empire/Helper/Config/Resources.php index c825f74..8ce2483 100644 --- a/application/code/core/Wootook/Empire/Model/Game/Resources.php +++ b/src/application/code/core/Wootook/Empire/Helper/Config/Resources.php @@ -7,8 +7,8 @@ * @uses Wootook_Object * @uses Legacies_Empire */ -class Wootook_Empire_Model_Game_Resources - extends Wootook_Core_Model_Config_Abstract +class Wootook_Empire_Helper_Config_Resources + extends Wootook_Core_Helper_Config_ConfigHandler implements Wootook_Core_Singleton { private static $_singleton = null; diff --git a/application/code/core/Wootook/Empire/Model/Game/Types.php b/src/application/code/core/Wootook/Empire/Helper/Config/Types.php similarity index 90% rename from application/code/core/Wootook/Empire/Model/Game/Types.php rename to src/application/code/core/Wootook/Empire/Helper/Config/Types.php index 291c964..9ef029d 100644 --- a/application/code/core/Wootook/Empire/Model/Game/Types.php +++ b/src/application/code/core/Wootook/Empire/Helper/Config/Types.php @@ -7,8 +7,8 @@ * @uses Wootook_Object * @uses Legacies_Empire */ -class Wootook_Empire_Model_Game_Types - extends Wootook_Core_Model_Config_Abstract +class Wootook_Empire_Helper_Config_Types + extends Wootook_Core_Helper_Config_ConfigHandler implements Wootook_Core_Singleton { private static $_singleton = null; diff --git a/application/code/core/Wootook/Empire/Model/Builder/Break.php b/src/application/code/core/Wootook/Empire/Model/Builder/Break.php similarity index 100% rename from application/code/core/Wootook/Empire/Model/Builder/Break.php rename to src/application/code/core/Wootook/Empire/Model/Builder/Break.php diff --git a/application/code/core/Wootook/Empire/Model/Builder/Item.php b/src/application/code/core/Wootook/Empire/Model/Builder/Item.php similarity index 100% rename from application/code/core/Wootook/Empire/Model/Builder/Item.php rename to src/application/code/core/Wootook/Empire/Model/Builder/Item.php diff --git a/application/code/core/Wootook/Empire/Model/BuilderAbstract.php b/src/application/code/core/Wootook/Empire/Model/BuilderAbstract.php similarity index 83% rename from application/code/core/Wootook/Empire/Model/BuilderAbstract.php rename to src/application/code/core/Wootook/Empire/Model/BuilderAbstract.php index ee3c32e..dc0899e 100644 --- a/application/code/core/Wootook/Empire/Model/BuilderAbstract.php +++ b/src/application/code/core/Wootook/Empire/Model/BuilderAbstract.php @@ -10,10 +10,10 @@ abstract class Wootook_Empire_Model_BuilderAbstract protected $_currentPlanet = null; /** - * User instance - * @var Wootook_Empire_Model_User + * Player instance + * @var Wootook_Player_Model_Entity */ - protected $_currentUser = null; + protected $_currentPlayer = null; /** * construction queue @@ -30,12 +30,12 @@ abstract class Wootook_Empire_Model_BuilderAbstract /** * * @param Wootook_Empire_Model_Planet $currentPlanet - * @param Wootook_Empire_Model_User $currentUser + * @param Wootook_Player_Model_Entity $currentPlayer */ - public function __construct(Wootook_Empire_Model_Planet $currentPlanet, Wootook_Empire_Model_User $currentUser) + public function __construct(Wootook_Empire_Model_Planet $currentPlanet, Wootook_Player_Model_Entity $currentPlayer) { $this->_currentPlanet = $currentPlanet; - $this->_currentUser = $currentUser; + $this->_currentPlayer = $currentPlayer; $this->init(); } @@ -46,6 +46,10 @@ abstract class Wootook_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 Wootook_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 Wootook_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 Wootook_Empire_Model_BuilderAbstract */ public function checkAvailability($typeId) { - $types = Wootook_Empire_Model_Game_Types::getSingleton(); - $requirements = Wootook_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 Wootook_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,9 +212,9 @@ abstract class Wootook_Empire_Model_BuilderAbstract return $this->_currentPlanet; } - public function getCurrentUser() + public function getCurrentPlayer() { - return $this->_currentUser; + return $this->_currentPlayer; } public function setCurrentPlanet(Wootook_Empire_Model_Planet $planet) @@ -217,9 +224,9 @@ abstract class Wootook_Empire_Model_BuilderAbstract return $this; } - public function setCurrentUser(Wootook_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 Wootook_Empire_Model_BuilderAbstract } return $resourceAmounts; } -} \ No newline at end of file +} diff --git a/application/code/core/Wootook/Empire/Model/Fleet.php b/src/application/code/core/Wootook/Empire/Model/Fleet.php similarity index 56% rename from application/code/core/Wootook/Empire/Model/Fleet.php rename to src/application/code/core/Wootook/Empire/Model/Fleet.php index 1ce2b7d..e622226 100644 --- a/application/code/core/Wootook/Empire/Model/Fleet.php +++ b/src/application/code/core/Wootook/Empire/Model/Fleet.php @@ -7,7 +7,7 @@ * @uses Legacies_Empire */ class Wootook_Empire_Model_Fleet - extends Wootook_Core_Entity + extends Wootook_Core_Mvc_Model_Entity { protected static $_instances = array(); @@ -34,24 +34,36 @@ class Wootook_Empire_Model_Fleet { $this->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_Empire_Model_User $user) + public function isOwnedBy(Wootook_Player_Model_Entity $player) { - if ($this->getData('fleet_owner') == $user->getId()) { + if ($this->getData('fleet_owner') == $player->getId()) { return true; } return false; } - public function getOwner() + /** + * @return null|Wootook_Player_Resource_Entity_Collection + */ + public function getOwnerCollection() { if ($id = $this->getData('fleet_owner')) { - return Wootook_Empire_Model_User::factory($id); + $ownerCollection = new Wootook_Player_Resource_Entity_Collection($this->getReadConnection()); + $ownerCollection->addFieldToFilter('id', $id); + + return $ownerCollection; } return null; } @@ -64,10 +76,10 @@ class Wootook_Empire_Model_Fleet return false; } - public function getRowClass(Wootook_Empire_Model_User $user = null) + 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 ($user !== null && $this->isOwnedBy($user)) { + if ($player !== null && $this->isOwnedBy($player)) { return 'attack'; } else { return 'ownattack'; @@ -86,6 +98,8 @@ class Wootook_Empire_Model_Fleet 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'; } } @@ -107,25 +121,34 @@ class Wootook_Empire_Model_Fleet 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() { - if ($this->isMission(Legacies_Empire::ID_MISSION_STATION) || $this->isMission(Legacies_Empire::ID_MISSION_STATION_ALLY)) { - return $this->getActionTime(); - } return $this->getData('fleet_end_time'); } @@ -141,15 +164,85 @@ class Wootook_Empire_Model_Fleet 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); } -} \ No newline at end of file + + 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/application/code/core/Wootook/Empire/Model/Planet.php b/src/application/code/core/Wootook/Empire/Model/Planet.php similarity index 63% rename from application/code/core/Wootook/Empire/Model/Planet.php rename to src/application/code/core/Wootook/Empire/Model/Planet.php index c013667..980524f 100644 --- a/application/code/core/Wootook/Empire/Model/Planet.php +++ b/src/application/code/core/Wootook/Empire/Model/Planet.php @@ -4,10 +4,10 @@ * * @uses Wootook_Object * @uses Legacies_Empire - * @uses Legacies_Empire_User + * @uses Wootook_Player_Model_Entity */ class Wootook_Empire_Model_Planet - extends Wootook_Core_Entity + extends Wootook_Core_Mvc_Model_Entity { const TYPE_PLANET = 1; const TYPE_DEBRIS = 2; @@ -17,9 +17,9 @@ class Wootook_Empire_Model_Planet protected $_eventObject = 'planet'; /** - * @var Wootook_Empire_Model_User + * @var Wootook_Player_Model_Entity */ - protected $_user = null; + protected $_player = null; /** * @var Wootook_Empire_Model_Planet @@ -27,7 +27,12 @@ class Wootook_Empire_Model_Planet protected $_moon = null; /** - * @var Wootook_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,7 @@ class Wootook_Empire_Model_Planet protected static $_productionInstances = array(); + /** @var Wootook_Empire_Model_Planet_PluginLoader */ protected $_pluginLoader = null; public static function factory($id) @@ -95,31 +101,40 @@ class Wootook_Empire_Model_Planet $coords['type'] = $type; } - $database = Wootook_Database::getSingleton(); - $collection = new Wootook_Core_Collection('planets'); - $collection - ->column('id') - ->where('galaxy=:galaxy') - ->where('system=:system') - ->where('planet=:position') - ->where('planet_type=:type') - ->limit(1) - ->load($coords) - ; + $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(); - $planetData = $collection->getFirstItem(); - - if ($planetData === null || !$planetData->getData('id')) { - return new self(); + $planet = $collection->getFirstItem(); + if ($planet !== null) { + return $planet; } - return self::factory($planetData->getData('id')); + 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) @@ -128,31 +143,33 @@ class Wootook_Empire_Model_Planet $plugin = substr($method, 3); if ($this->_pluginLoader === null) { - $this->_pluginLoader = new Wootook_Empire_Model_Planet_PluginLoader($this, $this->getUser()); + $this->_pluginLoader = new Wootook_Empire_Model_Planet_PluginLoader($this, $this->getPlayer()); } switch ($prefix) { case 'get': - $this->_pluginLoader->getPlugin($plugin); + return $this->_pluginLoader->getPlugin($plugin); break; case 'set': - $this->_pluginLoader->setPlugin($plugin, $params[0]); + return $this->_pluginLoader->setPlugin($plugin, $params[0]); break; case 'uns': - $this->_pluginLoader->unsetPlugin($plugin); + return $this->_pluginLoader->unsetPlugin($plugin); break; case 'has': - $this->_pluginLoader->hasPlugin($plugin); - break; + return $this->_pluginLoader->hasPlugin($plugin); break; } - throw new InvalidMethodCall(Wootook::__('Undefined method %s::%s.', get_class($this), $method)); + 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'); @@ -175,18 +192,22 @@ class Wootook_Empire_Model_Planet public function getGalaxyData() { - $entity = new Wootook_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 = Wootook_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; } @@ -217,7 +238,7 @@ class Wootook_Empire_Model_Planet public function updateBuildingFields() { - $types = Wootook_Empire_Model_Game_Types::getSingleton(); + $types = Wootook_Empire_Helper_Config_Types::getSingleton(); if ($this->isPlanet()) { $filter = Legacies_Empire::TYPE_BUILDING_PLANET; @@ -237,17 +258,21 @@ class Wootook_Empire_Model_Planet return $this; } - public function updateResourceProduction($time = null) + public function updateResourceProduction() { - $types = Wootook_Empire_Model_Game_Types::getSingleton(); - $resources = Wootook_Empire_Model_Game_Resources::getSingleton(); - $production = Wootook_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 = Wootook::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; } @@ -270,7 +295,7 @@ class Wootook_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) { @@ -339,7 +364,7 @@ class Wootook_Empire_Model_Planet // Dispatch 'planet.update-production.before' event Wootook::dispatchEvent($this->_eventPrefix . '.update-production.before', array( $this->_eventObject => $this, - 'user' => $this->getUser(), + 'player' => $this->getPlayer(), 'productions' => $actualProduction )); @@ -355,27 +380,28 @@ class Wootook_Empire_Model_Planet // Dispatch 'planet.update-production.after' event 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 = Wootook_Empire_Model_Game_Resources::getSingleton(); + $resources = Wootook_Empire_Helper_Config_Resources::getSingleton(); if ($time === null) { - $time = Wootook::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']))); } @@ -386,13 +412,13 @@ class Wootook_Empire_Model_Planet public static function getProductionElementInstance($buildingId) { - $production = Wootook_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(); } @@ -402,93 +428,30 @@ class Wootook_Empire_Model_Planet public function getFleetCollection($time = null) { - $firstCollection = new Wootook_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 Wootook_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 Wootook_Core_Collection(); - $collection - ->setEntityClassName('Wootook_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 = Wootook_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(Wootook_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; } @@ -510,31 +473,60 @@ class Wootook_Empire_Model_Planet public function getMoon() { - static $statement = null; - if ($this->isMoon()) { return null; } if ($this->_moon === null) { - if ($statement === null) { - $statement = new Wootook_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) @@ -614,7 +606,7 @@ class Wootook_Empire_Model_Planet public function isDestroyed() { - return (bool) $this->getData('destruyed'); + return (bool) ($this->getData('destruyed') > 0); } public function destroy() @@ -624,23 +616,23 @@ class Wootook_Empire_Model_Planet } if ($this->isDestroyed()) { - throw new Wootook_Empire_Model_Planet_Exception(Wootook::__('Planet is already destroyed.')); + throw new Wootook_Empire_Exception_Planet(Wootook::__('Planet is already destroyed.')); } if ($this->getFleetCollection()->count() > 0) { - throw new Wootook_Empire_Model_Planet_Exception(Wootook::__("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 Wootook_Empire_Model_Planet_Exception(Wootook::__("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); } } @@ -649,41 +641,49 @@ class Wootook_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 = Wootook_Empire_Model_Game_FieldsAlias::getSingleton(); + $fields = Wootook_Empire_Helper_Config_FieldsAlias::getSingleton(); return $this->getData($fields[$elementId]); } public function setElement($elementId, $level) { - $fields = Wootook_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 = Wootook_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 = Wootook_Empire_Model_Game_Types::getSingleton(); - $prices = Wootook_Empire_Model_Game_Prices::getSingleton(); + $types = Wootook_Empire_Helper_Config_Types::getSingleton(); + $prices = Wootook_Empire_Helper_Config_Prices::getSingleton(); if ($time === null) { - $time = Wootook::now(); + $time = new Wootook_Core_DateTime(); } if (!$types->is($buildingId, Legacies_Empire::TYPE_BUILDING)) { @@ -699,7 +699,7 @@ class Wootook_Empire_Model_Planet 'bulding_id' => $buildingId, 'level' => $this->getElement($buildingId), $this->_eventObject => $this, - 'user' => $this->getUser(), + 'player' => $this->getPlayer(), 'destroy' => $destroy )); @@ -716,24 +716,24 @@ class Wootook_Empire_Model_Planet '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 = Wootook::now(); + $time = new Wootook_Core_DateTime(); } // Dispatch event 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); @@ -741,9 +741,8 @@ class Wootook_Empire_Model_Planet // Dispatch event 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; @@ -764,12 +763,12 @@ class Wootook_Empire_Model_Planet /** * - * @return Wootook_Empire_Model_Planet_Builder + * @return Wootook_Empire_Model_Planet_Builder_Builder */ public function getBuildingQueue() { - if ($this->_builder === null) { - $this->_builder = new Wootook_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; } @@ -784,7 +783,7 @@ class Wootook_Empire_Model_Planet $this->getBuildingQueue()->rewind(); $item = $this->getBuildingQueue()->current(); - $this->getBuildingQueue()->dequeueFirstItem(Wootook::now()); + $this->getBuildingQueue()->dequeueFirstItem(new Wootook_Core_DateTime()); return $this; } @@ -810,15 +809,17 @@ class Wootook_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. 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; @@ -849,129 +850,53 @@ class Wootook_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 Wootook_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 Wootook_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 = Wootook_Core_Model_Config::getSingleton(); - $planet = new self(); - $planet - ->setData('id_owner', $user->getId()) - ->setData('name', Wootook::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()) - ; - - Wootook::dispatchEvent('planet.init', array( - 'planet' => $planet, - 'user' => $user - )); - - $planet->save(); - } - } - public static function searchMostFreeSystems($galaxyList = null, $systemList = null) { - $collection = new Wootook_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 = Wootook_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) @@ -979,6 +904,32 @@ class Wootook_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'])) { @@ -987,7 +938,10 @@ class Wootook_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 Wootook_Empire_Model_Planet) { @@ -996,14 +950,17 @@ class Wootook_Empire_Model_Planet $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 = Wootook_Empire_Model_Game_Resources::getSingleton(); + $resources = Wootook_Empire_Helper_Config_Resources::getSingleton(); $resourceConfig = $resources->getData($resourceType); if ($resourceConfig === null) { @@ -1014,7 +971,7 @@ class Wootook_Empire_Model_Planet public function getResourceCap($resourceType) { - $resources = Wootook_Empire_Model_Game_Resources::getSingleton(); + $resources = Wootook_Empire_Helper_Config_Resources::getSingleton(); $resourceConfig = $resources->getData($resourceType); if ($resourceConfig === null) { @@ -1034,4 +991,4 @@ class Wootook_Empire_Model_Planet } return false; } -} \ No newline at end of file +} diff --git a/application/code/core/Wootook/Empire/Model/Planet/Builder.php b/src/application/code/core/Wootook/Empire/Model/Planet/Builder/Builder.php similarity index 59% rename from application/code/core/Wootook/Empire/Model/Planet/Builder.php rename to src/application/code/core/Wootook/Empire/Model/Planet/Builder/Builder.php index d696c8c..eddf545 100644 --- a/application/code/core/Wootook/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 Wootook_Empire_Model_Planet_Builder +/** + * + * 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,7 +69,7 @@ class Wootook_Empire_Model_Planet_Builder $level = $params['level']; if (!isset($params['created_at'])) { - $createdAt = time(); + $createdAt = new Wootook_Core_DateTime(); } else { $createdAt = $params['created_at']; } @@ -47,36 +95,60 @@ class Wootook_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 = Wootook_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 = Wootook_Empire_Model_Game_Prices::getSingleton(); - $gameConfig = Wootook_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(); @@ -84,7 +156,7 @@ class Wootook_Empire_Model_Planet_Builder 'time' => $baseTime, 'base_time' => $baseTime, 'planet' => $this->_currentPlanet, - 'user' => $this->_currentUser, + 'player' => $this->_currentPlayer, 'building_id' => $buildingId, 'level' => $level )); @@ -92,10 +164,14 @@ class Wootook_Empire_Model_Planet_Builder return $event->getData('time'); } + /** + * (non-PHPdoc) + * @see Legacies_Empire_Model_BuilderAbstract::getResourcesNeeded() + */ public function getResourcesNeeded($buildingId, $level) { - $prices = Wootook_Empire_Model_Game_Prices::getSingleton(); - $resources = Wootook_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 Wootook_Empire_Model_Planet_Builder /** * Update the contruction queue. * - * @return Wootook_Empire_Model_Planet_Building_Shipyard + * @return Wootook_Empire_Model_Planet_Builder_Builder */ - public function updateQueue($time) + public function updateQueue(Wootook_Core_DateTime $time) { - $fields = Wootook_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 === null) { - $element->setData('started_at', $startingTime); - $elementTime = $startingTime; + $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); + $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' => $time - $elapsedTime, + '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 Wootook_Empire_Model_Planet_Builder /** * Append items to build to the construction list * - * @param int $buildingId - * @param int|string $level - * @return Wootook_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 = Wootook_Empire_Model_Game_Types::getSingleton(); - $resources = Wootook_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; @@ -206,7 +287,7 @@ class Wootook_Empire_Model_Planet_Builder $this->enqueue(array( 'building_id' => $buildingId, 'level' => $level, - 'created_at' => $time + 'created_at' => $time->getTimestamp() )); $this->_currentPlanet->setData('b_building_id', $this->serialize()); @@ -221,7 +302,7 @@ class Wootook_Empire_Model_Planet_Builder * Dequeues the first item to build to the construction list and removes all * its successors of the same type. * - * @return Wootook_Empire_Model_Planet_Builder + * @return Wootook_Empire_Model_Planet_Builder_Builder */ public function dequeueFirstItem() { @@ -236,7 +317,7 @@ class Wootook_Empire_Model_Planet_Builder * successors of the same type. * * @param string $itemId - * @return Wootook_Empire_Model_Planet_Builder + * @return Wootook_Empire_Model_Planet_Builder_Builder */ public function dequeueItem($itemId) { @@ -269,4 +350,4 @@ class Wootook_Empire_Model_Planet_Builder return $this; } -} \ No newline at end of file +} diff --git a/application/code/core/Wootook/Empire/Model/Planet/Builder/Item.php b/src/application/code/core/Wootook/Empire/Model/Planet/Builder/Item.php similarity index 100% rename from application/code/core/Wootook/Empire/Model/Planet/Builder/Item.php rename to src/application/code/core/Wootook/Empire/Model/Planet/Builder/Item.php diff --git a/application/code/core/Wootook/Empire/Model/Planet/BuildingInterface.php b/src/application/code/core/Wootook/Empire/Model/Planet/BuildingInterface.php similarity index 100% rename from application/code/core/Wootook/Empire/Model/Planet/BuildingInterface.php rename to src/application/code/core/Wootook/Empire/Model/Planet/BuildingInterface.php diff --git a/src/application/code/core/Wootook/Empire/Model/Planet/PluginLoader.php b/src/application/code/core/Wootook/Empire/Model/Planet/PluginLoader.php new file mode 100644 index 0000000..d3cc37b --- /dev/null +++ b/src/application/code/core/Wootook/Empire/Model/Planet/PluginLoader.php @@ -0,0 +1,31 @@ +_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/application/code/core/Legacies/Oficers.php b/src/application/code/core/Wootook/Exception.php similarity index 95% rename from application/code/core/Legacies/Oficers.php rename to src/application/code/core/Wootook/Exception.php index 089b825..c3b339a 100644 --- a/application/code/core/Legacies/Oficers.php +++ b/src/application/code/core/Wootook/Exception.php @@ -3,7 +3,7 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/agpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * * Copyright (c) 2011-Present, Grégory PLANCHAT * All rights reserved. @@ -27,14 +27,11 @@ * documentation for further information about customizing Wootook. * */ + /** * * Enter description here ... * @author Greg * */ - -class Legacies_Officers -{ - -} \ No newline at end of file +interface Wootook_Exception {} \ No newline at end of file diff --git a/application/code/core/Wootook/Object.php b/src/application/code/core/Wootook/Object.php similarity index 54% rename from application/code/core/Wootook/Object.php rename to src/application/code/core/Wootook/Object.php index 2f214d3..d3271ee 100644 --- a/application/code/core/Wootook/Object.php +++ b/src/application/code/core/Wootook/Object.php @@ -1,5 +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 Wootook_Object implements ArrayAccess { @@ -79,4 +113,4 @@ class Wootook_Object { return $this->unsetData($offset); } -} \ No newline at end of file +} diff --git a/application/code/core/Wootook/Empire/Block/Overview.php b/src/application/code/core/Wootook/Player/Block/Overview.php similarity index 58% rename from application/code/core/Wootook/Empire/Block/Overview.php rename to src/application/code/core/Wootook/Player/Block/Overview.php index c09ec87..bf689f0 100644 --- a/application/code/core/Wootook/Empire/Block/Overview.php +++ b/src/application/code/core/Wootook/Player/Block/Overview.php @@ -1,6 +1,6 @@ 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/application/code/core/Wootook/Empire/Model/User/Message.php b/src/application/code/core/Wootook/Player/Model/Message.php similarity index 59% rename from application/code/core/Wootook/Empire/Model/User/Message.php rename to src/application/code/core/Wootook/Player/Model/Message.php index 80241ef..0002d94 100644 --- a/application/code/core/Wootook/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/application/design/base/default/scripts/empire/planet/shipyard/queue.phtml b/src/application/code/core/Wootook/Server/Mvc/Dispatcher.php similarity index 100% rename from application/design/base/default/scripts/empire/planet/shipyard/queue.phtml rename to src/application/code/core/Wootook/Server/Mvc/Dispatcher.php diff --git a/application/code/libraries/Math.php b/src/application/code/libraries/Math.php similarity index 99% rename from application/code/libraries/Math.php rename to src/application/code/libraries/Math.php index 7ea2d08..f429008 100644 --- a/application/code/libraries/Math.php +++ b/src/application/code/libraries/Math.php @@ -3,7 +3,7 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/agpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * * Copyright (c) 2011-Present, Grégory PLANCHAT * All rights reserved. diff --git a/application/code/libraries/Math/Bcmath.php b/src/application/code/libraries/Math/Bcmath.php similarity index 99% rename from application/code/libraries/Math/Bcmath.php rename to src/application/code/libraries/Math/Bcmath.php index bbf9b45..e5368c6 100644 --- a/application/code/libraries/Math/Bcmath.php +++ b/src/application/code/libraries/Math/Bcmath.php @@ -3,7 +3,7 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/agpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * * Copyright (c) 2011-Present, Grégory PLANCHAT * All rights reserved. diff --git a/application/code/libraries/Math/Native.php b/src/application/code/libraries/Math/Native.php similarity index 98% rename from application/code/libraries/Math/Native.php rename to src/application/code/libraries/Math/Native.php index 300d8e7..0958113 100644 --- a/application/code/libraries/Math/Native.php +++ b/src/application/code/libraries/Math/Native.php @@ -3,7 +3,7 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/agpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * * Copyright (c) 2011-Present, Grégory PLANCHAT * All rights reserved. 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/application/code/test/Legacies/Core/LayoutTest.php b/src/application/code/test/Legacies/Core/LayoutTest.php similarity index 100% rename from application/code/test/Legacies/Core/LayoutTest.php rename to src/application/code/test/Legacies/Core/LayoutTest.php diff --git a/application/code/test/Legacies/Empire/Model/BuilderTest.php b/src/application/code/test/Legacies/Empire/Model/BuilderTest.php similarity index 100% rename from application/code/test/Legacies/Empire/Model/BuilderTest.php rename to src/application/code/test/Legacies/Empire/Model/BuilderTest.php diff --git a/application/code/test/Legacies/ObjectTest.php b/src/application/code/test/Legacies/ObjectTest.php similarity index 100% rename from application/code/test/Legacies/ObjectTest.php rename to src/application/code/test/Legacies/ObjectTest.php diff --git a/application/code/test/LegaciesTest.php b/src/application/code/test/WootookTest.php similarity index 99% rename from application/code/test/LegaciesTest.php rename to src/application/code/test/WootookTest.php index d230e54..8962684 100644 --- a/application/code/test/LegaciesTest.php +++ b/src/application/code/test/WootookTest.php @@ -1,6 +1,6 @@ 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/application/design/base/default/scripts/deprecated/admin/activeplanet_body.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/activeplanet_body.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/admin/activeplanet_body.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/activeplanet_body.tpl diff --git a/application/design/base/default/scripts/deprecated/admin/add_money.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/add_money.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/admin/add_money.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/add_money.tpl diff --git a/application/design/base/default/scripts/deprecated/admin/add_moon.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/add_moon.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/admin/add_moon.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/add_moon.tpl diff --git a/application/design/base/default/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 application/design/base/default/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/application/design/base/default/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 application/design/base/default/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/application/design/base/default/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 application/design/base/default/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/application/design/base/default/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 application/design/base/default/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/application/design/base/default/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 application/design/base/default/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/application/design/base/default/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 application/design/base/default/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/application/design/base/default/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 application/design/base/default/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/application/design/base/default/scripts/deprecated/admin/banadni.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/banadni.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/admin/banadni.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/banadni.tpl diff --git a/application/design/base/default/scripts/deprecated/admin/banned.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/banned.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/admin/banned.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/banned.tpl diff --git a/application/design/base/default/scripts/deprecated/admin/changepass.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/changepass.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/admin/changepass.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/changepass.tpl diff --git a/application/design/base/default/scripts/deprecated/admin/chat_body.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/chat_body.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/admin/chat_body.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/chat_body.tpl diff --git a/application/design/base/default/scripts/deprecated/admin/credit_body.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/credit_body.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/admin/credit_body.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/credit_body.tpl diff --git a/application/design/base/default/scripts/deprecated/admin/declarelist_body.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/declarelist_body.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/admin/declarelist_body.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/declarelist_body.tpl diff --git a/application/design/base/default/scripts/deprecated/admin/declarelist_rows.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/declarelist_rows.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/admin/declarelist_rows.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/declarelist_rows.tpl diff --git a/application/design/base/default/scripts/deprecated/admin/deletuser.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/deletuser.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/admin/deletuser.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/deletuser.tpl diff --git a/application/design/base/default/scripts/deprecated/admin/errors_body.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/errors_body.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/admin/errors_body.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/errors_body.tpl diff --git a/application/design/base/default/scripts/deprecated/admin/exec_query.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/exec_query.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/admin/exec_query.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/exec_query.tpl diff --git a/application/design/base/default/scripts/deprecated/admin/fleet_body.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/fleet_body.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/admin/fleet_body.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/fleet_body.tpl diff --git a/application/design/base/default/scripts/deprecated/admin/fleet_rows.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/fleet_rows.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/admin/fleet_rows.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/fleet_rows.tpl diff --git a/application/design/base/default/scripts/deprecated/admin/left_menu.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/left_menu.tpl similarity index 97% rename from application/design/base/default/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/application/design/base/default/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/application/design/base/default/scripts/deprecated/admin/md5enc.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/md5enc.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/admin/md5enc.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/md5enc.tpl diff --git a/application/design/base/default/scripts/deprecated/admin/message_body.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/message_body.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/admin/message_body.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/message_body.tpl diff --git a/application/design/base/default/scripts/deprecated/admin/messagelist_body.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/messagelist_body.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/admin/messagelist_body.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/messagelist_body.tpl diff --git a/application/design/base/default/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 application/design/base/default/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/application/design/base/default/scripts/deprecated/admin/messall_body.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/messall_body.tpl similarity index 51% rename from application/design/base/default/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/application/design/base/default/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/application/design/base/default/scripts/deprecated/admin/moonlist_body.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/moonlist_body.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/admin/moonlist_body.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/moonlist_body.tpl diff --git a/application/design/base/default/scripts/deprecated/admin/multi_body.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/multi_body.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/admin/multi_body.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/multi_body.tpl diff --git a/application/design/base/default/scripts/deprecated/admin/multi_rows.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/multi_rows.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/admin/multi_rows.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/multi_rows.tpl diff --git a/application/design/base/default/scripts/deprecated/admin/options_body.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/options_body.tpl similarity index 89% rename from application/design/base/default/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/application/design/base/default/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/application/design/base/default/scripts/deprecated/admin/overview_rows.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/overview_rows.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/admin/overview_rows.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/overview_rows.tpl diff --git a/application/design/base/default/scripts/deprecated/admin/planetlist_body.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/planetlist_body.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/admin/planetlist_body.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/planetlist_body.tpl diff --git a/application/design/base/default/scripts/deprecated/admin/reset_body.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/reset_body.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/admin/reset_body.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/reset_body.tpl diff --git a/application/design/base/default/scripts/deprecated/admin/simple_header.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/simple_header.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/admin/simple_header.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/simple_header.tpl diff --git a/application/design/base/default/scripts/deprecated/admin/unbanned.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/unbanned.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/admin/unbanned.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/unbanned.tpl diff --git a/application/design/base/default/scripts/deprecated/admin/userlist_body.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/userlist_body.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/admin/userlist_body.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/userlist_body.tpl diff --git a/application/design/base/default/scripts/deprecated/admin/userlist_rows.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/userlist_rows.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/admin/userlist_rows.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/userlist_rows.tpl diff --git a/application/design/base/default/scripts/deprecated/admin/variables_body.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/variables_body.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/admin/variables_body.tpl rename to src/application/design/backend/base/default/scripts/deprecated/admin/variables_body.tpl diff --git a/application/design/base/default/scripts/deprecated/admin/variables_rows.tpl b/src/application/design/backend/base/default/scripts/deprecated/admin/variables_rows.tpl similarity index 100% rename from application/design/base/default/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/application/design/base/default/scripts/page/html/head.phtml b/src/application/design/backend/base/default/scripts/page/html/head.phtml similarity index 82% rename from application/design/base/default/scripts/page/html/head.phtml rename to src/application/design/backend/base/default/scripts/page/html/head.phtml index 7933554..b98b464 100644 --- a/application/design/base/default/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/application/design/base/default/scripts/page/html/message.phtml b/src/application/design/backend/base/default/scripts/page/html/message.phtml similarity index 100% rename from application/design/base/default/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/application/design/base/default/scripts/deprecated/add_declare.tpl b/src/application/design/frontend/base/default/scripts/deprecated/add_declare.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/add_declare.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/add_declare.tpl diff --git a/application/design/base/default/scripts/deprecated/alliance_admin.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_admin.tpl similarity index 100% rename from application/design/base/default/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/application/design/base/default/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 application/design/base/default/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/application/design/base/default/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 application/design/base/default/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/application/design/base/default/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 application/design/base/default/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/application/design/base/default/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 application/design/base/default/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/application/design/base/default/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 application/design/base/default/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/application/design/base/default/scripts/deprecated/alliance_admin_rename.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_admin_rename.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/alliance_admin_rename.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_admin_rename.tpl diff --git a/application/design/base/default/scripts/deprecated/alliance_admin_rename1.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_admin_rename1.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/alliance_admin_rename1.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_admin_rename1.tpl diff --git a/application/design/base/default/scripts/deprecated/alliance_admin_rename2.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_admin_rename2.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/alliance_admin_rename2.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_admin_rename2.tpl diff --git a/application/design/base/default/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 application/design/base/default/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/application/design/base/default/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 application/design/base/default/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/application/design/base/default/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 application/design/base/default/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/application/design/base/default/scripts/deprecated/alliance_ainfo.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_ainfo.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/alliance_ainfo.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_ainfo.tpl diff --git a/application/design/base/default/scripts/deprecated/alliance_apply_waitform.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_apply_waitform.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/alliance_apply_waitform.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_apply_waitform.tpl diff --git a/application/design/base/default/scripts/deprecated/alliance_applyform.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_applyform.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/alliance_applyform.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_applyform.tpl diff --git a/application/design/base/default/scripts/deprecated/alliance_circular.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_circular.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/alliance_circular.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_circular.tpl diff --git a/application/design/base/default/scripts/deprecated/alliance_circular_form.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_circular_form.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/alliance_circular_form.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_circular_form.tpl diff --git a/application/design/base/default/scripts/deprecated/alliance_defaultmenu.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_defaultmenu.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/alliance_defaultmenu.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_defaultmenu.tpl diff --git a/application/design/base/default/scripts/deprecated/alliance_frontpage.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_frontpage.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/alliance_frontpage.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_frontpage.tpl diff --git a/application/design/base/default/scripts/deprecated/alliance_make.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_make.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/alliance_make.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_make.tpl diff --git a/application/design/base/default/scripts/deprecated/alliance_makeform.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_makeform.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/alliance_makeform.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_makeform.tpl diff --git a/application/design/base/default/scripts/deprecated/alliance_memberslist_row.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_memberslist_row.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/alliance_memberslist_row.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_memberslist_row.tpl diff --git a/application/design/base/default/scripts/deprecated/alliance_memberslist_table.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_memberslist_table.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/alliance_memberslist_table.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_memberslist_table.tpl diff --git a/application/design/base/default/scripts/deprecated/alliance_searchform.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_searchform.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/alliance_searchform.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_searchform.tpl diff --git a/application/design/base/default/scripts/deprecated/alliance_searchresult_row.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_searchresult_row.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/alliance_searchresult_row.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_searchresult_row.tpl diff --git a/application/design/base/default/scripts/deprecated/alliance_searchresult_table.tpl b/src/application/design/frontend/base/default/scripts/deprecated/alliance_searchresult_table.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/alliance_searchresult_table.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/alliance_searchresult_table.tpl diff --git a/application/design/base/default/scripts/deprecated/banned_body.tpl b/src/application/design/frontend/base/default/scripts/deprecated/banned_body.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/banned_body.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/banned_body.tpl diff --git a/application/design/base/default/scripts/deprecated/changelog_body.tpl b/src/application/design/frontend/base/default/scripts/deprecated/changelog_body.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/changelog_body.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/changelog_body.tpl diff --git a/application/design/base/default/scripts/deprecated/changelog_table.tpl b/src/application/design/frontend/base/default/scripts/deprecated/changelog_table.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/changelog_table.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/changelog_table.tpl diff --git a/application/design/base/default/scripts/deprecated/chat_body.tpl b/src/application/design/frontend/base/default/scripts/deprecated/chat_body.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/chat_body.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/chat_body.tpl diff --git a/application/design/base/default/scripts/deprecated/contact_body.tpl b/src/application/design/frontend/base/default/scripts/deprecated/contact_body.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/contact_body.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/contact_body.tpl diff --git a/application/design/base/default/scripts/deprecated/contact_body_rows.tpl b/src/application/design/frontend/base/default/scripts/deprecated/contact_body_rows.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/contact_body_rows.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/contact_body_rows.tpl diff --git a/application/design/base/default/scripts/deprecated/credit_body.tpl b/src/application/design/frontend/base/default/scripts/deprecated/credit_body.tpl similarity index 83% rename from application/design/base/default/scripts/deprecated/credit_body.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/credit_body.tpl index 77c7886..525309d 100644 --- a/application/design/base/default/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/application/design/base/default/scripts/deprecated/galaxy_body.tpl b/src/application/design/frontend/base/default/scripts/deprecated/galaxy_body.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/galaxy_body.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/galaxy_body.tpl diff --git a/application/design/base/default/scripts/deprecated/galaxy_row.tpl b/src/application/design/frontend/base/default/scripts/deprecated/galaxy_row.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/galaxy_row.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/galaxy_row.tpl diff --git a/application/design/base/default/scripts/deprecated/galaxy_row_action.tpl b/src/application/design/frontend/base/default/scripts/deprecated/galaxy_row_action.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/galaxy_row_action.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/galaxy_row_action.tpl diff --git a/application/design/base/default/scripts/deprecated/galaxy_row_ally.tpl b/src/application/design/frontend/base/default/scripts/deprecated/galaxy_row_ally.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/galaxy_row_ally.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/galaxy_row_ally.tpl diff --git a/application/design/base/default/scripts/deprecated/galaxy_row_debris.tpl b/src/application/design/frontend/base/default/scripts/deprecated/galaxy_row_debris.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/galaxy_row_debris.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/galaxy_row_debris.tpl diff --git a/application/design/base/default/scripts/deprecated/galaxy_row_luna.tpl b/src/application/design/frontend/base/default/scripts/deprecated/galaxy_row_luna.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/galaxy_row_luna.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/galaxy_row_luna.tpl diff --git a/application/design/base/default/scripts/deprecated/galaxy_row_planet.tpl b/src/application/design/frontend/base/default/scripts/deprecated/galaxy_row_planet.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/galaxy_row_planet.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/galaxy_row_planet.tpl diff --git a/application/design/base/default/scripts/deprecated/galaxy_row_user.tpl b/src/application/design/frontend/base/default/scripts/deprecated/galaxy_row_user.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/galaxy_row_user.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/galaxy_row_user.tpl diff --git a/application/design/base/default/scripts/deprecated/gate_fleet_rows.tpl b/src/application/design/frontend/base/default/scripts/deprecated/gate_fleet_rows.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/gate_fleet_rows.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/gate_fleet_rows.tpl diff --git a/application/design/base/default/scripts/deprecated/gate_fleet_table.tpl b/src/application/design/frontend/base/default/scripts/deprecated/gate_fleet_table.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/gate_fleet_table.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/gate_fleet_table.tpl diff --git a/application/design/base/default/scripts/deprecated/imperium_row.tpl b/src/application/design/frontend/base/default/scripts/deprecated/imperium_row.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/imperium_row.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/imperium_row.tpl diff --git a/application/design/base/default/scripts/deprecated/imperium_row2.tpl b/src/application/design/frontend/base/default/scripts/deprecated/imperium_row2.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/imperium_row2.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/imperium_row2.tpl diff --git a/application/design/base/default/scripts/deprecated/imperium_table.tpl b/src/application/design/frontend/base/default/scripts/deprecated/imperium_table.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/imperium_table.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/imperium_table.tpl diff --git a/application/design/base/default/scripts/deprecated/info_buildings_defense.tpl b/src/application/design/frontend/base/default/scripts/deprecated/info_buildings_defense.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/info_buildings_defense.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/info_buildings_defense.tpl diff --git a/application/design/base/default/scripts/deprecated/info_buildings_destroy.tpl b/src/application/design/frontend/base/default/scripts/deprecated/info_buildings_destroy.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/info_buildings_destroy.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/info_buildings_destroy.tpl diff --git a/application/design/base/default/scripts/deprecated/info_buildings_fleet.tpl b/src/application/design/frontend/base/default/scripts/deprecated/info_buildings_fleet.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/info_buildings_fleet.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/info_buildings_fleet.tpl diff --git a/application/design/base/default/scripts/deprecated/info_buildings_general.tpl b/src/application/design/frontend/base/default/scripts/deprecated/info_buildings_general.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/info_buildings_general.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/info_buildings_general.tpl diff --git a/application/design/base/default/scripts/deprecated/info_buildings_table.tpl b/src/application/design/frontend/base/default/scripts/deprecated/info_buildings_table.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/info_buildings_table.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/info_buildings_table.tpl diff --git a/application/design/base/default/scripts/deprecated/info_officiers_general.tpl b/src/application/design/frontend/base/default/scripts/deprecated/info_officiers_general.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/info_officiers_general.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/info_officiers_general.tpl diff --git a/application/design/base/default/scripts/deprecated/lostpassword.tpl b/src/application/design/frontend/base/default/scripts/deprecated/lostpassword.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/lostpassword.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/lostpassword.tpl diff --git a/application/design/base/default/scripts/deprecated/marchand_cristal.tpl b/src/application/design/frontend/base/default/scripts/deprecated/marchand_cristal.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/marchand_cristal.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/marchand_cristal.tpl diff --git a/application/design/base/default/scripts/deprecated/marchand_deuterium.tpl b/src/application/design/frontend/base/default/scripts/deprecated/marchand_deuterium.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/marchand_deuterium.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/marchand_deuterium.tpl diff --git a/application/design/base/default/scripts/deprecated/marchand_main.tpl b/src/application/design/frontend/base/default/scripts/deprecated/marchand_main.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/marchand_main.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/marchand_main.tpl diff --git a/application/design/base/default/scripts/deprecated/marchand_metal.tpl b/src/application/design/frontend/base/default/scripts/deprecated/marchand_metal.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/marchand_metal.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/marchand_metal.tpl diff --git a/application/design/base/default/scripts/deprecated/message_body.tpl b/src/application/design/frontend/base/default/scripts/deprecated/message_body.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/message_body.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/message_body.tpl diff --git a/application/design/base/default/scripts/deprecated/messages_pm_form.tpl b/src/application/design/frontend/base/default/scripts/deprecated/messages_pm_form.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/messages_pm_form.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/messages_pm_form.tpl diff --git a/application/design/base/default/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 application/design/base/default/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/application/design/base/default/scripts/deprecated/multi.tpl b/src/application/design/frontend/base/default/scripts/deprecated/multi.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/multi.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/multi.tpl diff --git a/application/design/base/default/scripts/deprecated/notes_body.tpl b/src/application/design/frontend/base/default/scripts/deprecated/notes_body.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/notes_body.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/notes_body.tpl diff --git a/application/design/base/default/scripts/deprecated/notes_body_entry.tpl b/src/application/design/frontend/base/default/scripts/deprecated/notes_body_entry.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/notes_body_entry.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/notes_body_entry.tpl diff --git a/application/design/base/default/scripts/deprecated/notes_form.tpl b/src/application/design/frontend/base/default/scripts/deprecated/notes_form.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/notes_form.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/notes_form.tpl diff --git a/application/design/base/default/scripts/deprecated/officier_body.tpl b/src/application/design/frontend/base/default/scripts/deprecated/officier_body.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/officier_body.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/officier_body.tpl diff --git a/application/design/base/default/scripts/deprecated/officier_rows.tpl b/src/application/design/frontend/base/default/scripts/deprecated/officier_rows.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/officier_rows.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/officier_rows.tpl diff --git a/application/design/base/default/scripts/deprecated/options_admadd.tpl b/src/application/design/frontend/base/default/scripts/deprecated/options_admadd.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/options_admadd.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/options_admadd.tpl diff --git a/application/design/base/default/scripts/deprecated/options_body.tpl b/src/application/design/frontend/base/default/scripts/deprecated/options_body.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/options_body.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/options_body.tpl diff --git a/application/design/base/default/scripts/deprecated/options_body_vmode.tpl b/src/application/design/frontend/base/default/scripts/deprecated/options_body_vmode.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/options_body_vmode.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/options_body_vmode.tpl diff --git a/application/design/base/default/scripts/deprecated/overall_footer.tpl b/src/application/design/frontend/base/default/scripts/deprecated/overall_footer.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/overall_footer.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/overall_footer.tpl diff --git a/application/design/base/default/scripts/deprecated/overview_body.tpl b/src/application/design/frontend/base/default/scripts/deprecated/overview_body.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/overview_body.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/overview_body.tpl diff --git a/application/design/base/default/scripts/deprecated/overview_deleteplanet.tpl b/src/application/design/frontend/base/default/scripts/deprecated/overview_deleteplanet.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/overview_deleteplanet.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/overview_deleteplanet.tpl diff --git a/application/design/base/default/scripts/deprecated/overview_fleet_event.tpl b/src/application/design/frontend/base/default/scripts/deprecated/overview_fleet_event.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/overview_fleet_event.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/overview_fleet_event.tpl diff --git a/application/design/base/default/scripts/deprecated/overview_renameplanet.tpl b/src/application/design/frontend/base/default/scripts/deprecated/overview_renameplanet.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/overview_renameplanet.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/overview_renameplanet.tpl diff --git a/application/design/base/default/scripts/deprecated/phalanx_body.tpl b/src/application/design/frontend/base/default/scripts/deprecated/phalanx_body.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/phalanx_body.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/phalanx_body.tpl diff --git a/application/design/base/default/scripts/deprecated/records_body.tpl b/src/application/design/frontend/base/default/scripts/deprecated/records_body.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/records_body.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/records_body.tpl diff --git a/application/design/base/default/scripts/deprecated/records_section_header.tpl b/src/application/design/frontend/base/default/scripts/deprecated/records_section_header.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/records_section_header.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/records_section_header.tpl diff --git a/application/design/base/default/scripts/deprecated/records_section_rows.tpl b/src/application/design/frontend/base/default/scripts/deprecated/records_section_rows.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/records_section_rows.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/records_section_rows.tpl diff --git a/application/design/base/default/scripts/deprecated/registry_form.tpl b/src/application/design/frontend/base/default/scripts/deprecated/registry_form.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/registry_form.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/registry_form.tpl diff --git a/application/design/base/default/scripts/deprecated/resources.tpl b/src/application/design/frontend/base/default/scripts/deprecated/resources.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/resources.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/resources.tpl diff --git a/application/design/base/default/scripts/deprecated/resources_row.tpl b/src/application/design/frontend/base/default/scripts/deprecated/resources_row.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/resources_row.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/resources_row.tpl diff --git a/application/design/base/default/scripts/deprecated/rules_body.tpl b/src/application/design/frontend/base/default/scripts/deprecated/rules_body.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/rules_body.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/rules_body.tpl diff --git a/application/design/base/default/scripts/deprecated/search_ally_row.tpl b/src/application/design/frontend/base/default/scripts/deprecated/search_ally_row.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/search_ally_row.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/search_ally_row.tpl diff --git a/application/design/base/default/scripts/deprecated/search_ally_table.tpl b/src/application/design/frontend/base/default/scripts/deprecated/search_ally_table.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/search_ally_table.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/search_ally_table.tpl diff --git a/application/design/base/default/scripts/deprecated/search_body.tpl b/src/application/design/frontend/base/default/scripts/deprecated/search_body.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/search_body.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/search_body.tpl diff --git a/application/design/base/default/scripts/deprecated/search_user_row.tpl b/src/application/design/frontend/base/default/scripts/deprecated/search_user_row.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/search_user_row.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/search_user_row.tpl diff --git a/application/design/base/default/scripts/deprecated/search_user_table.tpl b/src/application/design/frontend/base/default/scripts/deprecated/search_user_table.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/search_user_table.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/search_user_table.tpl diff --git a/application/design/base/default/scripts/deprecated/serv_infos.tpl b/src/application/design/frontend/base/default/scripts/deprecated/serv_infos.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/serv_infos.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/serv_infos.tpl diff --git a/application/design/base/default/scripts/deprecated/simple_footer.tpl b/src/application/design/frontend/base/default/scripts/deprecated/simple_footer.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/simple_footer.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/simple_footer.tpl diff --git a/application/design/base/default/scripts/deprecated/simple_header.tpl b/src/application/design/frontend/base/default/scripts/deprecated/simple_header.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/simple_header.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/simple_header.tpl diff --git a/application/design/base/default/scripts/deprecated/stat_alliancetable.tpl b/src/application/design/frontend/base/default/scripts/deprecated/stat_alliancetable.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/stat_alliancetable.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/stat_alliancetable.tpl diff --git a/application/design/base/default/scripts/deprecated/stat_alliancetable_header.tpl b/src/application/design/frontend/base/default/scripts/deprecated/stat_alliancetable_header.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/stat_alliancetable_header.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/stat_alliancetable_header.tpl diff --git a/application/design/base/default/scripts/deprecated/stat_body.tpl b/src/application/design/frontend/base/default/scripts/deprecated/stat_body.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/stat_body.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/stat_body.tpl diff --git a/application/design/base/default/scripts/deprecated/stat_playertable.tpl b/src/application/design/frontend/base/default/scripts/deprecated/stat_playertable.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/stat_playertable.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/stat_playertable.tpl diff --git a/application/design/base/default/scripts/deprecated/stat_playertable_header.tpl b/src/application/design/frontend/base/default/scripts/deprecated/stat_playertable_header.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/stat_playertable_header.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/stat_playertable_header.tpl diff --git a/application/design/base/default/scripts/deprecated/statjoueur.tpl b/src/application/design/frontend/base/default/scripts/deprecated/statjoueur.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/statjoueur.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/statjoueur.tpl diff --git a/application/design/base/default/scripts/deprecated/techtree_body.tpl b/src/application/design/frontend/base/default/scripts/deprecated/techtree_body.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/techtree_body.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/techtree_body.tpl diff --git a/application/design/base/default/scripts/deprecated/techtree_details.tpl b/src/application/design/frontend/base/default/scripts/deprecated/techtree_details.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/techtree_details.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/techtree_details.tpl diff --git a/application/design/base/default/scripts/deprecated/techtree_head.tpl b/src/application/design/frontend/base/default/scripts/deprecated/techtree_head.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/techtree_head.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/techtree_head.tpl diff --git a/application/design/base/default/scripts/deprecated/techtree_row.tpl b/src/application/design/frontend/base/default/scripts/deprecated/techtree_row.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/techtree_row.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/techtree_row.tpl diff --git a/application/design/base/default/scripts/deprecated/teleport.tpl b/src/application/design/frontend/base/default/scripts/deprecated/teleport.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/teleport.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/teleport.tpl diff --git a/application/design/base/default/scripts/deprecated/tradingscrapmetal.tpl b/src/application/design/frontend/base/default/scripts/deprecated/tradingscrapmetal.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/tradingscrapmetal.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/tradingscrapmetal.tpl diff --git a/application/design/base/default/scripts/deprecated/tradingscrapmetal_n.tpl b/src/application/design/frontend/base/default/scripts/deprecated/tradingscrapmetal_n.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/tradingscrapmetal_n.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/tradingscrapmetal_n.tpl diff --git a/application/design/base/default/scripts/deprecated/usr_banned.tpl b/src/application/design/frontend/base/default/scripts/deprecated/usr_banned.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/usr_banned.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/usr_banned.tpl diff --git a/application/design/base/default/scripts/deprecated/usuw_body.tpl b/src/application/design/frontend/base/default/scripts/deprecated/usuw_body.tpl similarity index 100% rename from application/design/base/default/scripts/deprecated/usuw_body.tpl rename to src/application/design/frontend/base/default/scripts/deprecated/usuw_body.tpl diff --git a/application/design/base/default/scripts/deprecated/zglos.tpl b/src/application/design/frontend/base/default/scripts/deprecated/zglos.tpl similarity index 100% rename from application/design/base/default/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/application/design/base/default/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 application/design/base/default/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/application/design/base/default/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 application/design/base/default/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/application/design/base/default/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/application/design/base/default/scripts/empire/resources/default.phtml b/src/application/design/frontend/base/default/scripts/empire/resources/default.phtml similarity index 100% rename from application/design/base/default/scripts/empire/resources/default.phtml rename to src/application/design/frontend/base/default/scripts/empire/resources/default.phtml diff --git a/application/design/base/default/scripts/empire/resources/energy.phtml b/src/application/design/frontend/base/default/scripts/empire/resources/energy.phtml similarity index 100% rename from application/design/base/default/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/application/design/base/default/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 application/design/base/default/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/application/design/base/default/scripts/empire/overview/messages.phtml b/src/application/design/frontend/base/default/scripts/player/overview/messages.phtml similarity index 100% rename from application/design/base/default/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 @@ + +

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

    +

    + +

    + count() > 0):?> +

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

    + +

    __('Idle.')?>

    + + + + + 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/application/design/base/default/scripts/user/registration.phtml b/src/application/design/frontend/base/default/scripts/player/registration.phtml similarity index 68% rename from application/design/base/default/scripts/user/registration.phtml rename to src/application/design/frontend/base/default/scripts/player/registration.phtml index f2503bc..efdea56 100644 --- a/application/design/base/default/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/application/design/base/default/scripts/page/1column.phtml b/src/application/design/install/base/default/scripts/page/1column.phtml similarity index 100% rename from application/design/base/default/scripts/page/1column.phtml rename to src/application/design/install/base/default/scripts/page/1column.phtml diff --git a/application/design/base/default/scripts/page/2columns-left.phtml b/src/application/design/install/base/default/scripts/page/2columns-left.phtml similarity index 100% rename from application/design/base/default/scripts/page/2columns-left.phtml rename to src/application/design/install/base/default/scripts/page/2columns-left.phtml diff --git a/application/design/base/default/scripts/page/2columns-right.phtml b/src/application/design/install/base/default/scripts/page/2columns-right.phtml similarity index 100% rename from application/design/base/default/scripts/page/2columns-right.phtml rename to src/application/design/install/base/default/scripts/page/2columns-right.phtml diff --git a/application/design/base/default/scripts/page/3columns.phtml b/src/application/design/install/base/default/scripts/page/3columns.phtml similarity index 100% rename from application/design/base/default/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/application/gamedata/legacies/default/fields-alias.php b/src/application/gamedata/legacies/default/fields-alias.php similarity index 90% rename from application/gamedata/legacies/default/fields-alias.php rename to src/application/gamedata/legacies/default/fields-alias.php index 2a56eb1..788a72c 100644 --- a/application/gamedata/legacies/default/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/application/gamedata/legacies/default/prices.php b/src/application/gamedata/legacies/default/prices.php similarity index 100% rename from application/gamedata/legacies/default/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/application/gamedata/legacies/default/requirements.php b/src/application/gamedata/legacies/default/requirements.php similarity index 95% rename from application/gamedata/legacies/default/requirements.php rename to src/application/gamedata/legacies/default/requirements.php index 838a930..2ed5430 100644 --- a/application/gamedata/legacies/default/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/application/gamedata/legacies/default/resources.php b/src/application/gamedata/legacies/default/resources.php similarity index 100% rename from application/gamedata/legacies/default/resources.php rename to src/application/gamedata/legacies/default/resources.php diff --git a/application/gamedata/legacies/default/types.php b/src/application/gamedata/legacies/default/types.php similarity index 97% rename from application/gamedata/legacies/default/types.php rename to src/application/gamedata/legacies/default/types.php index 76c773d..c67c74d 100644 --- a/application/gamedata/legacies/default/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/application/locale/en_US/Legacies_User.csv b/src/application/locale/en_US/Legacies_User.csv similarity index 100% rename from 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/application/locale/fr_FR/Legacies_User.csv b/src/application/locale/fr_FR/Legacies_User.csv similarity index 100% rename from application/locale/fr_FR/Legacies_User.csv rename to src/application/locale/fr_FR/Legacies_User.csv diff --git a/application/locale/fr_FR/Legacies_User.txt b/src/application/locale/fr_FR/Legacies_User.txt similarity index 100% rename from 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 94% rename from banned.php rename to src/banned.php index 53c3b94..7874d75 100644 --- a/banned.php +++ b/src/banned.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/buddy.php b/src/buddy.php similarity index 98% rename from buddy.php rename to src/buddy.php index a59aca3..edc72dc 100644 --- a/buddy.php +++ b/src/buddy.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/calc.php b/src/calc.php similarity index 98% rename from calc.php rename to src/calc.php index 13c5db8..ab69276 100644 --- a/calc.php +++ b/src/calc.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/changelog.php b/src/changelog.php similarity index 93% rename from changelog.php rename to src/changelog.php index 00df85d..ff78373 100644 --- a/changelog.php +++ b/src/changelog.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/chat.php b/src/chat.php similarity index 92% rename from chat.php rename to src/chat.php index 16254dd..a10f64b 100644 --- a/chat.php +++ b/src/chat.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/chat_add.php b/src/chat_add.php similarity index 94% rename from chat_add.php rename to src/chat_add.php index f3f8c13..62381d4 100644 --- a/chat_add.php +++ b/src/chat_add.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify diff --git a/chat_msg.php b/src/chat_msg.php similarity index 94% rename from chat_msg.php rename to src/chat_msg.php index acb1bfa..7228440 100644 --- a/chat_msg.php +++ b/src/chat_msg.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -62,7 +62,7 @@ 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#","Wootook",$msg); + $msg=preg_replace("#xnova#","Wootook",$msg); // Affichage du message $msg="
    ".$nick." > ".$msg."
    "; diff --git a/contact.php b/src/contact.php similarity index 95% rename from contact.php rename to src/contact.php index 17fc8bf..437950c 100644 --- a/contact.php +++ b/src/contact.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify 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/fleet.php b/src/fleet.php similarity index 92% rename from fleet.php rename to src/fleet.php index abc968d..e43bc39 100644 --- a/fleet.php +++ b/src/fleet.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -31,6 +31,7 @@ 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); @@ -68,18 +69,18 @@ $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_Empire_Model_User::getSingleton(); +$user = Wootook_Player_Model_Session::getSingleton()->getPlayer(); $planet = $user->getCurrentPlanet(); $MaxFlyingFleets = $user->getFleetCount(); -if ($galaxy <= 0 || $galaxy > MAX_GALAXY_IN_WORLD) { +if ($galaxy <= 0 || $galaxy > Wootook::getGameConfig('engine/universe/galaxies')) { $galaxy = $planet['galaxy']; } -if ($system <= 0 || $system > MAX_SYSTEM_IN_GALAXY) { +if ($system <= 0 || $system > Wootook::getGameConfig('engine/universe/systems')) { $system = $planet['system']; } -if ($position <= 0 || $position > MAX_PLANET_IN_SYSTEM) { +if ($position <= 0 || $position > Wootook::getGameConfig('engine/universe/positions')) { $position = $planet['planet']; } @@ -228,12 +229,13 @@ if (!$planet) { $ShipData = ""; +$have_ships = false; foreach ($reslist['fleet'] as $n => $i) { - if ($planet[$resource[$i]] > 0) { + if ($planet->getElement($i) > 0) { $page .= ""; - $page .= "" . $lang['tech'][$i] . ""; - $page .= "". pretty_number ($planet[$resource[$i]]); - $ShipData .= ""; + $page .= "" . $labels[$i]['name'] . ""; + $page .= "". pretty_number ($planet->getElement($i)); + $ShipData .= "getElement($i) ."\" />"; $ShipData .= ""; $ShipData .= ""; $ShipData .= ""; @@ -243,11 +245,11 @@ foreach ($reslist['fleet'] as $n => $i) { $page .= ""; } else { $page .= "".$lang['fl_selmax']." "; - $page .= ""; + $page .= "getElement($i) ."\" onChange=\"shortInfo()\" onKeyUp=\"shortInfo()\" />"; } $page .= ""; + $have_ships = true; } - $have_ships = true; } $btncontinue = ""; 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/floten1.php b/src/floten1.php similarity index 86% rename from floten1.php rename to src/floten1.php index 42bb9c7..5c881a1 100644 --- a/floten1.php +++ b/src/floten1.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -46,7 +46,7 @@ $speed = array( 1 => 10, ); -$user = Wootook_Empire_Model_User::getSingleton(); +$user = Wootook_Player_Model_Session::getSingleton()->getPlayer(); $planetrow = $user->getCurrentPlanet(); $g = isset($_POST['galaxy']) ? intval($_POST['galaxy']) : 0; @@ -54,13 +54,13 @@ $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 > MAX_GALAXY_IN_WORLD) { +if ($g <= 0 || $g > Wootook::getGameConfig('engine/universe/galaxies')) { $g = $planetrow['galaxy']; } -if ($s <= 0 || $s > MAX_SYSTEM_IN_GALAXY) { +if ($s <= 0 || $s > Wootook::getGameConfig('engine/universe/systems')) { $s = $planetrow['system']; } -if ($p <= 0 || $p > MAX_PLANET_IN_SYSTEM) { +if ($p <= 0 || $p > Wootook::getGameConfig('engine/universe/positions')) { $p = $planetrow['planet']; } $allowedPlanetTypes = array( @@ -128,8 +128,8 @@ if (empty($fleetArray)) { $speedFactor = GetGameSpeedFactor(); $session['speedallsmin'] = $speedallsmin; -$scriptPath = Wootook::getUrl('scripts/flotten.js'); -$page .= ""; +$scriptPath = Wootook::getStaticUrl('scripts/flotten.js'); +$page = ""; $page .= ""; diff --git a/floten2.php b/src/floten2.php similarity index 80% rename from floten2.php rename to src/floten2.php index 367df96..1563070 100644 --- a/floten2.php +++ b/src/floten2.php @@ -3,9 +3,9 @@ * This file is part of Wootook * * @license http://www.gnu.org/licenses/gpl-3.0.txt - * @see http://www.wootook.com/ + * @see http://wootook.org/ * - * Copyright (c) 2009-Present, Wootook Support Team + * Copyright (c) 2009-Present, Wootook Support Team * All rights reserved. * * This program is free software: you can redistribute it and/or modify @@ -37,20 +37,20 @@ $session = Wootook::getSession('fleet'); $galaxy = isset($_POST['galaxy']) ? intval($_POST['galaxy']) : 0; $system = isset($_POST['system']) ? intval($_POST['system']) : 0; -$planet = isset($_POST['planet']) ? intval($_POST['planet']) : 0; -$planettype = isset($_POST['planettype']) ? intval($_POST['planettype']) : 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' => $planet + 'position' => $position ); -$destination = Wootook_Empire_Model_Planet::factoryFromCoords($coords, $planettype); +$destination = Wootook_Empire_Model_Planet::factoryFromCoords($coords, $planetType); $session['planet_destination'] = $destination->getId(); -$user = Wootook_Empire_Model_User::getSingleton(); -$planetrow = $user->getCurrentPlanet(); +$user = Wootook_Player_Model_Session::getSingleton()->getPlayer(); +$planet = $user->getCurrentPlanet(); $YourPlanet = false; if ($destination->getUserId() == $user->getId()) { @@ -62,22 +62,28 @@ if ($destination->getId()) { } $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 == (MAX_PLANET_IN_SYSTEM + 1)) { +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 ($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) { + } 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) { + } 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) { @@ -85,7 +91,7 @@ if ($position == (MAX_PLANET_IN_SYSTEM + 1)) { } } - if (in_array($planettype, array(Wootook_Empire_Model_Planet::TYPE_MOON, Wootook_Empire_Model_Planet::TYPE_PLANET))) { + 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]; } @@ -96,9 +102,8 @@ if ($position == (MAX_PLANET_IN_SYSTEM + 1)) { (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 && ALLOW_SPY_DRONE_ATTACKS) || + (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) || @@ -125,11 +130,11 @@ if (isset($fleetArray[Legacies_Empire::ID_SHIP_SOLAR_SATELLITE])) { $mission = isset($_POST['target_mission']) ? $_POST['target_mission'] : 0; -$SpeedFactor = GetGameSpeedFactor(); +$SpeedFactor = Wootook::getGameConfig('game/speed/general'); $AllFleetSpeed = GetFleetMaxSpeed($fleetArray, 0, $user); $MaxFleetSpeed = min($AllFleetSpeed); -$distance = GetTargetDistance($planetrow->getGalaxy(), $galaxy, $planetrow->getSystem(), $system, $planetrow->getPosition(), $planet); +$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 ); @@ -139,12 +144,12 @@ $session['consumption'] = $consumption; $session['speed'] = $speed; $session['galaxy'] = $galaxy; $session['system'] = $system; -$session['position'] = $planet; -$session['type'] = $planettype; +$session['position'] = $position; +$session['type'] = $planetType; $MissionSelector = ""; if (count($missionTypes) > 0) { - if ($planet == (MAX_PLANET_IN_SYSTEM + 1)) { + if ($position == (Wootook::getGameConfig('engine/universe/positions') + 1)) { $MissionSelector .= ""; $MissionSelector .= ""; $MissionSelector .= "". $lang['type_mission'][Legacies_Empire::ID_MISSION_EXPEDITION] ."

    "; @@ -171,27 +176,36 @@ if (count($missionTypes) > 0) { $MissionSelector .= ""; } -if ($planetrow->isPlanet()) { - $TableTitle = "{$planetrow->getCoords()} - {$lang['fl_planet']}"; -} elseif ($planetrow->isMoon()) { - $TableTitle = "{$planetrow->getCoords()} - {$lang['fl_moon']}"; +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) { - $maxexpde = doquery("SELECT 1 FROM {{table}} WHERE `fleet_owner` = '".$user['id']."' AND `fleet_mission` = '15';", 'fleets'); - $ExpeditionEnCours = $maxexpde->rowCount(); - $maxexpde->closeCursor(); + $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); + $EnvoiMaxExpedition = 1 + floor(sqrt($maxExpedition)); } -$maxfleet = doquery("SELECT 1 FROM {{table}} WHERE `fleet_owner` = '".$user['id']."';", 'fleets'); - -$MaxFlyingFleets = $maxfleet->rowCount(); -$maxfleet->closeCursor(); +$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 .= "