Compare commits

..
1596 changed files with 16616 additions and 35350 deletions

3
.gitignore vendored
View file

@ -2,7 +2,4 @@ config.php
.buildpath .buildpath
.project .project
.settings/ .settings/
.idea/
coverage/ coverage/
src/application/cache/*
src/application/configs/local.php

2
.htaccess Normal file
View file

@ -0,0 +1,2 @@
SetEnv DEBUG On
SetEnv DEPRECATION Off

68
add_declare.php Normal file
View file

@ -0,0 +1,68 @@
<?php
/**
* 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, Wootook Support Team <http://www.xnova-ng.org>
* 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 <http://www.gnu.org/licenses/>.
*
* --> NOTICE <--
* This file is part of the core development branch, changing its contents will
* make you unable to use the automatic updates manager. Please refer to the
* documentation for further information about customizing Wootook.
*
*/
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);
?>

View file

@ -3,9 +3,9 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/gpl-3.0.txt * @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.org> * Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved. * All rights reserved.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View file

@ -3,9 +3,9 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/gpl-3.0.txt * @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.org> * Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved. * All rights reserved.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View file

@ -3,9 +3,9 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/gpl-3.0.txt * @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.org> * Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved. * All rights reserved.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -33,15 +33,18 @@ define('INSTALL' , false);
define('IN_ADMIN', true); define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php'; require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
if (in_array($user['authlevel'], array(LEVEL_ADMIN))) { if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR, LEVEL_MODERATOR))) {
doquery("UPDATE {{table}} SET `banaday` =` banaday` - '1' WHERE `banaday` != '0';",'users'); includeLang('admin/fleets');
doquery("UPDATE {{table}} SET `bana` = '0' WHERE `banaday` < '1';",'users'); $PageTPL = gettemplate('admin/fleet_body');
$response = Wootook::getResponse() $parse = $lang;
->setRedirect(Wootook::getStaticUrl('admin/overview.php')) $parse['flt_table'] = BuildFlyingFleetTable ();
->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'] );
}
?>

View file

@ -3,9 +3,9 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/gpl-3.0.txt * @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.org> * Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved. * All rights reserved.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

66
admin/activeplanet.php Normal file
View file

@ -0,0 +1,66 @@
<?php
/**
* 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, Wootook Support Team <http://www.xnova-ng.org>
* 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 <http://www.gnu.org/licenses/>.
*
* --> NOTICE <--
* This file is part of the core development branch, changing its contents will
* make you unable to use the automatic updates manager. Please refer to the
* documentation for further information about customizing Wootook.
*
*/
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'] .= "<tr>";
$parse['online_list'] .= "<td class=b><center><b>". $ActivPlanet['name'] ."</b></center></td>";
$parse['online_list'] .= "<td class=b><center><b>[". $ActivPlanet['galaxy'] .":". $ActivPlanet['system'] .":". $ActivPlanet['planet'] ."]</b></center></td>";
$parse['online_list'] .= "<td class=m><center><b>". pretty_number($ActivPlanet['points'] / 1000) ."</b></center></td>";
$parse['online_list'] .= "<td class=b><center><b>". pretty_time(time() - $ActivPlanet['last_update']) . "</b></center></td>";
$parse['online_list'] .= "</tr>";
$Count++;
}
$parse['online_list'] .= "<tr>";
$parse['online_list'] .= "<th class=\"b\" colspan=\"4\">". $lang['adm_pl_they'] ." ". $Count ." ". $lang['adm_pl_apla'] ."</th>";
$parse['online_list'] .= "</tr>";
$page = parsetemplate( $PageTPL , $parse );
display( $page, $lang['adm_pl_title'], false, '', true );
} else {
message( $lang['sys_noalloaw'], $lang['sys_noaccess'] );
}
?>

101
admin/add_fleet.php Normal file
View file

@ -0,0 +1,101 @@
<?php
/**
* 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, Wootook Support Team <http://www.xnova-ng.org>
* 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 <http://www.gnu.org/licenses/>.
*
* --> NOTICE <--
* This file is part of the core development branch, changing its contents will
* make you unable to use the automatic updates manager. Please refer to the
* documentation for further information about customizing Wootook.
*
*/
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'] );
}
?>

67
admin/add_money.php Normal file
View file

@ -0,0 +1,67 @@
<?php
/**
* 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, Wootook Support Team <http://www.xnova-ng.org>
* 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 <http://www.gnu.org/licenses/>.
*
* --> NOTICE <--
* This file is part of the core development branch, changing its contents will
* make you unable to use the automatic updates manager. Please refer to the
* documentation for further information about customizing Wootook.
*
*/
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');
$mode = $_POST['mode'];
$PageTpl = gettemplate("admin/add_money");
$parse = $lang;
if ($mode == 'addit') {
$id = $_POST['id'];
$metal = $_POST['metal'];
$cristal = $_POST['cristal'];
$deut = $_POST['deut'];
$QryUpdatePlanet = "UPDATE {{table}} SET ";
$QryUpdatePlanet .= "`metal` = `metal` + '". $metal ."', ";
$QryUpdatePlanet .= "`crystal` = `crystal` + '". $cristal ."', ";
$QryUpdatePlanet .= "`deuterium` = `deuterium` + '". $deut ."' ";
$QryUpdatePlanet .= "WHERE ";
$QryUpdatePlanet .= "`id` = '". $id ."' ";
doquery( $QryUpdatePlanet, "planets");
AdminMessage ( $lang['adm_am_done'], $lang['adm_am_ttle'] );
}
$Page = parsetemplate($PageTpl, $parse);
display ($Page, $lang['adm_am_ttle'], false, '', true);
} else {
AdminMessage ( $lang['sys_noalloaw'], $lang['sys_noaccess'] );
}
?>

View file

@ -3,9 +3,9 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/gpl-3.0.txt * @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.org> * Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved. * All rights reserved.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View file

@ -3,9 +3,9 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/gpl-3.0.txt * @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.org> * Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved. * All rights reserved.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -33,18 +33,16 @@ define('INSTALL' , false);
define('IN_ADMIN', true); define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php'; require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
include(ROOT_PATH . 'includes/functions/BuildFlyingFleetTable.'.PHPEXT); 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'] );
}
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'] );
}

View file

@ -3,9 +3,9 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/gpl-3.0.txt * @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.org> * Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved. * All rights reserved.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View file

@ -3,9 +3,9 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/gpl-3.0.txt * @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.org> * Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved. * All rights reserved.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View file

@ -3,9 +3,9 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/gpl-3.0.txt * @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.org> * Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved. * All rights reserved.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View file

@ -3,9 +3,9 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/gpl-3.0.txt * @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.org> * Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved. * All rights reserved.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View file

@ -3,9 +3,9 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/gpl-3.0.txt * @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.org> * Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved. * All rights reserved.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -36,11 +36,7 @@ require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) { if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) {
includeLang('admin'); includeLang('admin');
if ($_GET['cmd'] == 'dele') { if ($_GET['cmd'] == 'dele') {
$player = new Wootook_Player_Model_Entity(); DeleteSelectedUser ( $_GET['user'] );
$player->load(intval($_GET['user']));
if ($player->getId()) {
$player->delete();
}
} }
if ($_GET['cmd'] == 'sort') { if ($_GET['cmd'] == 'sort') {
$TypeSort = $_GET['type']; $TypeSort = $_GET['type'];

View file

@ -3,9 +3,9 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/gpl-3.0.txt * @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.org> * Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved. * All rights reserved.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View file

@ -3,9 +3,9 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/gpl-3.0.txt * @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.org> * Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved. * All rights reserved.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View file

@ -3,9 +3,9 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/gpl-3.0.txt * @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.org> * Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved. * All rights reserved.
* *
* This program is free software: you can redistribute it and/or modify * 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'); includeLang('leftmenu');
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR, LEVEL_MODERATOR))) { if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR, LEVEL_MODERATOR))) {
$parse = $lang; $parse = $lang;
$parse['mf'] = "Hauptframe"; $parse['mf'] = "Hauptframe";
$parse['dpath'] = $dpath; $parse['dpath'] = $dpath;
$parse['WootookRelease'] = VERSION; $parse['WootookRelease'] = VERSION;
$parse['servername'] = 'Wootook'; $parse['servername'] = Wootook;
$Page = parsetemplate(gettemplate('admin/left_menu'), $parse); $Page = parsetemplate(gettemplate('admin/left_menu'), $parse);
display($Page, "", false, '', true); display( $Page, "", false, '', true);
} else { } else {
message( $lang['sys_noalloaw'], $lang['sys_noaccess'] ); message( $lang['sys_noalloaw'], $lang['sys_noaccess'] );
} }

66
admin/mass_message.php Normal file
View file

@ -0,0 +1,66 @@
<?php
/**
* 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, Wootook Support Team <http://www.xnova-ng.org>
* 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 <http://www.gnu.org/licenses/>.
*
* --> NOTICE <--
* This file is part of the core development branch, changing its contents will
* make you unable to use the automatic updates manager. Please refer to the
* documentation for further information about customizing Wootook.
*
*/
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`='<font color=\"$kolor\">Administracja</font>',
`message_subject`='<font color=\"$kolor\">{$gameConfig['temat']}</font>',
`message_text`='<font color=\"$kolor\"><b>{$gameConfig['tresc']}</b></font>'
","messages");
$parent->db->query("UPDATE {{table}} SET new_message=new_message+1 WHERE id='{$u['id']}'",'users');
}
$parent->smarty->assign("message","<font color=\"lime\">Wys<79>a<EFBFBD>e<EFBFBD> wiadomo<6D><6F> do wszystkich graczy</font>");
}
}
$parent->smarty->display("mass_message.tpl");
}
function mass_message_info(){
return array("name" => "Send MassMessages","description"=>"Sends messagess to all players","default_weight"=>"0");
}

View file

@ -3,9 +3,9 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/gpl-3.0.txt * @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.org> * Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved. * All rights reserved.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View file

@ -3,9 +3,9 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/gpl-3.0.txt * @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.org> * Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved. * All rights reserved.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View file

@ -3,9 +3,9 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/gpl-3.0.txt * @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.org> * Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved. * All rights reserved.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

75
admin/messall.php Normal file
View file

@ -0,0 +1,75 @@
<?php
/**
* 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, Wootook Support Team <http://www.xnova-ng.org>
* 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 <http://www.gnu.org/licenses/>.
*
* --> NOTICE <--
* This file is part of the core development branch, changing its contents will
* make you unable to use the automatic updates manager. Please refer to the
* documentation for further information about customizing Wootook.
*
*/
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 = "<font color=\"". $kolor ."\">". $ranga ." ".$user['username']."</font>";
$Subject = "<font color=\"". $kolor ."\">". $gameConfig['temat'] ."</font>";
$Message = "<font color=\"". $kolor ."\"><b>". $gameConfig['tresc'] ."</b></font>";
while ($u = $sq->fetch(PDO::FETCH_BOTH)) {
SendSimpleMessage ( $u['id'], $user['id'], $Time, 97, $From, $Subject, $Message);
}
message("<font color=\"lime\">Wys<79>a<EFBFBD>e<EFBFBD> wiadomo<6D><6F> do wszystkich graczy</font>", "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']);
}
?>

View file

@ -3,9 +3,9 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/gpl-3.0.txt * @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.org> * Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved. * All rights reserved.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View file

@ -3,9 +3,9 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/gpl-3.0.txt * @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.org> * Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved. * All rights reserved.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

116
admin/overview.php Normal file
View file

@ -0,0 +1,116 @@
<?php
/**
* 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, Wootook Support Team <http://www.xnova-ng.org>
* 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 <http://www.gnu.org/licenses/>.
*
* --> NOTICE <--
* This file is part of the core development branch, changing its contents will
* make you unable to use the automatic updates manager. Please refer to the
* documentation for further information about customizing Wootook.
*
*/
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<EFBFBD>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'] = "<img src=\"../images/true.png\" >";
} else {
$Bloc['state_vacancy'] = "<img src=\"../images/false.png\">";
}
if ($TheUser['bana'] == 1) {
$Bloc['is_banned'] = "<img src=\"../images/banned.png\" >";
} 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'] );
}
?>

View file

@ -3,9 +3,9 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/gpl-3.0.txt * @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.org> * Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved. * All rights reserved.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View file

@ -3,9 +3,9 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/gpl-3.0.txt * @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.org> * Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved. * All rights reserved.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

310
admin/settings.php Normal file
View file

@ -0,0 +1,310 @@
<?php
/**
* 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, Wootook Support Team <http://www.xnova-ng.org>
* 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 <http://www.gnu.org/licenses/>.
*
* --> NOTICE <--
* This file is part of the core development branch, changing its contents will
* make you unable to use the automatic updates manager. Please refer to the
* documentation for further information about customizing Wootook.
*
*/
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<72> !
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 );
?>

View file

@ -3,9 +3,9 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/gpl-3.0.txt * @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.org> * Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved. * All rights reserved.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -42,16 +42,14 @@ if (strtolower(substr(PHP_SAPI, 0, 3)) == 'cli' || in_array($user['authlevel'],
$StatDate = time(); $StatDate = time();
// Rotation des statistiques // Rotation des statistiques
doquery ( "DELETE FROM {{table}} WHERE `stat_code` >= '10';" , 'statpoints'); doquery ( "DELETE FROM {{table}} WHERE `stat_code` = '2';" , 'statpoints');
doquery ( "UPDATE {{table}} SET `stat_code` = `stat_code` + '1';" , 'statpoints'); doquery ( "UPDATE {{table}} SET `stat_code` = `stat_code` + '1';" , 'statpoints');
$GameUsers = doquery("SELECT * FROM {{table}} WHERE authlevel<3", 'users'); $GameUsers = doquery("SELECT * FROM {{table}} WHERE authlevel<3", 'users');
$resourceMultiplier = Wootook::getGameConfig('game/resource/multiplier');
while ($CurUser = $GameUsers->fetch(PDO::FETCH_ASSOC)) { while ($CurUser = $GameUsers->fetch(PDO::FETCH_ASSOC)) {
// Recuperation des anciennes statistiques // Recuperation des anciennes statistiques
$OldStatRecord = doquery ("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `id_owner` = '".$CurUser['id']."';", 'statpoints', true); $OldStatRecord = doquery ("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `id_owner` = '".$CurUser['id']."';",'statpoints');
if ($OldStatRecord) { if ($OldStatRecord) {
$OldTotalRank = $OldStatRecord['total_rank']; $OldTotalRank = $OldStatRecord['total_rank'];
$OldTechRank = $OldStatRecord['tech_rank']; $OldTechRank = $OldStatRecord['tech_rank'];
@ -71,7 +69,7 @@ if (strtolower(substr(PHP_SAPI, 0, 3)) == 'cli' || in_array($user['authlevel'],
// Total des unitées consommée pour la recherche // Total des unitées consommée pour la recherche
$Points = GetTechnoPoints ( $CurUser ); $Points = GetTechnoPoints ( $CurUser );
$TTechCount = $Points['TechCount']; $TTechCount = $Points['TechCount'];
$TTechPoints = ($Points['TechPoint'] / $resourceMultiplier); $TTechPoints = ($Points['TechPoint'] / $gameConfig['stat_settings']);
// Totalisation des points accumulés par planete // Totalisation des points accumulés par planete
$TBuildCount = 0; $TBuildCount = 0;
@ -83,24 +81,24 @@ if (strtolower(substr(PHP_SAPI, 0, 3)) == 'cli' || in_array($user['authlevel'],
$GCount = $TTechCount; $GCount = $TTechCount;
$GPoints = $TTechPoints; $GPoints = $TTechPoints;
$UsrPlanets = doquery("SELECT * FROM {{table}} WHERE `id_owner` = '". $CurUser['id'] ."';", 'planets'); $UsrPlanets = doquery("SELECT * FROM {{table}} WHERE `id_owner` = '". $CurUser['id'] ."';", 'planets');
while ($CurPlanet = $UsrPlanets->fetch(PDO::FETCH_ASSOC)) { while ($CurPlanet = mysql_fetch_assoc($UsrPlanets) ) {
$Points = GetBuildPoints ( $CurPlanet ); $Points = GetBuildPoints ( $CurPlanet );
$TBuildCount += $Points['BuildCount']; $TBuildCount += $Points['BuildCount'];
$GCount += $Points['BuildCount']; $GCount += $Points['BuildCount'];
$PlanetPoints = ($Points['BuildPoint'] / $resourceMultiplier); $PlanetPoints = ($Points['BuildPoint'] / $gameConfig['stat_settings']);
$TBuildPoints += ($Points['BuildPoint'] / $resourceMultiplier); $TBuildPoints += ($Points['BuildPoint'] / $gameConfig['stat_settings']);
$Points = GetDefensePoints ( $CurPlanet ); $Points = GetDefensePoints ( $CurPlanet );
$TDefsCount += $Points['DefenseCount'];; $TDefsCount += $Points['DefenseCount'];;
$GCount += $Points['DefenseCount']; $GCount += $Points['DefenseCount'];
$PlanetPoints += ($Points['DefensePoint'] / $resourceMultiplier); $PlanetPoints += ($Points['DefensePoint'] / $gameConfig['stat_settings']);
$TDefsPoints += ($Points['DefensePoint'] / $resourceMultiplier); $TDefsPoints += ($Points['DefensePoint'] / $gameConfig['stat_settings']);
$Points = GetFleetPoints ( $CurPlanet ); $Points = GetFleetPoints ( $CurPlanet );
$TFleetCount += $Points['FleetCount']; $TFleetCount += $Points['FleetCount'];
$GCount += $Points['FleetCount']; $GCount += $Points['FleetCount'];
$PlanetPoints += ($Points['FleetPoint'] / $resourceMultiplier); $PlanetPoints += ($Points['FleetPoint'] / $gameConfig['stat_settings']);
$TFleetPoints += ($Points['FleetPoint'] / $resourceMultiplier); $TFleetPoints += ($Points['FleetPoint'] / $gameConfig['stat_settings']);
$GPoints += $PlanetPoints; $GPoints += $PlanetPoints;
$QryUpdatePlanet = "UPDATE {{table}} SET "; $QryUpdatePlanet = "UPDATE {{table}} SET ";
@ -136,7 +134,7 @@ if (strtolower(substr(PHP_SAPI, 0, 3)) == 'cli' || in_array($user['authlevel'],
$Rank = 1; $Rank = 1;
$RankQry = doquery("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' ORDER BY `tech_points` DESC;", 'statpoints'); $RankQry = doquery("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' ORDER BY `tech_points` DESC;", 'statpoints');
while ($TheRank = $RankQry->fetch(PDO::FETCH_ASSOC)) { while ($TheRank = mysql_fetch_assoc($RankQry) ) {
$QryUpdateStats = "UPDATE {{table}} SET "; $QryUpdateStats = "UPDATE {{table}} SET ";
$QryUpdateStats .= "`tech_rank` = '". $Rank ."' "; $QryUpdateStats .= "`tech_rank` = '". $Rank ."' ";
$QryUpdateStats .= "WHERE "; $QryUpdateStats .= "WHERE ";
@ -147,7 +145,7 @@ if (strtolower(substr(PHP_SAPI, 0, 3)) == 'cli' || in_array($user['authlevel'],
$Rank = 1; $Rank = 1;
$RankQry = doquery("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' ORDER BY `build_points` DESC;", 'statpoints'); $RankQry = doquery("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' ORDER BY `build_points` DESC;", 'statpoints');
while ($TheRank = $RankQry->fetch(PDO::FETCH_ASSOC) ) { while ($TheRank = mysql_fetch_assoc($RankQry) ) {
$QryUpdateStats = "UPDATE {{table}} SET "; $QryUpdateStats = "UPDATE {{table}} SET ";
$QryUpdateStats .= "`build_rank` = '". $Rank ."' "; $QryUpdateStats .= "`build_rank` = '". $Rank ."' ";
$QryUpdateStats .= "WHERE "; $QryUpdateStats .= "WHERE ";
@ -158,7 +156,7 @@ if (strtolower(substr(PHP_SAPI, 0, 3)) == 'cli' || in_array($user['authlevel'],
$Rank = 1; $Rank = 1;
$RankQry = doquery("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' ORDER BY `defs_points` DESC;", 'statpoints'); $RankQry = doquery("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' ORDER BY `defs_points` DESC;", 'statpoints');
while ($TheRank = $RankQry->fetch(PDO::FETCH_ASSOC)) { while ($TheRank = mysql_fetch_assoc($RankQry) ) {
$QryUpdateStats = "UPDATE {{table}} SET "; $QryUpdateStats = "UPDATE {{table}} SET ";
$QryUpdateStats .= "`defs_rank` = '". $Rank ."' "; $QryUpdateStats .= "`defs_rank` = '". $Rank ."' ";
$QryUpdateStats .= "WHERE "; $QryUpdateStats .= "WHERE ";
@ -169,7 +167,7 @@ if (strtolower(substr(PHP_SAPI, 0, 3)) == 'cli' || in_array($user['authlevel'],
$Rank = 1; $Rank = 1;
$RankQry = doquery("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' ORDER BY `fleet_points` DESC;", 'statpoints'); $RankQry = doquery("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' ORDER BY `fleet_points` DESC;", 'statpoints');
while ($TheRank = $RankQry->fetch(PDO::FETCH_ASSOC)) { while ($TheRank = mysql_fetch_assoc($RankQry) ) {
$QryUpdateStats = "UPDATE {{table}} SET "; $QryUpdateStats = "UPDATE {{table}} SET ";
$QryUpdateStats .= "`fleet_rank` = '". $Rank ."' "; $QryUpdateStats .= "`fleet_rank` = '". $Rank ."' ";
$QryUpdateStats .= "WHERE "; $QryUpdateStats .= "WHERE ";
@ -180,7 +178,7 @@ if (strtolower(substr(PHP_SAPI, 0, 3)) == 'cli' || in_array($user['authlevel'],
$Rank = 1; $Rank = 1;
$RankQry = doquery("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' ORDER BY `total_points` DESC;", 'statpoints'); $RankQry = doquery("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' ORDER BY `total_points` DESC;", 'statpoints');
while ($TheRank = $RankQry->fetch(PDO::FETCH_ASSOC)) { while ($TheRank = mysql_fetch_assoc($RankQry) ) {
$QryUpdateStats = "UPDATE {{table}} SET "; $QryUpdateStats = "UPDATE {{table}} SET ";
$QryUpdateStats .= "`total_rank` = '". $Rank ."' "; $QryUpdateStats .= "`total_rank` = '". $Rank ."' ";
$QryUpdateStats .= "WHERE "; $QryUpdateStats .= "WHERE ";
@ -194,7 +192,7 @@ if (strtolower(substr(PHP_SAPI, 0, 3)) == 'cli' || in_array($user['authlevel'],
while ($CurAlly = $GameAllys->fetch(PDO::FETCH_ASSOC)) { while ($CurAlly = $GameAllys->fetch(PDO::FETCH_ASSOC)) {
// Recuperation des anciennes statistiques // Recuperation des anciennes statistiques
$OldStatRecord = doquery ("SELECT * FROM {{table}} WHERE `stat_type` = '2' AND `id_owner` = '".$CurAlly['id']."';",'statpoints', true); $OldStatRecord = doquery ("SELECT * FROM {{table}} WHERE `stat_type` = '2' AND `id_owner` = '".$CurAlly['id']."';",'statpoints');
if ($OldStatRecord) { if ($OldStatRecord) {
$OldTotalRank = $OldStatRecord['total_rank']; $OldTotalRank = $OldStatRecord['total_rank'];
$OldTechRank = $OldStatRecord['tech_rank']; $OldTechRank = $OldStatRecord['tech_rank'];

View file

@ -3,9 +3,9 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/gpl-3.0.txt * @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.org> * Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved. * All rights reserved.
* *
* This program is free software: you can redistribute it and/or modify * 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 ) { foreach ( $reslist['tech'] as $n => $Techno ) {
if ( $CurrentUser[ $resource[ $Techno ] ] > 0 ) { if ( $CurrentUser[ $resource[ $Techno ] ] > 0 ) {
for ( $Level = 1; $Level < $CurrentUser[ $resource[ $Techno ] ]; $Level++ ) { for ( $Level = 1; $Level < $CurrentUser[ $resource[ $Techno ] ]; $Level++ ) {
$Units = $pricelist[ $Techno ]['metal'] + $pricelist[ $Techno ]['cristal'] + $pricelist[ $Techno ]['deuterium']; $Units = $pricelist[ $Techno ]['metal'] + $pricelist[ $Techno ]['crystal'] + $pricelist[ $Techno ]['deuterium'];
$LevelMul = pow( $pricelist[ $Techno ]['factor'], $Level ); $LevelMul = pow( $pricelist[ $Techno ]['factor'], $Level );
$TechPoints += ($Units * $LevelMul); $TechPoints += ($Units * $LevelMul);
$TechCounts += 1; $TechCounts += 1;
@ -57,7 +57,7 @@ function GetBuildPoints ( $CurrentPlanet ) {
foreach($reslist['build'] as $n => $Building) { foreach($reslist['build'] as $n => $Building) {
if ( $CurrentPlanet[ $resource[ $Building ] ] > 0 ) { if ( $CurrentPlanet[ $resource[ $Building ] ] > 0 ) {
for ( $Level = 1; $Level < $CurrentPlanet[ $resource[ $Building ] ]; $Level++ ) { for ( $Level = 1; $Level < $CurrentPlanet[ $resource[ $Building ] ]; $Level++ ) {
$Units = $pricelist[ $Building ]['metal'] + $pricelist[ $Building ]['cristal'] + $pricelist[ $Building ]['deuterium']; $Units = $pricelist[ $Building ]['metal'] + $pricelist[ $Building ]['crystal'] + $pricelist[ $Building ]['deuterium'];
$LevelMul = pow( $pricelist[ $Building ]['factor'], $Level ); $LevelMul = pow( $pricelist[ $Building ]['factor'], $Level );
$BuildPoints += ($Units * $LevelMul); $BuildPoints += ($Units * $LevelMul);
$BuildCounts += 1; $BuildCounts += 1;
@ -77,7 +77,7 @@ function GetDefensePoints ( $CurrentPlanet ) {
$DefensePoints = 0; $DefensePoints = 0;
foreach($reslist['defense'] as $n => $Defense) { foreach($reslist['defense'] as $n => $Defense) {
if ($CurrentPlanet[ $resource[ $Defense ] ] > 0) { if ($CurrentPlanet[ $resource[ $Defense ] ] > 0) {
$Units = $pricelist[ $Defense ]['metal'] + $pricelist[ $Defense ]['cristal'] + $pricelist[ $Defense ]['deuterium']; $Units = $pricelist[ $Defense ]['metal'] + $pricelist[ $Defense ]['crystal'] + $pricelist[ $Defense ]['deuterium'];
$DefensePoints += ($Units * $CurrentPlanet[ $resource[ $Defense ] ]); $DefensePoints += ($Units * $CurrentPlanet[ $resource[ $Defense ] ]);
$DefenseCounts += $CurrentPlanet[ $resource[ $Defense ] ]; $DefenseCounts += $CurrentPlanet[ $resource[ $Defense ] ];
} }
@ -95,7 +95,7 @@ function GetFleetPoints ( $CurrentPlanet ) {
$FleetPoints = 0; $FleetPoints = 0;
foreach($reslist['fleet'] as $n => $Fleet) { foreach($reslist['fleet'] as $n => $Fleet) {
if ($CurrentPlanet[ $resource[ $Fleet ] ] > 0) { if ($CurrentPlanet[ $resource[ $Fleet ] ] > 0) {
$Units = $pricelist[ $Fleet ]['metal'] + $pricelist[ $Fleet ]['cristal'] + $pricelist[ $Fleet ]['deuterium']; $Units = $pricelist[ $Fleet ]['metal'] + $pricelist[ $Fleet ]['crystal'] + $pricelist[ $Fleet ]['deuterium'];
$FleetPoints += ($Units * $CurrentPlanet[ $resource[ $Fleet ] ]); $FleetPoints += ($Units * $CurrentPlanet[ $resource[ $Fleet ] ]);
$FleetCounts += $CurrentPlanet[ $resource[ $Fleet ] ]; $FleetCounts += $CurrentPlanet[ $resource[ $Fleet ] ];
} }

View file

@ -3,9 +3,9 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/gpl-3.0.txt * @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.org> * Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved. * All rights reserved.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View file

@ -3,9 +3,9 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/gpl-3.0.txt * @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.org> * Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved. * All rights reserved.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -36,11 +36,7 @@ require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) { if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) {
includeLang('admin'); includeLang('admin');
if ($_GET['cmd'] == 'dele') { if ($_GET['cmd'] == 'dele') {
$player = new Wootook_Player_Model_Entity(); DeleteSelectedUser ( $_GET['user'] );
$player->load(intval($_GET['user']));
if ($player->getId()) {
$player->delete();
}
} }
if ($_GET['cmd'] == 'sort') { if ($_GET['cmd'] == 'sort') {
$TypeSort = $_GET['type']; $TypeSort = $_GET['type'];

View file

@ -3,9 +3,9 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/gpl-3.0.txt * @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.org> * Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved. * All rights reserved.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

70
ainfo.php Normal file
View file

@ -0,0 +1,70 @@
<?php
/**
* 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, Wootook Support Team <http://www.xnova-ng.org>
* 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 <http://www.gnu.org/licenses/>.
*
* --> NOTICE <--
* This file is part of the core development branch, changing its contents will
* make you unable to use the automatic updates manager. Please refer to the
* documentation for further information about customizing Wootook.
*
*/
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&uuml;ltige Allianz-ID","Fehler");}
$allyrow = doquery("SELECT ally_name,ally_tag,ally_description,ally_web,ally_image FROM {{table}} WHERE id=".$_GET["a"],"alliance",true);
if(!$allyrow){ message("Alliance non trouv&eacute;e","Erreur");}
$count = doquery("SELECT COUNT(DISTINCT(id)) FROM {{table}} WHERE ally_id=".$_GET["a"].";","users",true);
$ally_member_scount = $count[0];
$page .="<table width=519><tr><td class=c colspan=2>Informations sur l'alliance</td></tr>";
if($allyrow["ally_image"] != ""){
$page .= "<tr><th colspan=2><img src=\"".$allyrow["ally_image"]."\"></td></tr>";
}
$page .= "<tr><th>Tag</th><th>".$allyrow["ally_tag"]."</th></tr><tr><th>Nom</th><th>".$allyrow["ally_name"]."</th></tr><tr><th>Membres</th><th>$ally_member_scount</th></tr>";
if($allyrow["ally_description"] != ""){
$page .= "<tr><th colspan=2 height=100>".$allyrow["ally_description"]."</th></tr>";
}
if($allyrow["ally_web"] != ""){
$page .="<tr>
<th>Site internet</th>
<th><a href=\"".$allyrow["ally_web"]."\">".$allyrow["ally_web"]."</a></th>
</tr>";
}
$page .= "</table>";
display($page,"Information sur l'alliance [".$allyrow["ally_name"]."]",false);
?>

View file

@ -3,9 +3,9 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/gpl-3.0.txt * @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.org> * Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved. * All rights reserved.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -32,8 +32,8 @@ define('INSTALL' , false);
define('INSIDE' , true); define('INSIDE' , true);
require_once dirname(__FILE__) .'/application/bootstrap.php'; require_once dirname(__FILE__) .'/application/bootstrap.php';
$user = Wootook_Player_Model_Session::getSingleton()->getPlayer(); $user = Wootook_Empire_Model_User::getSingleton();
$db = Wootook_Core_Database_ConnectionManager::getSingleton()->getConnection(Wootook_Core_Database_ConnectionManager::DEFAULT_CONNECTION_NAME); $db = Wootook_Database::getSingleton();
if(!$user->getId()){ if(!$user->getId()){
echo '<script language="javascript">'; echo '<script language="javascript">';
@ -41,31 +41,30 @@ echo 'parent.location="../";';
echo '</script>'; echo '</script>';
} }
$request = Wootook::getRequest(); $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;
$mode = $request->getQuery('mode'); $_POST['id'] = isset($_POST['id']) ? $_POST['id'] : null;
$yes = $request->getQuery('yes'); $_POST['t'] = isset($_POST['t']) ? $_POST['t'] : null;
$edit = $request->getQuery('edit'); $_POST['options'] = isset($_POST['options']) ? $_POST['options'] : null;
$allyid = intval($request->getQuery('allyid')); $_POST['action'] = isset($_POST['action']) ? $_POST['action'] : null;
$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'); includeLang('alliance');
/** /**
*Alliance information display. *Alliance information display.
*/ */
@ -74,9 +73,9 @@ if ($mode == 'ainfo') {
$lang['Alliance_information'] = "Information Alliance"; $lang['Alliance_information'] = "Information Alliance";
if ($tag) { if ($tag) {
$allyrow = doquery("SELECT * FROM {{table}} WHERE ally_tag={$db->quote($tag)}", "alliance", true); $allyrow = doquery("SELECT * FROM {{table}} WHERE ally_tag={$tag}", "alliance", true);
} elseif (is_numeric($allianceId) && $allianceId != 0) { } elseif (is_numeric($a) && $a != 0) {
$allyrow = doquery("SELECT * FROM {{table}} WHERE id='{$allianceId}'", "alliance", true); $allyrow = doquery("SELECT * FROM {{table}} WHERE id='{$a}'", "alliance", true);
} else { } else {
message("Cette alliance n'existe pas !", "Information Alliance (1)"); message("Cette alliance n'existe pas !", "Information Alliance (1)");
} }
@ -139,17 +138,17 @@ if ($user->getData('ally_id') == 0) {
/* /*
* Creation of the alliance * Creation of the alliance
*/ */
if ($yes == 1 && $request->isPost()) { if ($yes == 1 && isset($_POST)) {
if ($request->getPost('atag') !== null) { if (empty($_POST['atag'])) {
message($lang['have_not_tag'], $lang['make_alliance']); message($lang['have_not_tag'], $lang['make_alliance']);
} }
if ($request->getPost('aname') !== null) { if (empty($_POST['aname'])) {
message($lang['have_not_name'], $lang['make_alliance']); message($lang['have_not_name'], $lang['make_alliance']);
} }
$alliance_name = $db->quote($request->getPost('aname')); $alliance_name = $db->quote($_POST['aname']);
$alliance_tag = $db->quote($request->getPost('atag')); $alliance_tag = $db->quote($_POST['atag']);
$tagquery = doquery("SELECT * FROM {{table}} WHERE ally_tag=" .$alliance_tag. ";", 'alliance', true); $tagquery = doquery("SELECT * FROM {{table}} WHERE ally_tag=" .$alliance_tag. ";", 'alliance', true);
@ -157,7 +156,7 @@ if ($user->getData('ally_id') == 0) {
message(str_replace('%s', $alliance_tag, $lang['always_exist']), $lang['make_alliance']); message(str_replace('%s', $alliance_tag, $lang['always_exist']), $lang['make_alliance']);
} }
$ranks = ''; $ranks = '';
$allianz_raenge[] = array('name' => 'Novice', $allianz_raenge[] = array('name' => 'Novice',
'mails' => 0, 'mails' => 0,
'delete' => 0, 'delete' => 0,
'kick' => 0, 'kick' => 0,
@ -176,7 +175,7 @@ if ($user->getData('ally_id') == 0) {
`ally_tag`=" . $alliance_tag . " , `ally_tag`=" . $alliance_tag . " ,
`ally_owner`='" .$user->getId(). "', `ally_owner`='" .$user->getId(). "',
`ally_owner_range`='Leader', `ally_owner_range`='Leader',
`ally_ranks`='" . $ranks . "', `ally_ranks`='" . $ranks . "',
`ally_members`='1', `ally_members`='1',
`ally_register_time`=" . time() , "alliance"); `ally_register_time`=" . time() , "alliance");
@ -201,11 +200,11 @@ if ($user->getData('ally_id') == 0) {
if ($mode == 'search' && $user->getData('ally_request') == 0) { if ($mode == 'search' && $user->getData('ally_request') == 0) {
$parse = $lang; $parse = $lang;
$search_text = $request->getPost('searchtext'); $search_text = isset($_POST['searchtext']) ? $_POST['searchtext'] : null;
$lang['searchtext'] = $search_text; $lang['searchtext'] = $search_text;
$page = parsetemplate(gettemplate('alliance_searchform'), $lang); $page = parsetemplate(gettemplate('alliance_searchform'), $lang);
if ($request->getPost('searchtext') !== null) { if (isset($_POST['searchtext'])) {
$stmt = $db->prepare("SELECT * FROM {$db->getTable('alliance')} WHERE ally_name LIKE :search_field OR ally_tag LIKE :search_field LIMIT 30"); $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. '%')); $stmt->execute(array(':search_field' => '%' .$search_text. '%'));
if ($stmt->rowCount() != 0) { if ($stmt->rowCount() != 0) {
@ -245,8 +244,8 @@ if ($user->getData('ally_id') == 0) {
extract($allyrow); extract($allyrow);
if ($request->getPost('further') !== null && $request->getPost('further') == $lang['Send']) { if (isset($_POST['further']) && $_POST['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"); doquery("UPDATE {{table}} SET `ally_request`='" . $allyid . "', ally_request_text=" . $db->quote($_POST['text']) . ", ally_register_time='" . time() . "' WHERE `id`='" . $user->getId(). "'", "users");
message($lang['apply_registered'], $lang['your_apply']); message($lang['apply_registered'], $lang['your_apply']);
} else { } else {
$text_apply = ($ally_request) ? $ally_request : $lang['There_is_no_a_text_apply']; $text_apply = ($ally_request) ? $ally_request : $lang['There_is_no_a_text_apply'];
@ -270,7 +269,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); $allyquery = doquery("SELECT ally_tag FROM {{table}} WHERE id='" . $user->getData('ally_request') . "' ORDER BY `id`", "alliance", true);
extract($allyquery); extract($allyquery);
if ($request->getPost('bcancel') !== null) { if (isset($_POST['bcancel'])) {
doquery("UPDATE {{table}} SET `ally_request`=0 WHERE `id`=" . $user->getId('id'), "users"); 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']); $lang['request_text'] = str_replace('%s', $ally_tag, $lang['Canceled_a_request_text']);
@ -395,9 +394,9 @@ elseif ($user->getData('ally_id') != 0 && $user->getData('ally_request') == 0) {
message($lang['Denied_access'], $lang['Members_list']); message($lang['Denied_access'], $lang['Members_list']);
} }
// Order of displaying the different users // Order of displaying the different users
$sort2 = intval($request->getQuery('sort2')); $sort2 = isset($_GET['sort2']) ? intval($_GET['sort2']) : null;
if ($sort2) { if ($sort2) {
$sort1 = intval($request->getQuery('sort1')); $sort1 = isset($_GET['sort1']) ? intval($_GET['sort1']) : null;
switch($sort1){ switch($sort1){
case 1: case 1:
$sort = " ORDER BY `username`"; $sort = " ORDER BY `username`";
@ -507,9 +506,9 @@ elseif ($user->getData('ally_id') != 0 && $user->getData('ally_request') == 0) {
} }
if ($sendmail == 1) { if ($sendmail == 1) {
if ($request->getPost('r') !== null && is_numeric($request->getPost('r'))){ if (isset($_POST['r']) && is_numeric($_POST['r'])){
$group_rank = intval($request->getPost('r')); $group_rank = intval($_POST['r']);
$message_text = $db->quote($request->getPost('text')); $message_text = $db->quote($_POST['text']);
if ($group_rang == 0) { if ($group_rang == 0) {
$sq = doquery("SELECT id,username FROM {{table}} WHERE ally_id='{$user['ally_id']}'", "users"); $sq = doquery("SELECT id,username FROM {{table}} WHERE ally_id='{$user['ally_id']}'", "users");
} else { } else {
@ -559,8 +558,8 @@ elseif ($user->getData('ally_id') != 0 && $user->getData('ally_request') == 0) {
if ($ally['ally_owner'] != $user->getId() && !$user_can_edit_rights) { if ($ally['ally_owner'] != $user->getId() && !$user_can_edit_rights) {
message($lang['Denied_access'], $lang['Members_list']); message($lang['Denied_access'], $lang['Members_list']);
} else if ($request->getPost('newrangname') != '') { } elseif (!empty($_POST['newrangname'])) {
$name = strip_tags($request->getPost('newrangname')); $name = strip_tags($_POST['newrangname']);
$allianz_raenge[] = array('name' => $name, $allianz_raenge[] = array('name' => $name,
'mails' => 0, 'mails' => 0,
@ -582,63 +581,63 @@ elseif ($user->getData('ally_id') != 0 && $user->getData('ally_request') == 0) {
header("Location: " . $goto); header("Location: " . $goto);
exit(); exit();
} elseif (is_array($allianceIds) && !empty($allianceIds)) { } elseif ($_POST['id'] != '' && is_array($_POST['id'])) {
$ally_ranks_new = array(); $ally_ranks_new = array();
foreach ($allianceIds as $id) { foreach ($_POST['id'] as $id) {
$name = $allianz_raenge[$id]['name']; $name = $allianz_raenge[$id]['name'];
$ally_ranks_new[$id]['name'] = $name; $ally_ranks_new[$id]['name'] = $name;
if ($request->getPost('u' . $id . 'r0') !== null) { if (isset($_POST['u' . $id . 'r0'])) {
$ally_ranks_new[$id]['delete'] = 1; $ally_ranks_new[$id]['delete'] = 1;
} else { } else {
$ally_ranks_new[$id]['delete'] = 0; $ally_ranks_new[$id]['delete'] = 0;
} }
if ($request->getPost('u' . $id . 'r1') !== null && $ally['ally_owner'] == $user->getId()) { if (isset($_POST['u' . $id . 'r1']) && $ally['ally_owner'] == $user->getId()) {
$ally_ranks_new[$id]['kick'] = 1; $ally_ranks_new[$id]['kick'] = 1;
} else { } else {
$ally_ranks_new[$id]['kick'] = 0; $ally_ranks_new[$id]['kick'] = 0;
} }
if ($request->getPost('u' . $id . 'r2') !== null) { if (isset($_POST['u' . $id . 'r2'])) {
$ally_ranks_new[$id]['bewerbungen'] = 1; $ally_ranks_new[$id]['bewerbungen'] = 1;
} else { } else {
$ally_ranks_new[$id]['bewerbungen'] = 0; $ally_ranks_new[$id]['bewerbungen'] = 0;
} }
if ($request->getPost('u' . $id . 'r3') !== null) { if (isset($_POST['u' . $id . 'r3'])) {
$ally_ranks_new[$id]['memberlist'] = 1; $ally_ranks_new[$id]['memberlist'] = 1;
} else { } else {
$ally_ranks_new[$id]['memberlist'] = 0; $ally_ranks_new[$id]['memberlist'] = 0;
} }
if ($request->getPost('u' . $id . 'r4') !== null) { if (isset($_POST['u' . $id . 'r4'])) {
$ally_ranks_new[$id]['bewerbungenbearbeiten'] = 1; $ally_ranks_new[$id]['bewerbungenbearbeiten'] = 1;
} else { } else {
$ally_ranks_new[$id]['bewerbungenbearbeiten'] = 0; $ally_ranks_new[$id]['bewerbungenbearbeiten'] = 0;
} }
if ($request->getPost('u' . $id . 'r5') !== null) { if (isset($_POST['u' . $id . 'r5'])) {
$ally_ranks_new[$id]['administrieren'] = 1; $ally_ranks_new[$id]['administrieren'] = 1;
} else { } else {
$ally_ranks_new[$id]['administrieren'] = 0; $ally_ranks_new[$id]['administrieren'] = 0;
} }
if ($request->getPost('u' . $id . 'r6') !== null) { if (isset($_POST['u' . $id . 'r6'])) {
$ally_ranks_new[$id]['onlinestatus'] = 1; $ally_ranks_new[$id]['onlinestatus'] = 1;
} else { } else {
$ally_ranks_new[$id]['onlinestatus'] = 0; $ally_ranks_new[$id]['onlinestatus'] = 0;
} }
if ($request->getPost('u' . $id . 'r7') !== null) { if (isset($_POST['u' . $id . 'r7'])) {
$ally_ranks_new[$id]['mails'] = 1; $ally_ranks_new[$id]['mails'] = 1;
} else { } else {
$ally_ranks_new[$id]['mails'] = 0; $ally_ranks_new[$id]['mails'] = 0;
} }
if ($request->getPost('u' . $id . 'r8') !== null) { if (isset($_POST['u' . $id . 'r8'])) {
$ally_ranks_new[$id]['rechtehand'] = 1; $ally_ranks_new[$id]['rechtehand'] = 1;
} else { } else {
$ally_ranks_new[$id]['rechtehand'] = 0; $ally_ranks_new[$id]['rechtehand'] = 0;
@ -672,6 +671,7 @@ elseif ($user->getData('ally_id') != 0 && $user->getData('ally_request') == 0) {
foreach($ally_ranks as $a => $b) { foreach($ally_ranks as $a => $b) {
if ($ally['ally_owner'] == $user->getId()) { if ($ally['ally_owner'] == $user->getId()) {
$lang['id'] = $a; $lang['id'] = $a;
$lang['delete'] = "<a href=\"alliance.php?mode=admin&edit=rights&d={$a}\"><img src=\"../pic/abort.gif\" alt=\"{$lang['Delete_range']}\" border=0></a>";
$lang['r0'] = $b['name']; $lang['r0'] = $b['name'];
$lang['a'] = $a; $lang['a'] = $a;
$lang['r1'] = "<input type=checkbox name=\"u{$a}r0\"" . (($b['delete'] == 1)?' checked="checked"':'') . ">"; //{$b[1]} $lang['r1'] = "<input type=checkbox name=\"u{$a}r0\"" . (($b['delete'] == 1)?' checked="checked"':'') . ">"; //{$b[1]}
@ -688,6 +688,7 @@ elseif ($user->getData('ally_id') != 0 && $user->getData('ally_request') == 0) {
} else { } else {
$lang['id'] = $a; $lang['id'] = $a;
$lang['r0'] = $b['name']; $lang['r0'] = $b['name'];
$lang['delete'] = "<a href=\"alliance.php?mode=admin&edit=rights&d={$a}\"><img src=\"./pic/abort.gif\" alt=\"{$lang['Delete_range']}\" border=0></a>";
$lang['a'] = $a; $lang['a'] = $a;
$lang['r1'] = "<b>-</b>"; $lang['r1'] = "<b>-</b>";
$lang['r2'] = "<input type=checkbox name=\"u{$a}r1\"" . (($b['kick'] == 1)?' checked="checked"':'') . ">"; $lang['r2'] = "<input type=checkbox name=\"u{$a}r1\"" . (($b['kick'] == 1)?' checked="checked"':'') . ">";
@ -720,18 +721,24 @@ elseif ($user->getData('ally_id') != 0 && $user->getData('ally_request') == 0) {
if ($t != 1 && $t != 2 && $t != 3) { if ($t != 1 && $t != 2 && $t != 3) {
$t = 1; $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 ($options) { if ($_POST['options']) {
$ally['ally_owner_range'] = htmlspecialchars(strip_tags($request->getPost('owner_range'))); $ally['ally_owner_range'] = htmlspecialchars(strip_tags($_POST['owner_range']));
$ally['ally_web'] = htmlspecialchars(strip_tags($request->getPost('web'))); $ally['ally_web'] = htmlspecialchars(strip_tags($_POST['web']));
$ally['ally_image'] = htmlspecialchars(strip_tags($request->getPost('image'))); $ally['ally_image'] = htmlspecialchars(strip_tags($_POST['image']));
$ally['ally_request_notallow'] = intval($request->getPost('request_notallow')); $ally['ally_request_notallow'] = intval($_POST['request_notallow']);
if ($ally['ally_request_notallow'] != 0 && $ally['ally_request_notallow'] != 1) { 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; exit;
} }
@ -741,20 +748,20 @@ elseif ($user->getData('ally_id') != 0 && $user->getData('ally_request') == 0) {
`ally_web`={$db->quote($ally['ally_web'])}, `ally_web`={$db->quote($ally['ally_web'])},
`ally_request_notallow`='{$ally['ally_request_notallow']}' `ally_request_notallow`='{$ally['ally_request_notallow']}'
WHERE `id`='{$ally['id']}'", "alliance"); WHERE `id`='{$ally['id']}'", "alliance");
} elseif ($actionType) { } elseif ($_POST['t']) {
if ($t == 3) { if ($t == 3) {
$ally['ally_request'] = strip_tags($request->getPost('text')); $ally['ally_request'] = strip_tags($_POST['text']);
doquery("UPDATE {{table}} SET doquery("UPDATE {{table}} SET
`ally_request`={$db->quote($ally['ally_request'])} `ally_request`={$db->quote($ally['ally_request'])}
WHERE `id`='{$ally['id']}'", "alliance"); WHERE `id`='{$ally['id']}'", "alliance");
} elseif ($t == 2) { } elseif ($t == 2) {
$ally['ally_text'] = strip_tags($request->getPost('text')); $ally['ally_text'] = strip_tags($_POST['text']);
doquery("UPDATE {{table}} SET doquery("UPDATE {{table}} SET
`ally_text`={$db->quote($ally['ally_text'])} `ally_text`={$db->quote($ally['ally_text'])}
WHERE `id`='{$ally['id']}'", "alliance"); WHERE `id`='{$ally['id']}'", "alliance");
} else { } else {
$ally['ally_description'] = strip_tags($request->getPost('text')); $ally['ally_description'] = strip_tags($_POST['text']);
doquery("UPDATE {{table}} SET doquery("UPDATE {{table}} SET
`ally_description`=" . $db->quote($ally['ally_description']) . " `ally_description`=" . $db->quote($ally['ally_description']) . "
@ -801,8 +808,8 @@ elseif ($user->getData('ally_id') != 0 && $user->getData('ally_request') == 0) {
} }
if ($mode == 'admin' && $edit == 'give') { if ($mode == 'admin' && $edit == 'give') {
if ($request->getPost('id')) { if ($_POST["id"]) {
doquery("update {{table}} set `ally_owner`=".$db->quote($request->getPost('id'))." where `id`='".$user['ally_id']."'",'alliance'); doquery("update {{table}} set `ally_owner`=".$db->quote($_POST["id"])." where `id`='".$user['ally_id']."'",'alliance');
} else { } else {
$selection=doquery("SELECT * FROM {{table}} where ally_id='".$user['ally_id']."'",'users'); $selection=doquery("SELECT * FROM {{table}} where ally_id='".$user['ally_id']."'",'users');
$select=''; $select='';
@ -841,12 +848,12 @@ elseif ($user->getData('ally_id') != 0 && $user->getData('ally_request') == 0) {
if ($u['ally_id'] == $ally['id'] && $u['id'] != $ally['ally_owner']) { 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'); doquery("UPDATE {{table}} SET `ally_id`='0', `ally_name`='', `ally_rank_id` = '0' WHERE `id`='{$u['id']}'", 'users');
} }
} else if ($request->getPost('newrang') !== null) { } elseif (isset($_POST['newrang'])) {
$newrank = $request->getPost('newrang'); $newrank = isset($_POST['newrang']) ? intval($_POST['newrang']) : null;
$selectedUser = Wootook_Player_Model_Entity::factory($id); $q = doquery("SELECT * FROM {{table}} WHERE id='{intval($id}' LIMIT 1", 'users', true);
if ($newrank !== null && isset($ally_ranks[$newrank]) && $selectedUser->getId() != $ally['ally_owner']) { if (isset($ally_ranks[$newrank]) && $q['id'] != $ally['ally_owner']) {
$selectedUser->setData('ally_rank_id', $newrank)->save(); doquery("UPDATE {{table}} SET `ally_rank_id`=" . $newrank . " WHERE `id`='" . intval($id) . "'", 'users');
} }
} }
@ -854,9 +861,9 @@ elseif ($user->getData('ally_id') != 0 && $user->getData('ally_request') == 0) {
$f_template = gettemplate('alliance_admin_members_function'); $f_template = gettemplate('alliance_admin_members_function');
// Order of displaying the different users // Order of displaying the different users
$sort2 = intval($request->getQuery('sort2')); $sort2 = isset($_GET['sort2']) ? intval($_GET['sort2']) : null;
if ($sort2) { if ($sort2) {
$sort1 = intval($request->getQuery('sort1')); $sort1 = isset($_GET['sort1']) ? intval($_GET['sort1']) : null;
switch($sort1){ switch($sort1){
case 1: case 1:
$sort = " ORDER BY `username`"; $sort = " ORDER BY `username`";
@ -992,7 +999,9 @@ elseif ($user->getData('ally_id') != 0 && $user->getData('ally_request') == 0) {
message($lang['Denied_access'], $lang['Check_the_requests']); message($lang['Denied_access'], $lang['Check_the_requests']);
} }
if ($action == "Accepter") { if ($_POST['action'] == "Accepter") {
$_POST['text'] = strip_tags($_POST['text']);
$u = doquery("SELECT * FROM {{table}} WHERE id=$show", 'users', true); $u = doquery("SELECT * FROM {{table}} WHERE id=$show", 'users', true);
// add points from the user who join the alliance // add points from the user who join the alliance
doquery("UPDATE {{table}} SET doquery("UPDATE {{table}} SET
@ -1008,7 +1017,7 @@ elseif ($user->getData('ally_id') != 0 && $user->getData('ally_request') == 0) {
mnl_alliance=mnl_alliance+1 mnl_alliance=mnl_alliance+1
WHERE id='{$show}'", 'users'); WHERE id='{$show}'", 'users');
$message = "Bonjour,<br>L'Alliance <b>{$ally['ally_name']}</b> a accepté votre candidature.<br>Charte:<br>{$request->getPost('text')}"; $message = "Bonjour,<br>L'Alliance <b>{$ally['ally_name']}</b> a accepté votre candidature.<br>Charte:<br>{$_POST['text']}";
// Send a message to the new member of the alliance // Send a message to the new member of the alliance
doquery("INSERT INTO {{table}} SET doquery("INSERT INTO {{table}} SET
`message_owner`=" .$db->quote($show).", `message_owner`=" .$db->quote($show).",
@ -1022,10 +1031,12 @@ elseif ($user->getData('ally_id') != 0 && $user->getData('ally_request') == 0) {
header('Location: alliance.php?mode=admin&edit=requests'); header('Location: alliance.php?mode=admin&edit=requests');
die(); die();
} elseif ($action == "Refuser" && $action != '') { } elseif ($_POST['action'] == "Refuser" && $_POST['action'] != '') {
$_POST['text'] = strip_tags($_POST['text']);
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'); doquery("UPDATE {{table}} SET ally_request_text='',ally_request='0',ally_id='0',new_message=new_message+1, mnl_alliance=mnl_alliance+1 WHERE id={$db->quote($show)}", 'users');
$message = "Bonjour,<br>L'Alliance <b>{$ally['ally_name']}</b> a refusé votre candidature.<br>Raison:<br>{$request->getPost('text')}"; $message = "Bonjour,<br>L'Alliance <b>{$ally['ally_name']}</b> a refusé votre candidature.<br>Raison:<br>{$_POST['text']}";
// Send a polite message to the player that he is too noobish for that alliance. // Send a polite message to the player that he is too noobish for that alliance.
doquery("INSERT INTO {{table}} SET doquery("INSERT INTO {{table}} SET
`message_owner`=" .$db->quote($show).", `message_owner`=" .$db->quote($show).",
@ -1093,10 +1104,10 @@ elseif ($user->getData('ally_id') != 0 && $user->getData('ally_request') == 0) {
message($lang['Denied_access'], $lang['Members_list']); message($lang['Denied_access'], $lang['Members_list']);
} }
if ($request->getPost('newname') !== null) { if (isset($_POST['newname'])) {
// Y a le nouveau Nom // Y a le nouveau Nom
// New name so lets update all // New name so lets update all
$ally['ally_name'] = strip_tags($request->getPost('newname')); $ally['ally_name'] = strip_tags($_POST['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 `id` = '". $user->getData('ally_id') ."';", 'alliance');
doquery("UPDATE {{table}} SET `ally_name` = ". $db->quote($ally['ally_name']) ." WHERE `ally_id` = '". $ally['id'] ."';", 'users'); doquery("UPDATE {{table}} SET `ally_name` = ". $db->quote($ally['ally_name']) ." WHERE `ally_id` = '". $ally['id'] ."';", 'users');
} }
@ -1121,10 +1132,10 @@ elseif ($user->getData('ally_id') != 0 && $user->getData('ally_request') == 0) {
message($lang['Denied_access'], $lang['Members_list']); message($lang['Denied_access'], $lang['Members_list']);
} }
if ($request->getPost('newtag') !== null) { if (isset($_POST['newtag'])) {
// Y a le nouveau TAG // Y a le nouveau TAG
// new TAG, lets update the table // new TAG, lets update the table
$ally['ally_tag'] = strip_tags($request->getPost('newtag')); $ally['ally_tag'] = strip_tags($_POST['newtag']);
doquery("UPDATE {{table}} SET `ally_tag` = ". $db->quote($ally['ally_tag']) ." WHERE `id` = '". $user->getData('ally_id') ."';", 'alliance'); doquery("UPDATE {{table}} SET `ally_tag` = ". $db->quote($ally['ally_tag']) ." WHERE `id` = '". $user->getData('ally_id') ."';", 'alliance');
} }

View file

@ -3,9 +3,9 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/gpl-3.0.txt * @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.org> * Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved. * All rights reserved.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -31,26 +31,35 @@
define('INSIDE' , true); define('INSIDE' , true);
define('INSTALL' , false); define('INSTALL' , false);
require_once dirname(__FILE__) .'/application/bootstrap.php'; require_once dirname(__FILE__) .'/application/bootstrap.php';
$users = doquery("SELECT * FROM {{table}} WHERE id='".$user['id']."';", 'users');
$readAdapter = Wootook_Core_Database_ConnectionManager::getSingleton()->getConnection('core_read'); $annonce = doquery("SELECT * FROM {{table}} ", 'annonce');
$writeAdapter = Wootook_Core_Database_ConnectionManager::getSingleton()->getConnection('core_write'); $action = $_GET['action'];
$action = isset($_GET['action']) ? $_GET['action'] : null;
if ($action == 5) { if ($action == 5) {
$writeAdapter->insert() $metalvendre = $_POST['metalvendre'];
->into($writeAdapter->getTable('annonce')) $cristalvendre = $_POST['cristalvendre'];
->set('user', $user->getUsername()) $deutvendre = $_POST['deutvendre'];
->set('galaxie', $planet->getGalaxy())
->set('systeme', $planet->getSystem()) $metalsouhait = $_POST['metalsouhait'];
->set('metala', Wootook::getRequest()->getParam('metalvendre')) $cristalsouhait = $_POST['cristalsouhait'];
->set('cristala', Wootook::getRequest()->getParam('cristalvendre')) $deutsouhait = $_POST['deutsouhait'];
->set('deuta', Wootook::getRequest()->getParam('deutvendre'))
->set('metals', Wootook::getRequest()->getParam('metalsouhait')) while ($v_annonce = $users->fetch(PDO::FETCH_BOTH)) {
->set('cristals', Wootook::getRequest()->getParam('cristalsouhait')) $user = $v_annonce['username'];
->set('deuts', Wootook::getRequest()->getParam('deutsouhait')) $galaxie = $v_annonce['galaxy'];
->execute() $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");
$page2 .= <<<HTML $page2 .= <<<HTML
<center> <center>
@ -64,7 +73,7 @@ HTML;
} }
if ($action != 5) { if ($action != 5) {
$statement = $readAdapter->select()->from(array('annonce' => $readAdapter->getTable('annonce')))->order('id', 'DESC')->prepare(); $annonce = doquery("SELECT * FROM {{table}} ORDER BY `id` DESC ", "annonce");
$page2 = "<HTML> $page2 = "<HTML>
<center> <center>
@ -73,9 +82,12 @@ if ($action != 5) {
<td class=\"c\" colspan=\"10\"><font color=\"#FFFFFF\">Petites Annonces</font></td></tr> <td class=\"c\" colspan=\"10\"><font color=\"#FFFFFF\">Petites Annonces</font></td></tr>
<tr><th colspan=\"3\">Infos de livraison</th><th colspan=\"3\">Ressources &agrave; vendre</th><th colspan=\"3\">Ressources souhait&eacute;es</th><th>Action</th></tr> <tr><th colspan=\"3\">Infos de livraison</th><th colspan=\"3\">Ressources &agrave; vendre</th><th colspan=\"3\">Ressources souhait&eacute;es</th><th>Action</th></tr>
<tr><th>Vendeur</th><th>Galaxie</th><th>Syst&egrave;me</th><th>M&eacute;tal</th><th>Cristal</th><th>Deuterium</th><th>M&eacute;tal</th><th>Cristal</th><th>Deuterium</th><th>Delet</th></tr> <tr><th>Vendeur</th><th>Galaxie</th><th>Syst&egrave;me</th><th>M&eacute;tal</th><th>Cristal</th><th>Deuterium</th><th>M&eacute;tal</th><th>Cristal</th><th>Deuterium</th><th>Delet</th></tr>
";
foreach ($statement as $b) {
";
while ($b = $annonce->fetch(PDO::FETCH_BOTH)) {
$page2 .= '<tr><th> '; $page2 .= '<tr><th> ';
$page2 .= $b["user"] ; $page2 .= $b["user"] ;
$page2 .= '</th><th>'; $page2 .= '</th><th>';
@ -107,3 +119,4 @@ if ($action != 5) {
display($page2); display($page2);
} }
?>

View file

@ -3,9 +3,9 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/gpl-3.0.txt * @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.org> * Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved. * All rights reserved.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View file

@ -3,9 +3,9 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/gpl-3.0.txt * @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.org> * Copyright (c) 2009-Present, Wootook Support Team <http://www.xnova-ng.org>
* All rights reserved. * All rights reserved.
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -28,11 +28,9 @@
* *
*/ */
if (!defined('PHP_VERSION_ID')) { defined('BCNUMBERS') || define('BCNUMBERS', true);
$version = explode('.',PHP_VERSION); defined('DEPRECATION') || define('DEPRECATION', true);
define('PHP_VERSION_ID', (((int)$version[0]) * 10000 + ((int)$version[1]) * 100 + ((int)$version[2]))); defined('DEBUG') || define('DEBUG', true);
unset($version);
}
if (!defined('DEBUG') && ($env = getenv('DEBUG')) !== false && in_array(strtolower($env), array('1', 'on', 'true'))) { if (!defined('DEBUG') && ($env = getenv('DEBUG')) !== false && in_array(strtolower($env), array('1', 'on', 'true'))) {
define('DEBUG', true); define('DEBUG', true);
@ -62,9 +60,9 @@ if (!defined('DEBUG')) {
defined('ROOT_PATH') || define('ROOT_PATH', dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR); defined('ROOT_PATH') || define('ROOT_PATH', dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR);
defined('APPLICATION_PATH') || define('APPLICATION_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR); defined('APPLICATION_PATH') || define('APPLICATION_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
defined('PHPEXT') || define('PHPEXT', 'php'); defined('PHPEXT') || define('PHPEXT', require 'extension.inc');
defined('VERSION') || define('VERSION', '1.5.0-beta2'); defined('VERSION') || define('VERSION', '2011.1');
set_include_path(implode(PATH_SEPARATOR, array( set_include_path(implode(PATH_SEPARATOR, array(
APPLICATION_PATH . DIRECTORY_SEPARATOR . 'code' . DIRECTORY_SEPARATOR . 'libraries', APPLICATION_PATH . DIRECTORY_SEPARATOR . 'code' . DIRECTORY_SEPARATOR . 'libraries',
@ -78,36 +76,25 @@ function __autoload($class) {
include_once str_replace('_', '/', $class) . '.php'; include_once str_replace('_', '/', $class) . '.php';
} }
if (defined('IN_ADMIN')) { Wootook_Core_Time::init();
$website = new Wootook_Core_Model_Website(); Wootook_Core_ErrorProfiler::register();
$website->setId(0)->setData('code', 'admin'); Wootook_Core_Model_Config_Events::registerEvents();
Wootook::addWebsite($website);
Wootook::setDefaultWebsite($website);
$game = new Wootook_Core_Model_Game(); if (0 === filesize(ROOT_PATH . 'config.php')) {
$game->setId(0)->setData('code', 'admin')->setData('website_id', $website->getId()); header('Location: install/');
Wootook::addGame($game); die();
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(); $lang = array();
define('TEMPLATE_DIR', realpath(ROOT_PATH . '/templates/'));
define('TEMPLATE_NAME', 'OpenGame');
define('DEFAULT_LANG', 'fr'); 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/functions.' . PHPEXT);
include(ROOT_PATH . 'includes/unlocalised.' . PHPEXT); include(ROOT_PATH . 'includes/unlocalised.' . PHPEXT);
include(ROOT_PATH . 'includes/todofleetcontrol.' . PHPEXT); include(ROOT_PATH . 'includes/todofleetcontrol.' . PHPEXT);
@ -115,26 +102,20 @@ include(ROOT_PATH . 'language/' . DEFAULT_LANG . '/lang_info.cfg');
include(ROOT_PATH . 'includes/vars.' . PHPEXT); include(ROOT_PATH . 'includes/vars.' . PHPEXT);
include(ROOT_PATH . 'includes/strings.' . PHPEXT); include(ROOT_PATH . 'includes/strings.' . PHPEXT);
$user = Wootook_Player_Model_Session::getSingleton()->getPlayer(); $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();
if (!defined('DISABLE_IDENTITY_CHECK')) { if (!defined('DISABLE_IDENTITY_CHECK')) {
if ($user === null || !$user->getId()) { if (($user === null || !$user->getId())) {
Wootook::getResponse() header('Location: login.php');
->setRedirect(Wootook::getUrl('player/account/login'))
->sendHeaders();
exit(0); exit(0);
} }
//var_dump(Wootook::getGameConfig('game/general/active')); if ($gameConfig->isEnabled() && $user !== null && !in_array($user->getData('authlevel'), array(LEVEL_ADMIN, LEVEL_MODERATOR, LEVEL_OPERATOR))) {
if (!Wootook::getGameConfig('game/general/active')/* && !in_array($user->getData('authlevel'), array(LEVEL_ADMIN, LEVEL_MODERATOR, LEVEL_OPERATOR))*/) { message(stripslashes($gameConfig->getData('close_reason')), $gameConfig->getData('game_name'));
$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); exit(0);
} }
} }

View file

@ -3,7 +3,7 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/agpl-3.0.txt * @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com> * Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved. * All rights reserved.
@ -99,7 +99,6 @@ class Legacies_Empire
const ID_RESEARCH_INTERGALACTIC_RESEARCH_NETWORK = 123; const ID_RESEARCH_INTERGALACTIC_RESEARCH_NETWORK = 123;
const ID_RESEARCH_EXPEDITION_TECHNOLOGY = 124; const ID_RESEARCH_EXPEDITION_TECHNOLOGY = 124;
const ID_RESEARCH_ASTROPHYSICS = 124; const ID_RESEARCH_ASTROPHYSICS = 124;
const ID_RESEARCH_ORE_MINING = 125;
const ID_RESEARCH_GRAVITON_TECHNOLOGY = 199; const ID_RESEARCH_GRAVITON_TECHNOLOGY = 199;
const ID_SHIP_LIGHT_TRANSPORT = 202; const ID_SHIP_LIGHT_TRANSPORT = 202;
@ -117,7 +116,6 @@ class Legacies_Empire
const ID_SHIP_DEATH_STAR = 214; const ID_SHIP_DEATH_STAR = 214;
const ID_SHIP_BATTLECRUISER = 215; const ID_SHIP_BATTLECRUISER = 215;
const ID_SHIP_SUPERNOVA = 216; const ID_SHIP_SUPERNOVA = 216;
const ID_SHIP_ORE_MININER = 217;
const ID_DEFENSE_ROCKET_LAUNCHER = 401; const ID_DEFENSE_ROCKET_LAUNCHER = 401;
const ID_DEFENSE_LIGHT_LASER = 402; const ID_DEFENSE_LIGHT_LASER = 402;
@ -146,11 +144,10 @@ class Legacies_Empire
const ID_MISSION_DESTROY = 9; const ID_MISSION_DESTROY = 9;
const ID_MISSION_MISSILES = 10; const ID_MISSION_MISSILES = 10;
const ID_MISSION_EXPEDITION = 15; const ID_MISSION_EXPEDITION = 15;
const ID_MISSION_ORE_MINING = 16;
public static function getFieldName($id) public static function getFieldName($id)
{ {
$fieldsAlias = Wootook_Empire_Helper_Config_FieldsAlias::getSingleton(); $fieldsAlias = Wootook_Empire_Model_Game_FieldsAlias::getSingleton();
if (!isset($fieldsAlias[$id])) { if (!isset($fieldsAlias[$id])) {
return null; return null;

View file

@ -3,7 +3,7 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/agpl-3.0.txt * @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com> * Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved. * All rights reserved.
@ -49,7 +49,7 @@ class Legacies_Empire_Block_Planet_ResearchLab
public function getPlanet() public function getPlanet()
{ {
if ($this->_planet === null) { if ($this->_planet === null) {
$this->_planet = Wootook_Player_Model_Session::getSingleton()->getPlayer() $this->_planet = Wootook_Empire_Model_User::getSingleton()
->getCurrentPlanet() ->getCurrentPlanet()
; ;
} }
@ -58,7 +58,7 @@ class Legacies_Empire_Block_Planet_ResearchLab
public function _initChildBlocks() public function _initChildBlocks()
{ {
$types = Wootook_Empire_Helper_Config_Types::getSingleton(); $types = Wootook_Empire_Model_Game_Types::getSingleton();
/** @var Wootook_Core_Block_Concat $parentBlock */ /** @var Wootook_Core_Block_Concat $parentBlock */
$parentBlock = $this->getLayout()->getBlock('item-list.items'); $parentBlock = $this->getLayout()->getBlock('item-list.items');

View file

@ -3,7 +3,7 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/agpl-3.0.txt * @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com> * Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved. * All rights reserved.
@ -27,7 +27,6 @@
* documentation for further information about customizing Wootook. * documentation for further information about customizing Wootook.
* *
*/ */
/** /**
* *
* Enter description here ... * Enter description here ...
@ -39,7 +38,7 @@ class Legacies_Empire_Block_Planet_ResearchLab_Item
{ {
public function getLevel() public function getLevel()
{ {
return $this->getPlayer()->getElement($this->getItemId()); return $this->getUser()->getElement($this->getItemId());
} }
public function getResourcesNeeded($level) public function getResourcesNeeded($level)

View file

@ -3,7 +3,7 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/agpl-3.0.txt * @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com> * Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved. * All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/agpl-3.0.txt * @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com> * Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved. * All rights reserved.
@ -37,11 +37,11 @@
class Legacies_Empire_Block_Planet_ResearchLab_Queue_Item class Legacies_Empire_Block_Planet_ResearchLab_Queue_Item
extends Wootook_Empire_Block_Planet_Builder_Queue_ItemAbstract extends Wootook_Empire_Block_Planet_Builder_Queue_ItemAbstract
{ {
protected $_itemIdField = 'technology_id'; protected $_itemIdField = 'research_id';
public function getLevel() public function getLevel()
{ {
return $this->getPlayer()->getElement($this->getItemId()); return $this->getUser()->getElement($this->getItemId());
} }
public function getResourcesNeeded($level) public function getResourcesNeeded($level)
@ -49,6 +49,11 @@ class Legacies_Empire_Block_Planet_ResearchLab_Queue_Item
return $this->getPlanet()->getResearchLab()->getResourcesNeeded($this->getItemId(), $this->getQueuedLevel() + 1); return $this->getPlanet()->getResearchLab()->getResourcesNeeded($this->getItemId(), $this->getQueuedLevel() + 1);
} }
public function getItemQueuedLevel()
{
return $this->getItem()->getData('level');
}
public function getQueuedLevel() public function getQueuedLevel()
{ {
return $this->getPlanet()->getResearchLab()->getResearchLevelQueued($this->getItemId()); return $this->getPlanet()->getResearchLab()->getResearchLevelQueued($this->getItemId());
@ -59,15 +64,6 @@ class Legacies_Empire_Block_Planet_ResearchLab_Queue_Item
return $this->getPlanet()->getResearchLab()->getBuildingTime($this->getItemId(), $level); return $this->getPlanet()->getResearchLab()->getBuildingTime($this->getItemId(), $level);
} }
public function getBuildingRemainingTime()
{
$totalTime = $this->getPlanet()->getResearchLab()
->getResearchTime($this->getItemId(), $this->getItemQueuedLevel());
$item = $this->getItem();
return $totalTime - ($item->getData('created_at') - $item->getData('updated_at'));
}
public function getResourcesConfigForLevel($level) public function getResourcesConfigForLevel($level)
{ {
$resources = $this->getResourcesNeeded($level); $resources = $this->getResourcesNeeded($level);

View file

@ -3,7 +3,7 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/agpl-3.0.txt * @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com> * Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved. * All rights reserved.
@ -54,7 +54,7 @@ class Legacies_Empire_Block_Planet_Shipyard
public function getPlanet() public function getPlanet()
{ {
if ($this->_planet === null) { if ($this->_planet === null) {
$this->_planet = Wootook_Player_Model_Session::getSingleton()->getPlayer() $this->_planet = Wootook_Empire_Model_User::getSingleton()
->getCurrentPlanet() ->getCurrentPlanet()
; ;
} }
@ -97,11 +97,7 @@ class Legacies_Empire_Block_Planet_Shipyard
public function _initChildBlocks() public function _initChildBlocks()
{ {
$types = Wootook_Empire_Helper_Config_Types::getSingleton(); $types = Wootook_Empire_Model_Game_Types::getSingleton();
if (!$this->getPlanet() || !$this->getPlanet()->getShipyard()) {
return $this;
}
/** @var Wootook_Core_Block_Concat $parentBlock */ /** @var Wootook_Core_Block_Concat $parentBlock */
$parentBlock = $this->getLayout()->getBlock('item-list.items'); $parentBlock = $this->getLayout()->getBlock('item-list.items');

View file

@ -3,7 +3,7 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/agpl-3.0.txt * @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com> * Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved. * All rights reserved.
@ -42,11 +42,6 @@ class Legacies_Empire_Block_Planet_Shipyard_Item
return $this->getPlanet()->getElement($this->getItemId()); return $this->getPlanet()->getElement($this->getItemId());
} }
public function getClass()
{
return $this->getLabel('class');
}
public function getResourcesNeeded($qty) public function getResourcesNeeded($qty)
{ {
return $this->getPlanet()->getShipyard()->getResourcesNeeded($this->getItemId(), $qty); return $this->getPlanet()->getShipyard()->getResourcesNeeded($this->getItemId(), $qty);

View file

@ -3,7 +3,7 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/agpl-3.0.txt * @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com> * Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved. * All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/agpl-3.0.txt * @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com> * Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved. * All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/agpl-3.0.txt * @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com> * Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved. * All rights reserved.
@ -36,7 +36,7 @@
class Legacies_Empire_Model_Planet_Building_CristalMine class Legacies_Empire_Model_Planet_Building_CristalMine
implements Wootook_Empire_Model_Planet_ResourceProductionInterface, Wootook_Empire_Model_Planet_BuildingInterface implements Wootook_Empire_Model_Planet_ResourceProductionInterface, Wootook_Empire_Model_Planet_BuildingInterface
{ {
public function getProductionRatios($level, $produtionRatio, $planet, $player) public function getProductionRatios($level, $produtionRatio, $planet, $user)
{ {
return array( return array(
Legacies_Empire::RESOURCE_CRISTAL => 10 + 20 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio), Legacies_Empire::RESOURCE_CRISTAL => 10 + 20 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio),

View file

@ -3,7 +3,7 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/agpl-3.0.txt * @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com> * Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved. * All rights reserved.
@ -36,7 +36,7 @@
class Legacies_Empire_Model_Planet_Building_DeuteriumSynthetiser class Legacies_Empire_Model_Planet_Building_DeuteriumSynthetiser
implements Wootook_Empire_Model_Planet_ResourceProductionInterface, Wootook_Empire_Model_Planet_BuildingInterface implements Wootook_Empire_Model_Planet_ResourceProductionInterface, Wootook_Empire_Model_Planet_BuildingInterface
{ {
public function getProductionRatios($level, $produtionRatio, $planet, $player) public function getProductionRatios($level, $produtionRatio, $planet, $user)
{ {
return array( return array(
Legacies_Empire::RESOURCE_DEUTERIUM => 10 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio), Legacies_Empire::RESOURCE_DEUTERIUM => 10 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio),

View file

@ -3,7 +3,7 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/agpl-3.0.txt * @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com> * Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved. * All rights reserved.
@ -36,7 +36,7 @@
class Legacies_Empire_Model_Planet_Building_FusionReactor class Legacies_Empire_Model_Planet_Building_FusionReactor
implements Wootook_Empire_Model_Planet_ResourceProductionInterface, Wootook_Empire_Model_Planet_BuildingInterface implements Wootook_Empire_Model_Planet_ResourceProductionInterface, Wootook_Empire_Model_Planet_BuildingInterface
{ {
public function getProductionRatios($level, $produtionRatio, $planet, $player) public function getProductionRatios($level, $produtionRatio, $planet, $user)
{ {
return array( return array(
Legacies_Empire::RESOURCE_DEUTERIUM => -10 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio), Legacies_Empire::RESOURCE_DEUTERIUM => -10 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio),

View file

@ -3,7 +3,7 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/agpl-3.0.txt * @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com> * Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved. * All rights reserved.
@ -37,7 +37,7 @@
class Legacies_Empire_Model_Planet_Building_MetalMine class Legacies_Empire_Model_Planet_Building_MetalMine
implements Wootook_Empire_Model_Planet_ResourceProductionInterface, Wootook_Empire_Model_Planet_BuildingInterface implements Wootook_Empire_Model_Planet_ResourceProductionInterface, Wootook_Empire_Model_Planet_BuildingInterface
{ {
public function getProductionRatios($level, $produtionRatio, $planet, $player) public function getProductionRatios($level, $produtionRatio, $planet, $user)
{ {
return array( return array(
Legacies_Empire::RESOURCE_METAL => 20 + 30 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio), Legacies_Empire::RESOURCE_METAL => 20 + 30 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio),

View file

@ -3,7 +3,7 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/agpl-3.0.txt * @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com> * Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved. * All rights reserved.
@ -36,16 +36,17 @@
class Legacies_Empire_Model_Planet_Building_NaniteFactory class Legacies_Empire_Model_Planet_Building_NaniteFactory
implements Wootook_Empire_Model_Planet_BuildingInterface implements Wootook_Empire_Model_Planet_BuildingInterface
{ {
public static function buildingEnhancementListener(Wootook_Core_Event $event) public static function buildingTimeListener($event)
{ {
/** @var float $enhancement */
$enhancement = $event->getData('enhancement');
/** @var Wootook_Empire_Model_Planet $planet */
$planet = $event->getData('planet'); $planet = $event->getData('planet');
$level = $planet->getElement(Legacies_Empire::ID_BUILDING_NANITE_FACTORY); if (!$planet->getId() || ($level = $planet->getElement(Legacies_Empire::ID_BUILDING_NANITE_FACTORY)) <= 0) {
return;
}
$event->setData('enhancement', $enhancement * pow(.5, $level)); $time = $event->getData('time');
$speedFactor = pow(2, $level);
$event->setData('time', $time / $speedFactor);
} }
} }

View file

@ -3,7 +3,7 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/agpl-3.0.txt * @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com> * Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved. * All rights reserved.
@ -38,8 +38,7 @@
* @subpackage Legacies_Empire * @subpackage Legacies_Empire
*/ */
class Legacies_Empire_Model_Planet_Building_ResearchLab 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.'; private $_eventPrefix = 'planet.laboratory.';
@ -50,14 +49,14 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab
protected $_currentPlanet = null; protected $_currentPlanet = null;
/** /**
* Player instance * User instance
* @var Woootook_Player_Model_Entity * @var Legacies_Empire_Model_User
*/ */
protected $_currentPlayer = null; protected $_currentUser = null;
/** /**
* construction queue * construction queue
* @var Legacies_Empire_Model_Planet_Building_ResearchLab_Builder * @var array
*/ */
protected $_builder = null; protected $_builder = null;
@ -72,17 +71,17 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab
* it doesn't yet exist. * it doesn't yet exist.
* *
* @param Legacies_Empire_Model_Planet $currentPlanet * @param Legacies_Empire_Model_Planet $currentPlanet
* @param Woootook_Player_Model_Entity $currentPlayer * @param Legacies_Empire_Model_User $currentUser
* @return Legacies_Empire_Model_Planet_Building_ResearchLab * @return Legacies_Empire_Model_Planet_Building_ResearchLab
*/ */
public static function factory($currentPlanet, $currentPlayer) public static function factory($currentPlanet, $currentUser)
{ {
if ($currentPlanet->getId()) { if ($currentPlanet->getId()) {
return null; return null;
} }
if (!isset(self::$_instances[$currentPlanet->getId()])) { if (!isset(self::$_instances[$currentPlanet->getId()])) {
self::$_instances[$currentPlanet->getId()] = new self($currentPlanet, $currentPlayer); self::$_instances[$currentPlanet->getId()] = new self($currentPlanet, $currentUser);
} }
return self::$_instances[$currentPlanet->getId()]; return self::$_instances[$currentPlanet->getId()];
} }
@ -93,14 +92,14 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab
* @see Legacies_Empire_Model_Planet_Building_ResearchLab::factory() * @see Legacies_Empire_Model_Planet_Building_ResearchLab::factory()
* *
* @param Legacies_Empire_Model_Planet $currentPlanet * @param Legacies_Empire_Model_Planet $currentPlanet
* @param Woootook_Player_Model_Entity $currentPlayer * @param Legacies_Empire_Model_User $currentUser
*/ */
public function __construct($currentPlanet, $currentPlayer) public function __construct($currentPlanet, $currentUser)
{ {
$this->_currentPlanet = $currentPlanet; $this->_currentPlanet = $currentPlanet;
$this->_currentPlayer = $currentPlayer; $this->_currentUser = $currentUser;
$this->_builder = new Legacies_Empire_Model_Planet_Building_ResearchLab_Builder($currentPlanet, $currentPlayer); $this->_builder = new Legacies_Empire_Model_Planet_Building_ResearchLab_Builder($currentPlanet, $currentUser);
} }
/** /**
@ -120,14 +119,16 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab
* @param int|string $level * @param int|string $level
* @return Legacies_Empire_Model_Planet_Building_ResearchLab * @return Legacies_Empire_Model_Planet_Building_ResearchLab
*/ */
public function appendQueue($researchId, $level = null, Wootook_Core_DateTime $time = null) public function appendQueue($researchId, $destroy = false, $time = null)
{ {
if ($time === null) { if ($time === null) {
$time = new Wootook_Core_DateTime(); $time = Wootook::now();
} }
if ($level === null) { if ($destroy === false) {
$level = $this->_currentPlayer->getElement($researchId) + 1; $level = $this->_currentUser->getElement($researchId) + 1;
} else {
$level = max($this->_currentUser->getElement($researchId) - 1, 0);
} }
// Dispatch event // Dispatch event
@ -137,7 +138,7 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab
'time' => &$time, 'time' => &$time,
'laboratory' => $this, 'laboratory' => $this,
'planet' => $this->_currentPlanet, 'planet' => $this->_currentPlanet,
'player' => $this->_currentPlayer 'user' => $this->_currentUser
)); ));
$this->_builder->appendQueue($researchId, $level, $time); $this->_builder->appendQueue($researchId, $level, $time);
@ -149,7 +150,7 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab
'time' => $time, 'time' => $time,
'laboratory' => $this, 'laboratory' => $this,
'planet' => $this->_currentPlanet, 'planet' => $this->_currentPlanet,
'player' => $this->_currentPlayer 'user' => $this->_currentUser
)); ));
return $this; return $this;
@ -160,10 +161,10 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab
* *
* @return Legacies_Empire_Model_Planet_Building_ResearchLab * @return Legacies_Empire_Model_Planet_Building_ResearchLab
*/ */
public function updateQueue(Wootook_Core_DateTime $time = null) public function updateQueue($time = null)
{ {
if ($time === null) { if ($time === null) {
$time = new Wootook_Core_DateTime(); $time = Wootook::now();
} }
// Dispatch event // Dispatch event
@ -171,7 +172,7 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab
'time' => &$time, 'time' => &$time,
'laboratory' => $this, 'laboratory' => $this,
'planet' => $this->_currentPlanet, 'planet' => $this->_currentPlanet,
'player' => $this->_currentPlayer 'user' => $this->_currentUser
)); ));
$this->_builder->updateQueue($time); $this->_builder->updateQueue($time);
@ -181,7 +182,7 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab
'time' => $time, 'time' => $time,
'laboratory' => $this, 'laboratory' => $this,
'planet' => $this->_currentPlanet, 'planet' => $this->_currentPlanet,
'player' => $this->_currentPlayer 'user' => $this->_currentUser
)); ));
return $this; return $this;
@ -208,22 +209,18 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab
public function checkAvailability($researchId) public function checkAvailability($researchId)
{ {
try { try {
if (!$this->_builder->checkAvailability($researchId)) {
return false;
}
// Dispatch event // Dispatch event
Wootook::dispatchEvent($this->_eventPrefix . 'check-availability', array( Wootook::dispatchEvent($this->_eventPrefix . 'check-availability', array(
'research_id' => $researchId, 'research_id' => $researchId,
'laboratory' => $this, 'laboratory' => $this,
'planet' => $this->_currentPlanet, 'planet' => $this->_currentPlanet,
'player' => $this->_currentPlayer 'user' => $this->_currentUser
)); ));
} catch (Legacies_Core_Event_Break $e) { } catch (Legacies_Core_Event_Break $e) {
return false; return false;
} }
return true; return $this->_builder->checkAvailability($researchId);
} }
public function getResourcesNeeded($researchId, $level) public function getResourcesNeeded($researchId, $level)
@ -233,12 +230,12 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab
public function getResearchTime($researchId, $level) public function getResearchTime($researchId, $level)
{ {
return $this->_builder->getBuildingTime($researchId, $level); $this->_builder->getBuildingTime($researchId, $level);
} }
public function getResearchLevelQueued($researchId) public function getResearchLevelQueued($researchId)
{ {
$level = $this->_currentPlayer->getElement($researchId); $level = $this->_currentUser->getElement($researchId);
foreach ($this->_builder as $item) { foreach ($this->_builder as $item) {
if ($item->getData('research_id') != $researchId) { if ($item->getData('research_id') != $researchId) {
continue; continue;
@ -263,9 +260,9 @@ class Legacies_Empire_Model_Planet_Building_ResearchLab
$time = $eventData['time']; $time = $eventData['time'];
} }
$researchLab = $planet->getResearchLab(); $shipyard = $planet->getResearchLab();
if ($researchLab !== null) { if ($shipyard !== null) {
$researchLab->updateQueue(); $shipyard->updateQueue();
} }
} }
} }

View file

@ -0,0 +1,252 @@
<?php
/**
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://www.wootook.com/
*
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* --> NOTICE <--
* This file is part of the core development branch, changing its contents will
* make you unable to use the automatic updates manager. Please refer to the
* documentation for further information about customizing Wootook.
*
*/
/**
*
* Enter description here ...
* @author Greg
*
*/
class 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;
}
};

View file

@ -3,7 +3,7 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/agpl-3.0.txt * @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com> * Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved. * All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/agpl-3.0.txt * @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com> * Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved. * All rights reserved.
@ -36,16 +36,17 @@
class Legacies_Empire_Model_Planet_Building_RoboticFactory class Legacies_Empire_Model_Planet_Building_RoboticFactory
implements Wootook_Empire_Model_Planet_BuildingInterface implements Wootook_Empire_Model_Planet_BuildingInterface
{ {
public static function buildingEnhancementListener(Wootook_Core_Event $event) public static function buildingTimeListener($event)
{ {
/** @var float $enhancement */
$enhancement = $event->getData('enhancement');
/** @var Wootook_Empire_Model_Planet $planet */
$planet = $event->getData('planet'); $planet = $event->getData('planet');
$level = $planet->getElement(Legacies_Empire::ID_BUILDING_ROBOTIC_FACTORY); if (!$planet->getId() || ($level = $planet->getElement(Legacies_Empire::ID_BUILDING_ROBOTIC_FACTORY)) <= 0) {
return;
}
$event->setData('enhancement', $enhancement * (2 / (1 + $level))); $time = $event->getData('time');
$speedFactor = 1 + $level;
$event->setData('time', $time / $speedFactor);
} }
} }

View file

@ -3,7 +3,7 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/agpl-3.0.txt * @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com> * Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved. * All rights reserved.
@ -38,8 +38,7 @@
* @subpackage Legacies_Empire * @subpackage Legacies_Empire
*/ */
class Legacies_Empire_Model_Planet_Building_Shipyard 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.'; private $_eventPrefix = 'planet.shipyard.';
@ -50,10 +49,10 @@ class Legacies_Empire_Model_Planet_Building_Shipyard
protected $_currentPlanet = null; protected $_currentPlanet = null;
/** /**
* Player instance * User instance
* @var Woootook_Player_Model_Entity * @var Legacies_Empire_Model_User
*/ */
protected $_currentPlayer = null; protected $_currentUser = null;
/** /**
* construction queue * construction queue
@ -84,17 +83,17 @@ class Legacies_Empire_Model_Planet_Building_Shipyard
* it doesn't yet exist. * it doesn't yet exist.
* *
* @param Legacies_Empire_Model_Planet $currentPlanet * @param Legacies_Empire_Model_Planet $currentPlanet
* @param Woootook_Player_Model_Entity $currentPlayer * @param Legacies_Empire_Model_User $currentUser
* @return Legacies_Empire_Model_Planet_Building_Shipyard * @return Legacies_Empire_Model_Planet_Building_Shipyard
*/ */
public static function factory($currentPlanet, $currentPlayer) public static function factory($currentPlanet, $currentUser)
{ {
if ($currentPlanet->getId()) { if ($currentPlanet->getId()) {
return null; return null;
} }
if (!isset(self::$_instances[$currentPlanet->getId()])) { if (!isset(self::$_instances[$currentPlanet->getId()])) {
self::$_instances[$currentPlanet->getId()] = new self($currentPlanet, $currentPlayer); self::$_instances[$currentPlanet->getId()] = new self($currentPlanet, $currentUser);
} }
return self::$_instances[$currentPlanet->getId()]; return self::$_instances[$currentPlanet->getId()];
} }
@ -105,14 +104,25 @@ class Legacies_Empire_Model_Planet_Building_Shipyard
* @see Legacies_Empire_Model_Planet_Building_Shipyard::factory() * @see Legacies_Empire_Model_Planet_Building_Shipyard::factory()
* *
* @param Legacies_Empire_Model_Planet $currentPlanet * @param Legacies_Empire_Model_Planet $currentPlanet
* @param Woootook_Player_Model_Entity $currentPlayer * @param Legacies_Empire_Model_User $currentUser
*/ */
public function __construct($currentPlanet, $currentPlayer) public function __construct($currentPlanet, $currentUser)
{ {
$this->_currentPlanet = $currentPlanet; $this->_currentPlanet = $currentPlanet;
$this->_currentPlayer = $currentPlayer; $this->_currentUser = $currentUser;
$this->_builder = new Legacies_Empire_Model_Planet_Building_Shipyard_Builder($currentPlanet, $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();
} }
/** /**
@ -132,10 +142,10 @@ class Legacies_Empire_Model_Planet_Building_Shipyard
* @param int|string $qty * @param int|string $qty
* @return Legacies_Empire_Model_Planet_Building_Shipyard * @return Legacies_Empire_Model_Planet_Building_Shipyard
*/ */
public function appendQueue($shipId, $qty, Wootook_Core_DateTime $time = null) public function appendQueue($shipId, $qty, $time = null)
{ {
if ($time === null) { if ($time === null) {
$time = new Wootook_Core_DateTime(); $time = Wootook::now();
} }
// Dispatch event // Dispatch event
@ -145,7 +155,7 @@ class Legacies_Empire_Model_Planet_Building_Shipyard
'time' => &$time, 'time' => &$time,
'shipyard' => $this, 'shipyard' => $this,
'planet' => $this->_currentPlanet, 'planet' => $this->_currentPlanet,
'player' => $this->_currentPlayer 'user' => $this->_currentUser
)); ));
$this->_builder->appendQueue($shipId, $qty, $time); $this->_builder->appendQueue($shipId, $qty, $time);
@ -157,7 +167,7 @@ class Legacies_Empire_Model_Planet_Building_Shipyard
'time' => $time, 'time' => $time,
'shipyard' => $this, 'shipyard' => $this,
'planet' => $this->_currentPlanet, 'planet' => $this->_currentPlanet,
'player' => $this->_currentPlayer 'user' => $this->_currentUser
)); ));
return $this; return $this;
@ -168,10 +178,10 @@ class Legacies_Empire_Model_Planet_Building_Shipyard
* *
* @return Legacies_Empire_Model_Planet_Building_Shipyard * @return Legacies_Empire_Model_Planet_Building_Shipyard
*/ */
public function updateQueue(Wootook_Core_DateTime $time = null) public function updateQueue($time = null)
{ {
if ($time === null) { if ($time === null) {
$time = new Wootook_Core_DateTime(); $time = Wootook::now();
} }
// Dispatch event // Dispatch event
@ -179,7 +189,7 @@ class Legacies_Empire_Model_Planet_Building_Shipyard
'time' => &$time, 'time' => &$time,
'shipyard' => $this, 'shipyard' => $this,
'planet' => $this->_currentPlanet, 'planet' => $this->_currentPlanet,
'player' => $this->_currentPlayer 'user' => $this->_currentUser
)); ));
$this->_builder->updateQueue($time); $this->_builder->updateQueue($time);
@ -189,7 +199,7 @@ class Legacies_Empire_Model_Planet_Building_Shipyard
'time' => $time, 'time' => $time,
'shipyard' => $this, 'shipyard' => $this,
'planet' => $this->_currentPlanet, 'planet' => $this->_currentPlanet,
'player' => $this->_currentPlayer 'user' => $this->_currentUser
)); ));
return $this; return $this;
@ -221,7 +231,7 @@ class Legacies_Empire_Model_Planet_Building_Shipyard
'ship_id' => $shipId, 'ship_id' => $shipId,
'shipyard' => $this, 'shipyard' => $this,
'planet' => $this->_currentPlanet, 'planet' => $this->_currentPlanet,
'player' => $this->_currentPlayer 'user' => $this->_currentUser
)); ));
} catch (Legacies_Core_Event_Break $e) { } catch (Legacies_Core_Event_Break $e) {
return false; return false;
@ -266,7 +276,7 @@ class Legacies_Empire_Model_Planet_Building_Shipyard
$time = $eventData['time']; $time = $eventData['time'];
} }
$shipyard = self::factory($planet, $planet->getPlayer()); $shipyard = self::factory($planet, $planet->getUser());
if ($shipyard !== null) { if ($shipyard !== null) {
$shipyard->updateQueue(); $shipyard->updateQueue();
} }

View file

@ -3,7 +3,7 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/agpl-3.0.txt * @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com> * Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved. * All rights reserved.
@ -42,11 +42,6 @@ class Legacies_Empire_Model_Planet_Building_Shipyard_Builder
*/ */
protected $_maxLength = 0; protected $_maxLength = 0;
/**
* @var float
*/
protected $_speedEnhancement = null;
public function init() public function init()
{ {
$this->_unserializeQueue($this->_currentPlanet->getData('b_hangar_id')); $this->_unserializeQueue($this->_currentPlanet->getData('b_hangar_id'));
@ -66,7 +61,7 @@ class Legacies_Empire_Model_Planet_Building_Shipyard_Builder
$shipId = $params['ship_id']; $shipId = $params['ship_id'];
$qty = $params['qty']; $qty = $params['qty'];
if (!isset($params['created_at'])) { if (!isset($params['created_at'])) {
$createdAt = new Wootook_Core_DateTime(); $createdAt = time();
} else { } else {
$createdAt = $params['created_at']; $createdAt = $params['created_at'];
} }
@ -84,21 +79,6 @@ 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 * Check if a ship or defense type is actually buildable on the current
* planet, depending on the technology and buildings requirements. * planet, depending on the technology and buildings requirements.
@ -108,13 +88,15 @@ class Legacies_Empire_Model_Planet_Building_Shipyard_Builder
*/ */
public function checkAvailability($shipId) public function checkAvailability($shipId)
{ {
$types = Wootook_Empire_Helper_Config_Types::getSingleton(); $types = Wootook_Empire_Model_Game_Types::getSingleton();
if (!$types->is($shipId, Legacies_Empire::TYPE_SHIP) && !$types->is($shipId, Legacies_Empire::TYPE_DEFENSE)) { if (!$types->is($shipId, Legacies_Empire::TYPE_SHIP) && !$types->is($shipId, Legacies_Empire::TYPE_DEFENSE)) {
return false; return false;
} }
return parent::checkAvailability($shipId); parent::checkAvailability($shipId);
return true;
} }
/** /**
@ -126,9 +108,9 @@ class Legacies_Empire_Model_Planet_Building_Shipyard_Builder
*/ */
public function getMaximumBuildableElementsCount($shipId) public function getMaximumBuildableElementsCount($shipId)
{ {
$prices = Wootook_Empire_Helper_Config_Prices::getSingleton(); $prices = Wootook_Empire_Model_Game_Prices::getSingleton();
$fields = Wootook_Empire_Helper_Config_FieldsAlias::getSingleton(); $fields = Wootook_Empire_Model_Game_FieldsAlias::getSingleton();
$resources = Wootook_Empire_Helper_Config_Resources::getSingleton(); $resources = Wootook_Empire_Model_Game_Resources::getSingleton();
$qty = 0; $qty = 0;
foreach ($resources as $resourceId => $_) { foreach ($resources as $resourceId => $_) {
@ -202,20 +184,22 @@ class Legacies_Empire_Model_Planet_Building_Shipyard_Builder
*/ */
public function getBuildingTime($shipId, $qty) public function getBuildingTime($shipId, $qty)
{ {
$prices = Wootook_Empire_Helper_Config_Prices::getSingleton(); $prices = Wootook_Empire_Model_Game_Prices::getSingleton();
$gameConfig = Wootook_Core_Model_Config::getSingleton();
Math::setPrecision(50); Math::setPrecision(50);
$buildingTime = Math::mul($prices[$shipId][Legacies_Empire::BASE_BUILDING_TIME], intval($qty)); $buildingTime = Math::mul($prices[$shipId][Legacies_Empire::BASE_BUILDING_TIME], $qty);
$speedFactor = $gameConfig->getData('game_speed');
$baseTime = Math::div($buildingTime, $speedFactor);
$speedFactor = Wootook::getGameConfig('game/speed/general') / 1000;
$baseTime = Math::mul(Math::div($buildingTime, 5000), Math::mul($speedFactor, $this->getSpeedEnhancement()));
Math::setPrecision(); Math::setPrecision();
$event = Wootook::dispatchEvent('planet.shipyard.building-time', array( $event = Wootook::dispatchEvent('planet.shipyard.building-time', array(
'time' => $baseTime, 'time' => $baseTime,
'base_time' => $baseTime, 'base_time' => $baseTime,
'planet' => $this->_currentPlanet, 'planet' => $this->_currentPlanet,
'player' => $this->_currentPlayer, 'user' => $this->_currentUser,
'ship_id' => $shipId, 'ship_id' => $shipId,
'qty' => $qty 'qty' => $qty
)); ));
@ -229,8 +213,8 @@ class Legacies_Empire_Model_Planet_Building_Shipyard_Builder
*/ */
public function getResourcesNeeded($shipId, $qty) public function getResourcesNeeded($shipId, $qty)
{ {
$prices = Wootook_Empire_Helper_Config_Prices::getSingleton(); $prices = Wootook_Empire_Model_Game_Prices::getSingleton();
$resources = Wootook_Empire_Helper_Config_Resources::getSingleton(); $resources = Wootook_Empire_Model_Game_Resources::getSingleton();
if (!isset($prices[$shipId])) { if (!isset($prices[$shipId])) {
return array(); return array();
@ -266,11 +250,11 @@ class Legacies_Empire_Model_Planet_Building_Shipyard_Builder
* *
* @return Legacies_Empire_Model_Planet_Building_Shipyard * @return Legacies_Empire_Model_Planet_Building_Shipyard
*/ */
public function updateQueue(Wootook_Core_DateTime $time) public function updateQueue($time)
{ {
$fields = Wootook_Empire_Helper_Config_FieldsAlias::getSingleton(); $fields = Wootook_Empire_Model_Game_FieldsAlias::getSingleton();
$elapsedTime = $time->getTimestamp() - $this->_currentPlanet->getData('b_hangar')->getTimestamp(); $elapsedTime = $time - $this->_currentPlanet->getData('b_hangar');
foreach ($this->getQueue() as $element) { foreach ($this->getQueue() as $element) {
$shipId = $element->getData('ship_id'); $shipId = $element->getData('ship_id');
@ -287,7 +271,7 @@ class Legacies_Empire_Model_Planet_Building_Shipyard_Builder
$timeRatio = $elapsedTime / $buildTime; $timeRatio = $elapsedTime / $buildTime;
$itemsBuilt = Math::mul($timeRatio, $qty); $itemsBuilt = Math::mul($timeRatio, $qty);
$element->setData('updated_at', $time->getTimestamp()); $element->setData('updated_at', $time);
$element->setData('qty', Math::sub($qty, $itemsBuilt)); $element->setData('qty', Math::sub($qty, $itemsBuilt));
$this->_currentPlanet->setData($fields[$shipId], Math::add($this->_currentPlanet->getData($fields[$shipId]), $itemsBuilt)); $this->_currentPlanet->setData($fields[$shipId], Math::add($this->_currentPlanet->getData($fields[$shipId]), $itemsBuilt));
break; break;
@ -306,7 +290,7 @@ class Legacies_Empire_Model_Planet_Building_Shipyard_Builder
* @param int|string $qty * @param int|string $qty
* @return Legacies_Empire_Model_Planet_Building_Shipyard * @return Legacies_Empire_Model_Planet_Building_Shipyard
*/ */
public function appendQueue($shipId, $qty, Wootook_Core_DateTime $time) public function appendQueue($shipId, $qty, $time)
{ {
if ($this->_maxLength > 0 && $this->count() >= $this->_maxLength) { if ($this->_maxLength > 0 && $this->count() >= $this->_maxLength) {
return $this; return $this;
@ -316,7 +300,7 @@ class Legacies_Empire_Model_Planet_Building_Shipyard_Builder
return $this; return $this;
} }
$types = Wootook_Empire_Helper_Config_Types::getSingleton(); $types = Wootook_Empire_Model_Game_Types::getSingleton();
if (!$types->is($shipId, Legacies_Empire::TYPE_SHIP) && !$types->is($shipId, Legacies_Empire::TYPE_DEFENSE)) { if (!$types->is($shipId, Legacies_Empire::TYPE_SHIP) && !$types->is($shipId, Legacies_Empire::TYPE_DEFENSE)) {
return $this; return $this;
} }
@ -341,12 +325,7 @@ class Legacies_Empire_Model_Planet_Building_Shipyard_Builder
return $this; return $this;
} }
$this->enqueue(array( $this->enqueue($shipId, $qty, $time);
'ship_id' => $shipId,
'qty' => $qty,
'created_at' => $time->getTimestamp(),
'updated_at' => $time->getTimestamp()
));
$this->_currentPlanet->setData('b_hangar_id', $this->serialize()); $this->_currentPlanet->setData('b_hangar_id', $this->serialize());
foreach ($remainingAmounts as $resourceId => $resourceAmount) { foreach ($remainingAmounts as $resourceId => $resourceAmount) {

View file

@ -3,7 +3,7 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/agpl-3.0.txt * @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com> * Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved. * All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/agpl-3.0.txt * @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com> * Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved. * All rights reserved.
@ -31,7 +31,7 @@
class Legacies_Empire_Model_Planet_Building_SolarPlant class Legacies_Empire_Model_Planet_Building_SolarPlant
implements Wootook_Empire_Model_Planet_ResourceProductionInterface, Wootook_Empire_Model_Planet_BuildingInterface implements Wootook_Empire_Model_Planet_ResourceProductionInterface, Wootook_Empire_Model_Planet_BuildingInterface
{ {
public function getProductionRatios($level, $produtionRatio, $planet, $player) public function getProductionRatios($level, $produtionRatio, $planet, $user)
{ {
return array( return array(
Legacies_Empire::RESOURCE_ENERGY => 20 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio) Legacies_Empire::RESOURCE_ENERGY => 20 * floatval($level) * pow(1.1, floatval($level)) * (0.1 * $produtionRatio)

View file

@ -3,7 +3,7 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/agpl-3.0.txt * @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com> * Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved. * All rights reserved.
@ -39,15 +39,15 @@ class Legacies_Empire_Model_Planet_Ship_LargeTransport
{ {
const REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_IMPULSE_DRIVE = 4; const REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_IMPULSE_DRIVE = 4;
public function getBaseSpeed(Wootook_Player_Model_Entity $player) public function getBaseSpeed(Wootook_Empire_Model_User $user)
{ {
$prices = Wootook_Empire_Helper_Config_Prices::getSingleton(); $prices = Wootook_Empire_Model_Game_Prices::getSingleton();
return $prices[Legacies_Empire::ID_SHIP_LARGE_TRANSPORT][Legacies_Empire::SHIPS_CELERITY_PRIMARY]; return $prices[Legacies_Empire::ID_SHIP_LARGE_TRANSPORT][Legacies_Empire::SHIPS_CELERITY_PRIMARY];
} }
public function getSpeedMultiplier(Wootook_Player_Model_Entity $player) public function getSpeedMultiplier(Wootook_Empire_Model_User $user)
{ {
return pow(1.1, $player->getElement(Legacies_Empire::ID_RESEARCH_COMBUSTION_DRIVE)); return pow(1.1, $user->getElement(Legacies_Empire::ID_RESEARCH_COMBUSTION_DRIVE));
} }
} }

View file

@ -3,7 +3,7 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/agpl-3.0.txt * @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com> * Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved. * All rights reserved.
@ -39,23 +39,23 @@ class Legacies_Empire_Model_Planet_Ship_LightTransport
{ {
const REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_IMPULSE_DRIVE = 4; const REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_IMPULSE_DRIVE = 4;
public function getBaseSpeed(Wootook_Player_Model_Entity $player) public function getBaseSpeed(Wootook_Empire_Model_User $user)
{ {
$prices = Wootook_Empire_Helper_Config_Prices::getSingleton(); $prices = Wootook_Empire_Model_Game_Prices::getSingleton();
if ($player->getElement(Legacies_Empire::ID_RESEARCH_IMPULSE_DRIVE) < self::REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_IMPULSE_DRIVE) { if ($user->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]; return $prices[Legacies_Empire::ID_SHIP_LIGHT_TRANSPORT][Legacies_Empire::SHIPS_CELERITY_PRIMARY];
} else { } else {
return $prices[Legacies_Empire::ID_SHIP_LIGHT_TRANSPORT][Legacies_Empire::SHIPS_CELERITY_SECONDARY]; return $prices[Legacies_Empire::ID_SHIP_LIGHT_TRANSPORT][Legacies_Empire::SHIPS_CELERITY_SECONDARY];
} }
} }
public function getSpeedMultiplier(Wootook_Player_Model_Entity $player) public function getSpeedMultiplier(Wootook_Empire_Model_User $user)
{ {
if ($player->getElement(Legacies_Empire::ID_RESEARCH_HYPERSPACE_DRIVE) < self::REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_IMPULSE_DRIVE) { if ($user->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)); return pow(1.1, $user->getElement(Legacies_Empire::ID_RESEARCH_COMBUSTION_DRIVE));
} else { } else {
return pow(1.2, $player->getElement(Legacies_Empire::ID_RESEARCH_IMPULSE_DRIVE)); return pow(1.2, $user->getElement(Legacies_Empire::ID_RESEARCH_IMPULSE_DRIVE));
} }
} }
} }

View file

@ -3,7 +3,7 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/agpl-3.0.txt * @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com> * Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved. * All rights reserved.
@ -37,29 +37,29 @@ class Legacies_Empire_Model_Planet_Ship_SolarSatellite
extends Wootook_Empire_Model_Planet_ShipAbstract extends Wootook_Empire_Model_Planet_ShipAbstract
implements Wootook_Empire_Model_Planet_ResourceProductionInterface implements Wootook_Empire_Model_Planet_ResourceProductionInterface
{ {
public function getProductionRatios($quantity, $produtionRatio, $planet, $player) public function getProductionRatios($quantity, $produtionRatio, $planet, $user)
{ {
return array( return array(
Legacies_Empire::RESOURCE_ENERGY => ((floatval($planet->getData('temp_max')) / 4) + 20) * (0.1 * $produtionRatio) * floatval($quantity) Legacies_Empire::RESOURCE_ENERGY => ((floatval($planet->getData('temp_max')) / 4) + 20) * (0.1 * $produtionRatio) * floatval($quantity)
); );
} }
public function getBaseSpeed(Wootook_Player_Model_Entity $player) public function getBaseSpeed(Wootook_Empire_Model_User $user)
{ {
return 0; return 0;
} }
public function getSpeedMultiplier(Wootook_Player_Model_Entity $player) public function getSpeedMultiplier(Wootook_Empire_Model_User $user)
{ {
return 0; return 0;
} }
public function getActualSpeed(Wootook_Player_Model_Entity $player) public function getActualSpeed(Wootook_Empire_Model_User $user)
{ {
return 0; return 0;
} }
public function getBaseConsumption(Wootook_Player_Model_Entity $player) public function getBaseConsumption(Wootook_Empire_Model_User $user)
{ {
return 0; return 0;
} }

View file

@ -3,7 +3,7 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/agpl-3.0.txt * @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com> * Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved. * 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_DRIVE = 20;
const REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_HYPERSPACE_TECHNOLOGY = 15; const REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_HYPERSPACE_TECHNOLOGY = 15;
public function getProductionRatios($quantity, $produtionRatio, $planet, $player) public function getProductionRatios($quantity, $produtionRatio, $planet, $user)
{ {
return array( return array(
Legacies_Empire::RESOURCE_ENERGY => ((floatval($planet->getData('temp_max')) / 4) + 20) * (0.1 * $produtionRatio) * floatval($quantity) * -1250 Legacies_Empire::RESOURCE_ENERGY => ((floatval($planet->getData('temp_max')) / 4) + 20) * (0.1 * $produtionRatio) * floatval($quantity) * -1250
); );
} }
public function getBaseSpeed(Wootook_Player_Model_Entity $player) public function getBaseSpeed(Wootook_Empire_Model_User $user)
{ {
$prices = Wootook_Empire_Helper_Config_Prices::getSingleton(); $prices = Wootook_Empire_Model_Game_Prices::getSingleton();
if ($player->getElement(Legacies_Empire::ID_RESEARCH_HYPERSPACE_DRIVE) < self::REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_HYPERSPACE_DRIVE && if ($user->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) { $user->getElement(Legacies_Empire::ID_RESEARCH_HYPERSPACE_TECHNOLOGY) < self::REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_HYPERSPACE_TECHNOLOGY) {
return $prices[Legacies_Empire::ID_SHIP_SUPERNOVA][Legacies_Empire::SHIPS_CELERITY_PRIMARY]; return $prices[Legacies_Empire::ID_SHIP_SUPERNOVA][Legacies_Empire::SHIPS_CELERITY_PRIMARY];
} else { } else {
return $prices[Legacies_Empire::ID_SHIP_SUPERNOVA][Legacies_Empire::SHIPS_CELERITY_SECONDARY]; return $prices[Legacies_Empire::ID_SHIP_SUPERNOVA][Legacies_Empire::SHIPS_CELERITY_SECONDARY];
} }
} }
public function getSpeedMultiplier(Wootook_Player_Model_Entity $player) public function getSpeedMultiplier(Wootook_Empire_Model_User $user)
{ {
if ($player->getElement(Legacies_Empire::ID_RESEARCH_HYPERSPACE_DRIVE) < self::REQUIREMENT_TO_UPGRADE_CELERITY__RESEARCH_HYPERSPACE_DRIVE && if ($user->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) { $user->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)); return pow(1.2, $user->getElement(Legacies_Empire::ID_RESEARCH_IMPULSE_DRIVE));
} else { } else {
return pow(1.3, $player->getElement(Legacies_Empire::ID_RESEARCH_HYPERSPACE_DRIVE)) * return pow(1.3, $user->getElement(Legacies_Empire::ID_RESEARCH_HYPERSPACE_DRIVE)) *
pow(1.1, $player->getElement(Legacies_Empire::ID_RESEARCH_HYPERSPACE_TECHNOLOGY)); pow(1.1, $user->getElement(Legacies_Empire::ID_RESEARCH_HYPERSPACE_TECHNOLOGY));
} }
} }
public function getBaseConsumption(Wootook_Player_Model_Entity $player) public function getBaseConsumption(Wootook_Empire_Model_User $user)
{ {
return 0; return 0;
} }

View file

@ -3,7 +3,7 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/agpl-3.0.txt * @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com> * Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved. * All rights reserved.

View file

@ -3,7 +3,7 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/agpl-3.0.txt * @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com> * Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved. * All rights reserved.
@ -27,14 +27,11 @@
* documentation for further information about customizing Wootook. * documentation for further information about customizing Wootook.
* *
*/ */
/** /**
* *
* Enter description here ... * Enter description here ...
* @author Greg * @author Greg
* *
*/ */
class Wootook_Core_Event
extends Wootook_Object interface Legacies_Officers_Exception {}
{
}

View file

@ -0,0 +1,70 @@
<?php
/**
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://www.wootook.com/
*
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* --> NOTICE <--
* This file is part of the core development branch, changing its contents will
* make you unable to use the automatic updates manager. Please refer to the
* documentation for further information about customizing Wootook.
*
*/
/**
*
* Enter description here ...
* @author Greg
*
*/
class 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);
}
}
}
}
}

View file

@ -3,7 +3,7 @@
* This file is part of Wootook * This file is part of Wootook
* *
* @license http://www.gnu.org/licenses/agpl-3.0.txt * @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://wootook.org/ * @see http://www.wootook.com/
* *
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com> * Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved. * All rights reserved.
@ -27,11 +27,14 @@
* documentation for further information about customizing Wootook. * documentation for further information about customizing Wootook.
* *
*/ */
/** /**
* *
* Enter description here ... * Enter description here ...
* @author Greg * @author Greg
* *
*/ */
interface Wootook_Exception {}
class Legacies_Officers
{
}

View file

@ -0,0 +1,285 @@
<?php
/**
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/agpl-3.0.txt
* @see http://www.wootook.com/
*
* Copyright (c) 2011-Present, Grégory PLANCHAT <g.planchat@gmail.com>
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* --> NOTICE <--
* This file is part of the core development branch, changing its contents will
* make you unable to use the automatic updates manager. Please refer to the
* documentation for further information about customizing Wootook.
*
*/
/**
* 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;
}
}

View file

@ -1,7 +1,7 @@
<?php <?php
class Wootook_Core_Block_Concat class Wootook_Core_Block_Concat
extends Wootook_Core_Mvc_View_View extends Wootook_Core_View
{ {
public function render() public function render()
{ {

View file

@ -0,0 +1,145 @@
<?php
class Wootook_Core_Block_Html_Head
extends Wootook_Core_Block_Template
{
const TYPE_GLOBAL_JS = 'global_js';
const TYPE_SKIN_CSS = 'skin_css';
const TYPE_SKIN_JS = 'skin_js';
const TYPE_INLINE_CSS = 'inline_css';
const TYPE_INLINE_JS = 'inline_js';
protected $_items = array();
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())
{
$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
<link rel="stylesheet" type="{$css['type']}" src="{$css['path']}" media="{$css['media']}" />
HTML_EOF;
}
return $render;
}
public function renderJs()
{
$render = '';
foreach ($this->getJs() as $js) {
if (!isset($js['type'])) {
$js['type'] = 'text/javascript';
}
$render .=<<<HTML_EOF
<script type="{$js['type']}" src="{$js['path']}"></script>
HTML_EOF;
}
return $render;
}
}

View file

@ -0,0 +1,66 @@
<?php
class Wootook_Core_Block_Html_Navigation
extends Wootook_Core_Block_Template
{
public function addLink($name, $label, $title, $uri, Array $params = array(), Array $classes = array(), $template = null)
{
$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
),
'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);
}
}

View file

@ -0,0 +1,116 @@
<?php
class Wootook_Core_Block_Html_Navigation_Link
extends Wootook_Core_Block_Template
{
protected $_label = '';
protected $_title = '';
protected $_uri = '';
protected $_params = array();
protected $_classes = array('link');
public function getTemplate()
{
if ($this->_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;
}
}

View file

@ -0,0 +1,36 @@
<?php
class Wootook_Core_Block_Template
extends Wootook_Core_View
{
protected function _getTemplatePath($file)
{
$pattern = "{$this->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;
}
}

View file

@ -1,7 +1,7 @@
<?php <?php
class Wootook_Core_Block_Text class Wootook_Core_Block_Text
extends Wootook_Core_Mvc_View_View extends Wootook_Core_View
{ {
protected $_content = null; protected $_content = null;

View file

@ -0,0 +1,366 @@
<?php
class Wootook_Core_Collection
extends Wootook_Core_Model
implements Iterator, Countable
{
protected $_tableName = null;
protected $_tableAlias = null;
protected $_entityClassName = 'Wootook_Object';
protected $_columns = array();
protected $_where = array();
protected $_join = array();
protected $_order = array();
protected $_union = array();
protected $_limit = null;
protected $_offset = null;
protected $_group = array();
protected $_items = array();
public function __construct($tableName = null, $entityClassName = null)
{
if ($tableName !== null) {
$this->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 <<<SQL_EOF
SELECT {$fields}
FROM {$database->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 <<<SQL_EOF
$statements
{$where}
{$limit}
SQL_EOF;
}
}
public function __toString()
{
return $this->_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;
}
}

View file

@ -0,0 +1,50 @@
<?php
class Wootook_Core_Controller_Action
{
private $_request = null;
private $_response = null;
public function init()
{
}
public function preDispatch()
{
}
public function postDispatch()
{
}
public function getRequest()
{
return $this->_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;
}
}

View file

@ -0,0 +1,102 @@
<?php
class Wootook_Core_Controller_Request_Http
extends Wootook_Object
{
public function __construct()
{
parent::__construct(array());
}
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 (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;
}
}

View file

@ -1,23 +1,24 @@
<?php <?php
class Wootook_Core_Mvc_Controller_Response_Http class Wootook_Core_Controller_Response_Http
extends Wootook_Core_Mvc_Controller_Response_Response extends Wootook_Object
{ {
const STATUS_OK = 200;
const REDIRECT_MOVED_PERMANENTLY = 301; const REDIRECT_MOVED_PERMANENTLY = 301;
const REDIRECT_FOUND = 302; const REDIRECT_FOUND = 302;
const REDIRECT_SEE_OTHER = 303; const REDIRECT_SEE_OTHER = 303;
const REDIRECT_TEMPORARY = 307; const REDIRECT_TEMPORARY = 307;
protected static $_redirectCodes = array( protected static $_redirectCodes = array(
self::REDIRECT_MOVED_PERMANENTLY => 'Moved Permanently', REDIRECT_MOVED_PERMANENTLY => 'Moved Permanently',
self::REDIRECT_FOUND => 'Found', REDIRECT_FOUND => 'Found',
self::REDIRECT_SEE_OTHER => 'See Other', REDIRECT_SEE_OTHER => 'See Other',
self::REDIRECT_TEMPORARY => 'Temporary Redirect' REDIRECT_TEMPORARY => 'Temporary Redirect'
); );
protected $_returnCode = self::STATUS_OK; public function __construct()
{
parent::__construct(array());
}
public function setBody($data) public function setBody($data)
{ {
@ -45,9 +46,6 @@ class Wootook_Core_Mvc_Controller_Response_Http
public function sendBody() public function sendBody()
{ {
if (!isset($this->_data['body']) || empty($this->_data['body'])) {
return '';
}
return implode('', $this->_data['body']); return implode('', $this->_data['body']);
} }
@ -83,7 +81,7 @@ class Wootook_Core_Mvc_Controller_Response_Http
return $this; return $this;
} }
public function setRawHeader($value) public function setRawHeader($name, $value)
{ {
if (!isset($this->_data['raw_headers']) || !is_array($this->_data['raw_headers'])) { if (!isset($this->_data['raw_headers']) || !is_array($this->_data['raw_headers'])) {
$this->clearRawHeaders(); $this->clearRawHeaders();
@ -110,9 +108,22 @@ class Wootook_Core_Mvc_Controller_Response_Http
return $this; return $this;
} }
public function isRedirect() public function setIsRedirect($value = null)
{ {
return $this->_returnCode >= 300 && $this->_returnCode < 400; 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');
} }
public function setCookie($name, $value, $lifetime = null, $path = null, $domain = null) public function setCookie($name, $value, $lifetime = null, $path = null, $domain = null)
@ -127,10 +138,7 @@ class Wootook_Core_Mvc_Controller_Response_Http
public function setRawCookie($name, $value, $lifetime = null, $path = null, $domain = null) public function setRawCookie($name, $value, $lifetime = null, $path = null, $domain = null)
{ {
$date = new Wootook_Core_DateTime(); setcookie($name, $value, time() + $lifetime, $path, $domain);
$date->add($lifetime);
setcookie($name, $value, $date->getTimestamp(), $path, $domain);
return $this; return $this;
} }
@ -140,22 +148,11 @@ class Wootook_Core_Mvc_Controller_Response_Http
$code = self::REDIRECT_FOUND; $code = self::REDIRECT_FOUND;
} }
$this->_returnCode = $code;
$statusText = self::$_redirectCodes[$code]; $statusText = self::$_redirectCodes[$code];
$this->setRawHeader("HTTP/1.1 {$code} {$statusText}") $this->setRawHeader("HTTP/1.1 {$code} {$statusText}")
->setHeader('Location', $url); ->setHeader('Location', $url)
->setIsRedirect(true);
return $this; return $this;
} }
public function render($send = true)
{
if ($send) {
$this->sendHeaders();
echo $this->sendBody();
} else {
return $this->sendBody();
}
}
} }

View file

@ -0,0 +1,32 @@
<?php
class Wootook_Core_Email
{
protected static $_defaultHeadrs = array(
);
protected $_headers = array();
public function send($to, $from, $subject, $body, Array $headers = array())
{
$this->_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;
}
}

View file

@ -0,0 +1,153 @@
<?php
abstract class Wootook_Core_Entity
extends Wootook_Core_Model
implements Wootook_Core_EntityInterface
{
protected $_idFieldName = null;
protected $_tableName = null;
public function setIdFieldName($fieldName)
{
$this->_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 =<<<SQL_EOF
SELECT * FROM {$database->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 =<<<SQL_EOF
UPDATE {$database->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 =<<<SQL_EOF
INSERT INTO {$database->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 =<<<SQL_EOF
DELETE {$database->getTable(self::getTableName())}
WHERE {$idFieldName}=:{$idFieldName}
SQL_EOF;
$statement->execute($this->getAllDatas());
return $this;
}
}

View file

@ -4,12 +4,13 @@
* *
* @uses Wootook_Object * @uses Wootook_Object
* @uses Legacies_Empire * @uses Legacies_Empire
* @uses Wootook_Player_Model_Entity * @uses Wootook_Empire_Model_User
*/ */
abstract class Wootook_Core_Mvc_Model_Entity_SubTable abstract class Wootook_Core_Entity_SubTable
extends Wootook_Core_Database_Resource extends Wootook_Core_Model
{ {
private $_isLoaded = false; private $_isLoaded = false;
protected $_tableName = null;
protected $_idFieldNames = array(); protected $_idFieldNames = array();
protected $_eventPrefix = 'entity.sub-table'; protected $_eventPrefix = 'entity.sub-table';
@ -31,7 +32,7 @@ abstract class Wootook_Core_Mvc_Model_Entity_SubTable
$idFields = '(' . implode(') AND (', $idFields) . ')'; $idFields = '(' . implode(') AND (', $idFields) . ')';
$fields = implode(', ', $fields); $fields = implode(', ', $fields);
$database = $this->getWriteConnection(); $database = Wootook_Database::getSingleton();
$sql =<<<SQL_EOF $sql =<<<SQL_EOF
UPDATE {$database->getTable(self::getTableName())} UPDATE {$database->getTable(self::getTableName())}
SET {$fields} SET {$fields}
@ -50,7 +51,7 @@ SQL_EOF;
} }
$tokens = implode(', ', $tokens); $tokens = implode(', ', $tokens);
$database = $this->getWriteConnection(); $database = Wootook_Database::getSingleton();
$sql =<<<SQL_EOF $sql =<<<SQL_EOF
INSERT INTO {$database->getTable(self::getTableName())} ($fields) INSERT INTO {$database->getTable(self::getTableName())} ($fields)
VALUES ({$tokens}) VALUES ({$tokens})
@ -65,18 +66,20 @@ SQL_EOF;
protected function _load() protected function _load()
{ {
$idValues = func_get_arg(0); $idValues = func_get_arg(0);
$database = $this->getReadConnection(); $database = Wootook_Database::getSingleton();
$select = $database->select()
->from(array('main_table' => $database->getTable($this->getTableName())))
->limit(1);
$idFields = array(); $idFields = array();
foreach ($this->_idFieldNames as $field) { foreach ($this->_idFieldNames as $field) {
$select->where("{$database->quoteIdentifier($field)}=:{$field}"); $idFields[] = "{$field}=:{$field}";
} }
$idFields = '(' . implode(') AND (', $idFields) . ')';
$statement = $database->prepare($select); $sql =<<<SQL_EOF
SELECT * FROM {$database->getTable(self::getTableName())}
WHERE $idFields
LIMIT 1
SQL_EOF;
$statement = $database->prepare($sql);
$statement->execute($idValues); $statement->execute($idValues);
$datas = $statement->fetch(PDO::FETCH_ASSOC); $datas = $statement->fetch(PDO::FETCH_ASSOC);
@ -84,9 +87,7 @@ SQL_EOF;
throw new Wootook_Core_Exception_DataAccessException('Could not load data: this id combination could not be found.'); throw new Wootook_Core_Exception_DataAccessException('Could not load data: this id combination could not be found.');
} }
$this->_data = array(); $this->_data = $datas;
$this->getDataMapper()->decode($this, $datas);
$this->_isLoaded = true; $this->_isLoaded = true;
return $this; return $this;
@ -94,7 +95,7 @@ SQL_EOF;
protected function _delete() protected function _delete()
{ {
$database = $this->getWriteConnection(); $database = Wootook_Database::getSingleton();
$idFields = array(); $idFields = array();
$idValues = array(); $idValues = array();
@ -117,4 +118,16 @@ SQL_EOF;
return $this; return $this;
} }
public function setTableName($tableName)
{
$this->_tableName = $tableName;
return $this;
}
public function getTableName()
{
return $this->_tableName;
}
} }

View file

@ -0,0 +1,13 @@
<?php
interface Wootook_Core_EntityInterface
{
public function getId();
public function setId($id);
public function getIdFieldName();
public function setIdFieldName($fieldName);
public function getTableName();
public function setTableName($tableName);
}

View file

@ -0,0 +1,202 @@
<?php
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 static $_listen = true;
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 (!self::$_listen) {
return;
}
switch ($errno) {
case E_USER_ERROR:
case E_ERROR:
$this->_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 <<<ERROR_EOF
Message #{$id}
On: {$date} +{$microsec}µs
Type: {$code}
Message: {$error['message']}
File: {$error['file']}
Line: {$error['line']}
\n
ERROR_EOF;
}
public function shutdownManager()
{
$index = 0;
echo '<div style="background:#FFF;border:1px solid #F00;color:#000;padding:10px;margin:20px;text-align:left;">';
echo '<h1>Debug profiler</h1>';
if (count($this->_errors) <= 0 && count($this->_warnings) <= 0 &&
count($this->_notices) <= 0 && count($this->_otherErrors) <= 0 &&
count($this->_exceptions) <= 0) {
echo '<p>Profiler was empty.</p>';
} else {
echo '<pre>';
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 '</pre>';
}
echo '</div>';
}
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;
}
}

View file

@ -0,0 +1,6 @@
<?php
class Wootook_Core_Event
extends Wootook_Object
{
}

View file

@ -0,0 +1,3 @@
<?php
interface Wootook_Core_Exception extends Wootook_Exception {}

View file

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

View file

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

View file

@ -0,0 +1,399 @@
<?php
class Wootook_Core_Layout
extends Wootook_Core_Model
{
const DEFAULT_PACKAGE = 'base';
const DEFAULT_THEME = 'default';
protected $_blocks = array();
protected $_view = null;
protected $_eventPrefix = 'layout';
protected $_eventObject = 'layout';
protected $_package = self::DEFAULT_PACKAGE;
protected $_theme = self::DEFAULT_THEME;
protected $_namespaces = array(
'core' => 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;
}
}

Some files were not shown because too many files have changed in this diff Show more