Added application handler

Fixed fleet bugs
Fixed colonization bug
Updated mail handler support
Fixed galaxy bugs
Updated license block

Signed-off-by: Gregory PLANCHAT <g.planchat@gmail.com>
This commit is contained in:
Gregory PLANCHAT 2012-05-28 23:18:54 +02:00
commit 9e3c1e68bf
89 changed files with 4256 additions and 2168 deletions

View file

@ -36,7 +36,11 @@ require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) {
includeLang('admin');
if ($_GET['cmd'] == 'dele') {
DeleteSelectedUser ( $_GET['user'] );
$player = new Wootook_Player_Model_Entity();
$player->load(intval($_GET['user']));
if ($player->getId()) {
$player->delete();
}
}
if ($_GET['cmd'] == 'sort') {
$TypeSort = $_GET['type'];

View file

@ -36,7 +36,11 @@ require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php';
if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR))) {
includeLang('admin');
if ($_GET['cmd'] == 'dele') {
DeleteSelectedUser ( $_GET['user'] );
$player = new Wootook_Player_Model_Entity();
$player->load(intval($_GET['user']));
if ($player->getId()) {
$player->delete();
}
}
if ($_GET['cmd'] == 'sort') {
$TypeSort = $_GET['type'];

View file

@ -126,7 +126,8 @@ if (!defined('DISABLE_IDENTITY_CHECK')) {
exit(0);
}
if (!Wootook::getGameConfig('game/general/active') && !in_array($user->getData('authlevel'), array(LEVEL_ADMIN, LEVEL_MODERATOR, LEVEL_OPERATOR))) {
//var_dump(Wootook::getGameConfig('game/general/active'));
if (!Wootook::getGameConfig('game/general/active')/* && !in_array($user->getData('authlevel'), array(LEVEL_ADMIN, LEVEL_MODERATOR, LEVEL_OPERATOR))*/) {
$layout = new Wootook_Core_Model_Layout(Wootook_Core_Model_Layout::DOMAIN_FRONTEND);
$layout->load('message');

View file

@ -13,10 +13,6 @@ class Legacies_Empire_Controller_DefenseController
{
parent::preDispatch();
if ($this->getResponse()->isDispatched()) {
return;
}
$planet = $this->getCurrentPlanet();
if ($planet->getElement(Legacies_Empire::ID_BUILDING_SHIPYARD) < 1) {

View file

@ -13,10 +13,6 @@ class Legacies_Empire_Controller_ResearchLabController
{
parent::preDispatch();
if ($this->getResponse()->isDispatched()) {
return;
}
$planet = $this->getCurrentPlanet();
if ($planet->getElement(Legacies_Empire::ID_BUILDING_SHIPYARD) < 1) {

View file

@ -13,10 +13,6 @@ class Legacies_Empire_Controller_ShipyardController
{
parent::preDispatch();
if ($this->getResponse()->isDispatched() || $this->getResponse()->isRedirect()) {
return;
}
$planet = $this->getCurrentPlanet();
if ($planet->getElement(Legacies_Empire::ID_BUILDING_SHIPYARD) < 1) {

View file

@ -160,14 +160,13 @@ CREATE TABLE IF NOT EXISTS {$this->getTableName('fleets')} (
`fleet_end_system` SMALLINT UNSIGNED NOT NULL,
`fleet_end_planet` TINYINT UNSIGNED NOT NULL,
`fleet_end_type` TINYINT UNSIGNED NOT NULL,
`fleet_taget_owner` BIGINT UNSIGNED NOT NULL,
`fleet_target_owner` BIGINT UNSIGNED NOT NULL,
`fleet_resource_metal` DECIMAL(65,0) NOT NULL DEFAULT 0,
`fleet_resource_crystal` DECIMAL(65,0) NOT NULL DEFAULT 0,
`fleet_resource_deuterium` DECIMAL(65,0) NOT NULL DEFAULT 0,
`fleet_target_owner` BIGINT UNSIGNED NOT NULL,
`fleet_group` BIGINT UNSIGNED NOT NULL,
`fleet_mess` BIGINT UNSIGNED NOT NULL,
`start_time` INT,
`start_time` TIMESTAMP NOT NULL,
PRIMARY KEY (`fleet_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
SQL_EOF;
@ -286,7 +285,7 @@ CREATE TABLE IF NOT EXISTS {$this->getTableName('planets')} (
`planet` TINYINT UNSIGNED NOT NULL,
`last_update` DATETIME NOT NULL,
`planet_type` TINYINT UNSIGNED NOT NULL,
`destruyed` BOOL NOT NULL DEFAULT FALSE,
`destruyed` INT UNSIGNED NOT NULL DEFAULT FALSE,
`b_building` DATETIME NOT NULL,
`b_building_id` TEXT NOT NULL,
`b_tech` DATETIME NOT NULL,

View file

@ -22,7 +22,7 @@ class Legacies_Stats_Block_View
return $this->_statData;
}
public function getPlayerStatData($type)
public function getPlayerStatData()
{
if (empty($this->_statData)) {
$playerId = Wootook_Player_Model_Session::getSingleton()->getPlayerId();
@ -31,7 +31,6 @@ class Legacies_Stats_Block_View
$statement = $readAdapter->select()
->from($readAdapter->getTable('statpoints'))
->where('stat_type', $type)
->where('id_owner', $playerId)
->prepare()
;

View file

@ -189,6 +189,11 @@ class Wootook
return Wootook_Core_Model_Session::factory($namespace);
}
/**
* @static
* @param string|null $locale
* @return Wootook_Core_Model_Translator
*/
public static function getTranslator($locale = null)
{
if ($locale === null) {
@ -381,7 +386,7 @@ class Wootook
}
try {
$adapter = Wootook_Core_Database_ConnectionManager::getSingleton()
$adapter = Wootook_Core_Database_ConnectionManager::getSingleton()
->getConnection('core_read');
} catch (Wootook_Core_Exception_Database_AdapterError $e) {
self::$isInstalled = false;
@ -394,24 +399,21 @@ class Wootook
switch ($type) {
case 'website':
$select->where(new Wootook_Core_Database_Sql_Placeholder_Expression('website_id = :website_id', array('website_id' => $model->getId())));
$statement = $adapter->prepare($select);
$statement->execute();
break;
case 'game':
$select->where(new Wootook_Core_Database_Sql_Placeholder_Expression('game_id = :game_id', array('game_id' => $model->getId())));
$statement = $adapter->prepare($select);
$statement->execute();
break;
default:
$select->where('website_id', 0);
$select->where('game_id', 0);
$statement = $adapter->prepare($select);
$statement->execute();
break;
}
$statement = $select->prepare();
$statement->execute();
foreach ($statement as $row) {
$config->setConfig($row['config_path'], $row['config_value']);
}
@ -598,6 +600,7 @@ class Wootook
if (self::$_config === null) {
self::loadConfig();
}
if (!self::$isInstalled) {
if (isset(self::$_config['default'])) {
self::$_gameConfigs[Wootook_Core_Model_Game::DEFAULT_CODE] = clone self::$_config['default'];
@ -781,6 +784,7 @@ class Wootook
$queryParams = array();
if (isset($params['_query'])) {
$queryParams = $params['_query'];
unset($params['_query']);
}
$serializedParams = array();

View file

@ -112,44 +112,44 @@ class Wootook_Core_App
return $this->_newInstance($className, $constructorParams);
}
public function getModel($module, $class)
public function getModel($module, $class, Array $constructorParams = array())
{
$className = $this->_resolveClassType($this->_globalConfig->models, $module, $class);
return $this->_newInstance($className, $constructorParams);
}
public function getResource($module, $class)
public function getResource($module, $class, Array $constructorParams = array())
{
$className = $this->_resolveClassType($this->_globalConfig->resources, $module, $class);
return $this->_newInstance($className, $constructorParams);
}
public function getHelper($module, $class)
public function getHelper($module, $class, Array $constructorParams = array())
{
$className = $this->_resolveClassType($this->_globalConfig->helpers, $module, $class);
return $this->_newInstance($className, $constructorParams);
}
public function getBlockSingleton($module, $class)
public function getBlockSingleton($module, $class, Array $constructorParams = array())
{
}
public function getModelSingleton($module, $class)
public function getModelSingleton($module, $class, Array $constructorParams = array())
{
}
public function getResourceSingleton($module, $class)
public function getResourceSingleton($module, $class, Array $constructorParams = array())
{
}
public function getHelperSingleton($module, $class)
public function getHelperSingleton($module, $class, Array $constructorParams = array())
{
}
}
}

View file

@ -16,4 +16,4 @@ class Wootook_Core_Block_Html_Page
return $this;
}
}
}

View file

@ -1,7 +1,7 @@
<?php
class Wootook_Core_Config_Node
implements ArrayAccess
implements ArrayAccess, Iterator, Countable
{
protected $_children = array();
@ -214,4 +214,34 @@ class Wootook_Core_Config_Node
unset($this->_children[$offset]);
}
}
}
public function valid()
{
return key($this->_children);
}
public function next()
{
next($this->_children);
}
public function current()
{
return current($this->_children);
}
public function rewind()
{
reset($this->_children);
}
public function key()
{
return key($this->_children);
}
public function count()
{
return count($this->_children);
}
}

View file

@ -11,6 +11,11 @@ abstract class Wootook_Core_Database_Adapter_Adapter
return $this->_handler;
}
public function getDataMapper()
{
return new Wootook_Core_Database_Orm_DataMapper();
}
/**
*
* @param string $prefix

View file

@ -35,4 +35,4 @@ class Wootook_Core_Database_Orm_DataMapper_DateTime
{
return new Wootook_Core_DateTime($value, $this->getFormat());
}
}
}

View file

@ -4,7 +4,7 @@ abstract class Wootook_Core_Database_Orm_DataMapper_FieldMapper
{
protected $_mapper = null;
public function __construct(Wootook_Core_Database_Orm_DataMapper $mapper)
public function __construct(Wootook_Core_Database_Orm_DataMapper $mapper = null)
{
$this->_mapper = $mapper;
}
@ -12,4 +12,4 @@ abstract class Wootook_Core_Database_Orm_DataMapper_FieldMapper
abstract public function encode($value);
abstract public function decode($value);
}
}

View file

@ -74,8 +74,9 @@ class Wootook_Core_Database_Sql_Delete
public function renderFrom()
{
if ($this->_parts[self::FROM]['schema'] !== null) {
return "DELETE FROM {$this->getConnection()->quoteIdentifier($this->_parts[self::FROM]['schema'])}.{$this->getConnection()->quoteIdentifier($this->_parts[self::FROM]['schema'])}";
return "DELETE FROM {$this->getConnection()->quoteIdentifier($this->_parts[self::FROM]['schema'])}.{$this->getConnection()->quoteIdentifier($this->_parts[self::FROM]['table'])}";
}
return "DELETE FROM {$this->getConnection()->quoteIdentifier($this->_parts[self::FROM]['table'])}";
}
public function render()

View file

@ -183,7 +183,7 @@ abstract class Wootook_Core_Database_Sql_DmlFilterableQuery
$dateValues = array();
if (isset($value['from'])) {
if ($value['from'] instanceof Wootook_Core_DateTime) {
$dateValues['from'] = "{$adapter->quoteIdentifier($field)} >= {$adapter->quote($this->getDataMapper()->load('DateTime')->encode($value['from']))}";
$dateValues['from'] = "{$adapter->quoteIdentifier($field)} >= {$adapter->quote($this->getConnection()->getDataMapper()->load('DateTime')->encode($value['from']))}";
} else if (is_string($value['from'])) {
$dateValues['from'] = "{$adapter->quoteIdentifier($field)} >= {$adapter->quote($value['from'])}";
} else if (is_numeric($value['from'])) {
@ -192,7 +192,7 @@ abstract class Wootook_Core_Database_Sql_DmlFilterableQuery
}
if (isset($value['to'])) {
if ($value['to'] instanceof Wootook_Core_DateTime) {
$dateValues['to'] = "{$adapter->quoteIdentifier($field)} <= {$adapter->quote($this->getDataMapper()->load('DateTime')->encode($value['to']))}";
$dateValues['to'] = "{$adapter->quoteIdentifier($field)} <= {$adapter->quote($this->getConnection()->getDataMapper()->load('DateTime')->encode($value['to']))}";
} else if (is_string($value['to'])) {
$dateValues['to'] = "{$adapter->quoteIdentifier($field)} <= {$adapter->quote($value['to'])}";
} else if (is_numeric($value['to'])) {

View file

@ -0,0 +1,20 @@
<?php
class Wootook_Core_Database_Sql_Placeholder_Variable
extends Wootook_Core_Database_Sql_Placeholder_Placeholder
{
protected $_paramType = null;
protected $_paramName = null;
protected $_value = null;
public function __construct($paramName, $type = null)
{
$this->_paramName = $paramName;
$this->_paramType = $type;
}
public function __toString()
{
return ':' . $this->_paramName;
}
}

View file

@ -3,6 +3,9 @@
class Wootook_Core_Database_Statement_Pdo_Mysql
extends Wootook_Core_Database_Statement_Statement
{
/**
* @var PDOStatement
*/
protected $_handler = null;
protected $_query = null;
@ -114,8 +117,20 @@ class Wootook_Core_Database_Statement_Pdo_Mysql
*/
public function fetchAll($style = null, $col = null)
{
throw new Wootook_Core_Exception_Database_StatementError($this, 'Unimplemented', null, $e);
return array();
try {
if ($style !== null) {
if ($col !== null) {
$result = $this->_handler->fetchAll($style, $col);
} else {
$result = $this->_handler->fetchAll($style);
}
} else {
$result = $this->_handler->fetchAll($style);
}
} catch (PDOException $e) {
throw new Wootook_Core_Exception_Database_StatementError($this, $e->getMessage(), null, $e);
}
return $result;
}
/**

View file

@ -100,7 +100,9 @@ abstract class Wootook_Core_Database_Statement_Statement
}
$data = $this->fetch(Wootook_Core_Database_ConnectionManager::FETCH_ASSOC);
$object->getDataMapper()->decode($object, $data);
if ($data !== false) {
$object->getDataMapper()->decode($object, $data);
}
return $object;
}
@ -202,11 +204,12 @@ abstract class Wootook_Core_Database_Statement_Statement
public function rewind()
{
return $this->_currentIndex = 0;
return $this->_currentIndex;
}
public function valid()
{
return $this->_currentRow !== null;
$rows = $this->rowCount();
return $rows > 0 && $this->_currentIndex <= $rows;
}
}

View file

@ -143,14 +143,14 @@ class Wootook_Core_DateTime
case self::SECOND:
$current = getdate($this->_datetime);
if ($type === self::OPERATOR_ADD) {
$parts = $current[$part] += $value;
$current[$part] += $value;
} else if ($type === self::OPERATOR_SUB) {
$parts = $current[$part] -= $value;
$current[$part] -= $value;
} else if ($type === self::OPERATOR_SET) {
$parts = $current[$part] = $value;
$current[$part] = $value;
}
$this->_datetime = $this->_mktime($parts);
$this->_datetime = $this->_mktime($current);
break;
case self::TIMESTAMP:
@ -173,6 +173,22 @@ class Wootook_Core_DateTime
return $this->_datetime - $date->_datetime;
}
public function isEarlier(self $date = null)
{
if ($date === null) {
$date = new self();
}
return (bool) ($this->diff($date) > 0);
}
public function isLater(self $date = null)
{
if ($date === null) {
$date = new self();
}
return (bool) ($this->diff($date) < 0);
}
protected function _mktime(Array $parts)
{
return mktime($parts[self::HOUR], $parts[self::MINUTE], $parts[self::SECOND],

View file

@ -2,30 +2,49 @@
class Wootook_Core_Email
{
protected static $_defaultHeadrs = array(
);
/**
* @var Wootook_Core_Email_Transport_Transport
*/
protected $_transport = null;
protected $_headers = array();
public function __construct(Wootook_Core_Email_Transport_Transport $transport = null)
{
if ($transport === null) {
$transport = new Wootook_Core_Email_Transport_Sendmail();
}
$this->setTransport($transport);
}
public function setTransport(Wootook_Core_Email_Transport_Transport $transport)
{
$this->_transport = $transport;
}
/**
* @return Wootook_Core_Email_Transport_Transport
*/
public function getTransport()
{
return $this->_transport;
}
public function send($to, $from, $subject, $body, Array $headers = array())
{
$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);
try {
$this->_transport
->addRecipient($to)
->setFrom($from)
->setSubject($subject)
->addPart(new Wootook_Core_Email_Part_Part($body))
->addHeaders($headers)
->connect()
->send()
;
} catch (Wootook_Core_Exception_RuntimeException $e) {
throw new Wootook_Core_Exception_RuntimeException('Could not send mail.', null, $e);
}
$this->addHeader('X-Mailer', 'PHP/' . PHP_VERSION . ' Wootook/' . VERSION);
$this->addHeader('Content-Transfer-Encoding', '7bit');
$this->addHeader('Content-Type', 'text/plain; charset=utf-8');
$this->_transport->disconnect();
return $this;
}

View file

@ -0,0 +1,16 @@
<?php
class Wootook_Core_Email_Part_Part
{
protected $_content = null;
public function __construct($content, $mime = 'text/plain')
{
$this->_content = $content;
}
public function render()
{
return $this->_content;
}
}

View file

@ -0,0 +1,162 @@
<?php
class Wootook_Core_Email_Transport_Sendmail
implements Wootook_Core_Email_Transport_Transport
{
protected static $_defaultHeaders = array();
protected $_headers = array();
protected $_parts = array();
protected $_from = null;
protected $_recipients = array();
protected $_subject = array();
public function __construct()
{
$this->_prepareHeaders();
}
public function setFrom($from)
{
if (is_array($from)) {
$this->_from = sprintf('"%s" <%s>', $this->_formatUnicode(current($from)), key($from));
} else {
$this->_from = $from;
}
return $this;
}
public function clearFrom()
{
$this->_from = null;
return $this;
}
public function addRecipient($recipient)
{
if (is_array($recipient)) {
foreach ($recipient as $email => $name) {
$this->_recipients[] = sprintf('"%s" <%s>', $this->_formatUnicode($name), $email);
}
} else {
$this->_recipients[] = $recipient;
}
return $this;
}
public function clearRecipients()
{
$this->_recipients = array();
return $this;
}
public function setSubject($subject)
{
$this->_subject = $this->_formatUnicode($subject);
return $this;
}
public function clearSubject()
{
$this->_subject = null;
return $this;
}
public function addHeader($name, $value)
{
$this->_headers[$name] = $value;
return $this;
}
public function addHeaders($headers)
{
foreach ($headers as $name => $value) {
$this->_headers[$name] = $value;
}
return $this;
}
public function clearHeaders()
{
$this->_headers = array();
return $this;
}
public function addPart(Wootook_Core_Email_Part_Part $part)
{
$this->_parts[] = $part;
return $this;
}
public function clearParts()
{
$this->_parts = array();
return $this;
}
protected function _formatUnicode($string)
{
return '=?UTF-8?B?' . base64_encode($string) . '?=';
}
protected function _prepareHeaders(Array $headers = array())
{
$this->addHeader('MIME-Version', '1.0');
foreach ($headers as $name => $value) {
$this->setHeader($name, $value);
}
$this->addHeader('X-Mailer', 'PHP/' . PHP_VERSION . ' Wootook/' . VERSION);
$this->addHeader('Content-Transfer-Encoding', '8bit');
$this->addHeader('Content-Type', 'text/plain; charset=utf-8; format=flowed');
return $this;
}
public function reset()
{
$this->clearHeaders();
$this->clearParts();
$this->clearFrom();
$this->clearRecipients();
$this->clearSubject();
return $this;
}
public function connect()
{
return $this;
}
public function disconnect()
{
return $this;
}
public function send()
{
$content = '';
foreach ($this->_parts as $part) {
$content .= $part->render();
}
$this->addHeader('To', implode(',', $this->_recipients));
if (!mail(implode(',', $this->_recipients), $this->_subject, $content, implode("\r\n", $this->_headers))) {
throw new Wootook_Core_Exception_RuntimeException('Could not send mail.');
}
return $this;
}
}

View file

@ -0,0 +1,22 @@
<?php
interface Wootook_Core_Email_Transport_Transport
{
public function setFrom($from);
public function addRecipient($recipient);
public function setSubject($subject);
public function addHeader($name, $value);
public function addPart(Wootook_Core_Email_Part_Part $part);
public function reset();
public function clearFrom();
public function clearHeaders();
public function clearRecipients();
public function clearSubject();
public function clearParts();
public function connect();
public function disconnect();
public function send();
}

View file

@ -68,7 +68,10 @@ class Wootook_Core_ErrorProfiler
return;
}
$trace = debug_backtrace();
switch ($errno) {
case E_RECOVERABLE_ERROR:
case E_USER_ERROR:
case E_ERROR:
$this->_errors[] = array(
@ -77,7 +80,8 @@ class Wootook_Core_ErrorProfiler
'message' => $errstr,
'file' => $errfile,
'line' => $errline,
'context' => $errcontext
'context' => $errcontext,
'trace' => $trace
);
break;
@ -89,7 +93,8 @@ class Wootook_Core_ErrorProfiler
'message' => $errstr,
'file' => $errfile,
'line' => $errline,
'context' => $errcontext
'context' => $errcontext,
'trace' => $trace
);
break;
@ -101,7 +106,8 @@ class Wootook_Core_ErrorProfiler
'message' => $errstr,
'file' => $errfile,
'line' => $errline,
'context' => $errcontext
'context' => $errcontext,
'trace' => $trace
);
break;
@ -116,7 +122,8 @@ class Wootook_Core_ErrorProfiler
'message' => $errstr,
'file' => $errfile,
'line' => $errline,
'context' => $errcontext
'context' => $errcontext,
'trace' => $trace
);
break;
}
@ -172,10 +179,87 @@ Type: {$code}
Message: {$error['message']}
File: {$error['file']}
Line: {$error['line']}
\n
{$this->_renderBacktrace($error['trace'])}
ERROR_EOF;
}
protected function _renderBacktrace(Array $traces)
{
$output = '<pre>';
foreach (array_slice($traces, 1) as $key => $trace) {
if (preg_match('#^(include|require)(_once)?$#', $trace['function'])) {
$output .= sprintf("#%d %s(%s) called at [%s:%s]\n",
$key, $trace['function'], $trace['args'][0], $trace['file'], $trace['line']);
} else if (!isset($trace['file']) || !isset($trace['line'])) {
if (isset($trace['class'])) {
$output .= sprintf("#%d Internal function <code>%s%s%s(%s)</code>\n",
$key, $trace['class'], $trace['type'], $trace['function'], implode(', ', $this->_formatArgs($trace['args'])));
} else {
$output .= sprintf("#%d Internal function <code>%s(%s)</code>\n",
$key, $trace['function'], implode(', ', $this->_formatArgs($trace['args'])));
}
} else {
if (isset($trace['class'])) {
$output .= sprintf("#%d <code>%s%s%s(%s)</code> called at [%s:%s]\n",
$key, $trace['class'], $trace['type'], $trace['function'], implode(', ', $this->_formatArgs($trace['args'])), $trace['file'], $trace['line']);
} else {
$output .= sprintf("#%d <code>%s(%s)</code> called at [%s:%s]\n",
$key, $trace['function'], implode(', ', $this->_formatArgs($trace['args'])), $trace['file'], $trace['line']);
}
}
}
return $output . '</pre>';
}
private function _formatArgs($args)
{
$argumentList = array();
foreach ($args as $argument) {
if (is_object($argument)) {
$argumentList[] = get_class($argument);
} else if (is_array($argument)) {
$keys = array_keys($argument);
$values = $this->_formatArgs($argument);
$length = count($values);
$output = array();
for ($index = 0; $index < $length; $index++) {
$output[] = sprintf('[%s] => %s', $keys[$index], $values[$index]);
}
$argumentList[] = '[' . implode(', ', $output) . ']';
} else {
$argumentList[] = var_export($argument, true);
}
}
return $argumentList;
}
protected function _renderConfig(Wootook_Core_Config_Node $config, $level = 0)
{
$output = '<ul style="list-style:none;padding:5px;margin:5px 10px;border:1px solid gray">';
foreach ($config as $key => $value) {
$output .= sprintf('<li style="">', $level);
$output .= sprintf('<span style="text-decoration:underline;padding-right:10px;font-family:monospace;color:darkred;font-weight:bold;font-size:12px;">%s</span>', $key);
if ($value instanceof Wootook_Core_Config_Node) {
if (count($value) > 0) {
$output .= $this->_renderConfig($value, $level + 1);
} else {
$output .= '<em>Empty node</em>';
}
} else {
$output .= '<code style="font-family:monospace;font-size:12px;">' . htmlspecialchars(var_export($value, true), ENT_QUOTES, 'UTF-8') . '</code>';
}
$output .= '</li>';
}
$output .= '</ul>';
return $output;
}
public function shutdownManager()
{
if ($this->_mute === true) {
@ -185,66 +269,140 @@ ERROR_EOF;
$index = 0;
echo '<div style="background:#FFF;border:5px solid #933;border-top-width:15px;border-radius:5px;color:#000;padding:0;margin:20px;text-align:left;margin:50px auto;width:800px;">';
echo '<h1 style="margin:0;padding:0 10px;text-decoration:none;border-bottom:3px solid #933;">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 style="color:#666;font-style:italic;margin:20px 10px 10px;">Error profiler was empty.</p>';
} else {
echo '<div style="margin:0;overflow:auto;">';
foreach ($this->_errors as $error) {
++$index;
echo '<h2 style="font-size:1.2em;text-decoration:none;margin:0 5px;">Message #' . $index . '</h2>';
echo '<pre style="margin:0 5px;">';
echo $this->_renderError($index, $error);
echo '</pre>';
}
foreach ($this->_warnings as $error) {
echo '<div style="margin:0;overflow:auto;">';
echo '</div>';
echo '<h2 style="font-size:1.5em;text-decoration:none;margin:0;padding:15px 10px 5px;border-color:#000;border-style:solid;border-width:0 0 1px;background-color:#EEE" rel="errors" class="error-profiler-link">Errors (' . count($this->_errors) . ')</h2>';
echo '<div class="error-profiler errors">';
foreach ($this->_errors as $error) {
++$index;
echo '<h2 style="font-size:1.2em;text-decoration:none;margin:0 5px;">Message #' . $index . '</h2>';
echo '<pre style="margin:0 5px;">';
echo $this->_renderError($index, $error);
echo '</pre>';
}
echo '</div>';
echo '<h2 style="font-size:1.5em;text-decoration:none;margin:0;padding:15px 10px 5px;border-color:#000;border-style:solid;border-width:0 0 1px;background-color:#EEE" rel="warnings" class="error-profiler-link">Warnings (' . count($this->_warnings) . ')</h2>';
echo '<div class="error-profiler warnings">';
foreach ($this->_warnings as $error) {
++$index;
echo '<h2 style="font-size:1.2em;text-decoration:none;margin:10px 5px 0;">Message #' . $index . '</h2>';
echo '<pre style="margin:0 5px;">';
echo $this->_renderError($index, $error);
echo '</pre>';
}
echo '</div>';
echo '<h2 style="font-size:1.5em;text-decoration:none;margin:0;padding:15px 10px 5px;border-color:#000;border-style:solid;border-width:0 0 1px;background-color:#EEE" rel="notices" class="error-profiler-link">Notices (' . count($this->_notices) . ')</h2>';
echo '<div class="error-profiler notices">';
foreach ($this->_notices as $error) {
++$index;
echo '<h2 style="font-size:1.2em;text-decoration:none;margin:10px 5px 0;">Message #' . $index . '</h2>';
echo '<pre style="margin:0 5px;">';
echo $this->_renderError($index, $error);
echo '</pre>';
}
echo '</div>';
foreach ($this->_otherErrors as $errno => $errorList) {
echo '<h2 style="font-size:1.5em;text-decoration:none;margin:0;padding:15px 10px 5px;border-color:#000;border-style:solid;border-width:0 0 1px;background-color:#EEE" rel="other' . $errno . '" class="error-profiler-link">Other error errno#' . $errno . ' (' . count($errorList) . ')</h2>';
echo '<div class="error-profiler other' . $errno . '">';
foreach ($errorList as $error) {
++$index;
echo '<h2 style="font-size:1.2em;text-decoration:none;margin:10px 5px 0;">Message #' . $index . '</h2>';
echo '<pre style="margin:0 5px;">';
echo $this->_renderError($index, $error);
echo '</pre>';
}
foreach ($this->_notices as $error) {
++$index;
echo '<h2 style="font-size:1.2em;text-decoration:none;margin:10px 5px 0;">Message #' . $index . '</h2>';
echo '<pre style="margin:0 5px;">';
echo $this->_renderError($index, $error);
echo '</pre>';
}
foreach ($this->_otherErrors as $errorList) {
foreach ($errorList as $error) {
++$index;
echo '<h2 style="font-size:1.2em;text-decoration:none;margin:10px 5px 0;">Message #' . $index . '</h2>';
echo '<pre style="margin:0 5px;">';
echo $this->_renderError($index, $error);
echo '</pre>';
}
}
foreach ($this->_exceptions as $exception) {
++$index;
echo '<h2 style="font-size:1.2em;text-decoration:none;margin:10px 5px 0;">Message #' . $index . '</h2>';
echo '<pre style="margin:0 5px;">';
echo $exception->getMessage() . PHP_EOL;
echo $exception->getTraceAsString() . PHP_EOL;
echo '</pre>';
echo '</div>';
}
echo '<h2 style="font-size:1.5em;text-decoration:none;margin:0;padding:15px 10px 5px;border-color:#000;border-style:solid;border-width:0 0 1px;background-color:#EEE" rel="exceptions" class="error-profiler-link">Exceptions (' . count($this->_exceptions) . ')</h2>';
echo '<div class="error-profiler exceptions">';
foreach ($this->_exceptions as $exception) {
++$index;
echo '<h2 style="font-size:1.2em;text-decoration:none;margin:10px 5px 0;">Message #' . $index . '</h2>';
echo '<pre style="margin:0 5px;">';
echo $exception->getMessage() . PHP_EOL;
echo $exception->getTraceAsString() . PHP_EOL;
echo '</pre>';
$child = 0;
$current = $exception;
while (($current = $current->getPrevious()) !== null) {
$child++;
echo '<h3 style="font-size:1em;text-decoration:none;margin:10px 30px 0;">Message #' . $index . ', child level #' . $child . '</h3>';
echo '<pre style="margin:0 30px;">';
echo $current->getMessage() . PHP_EOL;
echo $current->getTraceAsString() . PHP_EOL;
echo PHP_EOL;
echo '</pre>';
}
$child = 0;
$current = $exception;
while (($current = $current->getPrevious()) !== null) {
$child++;
echo '<h3 style="font-size:1em;text-decoration:none;margin:10px 30px 0;">Message #' . $index . ', child level #' . $child . '</h3>';
echo '<pre style="margin:0 30px;">';
echo $current->getMessage() . PHP_EOL;
echo $current->getTraceAsString() . PHP_EOL;
echo PHP_EOL;
echo '</pre>';
}
echo '</div>';
}
echo '</div>';
echo <<<JS_EOF
<script>
(function(){
var sections = jQuery('.error-profiler');
sections.each(function(){
var element = jQuery(this);
element.hide();
});
jQuery('.error-profiler-link').click(function(e){
var rel = jQuery(this).attr('rel');
sections.each(function(){
var element = jQuery(this);
if (element.hasClass(rel) && !element.hasClass('opened')) {
element.slideDown(500, function(){element.addClass('opened');});
} else {
element.slideUp(500, function(){element.removeClass('opened');});
}
});
});
})();
</script>
JS_EOF;
echo '<h1 style="margin:0;padding:0 10px;text-decoration:none;border-bottom:3px solid #933;">Configuration profiler</h1>';
echo '<h2 style="font-size:1.5em;text-decoration:none;margin:0;padding:15px 10px 5px;border-color:#000;border-style:solid;border-width:0 0 1px;background-color:#EEE" rel="global" class="config-profiler-link">Global configuration</h2>';
echo '<div class="config-profiler global">';
$config = clone Wootook::getConfig();
foreach ($config->getConfig('resource/database') as $node) {
if ($node->params) {
$node->params->reset();
}
}
echo $this->_renderConfig(Wootook::getConfig(), 0);
echo '</div>';
echo '<h2 style="font-size:1.5em;text-decoration:none;margin:0;padding:15px 10px 5px;border-color:#000;border-style:solid;border-width:0 0 1px;background-color:#EEE" rel="website" class="config-profiler-link">Website configuration</h2>';
echo '<div class="config-profiler website">';
echo $this->_renderConfig(Wootook::getWebsiteConfig());
echo '</div>';
echo '<h2 style="font-size:1.5em;text-decoration:none;margin:0;padding:15px 10px 5px;border-color:#000;border-style:solid;border-width:0 0 1px;background-color:#EEE" rel="game" class="config-profiler-link">Game configuration</h2>';
echo '<div class="config-profiler game">';
echo $this->_renderConfig(Wootook::getGameConfig());
echo '</div>';
echo '</div>';
echo <<<JS_EOF
<script>
(function(){
var sections = jQuery('.config-profiler');
sections.each(function(){
var element = jQuery(this);
element.hide();
});
jQuery('.config-profiler-link').click(function(e){
var rel = jQuery(this).attr('rel');
sections.each(function(){
var element = jQuery(this);
if (element.hasClass(rel) && !element.hasClass('opened')) {
element.slideDown(500, function(){element.addClass('opened');});
} else {
element.slideUp(500, function(){element.removeClass('opened');});
}
});
});
})();
</script>
JS_EOF;
}
public static function register()

View file

@ -197,6 +197,7 @@ class Wootook_Core_Mvc_Controller_Front
$this->_response->setIsDispatched();
$this->preDispatch();
$controller->preDispatch();
if (!$this->_response->isDispatched()) {
continue;
@ -212,6 +213,7 @@ class Wootook_Core_Mvc_Controller_Front
}
$controller->postDispatch();
$this->postDispatch();
if ($this->_response->isDispatched() || $this->_response->isRedirect()) {
break;
@ -246,4 +248,24 @@ class Wootook_Core_Mvc_Controller_Front
return $this;
}
public function preDispatch()
{
Wootook::dispatchEvent('core.mvc.controller.front.pre-dispatch', array(
'request' => $this->_request,
'response' => $this->_response
));
return $this;
}
public function postDispatch()
{
Wootook::dispatchEvent('core.mvc.controller.front.post-dispatch', array(
'request' => $this->_request,
'response' => $this->_response
));
return $this;
}
}

View file

@ -32,7 +32,12 @@ class Wootook_Core_Mvc_Controller_Request_Http
$params = '';
if (($offset = strpos($this->getServer('REQUEST_URI'), $baseUri)) !== false) {
$path = substr($this->getServer('REQUEST_URI'), $offset + strlen($baseUri));
$queryParamsOffset = strpos($this->getServer('REQUEST_URI'), '?');
if ($queryParamsOffset !== false) {
$path = substr($this->getServer('REQUEST_URI'), $offset + strlen($baseUri), $queryParamsOffset - $offset - 1);
} else {
$path = substr($this->getServer('REQUEST_URI'), $offset + strlen($baseUri));
}
$moduleOffset = strpos($path, '/');
if ($moduleOffset !== false) {

View file

@ -59,11 +59,12 @@ abstract class Wootook_Core_Mvc_Model_Entity
if (!is_array($datas) || empty($datas)) {
throw new Wootook_Core_Exception_DataAccessException('Could not load data: this id could not be found.');
}
$realId = $datas[$this->getIdFieldName()];
unset($datas[$this->getIdFieldName()]);
$this->_data = array();
$this->getDataMapper()->decode($this, $datas);
$this->setId($id);
$this->setId($realId);
return $this;
}

View file

@ -90,6 +90,17 @@ class Wootook_Core_Mvc_View_View
}
}
public function renderDateTime($dateTime, $format = null)
{
if ($format === null) {
$format = 'H:i:s';
}
if (!$dateTime instanceof Wootook_Core_DateTime) {
$dateTime = new Wootook_Core_DateTime($dateTime);
}
return $dateTime->toString($format);
}
public function escape($unescaped)
{
return htmlspecialchars($unescaped, ENT_QUOTES, 'UTF-8');

View file

@ -21,7 +21,7 @@ abstract class Wootook_Core_Resource_EntityCollection
protected $_items = array();
public function __construct(Wootook_Core_Database_Adapter_Pdo_Mysql $connection = null)
public function __construct(Wootook_Core_Database_Adapter_Adapter $connection = null)
{
$this->setReadConnection($connection);
@ -153,17 +153,28 @@ abstract class Wootook_Core_Resource_EntityCollection
return $this;
}
public function getSize()
public function getSize($maintainGrouping = array())
{
$clone = clone $this->_select;
$clone->_fields = array();
$clone->column('1');
$clone->reset(Wootook_Core_Database_Sql_Select::COLUMNS);
if (empty($maintainGrouping)) {
$clone->reset(Wootook_Core_Database_Sql_Select::GROUP);
} else {
$groupingFields = $clone->getPart(Wootook_Core_Database_Sql_Select::GROUP);
$clone->reset(Wootook_Core_Database_Sql_Select::GROUP);
foreach ($groupingFields as $field) {
if (in_array($field, $maintainGrouping)) {
$clone->group($field);
}
}
}
$clone->column(new Wootook_Core_Database_Sql_Placeholder_Expression('COUNT(*)'));
$database = $this->getReadConnection();
$statement = $database->prepare($clone);
$statement->execute();
$count = $statement->rowCount();
$count = $statement->fetchColumn();
$statement->closeCursor();
return $count;

View file

@ -0,0 +1,77 @@
<?php
class Wootook_Empire_Block_Overview_Fleet_List
extends Wootook_Core_Block_Template
{
protected $_itemTemplate = null;
protected $_itemBlockType = null;
protected $_fleetCollection = null;
public function getFleetCollection()
{
if ($this->_fleetCollection === null) {
$player = Wootook_Player_Model_Session::getSingleton()->getPlayer();
$this->_fleetCollection = $player->getVisibleFleets();
}
return $this->_fleetCollection;
}
public function setItemTemplate($template)
{
$this->_itemTemplate = $template;
return $this;
}
public function getItemTemplate()
{
return $this->_itemTemplate;
}
public function setItemBlockType($blockType)
{
$this->_itemBlockType = $blockType;
return $this;
}
public function getItemBlockType()
{
return $this->_itemBlockType;
}
public function getItemBlock($fleet)
{
$blockName = $this->getNameInLayout() . ".item({$fleet->getId()})";
return $this->getLayout()
->createBlock($this->getItemBlockType(), $blockName)
->setTemplate($this->getItemTemplate())
->setFleetItem($fleet);
}
public function prepareLayout()
{
parent::prepareLayout();
$this->_initChildBlocks();
return $this;
}
public function _initChildBlocks()
{
$parentBlock = $this->getLayout()
->createBlock('core/concat', $this->getNameInLayout() . '.item-list')
;
$this->setPartial('item-list', $parentBlock);
foreach ($this->getFleetCollection()->load() as $fleet) {
$block = $this->getItemBlock($fleet);
$parentBlock->setPartial($block->getNameInLayout(), $block);
}
return $this;
}
}

View file

@ -0,0 +1,153 @@
<?php
class Wootook_Empire_Block_Overview_Fleet_List_Item
extends Wootook_Core_Block_Template
{
protected $_fleet = null;
protected $_currentPlayer = null;
protected $_ownerCollection = null;
/**
* @return Wootook_Player_Model_Entity
*/
public function getPlayer()
{
if ($this->_currentPlayer == null) {
$this->_currentPlayer = Wootook_Player_Model_Session::getSingleton()->getPlayer();
}
return $this->_currentPlayer;
}
/**
* @return Wootook_Player_Resource_Entity_Collection
*/
public function getFleetOwnerCollection()
{
if ($this->_ownerCollection == null) {
$this->_ownerCollection = $this->getFleetItem()->getOwnerCollection();
}
return $this->_ownerCollection;
}
/**
* @return Wootook_Player_Resource_Entity_Collection
*/
public function getFleetOwnerUsernames()
{
$usernameList = array();
foreach ($this->getFleetOwnerCollection()->load() as $owner) {
$usernameList[] = $owner->getUsername();
}
return $usernameList;
}
public function setFleetItem(Wootook_Empire_Model_Fleet $fleetItem)
{
$this->_fleet = $fleetItem;
return $this;
}
/**
* @return Wootook_Empire_Model_Fleet
*/
public function getFleetItem()
{
return $this->_fleet;
}
public function getStartTime()
{
return $this->getFleetItem()->getStartTime();
}
public function getActionTime()
{
return $this->getFleetItem()->getActionTime();
}
public function getArrivalTime()
{
return $this->getFleetItem()->getArrivalTime();
}
public function isOwner()
{
return $this->getFleetItem()->isOwnedBy($this->getPlayer());
}
public function getRowClass()
{
return $this->getFleetItem()->getRowClass($this->getPlayer());
}
public function getOriginPlanet()
{
return $this->getFleetItem()->getOriginPlanet();
}
public function getOriginPlayer()
{
return $this->getOriginPlanet()->getPlayer();
}
public function getOriginPlayerName()
{
$player = $this->getOriginPlanet()->getPlayer();
if ($player !== null) {
return $player->getUsername();
}
return null;
}
public function getOriginPlanetName()
{
return $this->getOriginPlanetName();
}
public function getOriginPlanetCoords()
{
return $this->getOriginPlanetCoords();
}
public function getDestinationPlanet()
{
return $this->getFleetItem()->getDestinationPlanet();
}
public function getDestinationPlayer()
{
return $this->getDestinationPlanet()->getPlayer();
}
public function getDestinationPlayerName()
{
$player = $this->getDestinationPlanet()->getPlayer();
if ($player !== null) {
return $player->getUsername();
}
return null;
}
public function getDestinationPlanetName()
{
return $this->getDestinationPlanetName();
}
public function getDestinationPlanetCoords()
{
return $this->getDestinationPlanetCoords();
}
public function getMissionLabel()
{
return $this->getFleetItem()->getMissionLabel();
}
public function isMission($type)
{
return $this->getFleetItem()->isMission($type);
}
}

View file

@ -34,6 +34,12 @@ class Wootook_Empire_Model_Fleet
{
$this->setIdFieldName('fleet_id');
$this->setTableName('fleets');
$this->getDataMapper()
->addRule('fleet_start_time', 'date-time')
->addRule('fleet_end_time', 'date-time')
->addRule('fleet_end_stay', 'date-time')
;
}
public static function planetListener($eventData)
@ -48,10 +54,16 @@ class Wootook_Empire_Model_Fleet
return false;
}
public function getOwner()
/**
* @return null|Wootook_Player_Resource_Entity_Collection
*/
public function getOwnerCollection()
{
if ($id = $this->getData('fleet_owner')) {
return Wootook_Player_Model_Entity::factory($id);
$ownerCollection = new Wootook_Player_Resource_Entity_Collection($this->getReadConnection());
$ownerCollection->addFieldToFilter('id', $id);
return $ownerCollection;
}
return null;
}
@ -86,6 +98,8 @@ class Wootook_Empire_Model_Fleet
return 'missiles';
} else if ($this->isMission(Legacies_Empire::ID_MISSION_EXPEDITION)) {
return 'expedition';
} else if ($this->isMission(Legacies_Empire::ID_MISSION_ORE_MINING)) {
return 'ore-mining';
}
}
@ -107,25 +121,34 @@ class Wootook_Empire_Model_Fleet
return Wootook::__('Missiles Launch');
} else if ($this->isMission(Legacies_Empire::ID_MISSION_EXPEDITION)) {
return Wootook::__('Expedition');
} else if ($this->isMission(Legacies_Empire::ID_MISSION_ORE_MINING)) {
return Wootook::__('Ore mining');
}
return Legacies::__('Unknown');
}
/**
* @return Wootook_Core_DateTime
*/
public function getStartTime()
{
return $this->getData('fleet_start_time');
}
/**
* @return Wootook_Core_DateTime
*/
public function getActionTime()
{
return $this->getData('fleet_end_stay');
}
/**
* @return Wootook_Core_DateTime
*/
public function getArrivalTime()
{
if ($this->isMission(Legacies_Empire::ID_MISSION_STATION) || $this->isMission(Legacies_Empire::ID_MISSION_STATION_ALLY)) {
return $this->getActionTime();
}
return $this->getData('fleet_end_time');
}
@ -141,15 +164,85 @@ class Wootook_Empire_Model_Fleet
return Wootook_Empire_Model_Planet::factoryFromCoords($coords, $type);
}
public function getOriginPlanetName()
{
if (!($planet = $this->getOriginPlanet()->getId())) {
return '';
}
return $planet->getName();
}
public function getOriginPlanetCoords()
{
if (!($planet = $this->getOriginPlanet()->getId())) {
return sprintf('%s:%s:%s', $this->getData('fleet_start_galaxy'), $this->getData('fleet_start_system'), $this->getData('fleet_start_planet'));
}
return $planet->getCoords();
}
public function getDestinationPlanet()
{
$coords = array(
'galaxy' => $this->getData('fleet_end_galaxy'),
'system' => $this->getData('fleet_end_system'),
'position' => $this->getData('fleet_end_planet')
);
);
$type = $this->getData('fleet_end_type');
return Wootook_Empire_Model_Planet::factoryFromCoords($coords, $type);
}
public function getDestinationPlanetName()
{
if (!($planet = $this->getDestinationPlanet()->getId())) {
return '';
}
return $planet->getName();
}
public function getDestinationPlanetCoords()
{
if (!($planet = $this->getDestinationPlanet()->getId())) {
return sprintf('%s:%s:%s', $this->getData('fleet_end_galaxy'), $this->getData('fleet_end_system'), $this->getData('fleet_end_planet'));
}
return $planet->getCoords();
}
public function goBack()
{
$this->setData('fleet_mess', 1)->save();
return $this;
}
/**
* @param Wootook_Empire_Model_Planet $planet
* @return Wootook_Empire_Model_Fleet
*/
public function dock(Wootook_Empire_Model_Planet $planet)
{
// Backward-compatible way to unserialize fleet ships listing
$serializedFleetArray = $this->getData('fleet_array');
foreach (explode(';', $serializedFleetArray) as $fleetShipData) {
if (empty($fleetShipData)) {
continue;
}
$fleetShipData = explode(',', $fleetShipData);
if (count($fleetShipData) != 2) {
continue;
}
$planet->setElement($fleetShipData[0], Math::add($planet->getElement($fleetShipData[0]), $fleetShipData[1]));
}
$planet
->setData('metal', Math::add($planet->getData('metal'), $this->getData('fleet_resource_metal')))
->setData('cristal', Math::add($planet->getData('cristal'), $this->getData('fleet_resource_crystal')))
->setData('deuterium', Math::add($planet->getData('deuterium'), $this->getData('fleet_resource_deuterium')))
->save();
;
$this->delete();
return $this;
}
}

View file

@ -105,7 +105,8 @@ class Wootook_Empire_Model_Planet
->getConnection('core_read');
$collection = new Wootook_Empire_Resource_Planet_Collection($adapter);
$collection->addCoordsToFilter($coords['galaxy'], $coords['system'], $coords['position'], $coords['type'])
->setPage(1, 1);
->setPage(1, 1)
->load();
$planet = $collection->getFirstItem();
if ($planet !== null) {
@ -166,6 +167,9 @@ class Wootook_Empire_Model_Planet
throw new Wootook_Core_Exception_RuntimeException(Wootook::__('Undefined method %s::%s.', get_class($this), $method));
}
/**
* @return Wootook_Core_DateTime
*/
public function getLastUpdate()
{
return $this->getData('last_update');
@ -424,7 +428,7 @@ class Wootook_Empire_Model_Planet
public function getFleetCollection($time = null)
{
$collection = new Wootook_Empire_Resource_Fleet_Collection();
$collection = new Wootook_Empire_Resource_Fleet_Collection($this->getReadConnection());
$collection->addPlanetToFilter($this, $time);
return $collection;
@ -469,22 +473,18 @@ class Wootook_Empire_Model_Planet
public function getMoon()
{
static $statement = null;
if ($this->isMoon()) {
return null;
}
if ($this->_moon === null) {
if ($statement === null) {
$collection = new Wootook_Empire_Resource_Planet_Collection($this->getReadConnection());
$collection->addFieldToFilter('galaxy', $this->getGalaxy())
->addFieldToFilter('system', $this->getGalaxy())
->addFieldToFilter('planet', $this->getPosition())
->addFieldToFilter('planet_type', self::TYPE_MOON)
->load()
;
}
$collection = new Wootook_Empire_Resource_Planet_Collection($this->getReadConnection());
$collection->addFieldToFilter('galaxy', $this->getGalaxy())
->addFieldToFilter('system', $this->getGalaxy())
->addFieldToFilter('planet', $this->getPosition())
->addFieldToFilter('planet_type', self::TYPE_MOON)
->load()
;
$this->_moon = $collection->getFirstItem();
@ -606,7 +606,7 @@ class Wootook_Empire_Model_Planet
public function isDestroyed()
{
return (bool) $this->getData('destruyed');
return (bool) ($this->getData('destruyed') > 0);
}
public function destroy()
@ -641,13 +641,21 @@ class Wootook_Empire_Model_Planet
}
$this
->setData('destruyed', true)
->setData('destruyed', time() + 172800)
->setData('id_owner', 0)
->save();
return $this;
}
public function isErasable()
{
if ($this->isDestroyed() && $this->getData('destruyed') >= time()) {
return true;
}
return false;
}
public function getElement($elementId)
{
$fields = Wootook_Empire_Helper_Config_FieldsAlias::getSingleton();
@ -896,6 +904,32 @@ class Wootook_Empire_Model_Planet
return intval($value);
}
public static function planetChangeListener($eventData)
{
if (!isset($eventData['request']) || !$eventData['request'] instanceof Wootook_Core_Mvc_Controller_Request_Http) {
return;
}
/** @var Wootook_Core_Mvc_Controller_Request_Http $request */
$request = $eventData['request'];
if (!($planetId = $request->getQuery('___planet'))) {
return;
}
$session = Wootook_Player_Model_Session::getSingleton();
if (!$session->isLoggedIn()) {
return;
}
$planet = new Wootook_Empire_Model_Planet();
$planet->load($planetId);
if (!$planet->getId()) {
return;
}
$player = $session->getPlayer();
$player->setCurrentPlanet($planet);
}
public static function planetUpdateListener($eventData)
{
if (isset($eventData['planet'])) {

View file

@ -10,20 +10,23 @@ class Wootook_Empire_Resource_Fleet_Collection
public function addPlanetToFilter(Wootook_Empire_Model_Planet $planet, $time = null)
{
if ($time === null) {
$time = new Wootook_Core_DateTime();
}
$this->addFieldToFilter(null, array(
array('and' => array(
array('eq' => array('field' => 'fleet_start_galaxy', 'value' => $planet->getGalaxy())),
array('eq' => array('field' => 'fleet_start_system', 'value' => $planet->getSystem())),
array('eq' => array('field' => 'fleet_start_planet', 'value' => $planet->getPosition())),
array('eq' => array('field' => 'fleet_start_type', 'value' => $planet->getType())),
array('date' => array('field' => 'fleet_start_time', 'value' => array('to' => $time))),
//array('date' => array('field' => 'fleet_start_time', 'value' => array('to' => $time))),
)),
array('and' => array(
array('eq' => array('field' => 'fleet_end_galaxy', 'value' => $planet->getGalaxy())),
array('eq' => array('field' => 'fleet_end_system', 'value' => $planet->getSystem())),
array('eq' => array('field' => 'fleet_end_planet', 'value' => $planet->getPosition())),
array('eq' => array('field' => 'fleet_end_type', 'value' => $planet->getType())),
array('date' => array('field' => 'fleet_end_time', 'value' => array('to' => $time))),
//array('date' => array('field' => 'fleet_end_time', 'value' => array('to' => $time))),
))
));
@ -32,6 +35,9 @@ class Wootook_Empire_Resource_Fleet_Collection
public function addIsVisibleToFilter(Wootook_Player_Model_Entity $player, $time = null)
{
if ($time === null) {
$time = new Wootook_Core_DateTime();
}
$this->addFieldToFilter(null, array(
array('and' => array(
array('eq' => array('field' => 'fleet_owner', 'value' => $player->getId())),

View file

@ -41,7 +41,7 @@ class Wootook_Player_Controller_AccountController
{
$session = new Wootook_Player_Model_Session();
if ($session->isLoggedIn()) {
$this->_redirect('player/overview');
$this->_redirect('*/overview');
return;
}
@ -55,27 +55,29 @@ class Wootook_Player_Controller_AccountController
$request = $this->getRequest();
if (!$request->isPost()) {
$this->_redirect('player/account/login');
$this->_redirect('*/*/login');
return;
}
if ($request->getPost('username') === null || $request->getPost('password') === null) {
$this->_redirect('player/account/login');
$this->_redirect('*/*/login');
return;
}
$session = new Wootook_Player_Model_Session();
if ($session->isLoggedIn()) {
$this->_redirect('player/overview');
$this->_redirect('*/overview');
return;
}
$session->login($request->getPost('username'), $request->getPost('password'), (bool) $request->getPost('rememberme'));
if ($session->isLoggedIn()) {
$this->_redirect('player/overview');
$this->_redirect('*/overview');
return;
} else {
$this->_redirect('player/account/login');
$this->_redirect('*/*/login');
return;
}
}
@ -84,6 +86,9 @@ class Wootook_Player_Controller_AccountController
$session = Wootook_Player_Model_Session::getSingleton();
if ($session->isLoggedIn()) {
$session->logout();
} else {
$this->_redirect('*/*/login');
return;
}
$this->_redirect('');
@ -93,16 +98,131 @@ class Wootook_Player_Controller_AccountController
{
$session = new Wootook_Player_Model_Session();
if ($session->isLoggedIn()) {
$this->_redirect('player/overview');
$this->_redirect('*/overview');
return;
}
$this->loadLayout('player.registration');
$this->_prepareLayoutMessages(Wootook_Player_Model_Entity::SESSION_KEY);
$this->renderLayout();
}
public function logoutSuccessAction()
public function newPostAction()
{
$session = Wootook_Player_Model_Session::getSingleton();
if ($session->isLoggedIn()) {
$this->_redirect('*/overview');
return;
}
$request = $this->getRequest();
if ($request->getPost('password') != $request->getPost('password_confirm')) {
$session->addError(Wootook::__('Passwords does not match. Please check your input.'));
$this->_redirect('*/*/new');
return;
}
if ($request->getPost('email') != $request->getPost('email_confirm')) {
$session->addError(Wootook::__('Both emails does not match. Please check your input.'));
$this->_redirect('*/*/new');
return;
}
try {
$user = Wootook_Player_Model_Entity::register($request->getPost('username'), $request->getPost('email'), $request->getPost('password'));
} catch (Wootook_Empire_Exception_RuntimeException $e) {
$session->addError(Wootook::__('Could not create user: %s', $e->getMessage()));
$this->_redirect('*/*/new');
return;
}
if (!$user || !$user->getId()) {
$session->addError(Wootook::__('Could not create user. Please contact the game administrator for more information.'));
$this->_redirect('*/*/new');
return;
}
$session->setLoggedIn($user);
if ($request->getPost('planet_name') != '') {
$user->getHomePlanet()->setName($request->getPost('planet_name'))->save();
} else {
$user->getHomePlanet()->setName(Wootook::__('Planet'))->save();
}
$this->_redirect('*/overview');
}
public function lostPasswordAction()
{
$session = new Wootook_Player_Model_Session();
if ($session->isLoggedIn()) {
$this->_redirect('*/overview');
return;
}
$this->loadLayout('player.lost-password');
$this->_prepareLayoutMessages(Wootook_Player_Model_Entity::SESSION_KEY);
$this->renderLayout();
}
/**
* Send new password by mail
*/
public function lostPasswordPostAction()
{
$session = new Wootook_Player_Model_Session();
if ($session->isLoggedIn()) {
$this->_redirect('*/overview');
return;
}
if (!$this->getRequest()->isPost()) {
$this->_redirect('*/*/lost-password');
return;
}
$email = $this->getRequest()->getPost('email');
$username = $this->getRequest()->getPost('username');
$player = new Wootook_Player_Model_Entity();
$player->loadByEmail($email);
if (!$player->getId() || strtolower($player->getUsername()) != strtolower(trim($username))) {
$session->addError(Wootook::__('The information you entered could not be found.'));
$this->_redirect('*/*/lost-password');
return;
}
$chars = array(
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P',
'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e',
'f', 'g', 'h', 'j', 'k', 'm', 'n', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z', '2', '3', '4', '5', '6', '7', '8', '9'
);
shuffle($chars);
$passwordChars = array_slice($chars, 0, 10);
$newPassword = implode($passwordChars);
$player->setPassword($newPassword)->save();
try {
$mailer = new Wootook_Core_Email();
$mailer->send(
array($player->getEmail() => $player->getUsername()),
array('contact@wootook.org' => 'Wootook'),
Wootook::__('Your new password'),
Wootook::__('Your new password is %s', $newPassword));
} catch (Wootook_Core_Exception_RuntimeException $e) {
Wootook_Player_Model_Session::getSingleton()
->addError($e->getMessage());
$this->_redirect('*/*/lost-password');
return;
}
$this->_redirect('*/*/login');
}
public function editAction()

View file

@ -6,10 +6,7 @@ class Wootook_Player_Controller_OverviewController
public function indexAction()
{
$this->loadLayout('player.overview');
$this->_prepareLayoutMessages(Wootook_Player_Model_Entity::SESSION_KEY);
$this->renderLayout();
/*
$this->getResponse()
->setRedirect(Wootook::getStaticUrl('overview.php'), Wootook_Core_Mvc_Controller_Response_Http::REDIRECT_TEMPORARY);
*/
}
}

View file

@ -88,6 +88,21 @@ class Wootook_Player_Model_Entity
return $this->getData('username');
}
public function getEmail()
{
return $this->getData('email');
}
public function loadByEmail($email)
{
return $this->load($email, 'email');
}
public function setPassword($newPassword)
{
return $this->setData('password', $this->hash($newPassword));
}
public static function hash($password, $salt = null)
{
if ($salt === null) {
@ -222,12 +237,10 @@ class Wootook_Player_Model_Entity
public function createNewPlanet($galaxy, $system, $position, $type, $name, $size = null)
{
if ($size === null) {
$baseSize = Wootook::getGameConfig('planet/initial/fields');
$factor = $position * 10 / (1 + log($position * 10));
$fuzz = 2 * $factor * pow(sin($factor), 2) / 2 + $factor / 4;
$size = mt_rand(floor($factor / 10), ceil($factor * 5 / 4)) + mt_rand(0, $fuzz);
$size = Wootook::getGameConfig('planet/initial/fields');
}
if ($size === null) {
$size = 200;
}
$now = new Wootook_Core_DateTime();
@ -464,6 +477,11 @@ class Wootook_Player_Model_Entity
return $this;
}
/**
* Returns all the flying fleets owned by the player
*
* @return Wootook_Empire_Resource_Fleet_Collection
*/
public function getFleets()
{
$collection = new Wootook_Empire_Resource_Fleet_Collection($this->getReadConnection());
@ -473,15 +491,22 @@ class Wootook_Player_Model_Entity
return $collection;
}
/**
* Counts all the flying fleets owned by the player
*
* @return mixed
*/
public function getFleetCount()
{
$collection = new Wootook_Empire_Resource_Fleet_Collection($this->getReadConnection());
$this->_prepareFleetCollection($collection);
return $collection->getSize();
return $this->getFleets()->getSize();
}
/**
* Returns all the visible fleets
*
* @param null $time
* @return Wootook_Empire_Resource_Fleet_Collection
*/
public function getVisibleFleets($time = null)
{
$collection = new Wootook_Empire_Resource_Fleet_Collection($this->getReadConnection());
@ -494,6 +519,19 @@ class Wootook_Player_Model_Entity
return $collection;
}
/**
* Returns all the visible fleets
*
* @param null $time
* @return Wootook_Empire_Resource_Fleet_Collection
* @deprecated
* @alias getVisibleFleets
*/
public function getFleetCollection($time = null)
{
return $this->getVisibleFleets($time);
}
public function getElement($elementId)
{
$fields = Wootook_Empire_Helper_Config_FieldsAlias::getSingleton();
@ -538,14 +576,6 @@ class Wootook_Player_Model_Entity
return false;
}
public function getFleetCollection($time = null)
{
$fleetCollection = new Wootook_Empire_Resource_Fleet_Collection($this->getReadConnection());
$fleetCollection->addIsVisibleToFilter($this, $time);
return $fleetCollection;
}
public function getNewMessagesCount()
{
$messageCollection = new Wootook_Player_Resource_Message_Collection($this->getReadConnection());
@ -582,6 +612,11 @@ class Wootook_Player_Model_Entity
}
}
public function isBanned()
{
return $this->getData('bana') ? true : false;
}
public function isVacation()
{
return $this->getData('urlaubs_modus') ? true : false;
@ -592,6 +627,11 @@ class Wootook_Player_Model_Entity
return $this->getData('urlaubs_until');
}
public function getLastLoginDate()
{
return $this->getData('onlinetime');
}
public function setVacation($active = true)
{
$this->setData('urlaubs_modus', $active);

View file

@ -23,9 +23,12 @@ class Wootook_Player_Resource_Entity_Collection
{
$onlineTime = (int) $onlineTime;
$date = new Wootook_Core_DateTime();
$date->sub($onlineTime, Wootook_Core_DateTime::TIMESTAMP);
if ($onlineTime > 0) {
$this->addFieldToFilter('onlinetime', array(array(
'gt' => new Wootook_Core_Database_Sql_Placeholder_Expression('UNIX_TIMESTAMP() - :online_time))', array('online_time' => $onlineTime))
Wootook_Core_Database_Sql_Select::OPERATOR_DATE => array('from' => $date)
)));
}

View file

@ -0,0 +1 @@
<?php

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,41 @@
<?php
/**
* Test class for Wootook_Object.
* Generated by PHPUnit on 2011-09-01 at 11:24:52.
*/
class Test_Legacies_Core_LayoutTest extends PHPUnit_Framework_TestCase
{
/**
* @var Wootook_Object
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->markTestIncomplete();
/*
$layoutDir = vfsStreamWrapper::getContent('');
vfsStream::addStructure(array());
$this->_object = new Legacies_Core_Layout();
*/
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
protected function tearDown()
{
}
public function testEmpty()
{
}
}

View file

@ -0,0 +1,237 @@
<?php
/**
* Test class for Wootook_Object.
* Generated by PHPUnit on 2011-09-01 at 11:24:52.
*/
class Test_Legacies_Empire_Model_BuilderTest extends PHPUnit_Framework_TestCase
{
/**
* @var Legacies_Empire_Model_Planet
*/
protected $_planet = null;
/**
* @var Legacies_Empire_Model_User
*/
protected $_user = null;
protected $_class = 'Legacies_Empire_Model_BuilderAbstract';
protected $_queueItemsData = null;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->_planet = new Legacies_Empire_Model_Planet(array(
'id' => 1,
'id_owner' => 1
));
$this->_user = new Legacies_Empire_Model_User(array(
'id' => 1
));
$this->_planet->setUser($this->_user);
$this->_user->setCurrentPlanet($this->_planet);
$this->_user->setHomePlanet($this->_planet);
$this->_queueItemsData = array(
'IDX0001' => array(
'item_id' => 1,
'level' => 1,
'created_at' => 0,
'updated_at' => 0
),
'IDX0002' => array(
'item_id' => 1,
'level' => 2,
'created_at' => 100,
'updated_at' => 100
),
'IDX0003' => array(
'item_id' => 1,
'level' => 3,
'created_at' => 150,
'updated_at' => 150
)
);
}
protected function _getMockedInstance($planet, $user, $methods = array())
{
$reflector = new ReflectionClass($this->_class);
foreach ($reflector->getMethods() as $method) {
if ($method->isAbstract()) {
$methods[] = $method->getName();
}
}
if (empty($methods)) {
$methods = null;
}
return $this->getMock($this->_class, $methods, array($planet, $user));
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
protected function tearDown()
{
}
public function testInit()
{
$stub = $this->getMockBuilder('Legacies_Empire_Model_BuilderAbstract')
->disableOriginalConstructor()
->setMethods(array('init', '_initItem', 'updateQueue', 'appendQueue', 'getResourcesNeeded', 'getBuildingTime'))
->getMock();
$stub->expects($this->once())
->method('init')
->will($this->returnValue($stub));
$stub->expects($this->never())
->method('_serializeQueue')
->will($this->returnValue($stub));
$stub->expects($this->never())
->method('_unserializeQueue')
->will($this->returnValue($stub));
$stub->__construct($this->_planet, $this->_user);
}
public function testSerializingQueue()
{
$items = array(
'IDX0001' => array(
'item_id' => 1,
'level' => 1,
'created_at' => 0,
'updated_at' => 0
),
'IDX0002' => array(
'item_id' => 1,
'level' => 2,
'created_at' => 100,
'updated_at' => 100
),
'IDX0003' => array(
'item_id' => 1,
'level' => 3,
'created_at' => 150,
'updated_at' => 150
)
);
$stub = $this->_getMockedInstance($this->_planet, $this->_user, array('_generateIndex'));
$stub->expects($this->exactly(3))
->method('_initItem')
->will($this->onConsecutiveCalls(
new Legacies_Empire_Model_Builder_Item($this->_queueItemsData['IDX0001']),
new Legacies_Empire_Model_Builder_Item($this->_queueItemsData['IDX0002']),
new Legacies_Empire_Model_Builder_Item($this->_queueItemsData['IDX0003'])
));
$stub->expects($this->exactly(3))
->method('_generateIndex')
->will($this->onConsecutiveCalls(
'IDX0001',
'IDX0002',
'IDX0003'
));
$stub->enqueue($this->_queueItemsData['IDX0001']);
$stub->enqueue($this->_queueItemsData['IDX0002']);
$stub->enqueue($this->_queueItemsData['IDX0003']);
$this->assertEquals(serialize($this->_queueItemsData), $stub->serialize());
}
public function testUnSerializingQueue()
{
$serializedData = serialize($this->_queueItemsData);
$stub = $this->_getMockedInstance($this->_planet, $this->_user, array('_generateIndex'));
$stub->expects($this->exactly(3))
->method('_initItem')
->will($this->onConsecutiveCalls(
new Legacies_Empire_Model_Builder_Item($this->_queueItemsData['IDX0001']),
new Legacies_Empire_Model_Builder_Item($this->_queueItemsData['IDX0002']),
new Legacies_Empire_Model_Builder_Item($this->_queueItemsData['IDX0003'])
));
$stub->expects($this->never())
->method('_generateIndex');
$stub->unserialize($serializedData);
$this->assertAttributeNotEmpty('_queue', $stub);
$this->assertEquals(serialize($this->_queueItemsData), $stub->serialize());
}
public function testUnSerializingQueueWithInvalidData()
{
$serializedData = '';
$stub = $this->_getMockedInstance($this->_planet, $this->_user, array('_generateIndex'));
$stub->expects($this->never())
->method('_initItem');
$stub->expects($this->never())
->method('_generateIndex');
$stub->unserialize($serializedData);
$this->assertAttributeEmpty('_queue', $stub);
$this->assertEquals('a:0:{}', $stub->serialize());
}
public function testInitItemReturningNull()
{
$serializedData = serialize($this->_queueItemsData);
$stub = $this->_getMockedInstance($this->_planet, $this->_user, array('_generateIndex'));
$stub->expects($this->exactly(3))
->method('_initItem')
->will($this->returnValue(null));
$stub->unserialize($serializedData);
$this->assertAttributeEmpty('_queue', $stub);
$this->assertEquals('a:0:{}', $stub->serialize());
}
public function testCheckAvailability()
{
$serializedData = serialize($this->_queueItemsData);
$stub = $this->_getMockedInstance($this->_planet, $this->_user, array('_generateIndex'));
$stub->expects($this->any())
->method('_initItem')
->will($this->onConsecutiveCalls(
new Legacies_Empire_Model_Builder_Item($this->_queueItemsData['IDX0001'])
));
$this->assertTrue($stub->checkAvailability(Legacies_Empire::ID_BUILDING_METAL_MINE));
$this->assertTrue($stub->checkAvailability(Legacies_Empire::ID_BUILDING_CRISTAL_MINE));
$this->assertTrue($stub->checkAvailability(Legacies_Empire::ID_BUILDING_DEUTERIUM_SYNTHETISER));
$this->assertTrue($stub->checkAvailability(Legacies_Empire::ID_BUILDING_FUSION_REACTOR));
}
}

View file

@ -0,0 +1,205 @@
<?php
/**
* Test class for Wootook_Object.
* Generated by PHPUnit on 2011-09-01 at 11:24:52.
*/
class Test_Wootook_ObjectTest extends PHPUnit_Framework_TestCase
{
/**
* @var Wootook_Object
*/
protected $_object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->_object = new Wootook_Object();
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
protected function tearDown()
{
}
/**
* @todo Implement testSetData().
*/
public function testSetData()
{
$this->assertAttributeEmpty('_data', $this->_object);
$this->_object->setData('test', true);
$expected = array('test' => true);
$this->assertAttributeEquals($expected, '_data', $this->_object);
$this->_object->setData('test', 'testing');
$expected = array('test' => 'testing');
$this->assertAttributeEquals($expected, '_data', $this->_object);
}
/**
* @requires testSetData
*/
public function testGetData()
{
$this->_object->setData('test', 'testing');
$this->assertEquals('testing', $this->_object->getData('test'));
$this->_object->setData('test', true);
$this->assertTrue($this->_object->getData('test'));
$this->assertNull($this->_object->getData('testing'));
}
/**
* @requires testSetData
* @requires testGetData
*/
public function testGetAllDatas()
{
$this->_object->setData('test', 'testing');
$expected = array('test' => 'testing');
$this->assertEquals($expected, $this->_object->getAllDatas());
$this->_object->setData('test', true);
$expected = array('test' => true);
$this->assertEquals($expected, $this->_object->getAllDatas());
}
/**
* @requires testSetData
* @requires testGetData
*/
public function testHasData()
{
$this->_object->setData('test', 'testing');
$this->assertTrue($this->_object->hasData('test'));
$this->assertFalse($this->_object->hasData('testing'));
}
/**
* @requires testSetData
*/
public function testAddData()
{
$this->_object->setData('test', 'testing');
$expected = array(
'test' => 'testing',
'testing' => true,
'legacies' => false
);
$this->_object->addData(array(
'testing' => true,
'legacies' => false
));
$this->assertAttributeEquals($expected, '_data', $this->_object);
$expected = array(
'test' => 'legacies',
'testing' => false,
'legacies' => 'Wootook_Object'
);
$this->_object->addData($expected);
$this->assertAttributeEquals($expected, '_data', $this->_object);
}
/**
* @requires testSetData
*/
public function testUnsetData()
{
$this->_object->setData('test', 'testing');
$this->_object->setData('testing', true);
$this->_object->setData('removed', 'me!');
$this->_object->setData('legacies', false);
$expected = array(
'test' => 'testing',
'testing' => true,
'legacies' => false
);
$this->_object->unsetData('removed');
$this->assertAttributeEquals($expected, '_data', $this->_object);
}
/**
* @todo Implement testClearData().
*/
public function testClearData()
{
$this->_object->setData('test', 'testing');
$this->_object->setData('testing', true);
$this->_object->setData('removed', 'me!');
$this->_object->setData('legacies', false);
$expected = array(
'test' => 'testing',
'testing' => true,
'legacies' => false
);
$this->_object->clearData();
$this->assertAttributeEmpty('_data', $this->_object);
}
/**
* @requires testSetData
* @requires testHasData
*/
public function testOffsetExists()
{
$this->_object->setData('test', 'testing');
$this->assertTrue(isset($this->_object['test']));
}
/**
* @requires testSetData
* @requires testGetData
*/
public function testOffsetGet()
{
$this->_object->setData('test', 'testing');
$this->assertEquals('testing', $this->_object['test']);
}
/**
* @requires testGetData
* @requires testSetData
*/
public function testOffsetSet()
{
$this->_object['test'] = 'testing';
$this->assertEquals('testing', $this->_object->getData('test'));
}
/**
* @requires testSetData
* @requires testGetData
*/
public function testOffsetUnset()
{
$this->_object->setData('test', 'testing');
unset($this->_object['test']);
$this->assertAttributeEmpty('_data', $this->_object);
$this->assertNull($this->_object->getData('test'));
}
}

View file

@ -0,0 +1,119 @@
<?php
class Test_WootookTest
extends PHPUnit_Framework_TestCase
{
protected function tearDown()
{
Wootook::clearAllListeners();
}
public function nonStaticListener($observer)
{
$observer->setData('success', true);
}
public static function staticListener($observer)
{
$observer->setData('success', true);
}
public function testRegisteringNonStaticEvent()
{
Wootook::registerListener('testing', array($this, 'nonStaticListener'));
$observer = Wootook::dispatchEvent('testing', array('success' => false));
$this->assertInstanceOf('Legacies_Core_Event', $observer);
$this->assertTrue($observer->getData('success'));
}
public function testRegisteringStaticEvent()
{
Wootook::registerListener('testing', array(get_class($this), 'staticListener'));
$observer = Wootook::dispatchEvent('testing', array('success' => false));
$this->assertInstanceOf('Legacies_Core_Event', $observer);
$this->assertTrue($observer->getData('success'));
}
public function testDispatchNonExistingEvent()
{
$observer = Wootook::dispatchEvent('testing', array('success' => true));
$this->assertInstanceOf('Legacies_Core_Event', $observer);
$this->assertTrue($observer->getData('success'));
}
/**
* @depends testRegisteringNonStaticEvent
*/
public function testUnregisteringNonStaticEvent()
{
Wootook::registerListener('testing', array($this, 'nonStaticListener'));
Wootook::clearEventListeners('testing');
$observer = Wootook::dispatchEvent('testing', array('success' => false));
$this->assertInstanceOf('Legacies_Core_Event', $observer);
$this->assertFalse($observer->getData('success'));
}
/**
* @depends testRegisteringStaticEvent
*/
public function testUnregisteringStaticEvent()
{
Wootook::registerListener('testing', array(get_class($this), 'staticListener'));
Wootook::clearEventListeners('testing');
$observer = Wootook::dispatchEvent('testing', array('success' => false));
$this->assertInstanceOf('Legacies_Core_Event', $observer);
$this->assertFalse($observer->getData('success'));
}
public function testGetSession()
{
$this->markTestSkipped('Sessions could not be tested in CLI.');
$this->assertInstanceOf('Legacies_Core_Model_Session', Wootook::getSession('test'));
}
public function testGetTranslator()
{
$this->assertInstanceOf('Legacies_Core_Model_Translator', Wootook::getTranslator('test'));
$this->assertInstanceOf('Legacies_Core_Model_Translator', Wootook::getTranslator());
}
public function testTranslate()
{
$this->assertEquals('My testing message!', Wootook::translate('test', 'My %s message!', array('testing')));
}
public function testTranslateGettextStyle()
{
$this->assertEquals('My testing message!', Wootook::__('My %s message!', 'testing'));
}
public function testSetDefaultLocale()
{
Wootook::setDefaultLocale('test');
$this->assertAttributeEquals('test', '_defaultLocale', 'Beyond');
}
/**
*
* @requires testSetDefaultLocale
*/
public function testGetDefaultLocale()
{
Wootook::setDefaultLocale('test');
$this->assertEquals('test', Wootook::getDefaultLocale());
}
}

View file

@ -0,0 +1,66 @@
<?php
set_include_path(implode(PATH_SEPARATOR, array(
dirname(__DIR__),
get_include_path()
)));
function frameworkAutoload($class) {
include_once str_replace('_', '/', $class) . '.php';
}
spl_autoload_register('frameworkAutoload');
include 'vfsStream/vfsStream.php';
vfsStream::create(array(
'includes' => array(
'application' => array(
'code' => array(
'community' => array(),
'core' => array(),
'libraries' => array(),
'local' => array(),
),
'design' => array(
'layouts' => array(),
'scripts' => array()
)
),
'data' => array(
'combat.php' => '<?php echo ' . var_export(array(), true),
'events.php' => '<?php echo ' . var_export(array(), true),
'fields-alias.php' => '<?php echo ' . var_export(array(), true),
'prices.php' => '<?php echo ' . var_export(array(), true),
'production.php' => '<?php echo ' . var_export(array(), true),
'requirements.php' => '<?php echo ' . var_export(array(), true),
'resources.php' => '<?php echo ' . var_export(array(), true),
'types.php' => '<?php echo ' . var_export(array(), true),
)
),
'config.php' => '<?php echo ' . var_export(array(
'global' => array(
'date' => array(
'timezone' => 'Europe/Paris'
),
'database' => array(
'engine' => 'mysql',
'options' => array(
'hostname' => 'localhost',
'username' => 'root',
'password' => '',
'database' => 'db_xnova'
),
'table_prefix' => 'game_',
),
'layout' => array(
'page' => 'page.php',
'empire' => 'empire.php'
)
)
), true) . ';'
), 'root', 644);
define('ROOT_PATH', vfsStream::url(''));
define('APPLICATION_PATH', vfsStream::url('includes/application'));

View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" ?>
<layout version="1.0">
<handle name="admin">
<update name="1column" />
<reference name="header">
<block name="navigation" type="core/html.navigation" template="page/html/navigation.phtml">
<action method="setNodeTitle">
<param name="path">system</action>
<param name="title">System</action>
</action>
<action method="setNodeTitle">
<param name="path">players</action>
<param name="title">Player Accounts</action>
</action>
</block>
</reference>
</handle>
</layout>

View file

@ -1,8 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<layout version="1.0">
<handle name="empire">
<update name="1column" />
<reference name="header">
<block name="navigation" type="core/html.navigation" template="page/html/navigation.phtml">
<action method="setNodeTitle">
@ -186,23 +184,44 @@
</reference>
</handle>
<handle name="deprecated">
<update name="1column" />
<update name="empire" />
</handle>
<handle name="message">
<update name="1column" />
<update name="empire" />
</handle>
<handle name="player.overview">
<update name="2columns-left" />
<update name="empire" />
<reference name="overview.left">
<reference name="root">
<action method="addBodyClass">
<param name="class">overview</param>
</action>
</reference>
<reference name="left">
<block type="empire/planet.overview" name="overview.planet.mini" template="player/overview/planet/mini.phtml" />
<block type="legacies-stats/view" name="overview.player.stats" template="player/overview/stats/mini.phtml" />
</reference>
<reference name="center">
<reference name="content">
<block type="empire/overview.fleet.list" name="overview.fleet.list" template="player/overview/fleet/list.phtml">
<action method="setItemTemplate">
<param name="template">player/overview/fleet/item.phtml</param>
</action>
<action method="setItemBlockType">
<param name="blockType">empire/overview.fleet.list.item</param>
</action>
</block>
</reference>
</handle>
<handle name="overview.rename-planet">
<update name="player.overview" />
<update name="1column" />
<update name="empire" />
<reference name="overview.center">
<block name="rename-planet" type="empire/overview.rename-planet" template="player/overview/form/rename-planet.phtml" />
@ -210,7 +229,8 @@
</handle>
<handle name="overview.destroy-planet">
<update name="player.overview" />
<update name="1column" />
<update name="empire" />
<reference name="overview.center">
<block name="rename-planet" type="empire/overview.destroy-planet" template="player/overview/form/destroy-planet.phtml" />
@ -218,6 +238,7 @@
</handle>
<handle name="planet.buildings">
<update name="1column" />
<update name="empire" />
<reference name="content">
@ -242,6 +263,7 @@
</handle>
<handle name="planet.shipyard">
<update name="1column" />
<update name="empire" />
<reference name="content">
@ -276,6 +298,7 @@
</handle>
<handle name="planet.research-lab">
<update name="1column" />
<update name="empire" />
<reference name="content">

View file

@ -59,8 +59,6 @@
</block>
</handle>
<handle name="public">
<update name="1column" />
<reference name="root">
<action method="addBodyClass">
<param name="class">public</param>
@ -90,6 +88,7 @@
</reference>
</handle>
<handle name="no-route">
<update name="1column" />
<update name="public" />
<reference name="content">
@ -103,6 +102,7 @@
</reference>
</handle>
<handle name="home">
<update name="1column" />
<update name="public" />
<reference name="root">

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<layout version="1.0">
<handle name="player.login">
<update name="1column" />
<update name="public" />
<reference name="root">
@ -24,6 +25,7 @@
</handle>
<handle name="player.registration">
<update name="1column" />
<update name="public" />
<reference name="root">
@ -47,6 +49,7 @@
</handle>
<handle name="player.lost-password">
<update name="1column" />
<update name="public" />
<reference name="root">
@ -68,21 +71,4 @@
<block name="registration" type="core/template" template="player/lost-password.phtml" />
</reference>
</handle>
<handle name="player.overview">
<update name="default" />
<reference name="content">
<block name="overview" type="player/overview" template="player/overview.phtml">
<block type="core/concat" name="overview.left" />
<block type="core/concat" name="overview.center" />
</block>
</reference>
<reference name="head">
<action method="setTitle">
<param name="title">Overview</param>
</action>
</reference>
</handle>
</layout>
</layout>

View file

@ -1,6 +1,6 @@
<?php if (!$this->isEmpty()):?>
<div class="building queue">
<h1><?php echo $this->__('Work in progress')?></h1>
<?php echo $this->getPartial('item-list')->render() ?>
<?php echo $this->renderPartial('item-list') ?>
</div>
<?php endif?>
<?php endif?>

View file

@ -7,11 +7,11 @@
<p class="planet-name"><a href="<?php echo $this->getStaticUrl('overview.php', array('cp' => $planet->getId()))?>"><?php echo $this->escape($planet->getName())?></a></p>
<div class="planet-image">
<?php if (false && ($moon = $planet->getMoon()) !== null): ?>
<a href="<?php echo $this->getStaticUrl('overview.php', array('cp' => $moon->getId()))?>" class="moon">
<a href="<?php echo $this->getUrl('player/overview', array('_query' => array('___planet' => $moon->getId())))?>" class="moon">
<img src="<?php echo $this->getSkinUrl($moon->getImage())?>" width="20" height="20"/>
</a>
<?php endif?>
<a href="<?php echo $this->getStaticUrl('overview.php', array('cp' => $planet->getId()))?>" class="planet">
<a href="<?php echo $this->getUrl('player/overview', array('_query' => array('___planet' => $planet->getId())))?>" class="planet">
<img src="<?php echo $this->getSkinUrl($planet->getImage())?>" width="50" height="50"/>
</a>
</div>

View file

@ -7,11 +7,14 @@
<div class="header">
<?php echo $this->header->render()?>
</div>
<div class="left">
<?php echo $this->left->render()?>
</div>
<div class="content">
<?php echo $this->content->render()?>
<div class="container">
<div class="left">
<?php echo $this->left->render()?>
</div>
<div class="content">
<?php echo $this->content->render()?>
</div>
<div class="clear"></div>
</div>
</div>
</body>

View file

@ -7,11 +7,14 @@
<div class="header">
<?php echo $this->header->render()?>
</div>
<div class="content">
<?php echo $this->content->render()?>
</div>
<div class="right">
<?php echo $this->left->render()?>
<div class="container">
<div class="content">
<?php echo $this->content->render()?>
</div>
<div class="right">
<?php echo $this->left->render()?>
</div>
<div class="clear"></div>
</div>
</div>
</body>

View file

@ -7,14 +7,17 @@
<div class="header">
<?php echo $this->header->render()?>
</div>
<div class="left">
<?php echo $this->left->render()?>
</div>
<div class="content">
<?php echo $this->content->render()?>
</div>
<div class="right">
<?php echo $this->left->render()?>
<div class="container">
<div class="left">
<?php echo $this->left->render()?>
</div>
<div class="content">
<?php echo $this->content->render()?>
</div>
<div class="right">
<?php echo $this->left->render()?>
</div>
<div class="clear"></div>
</div>
</div>
</body>

View file

@ -15,7 +15,7 @@
<input name="rememberme" id="login:remember-me" type="checkbox" class="input-checkbox" />
</p>
<p class="form lost-password">
<a href="<?php echo $this->getStaticUrl('lostpassword.php')?>" title="<?php echo $this->__('I have lost my password.')?>"><?php echo $this->__('I have lost my password.')?></a>
<a href="<?php echo $this->getUrl('player/account/lost-password')?>" title="<?php echo $this->__('I have lost my password.')?>"><?php echo $this->__('I have lost my password.')?></a>
</p>
</fieldset>
<p class="form submit">

View file

@ -6,9 +6,9 @@
<label for="lost-password:username"><?php echo $this->__('Username')?></label>
<input name="username" id="lost-password:username" value="" type="text" class="input-text" />
</p>
<p class="form password">
<p class="form email">
<label for="lost-password:email"><?php echo $this->__('Email')?></label>
<input name="email" id="lost-password:email" value="" type="text" class="input-password" />
<input name="email" id="lost-password:email" value="" type="text" class="input-text" />
</p>
</fieldset>
<p class="form submit">

View file

@ -1,21 +1,39 @@
<?php $fleet = $this->getData('fleet')?>
<?php $user = $this->getData('user')?>
<tr class="<?php echo $this->getData('class')?>">
<?php echo $this->getData('fleet_javai')?>
<td>
<div class="z">-</div>
<font color="lime"><?php echo $fleet->getArrivalTime()?></font>
</td>
<td colspan="3">
<?php if (!$fleet->isOwnedBy($user) || $fleet->isMission(Legacies_Empire::ID_MISSION_TRANSPORT) || $fleet->isMission(Legacies_Empire::ID_MISSION_STATION) || $fleet->isMission(Legacies_Empire::ID_MISSION_STATION_ALLY)):?>
<span class="<?php echo $fleet->getRowClass($user)?>"><?php echo $this->__('An hostile fleet sent by %1$s, coming from %2$s, reaches your planet %3$d. It has been sent with the mission: %4$d', $fleet->getOwner()->getUsername(), $fleet->getOriginPlanet()->getName(), $fleet->getDestinationPlanet()->getName(), $fleet->getMissionLabel())?></span>
<?php elseif ($fleet->isOwnedBy($user) || $fleet->isMission(Legacies_Empire::ID_MISSION_ATTACK) || $fleet->isMission(Legacies_Empire::ID_MISSION_GROUP_ATTACK) || $fleet->isMission(Legacies_Empire::ID_MISSION_DESTROY) || $fleet->isMission(Legacies_Empire::ID_MISSION_MISSILES) || $fleet->isMission(Legacies_Empire::ID_MISSION_SPY)):?>
<span class="<?php echo $fleet->getRowClass($user)?>"><?php echo $this->__('Your hostile fleet, sent from %1$s, reaches %2$d\'s planet %3$d. It has been sent with the mission: %4$d', $fleet->getOriginPlanet()->getName(), $fleet->getDestinationPlanet()->getUser()->getUsername(), $fleet->getDestinationPlanet()->getName(), $fleet->getMissionLabel())?></span>
<?php elseif ($fleet->isOwnedBy($user)):?>
<span class="<?php echo $fleet->getRowClass($user)?>"><?php echo $this->__('Your peaceful fleet, sent from %2$s, reaches the planet %3$d. It has been sent with the mission: %4$d', $fleet->getOwner()->getUsername(), $fleet->getOriginPlanet()->getName(), $fleet->getDestinationPlanet()->getName(), $fleet->getMissionLabel())?></span>
<?php else:?>
<span class="<?php echo $fleet->getRowClass($user)?>"><?php echo $this->__('A peaceful fleet sent by %1$s, coming from %2$s, reaches your planet %3$d. It has been sent with the mission: %4$d', $fleet->getOwner()->getUsername(), $fleet->getOriginPlanet()->getName(), $fleet->getDestinationPlanet()->getName(), $fleet->getMissionLabel())?></span>
<?php endif?>
</td>
<?php echo $this->getData('fleet_javas')?>
</tr>
<div class="fleet">
<span class="start-time"><?php echo $this->renderDateTime($this->getStartTime())?></span>
<span class="start-time"><?php echo $this->renderDateTime($this->getActionTime())?></span>
<span class="arrival-time"><?php echo $this->renderDateTime($this->getArrivalTime())?></span>
<div class="fleet-message">
<?php $player = $this->getPlayer() ?>
<?php if (!$this->isOwner() && ($this->isMission(Legacies_Empire::ID_MISSION_TRANSPORT) || $this->isMission(Legacies_Empire::ID_MISSION_STATION) || $this->isMission(Legacies_Empire::ID_MISSION_STATION_ALLY))):?>
<span class="<?php echo $this->getRowClass()?>">
<?php echo $this->__('An hostile fleet sent by %1$s, coming from %2$s[%3$s], reaches your planet %4$s[%5$s]. It has been sent with the mission: %6$s',
implode(', ', $this->getFleetOwnerUsernames()),
$this->getOriginPlanetName(), $this->getOriginPlanetCoords(),
$this->getDestinationPlanetName(), $this->getDestinationPlanetCoords(),
$this->getMissionLabel())?>
</span>
<?php elseif ($this->isOwner() && ($this->isMission(Legacies_Empire::ID_MISSION_ATTACK) || $this->isMission(Legacies_Empire::ID_MISSION_GROUP_ATTACK) || $this->isMission(Legacies_Empire::ID_MISSION_DESTROY) || $this->isMission(Legacies_Empire::ID_MISSION_MISSILES) || $this->isMission(Legacies_Empire::ID_MISSION_SPY))):?>
<span class="<?php echo $this->getRowClass()?>">
<?php echo $this->__('Your hostile fleet sent from %1$s[%2$s], reaches %3$s\'s planet %4$s[%5$s]. It has been sent with the mission: %6$s',
$this->getOriginPlanetName(), $this->getOriginPlanetCoords(),
implode(', ', $this->getFleetOwnerUsernames()),
$this->getDestinationPlanetName(), $this->getDestinationPlanetCoords(),
$this->getMissionLabel())?>
</span>
<?php elseif ($this->isOwner()):?>
<span class="<?php echo $this->getRowClass()?>">
<?php echo $this->__('Your peaceful fleet sent from %1$s[%2$s], reaches the planet %3$s[%4$s]. It has been sent with the mission: %5$s',
$this->getOriginPlanetName(), $this->getOriginPlanetCoords(),
$this->getDestinationPlanetName(), $this->getDestinationPlanetCoords(),
$this->getMissionLabel())?>
</span>
<?php else:?>
<span class="<?php echo $this->getRowClass()?>">
<?php echo $this->__('A peaceful fleet sent by %1$s, coming from %2$s[%3$s], reaches the planet %4$s[%5$s]. It has been sent with the mission: %6$s',
implode(', ', $this->getFleetOwnerUsernames()),
$this->getOriginPlanetName(), $this->getOriginPlanetCoords(),
$this->getDestinationPlanetName(), $this->getDestinationPlanetCoords(),
$this->getMissionLabel())?>
<?php endif?>
</div>
</div>

View file

@ -0,0 +1,9 @@
<div class="fleet item-container">
<h2><?php echo $this->__('Fleets') ?></h2>
<?php $collection = $this->getFleetCollection()?>
<?php if ($collection->getSize() > 0): ?>
<?php echo $this->renderPartial('item-list')?>
<?php else:?>
<p><?php echo $this->__('There are currently no fleets.')?></p>
<?php endif?>
</div>

View file

@ -1,7 +1,8 @@
<div id="overview:stats" class="item-container">
<h2><?php echo $this->escape($this->getPlanetName())?></h2>
<h3><?php echo $this->escape($this->getPlanetCoords())?></h3>
<p class="image">
<img src="<?php echo $this->getSkinUrl($this->getPlanetImage())?>" />
</p>
<h2><?php echo $this->__('Your statistics')?></h2>
<ul class="stats">
<?php foreach ($this->getPlayerStatData() as $stat): ?>
<li></li>
<?php endforeach ?>
</ul>
</div>

View file

@ -1,5 +1,5 @@
<?php echo $this->getLayout()->getMessagesBlock()->renderGroupedHtml()?>
<form id="register-form" name="register-form" action="<?php echo $this->getStaticUrl('player/account/register-post')?>" method="post" class="main-form">
<form id="register-form" name="register-form" action="<?php echo $this->getStaticUrl('player/account/new-post')?>" method="post" class="main-form">
<h1><?php echo $this->__('Register')?></h1>
<fieldset>
<legend><?php echo $this->__('User data:')?></legend>

View file

@ -9,14 +9,15 @@
'register.before' => array(),
'register.failure' => array(),
'register.success' => array(),
'planet.update' => array(
array('Wootook_Empire_Model_Planet', 'planetUpdateListener'),
array('Legacies_Empire_Model_Planet_Building_Shipyard', 'planetUpdateListener')
),
'user.init' => array(),
'planet.init' => array(
array('Wootook_Empire_Model_Galaxy_Position', 'initPlanetListerner')
),
'planet.update' => array(
array('Wootook_Empire_Model_Planet', 'planetUpdateListener'),
array('Legacies_Empire_Model_Planet_Building_Shipyard', 'planetUpdateListener'),
'flyingFleetListener'
),
'planet.shipyard.check-availability' => array(),
'planet.shipyard.update-queue.before' => array(),
'planet.shipyard.update-queue.after' => array(),
@ -34,5 +35,8 @@
),
'planet.research-lab.technology.speed-enhancement' => array(
array('Legacies_Empire_Model_Player_Technology_IntergalacticResearchNetwork', 'researchTechnologyEnhancementListener')
),
'core.mvc.controller.front.pre-dispatch' => array(
array('Wootook_Empire_Model_Planet', 'planetChangeListener')
)
);

View file

@ -425,19 +425,22 @@ if ($destinationUser['authlevel'] > $user['authlevel']) {
try {
$writeAdapter->beginTransaction();
$mapper = $writeAdapter->getDataMapper();
$dateMapper = $mapper->load('date-time');
$writeAdapter->insert()
->into($writeAdapter->getTable('fleets'))
->set('fleet_owner', $user->getId())
->set('fleet_mission', $mission)
->set('fleet_amount', $FleetShipCount)
->set('fleet_array', $serializedFleetArray)
->set('fleet_start_time', $startTime)
->set('fleet_start_time', $dateMapper->encode($startTime))
->set('fleet_start_galaxy', $planet->getGalaxy())
->set('fleet_start_system', $planet->getSystem())
->set('fleet_start_planet', $planet->getPosition())
->set('fleet_start_type', $planet->getType())
->set('fleet_end_time', $endTime)
->set('fleet_end_stay', $StayDuration)
->set('fleet_end_time', $dateMapper->encode($endTime))
->set('fleet_end_stay', $dateMapper->encode($StayTime))
->set('fleet_end_galaxy', $galaxy)
->set('fleet_end_system', $system)
->set('fleet_end_planet', $position)
@ -446,7 +449,7 @@ try {
->set('fleet_resource_crystal', intval($TransCrystal)) // FIXME: refactor field name
->set('fleet_resource_deuterium', intval($TransDeuterium))
->set('fleet_target_owner', $destination['id_owner'])
->set('start_time', time())
->set('start_time', $dateMapper->encode(time()))
->execute()
;
@ -481,10 +484,10 @@ $page .= "<th>". $lang['fl_deute_need'] ."</th>";
$page .= "<th>". pretty_number($consumption) ."</th>";
$page .= "</tr><tr height=\"20\">";
$page .= "<th>". $lang['fl_from'] ."</th>";
$page .= "<th>". $_POST['thisgalaxy'] .":". $_POST['thissystem']. ":". $_POST['thisplanet'] ."</th>";
$page .= "<th>". $planet->getCoords() ."</th>";
$page .= "</tr><tr height=\"20\">";
$page .= "<th>". $lang['fl_dest'] ."</th>";
$page .= "<th>". $galaxy .":". $system .":". $planet ."</th>";
$page .= "<th>". $galaxy . ':' . $system . ':' . $position ."</th>";
$page .= "</tr><tr height=\"20\">";
$page .= "<th>". $lang['fl_time_go'] ."</th>";
$page .= "<th>". date("M D d H:i:s", $startTime) ."</th>";
@ -494,10 +497,11 @@ $page .= "<th>". date("M D d H:i:s", $endTime) ."</th>";
$page .= "</tr><tr height=\"20\">";
$page .= "<td class=\"c\" colspan=\"2\">". $lang['fl_title'] ."</td>";
foreach ($fleetArray as $Ship => $Count) {
$helper = Wootook_Empire_Helper_Config_Labels::getSingleton();
foreach ($fleetArray as $shipId => $shipCount) {
$page .= "</tr><tr height=\"20\">";
$page .= "<th>". $lang['tech'][$Ship] ."</th>";
$page .= "<th>". pretty_number($Count) ."</th>";
$page .= "<th>". $helper[$shipId]['name'] ."</th>";
$page .= "<th>". pretty_number($shipCount) ."</th>";
}
$page .= "</tr></table></div></center>";

View file

@ -1,247 +0,0 @@
<?php
// Si la constante n'est pas defini on bloque l'execution du fichier
if(!defined('PHPSIMUL_PAGES') || @PHPSIMUL_PAGES != 'PHPSIMULLL')
{
die('Erreur 404 - Le fichier n\'a pas <20>t<EFBFBD> trouv<75>');
}
/* PHPsimul : Cr<EFBFBD>ez votre jeu de simulation en PHP
Copyright (<EFBFBD>) - 2007 - CAPARROS S<EFBFBD>bastien (Camaris)
Codeur officiel: Camaris & Max485
http://forum.epic-arena.fr
*/
class bb
{
##############################################################################################################
// Fonction d<>vlopp<70> par Max485 pour affichez le bbcode
function bbcode($texte)
{
//on supprime les slashs qui se seraient ajout<75>s automatiquement
$texte = stripslashes($texte) ;
//on d<>sactive le HTML
$texte = htmlspecialchars($texte) ;
//on g<>n<EFBFBD>re des retours chariots automatiques !!!
$texte = nl2br($texte) ;
//on cr<63>e le bbcode qui sera appliqu<71> <20> notre texte !
$bbcode=array(
//mise en gras
"!\[b\](.+)\[/b\]!isU",
//soulignement
"!\[u\](.+)\[/u\]!isU",
//mise en italique
"!\[i\](.+)\[/i\]!isU",
//mise en couleur
"!\[color=(.+)\](.+)\[/color\]!isU",
//liste <20> puces 1
"!\[ul\](.+)\[/ul\]!U",
//liste <20> puces 2
"!\[li\](.+)\[/li\]!U",
// Lien nomm<6D>
"!\[url=(.+?)\](.+?)\[\/url\]!i",
//afficher les images
"!\[img\](.+)\[/img\]!i",
// Lien
"!\[url\](.+?)\[\/url\]!i",
// Email nomm<6D>
"!\[email=(.+?)\](.+?)\[\/email\]!i",
// Email
"!\[email\](.+?)\[\/email\]!i",
// Size H1
"!\[size=1\](.+)\[/size\]!i",
// Size H2
"!\[size=2\](.+)\[/size\]!i",
// Size H3
"!\[size=3\](.+)\[/size\]!i",
// Size H4
"!\[size=4\](.+)\[/size\]!i",
// Size H5
"!\[size=5\](.+)\[/size\]!i",
// Size Tres petit
"!\[size=tres petit\](.+)\[/size\]!i",
// Size Petit
"!\[size=petit\](.+)\[/size\]!i",
// Size Normal
"!\[size=normal\](.+)\[/size\]!i",
// Size Moyen
"!\[size=moyen\](.+)\[/size\]!i",
// Size Grand
"!\[size=grand\](.+)\[/size\]!i",
// Size 18
"!\[size=18\](.+)\[/size\]!i",
// Quote
"!\[quote\](.+)\[/quote\]!i",
//Quote nomm<6D>
"!\[quote=(.+)\](.+)\[/quote\]!i",
// Code
"!\[code\](.+)\[/code\]!i",
);
$html = array(
//mise en gras
"<b>$1</b>",
//soulignement
"<u>$1</u>",
//mise en italique
"<i>$1</i>",
//mise en couleur
"<span style=\"color:$1\">$2</span>",
//liste <20> puce 1
"<ul>$1</ul>",
//liste <20> puce 2
"<li>$1</li>",
// Lien nomm<6D>
"<a href=\"$1\">$2</a>",
//afficher les images
"<img src=\"$1\">",
// Lien
"<a href=\"$1\">$1</a>",
// Email nomm<6D>
"<a href=\"mailto:$1\">$2</a>",
// Email
"<a href=\"mailto:$1\">$1</a>",
//Size H1
"<h1>$1</h1>",
//Size H2
"<h2>$1</h2>",
//Size H3
"<h3>$1</h3>",
//Size H4
"<h4>$1</h4>",
//Size H5
"<h5>$1</h5>",
//Size Tres Petit
"<h1>$1</h1>",
//Size Petit
"<h3>$1</h3>",
//Size Normal
"<h4>$1</h4>",
//Size Moyen
"<h6>$1</h6>",
//Size Grand
"<h7>$1</h7>",
// Size 18
"<h6>$1</h6>",
// Quote
"<br><u><b>Citation :</b></u><table cellpadding=\"2\" cellspacing=\"1\" border=\"0\" width=\"100%\" align=\"left\" bgcolor=\"red\"><tr><td bgcolor=\"#FFFFFF\"><font color=\"#000000\"><b>$1</b><br></font></td></tr></table><br><br>",
// Quote nomm<6D>
"<br><u><b>$1 :</b></u><table cellpadding=\"2\" cellspacing=\"1\" border=\"0\" width=\"100%\" align=\"left\" bgcolor=\"red\"><tr><td bgcolor=\"#FFFFFF\"><font color=\"#000000\"><b>$2</b><br></font></td></tr></table><br><br>",
// Code
"<br><u><b>Code :</b></u><table cellpadding=\"2\" cellspacing=\"1\" border=\"0\" width=\"100%\" align=\"left\" bgcolor=\"red\"><tr><td bgcolor=\"#FFFFFF\"><font color=\"#000000\"><b>$1</b><br></font></td></tr></table><br><br>",
);
$texte = preg_replace($bbcode,$html,$texte);
return $texte ;
}
##############################################################################################################
function div_page($nb_s,$d,$id,$cat,$nb_ep)
{
if($nb_s > $nb_ep)
{
$nb_p = ceil($nb_s / $nb_ep);
$p_suiv = $d+1;
$p_prec = $d-1;
if($d > 1)
{
echo '<a href="?cat='.$cat.'&amp;id='.$id.'&amp;d=1">&lt;&lt;&nbsp;</a>';
echo '<a href="?cat='.$cat.'&amp;id='.$id.'&amp;d='.$p_prec.'">&lt;&nbsp;</a>';
}
echo '<span class="p">&nbsp;Page n<> '.$d.' / '.$nb_p.'</span>';
if($d < $nb_p)
{
echo '<a href="?cat='.$cat.'&amp;id='.$id.'&amp;d='.$p_suiv.'">&nbsp;&gt;</a>';
echo '<a href="?cat='.$cat.'&amp;id='.$id.'&amp;d='.$nb_p.'">&nbsp;&gt;&gt;</a>';
}
echo ' <br /><br />';
}
}
function div_page_l($nb_s,$d,$id,$p,$s)
{
if(strlen($s) > 1)
{
$s_lien = "&amp;s=".$s;
}
else
{
$s_lien = "";
}
if($nb_s > 10)
{
echo' <br />';
$nb_p = ceil($nb_s / 10);
$p_suiv = $p+1;
$p_prec = $p-1;
if($p > 1)
{
echo '<a href="?cat=4&amp;id='.$id.'&amp;d='.$d.'&amp;p=1'.$s_lien.'">&lt;&lt;&nbsp;</a>';
echo '<a href="?cat=4&amp;id='.$id.'&amp;d='.$d.'&amp;p='.$p_prec.$s_lien.'">&lt;&nbsp;</a>';
}
echo '<span class="p">&nbsp;Page n<> '.$p.' / '.$nb_p.'</span>';
if($p < $nb_p)
{
echo '<a href="?cat=4&amp;id='.$id.'&amp;d='.$d.'&amp;p='.$p_suiv.$s_lien.'">&nbsp;&gt;</a>';
echo '<a href="?cat=4&amp;id='.$id.'&amp;d='.$d.'&amp;p='.$nb_p.$s_lien.'">&nbsp;&gt;&gt;</a>';
}
echo ' <br />';
}
}
##############################################################################################################
function smileys($chaine)
{
global $userrow;
$chaine = str_replace(":D", "<img alt='' style='border:0px;' src='templates/".$userrow["template"]."/images/forum/smileys/sourire.gif' />", $chaine);
$chaine = str_replace(";)", "<img alt='' style='border:0px;' src='templates/".$userrow["template"]."/images/forum/smileys/clin.gif' />", $chaine);
$chaine = str_replace(":(", "<img alt='' style='border:0px;' src='templates/".$userrow["template"]."/images/forum/smileys/triste.gif' />", $chaine);
$chaine = str_replace(":surpris:", "<img alt='' style='border:0px;' src='templates/".$userrow["template"]."/images/forum/smileys/yeuxrond.gif' />", $chaine);
$chaine = str_replace(":o", "<img alt='' style='border:0px;' src='templates/".$userrow["template"]."/images/forum/smileys/etonne.gif' />", $chaine);
$chaine = str_replace(":confus:", "<img alt='' style='border:0px;' src='templates/".$userrow["template"]."/images/forum/smileys/confus.gif' />", $chaine);
$chaine = str_replace(":lol:", "<img alt='' style='border:0px;' src='templates/".$userrow["template"]."/images/forum/smileys/lol.gif' />", $chaine);
$chaine = str_replace(":fire:", "&nbsp;<img alt='' style='border:0px;' src='templates/".$userrow["template"]."/images/forum/smileys/flame.gif' />", $chaine);
$chaine = str_replace(":splif:", "<img alt='' style='border:0px;' src='templates/".$userrow["template"]."/images/forum/smileys/petard.gif' />", $chaine);
$chaine = str_replace(":bigsmile:", "<img alt='' style='border:0px;' src='templates/".$userrow["template"]."/images/forum/smileys/green.gif' />", $chaine);
$chaine = str_replace(":x", "<img alt='' style='border:0px;' src='templates/".$userrow["template"]."/images/forum/smileys/mod.gif' />", $chaine);
$chaine = str_replace(":roll:", "<img alt='' style='border:0px;' src='templates/".$userrow["template"]."/images/forum/smileys/rolleyes.gif' />", $chaine);
$chaine = str_replace(":bigcry:", "<img alt='' style='border:0px;' src='templates/".$userrow["template"]."/images/forum/smileys/crying.gif' />", $chaine);
$chaine = str_replace(":colere:", "<img alt='' style='border:0px;' src='templates/".$userrow["template"]."/images/forum/smileys/colere.gif' />", $chaine);
$chaine = str_replace(":P", "<img alt='' style='border:0px;' src='templates/".$userrow["template"]."/images/forum/smileys/razz.gif' />", $chaine);
$chaine = str_replace("8)", "<img alt='' style='border:0px;' src='templates/".$userrow["template"]."/images/forum/smileys/lunettes.gif' />", $chaine);
$chaine = str_replace(":)", "<img alt='' style='border:0px;' src='templates/".$userrow["template"]."/images/forum/smileys/sourire.gif' />", $chaine);
$chaine = str_replace("^^oops:", "<img alt='' style='border:0px;' src='templates/".$userrow["template"]."/images/forum/smileys/redface.gif.gif' />", $chaine);
return($chaine);
}
}
?>

View file

@ -529,7 +529,7 @@ function display($page, $title = '', $topnav = true, $metatags = '', $adminPage
// TODO: implement extra meta tags
$layout = Deprecated::getLayout($adminPage);
if ($adminPage === false) {
$layout->load('empire');
$layout->load('deprecated');
} else {
$layout->setDomain(Wootook_Core_Model_Layout::DOMAIN_BACKEND);
$layout->load('admin');
@ -715,3 +715,108 @@ function AdminMessage($message, $title = 'Error', $dest = null, $time = '3', $co
echo $layout->render();
exit(0);
}
/**
*
* @deprecated
* @param Wootook_Empire_Model_Planet $planet
*/
function flyingFleetListener($event)
{
// defined('DEPRECATION') || Wootook_Core_ErrorProfiler::getSingleton()->addException(new Wootook_Core_Exception_Deprecated(sprintf('Function "%s" is deprecated', __FUNCTION__)));
$planet = $event->getData('planet');
FlyingFleetHandler($planet);
}
/**
*
* @deprecated
* @param Wootook_Empire_Model_Planet $planet
*/
function FlyingFleetHandler($planet)
{
// defined('DEPRECATION') || Wootook_Core_ErrorProfiler::getSingleton()->addException(new Wootook_Core_Exception_Deprecated(sprintf('Function "%s" is deprecated', __FUNCTION__)));
foreach ($planet->getFleetCollection()->load() as $fleet) {
try {
$fleet->getWriteConnection()->beginTransaction();
switch ($fleet["fleet_mission"]) {
case Legacies_Empire::ID_MISSION_ATTACK:
// Attaquer
MissionCaseAttack($fleet);
break;
case Legacies_Empire::ID_MISSION_TRANSPORT:
// Transporter
MissionCaseTransport($fleet);
break;
case Legacies_Empire::ID_MISSION_STATION:
// Stationner
MissionCaseStay($fleet);
break;
case Legacies_Empire::ID_MISSION_STATION_ALLY:
// Stationner chez un Allié
MissionCaseStayAlly($fleet);
break;
case Legacies_Empire::ID_MISSION_SPY:
// Flotte d'espionnage
MissionCaseSpy($fleet);
break;
case Legacies_Empire::ID_MISSION_SETTLE_COLONY:
// Coloniser
MissionCaseColonisation($fleet);
break;
case Legacies_Empire::ID_MISSION_RECYCLE:
// Recyclage
MissionCaseRecycling($fleet);
break;
case Legacies_Empire::ID_MISSION_DESTROY:
// Detruire ??? dans le code ogame c'est 9 !!
MissionCaseDestruction($fleet);
break;
case Legacies_Empire::ID_MISSION_EXPEDITION:
// Expeditions
MissionCaseExpedition($fleet);
break;
case Legacies_Empire::ID_MISSION_ORE_MINING:
// Exploitation
MissionCaseExploit($fleet);
break;
case Legacies_Empire::ID_MISSION_GROUP_ATTACK: // TODO: implement mission type
case Legacies_Empire::ID_MISSION_MISSILES: // TODO: implement mission type
default:
$fleet->delete();
break;
}
$fleet->getWriteConnection()->commit();
} catch (Wootook_Core_Exception_Exception $e) {
$fleet->getWriteConnection()->rollback();
Wootook_Core_ErrorProfiler::getSingleton()->addException($e);
}
}
}
/**
*
* @deprecated
* @param unknown_type $String
*/
function CheckInputStrings($string)
{
defined('DEPRECATION') || Wootook_Core_ErrorProfiler::getSingleton()->addException(new Wootook_Core_Exception_Deprecated(sprintf('Function "%s" is deprecated', __FUNCTION__)));
return htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
}

View file

@ -1,39 +0,0 @@
<?php
/**
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.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.
*
*/
/**
*
* @deprecated
* @param unknown_type $String
*/
function CheckInputStrings($string)
{
return htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
}

View file

@ -1,74 +0,0 @@
<?php
/**
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.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.
*
*/
/**
*
* @deprecated
* @param unknown_type $UserID
*/
function DeleteSelectedUser ( $UserID ) {
trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED);
$TheUser = doquery ( "SELECT * FROM {{table}} WHERE `id` = '" . $UserID . "';", 'users', true );
if ( $TheUser['ally_id'] != 0 ) {
$TheAlly = doquery ( "SELECT * FROM {{table}} WHERE `id` = '" . $TheUser['ally_id'] . "';", 'alliance', true );
$TheAlly['ally_members'] -= 1;
if ( $TheAlly['ally_members'] > 0 ) {
doquery ( "UPDATE {{table}} SET `ally_members` = '" . $TheAlly['ally_members'] . "' WHERE `id` = '" . $TheAlly['id'] . "';", 'alliance' );
} else {
doquery ( "DELETE FROM {{table}} WHERE `id` = '" . $TheAlly['id'] . "';", 'alliance' );
doquery ( "DELETE FROM {{table}} WHERE `stat_type` = '2' AND `id_owner` = '" . $TheAlly['id'] . "';", 'statpoints' );
}
}
doquery ( "DELETE FROM {{table}} WHERE `stat_type` = '1' AND `id_owner` = '" . $UserID . "';", 'statpoints' );
$ThePlanets = doquery ( "SELECT * FROM {{table}} WHERE `id_owner` = '" . $UserID . "';", 'planets' );
while ( $OnePlanet = $ThePlanets->fetch(PDO::FETCH_ASSOC) ) {
if ( $OnePlanet['planet_type'] == 1 ) {
doquery ( "DELETE FROM {{table}} WHERE `galaxy` = '" . $OnePlanet['galaxy'] . "' AND `system` = '" . $OnePlanet['system'] . "' AND `planet` = '" . $OnePlanet['planet'] . "';", 'galaxy' );
} elseif ( $OnePlanet['planet_type'] == 3 ) {
doquery ( "DELETE FROM {{table}} WHERE `galaxy` = '" . $OnePlanet['galaxy'] . "' AND `system` = '" . $OnePlanet['system'] . "' AND `lunapos` = '" . $OnePlanet['planet'] . "';", 'lunas' );
}
doquery ( "DELETE FROM {{table}} WHERE `id` = '" . $OnePlanet['id'] . "';", 'planets' );
}
doquery ( "DELETE FROM {{table}} WHERE `message_sender` = '" . $UserID . "';", 'messages' );
doquery ( "DELETE FROM {{table}} WHERE `message_owner` = '" . $UserID . "';", 'messages' );
doquery ( "DELETE FROM {{table}} WHERE `owner` = '" . $UserID . "';", 'notes' );
doquery ( "DELETE FROM {{table}} WHERE `fleet_owner` = '" . $UserID . "';", 'fleets' );
doquery ( "DELETE FROM {{table}} WHERE `id_owner1` = '" . $UserID . "';", 'rw' );
doquery ( "DELETE FROM {{table}} WHERE `id_owner2` = '" . $UserID . "';", 'rw' );
doquery ( "DELETE FROM {{table}} WHERE `sender` = '" . $UserID . "';", 'buddy' );
doquery ( "DELETE FROM {{table}} WHERE `owner` = '" . $UserID . "';", 'buddy' );
doquery ( "DELETE FROM {{table}} WHERE `user` = '" . $UserID . "';", 'annonce' );
doquery ( "DELETE FROM {{table}} WHERE `id` = '" . $UserID . "';", 'users' );
}
?>

View file

@ -1,71 +0,0 @@
<?php
/**
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.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.
*
*/
/**
*
* @deprecated
* @param unknown_type $CurrentUser
* @param unknown_type $CurrentPlanet
*/
function ElementBuildListBox ( $CurrentUser, $CurrentPlanet ) {
global $lang, $pricelist;
trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED);
// // Array del b_hangar_id
// $ElementQueue = explode(';', $CurrentPlanet['b_hangar_id']);
// $NbrePerType = "";
// $NamePerType = "";
// $TimePerType = "";
//
// foreach($ElementQueue as $ElementLine => $Element) {
// if ($Element != '') {
// $Element = explode(',', $Element);
// $ElementTime = GetBuildingTime( $CurrentUser, $CurrentPlanet, $Element[0] );
// $QueueTime += $ElementTime * $Element[1];
// $TimePerType .= "".$ElementTime.",";
// $NamePerType .= "'". html_entity_decode($lang['tech'][$Element[0]]) ."',";
// $NbrePerType .= "".$Element[1].",";
// }
// }
//
// $parse = $lang;
// $parse['a'] = $NbrePerType;
// $parse['b'] = $NamePerType;
// $parse['c'] = $TimePerType;
// $parse['b_hangar_id_plus'] = $CurrentPlanet['b_hangar'];
//
// $parse['pretty_time_b_hangar'] = pretty_time($QueueTime - $CurrentPlanet['b_hangar']);
//
// $text .= parsetemplate(gettemplate('buildings_script'), $parse);
//
// return $text;
}
?>

View file

@ -1,108 +0,0 @@
<?php
/**
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.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.
*
*/
/**
*
* @deprecated
* @param unknown_type $planet
*/
function FlyingFleetHandler($planet) {
global $resource;
$sql =<<<SQL_EOF
LOCK TABLE
{{table}}lunas WRITE,
{{table}}rw WRITE,
{{table}}errors WRITE,
{{table}}messages WRITE,
{{table}}fleets WRITE,
{{table}}planets WRITE,
{{table}}galaxy WRITE,
{{table}}users WRITE
SQL_EOF;
//doquery($sql, ''); // FIXME: use transactions
foreach ($planet->getFleetCollection(Wootook::now()) as $CurrentFleet) {
switch ($CurrentFleet["fleet_mission"]) {
case Legacies_Empire::ID_MISSION_ATTACK:
// Attaquer
MissionCaseAttack ( $CurrentFleet );
break;
case Legacies_Empire::ID_MISSION_TRANSPORT:
// Transporter
MissionCaseTransport ( $CurrentFleet );
break;
case Legacies_Empire::ID_MISSION_STATION:
// Stationner
MissionCaseStay ( $CurrentFleet );
break;
case Legacies_Empire::ID_MISSION_STATION_ALLY:
// Stationner chez un Allié
MissionCaseStayAlly ( $CurrentFleet );
break;
case Legacies_Empire::ID_MISSION_SPY:
// Flotte d'espionnage
MissionCaseSpy ( $CurrentFleet );
break;
case Legacies_Empire::ID_MISSION_SETTLE_COLONY:
// Coloniser
MissionCaseColonisation ( $CurrentFleet );
break;
case Legacies_Empire::ID_MISSION_RECYCLE:
// Recyclage
MissionCaseRecycling ( $CurrentFleet );
break;
case Legacies_Empire::ID_MISSION_DESTROY:
// Detruire ??? dans le code ogame c'est 9 !!
MissionCaseDestruction ( $CurrentFleet );
break;
case Legacies_Empire::ID_MISSION_EXPEDITION:
// Expeditions
MissionCaseExpedition ( $CurrentFleet );
break;
case Legacies_Empire::ID_MISSION_GROUP_ATTACK: // TODO: implement mission type
case Legacies_Empire::ID_MISSION_MISSILES: // TODO: implement mission type
default:
$CurrentFleet->delete();
break;
}
}
//doquery("UNLOCK TABLES", ""); // FIXME: use transactions
}

View file

@ -109,7 +109,7 @@ function GalaxyRowPlanet ( $GalaxyRow, $GalaxyRowPlanet, $GalaxyRowUser, $Galaxy
$Result .= "</tr>";
$Result .= "<tr>";
$Result .= "<th width=80>";
$Result .= "<img src=". $dpath ."planeten/small/s_". $GalaxyRowPlanet["image"] .".jpg height=75 width=75 />";
$Result .= "<img src=". $dpath ."graphics/planeten/small/s_". $GalaxyRowPlanet["image"] .".jpg height=75 width=75 />";
$Result .= "</th>";
$Result .= "<th align=left>";
$Result .= $MissionType6Link;
@ -124,7 +124,7 @@ function GalaxyRowPlanet ( $GalaxyRow, $GalaxyRowPlanet, $GalaxyRowUser, $Galaxy
// $Result .= ", STICKY, MOUSEOFF, DELAY, ". ($user["settings_tooltiptime"] * 1000) .", CENTER, OFFSETX, -40, OFFSETY, -40 );'";
$Result .= ", STICKY, MOUSEOFF, DELAY, 750, CENTER, OFFSETX, -40, OFFSETY, -40 );'";
$Result .= " onmouseout='return nd();'>";
$Result .= "<img src=". $dpath ."planeten/small/s_". $GalaxyRowPlanet["image"] .".jpg height=30 width=30>";
$Result .= "<img src=". $dpath ."graphics/planeten/small/s_". $GalaxyRowPlanet["image"] .".jpg height=30 width=30>";
// $Result .= $GalaxyRowPlanet["name"];
$Result .= "</a>";
}
@ -133,4 +133,4 @@ function GalaxyRowPlanet ( $GalaxyRow, $GalaxyRowPlanet, $GalaxyRowUser, $Galaxy
return $Result;
}
?>
?>

View file

@ -62,9 +62,14 @@ function GalaxyRowPlanetName ( $GalaxyRow, $GalaxyRowPlanet, $GalaxyRowUser, $Ga
$EndColor = "";
}
if ($GalaxyRowPlanet['last_update'] > (time()-59 * 60) AND
$GalaxyRowUser['id'] != $user['id']) {
$Inactivity = pretty_time_hour(time() - $GalaxyRowPlanet['last_update']);
$updateTimeLimit = new Wootook_Core_DateTime();
$updateTimeLimit->sub(3600);
if ($updateTimeLimit->isLater($GalaxyRowPlanet['last_update']) && $GalaxyRowUser['id'] != $user['id']) {
if ($GalaxyRowPlanet['last_update'] instanceof Wootook_Core_DateTime) {
$Inactivity = pretty_time_hour(time() - $GalaxyRowPlanet['last_update']->getTimestamp());
} else {
$Inactivity = pretty_time_hour(0);
}
}
if ($GalaxyRow && $GalaxyRowPlanet["destruyed"] == 0) {
if ($HavePhalanx <> 0) {
@ -85,22 +90,25 @@ function GalaxyRowPlanetName ( $GalaxyRow, $GalaxyRowPlanet, $GalaxyRowUser, $Ga
$Result .= $TextColor . $PhalanxTypeLink . $EndColor;
if ($GalaxyRowPlanet['last_update'] > (time()-59 * 60) AND
$GalaxyRowUser['id'] != $user['id']) {
if ($GalaxyRowPlanet['last_update'] > (time()-10 * 60) AND
$GalaxyRowUser['id'] != $user['id']) {
$Result .= "(*)";
} else {
$Result .= " (".$Inactivity.")";
}
}
} elseif ($GalaxyRowPlanet["destruyed"] != 0) {
$Result .= $lang['gl_destroyedplanet'];
}
if ($GalaxyRowUser->getId() && $updateTimeLimit->isLater($GalaxyRowPlanet['last_update']) &&
$GalaxyRowUser['id'] != $user['id']) {
$updateTimeLimit = new Wootook_Core_DateTime();
$updateTimeLimit->sub(600);
if ($GalaxyRowUser->getId() && $updateTimeLimit->isLater($GalaxyRowPlanet['last_update']) &&
$GalaxyRowUser['id'] != $user['id']) {
$Result .= "(*)";
} else {
$Result .= " (".$Inactivity.")";
}
}
} elseif ($GalaxyRowPlanet["destruyed"] != 0) {
$Result .= $lang['gl_destroyedplanet'];
}
$Result .= "</th>";
return $Result;
}
?>
?>

View file

@ -31,111 +31,106 @@
/**
*
* @deprecated
* @param unknown_type $GalaxyRow
* @param unknown_type $GalaxyRowPlanet
* @param unknown_type $GalaxyRowUser
* @param unknown_type $Galaxy
* @param unknown_type $System
* @param unknown_type $Planet
* @param unknown_type $PlanetType
* @param Wootook_Empire_Model_Planet $currentPlanet
* @param Wootook_Player_Model_Entity $currentPlayer
*/
function GalaxyRowUser ( $GalaxyRow, $GalaxyRowPlanet, $GalaxyRowUser, $Galaxy, $System, $Planet, $PlanetType ) {
global $lang, $user;
function GalaxyRowUser($currentPlanet, $currentPlayer) {
global $user;
// Joueur
$Result = "<th width=150>";
if ($GalaxyRowUser && $GalaxyRowPlanet["destruyed"] == 0) {
$NoobProt = doquery("SELECT * FROM {{table}} WHERE `config_name` = 'noobprotection';", 'config', true);
$NoobTime = doquery("SELECT * FROM {{table}} WHERE `config_name` = 'noobprotectiontime';", 'config', true);
$NoobMulti = doquery("SELECT * FROM {{table}} WHERE `config_name` = 'noobprotectionmulti';", 'config', true);
$UserPoints = doquery("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '". $user['id'] ."';", 'statpoints', true);
$User2Points = doquery("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '". $GalaxyRowUser['id'] ."';", 'statpoints', true);
$CurrentPoints = $UserPoints['total_points'];
$RowUserPoints = $User2Points['total_points'];
$CurrentLevel = $CurrentPoints * $NoobMulti['config_value'];
$RowUserLevel = $RowUserPoints * $NoobMulti['config_value'];
if ($GalaxyRowUser['bana'] == 1 AND
$GalaxyRowUser['urlaubs_modus'] == 1) {
$Systemtatus2 = $lang['vacation_shortcut']." <a href=\"banned.php\"><span class=\"banned\">".$lang['banned_shortcut']."</span></a>";
$Systemtatus = "<span class=\"vacation\">";
} elseif ($GalaxyRowUser['bana'] == 1) {
$Systemtatus2 = "<a href=\"banned.php\"><span class=\"banned\">".$lang['banned_shortcut']."</span></a>";
$Systemtatus = "";
} elseif ($GalaxyRowUser['urlaubs_modus'] == 1) {
$Systemtatus2 = "<span class=\"vacation\">".$lang['vacation_shortcut']."</span>";
$Systemtatus = "<span class=\"vacation\">";
} elseif ($GalaxyRowUser['onlinetime'] < (time()-60 * 60 * 24 * 7) AND
$GalaxyRowUser['onlinetime'] > (time()-60 * 60 * 24 * 28)) {
$Systemtatus2 = "<span class=\"inactive\">".$lang['inactif_7_shortcut']."</span>";
$Systemtatus = "<span class=\"inactive\">";
} elseif ($GalaxyRowUser['onlinetime'] < (time()-60 * 60 * 24 * 28)) {
$Systemtatus2 = "<span class=\"inactive\">".$lang['inactif_7_shortcut']."</span><span class=\"longinactive\"> ".$lang['inactif_28_shortcut']."</span>";
$Systemtatus = "<span class=\"longinactive\">";
} elseif ($RowUserLevel < $CurrentPoints AND
$NoobProt['config_value'] == 1 AND
$NoobTime['config_value'] * 1000 > $RowUserPoints) {
$Systemtatus2 = "<span class=\"noob\">".$lang['weak_player_shortcut']."</span>";
$Systemtatus = "<span class=\"noob\">";
} elseif ($RowUserPoints > $CurrentLevel AND
$NoobProt['config_value'] == 1 AND
$NoobTime['config_value'] * 1000 > $CurrentPoints) {
$Systemtatus2 = $lang['strong_player_shortcut'];
$Systemtatus = "<span class=\"strong\">";
} else {
$Systemtatus2 = "";
$Systemtatus = "";
}
$Systemtatus4 = $User2Points['total_rank'];
if ($Systemtatus2 != '') {
$Systemtatus6 = "<font color=\"white\">(</font>";
$Systemtatus7 = "<font color=\"white\">)</font>";
}
if ($Systemtatus2 == '') {
$Systemtatus6 = "";
$Systemtatus7 = "";
}
$admin = "";
if ($GalaxyRowUser['authlevel'] == LEVEL_ADMIN) {
$admin = "<font color=\"red\"><blink>A</blink></font>";
} else if ($GalaxyRowUser['authlevel'] == LEVEL_OPERATOR) {
$admin = "<font color=\"lime\"><blink>O</blink></font>";
} else if ($GalaxyRowUser['authlevel'] == LEVEL_MODERATOR) {
$admin = "<font color=\"skyblue\"><blink>M</blink></font>";
}
$Systemtart = $User2Points['total_rank'];
if (strlen($Systemtart) < 3) {
$Systemtart = 1;
} else {
$Systemtart = (floor( $User2Points['total_rank'] / 100 ) * 100) + 1;
}
$Result .= "<a style=\"cursor: pointer;\"";
$Result .= " onmouseover='return overlib(\"";
$Result .= "<table width=190>";
$Result .= "<tr>";
$Result .= "<td class=c colspan=2>".$lang['Player']." ".$GalaxyRowUser['username']." ".$lang['Place']." ".$Systemtatus4."</td>";
$Result .= "</tr><tr>";
if ($GalaxyRowUser['id'] != $user['id']) {
$Result .= "<td><a href=messages.php?mode=write&id=".$GalaxyRowUser['id'].">".$lang['gl_sendmess']."</a></td>";
$Result .= "</tr><tr>";
$Result .= "<td><a href=buddy.php?a=2&u=".$GalaxyRowUser['id'].">".$lang['gl_buddyreq']."</a></td>";
$Result .= "</tr><tr>";
}
$Result .= "<td><a href=stat.php?who=player&start=".$Systemtart.">".$lang['gl_stats']."</a></td>";
$Result .= "</tr>";
$Result .= "</table>\"";
$Result .= ", STICKY, MOUSEOFF, DELAY, 750, CENTER, OFFSETX, -40, OFFSETY, -40 );'";
$Result .= " onmouseout='return nd();'>";
$Result .= $Systemtatus;
$Result .= $GalaxyRowUser["username"]."</span>";
$Result .= $Systemtatus6;
$Result .= $Systemtatus;
$Result .= $Systemtatus2;
$Result .= $Systemtatus7." ".$admin;
$Result .= "</span></a>";
}
$Result .= "</th>";
if (is_array($currentPlayer)) {
$currentPlayer = new Wootook_Player_Model_Entity($currentPlayer);
}
if (is_array($currentPlanet)) {
$currentPlanet = new Wootook_Empire_Model_Planet($currentPlanet);
$currentPlanet->setData('last_update', new Wootook_Core_DateTime($currentPlanet->getData('last_update')));
}
if (!$currentPlayer || !$currentPlayer->getId() || !$currentPlanet || $currentPlanet->isDestroyed()) {
return '<td width="150"></td>';
}
return $Result;
$activeNoobProtection = Wootook::getGameConfig('game/noob-protection/active');
$noobProtectionMultiplier = Wootook::getGameConfig('game/noob-protection/multiplier');
$noobProtectionPointsLimit = Wootook::getGameConfig('game/noob-protection/points-cap');
$readAdapter = Wootook_Core_Database_ConnectionManager::getSingleton()->getConnection('core_read');
$statement = $readAdapter->select()
->column('total_points')
->column('total_rank')
->from(array('stats' => $readAdapter->getTable('statpoints')))
->where('id_owner', new Wootook_Core_Database_Sql_Placeholder_Variable('player_id'))
->where('stat_code', 1)
->where('stat_type', 1)
->prepare()
;
$statement->execute(array('player_id' => $user->getId()));
$playerPoints = $statement->fetchColumn(0);
$statement->execute(array('player_id' => $currentPlayer->getId()));
$currentPlayerPoints = $statement->fetchColumn(0);
$currentPlayerRank = $statement->fetchColumn(1);
$classes = array();
if ($currentPlayer->isBanned()) {
$classes['banned'] = 'B';
}
if ($currentPlayer->isVacation()) {
$classes['vacation'] = 'V';
}
$pastDate = new Wootook_Core_DateTime();
$pastDate->sub(8, Wootook_Core_DateTime::DAY);
if ($pastDate->isLater($currentPlayer->getLastLoginDate())) {
$classes['inactive'] = 'i';
}
$pastDate->sub(22, Wootook_Core_DateTime::DAY);
if ($pastDate->isLater($currentPlayer->getLastLoginDate())) {
$classes['long-inactive'] = 'I';
}
if ($currentPlayer->isAuthorized(LEVEL_ADMIN)) {
$classes['admin'] = 'A';
} else if ($currentPlayer->isAuthorized(LEVEL_OPERATOR)) {
$classes['operator'] = 'O';
} else if ($currentPlayer->isAuthorized(LEVEL_MODERATOR)) {
$classes['moderator'] = 'M';
}
if ($activeNoobProtection) {
if ($playerPoints <= $noobProtectionPointsLimit && ($playerPoints * $noobProtectionMultiplier) < $currentPlayerPoints) {
$classes['strong'] = 'F';
} else if ($currentPlayerPoints <= $noobProtectionPointsLimit && ($currentPlayerPoints * $noobProtectionMultiplier) < $playerPoints) {
$classes['strong'] = 'F';
}
}
$output = '<td width="150">';
if (count($classes) > 0) {
$output .= '<span class="' . implode(' ', array_keys($classes)) . '">' . $currentPlayer->getUsername() . '</span>';
foreach ($classes as $class => $identifier) {
$output .= '<span class="' . $class . '">' . $identifier . '</span>';
}
} else {
$output .= '<span class="active">' . $currentPlayer->getUsername() . '</span>';
}
if (true || $currentPlayer->getId() !== $user->getId()) {
$translator = Wootook::getTranslator();
$messageUrl = Wootook::getStaticUrl('messages.php', array('mode' => 'write', 'id' => $currentPlayer->getId()));
$buddyUrl = Wootook::getStaticUrl('buddy.php', array('a' => '2', 'u' => $currentPlayer->getId()));
$statsUrl = Wootook::getStaticUrl('stat.php', array('who' => 'player', 'start' => 100 * floor($currentPlayerRank / 100)));
$output .=<<<HTML_EOF
<div class="details player">
<p class="username">{$translator->translate('Player: %s', $currentPlayer->getUsername())}</p>
<p class="stats">{$translator->translate('Rank: %d', $currentPlayerRank)}</p>
<p class="send-message"><a href="{$messageUrl}">{$translator->translate('Send a message')}</a></p>
<p class="buddy"><a href="{$buddyUrl}">{$translator->translate('Add to buddy list')}</a></p>
<p class="stats"><a href="{$statsUrl}">{$translator->translate('Statistics')}</a></p>
</div>
HTML_EOF;
}
$output .= '</td>';
return $output;
}
?>

View file

@ -1,80 +0,0 @@
<?php
/**
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.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.
*
*/
/**
*
* @deprecated
* @param unknown_type $Element
* @param unknown_type $Ressources
*/
function GetMaxConstructibleElements ($Element, $Ressources) {
global $pricelist;
// On test les 4 Type de ressource pour voir si au moins on sait en construire 1
if ($pricelist[$Element]['metal'] != 0) {
$ResType_1_Needed = $pricelist[$Element]['metal'];
$Buildable = floor($Ressources["metal"] / $ResType_1_Needed);
$MaxElements = $Buildable;
}
if ($pricelist[$Element]['crystal'] != 0) {
$ResType_2_Needed = $pricelist[$Element]['crystal'];
$Buildable = floor($Ressources["crystal"] / $ResType_2_Needed);
}
if (!isset($MaxElements)) {
$MaxElements = $Buildable;
} elseif ($MaxElements > $Buildable) {
$MaxElements = $Buildable;
}
if ($pricelist[$Element]['deuterium'] != 0) {
$ResType_3_Needed = $pricelist[$Element]['deuterium'];
$Buildable = floor($Ressources["deuterium"] / $ResType_3_Needed);
}
if (!isset($MaxElements)) {
$MaxElements = $Buildable;
} elseif ($MaxElements > $Buildable) {
$MaxElements = $Buildable;
}
if ($pricelist[$Element]['energy'] != 0) {
$ResType_4_Needed = $pricelist[$Element]['energy'];
$Buildable = floor($Ressources["energy_max"] / $ResType_4_Needed);
}
if ($Buildable < 1) {
$MaxElements = 0;
}
return $MaxElements;
}
// Verion History
// - 1.0 Version initiale (creation)
// - 1.1 Correction bug ressources n<>gatives ...
// - 1.2 Correction bug quand pas de m<>tal
?>

View file

@ -1,75 +0,0 @@
<?php
/**
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.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.
*
*/
/**
*
* @deprecated
* @param unknown_type $user
* @param unknown_type $planet
* @param unknown_type $Element
* @param unknown_type $userfactor
*/
function GetRestPrice ($user, $planet, $Element, $userfactor = true) {
global $pricelist, $resource, $lang;
trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED);
if ($userfactor) {
$level = ($planet[$resource[$Element]]) ? $planet[$resource[$Element]] : $user[$resource[$Element]];
}
$array = array(
'metal' => $lang["Metal"],
'crystal' => $lang["Crystal"],
'deuterium' => $lang["Deuterium"],
'energy_max' => $lang["Energy"]
);
$text = "<br><font color=\"#7f7f7f\">". $lang['Rest_ress'] .": ";
foreach ($array as $ResType => $ResTitle) {
if ($pricelist[$Element][$ResType] != 0) {
$text .= $ResTitle . ": ";
if ($userfactor) {
$cost = floor($pricelist[$Element][$ResType] * pow($pricelist[$Element]['factor'], $level));
} else {
$cost = floor($pricelist[$Element][$ResType]);
}
if ($cost > $planet[$ResType]) {
$text .= "<b style=\"color: rgb(127, 95, 96);\">". pretty_number($planet[$ResType] - $cost) ."</b> ";
} else {
$text .= "<b style=\"color: rgb(95, 127, 108);\">". pretty_number($planet[$ResType] - $cost) ."</b> ";
}
}
}
$text .= "</font>";
return $text;
}
?>

View file

@ -1,58 +0,0 @@
<?php
/**
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.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.
*
*/
/**
*
* @deprecated
* @param unknown_type $CurrentUser
* @param unknown_type $Officier
*/
function IsOfficierAccessible ($CurrentUser, $Officier) {
global $requirements, $resource, $pricelist;
if (isset($requirements[$Officier])) {
$enabled = true;
foreach($requirements[$Officier] as $ReqOfficier => $OfficierLevel) {
if ($CurrentUser[$resource[$ReqOfficier]] &&
$CurrentUser[$resource[$ReqOfficier]] >= $OfficierLevel) {
$enabled = 1;
} else {
return 0;
}
}
}
if ($CurrentUser[$resource[$Officier]] < $pricelist[$Officier]['max'] ) {
return 1;
} else {
return -1;
}
}
?>

View file

@ -1,58 +0,0 @@
<?php
/**
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.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.
*
*/
/**
*
* @deprecated
* @param unknown_type $user
* @param unknown_type $planet
* @param unknown_type $element
*/
function IsTechnologieAccessible($user, $planet, $element)
{
trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED);
global $requirements, $resource;
if (isset($requirements[$element])) {
$enabled = true;
foreach($requirements[$element] as $ReqElement => $EleLevel) {
if (@$user[$resource[$ReqElement]] && $user[$resource[$ReqElement]] >= $EleLevel) {
// break;
} elseif ($planet[$resource[$ReqElement]] && $planet[$resource[$ReqElement]] >= $EleLevel) {
$enabled = true;
} else {
return false;
}
}
return $enabled;
} else {
return true;
}
}

View file

@ -31,85 +31,108 @@
/**
*
* @deprecated
* @param unknown_type $FleetRow
* @param Wootook_Empire_Model_Fleet|array $fleet
*/
function MissionCaseColonisation ( $FleetRow ) {
global $lang, $resource;
function MissionCaseColonisation($fleet)
{
$readConnection = Wootook_Core_Database_ConnectionManager::getSingleton()->getConnection('core_read');
$statement = doquery ("SELECT count(*) FROM {{table}} WHERE `id_owner` = '". $FleetRow['fleet_owner'] ."' AND `planet_type` = '1'", 'planets');
$iPlanetCount = $statement->fetch(PDO::FETCH_ASSOC);
if ($FleetRow['fleet_mess'] == 0) {
// Déjà, sommes nous a l'aller ??
$statement2 = doquery ("SELECT count(*) FROM {{table}} WHERE `galaxy` = '". $FleetRow['fleet_end_galaxy']."' AND `system` = '". $FleetRow['fleet_end_system']."' AND `planet` = '". $FleetRow['fleet_end_planet']."';", 'galaxy');
$iGalaxyPlace = $statement2->fetch(PDO::FETCH_ASSOC);
$TargetAdress = sprintf ($lang['sys_adress_planet'], $FleetRow['fleet_end_galaxy'], $FleetRow['fleet_end_system'], $FleetRow['fleet_end_planet']);
if ($iGalaxyPlace == 0) {
// Y a personne qui s'y est mis avant que je ne debarque !
if ($iPlanetCount >= MAX_PLAYER_PLANETS && $user['authlevel'] != LEVEL_ADMIN) {
$TheMessage = $lang['sys_colo_arrival'] . $TargetAdress . $lang['sys_colo_maxcolo'] . MAX_PLAYER_PLANETS . $lang['sys_colo_planet'];
SendSimpleMessage ( $FleetRow['fleet_owner'], '', $FleetRow['fleet_start_time'], 0, $lang['sys_colo_mess_from'], $lang['sys_colo_mess_report'], $TheMessage);
doquery("UPDATE {{table}} SET `fleet_mess` = '1' WHERE `fleet_id` = ". $FleetRow["fleet_id"], 'fleets');
} else {
$user = Wootook_Player_Model_Entity::factory($FleetRow['fleet_owner']);
$user->createNewPlanet(
intval($FleetRow['fleet_end_galaxy']),
intval($FleetRow['fleet_end_system']),
intval($FleetRow['fleet_end_planet']),
Wootook_Empire_Model_Planet::TYPE_PLANET,
Wootook::__('Colony')
);
$player = new Wootook_Player_Model_Entity();
$player->load($fleet->getData('fleet_owner'));
if (!$player->getId()) {
$fleet->delete();
return;
}
if ( $NewOwnerPlanet == true ) {
$TheMessage = $lang['sys_colo_arrival'] . $TargetAdress . $lang['sys_colo_allisok'];
SendSimpleMessage ( $FleetRow['fleet_owner'], '', $FleetRow['fleet_start_time'], 0, $lang['sys_colo_mess_from'], $lang['sys_colo_mess_report'], $TheMessage);
// Verifier ce que contient fleet_array (et le cas et cheant retirer un element '208'
if ($FleetRow['fleet_amount'] == 1) {
doquery("DELETE FROM {{table}} WHERE fleet_id=" . $FleetRow["fleet_id"], 'fleets');
} else {
$CurrentFleet = explode(";", $FleetRow['fleet_array']);
$NewFleet = "";
foreach ($CurrentFleet as $Item => $Group) {
if ($Group != '') {
$Class = explode (",", $Group);
if ($Class[0] == 208) {
if ($Class[1] > 1) {
$NewFleet .= $Class[0].",".($Class[1] - 1).";";
}
} else {
if ($Class[1] <> 0) {
$NewFleet .= $Class[0].",".$Class[1].";";
}
}
}
}
$QryUpdateFleet = "UPDATE {{table}} SET ";
$QryUpdateFleet .= "`fleet_array` = '". $NewFleet ."', ";
$QryUpdateFleet .= "`fleet_amount` = `fleet_amount` - 1, ";
$QryUpdateFleet .= "`fleet_mess` = '1' ";
$QryUpdateFleet .= "WHERE `fleet_id` = '". $FleetRow["fleet_id"] ."';";
doquery( $QryUpdateFleet, 'fleets');
}
} else {
$TheMessage = $lang['sys_colo_arrival'] . $TargetAdress . $lang['sys_colo_badpos'];
SendSimpleMessage ( $FleetRow['fleet_owner'], '', $FleetRow['fleet_start_time'], 0, $lang['sys_colo_mess_from'], $lang['sys_colo_mess_report'], $TheMessage);
doquery("UPDATE {{table}} SET `fleet_mess` = '1' WHERE `fleet_id` = ". $FleetRow["fleet_id"], 'fleets');
}
}
} else {
// Pas de bol coiffé sur le poteau !
$TheMessage = $lang['sys_colo_arrival'] . $TargetAdress . $lang['sys_colo_notfree'];
SendSimpleMessage ( $FleetRow['fleet_owner'], '', $FleetRow['fleet_end_time'], 0, $lang['sys_colo_mess_from'], $lang['sys_colo_mess_report'], $TheMessage);
// Mettre a jour la flotte pour qu'effectivement elle revienne !
doquery("UPDATE {{table}} SET `fleet_mess` = '1' WHERE `fleet_id` = ". $FleetRow["fleet_id"], 'fleets');
$event = Wootook::dispatchEvent('fleet.mission.colonize.max-allowed-planets', array(
'base_count' => MAX_PLAYER_PLANETS,
'count' => MAX_PLAYER_PLANETS,
'player' => $player,
'fleet' => $fleet
));
}
} else {
if ($FleetRow['fleet_end_time'] <= time()) {
// Retour de flotte
RestoreFleetToPlanet ( $FleetRow, true );
doquery("DELETE FROM {{table}} WHERE fleet_id=" . $FleetRow["fleet_id"], 'fleets');
}
}
}
$maxAllowedPlanetCount = $event->getData('count');
?>
/* first trip */
if ($fleet->getData('fleet_mess') == 0) {
if ($fleet->getActionTime()->isEarlier()) {
return;
}
if ($player->getPlanetCollection()->getSize() >= $maxAllowedPlanetCount && !$player->isAuthorized(array(LEVEL_ADMIN))) {
/* no more planets to colonize */
$coords = sprintf('%d:%d:%d', $fleet->getData('fleet_end_galaxy'), $fleet->getData('fleet_end_system'), $fleet->getData('fleet_end_planet'));
SendSimpleMessage($player->getId(), null, $fleet['fleet_end_time'], 0,
Wootook::__('Colonization'), Wootook::__('Colonization report'),
Wootook::__("The fleet has arrived at the coordinates [%1\$s], but unfortunatly colonization cannot happen : you can't have more than %2\$d colonies.", $coords, $maxAllowedPlanetCount));
$fleet->goBack();
return;
}
$statement = $readConnection->select()
->column(new Wootook_Core_Database_Sql_Placeholder_Expression('COUNT(*)'))
->from($readConnection->getTable('planets'))
->where('galaxy', $fleet->getData('fleet_end_galaxy'))
->where('system', $fleet->getData('fleet_end_system'))
->where('planet', $fleet->getData('fleet_end_planet'))
->prepare()
;
$statement->execute();
if ($statement->fetchColumn() > 0) {
$coords = sprintf('%d:%d:%d', $fleet->getData('fleet_end_galaxy'), $fleet->getData('fleet_end_system'), $fleet->getData('fleet_end_planet'));
SendSimpleMessage($player->getId(), null, $fleet['fleet_end_time'], 0,
Wootook::__('Colonization'), Wootook::__('Colonization report'),
Wootook::__("The fleet has arrived at the coordinates [%1\$s], but unfortunatly colonization cannot happen : the planet is already colonized.", $coords));
$fleet->goBack();
return;
}
if (mt_rand(0, 100) >= 75) {
$baseSize = Wootook::getGameConfig('planet/initial/fields');
$factor = 2 * $position / (1 + log($position));
$fuzz = 2 * $factor * pow(sin($factor), 2) / 2 + $factor / 4;
$size = ($baseSize * mt_rand(floor($factor / 10), ceil($factor * 5 / 4))) + mt_rand(0, $fuzz);
$player->createNewPlanet(
$fleet->getData('fleet_end_galaxy'),
$fleet->getData('fleet_end_system'),
$fleet->getData('fleet_end_planet'),
Wootook_Empire_Model_Planet::TYPE_PLANET,
Wootook::__('Colony'),
$size
);
$coords = sprintf('%d:%d:%d', $fleet->getData('fleet_end_galaxy'), $fleet->getData('fleet_end_system'), $fleet->getData('fleet_end_planet'));
SendSimpleMessage($player->getId(), null, $fleet['fleet_end_time'], 0,
Wootook::__('Colonization'), Wootook::__('Colonization report'),
Wootook::__("The fleet has arrived at the coordinates [%1\$s], the settlers succeeded creating your new colony.", $coords));
$fleet->delete();
return;
} else {
$coords = sprintf('%d:%d:%d', $fleet->getData('fleet_end_galaxy'), $fleet->getData('fleet_end_system'), $fleet->getData('fleet_end_planet'));
SendSimpleMessage($player->getId(), null, $fleet['fleet_end_time'], 0,
Wootook::__('Colonization'), Wootook::__('Colonization report'),
Wootook::__("The fleet has arrived at the coordinates [%1\$s], the settlers failed creating your new colony, no planet was there.", $coords));
$fleet->goBack();
return;
}
}
/* back trip */
if ($fleet->getArrivalTime()->isEarlier()) {
return;
}
$fleet->dock($fleet->getOriginPlanet());
$coords = sprintf('%d:%d:%d', $fleet->getData('fleet_end_galaxy'), $fleet->getData('fleet_end_system'), $fleet->getData('fleet_end_planet'));
SendSimpleMessage($player->getId(), null, $fleet['fleet_end_time'], 0,
Wootook::__('Colonization'), Wootook::__('Colonization report'),
Wootook::__("The fleet went back from the coordinates [%1\$s], the settlers failed creating your new colony.", $coords));
return;
}

View file

@ -1,51 +0,0 @@
<?php
/**
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.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.
*
*/
/**
*
* @deprecated
* @param array $CurrentUser
* @param array $CurrentPlanet
* @param int $UpdateTime
*/
function PlanetResourceUpdate($CurrentUser, &$CurrentPlanet, $UpdateTime)
{
trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED);
$planet = Legacies_Empire_Model_User::factory($CurrentPlanet['id']);
/*
* Update planet resources and constructions
*/
Wootook::dispatchEvent('planet.update', array(
'planet' => $planet,
'time' => $UpdateTime
));
$planet->save();
}

View file

@ -1,92 +0,0 @@
<?php
/**
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.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.
*
*/
/**
*
* @deprecated
* @param unknown_type $mail
*/
function sendnewpassword($mail){
trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED);
$ExistMail = doquery("SELECT `email` FROM {{table}} WHERE `email` = '". $mail ."' LIMIT 1;", 'users', true);
if (empty($ExistMail['email'])) {
message('L\'adresse n\'existe pas !','Erreur');
}
else{
//Caractere qui seront contenus dans le nouveau mot de passe
$Caracters="aazertyuiopqsdfghjklmwxcvbnAZERTYUIOPQSDFGHJKLMWXCVBN1234567890";
$Count=strlen($Caracters);
$NewPass="";
$Taille=6;
srand((double)microtime()*1000000);
for($i=0;$i<$Taille;$i++){
$CaracterBoucle=rand(0,$Count-1);
$NewPass=$NewPass.substr($Caracters,$CaracterBoucle,1);
}
//Et un nouveau mot de passe tout chaud ^^
//On va maintenant l'envoyer au destinataire
$Title = "Wootook : Nouveau mot de passe";
$Body = "Voici votre nouveau mot de passe : ";
$Body .= $NewPass;
mail($mail,$Title,$Body);
//Email envoy<6F>, maintenant place au changement dans la BDD
$NewPassSql = md5($NewPass);
$QryPassChange = "UPDATE {{table}} SET ";
$QryPassChange .= "`password` ='". $NewPassSql ."' ";
$QryPassChange .= "WHERE `email`='". $mail ."' LIMIT 1;";
doquery( $QryPassChange, 'users');
}
}
?>

View file

@ -31,73 +31,91 @@
/**
*
* @deprecated
* @param unknown_type $Galaxy
* @param unknown_type $System
* @param int $Galaxy
* @param int $System
*/
function ShowGalaxyRows ($Galaxy, $System) {
global $lang, $planetcount, $CurrentRC, $dpath, $user;
function ShowGalaxyRows($Galaxy, $System)
{
global $planetcount;
$readAdapter = Wootook_Core_Database_ConnectionManager::getSingleton()->getConnection('core_read');
$Result = "";
for ($Planet = 1; $Planet <= Wootook::getGameConfig('engine/universe/positions'); $Planet++) {
$galaxyStatement = $readAdapter->select()
->column('*')
->from($readAdapter->getTable('galaxy'))
->where('galaxy', $Galaxy)
->where('system', $System)
->where('planet', new Wootook_Core_Database_Sql_Placeholder_Variable('planet'))
->limit(1)
->prepare()
;
$GalaxyRowPlanet = array();
$GalaxyRowMoon = array();
$GalaxyRowPlayer = array();
$GalaxyRowAlly = array();
$planetStatement = $readAdapter->select()
->column('*')
->from($readAdapter->getTable('planets'))
->where('id', new Wootook_Core_Database_Sql_Placeholder_Variable('planet_id'))
->limit(1)
->prepare()
;
$GalaxyRow = doquery("SELECT * FROM {{table}} WHERE `galaxy` = '".$Galaxy."' AND `system` = '".$System."' AND `planet` = '".$Planet."';", 'galaxy', true);
$output = "";
for ($Planet = 1; $Planet <= Wootook::getGameConfig('engine/universe/positions'); $Planet++) {
if ($galaxyStatement->execute(array('planet' => $Planet))) {
/** @var Wootook_Empire_Model_Galaxy_Position $galaxyPosition */
$galaxyPosition = $galaxyStatement->fetchEntity('Wootook_Empire_Model_Galaxy_Position');
} else {
$output .= '<tr></tr>';
continue;
}
$Result .= "\n";
$Result .= "<tr>"; // Depart de ligne
if ($GalaxyRow) {
// Il existe des choses sur cette ligne de planete
if ($GalaxyRow["id_planet"] != 0) {
$GalaxyRowPlanet = doquery("SELECT * FROM {{table}} WHERE `id` = '". $GalaxyRow["id_planet"] ."';", 'planets', true);
$output .= "<tr>";
if ($galaxyPosition->getData('galaxy') && $galaxyPosition["id_planet"] != 0) {
if ($planetStatement->execute(array('planet_id' => $galaxyPosition["id_planet"]))) {
/** @var Wootook_Empire_Model_Planet $currentPlanet */
$currentPlanet = $planetStatement->fetchEntity('Wootook_Empire_Model_Planet');
} else {
$currentPlanet = new Wootook_Empire_Model_Planet();
}
if ($GalaxyRowPlanet['destruyed'] != 0 AND
$GalaxyRowPlanet['id_owner'] != '' AND
$GalaxyRow["id_planet"] != '') {
CheckAbandonPlanetState ($GalaxyRowPlanet);
} else {
$planetcount++;
$GalaxyRowPlayer = doquery("SELECT * FROM {{table}} WHERE `id` = '". $GalaxyRowPlanet["id_owner"] ."';", 'users', true);
}
if ($currentPlanet->getId() && !$currentPlanet->isDestroyed()) {
$planetcount++;
$currentPlayer = $currentPlanet->getPlayer();
} else {
CheckAbandonPlanetState($currentPlanet);
$currentPlayer = new Wootook_Player_Model_Entity();
}
if ($GalaxyRow["id_luna"] != 0) {
$GalaxyRowMoon = doquery("SELECT * FROM {{table}} WHERE `id` = '". $GalaxyRow["id_luna"] ."';", 'lunas', true);
if ($GalaxyRowMoon["destruyed"] != 0) {
CheckAbandonMoonState ($GalaxyRowMoon);
}
}
$GalaxyRowPlanet = doquery("SELECT * FROM {{table}} WHERE `id` = '". $GalaxyRow["id_planet"] ."';", 'planets', true);
if ($GalaxyRowPlanet['id_owner'] <> 0) {
$GalaxyRowUser = doquery("SELECT * FROM {{table}} WHERE `id` = '". $GalaxyRowPlanet['id_owner'] ."';", 'users', true);
} else {
$GalaxyRowUser = array();
}
}
}
$Result .= "\n";
$Result .= GalaxyRowPos ( $Planet, $GalaxyRow );
$Result .= "\n";
$Result .= GalaxyRowPlanet ( $GalaxyRow, $GalaxyRowPlanet, $GalaxyRowPlayer, $Galaxy, $System, $Planet, 1 );
$Result .= "\n";
$Result .= GalaxyRowPlanetName ( $GalaxyRow, $GalaxyRowPlanet, $GalaxyRowPlayer, $Galaxy, $System, $Planet, 1 );
$Result .= "\n";
$Result .= GalaxyRowMoon ( $GalaxyRow, $GalaxyRowMoon , $GalaxyRowPlayer, $Galaxy, $System, $Planet, 3 );
$Result .= "\n";
$Result .= GalaxyRowDebris ( $GalaxyRow, $GalaxyRowPlanet, $GalaxyRowPlayer, $Galaxy, $System, $Planet, 2 );
$Result .= "\n";
$Result .= GalaxyRowUser ( $GalaxyRow, $GalaxyRowPlanet, $GalaxyRowPlayer, $Galaxy, $System, $Planet, 0 );
$Result .= "\n";
$Result .= GalaxyRowAlly ( $GalaxyRow, $GalaxyRowPlanet, $GalaxyRowPlayer, $Galaxy, $System, $Planet, 0 );
$Result .= "\n";
$Result .= GalaxyRowActions ( $GalaxyRow, $GalaxyRowPlanet, $GalaxyRowPlayer, $Galaxy, $System, $Planet, 0 );
$Result .= "\n";
$Result .= "</tr>";
}
if ($galaxyPosition["id_luna"] != 0) {
if ($planetStatement->execute(array('planet_id' => $galaxyPosition["id_luna"]))) {
/** @var Wootook_Empire_Model_Planet $currentMoon */
$currentMoon = $planetStatement->fetchEntity('Wootook_Empire_Model_Planet');
} else {
$currentMoon = new Wootook_Empire_Model_Planet();
}
return $Result;
if ($currentMoon->isDestroyed()) {
CheckAbandonMoonState($currentMoon);
}
} else {
$currentMoon = new Wootook_Empire_Model_Planet();
}
} else {
$currentPlanet = new Wootook_Empire_Model_Planet();
$currentPlayer = new Wootook_Player_Model_Entity();
$currentMoon = new Wootook_Empire_Model_Planet();
}
$output .= GalaxyRowPos($Planet, $galaxyPosition);
$output .= GalaxyRowPlanet($galaxyPosition, $currentPlanet, $currentPlayer, $Galaxy, $System, $Planet, 1);
$output .= GalaxyRowPlanetName($galaxyPosition, $currentPlanet, $currentPlayer, $Galaxy, $System, $Planet, 1);
$output .= GalaxyRowMoon($galaxyPosition, $currentMoon , $currentPlayer, $Galaxy, $System, $Planet, 3);
$output .= GalaxyRowDebris($galaxyPosition, $currentPlanet, $currentPlayer, $Galaxy, $System, $Planet, 2);
$output .= GalaxyRowUser($currentPlanet, $currentPlayer);
$output .= GalaxyRowAlly($galaxyPosition, $currentPlanet, $currentPlayer, $Galaxy, $System, $Planet, 0);
$output .= GalaxyRowActions($galaxyPosition, $currentPlanet, $currentPlayer, $Galaxy, $System, $Planet, 0);
$output .= "</tr>";
}
return $output;
}
?>

View file

@ -1,52 +0,0 @@
<?php
/**
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.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.
*
*/
/**
*
* @deprecated
* @param unknown_type $CurrentUser
*/
function SortUserPlanets ( $CurrentUser ) {
$Order = ( $CurrentUser['planet_sort_order'] == 1 ) ? "DESC" : "ASC" ;
$Sort = $CurrentUser['planet_sort'];
$QryPlanets = "SELECT `id`, `name`, `galaxy`, `system`, `planet`, `planet_type` FROM {{table}} WHERE `id_owner` = '". $CurrentUser['id'] ."' ORDER BY ";
if ( $Sort == 0 ) {
$QryPlanets .= "`id` ". $Order;
} elseif ( $Sort == 1 ) {
$QryPlanets .= "`galaxy`, `system`, `planet`, `planet_type` ". $Order;
} elseif ( $Sort == 2 ) {
$QryPlanets .= "`name` ". $Order;
}
$Planets = doquery ( $QryPlanets, 'planets');
return $Planets;
}
?>

View file

@ -1,62 +0,0 @@
<?php
/**
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.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.
*
*/
/**
*
* @deprecated
* @param unknown_type $CurrentPlanet
* @param unknown_type $CurrentUser
*/
function UpdatePlanetBatimentQueueList ( &$CurrentPlanet, &$CurrentUser ) {
trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED);
$RetValue = false;
if ( $CurrentPlanet['b_building_id'] != 0 ) {
while ( $CurrentPlanet['b_building_id'] != 0 ) {
if ( $CurrentPlanet['b_building'] <= time() ) {
PlanetResourceUpdate ( $CurrentUser, $CurrentPlanet, $CurrentPlanet['b_building'], false );
$IsDone = CheckPlanetBuildingQueue( $CurrentPlanet, $CurrentUser );
if ( $IsDone == true ) {
SetNextQueueElementOnTop ( $CurrentPlanet, $CurrentUser );
}
} else {
$RetValue = true;
break;
}
}
}
return $RetValue;
}
// Revision History
// - 1.0 Mise en module initiale
// - 1.1 Mise a jour des ressources sur la planete verifi<66>e (pour prendre en compte les ressources produites
// pendant la construction et avant l'evolution evantuel d'une mine ou d'en batiment
?>

View file

@ -34,7 +34,6 @@ require_once ROOT_PATH . 'includes/deprecated.php';
* @deprecated
* {{{
*/
include(ROOT_PATH . 'includes/functions/FlyingFleetHandler.'.PHPEXT);
include(ROOT_PATH . 'includes/functions/MissionCaseAttack.'.PHPEXT);
include(ROOT_PATH . 'includes/functions/MissionCaseStay.'.PHPEXT);
include(ROOT_PATH . 'includes/functions/MissionCaseStayAlly.'.PHPEXT);
@ -47,36 +46,29 @@ include(ROOT_PATH . 'includes/functions/MissionCaseExpedition.'.PHPEXT);
include(ROOT_PATH . 'includes/functions/SendSimpleMessage.'.PHPEXT);
include(ROOT_PATH . 'includes/functions/SpyTarget.'.PHPEXT);
include(ROOT_PATH . 'includes/functions/RestoreFleetToPlanet.'.PHPEXT);
include(ROOT_PATH . 'includes/functions/StoreGoodsToPlanet.'.PHPEXT);
include(ROOT_PATH . 'includes/functions/InsertJavaScriptChronoApplet.'.PHPEXT);
include(ROOT_PATH . 'includes/functions/IsTechnologieAccessible.'.PHPEXT); // <- TODO: delete
include(ROOT_PATH . 'includes/functions/GetRestPrice.'.PHPEXT); // <- TODO: delete
include(ROOT_PATH . 'includes/functions/InsertGalaxyScripts.'.PHPEXT);
include(ROOT_PATH . 'includes/functions/GalaxyCheckFunctions.'.PHPEXT);
include(ROOT_PATH . 'includes/functions/ShowGalaxyRows.'.PHPEXT);
include(ROOT_PATH . 'includes/functions/GetPhalanxRange.'.PHPEXT); // <- TODO: delete
include(ROOT_PATH . 'includes/functions/GetMissileRange.'.PHPEXT); // <- TODO: delete
include(ROOT_PATH . 'includes/functions/GalaxyRowPos.'.PHPEXT);
include(ROOT_PATH . 'includes/functions/GalaxyRowPlanet.'.PHPEXT);
include(ROOT_PATH . 'includes/functions/GalaxyRowPlanetName.'.PHPEXT);
include(ROOT_PATH . 'includes/functions/GalaxyRowMoon.'.PHPEXT);
include(ROOT_PATH . 'includes/functions/GalaxyRowDebris.'.PHPEXT);
include(ROOT_PATH . 'includes/functions/GalaxyRowUser.'.PHPEXT);
include(ROOT_PATH . 'includes/functions/GalaxyRowAlly.'.PHPEXT);
include(ROOT_PATH . 'includes/functions/GalaxyRowActions.'.PHPEXT);
include(ROOT_PATH . 'includes/functions/ShowGalaxySelector.'.PHPEXT);
include(ROOT_PATH . 'includes/functions/ShowGalaxyMISelector.'.PHPEXT);
include(ROOT_PATH . 'includes/functions/ShowGalaxyTitles.'.PHPEXT);
include(ROOT_PATH . 'includes/functions/GalaxyLegendPopup.'.PHPEXT);
include(ROOT_PATH . 'includes/functions/ShowGalaxyFooter.'.PHPEXT);
include(ROOT_PATH . 'includes/functions/MessageForm.'.PHPEXT);
include(ROOT_PATH . 'includes/functions/SendNewPassword.'.PHPEXT);
include(ROOT_PATH . 'includes/functions/IsOfficierAccessible.'.PHPEXT);
include(ROOT_PATH . 'includes/functions/CheckInputStrings.'.PHPEXT);
include(ROOT_PATH . 'includes/functions/MipCombatEngine.'.PHPEXT);
include(ROOT_PATH . 'includes/functions/DeleteSelectedUser.'.PHPEXT);
include(ROOT_PATH . 'includes/functions/SortUserPlanets.'.PHPEXT);
include(ROOT_PATH . 'includes/functions/BuildFleetEventTable.'.PHPEXT);
include(ROOT_PATH . 'includes/functions/StoreGoodsToPlanet.'.PHPEXT); // includes/functions/StoreGoodsToPlanet.php
include(ROOT_PATH . 'includes/functions/InsertJavaScriptChronoApplet.'.PHPEXT); // infos.php, includes/functions/BuildFleetEventTable.php
include(ROOT_PATH . 'includes/functions/InsertGalaxyScripts.'.PHPEXT); // galaxy.php
include(ROOT_PATH . 'includes/functions/GalaxyCheckFunctions.'.PHPEXT); // galaxy.php
include(ROOT_PATH . 'includes/functions/ShowGalaxyRows.'.PHPEXT); // galaxy.php
include(ROOT_PATH . 'includes/functions/GetPhalanxRange.'.PHPEXT); // <- TODO: delete
include(ROOT_PATH . 'includes/functions/GetMissileRange.'.PHPEXT); // <- TODO: delete
include(ROOT_PATH . 'includes/functions/GalaxyRowPos.'.PHPEXT); // galaxy.php
include(ROOT_PATH . 'includes/functions/GalaxyRowPlanet.'.PHPEXT); // galaxy.php
include(ROOT_PATH . 'includes/functions/GalaxyRowPlanetName.'.PHPEXT); // galaxy.php
include(ROOT_PATH . 'includes/functions/GalaxyRowMoon.'.PHPEXT); // galaxy.php
include(ROOT_PATH . 'includes/functions/GalaxyRowDebris.'.PHPEXT); // galaxy.php
include(ROOT_PATH . 'includes/functions/GalaxyRowUser.'.PHPEXT); // galaxy.php
include(ROOT_PATH . 'includes/functions/GalaxyRowAlly.'.PHPEXT); // galaxy.php
include(ROOT_PATH . 'includes/functions/GalaxyRowActions.'.PHPEXT); // galaxy.php
include(ROOT_PATH . 'includes/functions/ShowGalaxySelector.'.PHPEXT); // galaxy.php
include(ROOT_PATH . 'includes/functions/ShowGalaxyMISelector.'.PHPEXT); // galaxy.php
include(ROOT_PATH . 'includes/functions/ShowGalaxyTitles.'.PHPEXT); // galaxy.php
include(ROOT_PATH . 'includes/functions/GalaxyLegendPopup.'.PHPEXT); // galaxy.php
include(ROOT_PATH . 'includes/functions/ShowGalaxyFooter.'.PHPEXT); // galaxy.php
include(ROOT_PATH . 'includes/functions/MessageForm.'.PHPEXT); // alliance.php
include(ROOT_PATH . 'includes/functions/MipCombatEngine.'.PHPEXT); // mipattack.php
include(ROOT_PATH . 'includes/functions/BuildFleetEventTable.'.PHPEXT); // phalanx.php
/**
* }}}
*/
*/

View file

@ -1,112 +0,0 @@
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
CREATE TABLE IF NOT EXISTS `game_core_config` (
`website_id` tinyint(3) unsigned NOT NULL,
`game_id` tinyint(3) unsigned NOT NULL,
`config_path` varchar(64) NOT NULL,
`config_value` varchar(255) NOT NULL,
PRIMARY KEY (`website_id`,`game_id`,`config_path`),
KEY `website_id` (`website_id`),
KEY `game_id` (`game_id`),
KEY `config_path` (`config_path`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `game_core_config` (`website_id`, `game_id`, `config_path`, `config_value`) VALUES
(0, 0, 'engine/ban/duration', '86400'),
(0, 0, 'engine/bot/active', '0'),
(0, 0, 'engine/bot/email', 'contact@wootook.org'),
(0, 0, 'engine/bot/name', 'Woot'),
(0, 0, 'engine/options/announces', '0'),
(0, 0, 'engine/options/banner', '0'),
(0, 0, 'engine/options/bbcode', '1'),
(0, 0, 'engine/options/chat', '0'),
(0, 0, 'engine/options/ga', '1'),
(0, 0, 'engine/options/notes', '0'),
(0, 0, 'engine/options/retailer', '0'),
(0, 0, 'engine/options/vacation-min-time', '172800'),
(0, 0, 'game/news/active', '0'),
(0, 0, 'game/news/content', 'Bienvenue sur le nouveau serveur de jeu Wootook!'),
(0, 0, 'web/cookie/name', '__wtk'),
(0, 0, 'web/cookie/time', '2592000'),
(0, 0, 'web/session/time', '900'),
(1, 1, 'game/debris/cristal-percent', '30'),
(1, 1, 'game/debris/defense', '0'),
(1, 1, 'game/debris/deuterium-percent', '0'),
(1, 1, 'game/debris/energy-percent', '0'),
(1, 1, 'game/debris/fleet', '1'),
(1, 1, 'game/debris/metal-percent', '30'),
(1, 1, 'game/general/active', '1'),
(1, 1, 'game/general/boards-url', 'http://wootook.org/board/'),
(1, 1, 'game/general/closing-message', 'Le jeu est clos pour le moment.'),
(1, 1, 'game/general/extra-url', 'http://wootook.org/'),
(1, 1, 'game/general/extra-url-title', 'Wootook!'),
(1, 1, 'game/general/locale', 'fr_FR'),
(1, 1, 'game/general/name', 'Wootook'),
(1, 1, 'game/noob-protection/active', '0'),
(1, 1, 'game/noob-protection/multiplier', '5'),
(1, 1, 'game/noob-protection/points-cap', '5000'),
(1, 1, 'game/resource/multiplier', '1000'),
(1, 1, 'game/speed/fleet', '2500'),
(1, 1, 'game/speed/general', '2500'),
(1, 1, 'resource/base-income/cristal', '10'),
(1, 1, 'resource/base-income/deuterium', '0'),
(1, 1, 'resource/base-income/energy', '0'),
(1, 1, 'resource/base-income/metal', '20'),
(1, 1, 'resource/initial/cristal', '500'),
(1, 1, 'resource/initial/deuterium', '0'),
(1, 1, 'resource/initial/energy', '0'),
(1, 1, 'resource/initial/fields', '163'),
(1, 1, 'resource/initial/metal', '500'),
(1, 1, 'web/cookie/name', '__wtk_1_1');
CREATE TABLE IF NOT EXISTS `game_core_game` (
`game_id` smallint(5) unsigned NOT NULL,
`group_id` tinyint(3) unsigned NOT NULL,
`website_id` tinyint(3) unsigned NOT NULL,
`code` varchar(64) NOT NULL,
`name` varchar(255) NOT NULL,
`sort_order` tinyint(3) unsigned NOT NULL,
`is_default` tinyint(1) NOT NULL,
`is_staging` tinyint(1) NOT NULL,
`is_active` tinyint(1) NOT NULL,
PRIMARY KEY (`group_id`),
UNIQUE KEY `code` (`code`),
KEY `website_id` (`website_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `game_core_game` (`game_id`, `group_id`, `website_id`, `code`, `name`, `sort_order`, `is_default`, `is_staging`, `is_active`) VALUES
(0, 0, 0, 'admin', 'Administration', 0, 0, 0, 1),
(1, 1, 1, 'default', 'Default Game', 1, 1, 0, 1);
CREATE TABLE IF NOT EXISTS `game_core_game_group` (
`group_id` tinyint(3) unsigned NOT NULL,
`website_id` tinyint(3) unsigned NOT NULL,
`code` varchar(64) NOT NULL,
`name` varchar(255) NOT NULL,
`sort_order` tinyint(3) unsigned NOT NULL,
`is_default` tinyint(1) NOT NULL,
PRIMARY KEY (`group_id`),
UNIQUE KEY `code` (`code`),
KEY `website_id` (`website_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `game_core_game_group` (`group_id`, `website_id`, `code`, `name`, `sort_order`, `is_default`) VALUES
(0, 0, 'admin', 'Administration', 0, 0),
(1, 1, 'default', 'Default Group', 1, 1);
CREATE TABLE IF NOT EXISTS `game_core_website` (
`website_id` tinyint(3) unsigned NOT NULL,
`code` varchar(64) NOT NULL,
`name` varchar(255) NOT NULL,
`sort_order` tinyint(3) unsigned NOT NULL,
`default_group_id` tinyint(3) unsigned NOT NULL,
`is_default` tinyint(1) NOT NULL,
`is_staging` tinyint(1) NOT NULL,
`is_active` tinyint(1) NOT NULL,
PRIMARY KEY (`website_id`),
UNIQUE KEY `code` (`code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `game_core_website` (`website_id`, `code`, `name`, `sort_order`, `default_group_id`, `is_default`, `is_staging`, `is_active`) VALUES
(0, 'admin', 'Administration', 0, 0, 0, 0, 1),
(1, 'default', 'Default Website', 1, 1, 1, 0, 1);

View file

@ -155,7 +155,7 @@ $mode = isset($_GET['mode']) ? $_GET['mode'] : null;
//Selectionne si le joueur a des techno en cours
$tech = doquery("SELECT COUNT(id) AS `tech` FROM {{table}} WHERE `id` = '".$user['id']."' and `b_tech_planet`!=0;", 'users', true);
//Selectionne si le joueur est en train de se faire attaquer
$attack = doquery("SELECT COUNT(fleet_taget_owner) AS `attack` FROM {{table}} WHERE `fleet_taget_owner` = '".$user['id']."';", 'fleets', true);
$attack = doquery("SELECT COUNT(fleet_target_owner) AS `attack` FROM {{table}} WHERE `fleet_target_owner` = '".$user['id']."';", 'fleets', true);
if ($fleet['actcnt'] == 0 && $build['building'] == 0 && $tech['tech'] == 0 && $attack['attack'] == 0) {
$user->setVacation();

View file

@ -1,301 +0,0 @@
<?php
/**
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.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('INSTALL' , false);
require_once dirname(__FILE__) .'/application/bootstrap.php';
$user = Wootook_Player_Model_Session::getSingleton()->getPlayer();
$planet = $user->getCurrentPlanet();
$moon = $planet->getMoon();
includeLang('resources');
includeLang('overview');
$layout = new Wootook_Core_Model_Layout();
$layout->load('overview');
if ($user->getId()) {
$planetCollection = $user->getPlanetCollection();
$planetBlock = $layout->createBlock('core/deprecated', 'planet.view');
$planetBlock->setTemplate('empire/overview/planet/view.phtml');
$planetList = $layout->createBlock('core/concat', 'planet.list');
$planetBlock->planetList = $planetList;
$i = 0;
foreach ($planetCollection as $userPlanet) {
if ($userPlanet->getId() == $planet->getId()) {
continue;
}
/*
* Update planet resources and constructions
*/
Wootook::dispatchEvent('planet.update', array(
'planet' => $userPlanet
));
$userPlanet->save();
if ($userPlanet->getId() != $user->getCurrentPlanet()->getId() && $userPlanet->isPlanet()) {
$id = uniqid();
$block = $layout->createBlock('core/deprecated', "planet.list.item.{$id}");
$block->setTemplate('empire/overview/planet/list/item.phtml');
$block['planet'] = $userPlanet;
$buildingQueue = $userPlanet->getBuildingQueue();
$buildingQueue->rewind();
$currentItem = $buildingQueue->current();
$block['queue_item'] = $currentItem;
$block['even'] = (($i++ % 4) == 3);
$planetList->$id = $block;
}
}
/**
* Missile attack management
* Refactoring needed
* {{{
*/
$iraks_query = doquery("SELECT * FROM {{table}} WHERE owner = '" . $user['id'] . "'", 'iraks');
$Record = 4000;
while ($irak = $iraks_query->fetch(PDO::FETCH_ASSOC)) {
$Record++;
$fpage[$irak['zeit']] = '';
if ($irak['zeit'] > time()) {
$time = $irak['zeit'] - time();
$fpage[$irak['zeit']] .= InsertJavaScriptChronoApplet ("fm", $Record, $time, true);
$planet_start = doquery("SELECT * FROM {{table}} WHERE
galaxy = '" . $irak['galaxy'] . "' AND
system = '" . $irak['system'] . "' AND
planet = '" . $irak['planet'] . "' AND
planet_type = '1'", 'planets');
$user_planet = doquery("SELECT * FROM {{table}} WHERE
galaxy = '" . $irak['galaxy_angreifer'] . "' AND
system = '" . $irak['system_angreifer'] . "' AND
planet = '" . $irak['planet_angreifer'] . "' AND
planet_type = '1'", 'planets', true);
if ($planet_start->rowCount() == 1) {
$planet = mysql_fetch_array($planet_start);
}
$fpage[$irak['zeit']] .= "<tr><th><div id=\"bxxfs$i\" class=\"z\"></div><font color=\"lime\">" . gmdate("H:i:s", $irak['zeit'] + 1 * 60 * 60) . "</font> </th><th colspan=\"3\"><font color=\"#0099FF\">Une attaque de missiles (" . $irak['anzahl'] . ") de " . $user_planet['name'] . " ";
$fpage[$irak['zeit']] .= '<a href="galaxy.php?mode=3&galaxy=' . $irak["galaxy_angreifer"] . '&system=' . $irak["system_angreifer"] . '&planet=' . $irak["planet_angreifer"] . '">[' . $irak["galaxy_angreifer"] . ':' . $irak["system_angreifer"] . ':' . $irak["planet_angreifer"] . ']</a>';
$fpage[$irak['zeit']] .= ' arrive sur la plan&egrave;te' . $planet["name"] . ' ';
$fpage[$irak['zeit']] .= '<a href="galaxy.php?mode=3&galaxy=' . $irak["galaxy"] . '&system=' . $irak["system"] . '&planet=' . $irak["planet"] . '">[' . $irak["galaxy"] . ':' . $irak["system"] . ':' . $irak["planet"] . ']</a>';
$fpage[$irak['zeit']] .= '</font>';
$fpage[$irak['zeit']] .= InsertJavaScriptChronoApplet ("fm", $Record, $time, false);
$fpage[$irak['zeit']] .= "</th>";
}
}
/**
* }}}
*/
/*
* Update fleet list
*/
Wootook::dispatchEvent('fleet.update', array(
'player' => $user
));
$fleetList = $layout->createBlock('core/concat', 'fleet.list');
$fleetCollection = $user->getFleetCollection();
foreach ($fleetCollection as $fleet) {
$id = uniqid();
$block = $layout->createBlock('core/deprecated', "fleet.list.item.{$id}");
$block->setTemplate('empire/overview/fleet/item.phtml');
$block['class'] = $fleet->getRowClass();
$block['fleet'] = $fleet;
$block['user'] = $user;
$fleetList->setPartial($id, $block);
}
$messageCollection = $user->getNewMessagesCount();
$newMessages = $layout->createBlock('core/deprecated', 'overview.messages');
$newMessages->setTemplate('empire/overview/messages.phtml');
$newMessages['count'] = (int) $count;
/**
* Page display
* Refactoring needed
* {{{
*/
// -----------------------------------------------------------------------------------------------
$parse = $lang;
// -----------------------------------------------------------------------------------------------
// News Frame ...
// External Chat Frame ...
// Banner ADS Google (meme si je suis contre cela)
if (Wootook::getGameConfig('game/news/active')) {
$parse['NewsFrame'] = "<tr><th>" . $lang['ov_news_title'] . "</th><th colspan=\"3\">" . htmlentities(Wootook::getGameConfig('game/news/content'), ENT_QUOTES, 'UTF-8') . "</th></tr>";
}
if (Wootook::getGameConfig('engine/options/chat')) {
$parse['ExternalTchatFrame'] = "<tr><th colspan=\"4\">" . Wootook::__('Open the chat.') . "</th></tr>";
}
if (Wootook::getGameConfig('engine/options/banner')) {
$bannerUrl = Wootook::getStaticUrl('scripts/createbanner.php', array('id' => $user['id']));
$parse['bannerframe'] = "<th colspan=\"4\"><img src=\"{$bannerUrl}\"><br>".$lang['InfoBanner']."<br><input name=\"bannerlink\" type=\"text\" id=\"bannerlink\" value=\"[img]".$bannerUrl."[/img]\" size=\"62\"></th></tr>";
}
// --- Gestion de l'affichage d'une lune ---------------------------------------------------------
if ($moon['id']) {
if ($planet->isPlanet()) {
$lune = doquery ("SELECT * FROM {{table}} WHERE `galaxy` = '" . $planet['galaxy'] . "' AND `system` = '" . $planet['system'] . "' AND `planet` = '" . $planet['planet'] . "' AND `planet_type` = '3'", 'planets', true);
$parse['moon_img'] = "<a href=\"?cp=" . $lune['id'] . "&re=0\" title=\"" . $lune['name'] . "\"><img src=\"" . Wootook::getSkinUrl('base', 'default', "graphics/planeten/{$lune['image']}.jpg") . '" height="50" width="50"></a>';
$parse['moon'] = $planet->getMoon()->getName();
} else {
$parse['moon_img'] = "";
$parse['moon'] = "";
}
} else {
$parse['moon_img'] = "";
$parse['moon'] = "";
}
// Moon END
$parse['planet_name'] = $planet['name'];
$parse['planet_diameter'] = Math::render($planet['diameter']);
$parse['planet_field_current'] = Math::render($planet->getUsedFields());
$parse['planet_field_max'] = Math::render($planet->getBuildingFields());
$parse['planet_temp_min'] = $planet['temp_min'];
$parse['planet_temp_max'] = $planet['temp_max'];
$parse['galaxy_galaxy'] = $planet['galaxy'];
$parse['galaxy_planet'] = $planet['planet'];
$parse['galaxy_system'] = $planet['system'];
$StatRecord = doquery("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '" . $user['id'] . "';", 'statpoints', true);
$parse['user_points'] = Math::render($StatRecord['build_points']);
$parse['user_fleet'] = Math::render($StatRecord['fleet_points']);
$parse['player_points_tech'] = Math::render($StatRecord['tech_points']);
$parse['total_points'] = Math::render($StatRecord['total_points']);;
$parse['user_rank'] = $StatRecord['total_rank'];
$ile = $StatRecord['total_old_rank'] - $StatRecord['total_rank'];
if ($ile >= 1) {
$parse['ile'] = "<font color=lime>+" . $ile . "</font>";
} elseif ($ile < 0) {
$parse['ile'] = "<font color=red>-" . $ile . "</font>";
} elseif ($ile == 0) {
$parse['ile'] = "<font color=lightblue>" . $ile . "</font>";
}
$parse['u_user_rank'] = $StatRecord['total_rank'];
$parse['user_username'] = $user['username'];
//$parse['fleet_list'] = $fleetList->render();
$parse['energy_used'] = $planet["energy_max"] - $planet["energy_used"];
//$parse['Have_new_message'] = $newMessages->render();
$parse['time'] = "<div id=\"dateheure\"></div>";
$parse['planet_image'] = $planet['image'];
//$parse['anothers_planets'] = $planetBlock->render();
$collection = new Wootook_Player_Resource_Entity_Collection($user->getReadConnection());
$collection->addAuthlevelToFilter(array(LEVEL_ADMIN), true);
$parse['max_users'] = $collection->getSize();
$galaxyData = $planet->getGalaxyData();
$parse['metal_debris'] = Math::render($galaxyData['metal']);
$parse['crystal_debris'] = Math::render($galaxyData['crystal']);
if (($galaxyData['metal'] != 0 || $galaxyData['crystal'] != 0) && Math::isPositive($planet->getElement(Legacies_Empire::ID_SHIP_RECYCLER))) {
$parse['get_link'] = " (<a href=\"quickfleet.php?mode=8&g=" . $galaxyData['galaxy'] . "&s=" . $galaxyData['system'] . "&p=" . $galaxyData['planet'] . "&t=2\">" . $lang['type_mission'][Legacies_Empire::ID_MISSION_RECYCLE] . "</a>)";
} else {
$parse['get_link'] = '';
}
$latestPlayerStatement = $user->getReadConnection()->prepare("SELECT user.username AS `latest_player` FROM {$user->getReadConnection()->getTable('users')} AS user WHERE user.authlevel IN({$displayedPlayerLevels}) ORDER BY user.`register_time` DESC LIMIT 1");
$latestPlayerStatement->execute();
$latestPlayer = $latestPlayerStatement->fetch(Wootook_Core_Database_Adapter_Pdo_Mysql::FETCH_COLUMN, 0);
$collection = new Wootook_Player_Resource_Entity_Collection($user->getReadConnection());
$collection->addAuthlevelToFilter(array(LEVEL_ADMIN), true);
$collection->addIsOnlineToFilter();
$onlinePlayers = $collection->getSize();
$query = doquery('SELECT username FROM {{table}} ORDER BY register_time DESC', 'users', true);
$parse['last_user'] = $latestPlayer;
$query = doquery("SELECT COUNT(DISTINCT(id)) FROM {{table}} WHERE onlinetime>" . (time()-900), 'users', true);
$parse['online_users'] = $onlinePlayers;
$parse['users_amount'] = $userCount;
// Rajout d'une barre pourcentage
// Calcul du pourcentage de remplissage
// Barre de remplissage
$size = floor($planet->getUsedFields() / $planet->getBuildingFields() * 100);
// Couleur de la barre de remplissage
$parse['case_pourcentage'] = $size . $lang['o/o'];
if ($size > 100) {
$size = 100;
$parse['case_barre_barcolor'] = '#C00000';
} elseif ($size >= 80) {
$parse['case_barre_barcolor'] = '#C0C000';
} else {
$parse['case_barre_barcolor'] = '#00C000';
}
$parse['case_barre'] = $size;
// Mode Améliorations
$parse['xpminier'] = $user['xpminier'];
$parse['xpraid'] = $user['xpraid'];
$parse['lvl_minier'] = $user['lvl_minier'];
$parse['lvl_raid'] = $user['lvl_raid'];
$LvlMinier = $user['lvl_minier'];
$LvlRaid = $user['lvl_raid'];
$parse['lvl_up_minier'] = $LvlMinier * 5000;
$parse['lvl_up_raid'] = $LvlRaid * 10;
// Nombre de raids, pertes, etc ...
$parse['Raids'] = $lang['Raids'];
$parse['NumberOfRaids'] = $lang['NumberOfRaids'];
$parse['RaidsWin'] = $lang['RaidsWin'];
$parse['RaidsLoose'] = $lang['RaidsLoose'];
$parse['raids'] = $user['raids'];
$parse['raidswin'] = $user['raidswin'];
$parse['raidsloose'] = $user['raidsloose'];
// Compteur de Membres en ligne
$OnlineUsers = doquery("SELECT COUNT(*) FROM {{table}} WHERE onlinetime>='" . (time()-15 * 60) . "'", 'users', 'true');
$parse['NumberMembersOnline'] = $OnlineUsers[0];
$page = parsetemplate(gettemplate('overview_body'), $parse);
display($page);
/**
* }}}
*/
}

View file

@ -1,110 +0,0 @@
<?php
/**
* This file is part of Wootook
*
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* @see http://wootook.org/
*
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.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('DISABLE_IDENTITY_CHECK', true);
require_once dirname(__FILE__) .'/application/bootstrap.php';
includeLang('reg');
if (!empty($_POST) && isset($_POST['username']) && isset($_POST['planet_name']) && isset($_POST['email']) && isset($_POST['email_confirm']) && isset($_POST['password']) && isset($_POST['password_confirm'])) {
$session = Wootook::getSession(Wootook_Player_Model_Entity::SESSION_KEY);
if ($_POST['password'] !== $_POST['password_confirm']) {
$session->addError('Password and password confirmation does not match.');
}
if ($_POST['email'] !== $_POST['email_confirm']) {
$session->addError('Email and email confirmation does not match.');
}
$user = null;
if (true || count($session->getMessages(false)) === 0) {
$user = Wootook_Player_Model_Entity::register($_POST['username'], $_POST['email'], $_POST['password']);
if ($user !== null) {
$user->getHomePlanet()->setName($_POST['planet_name'])->save();
}
}
if ($user !== null && $user->getId()) {
header("HTTP/1.1 302 Found");
//header("Location: welcome.php");
header("Location: overview.php");
} else {
header("HTTP/1.1 302 Found");
header("Location: reg.php");
}
Wootook_Core_ErrorProfiler::unregister(true);
exit(0);
}
$layout = new Wootook_Core_Model_Layout();
$layout->load('registration');
$block = $layout->getBlock('registration');
echo $layout->render();
/*
function sendpassemail($emailaddress, $password)
{
global $lang;
$parse['gameurl'] = Wootook::getStaticUrl('/');
$parse['password'] = $password;
$email = parsetemplate($lang['mail_welcome'], $parse);
$status = mymail($emailaddress, $lang['mail_title'], $email);
return $status;
}
function mymail($to, $title, $body, $from = '')
{
$from = trim($from);
if (!$from) {
$from = ADMINEMAIL;
}
$rp = ADMINEMAIL;
$head = '';
$head .= "Content-Type: text/plain \r\n";
$head .= "Date: " . date('r') . " \r\n";
$head .= "Return-Path: $rp \r\n";
$head .= "From: $from \r\n";
$head .= "Sender: $from \r\n";
$head .= "Reply-To: $from \r\n";
$head .= "Organization: $org \r\n";
$head .= "X-Sender: $from \r\n";
$head .= "X-Priority: 3 \r\n";
$body = str_replace("\r\n", "\n", $body);
$body = str_replace("\n", "\r\n", $body);
return mail($to, $title, $body, $head);
}
*/

View file

@ -106,14 +106,17 @@ input[type=submit],input[type=button] {height:2em;border:#58939f 0 solid;border-
* Overview
*/
.global .content .overview {width:740px;padding:10px 30px;margin:10px auto 0;background:#FFF;color:#000;border:10px solid #58939f;border-radius:10px;border-top-left-radius:30px;border-top-right-radius:30px;}
.global .content .overview h1 {border-bottom:10px solid #58939f;height:30px;margin:10px 10px 30px;font-size:2.3em;}
.global .content .overview .clear {clear:left;height:50px;}
.overview .global .container {width:740px;padding:10px 30px;margin:10px auto 0;background:#FFF;color:#000;border:10px solid #58939f;border-radius:10px;border-top-left-radius:30px;border-top-right-radius:30px;}
.overview .global .container h1 {border-bottom:10px solid #58939f;height:30px;margin:10px 10px 30px;font-size:2.3em;}
.overview .global .container .clear {clear:left;height:50px;}
.overview .global .container .item-container h2 {text-decoration:none;margin-bottom:0;font-size:1.3em;}
.overview .global .container .item-container h3 {text-decoration:none;margin-top:0;font-size:1em;color:#58939f;font-weight:bold;}
.overview .global .container .item-container {padding:10px;margin:10px;border:3px solid #58939f;background-color:#EFEFEF;border-radius:15px 3px 15px 3px;}
.global .content .overview .left {width:250px;float:left;}
.global .content .overview .left h2 {text-decoration:none;margin-bottom:0;font-size:1.3em;}
.global .content .overview .left h3 {text-decoration:none;margin-top:0;font-size:1em;color:#58939f;font-weight:bold;}
.global .content .overview .left .item-container {width:200px;padding:10px;margin:10px;height:250px;border:3px solid #58939f;background-color:#EFEFEF;}
.overview .global .container .left {width:250px;float:left;}
.overview .global .container .content {margin-left:250px;width:490px;}
.overview .global .container .left .item-container {width:200px;}
.overview .global .container .content .item-container {width:440px;}
/**
* Public pages