diff --git a/admin/ShowFlyingFleets.php b/admin/ShowFlyingFleets.php index 89f1eb1..828246e 100644 --- a/admin/ShowFlyingFleets.php +++ b/admin/ShowFlyingFleets.php @@ -33,18 +33,18 @@ define('INSTALL' , false); define('IN_ADMIN', true); require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php'; - if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR, LEVEL_MODERATOR))) { - includeLang('admin/fleets'); - $PageTPL = gettemplate('admin/fleet_body'); +include(ROOT_PATH . 'includes/functions/BuildFlyingFleetTable.'.PHPEXT); - $parse = $lang; - $parse['flt_table'] = BuildFlyingFleetTable (); +if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR, LEVEL_MODERATOR))) { + includeLang('admin/fleets'); + $PageTPL = gettemplate('admin/fleet_body'); - $page = parsetemplate( $PageTPL, $parse ); - display ( $page, $lang['flt_title'], false, '', true); + $parse = $lang; + $parse['flt_table'] = BuildFlyingFleetTable (); - } else { - AdminMessage ( $lang['sys_noalloaw'], $lang['sys_noaccess'] ); - } + $page = parsetemplate( $PageTPL, $parse ); + display ( $page, $lang['flt_title'], false, '', true); -?> \ No newline at end of file +} else { + AdminMessage ( $lang['sys_noalloaw'], $lang['sys_noaccess'] ); +} diff --git a/admin/leftmenu.php b/admin/leftmenu.php index 180034a..40c0a0d 100644 --- a/admin/leftmenu.php +++ b/admin/leftmenu.php @@ -36,13 +36,13 @@ require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php'; includeLang('leftmenu'); if (in_array($user['authlevel'], array(LEVEL_ADMIN, LEVEL_OPERATOR, LEVEL_MODERATOR))) { - $parse = $lang; - $parse['mf'] = "Hauptframe"; - $parse['dpath'] = $dpath; + $parse = $lang; + $parse['mf'] = "Hauptframe"; + $parse['dpath'] = $dpath; $parse['WootookRelease'] = VERSION; - $parse['servername'] = Wootook; - $Page = parsetemplate(gettemplate('admin/left_menu'), $parse); - display( $Page, "", false, '', true); + $parse['servername'] = 'Wootook'; + $Page = parsetemplate(gettemplate('admin/left_menu'), $parse); + display($Page, "", false, '', true); } else { message( $lang['sys_noalloaw'], $lang['sys_noaccess'] ); } diff --git a/application/bootstrap.php b/application/bootstrap.php index fd5a0f1..abd1b68 100644 --- a/application/bootstrap.php +++ b/application/bootstrap.php @@ -28,10 +28,6 @@ * */ -defined('BCNUMBERS') || define('BCNUMBERS', true); -defined('DEPRECATION') || define('DEPRECATION', true); -defined('DEBUG') || define('DEBUG', true); - if (!defined('DEBUG') && ($env = getenv('DEBUG')) !== false && in_array(strtolower($env), array('1', 'on', 'true'))) { define('DEBUG', true); } else if (!defined('DEBUG') && isset($_SERVER['DEBUG']) && in_array(strtolower($_SERVER['DEBUG']), array('1', 'on', 'true'))) { @@ -62,7 +58,7 @@ defined('APPLICATION_PATH') || define('APPLICATION_PATH', dirname(__FILE__) . DI defined('PHPEXT') || define('PHPEXT', 'php'); -defined('VERSION') || define('VERSION', '2011.1'); +defined('VERSION') || define('VERSION', '1.5.0-beta2'); set_include_path(implode(PATH_SEPARATOR, array( APPLICATION_PATH . DIRECTORY_SEPARATOR . 'code' . DIRECTORY_SEPARATOR . 'libraries', @@ -80,7 +76,8 @@ Wootook_Core_Time::init(); Wootook_Core_ErrorProfiler::register(); Wootook_Core_Model_Config_Events::registerEvents(); -if (0 === filesize(ROOT_PATH . 'config.php')) { +if (!defined('IN_INSTALL') && 0 === filesize(ROOT_PATH . 'config.php')) { + header('HTTP/1.1 307 Temporary Redirect'); header('Location: install/'); die(); } @@ -100,43 +97,46 @@ include(ROOT_PATH . 'language/' . DEFAULT_LANG . '/lang_info.cfg'); include(ROOT_PATH . 'includes/vars.' . PHPEXT); include(ROOT_PATH . 'includes/strings.' . PHPEXT); -$gameConfig = Wootook_Core_Model_Config::getSingleton(); -if (isset($gameConfig['cookie_name']) && !empty($gameConfig['cookie_name'])) { - Wootook_Empire_Model_User::setCookieName($gameConfig['cookie_name']); -} -$user = Wootook_Empire_Model_User::getSingleton(); +if (!defined('IN_INSTALL')) { -if (!defined('DISABLE_IDENTITY_CHECK')) { - if (($user === null || !$user->getId())) { - header('Location: login.php'); - exit(0); + $gameConfig = Wootook_Core_Model_Config::getSingleton(); + if (isset($gameConfig['cookie_name']) && !empty($gameConfig['cookie_name'])) { + Wootook_Empire_Model_User::setCookieName($gameConfig['cookie_name']); + } + $user = Wootook_Empire_Model_User::getSingleton(); + + if (!defined('DISABLE_IDENTITY_CHECK')) { + if (($user === null || !$user->getId())) { + header('Location: login.php'); + exit(0); + } + + if ($gameConfig->isEnabled() && $user !== null && !in_array($user->getData('authlevel'), array(LEVEL_ADMIN, LEVEL_MODERATOR, LEVEL_OPERATOR))) { + message(stripslashes($gameConfig->getData('close_reason')), $gameConfig->getData('game_name')); + exit(0); + } } - if ($gameConfig->isEnabled() && $user !== null && !in_array($user->getData('authlevel'), array(LEVEL_ADMIN, LEVEL_MODERATOR, LEVEL_OPERATOR))) { - message(stripslashes($gameConfig->getData('close_reason')), $gameConfig->getData('game_name')); - exit(0); + includeLang('system'); + includeLang('tech'); + + if (($user !== null && $user->getId())) { + if (isset($_GET['cp']) && !empty($_GET['cp'])) { + $user->updateCurrentPlanet((int) $_GET['cp']); + } + + $planet = $user->getCurrentPlanet(); + + foreach ($user->getPlanetCollection() as $userPlanet) { + FlyingFleetHandler($userPlanet); // TODO: implement logic into a refactored model + } + + /* + * Update planet resources and constructions + */ + Wootook::dispatchEvent('planet.update', array( + 'planet' => $planet + )); + $planet->save(); } -} - -includeLang('system'); -includeLang('tech'); - -if (($user !== null && $user->getId())) { - if (isset($_GET['cp']) && !empty($_GET['cp'])) { - $user->updateCurrentPlanet((int) $_GET['cp']); - } - - $planet = $user->getCurrentPlanet(); - - foreach ($user->getPlanetCollection() as $userPlanet) { - FlyingFleetHandler($userPlanet); // TODO: implement logic into a refactored model - } - - /* - * Update planet resources and constructions - */ - Wootook::dispatchEvent('planet.update', array( - 'planet' => $planet - )); - $planet->save(); } \ No newline at end of file diff --git a/application/code/core/Wootook.php b/application/code/core/Wootook.php index 4197254..1e58ee0 100644 --- a/application/code/core/Wootook.php +++ b/application/code/core/Wootook.php @@ -197,7 +197,7 @@ class Wootook return self::$_defaultLocale; } - public function getPreferredLocale($availableLocales = array()) + public static function getPreferredLocale($availableLocales = array()) { if (empty($availableLocales)) { return self::getDefaultLocale(); @@ -255,6 +255,9 @@ class Wootook return self::$_now; } + /** + * @return Wootook_Core_Controller_Request_Http + */ public static function getRequest() { if (self::$_request === null) { @@ -268,6 +271,9 @@ class Wootook self::$_request = $request; } + /** + * @return Wootook_Core_Controller_Response_Http + */ public static function getResponse() { if (self::$_response === null) { @@ -281,11 +287,20 @@ class Wootook self::$_response = $response; } - public static function getConfig($path = null) + private static function _loadConfig() { if (self::$_config === null) { self::$_config = include ROOT_PATH . DIRECTORY_SEPARATOR . 'config.php'; + + if (!is_array(self::$_config)) { + self::$_config = array(); + } } + } + + public static function getConfig($path = null) + { + self::_loadConfig(); if ($path === null || !is_string($path)) { return self::$_config; @@ -300,6 +315,25 @@ class Wootook return $config; } + public static function setConfig($path = null, $value) + { + self::_loadConfig(); + + if ($path === null || !is_string($path)) { + return self::$_config; + } + $config = &self::$_config; + foreach (explode('/', $path) as $chunk) { + if (!isset($config[$chunk])) { + $config[$chunk] = array(); + } + $config = &$config[$chunk]; + } + $config = $value; + + return true; + } + public static function getBaseUrl() { return self::getConfig('global/web/base_url'); @@ -333,10 +367,13 @@ class Wootook return false; } + Wootook_Core_ErrorProfiler::sleep(); if (($fp = @fopen($path, 'r', true)) === false) { + Wootook_Core_ErrorProfiler::wakeup(); return false; } fclose($fp); + Wootook_Core_ErrorProfiler::wakeup(); return true; } } \ No newline at end of file diff --git a/application/code/core/Wootook/Core/Block/Messages.php b/application/code/core/Wootook/Core/Block/Messages.php new file mode 100644 index 0000000..a214dec --- /dev/null +++ b/application/code/core/Wootook/Core/Block/Messages.php @@ -0,0 +1,43 @@ +_storages[] = $namespace; + } + + public function renderGroupedHtml() + { + $messages = array(); + + foreach ($this->_storages as $namespace) { + $session = Wootook::getSession($namespace); + + foreach ($session->getData('messages') as $messageLevel => $messageList) { + if (!isset($messages[$messageLevel])) { + $messages[$messageLevel] = $messageList; + } else { + $messages[$messageLevel] += $messageList; + } + } + } + + rsort($messages, SORT_NUMERIC); + + $output = '
'; + foreach ($messages as $messageLevel => $messageList) { + $output .= "'; + } + $output .= '
'; + + return $output; + } +} \ No newline at end of file diff --git a/application/code/core/Wootook/Core/Controller/Request/Http.php b/application/code/core/Wootook/Core/Controller/Request/Http.php index 611294f..db84156 100644 --- a/application/code/core/Wootook/Core/Controller/Request/Http.php +++ b/application/code/core/Wootook/Core/Controller/Request/Http.php @@ -84,6 +84,40 @@ class Wootook_Core_Controller_Request_Http return $_SERVER[$key]; } + public function getAllQueryData() + { + return $_GET; + } + + public function getAllFilesData() + { + return $_FILES; + } + + public function getAllCookieData() + { + $data = array(); + foreach ($_COOKIE as $key => $value) { + $data[$key] = unserialize(stripslashes($value)); + } + return $data; + } + + public function getAllRawCookieData() + { + return $_COOKIE; + } + + public function getAllPostData() + { + return $_POST; + } + + public function getAllServerData() + { + return $_SERVER; + } + public function isPost() { if (strtoupper($this->getServer('REQUEST_METHOD')) == 'POST') { @@ -92,6 +126,22 @@ class Wootook_Core_Controller_Request_Http return false; } + public function isPut() + { + if (strtoupper($this->getServer('REQUEST_METHOD')) == 'PUT') { + return true; + } + return false; + } + + public function isHead() + { + if (strtoupper($this->getServer('REQUEST_METHOD')) == 'HEAD') { + return true; + } + return false; + } + public function isGet() { if (strtoupper($this->getServer('REQUEST_METHOD')) == 'GET') { diff --git a/application/code/core/Wootook/Core/Controller/Response/Http.php b/application/code/core/Wootook/Core/Controller/Response/Http.php index 2e4ffcd..442759a 100644 --- a/application/code/core/Wootook/Core/Controller/Response/Http.php +++ b/application/code/core/Wootook/Core/Controller/Response/Http.php @@ -81,7 +81,7 @@ class Wootook_Core_Controller_Response_Http return $this; } - public function setRawHeader($name, $value) + public function setRawHeader($value) { if (!isset($this->_data['raw_headers']) || !is_array($this->_data['raw_headers'])) { $this->clearRawHeaders(); diff --git a/application/code/core/Wootook/Core/Form.php b/application/code/core/Wootook/Core/Form.php new file mode 100644 index 0000000..6c7aec1 --- /dev/null +++ b/application/code/core/Wootook/Core/Form.php @@ -0,0 +1,175 @@ +_session = $session; + + $this->_fieldLoader = new Wootook_Core_Form_FieldLoader($this, array( + 'Wootook_Core_Form_Field_' => 'Wootook/Core/Form/Field' + )); + + $this->_validatorLoader = new Wootook_Core_Form_ValidatorLoader($this, array( + 'Wootook_Core_Form_Validator_' => 'Wootook/Core/Form/Validator' + )); + + $this->addField('__formkey', 'text', array('form_key' => 'formKey')); + + foreach ($fields as $fieldName => $fieldConfig) { + if (is_string($fieldConfig)) { + $this->addField($fieldName, $fieldConfig); + } else if ($fieldConfig instanceof Wootook_Core_Form_FieldAbstract) { + $this->addField($fieldName, $fieldConfig); + } else { + if (isset($fieldConfig['validators'])) { + $this->addField($fieldName, $fieldConfig['type'], $fieldConfig['validators']); + } else { + $this->addField($fieldName, $fieldConfig['type']); + } + } + } + } + + public function validate() + { + foreach ($this->_fields as $field) { + $field->validate(); + } + } + + /** + * + * Enter description here ... + * @param string $name + * @param string|Wootook_Core_Form_FieldAbstract $type + * @return Wootook_Core_Form + */ + public function addField($name, $type = 'text', Array $validators = array()) + { + if ($type instanceof Wootook_Core_Form_FieldAbstract) { + $this->_fields[$name] = $name; + $this->_fields[$name]->setForm($this); + } else { + $field = $this->_fieldLoader->load($type); + + if ($field === null) { + trigger_error(sprintf('Field %1$s (type: %2$s) could not be created.', $name, $type), E_USER_WARNING); + return $this; + } + $this->_fields[$name] = $field; + } + $this->_fields[$name]->setName($name); + + foreach ($validators as $validatorName => $validatorType) { + if ($validatorType instanceof Wootook_Core_Form_FieldAbstract) { + $this->_fields[$name]->addValidator($validatorType, $validatorName); + } else { + $validator = $this->_validatorLoader->load($validatorType); + + if ($validator === null) { + trigger_error(sprintf('Validator %1$s (type: %2$s) could not be created.', $validatorName, $validatorType), E_USER_WARNING); + return $this; + } + $this->_fields[$name]->addValidator($validator, $validatorName); + } + } + + return $this; + } + + /** + * + * Enter description here ... + * @param string $name + * @return Wootook_Core_Form_FieldAbstract + */ + public function getField($name) + { + if (!isset($this->_fields[$name])) { + return null; + } + + return $this->_fields[$name]; + } + + /** + * + * Enter description here ... + * @param string $name + * @return Wootook_Core_Model_Session + */ + public function getSession() + { + return $this->_session; + } + + public function setRequest(Wootook_Core_Controller_Request_Http $request) + { + $this->_request = $request; + + return $this; + } + + /** + * + * Enter description here ... + * @return Wootook_Core_Controller_Request_Http + */ + public function getRequest() + { + return $this->_request; + } + + public function getData() + { + $request = $this->getRequest(); + if ($request === null) { + return array(); + } + if ($request->isPost()) { + return $request->getAllPostData(); + } + return $request->getAllQueryData(); + } + + public function populate(Array $datas = array()) + { + $request = $this->getRequest(); + + foreach ($this->_fields as $fieldName => $field) { + if (isset($datas[$fieldName])) { + $field->populate($datas[$fieldName]); + } else if ($request->isPost()) { + $field->populate($request->getPost($fieldName)); + } else { + $field->populate($request->getQuery($fieldName)); + } + } + } +} \ No newline at end of file diff --git a/application/code/core/Wootook/Core/Form/Field/Text.php b/application/code/core/Wootook/Core/Form/Field/Text.php new file mode 100644 index 0000000..e70f30b --- /dev/null +++ b/application/code/core/Wootook/Core/Form/Field/Text.php @@ -0,0 +1,11 @@ +setForm($form); + } + } + + abstract public function getType(); + + public function validate() + { + $data = $this->getData(); + + foreach ($this->_validators as $validator) { + if (!$validator->validate($this, $data)) { + return false; + } + } + return true; + } + + public function setName($name) + { + $this->_name = $name; + + return $this; + } + + public function getName() + { + return $this->_name; + } + + public function setForm(Wootook_Core_Form $form) + { + $this->_form = $form; + + return $this; + } + + public function getForm() + { + return $this->_form; + } + + public function getData() + { + return $this->_value; + } + + public function populate($value) + { + $this->_value = $value; + + return $this; + } + + public function addValidator(Wootook_Core_Form_ValidatorAbstract $validator, $name = null) + { + if ($name === null) { + $this->_validators = array(); + $name = 'default'; + } + + $this->_validators[$name] = $validator; + + return $this; + } + + public function getValidator($name) + { + if (!isset($this->_validators[$name])) { + return null; + } + + return $this->_validators[$name]; + } + + public function clearValidator($name) + { + if (isset($this->_validators[$name])) { + unset($this->_validators[$name]); + } + + return $this; + } + + public function clearAllValidators() + { + $this->_validators = array(); + + return $this; + } +} \ No newline at end of file diff --git a/application/code/core/Wootook/Core/Form/FieldLoader.php b/application/code/core/Wootook/Core/Form/FieldLoader.php new file mode 100644 index 0000000..06fa14d --- /dev/null +++ b/application/code/core/Wootook/Core/Form/FieldLoader.php @@ -0,0 +1,36 @@ +_form = $form; + + foreach ($namespaces as $namespace => $path) { + if (is_int($namespace)) { + $this->registerNamespace($path); + } else { + $this->registerNamespace($namespace, $path); + } + } + } + + protected function _load($className, $useSingleton) + { + $reflection = new ReflectionClass($className); + if ($useSingleton && $reflection->implementsInterface('Wootook_Core_Singleton')) { + $method = $reflection->getMethod('getSingleton'); + return $method->invoke(null); + } + + try { + return $reflection->newInstance($this->_form); + } catch (ReflectionException $e) { + trigger_error($e->getMessage(), E_USER_WARNING); + return null; + } + } +} \ No newline at end of file diff --git a/application/code/core/Wootook/Core/Form/Validator/Alnum.php b/application/code/core/Wootook/Core/Form/Validator/Alnum.php new file mode 100644 index 0000000..6b6515b --- /dev/null +++ b/application/code/core/Wootook/Core/Form/Validator/Alnum.php @@ -0,0 +1,22 @@ +_validate($field, $data)) { + $this->_getSession($field) + ->addError('Field "%s" should only contain alphanumeric characters.', $field->getName()); + + return false; + } + return true; + } +} \ No newline at end of file diff --git a/application/code/core/Wootook/Core/Form/Validator/Alpha.php b/application/code/core/Wootook/Core/Form/Validator/Alpha.php new file mode 100644 index 0000000..1e0920b --- /dev/null +++ b/application/code/core/Wootook/Core/Form/Validator/Alpha.php @@ -0,0 +1,22 @@ +_validate($field, $data)) { + $this->_getSession($field) + ->addError('Field "%s" should only contain alphabetic characters.', $field->getName()); + + return false; + } + return true; + } +} \ No newline at end of file diff --git a/application/code/core/Wootook/Core/Form/Validator/Email.php b/application/code/core/Wootook/Core/Form/Validator/Email.php new file mode 100644 index 0000000..7dbb232 --- /dev/null +++ b/application/code/core/Wootook/Core/Form/Validator/Email.php @@ -0,0 +1,21 @@ +_validate($field, $data)) { + $this->_getSession($field) + ->addError('Field "%s" should contain an email.', $field->getName()); + + return false; + } + return true; + } +} \ No newline at end of file diff --git a/application/code/core/Wootook/Core/Form/Validator/FormKey.php b/application/code/core/Wootook/Core/Form/Validator/FormKey.php new file mode 100644 index 0000000..0d3c0ff --- /dev/null +++ b/application/code/core/Wootook/Core/Form/Validator/FormKey.php @@ -0,0 +1,20 @@ +getForm(); + $session = $form->getSession(); + + if ($session->getFormKey(false) == $data) { + return true; + } + + $this->_getSession($field) + ->addError('CSRF token failure.', $field->getName()); + + return false; + } +} \ No newline at end of file diff --git a/application/code/core/Wootook/Core/Form/Validator/Hex.php b/application/code/core/Wootook/Core/Form/Validator/Hex.php new file mode 100644 index 0000000..9025b70 --- /dev/null +++ b/application/code/core/Wootook/Core/Form/Validator/Hex.php @@ -0,0 +1,22 @@ +_validate($field, $data)) { + $this->_getSession($field) + ->addError('Field "%s" should only contain numeric characters.', $field->getName()); + + return false; + } + return true; + } +} \ No newline at end of file diff --git a/application/code/core/Wootook/Core/Form/Validator/Host.php b/application/code/core/Wootook/Core/Form/Validator/Host.php new file mode 100644 index 0000000..270124e --- /dev/null +++ b/application/code/core/Wootook/Core/Form/Validator/Host.php @@ -0,0 +1,21 @@ +_validate($field, $data)) { + $this->_getSession($field) + ->addError('Field "%s" should contain a host name.', $field->getName()); + + return false; + } + return true; + } +} \ No newline at end of file diff --git a/application/code/core/Wootook/Core/Form/Validator/Numeric.php b/application/code/core/Wootook/Core/Form/Validator/Numeric.php new file mode 100644 index 0000000..cd2fd56 --- /dev/null +++ b/application/code/core/Wootook/Core/Form/Validator/Numeric.php @@ -0,0 +1,22 @@ +_validate($field, $data)) { + $this->_getSession($field) + ->addError('Field "%s" should only contain numeric characters.', $field->getName()); + + return false; + } + return true; + } +} \ No newline at end of file diff --git a/application/code/core/Wootook/Core/Form/Validator/Regex.php b/application/code/core/Wootook/Core/Form/Validator/Regex.php new file mode 100644 index 0000000..a2d76e5 --- /dev/null +++ b/application/code/core/Wootook/Core/Form/Validator/Regex.php @@ -0,0 +1,28 @@ +_expression = $expression; + } + + public function validate(Wootook_Core_Form_FieldAbstract $field, $data) + { + if (!$this->_validate($field, $data)) { + $this->_getSession($field) + ->addError('Field "%s" does not match the validation pattern.', $field->getName()); + + return false; + } + return true; + } + + protected function _validate(Wootook_Core_Form_FieldAbstract $field, $data) + { + return preg_match($this->_expression, $data); + } +} \ No newline at end of file diff --git a/application/code/core/Wootook/Core/Form/ValidatorAbstract.php b/application/code/core/Wootook/Core/Form/ValidatorAbstract.php new file mode 100644 index 0000000..5f7239b --- /dev/null +++ b/application/code/core/Wootook/Core/Form/ValidatorAbstract.php @@ -0,0 +1,15 @@ +getForm(); + if (!$form instanceof Wootook_Core_Form) { + return null; + } + return $form->getSession(); + } +} \ No newline at end of file diff --git a/application/code/core/Wootook/Core/Form/ValidatorLoader.php b/application/code/core/Wootook/Core/Form/ValidatorLoader.php new file mode 100644 index 0000000..f95d439 --- /dev/null +++ b/application/code/core/Wootook/Core/Form/ValidatorLoader.php @@ -0,0 +1,36 @@ +_form = $form; + + foreach ($namespaces as $namespace => $path) { + if (is_int($namespace)) { + $this->registerNamespace($path); + } else { + $this->registerNamespace($namespace, $path); + } + } + } + + protected function _load($className, $useSingleton) + { + $reflection = new ReflectionClass($className); + if ($useSingleton && $reflection->implementsInterface('Wootook_Core_Singleton')) { + $method = $reflection->getMethod('getSingleton'); + return $method->invoke(null); + } + + try { + return $reflection->newInstance(); + } catch (ReflectionException $e) { + trigger_error($e->getMessage(), E_USER_WARNING); + return null; + } + } +} \ No newline at end of file diff --git a/application/code/core/Wootook/Core/Layout.php b/application/code/core/Wootook/Core/Layout.php index 5b4f179..15297d9 100644 --- a/application/code/core/Wootook/Core/Layout.php +++ b/application/code/core/Wootook/Core/Layout.php @@ -8,6 +8,8 @@ class Wootook_Core_Layout protected $_blocks = array(); + protected $_messageBlock = null; + protected $_view = null; protected $_eventPrefix = 'layout'; protected $_eventObject = 'layout'; @@ -31,19 +33,16 @@ class Wootook_Core_Layout } } - $config = include ROOT_PATH . 'config.php'; - $fileList = array(); - if (isset($config['global'])) { - if (isset($config['global']['layout'])) { - $fileList = $config['global']['layout']; - } - if (isset($config['global']['package'])) { - $this->setPackage($config['global']['package']); - } - if (isset($config['global']['theme'])) { - $this->setTheme($config['global']['theme']); - } + $fileList = Wootook::getConfig('global/layout'); + if (!is_array($fileList) || empty($fileList)) { + $fileList = $this->getAllDatas(); + } else { + $fileList = array_merge($fileList, $this->getAllDatas()); } + $this->_data = array(); + + $this->setPackage(Wootook::getConfig('global/package')); + $this->setTheme(Wootook::getConfig('global/theme')); foreach ($fileList as $layoutFile) { foreach (include $this->_getLayoutPath($layoutFile) as $layoutId => $layoutConfig) { @@ -57,6 +56,8 @@ class Wootook_Core_Layout } } + $this->_messageBlock = $this->createBlock('core/messages', 'messages'); + return $this; } @@ -86,6 +87,9 @@ class Wootook_Core_Layout $layoutUpdates = array(); $layoutConfig = array(); foreach (array_reverse($layoutConfigs) as $config) { + if (!is_array($config)) { + continue; + } $layoutConfig = array_merge($layoutConfig, $config); if (isset($layoutConfig['reference'])) { @@ -374,6 +378,10 @@ class Wootook_Core_Layout public function render() { + if (!$this->_view instanceof Wootook_Core_View) { + throw new Wootook_Core_Exception_RuntimeException(Wootook::__('No root view declared.')); + } + $scriptPath = $this->getScriptPath(); foreach ($this->_blocks as $block) { if ($block instanceof Wootook_Core_Block_Template) { @@ -407,8 +415,17 @@ class Wootook_Core_Layout return $path; } - trigger_error(Legacies::__("Layout file '%s' does not exist.", $file), E_USER_NOTICE); + trigger_error(Wootook::__("Layout file '%s' does not exist.", $file), E_USER_NOTICE); return null; } + + /** + * + * @return Wootook_Core_Block_Messages + */ + public function getMessagesblock() + { + return $this->_messageBlock; + } } \ No newline at end of file diff --git a/application/code/core/Wootook/Core/Model/Config/Abstract.php b/application/code/core/Wootook/Core/Model/Config/Abstract.php index ebebf65..ef946a8 100644 --- a/application/code/core/Wootook/Core/Model/Config/Abstract.php +++ b/application/code/core/Wootook/Core/Model/Config/Abstract.php @@ -8,6 +8,13 @@ abstract class Wootook_Core_Model_Config_Abstract { $config = Wootook::getConfig('global/storyline'); + if ($config === null || empty($config)) { + $config = array( + 'universe' => 'default', + 'episode' => 'default' + ); + } + $path = 'gamedata' . DIRECTORY_SEPARATOR . $config['universe'] . DIRECTORY_SEPARATOR . $config['episode'] . DIRECTORY_SEPARATOR . $filename . '.php'; diff --git a/application/code/core/Wootook/Core/Model/Session.php b/application/code/core/Wootook/Core/Model/Session.php index 5199542..62f0455 100644 --- a/application/code/core/Wootook/Core/Model/Session.php +++ b/application/code/core/Wootook/Core/Model/Session.php @@ -128,7 +128,7 @@ class Wootook_Core_Model_Session return $this->addMessage(vsprintf($message, $args), self::DEBUG); } - public function getFormKey($reset = false) + public function getFormKey($reset = true) { if (!$this->getData('form_key')) { $this->setData('form_key', uniqid()); @@ -136,10 +136,32 @@ class Wootook_Core_Model_Session } $key = $this->getData('form_key'); - if ($reset == true) { + if ($reset !== true) { $this->setData('form_key', uniqid()); } return $key; } + + public function setFormData(Array $data = array()) + { + if (isset($data['__formkey'])) { + unset($data['__formkey']); + } + + $this->setData('form_data', $data); + + return $this; + } + + public function getFormData($key = null, $default = null) + { + $data = $this->getData('form_data'); + if ($key === null) { + return $data; + } else if (isset($data[$key])) { + return $data[$key]; + } + return $default; + } } \ No newline at end of file diff --git a/application/code/core/Wootook/Core/Plugin/LoaderAbstract.php b/application/code/core/Wootook/Core/Plugin/LoaderAbstract.php index 211f572..37b4da1 100644 --- a/application/code/core/Wootook/Core/Plugin/LoaderAbstract.php +++ b/application/code/core/Wootook/Core/Plugin/LoaderAbstract.php @@ -15,7 +15,7 @@ abstract class Wootook_Core_Plugin_LoaderAbstract $className = $namespace . ucfirst($pluginName); $fileName = $path . DIRECTORY_SEPARATOR . ucfirst($pluginName) . '.php'; - if (!file_exists($fileName)) { + if (!Wootook::fileExists($fileName)) { continue; } @@ -26,7 +26,7 @@ abstract class Wootook_Core_Plugin_LoaderAbstract return $this->_load($className, $useSingleton); } - return $this; + return null; } public function registerNamespace($namespace, $path = null) @@ -48,7 +48,7 @@ abstract class Wootook_Core_Plugin_LoaderAbstract return $this; } - abstract protected function _load($className); + abstract protected function _load($className, $useSingleton); public function getPlugin($pluginName) { diff --git a/application/code/core/Wootook/Core/Time.php b/application/code/core/Wootook/Core/Time.php index 069867c..62b9952 100644 --- a/application/code/core/Wootook/Core/Time.php +++ b/application/code/core/Wootook/Core/Time.php @@ -3,10 +3,14 @@ class Wootook_Core_Time { - public static function init() + public static function init($timezone = null) { - $config = include ROOT_PATH . 'config.php'; - $timezone = $config['global']['date']['timezone']; + if ($timezone === null) { + $timezone = Wootook::getConfig('global/date/timezone'); + } + if ($timezone === null) { + $timezone = 'GMT'; + } date_default_timezone_set($timezone); } diff --git a/application/code/core/Wootook/Core/View.php b/application/code/core/Wootook/Core/View.php index e7b0cc6..1c75663 100644 --- a/application/code/core/Wootook/Core/View.php +++ b/application/code/core/Wootook/Core/View.php @@ -142,7 +142,16 @@ class Wootook_Core_View $theme = Wootook_Core_Layout::DEFAULT_THEME; } - return Wootook::getSkinUrl($package, $theme, $uri, $params); + $pattern = ROOT_PATH . DIRECTORY_SEPARATOR . 'skin/%s/%s/{$uri}'; + + if (Wootook::fileExists(sprintf($pattern, $package, $theme))) { + return Wootook::getSkinUrl($package, $theme, $uri, $params); + } + if (Wootook::fileExists(sprintf($pattern, $package, Wootook_Core_Layout::DEFAULT_THEME))) { + return Wootook::getSkinUrl($package, Wootook_Core_Layout::DEFAULT_THEME, $uri, $params); + } + + return Wootook::getSkinUrl(Wootook_Core_Layout::DEFAULT_PACKAGE, Wootook_Core_Layout::DEFAULT_THEME, $uri, $params); } public function setPartial($name, $content) diff --git a/application/code/core/Wootook/Empire/Model/Planet.php b/application/code/core/Wootook/Empire/Model/Planet.php index c013667..7cf15bb 100644 --- a/application/code/core/Wootook/Empire/Model/Planet.php +++ b/application/code/core/Wootook/Empire/Model/Planet.php @@ -26,6 +26,11 @@ class Wootook_Empire_Model_Planet */ protected $_moon = null; + /** + * @var Wootook_Empire_Model_Planet + */ + protected $_planet = null; + /** * @var Wootook_Empire_Model_Planet_Builder */ @@ -175,10 +180,14 @@ class Wootook_Empire_Model_Planet public function getGalaxyData() { - $entity = new Wootook_Empire_Model_Galaxy_Position(); - $entity->load(array('id_planet' => $this->getId())); + if ($this->isPlanet()) { + $entity = new Wootook_Empire_Model_Galaxy_Position(); + $entity->load(array('id_planet' => $this->getId())); - return $entity; + return $entity; + } + + return $this->getPlanet()->getGalaxyData(); } public function updateStorages($time = null) @@ -533,10 +542,62 @@ class Wootook_Empire_Model_Planet )); $this->_moon = $statement->current(); + + if ($this->_moon !== null && $this->_moon instanceof self) { + $this->_moon->setPlanet($this); + } } return $this->_moon; } + public function setMoon(Wootook_Empire_Model_Planet $moon) + { + $this->_moon = $moon; + + return $this; + } + + public function getPlanet() + { + static $statement = null; + + if ($this->isPlanet()) { + return null; + } + + if ($this->_planet === null) { + if ($statement === null) { + $statement = new Wootook_Core_Collection(array('planet' => 'planets'), get_class($this)); + $statement + ->where('galaxy=:galaxy') + ->where('system=:system') + ->where('planet=:position') + ->where('planet_type=' . strval(self::TYPE_PLANET)) + ; + } + + $statement->load(array( + 'galaxy' => $this->getGalaxy(), + 'system' => $this->getSystem(), + 'position' => $this->getPosition() + )); + + $this->_planet = $statement->current(); + + if ($this->_planet !== null && $this->_planet instanceof self) { + $this->_planet->setMoon($this); + } + } + return $this->_planet; + } + + public function setPlanet(Wootook_Empire_Model_Planet $planet) + { + $this->_planet = $planet; + + return $this; + } + public function setGalaxy($galaxy) { $this->setData('galaxy', $galaxy); diff --git a/application/code/core/Wootook/Empire/Model/User.php b/application/code/core/Wootook/Empire/Model/User.php index f96fd60..b7bb9e8 100644 --- a/application/code/core/Wootook/Empire/Model/User.php +++ b/application/code/core/Wootook/Empire/Model/User.php @@ -555,6 +555,10 @@ class Wootook_Empire_Model_User $layout = $eventData['layout']; $navigation = $layout->getBlock('navigation'); - $navigation->addLink('tools/admin', 'Admin Panel', 'Admin Panel', 'admin/index.php', array(), array('admin')); + if (!defined('IN_ADMIN')) { + $navigation->addLink('tools/admin', 'Admin Panel', 'Admin Panel', 'admin/overview.php', array(), array('admin')); + } else { + $navigation->addLink('tools/back', 'Go back to the game', 'Go back to the game', 'overview.php', array(), array('admin')); + } } } \ No newline at end of file diff --git a/application/design/base/default/layouts/admin.php b/application/design/base/default/layouts/admin.php new file mode 100644 index 0000000..9e6ebdd --- /dev/null +++ b/application/design/base/default/layouts/admin.php @@ -0,0 +1,243 @@ + array( + 'update' => '1column', + 'reference' => array( + 'content' => array( + 'children' => array( + 'navigation' => array( + 'type' => 'core/html.navigation', + 'template' => 'page/html/navigation.phtml', + 'actions' => array( + array( + 'method' => 'setNodeTitle', + 'params' => array( + 'path' => 'system', + 'title' => 'System' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'system/overview', + 'label' => 'Overview', + 'title' => 'Overview', + 'uri' => 'admin/overview.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'system/settings', + 'label' => 'Settings', + 'title' => 'Settings', + 'uri' => 'admin/settings.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'system/reset-universe', + 'label' => 'Reset Universe', + 'title' => 'Reset Universe', + 'uri' => 'admin/XNovaResetUnivers.php' + ) + ), + array( + 'method' => 'setNodeTitle', + 'params' => array( + 'path' => 'players', + 'title' => 'Player Accounts' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'players/list', + 'label' => 'List', + 'title' => 'List', + 'uri' => 'admin/userlist.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'players/password-recovery', + 'label' => 'Change a password', + 'title' => 'Change a password', + 'uri' => 'admin/md5changepass.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'players/search', + 'label' => 'Search', + 'title' => 'Search', + 'uri' => 'admin/paneladmina.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'players/multi-account-alerts', + 'label' => 'Multi account alerts', + 'title' => 'Multi account alerts', + 'uri' => 'admin/multi.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'players/declared-multi-account', + 'label' => 'Declared multi accounts', + 'title' => 'Declared multi accounts', + 'uri' => 'admin/declare_list.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'players/add-resources', + 'label' => 'Add Resources', + 'title' => 'Add Resources', + 'uri' => 'admin/add_money.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'players/messages', + 'label' => 'Private messages management', + 'title' => 'Private messages management', + 'uri' => 'admin/messagelist.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'players/chat', + 'label' => 'Manage Chat', + 'title' => 'Manage Chat', + 'uri' => 'chat.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'players/ban', + 'label' => 'Ban Player', + 'title' => 'Ban Player', + 'uri' => 'admin/banned.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'players/unban', + 'label' => 'Unban Player', + 'title' => 'Unban Player', + 'uri' => 'admin/unbanned.php' + ) + ), + array( + 'method' => 'setNodeTitle', + 'params' => array( + 'path' => 'empire', + 'title' => 'Empires' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'empire/planet-list', + 'label' => 'Planet List', + 'title' => 'Planet List', + 'uri' => 'admin/planetlist.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'empire/moon-list', + 'label' => 'Moon List', + 'title' => 'Moon List', + 'uri' => 'admin/moonlist.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'empire/add-moon', + 'label' => 'Add a moon', + 'title' => 'Add a moon', + 'uri' => 'admin/add_moon.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'empire/planet-activity', + 'label' => 'Planet Activity', + 'title' => 'Planet Activity', + 'uri' => 'admin/activeplanet.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'empire/fleet-list', + 'label' => 'Fleet list', + 'title' => 'Fleet list', + 'uri' => 'admin/ShowFlyingFleets.php' + ) + ), + array( + 'method' => 'setNodeTitle', + 'params' => array( + 'path' => 'tools', + 'title' => 'Tools' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'tools/phpinfo', + 'label' => 'PHP Info', + 'title' => 'PHP Info', + 'uri' => 'variables.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'tools/stats', + 'label' => 'Stats updater', + 'title' => 'Stats updater', + 'uri' => 'statbuilder.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'tools/errors', + 'label' => 'Error reporting', + 'title' => 'Error reporting', + 'uri' => 'errors.php' + ) + ), + array( + 'method' => 'addExternalLink', + 'params' => array( + 'name' => 'tools/help', + 'label' => 'Need help?', + 'title' => 'Need help?', + 'url' => 'http://wootook.org/board/' + ) + ) + ) + ) + ) + ) + ) + ) + ); diff --git a/application/design/base/default/layouts/empire.php b/application/design/base/default/layouts/empire.php index 6c8391a..e6f34d2 100644 --- a/application/design/base/default/layouts/empire.php +++ b/application/design/base/default/layouts/empire.php @@ -2,287 +2,293 @@ 'empire' => array( 'update' => '1column', 'reference' => array( - 'navigation' => array( - 'actions' => array( - array( - 'method' => 'setNodeTitle', - 'params' => array( - 'path' => 'development', - 'title' => 'Development' - ) - ), - array( - 'method' => 'addLink', - 'params' => array( - 'name' => 'development/overview', - 'label' => 'Overview', - 'title' => 'Overview', - 'uri' => 'overview.php' - ) - ), - array( - 'method' => 'addLink', - 'params' => array( - 'name' => 'development/buildings', - 'label' => 'Buildings', - 'title' => 'Buildings', - 'uri' => 'buildings.php' - ) - ), - array( - 'method' => 'addLink', - 'params' => array( - 'name' => 'development/research-lab', - 'label' => 'Research Lab', - 'title' => 'Research Lab', - 'uri' => 'buildings.php', - 'params' => array( - 'mode' => 'research' + 'content' => array( + 'children' => array( + 'navigation' => array( + 'type' => 'core/html.navigation', + 'template' => 'page/html/navigation.phtml', + 'actions' => array( + array( + 'method' => 'setNodeTitle', + 'params' => array( + 'path' => 'development', + 'title' => 'Development' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'development/overview', + 'label' => 'Overview', + 'title' => 'Overview', + 'uri' => 'overview.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'development/buildings', + 'label' => 'Buildings', + 'title' => 'Buildings', + 'uri' => 'buildings.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'development/research-lab', + 'label' => 'Research Lab', + 'title' => 'Research Lab', + 'uri' => 'buildings.php', + 'params' => array( + 'mode' => 'research' + ) + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'development/shipyard', + 'label' => 'Shipyard', + 'title' => 'Shipyard', + 'uri' => 'buildings.php', + 'params' => array( + 'mode' => 'fleet' + ) + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'development/defenses', + 'label' => 'Defenses', + 'title' => 'Defenses', + 'uri' => 'buildings.php', + 'params' => array( + 'mode' => 'defense' + ) + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'development/officers', + 'label' => 'Officers', + 'title' => 'Officers', + 'uri' => 'officier.php' + ) + ), + array( + 'method' => 'setNodeTitle', + 'params' => array( + 'path' => 'navigation', + 'title' => 'Navigation' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'navigation/alliance', + 'label' => 'Alliance', + 'title' => 'Alliance', + 'uri' => 'alliance.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'navigation/fleet', + 'label' => 'Fleet', + 'title' => 'Fleet', + 'uri' => 'fleet.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'navigation/galaxy', + 'label' => 'Galaxy', + 'title' => 'Galaxy', + 'uri' => 'galaxy.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'navigation/empire', + 'label' => 'Empire', + 'title' => 'Empire', + 'uri' => 'imperium.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'navigation/resources', + 'label' => 'Resources Production', + 'title' => 'Resources Production', + 'uri' => 'resources.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'development/retailer', + 'label' => 'Retailer', + 'title' => 'Retailer', + 'uri' => 'marchand.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'navigation/tech-tree', + 'label' => 'Technology Tree', + 'title' => 'Technology Tree', + 'uri' => 'techtree.php' + ) + ), + array( + 'method' => 'setNodeTitle', + 'params' => array( + 'path' => 'tools', + 'title' => 'Tools' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'tools/messages', + 'label' => 'Messages', + 'title' => 'Messages', + 'uri' => 'messages.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'tools/records', + 'label' => 'Records', + 'title' => 'Records', + 'uri' => 'records.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'tools/statistics', + 'label' => 'Stats', + 'title' => 'Stats', + 'uri' => 'stat.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'tools/banned', + 'label' => 'Banned Players', + 'title' => 'Banned Players', + 'uri' => 'banned.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'tools/announcement', + 'label' => 'Announcements', + 'title' => 'Announcements', + 'uri' => 'annonce.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'tools/notes', + 'label' => 'Note Pad', + 'title' => 'Note Pad', + 'uri' => 'notes.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'tools/options', + 'label' => 'Account Options', + 'title' => 'Account Options', + 'uri' => 'options.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'tools/logout', + 'label' => 'Log Out', + 'title' => 'Log Out', + 'uri' => 'logout.php' + ) + ), + array( + 'method' => 'setNodeTitle', + 'params' => array( + 'path' => 'community', + 'title' => 'Community' + ) + ), + array( + 'method' => 'addExternalLink', + 'params' => array( + 'name' => 'community/board', + 'label' => 'Forum board', + 'title' => 'Forum board', + 'url' => 'http://www.wootook.org/' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'community/search-player', + 'label' => 'Search Player', + 'title' => 'Search Player', + 'uri' => 'search.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'community/chat', + 'label' => 'Chat', + 'title' => 'Chat', + 'uri' => 'chat.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'community/multi', + 'label' => 'Declare Multi-account', + 'title' => 'Declare Multi-account', + 'uri' => 'delclare_multi.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'community/rules', + 'label' => 'Rules', + 'title' => 'Rules', + 'uri' => 'rules.php' + ) + ), + array( + 'method' => 'addLink', + 'params' => array( + 'name' => 'community/contact', + 'label' => 'Contact Admin', + 'title' => 'Contact Admin', + 'uri' => 'contact.php' + ) ) ) - ), - array( - 'method' => 'addLink', - 'params' => array( - 'name' => 'development/shipyard', - 'label' => 'Shipyard', - 'title' => 'Shipyard', - 'uri' => 'buildings.php', - 'params' => array( - 'mode' => 'fleet' - ) - ) - ), - array( - 'method' => 'addLink', - 'params' => array( - 'name' => 'development/defenses', - 'label' => 'Defenses', - 'title' => 'Defenses', - 'uri' => 'buildings.php', - 'params' => array( - 'mode' => 'defense' - ) - ) - ), - array( - 'method' => 'addLink', - 'params' => array( - 'name' => 'development/officers', - 'label' => 'Officers', - 'title' => 'Officers', - 'uri' => 'officers.php' - ) - ), - array( - 'method' => 'setNodeTitle', - 'params' => array( - 'path' => 'navigation', - 'title' => 'Navigation' - ) - ), - array( - 'method' => 'addLink', - 'params' => array( - 'name' => 'navigation/alliance', - 'label' => 'Alliance', - 'title' => 'Alliance', - 'uri' => 'alliance.php' - ) - ), - array( - 'method' => 'addLink', - 'params' => array( - 'name' => 'navigation/fleet', - 'label' => 'Fleet', - 'title' => 'Fleet', - 'uri' => 'fleet.php' - ) - ), - array( - 'method' => 'addLink', - 'params' => array( - 'name' => 'navigation/galaxy', - 'label' => 'Galaxy', - 'title' => 'Galaxy', - 'uri' => 'galaxy.php' - ) - ), - array( - 'method' => 'addLink', - 'params' => array( - 'name' => 'navigation/empire', - 'label' => 'Empire', - 'title' => 'Empire', - 'uri' => 'imperium.php' - ) - ), - array( - 'method' => 'addLink', - 'params' => array( - 'name' => 'navigation/resources', - 'label' => 'Resources Production', - 'title' => 'Resources Production', - 'uri' => 'resources.php' - ) - ), - array( - 'method' => 'addLink', - 'params' => array( - 'name' => 'development/retailer', - 'label' => 'Retailer', - 'title' => 'Retailer', - 'uri' => 'marchand.php' - ) - ), - array( - 'method' => 'addLink', - 'params' => array( - 'name' => 'navigation/tech-tree', - 'label' => 'Technology Tree', - 'title' => 'Technology Tree', - 'uri' => 'techtree.php' - ) - ), - array( - 'method' => 'setNodeTitle', - 'params' => array( - 'path' => 'tools', - 'title' => 'Tools' - ) - ), - array( - 'method' => 'addLink', - 'params' => array( - 'name' => 'tools/messages', - 'label' => 'Messages', - 'title' => 'Messages', - 'uri' => 'messages.php' - ) - ), - array( - 'method' => 'addLink', - 'params' => array( - 'name' => 'tools/records', - 'label' => 'Records', - 'title' => 'Records', - 'uri' => 'records.php' - ) - ), - array( - 'method' => 'addLink', - 'params' => array( - 'name' => 'tools/statistics', - 'label' => 'Stats', - 'title' => 'Stats', - 'uri' => 'stat.php' - ) - ), - array( - 'method' => 'addLink', - 'params' => array( - 'name' => 'tools/banned', - 'label' => 'Banned Players', - 'title' => 'Banned Players', - 'uri' => 'banned.php' - ) - ), - array( - 'method' => 'addLink', - 'params' => array( - 'name' => 'tools/announcement', - 'label' => 'Announcements', - 'title' => 'Announcements', - 'uri' => 'annonce.php' - ) - ), - array( - 'method' => 'addLink', - 'params' => array( - 'name' => 'tools/notes', - 'label' => 'Note Pad', - 'title' => 'Note Pad', - 'uri' => 'notes.php' - ) - ), - array( - 'method' => 'addLink', - 'params' => array( - 'name' => 'tools/options', - 'label' => 'Account Options', - 'title' => 'Account Options', - 'uri' => 'options.php' - ) - ), - array( - 'method' => 'addLink', - 'params' => array( - 'name' => 'tools/logout', - 'label' => 'Log Out', - 'title' => 'Log Out', - 'uri' => 'logout.php' - ) - ), - array( - 'method' => 'setNodeTitle', - 'params' => array( - 'path' => 'community', - 'title' => 'Community' - ) - ), - array( - 'method' => 'addExternalLink', - 'params' => array( - 'name' => 'community/board', - 'label' => 'Forum board', - 'title' => 'Forum board', - 'url' => 'http://www.wootook.org/' - ) - ), - array( - 'method' => 'addLink', - 'params' => array( - 'name' => 'community/search-player', - 'label' => 'Search Player', - 'title' => 'Search Player', - 'uri' => 'search.php' - ) - ), - array( - 'method' => 'addLink', - 'params' => array( - 'name' => 'community/chat', - 'label' => 'Chat', - 'title' => 'Chat', - 'uri' => 'chat.php' - ) - ), - array( - 'method' => 'addLink', - 'params' => array( - 'name' => 'community/multi', - 'label' => 'Declare Multi-account', - 'title' => 'Declare Multi-account', - 'uri' => 'delclare_multi.php' - ) - ), - array( - 'method' => 'addLink', - 'params' => array( - 'name' => 'community/rules', - 'label' => 'Rules', - 'title' => 'Rules', - 'uri' => 'rules.php' - ) - ), - array( - 'method' => 'addLink', - 'params' => array( - 'name' => 'community/contact', - 'label' => 'Contact Admin', - 'title' => 'Contact Admin', - 'uri' => 'contact.php' - ) ) ) ) diff --git a/application/design/base/default/layouts/page.php b/application/design/base/default/layouts/page.php index 32b0013..9f0a95d 100644 --- a/application/design/base/default/layouts/page.php +++ b/application/design/base/default/layouts/page.php @@ -1,16 +1,6 @@ array( - 'update' => 'default', - 'reference' => array( - 'content' => array( - 'children' => array( - 'navigation' => array( - 'type' => 'core/html.navigation', - 'template' => 'page/html/navigation.phtml' - ) - ) - ) - ) + 'update' => 'default' ), '2columns-left' => array( @@ -20,13 +10,7 @@ 'root' => array( 'children' => array( 'left' => array( - 'type' => 'core/concat', - 'children' => array( - 'navigation' => array( - 'type' => 'core/html.navigation', - 'template' => 'page/html/navigation.phtml' - ) - ) + 'type' => 'core/concat' ) ) ) diff --git a/application/design/base/default/scripts/empire/overview/form/rename-planet.phtml b/application/design/base/default/scripts/empire/overview/form/rename-planet.phtml index 45ba7da..94f0148 100644 --- a/application/design/base/default/scripts/empire/overview/form/rename-planet.phtml +++ b/application/design/base/default/scripts/empire/overview/form/rename-planet.phtml @@ -1,10 +1,16 @@ -
+
- - - - - +

+ + +

+

+ + +

+

+ +

\ No newline at end of file diff --git a/application/design/base/default/scripts/user/registration.phtml b/application/design/base/default/scripts/user/registration.phtml index 50b9876..f141946 100644 --- a/application/design/base/default/scripts/user/registration.phtml +++ b/application/design/base/default/scripts/user/registration.phtml @@ -1,4 +1,4 @@ -
+

Wootook!

__('User data:')?> diff --git a/application/design/install/default/layouts/install.php b/application/design/install/default/layouts/install.php new file mode 100644 index 0000000..68db3c0 --- /dev/null +++ b/application/design/install/default/layouts/install.php @@ -0,0 +1,84 @@ + array( + 'update' => '2columns-left', + 'reference' => array( + 'messages' => array( + 'actions' => array( + array( + 'method' => 'prepareMessages', + 'params' => array( + 'namespace' => 'install' + ) + ) + ) + ), + 'content' => array( + 'children' => array( + 'navigation' => array( + 'type' => 'core/html.navigation', + 'template' => 'page/html/navigation.phtml', + 'actions' => array() + ) + ) + ), + 'left' => array( + 'children' => array( + 'status' => array( + 'type' => 'core/template', + 'template' => 'status.phtml' + ) + ) + ) + ) + ), + + 'install.intro' => array( + 'update' => 'install', + 'reference' => array( + 'content' => array( + 'children' => array( + 'overview' => array( + 'type' => 'core/template', + 'template' => 'intro.phtml' + ), + ) + ), + 'status' => array( + 'actions' => array( + array( + 'method' => 'setData', + 'params' => array( + 'key' => 'step', + 'value' => 'intro' + ) + ) + ) + ) + ) + ), + + 'install.step.system' => array( + 'update' => 'install', + 'reference' => array( + 'content' => array( + 'children' => array( + 'overview' => array( + 'type' => 'core/template', + 'template' => 'step/system.phtml' + ), + ) + ), + 'status' => array( + 'actions' => array( + array( + 'method' => 'setData', + 'params' => array( + 'key' => 'step', + 'value' => 'system' + ) + ) + ) + ) + ) + ) + ); diff --git a/application/design/install/default/scripts/deprecated/install/ins_acc.tpl b/application/design/install/default/scripts/deprecated/install/ins_acc.tpl new file mode 100644 index 0000000..990f8db --- /dev/null +++ b/application/design/install/default/scripts/deprecated/install/ins_acc.tpl @@ -0,0 +1,44 @@ + + +
getData('ins_tx_acc1')?>
+getData('ins_tx_acc2')?>

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

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

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

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

getData('ins_tx_done1')?>

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

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

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

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

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

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

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

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

+

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

+

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

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

+

__('System Config')?>

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

+ + +

+

+
+
\ No newline at end of file diff --git a/application/gamedata/default/default/combat.php b/application/gamedata/default/default/combat.php new file mode 100644 index 0000000..8d931c7 --- /dev/null +++ b/application/gamedata/default/default/combat.php @@ -0,0 +1 @@ + array( + 'core' => array('Wootook_Core_Block_' => 'Wootook/Core/Block'), + 'empire' => array('Wootook_Empire_Block_' => 'Wootook/Empire/Block') + ) + ); \ No newline at end of file diff --git a/application/gamedata/default/default/prices.php b/application/gamedata/default/default/prices.php new file mode 100644 index 0000000..dfd324f --- /dev/null +++ b/application/gamedata/default/default/prices.php @@ -0,0 +1,2 @@ + $listenerList) { - foreach ($listenerList as $listener) { - Wootook::registerListener($event, $listener); - } -} +Wootook_Core_Model_Config_Events::registerEvents(); include ROOT_PATH . 'includes/constants.php'; \ No newline at end of file diff --git a/buildings.php b/buildings.php index 46a4665..2546076 100644 --- a/buildings.php +++ b/buildings.php @@ -62,6 +62,11 @@ case 'fleet': $shipyard->appendQueue($shipId, $count); } $planet->save(); + + Wootook::getResponse() + ->setRedirect(Wootook::getUrl('buildings.php', array('mode' => $mode))) + ->sendHeaders(); + exit(0); } $layout = new Wootook_Core_Layout(); @@ -87,9 +92,19 @@ case 'research': $data = $planet->getAllDatas(); $planet->appendBuildingQueue(intval($_GET['research']), isset($_GET['destroy'])); $planet->save(); + + Wootook::getResponse() + ->setRedirect(Wootook::getUrl('buildings.php', array('mode' => $mode))) + ->sendHeaders(); + exit(0); } else if (isset($_GET['cancel']) && !empty($_GET['cancel'])) { $planet->dequeueItem($_GET['cancel']); $planet->save(); + + Wootook::getResponse() + ->setRedirect(Wootook::getUrl('buildings.php', array('mode' => $mode))) + ->sendHeaders(); + exit(0); } $layout = new Wootook_Core_Layout(); @@ -121,6 +136,11 @@ case 'defense': $shipyard->appendQueue($defenseId, $count); } $planet->save(); + + Wootook::getResponse() + ->setRedirect(Wootook::getUrl('buildings.php', array('mode' => $mode))) + ->sendHeaders(); + exit(0); } $layout = new Wootook_Core_Layout(); @@ -138,9 +158,19 @@ default: $data = $planet->getAllDatas(); $planet->appendBuildingQueue(intval($_GET['building']), isset($_GET['destroy'])); $planet->save(); + + Wootook::getResponse() + ->setRedirect(Wootook::getUrl('buildings.php', array('mode' => $mode))) + ->sendHeaders(); + exit(0); } else if (isset($_GET['cancel']) && !empty($_GET['cancel'])) { $planet->dequeueItem($_GET['cancel']); $planet->save(); + + Wootook::getResponse() + ->setRedirect(Wootook::getUrl('buildings.php', array('mode' => $mode))) + ->sendHeaders(); + exit(0); } $layout = new Wootook_Core_Layout(); diff --git a/config.php.default b/config.php.default index fcc1572..8f80dd0 100644 --- a/config.php.default +++ b/config.php.default @@ -22,6 +22,7 @@ ), 'layout' => array( 'page' => 'page.php', + 'admin' => 'admin.php', 'empire' => 'empire.php' ), 'locales' => array( diff --git a/fleetshortcut.php b/fleetshortcut.php index 538c8ae..73e5325 100644 --- a/fleetshortcut.php +++ b/fleetshortcut.php @@ -33,131 +33,174 @@ define('INSTALL' , false); require_once dirname(__FILE__) .'/application/bootstrap.php'; -$mode = $_GET['mode']; -$a = $_GET['a']; -/* - Este script es original xD - La funcion de este script es administrar una variable del $user - Permite agregar y quitar arrays... -*/ -//Lets start! -if(isset($_GET['mode'])){ - if($_POST){ - //Pegamos el texto :P - if($_POST["n"] == ""){$_POST["n"] = "Unbenannt";} +$mode = isset($_GET['mode']) ? $_GET['mode'] : null; +$a = isset($_GET['a']) ? $_GET['a'] : null; - $r = strip_tags($_POST[n]).",".intval($_POST[g]).",".intval($_POST[s]).",".intval($_POST[p]).",".intval($_POST[t])."\r\n"; - $user['fleet_shortcut'] .= $r; - doquery("UPDATE {{table}} SET fleet_shortcut='{$user[fleet_shortcut]}' WHERE id={$user[id]}","users"); - message("Le raccourcis a été enregistré !","Enregistrment","fleetshortcut.php"); - } - $page = "
- - - - "; - $page .= '
Nom [Galaxie/Système solaire/Planète]
- - - - - -
"; - //Muestra un (L) si el destino pertenece a luna, lo mismo para escombros - $page .= "
Effacer
'; -} -elseif(isset($_GET['a'])){ - if($_POST){ - //Armamos el array... - $scarray = explode("\r\n",$user['fleet_shortcut']); - if($_POST["delete"]){ - unset($scarray[$a]); - $user['fleet_shortcut'] = implode("\r\n",$scarray); - doquery("UPDATE {{table}} SET fleet_shortcut='{$user[fleet_shortcut]}' WHERE id={$user[id]}","users"); - message("Shortcut wurde gelöscht","Gelöscht","fleetshortcut.php"); - } - else{ - $r = explode(",",$scarray[$a]); - $r[0] = strip_tags($_POST['n']); - $r[1] = intval($_POST['g']); - $r[2] = intval($_POST['s']); - $r[3] = intval($_POST['p']); - $r[4] = intval($_POST['t']); - $scarray[$a] = implode(",",$r); - $user['fleet_shortcut'] = implode("\r\n",$scarray); - doquery("UPDATE {{table}} SET fleet_shortcut='{$user[fleet_shortcut]}' WHERE id={$user[id]}","users"); - message("Le raccourcis a été édité !.","Editer","fleetshortcut.php"); - } - } - if($user['fleet_shortcut']){ +$user = Wootook_Empire_Model_User::getSingleton(); - $scarray = explode("\r\n",$user['fleet_shortcut']); - $c = explode(',',$scarray[$a]); +if ($mode) { + if ($_POST) { + //Pegamos el texto :P + if (!isset($_POST["n"]) || empty($_POST["n"])) { + $name = Wootook::__("Unnamed"); + } else { + $name = $_POST["n"]; + } - $page = "
- - - "; - //if($i==0){$page .= "";} - $page .= " - "; + if (($offset = strpos($name, "\n")) !== false) { + $name = substr($name, 0, $offset); + } + if (($offset = strpos($name, "\r")) !== false) { + $name = substr($name, 0, $offset); + } + if (($offset = strpos($name, ",")) !== false) { + $name = substr($name, 0, $offset); + } + $planetTypes = array( + Wootook_Empire_Model_Planet::TYPE_PLANET, + Wootook_Empire_Model_Planet::TYPE_DEBRIS, + Wootook_Empire_Model_Planet::TYPE_MOON + ); - }else{$page .= message("Le raccourcis a été enregistré !","Enregistrer","fleetshortcut.php");} + $r = array(); + $r[0] = preg_replace('#[^[:alnum:]\s\-\_\']#', '', $name); + $r[1] = (isset($_POST['g']) && intval($_POST['g']) > 0 && intval($_POST['g']) <= MAX_GALAXY_IN_WORLD) ? intval($_POST['g']) : '1'; + $r[2] = (isset($_POST['s']) && intval($_POST['s']) > 0 && intval($_POST['s']) <= MAX_SYSTEM_IN_GALAXY) ? intval($_POST['s']) : '1'; + $r[3] = (isset($_POST['p']) && intval($_POST['p']) > 0 && intval($_POST['p']) <= MAX_PLANET_IN_SYSTEM) ? intval($_POST['p']) : '1'; + $r[4] = (isset($_POST['t']) && intval($_POST['t']) > 0 && in_array(intval($_POST['t']), $planetTypes)) ? intval($_POST['t']) : '1'; - $page .= '
Editer: {$c[0]} [{$c[1]}:{$c[2]}:{$c[3]}]
- - - - - - -
"; - $page .= "
Retour
'; + $user['fleet_shortcut'] .= implode(",", $r); + $user->save(); + message(Wootook::__("The shortcut has been saved."), Wootook::__("Success"), "fleetshortcut.php"); + } + $page = "
+ + + + "; + $page .= '
Nom [Galaxie/Système solaire/Planète]
+ + + + + +
"; + //Muestra un (L) si el destino pertenece a luna, lo mismo para escombros + $page .= "
Effacer
'; +} else if ($a !== null) { + if ($_POST) { + //Armamos el array... + $scarray = explode("\r\n", $user['fleet_shortcut']); + if (isset($_POST["delete"])) { + unset($scarray[$a]); + $user['fleet_shortcut'] = implode("\r\n", $scarray); + doquery("UPDATE {{table}} SET fleet_shortcut={$db->quote($user['fleet_shortcut'])} WHERE id={$user['id']}", "users"); + message(Wootook::__("The shortcut has been deleted"), Wootook::__("Success"), "fleetshortcut.php"); + } else { + $r = explode(",", $scarray[$a]); + if (!isset($_POST["n"]) || empty($_POST["n"])) { + $name = $r[0]; + } else { + $name = $_POST["n"]; + } + + if (($offset = strpos($name, "\n")) !== false) { + $name = substr($name, 0, $offset); + } + if (($offset = strpos($name, "\r")) !== false) { + $name = substr($name, 0, $offset); + } + if (($offset = strpos($name, ",")) !== false) { + $name = substr($name, 0, $offset); + } + $planetTypes = array( + Wootook_Empire_Model_Planet::TYPE_PLANET, + Wootook_Empire_Model_Planet::TYPE_DEBRIS, + Wootook_Empire_Model_Planet::TYPE_MOON + ); + $r[0] = preg_replace('#[^[:alnum:]\s\-\_\']#', '', $name); + $r[1] = (isset($_POST['g']) && intval($_POST['g']) > 0 && intval($_POST['g']) <= MAX_GALAXY_IN_WORLD) ? intval($_POST['g']) : $r[1]; + $r[2] = (isset($_POST['s']) && intval($_POST['s']) > 0 && intval($_POST['s']) <= MAX_SYSTEM_IN_GALAXY) ? intval($_POST['s']) : $r[2]; + $r[3] = (isset($_POST['p']) && intval($_POST['p']) > 0 && intval($_POST['p']) <= MAX_PLANET_IN_SYSTEM) ? intval($_POST['p']) : $r[3]; + $r[4] = (isset($_POST['t']) && intval($_POST['t']) > 0 && in_array(intval($_POST['t']), $planetTypes)) ? intval($_POST['t']) : $r[4]; + + $scarray[$a] = implode(",", $r); + $user['fleet_shortcut'] = implode("\r\n", $scarray); + $user->save(); + message(Wootook::__("The shortcut has been updated."), Wootook::__("Success"), "fleetshortcut.php"); + } + } + + if ($user['fleet_shortcut']) { + + $scarray = explode("\r\n",$user['fleet_shortcut']); + $c = explode(',',$scarray[$a]); + + $page = "
+ + + "; + //if($i==0){$page .= "";} + $page .= " + "; + + } else { + $page .= message("Le raccourcis a été enregistré !","Enregistrer","fleetshortcut.php"); + } + + $page .= '
Editer: {$c[0]} [{$c[1]}:{$c[2]}:{$c[3]}]
+ + + + + + +
"; + $page .= "
Retour
'; -} -else{ +} else { - $page = ' - - - '; + $page = '
Raccourcis(Ajout)
+ + + '; - if($user['fleet_shortcut']){ - /* - Dentro de fleet_shortcut, se pueden almacenar las diferentes direcciones - de acceso directo, el formato es el siguiente. - Nombre, Galaxia,Sistema,Planeta,Tipo - */ - $scarray = explode("\r\n",$user['fleet_shortcut']); - $i=$e=0; - foreach($scarray as $a => $b){ - if($b!=""){ - $c = explode(',',$b); - if($i==0){$page .= "";} - $page .= ""; - if($i==1){$page .= "";} - if($i==1){$i=0;}else{$i=1;} - } + if($user['fleet_shortcut']){ + /* + Dentro de fleet_shortcut, se pueden almacenar las diferentes direcciones + de acceso directo, el formato es el siguiente. + Nombre, Galaxia,Sistema,Planeta,Tipo + */ + $scarray = explode("\r\n",$user['fleet_shortcut']); + $i=$e=0; + foreach($scarray as $a => $b){ + if($b!=""){ + $c = explode(',',$b); + if($i==0){$page .= "";} + $page .= ""; + if($i==1){$page .= "";} + if($i==1){$i=0;}else{$i=1;} + } - } - if($i==1){$page .= "";} + } + if($i==1){$page .= "";} - }else{$page .= "";} + }else{$page .= "";} - $page .= '
Raccourcis(Ajout)
"; - $page .= "{$c[0]} {$c[1]}:{$c[2]}:{$c[3]}"; - //Muestra un (L) si el destino pertenece a luna, lo mismo para escombros - if($c[4]==2){$page .= " (E)";}elseif($c[4]==3){$page .= " (L)";} - $page .= "
"; + $page .= "{$c[0]} {$c[1]}:{$c[2]}:{$c[3]}"; + //Muestra un (L) si el destino pertenece a luna, lo mismo para escombros + if($c[4]==2){$page .= " (E)";}elseif($c[4]==3){$page .= " (L)";} + $page .= "
Pas de RaccourcisPas de Raccourcis
Retour
'; + $page .= 'Retour'; } display($page,"Shortcutmanager"); diff --git a/includes/deprecated.php b/includes/deprecated.php index fee9fc1..e89017b 100644 --- a/includes/deprecated.php +++ b/includes/deprecated.php @@ -503,11 +503,15 @@ class Deprecated /** * @return Wootook_Core_Layout */ - public static function getLayout() + public static function getLayout($adminPage = false) { if (self::$layout === null) { self::$layout = new Wootook_Core_Layout(); - self::$layout->load('empire'); + + if (defined('IN_INSTALL')) { + self::$layout->setPackage('install'); + self::$layout->setTheme('default'); + } } return self::$layout; @@ -528,7 +532,13 @@ function display($page, $title = '', $topnav = true, $metatags = '', $adminPage defined('DEPRECATION') || trigger_error(sprintf('%s is deprecated', __FUNCTION__), E_USER_DEPRECATED); // TODO: implement extra meta tags - $layout = Deprecated::getLayout(); + $layout = Deprecated::getLayout($adminPage); + if ($adminPage === false) { + $layout->load('empire'); + } else { + $layout->load('admin'); + } + $content = $layout->getBlock('content'); if ($topnav) { diff --git a/includes/functions/GalaxyRowAlly.php b/includes/functions/GalaxyRowAlly.php index 816c2da..86cfa7b 100644 --- a/includes/functions/GalaxyRowAlly.php +++ b/includes/functions/GalaxyRowAlly.php @@ -63,17 +63,17 @@ function GalaxyRowAlly ( $GalaxyRow, $GalaxyRowPlanet, $GalaxyRowUser, $Galaxy, $Result .= " onmouseover='return overlib(\""; $Result .= ""; $Result .= ""; - $Result .= ""; + $Result .= ""; $Result .= ""; $Result .= "
".$lang['Alliance']." ". $allyquery['ally_name'] ." ".$lang['gl_with']." ". $members_count[0] ." ". $lang['gl_membre'] . $add ."".htmlspecialchars($lang['Alliance'], ENT_QUOTES, 'UTF-8')." ". htmlspecialchars($allyquery['ally_name'], ENT_QUOTES, 'UTF-8') ." ".$lang['gl_with']." ". $members_count[0] ." ". $lang['gl_membre'] . $add ."
"; $Result .= ""; $Result .= ""; - $Result .= ""; + $Result .= ""; $Result .= ""; $Result .= ""; if ($allyquery["ally_web"] != "") { $Result .= ""; - $Result .= ""; + $Result .= ""; } $Result .= ""; $Result .= "
".$lang['gl_ally_internal']."".$lang['gl_ally_internal']."
".$lang['gl_stats']."
".$lang['gl_ally_web']."".$lang['gl_ally_web']."
"; @@ -82,7 +82,7 @@ function GalaxyRowAlly ( $GalaxyRow, $GalaxyRowPlanet, $GalaxyRowUser, $Galaxy, $Result .= ", STICKY, MOUSEOFF, DELAY, 750, CENTER, OFFSETX, -40, OFFSETY, -40 );'"; $Result .= " onmouseout='return nd();'>"; if ($user['ally_id'] == $GalaxyRowUser['ally_id']) { - $Result .= "". $allyquery['ally_tag'] .""; + $Result .= "". htmlspecialchars($allyquery['ally_tag'], ENT_QUOTES, 'UTF-8') .""; } else { $Result .= $allyquery['ally_tag'] .""; } diff --git a/includes/todofleetcontrol.php b/includes/todofleetcontrol.php index dd842e4..1809389 100644 --- a/includes/todofleetcontrol.php +++ b/includes/todofleetcontrol.php @@ -48,25 +48,17 @@ include(ROOT_PATH . 'includes/functions/SendSimpleMessage.'.PHPEXT); include(ROOT_PATH . 'includes/functions/SpyTarget.'.PHPEXT); include(ROOT_PATH . 'includes/functions/RestoreFleetToPlanet.'.PHPEXT); include(ROOT_PATH . 'includes/functions/StoreGoodsToPlanet.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/CheckPlanetBuildingQueue.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/CheckPlanetUsedFields.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/CreateOneMoonRecord.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/CreateOnePlanetRecord.'.PHPEXT); +include(ROOT_PATH . 'includes/functions/CreateOneMoonRecord.'.PHPEXT); // <- TODO: delete +include(ROOT_PATH . 'includes/functions/CreateOnePlanetRecord.'.PHPEXT); // <- TODO: delete include(ROOT_PATH . 'includes/functions/InsertJavaScriptChronoApplet.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/IsTechnologieAccessible.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/GetBuildingTime.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/GetBuildingTimeLevel.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/GetRestPrice.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/GetElementPrice.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/GetBuildingPrice.'.PHPEXT); +include(ROOT_PATH . 'includes/functions/IsTechnologieAccessible.'.PHPEXT); // <- TODO: delete +include(ROOT_PATH . 'includes/functions/GetRestPrice.'.PHPEXT); // <- TODO: delete include(ROOT_PATH . 'includes/functions/IsElementBuyable.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/CheckCookies.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/ChekUser.'.PHPEXT); include(ROOT_PATH . 'includes/functions/InsertGalaxyScripts.'.PHPEXT); include(ROOT_PATH . 'includes/functions/GalaxyCheckFunctions.'.PHPEXT); include(ROOT_PATH . 'includes/functions/ShowGalaxyRows.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/GetPhalanxRange.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/GetMissileRange.'.PHPEXT); +include(ROOT_PATH . 'includes/functions/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); @@ -80,30 +72,8 @@ include(ROOT_PATH . 'includes/functions/ShowGalaxyMISelector.'.PHPEXT); include(ROOT_PATH . 'includes/functions/ShowGalaxyTitles.'.PHPEXT); include(ROOT_PATH . 'includes/functions/GalaxyLegendPopup.'.PHPEXT); include(ROOT_PATH . 'includes/functions/ShowGalaxyFooter.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/GetMaxConstructibleElements.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/GetElementRessources.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/ElementBuildListBox.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/ElementBuildListQueue.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/FleetBuildingPage.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/DefensesBuildingPage.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/ResearchBuildingPage.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/BatimentBuildingPage.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/CheckLabSettingsInQueue.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/InsertBuildListScript.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/AddBuildingToQueue.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/ShowBuildingQueue.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/HandleTechnologieBuild.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/BuildingSavePlanetRecord.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/BuildingSaveUserRecord.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/RemoveBuildingFromQueue.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/CancelBuildingFromQueue.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/SetNextQueueElementOnTop.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/ShowTopNavigationBar.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/SetSelectedPlanet.'.PHPEXT); include(ROOT_PATH . 'includes/functions/MessageForm.'.PHPEXT); -include(ROOT_PATH . 'includes/functions/BuildFlyingFleetTable.'.PHPEXT); include(ROOT_PATH . 'includes/functions/SendNewPassword.'.PHPEXT); -//include(ROOT_PATH . 'includes/functions/UpdatePlanetBatimentQueueList.'.PHPEXT); include(ROOT_PATH . 'includes/functions/IsOfficierAccessible.'.PHPEXT); include(ROOT_PATH . 'includes/functions/CheckInputStrings.'.PHPEXT); include(ROOT_PATH . 'includes/functions/MipCombatEngine.'.PHPEXT); diff --git a/install/index.php b/install/index.php index 52870b9..5f58b4a 100644 --- a/install/index.php +++ b/install/index.php @@ -32,44 +32,158 @@ define('INSIDE' , true); define('INSTALL', false); define('IN_INSTALL', true); -define('ROOT_PATH', dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR); -define('PHPEXT', include ROOT_PATH . 'extension.inc'); +define('STEP_SYSTEM', 1); +define('STEP_DATABASE', 2); +define('STEP_PROFILE', 3); +define('STEP_UNIVERSE', 4); +define('STEP_CONFIG', 5); -define('DEFAULT_SKINPATH', '../skins/xnova/'); -define('TEMPLATE_DIR', realpath(ROOT_PATH . '/templates/')); -define('TEMPLATE_NAME', 'OpenGame'); -define('DEFAULT_LANG', 'fr'); -$dpath = DEFAULT_SKINPATH; +require_once dirname(dirname(__FILE__)) .'/application/bootstrap.php'; -include(ROOT_PATH . 'includes/debug.class.'.PHPEXT); -$debug = new debug(); - -include(ROOT_PATH . 'includes/constants.' . PHPEXT); -include(ROOT_PATH . 'includes/functions.' . PHPEXT); -include(ROOT_PATH . 'includes/unlocalised.' . PHPEXT); -include(ROOT_PATH . 'includes/todofleetcontrol.' . PHPEXT); -include(ROOT_PATH . 'language/' . DEFAULT_LANG . '/lang_info.cfg'); -include(ROOT_PATH . 'includes/vars.' . PHPEXT); -include(ROOT_PATH . 'includes/db.' . PHPEXT); -include(ROOT_PATH . 'includes/strings.' . PHPEXT); - -include(ROOT_PATH . 'includes/databaseinfos.php'); -include(ROOT_PATH . 'includes/migrateinfo.php'); +//include(ROOT_PATH . 'includes/databaseinfos.php'); +//include(ROOT_PATH . 'includes/migrateinfo.php'); $mode = isset($_GET['mode']) ? strval($_GET['mode']) : 'intro'; -$page = isset($_GET['page']) ? intval($_GET['page']) : 1; -$nextPage = $page + 1; +$step = isset($_GET['step']) ? intval($_GET['step']) : 1; +$prevStep = $step - 1; +$nextStep = $step + 1; -$mainTpl = gettemplate('install/ins_body'); includeLang('install/install'); +$baseUrl = (isset($_SERVER["HTTPS"]) && strtolower($_SERVER["HTTPS"]) == "on" ? 'https://' : 'http://') + . $_SERVER["SERVER_NAME"] . ($_SERVER["SERVER_PORT"] != "80" ? ":{$_SERVER["SERVER_PORT"]}" : ''); +if (isset($_SERVER['REQUEST_URI'])) { + if (strrpos($_SERVER['REQUEST_URI'], '/') == (strlen($_SERVER['REQUEST_URI']) - 1)) { + $baseUrl .= dirname($_SERVER['REQUEST_URI']) . '/'; + } else { + $baseUrl .= dirname(dirname($_SERVER['REQUEST_URI'])) . '/'; + } +} +Wootook::setConfig('global/web/base_url', $baseUrl); + +Wootook::setConfig('global/package', 'install'); +Wootook::setConfig('global/theme', 'default'); +Wootook::setconfig('global/layout', array( + 'page' => 'page.php', + 'install' => 'install.php' + )); + +$session = Wootook::getSession('install'); +$layout = new Wootook_Core_Layout(); +$request = new Wootook_Core_Controller_Request_Http(); +$response = new Wootook_Core_Controller_Response_Http(); + switch ($mode) { - case 'intro': - $subTpl = gettemplate('install/ins_intro'); - $bloc = $lang; - $bloc['dpath'] = $dpath; - $frame = parsetemplate($subTpl, $bloc); - break; +case 'intro': + $layout->load('install.intro'); + $session->setData('step', 1); + break; + +case 'install': + $session->addError('Test %s', 'Hello world!'); + if ($step != $session->getData('step')) { + $session->setData('step', 0); + $response->setRedirect("?mode=intro", Wootook_Core_Controller_Response_Http::REDIRECT_TEMPORARY); + $response->sendHeaders(); + exit(0); + } + + switch ($step) { + case STEP_SYSTEM: + if ($request->isPost()) { + $form = new Wootook_Core_Form($session, array( + 'url_path' => 'text' + )); + $form->addField('url_path'); + $form->setRequest($request); + $form->populate(); + + if (!$form->validate()) { + $session->setData('step', $step); + $session->setFormData($form->getData()); + var_dump($session); + $response->setRedirect("?mode=install&step={$step}"); + $response->sendHeaders(); + exit(0); + } + + $layout->getMessagesblock()->prepareMessages('install'); + $session->setBaseUrl($request->getPost('url_path')); + + $session->setStep(STEP_DATABASE); + $response->setRedirect("?mode=install&step={$nextStep}"); + $response->sendHeaders(); + exit(0); + } + + $layout->load('install.step.system'); + break; + + case STEP_DATABASE: + if ($request->isPost()) { + $form = new Wootook_Core_Form($session, array( + 'host' => 'text', + 'port' => 'text', + 'user' => 'text', + 'password' => 'text', + 'dbname' => 'text', + 'prefix' => 'text', + )); + $form->setRequest($request); + $form->populate(); + + if (!$form->validate()) { + $session->setData('step', $step); + $session->setFormData($request->getPost()); + $response->setRedirect("?mode=install&step={$step}"); + $response->sendHeaders(); + exit(0); + } + + $layout->getMessagesblock()->prepareMessages('install'); + $session->setStep(STEP_PROFILE); + $response->setRedirect("?mode=install&step={$nextStep}"); + $response->sendHeaders(); + exit(0); + } + + $layout->load('install.database'); + break; + + case STEP_PROFILE: + if (empty($_POST)) { + $session->setData('step', $step); + $response->setRedirect("?mode=install&step={$nextStep}"); + $response->sendHeaders(); + exit(0); + } + + $layout->load('install.profile'); + break; + + case STEP_UNIVERSE: + if (empty($_POST)) { + $session->setData('step', $step); + $response->setRedirect("?mode=install&step={$nextStep}"); + $response->sendHeaders(); + exit(0); + } + + $layout->load('install.universe'); + break; + + case STEP_CONFIG: + if (empty($_POST)) { + $session->setData('step', $step); + $response->setRedirect("?mode=install&step={$nextStep}"); + $response->sendHeaders(); + exit(0); + } + + $layout->load('install.config'); + break; + } + break; case 'ins': if ($page == 1) { @@ -345,12 +459,4 @@ EOF; die(); } - -$parse = $lang; -$parse['ins_state'] = $page; -$parse['ins_page'] = $frame; -$parse['dis_ins_btn'] = "?mode=$mode&page=$nextPage"; -$parse['dpath'] = $dpath; -$data = parsetemplate($mainTpl, $parse); - -display($data, "Installeur", false, '', true); +echo $layout->render(); diff --git a/install/upgrade-galaxy.php b/install/upgrade-galaxy.php new file mode 100644 index 0000000..4a7f26c --- /dev/null +++ b/install/upgrade-galaxy.php @@ -0,0 +1,98 @@ +getData('form_key')) { if ($action == 'rename' && isset($_POST['name']) && !empty($_POST['name'])) { $planet->setData('name', $_POST['name'])->save(); - - header('302 Found'); - header('Location: ' . basename(__FILE__)); - exit(0); } else if ($action == 'destroy' && isset($_POST['password']) && !empty($_POST['password']) && isset($_POST['confirm'])) { if (!$user->checkPassword($_POST['password'])) { Wootook::getSession('user') ->addError(Wootook::__('Password was not correct.')); - - header('302 Found'); - header('Location: ' . basename(__FILE__)); - exit(0); } try { @@ -67,15 +59,15 @@ if (isset($_POST) && !empty($_POST)) { Wootook::getSession('user') ->addError($e->getMessage()); } - - header('302 Found'); - header('Location: ' . basename(__FILE__)); - exit(0); } } else { Wootook::getSession('user') ->addError(Wootook::__('Invalid security key.')); } + + header('HTTP/1.1 302 Found'); + header('Location: ' . Wootook::getUrl(basename(__FILE__))); + exit(0); } else if ($action == 'rename') { $layout = new Wootook_Core_Layout(); $layout->load('overview.rename-planet'); diff --git a/skin/base/default/css/deprecated/formate.css b/skin/base/default/css/deprecated/formate.css index 9088598..f9d6ae2 100644 --- a/skin/base/default/css/deprecated/formate.css +++ b/skin/base/default/css/deprecated/formate.css @@ -279,13 +279,4 @@ a:hover .style { margin-top : 10px; -} - -h2 -{ - font-size : 14px; - font-family : Tahoma,sans-serif; - border-bottom : 0px #344566; solid; - width : 98%; - text-align : center; } \ No newline at end of file diff --git a/skin/base/default/css/legacies.css b/skin/base/default/css/legacies.css index e73b2d7..9b905c7 100644 --- a/skin/base/default/css/legacies.css +++ b/skin/base/default/css/legacies.css @@ -1,5 +1,19 @@ @CHARSET "UTF-8"; +* {font-size:10px;font-family:Arial,Tahoma,sans-serif;text-align:left;} +h1 {font-size:2em;border:#6AB 0 solid;border-width:1px 10px;border-radius:20px;text-align:center;color:#156;background:#EEE;} +h1:hover {color:#6AB;background:#CCC;} +h2,h3 {text-decoration:underline;font-weight:bold;} +h4,h5,h6 {font-style:italic;} +h2 {font-size:2em;} +h3 {font-size:2em;} +h4 {font-size:2em;} +h5 {font-size:2em;} +h6 {font-size:2em;} + +input[type=text] {height:2em;border:#156 0 solid;border-width:.1em 1em;border-radius:.9em;} +input[type=submit] {height:2em;border:#156 0 solid;border-width:.1em 1em;border-radius:.9em;} + .global .content .navigation {margin:0pt auto;width:1000px;height:30px;display:block;padding:0 40px;position:relative;border-width:0 1px;border-style:none solid;border-color:#FFF;background-color:#933;border-radius:10px;} .global .content .navigation .navigation-node {margin:0;height:30px;width:250px;color:#FFF;float:left;} .global .content .navigation .navigation-node .title {margin:5px 20px;font-size:1.5em;} @@ -39,13 +53,15 @@ .global .content .item-list .item {width:780px;margin:0 10px;border:0;box-shadow:none;border-radius:0;} .global .content .item-list .item,.global .content .item-list .item * {color:#000;} -.global .content form.registration {background:#FFF;width:300px;margin:10px auto;padding:10px 0;border-radius:20px;box-shadow:0 -4px 8px #115566 inset, 20px 20px 40px #115566, -20px 20px 40px #115566, 0 -20px 40px #115566;} -.global .content form.registration h1 {font-size:2em;} -.global .content form.registration fieldset {margin:20px 30px;width:220px;border:1px solid #000;padding:4px 9px;} -.global .content form.registration fieldset legend {font-size:1.2em;font-weight:bold;} -.global .content form.registration fieldset p label {width:100px;display:block;float:left;margin:0 10px;text-align:right;} -.global .content form.registration input {width:150px;display:block;margin:10px auto;} -.global .content form.registration fieldset p input {width:100px;display:block;} +.global .content form.form {background:#FFF;width:300px;margin:10px auto;padding:10px 0;border-radius:20px;box-shadow:0 -4px 8px #115566 inset, 20px 20px 40px #115566, -20px 20px 40px #115566, 0 -20px 40px #115566;} +.global .content form.form h1 {font-size:2em;} +.global .content form.form fieldset {margin:20px 30px;width:220px;border:1px solid #000;padding:4px 9px;} +.global .content form.form fieldset legend {font-size:1.2em;font-weight:bold;} +.global .content form.form fieldset p label {width:100px;display:block;float:left;margin:0 10px;text-align:right;} +.global .content form.form input {width:150px;display:block;margin:10px auto;} +.global .content form.form fieldset p input {width:100px;display:block;} + +.global .content .install {background:#FFF;width:600px;margin:10px auto;padding:20px;border-radius:20px;box-shadow:0 -4px 8px #115566 inset, 20px 20px 40px #115566, -20px 20px 40px #115566, 0 -20px 40px #115566;} /** * Galaxy user name display colors diff --git a/stat.php b/stat.php index c8e19d6..69b51f3 100644 --- a/stat.php +++ b/stat.php @@ -32,183 +32,183 @@ define('INSIDE' , true); define('INSTALL' , false); require_once dirname(__FILE__) .'/application/bootstrap.php'; - includeLang('stat'); +includeLang('stat'); - $parse = $lang; - $who = (isset($_POST['who'])) ? $_POST['who'] : $_GET['who']; - if (!isset($who)) { - $who = 1; +$parse = $lang; +$who = (isset($_POST['who'])) ? $_POST['who'] : $_GET['who']; +if (!isset($who)) { + $who = 1; +} +$type = (isset($_POST['type'])) ? $_POST['type'] : $_GET['type']; +if (!isset($type)) { + $type = 1; +} +$range = (isset($_POST['range'])) ? $_POST['range'] : $_GET['range']; +if (!isset($range)) { + $range = 1; +} + +$parse['who'] = ""; +$parse['who'] .= ""; + +$parse['type'] = ""; +$parse['type'] .= ""; +$parse['type'] .= ""; +$parse['type'] .= ""; +$parse['type'] .= ""; + +if ($type == 1) { + $Order = "total_points"; + $Points = "total_points"; + $Counts = "total_count"; + $Rank = "total_rank"; + $OldRank = "total_old_rank"; +} elseif ($type == 2) { + $Order = "fleet_points"; + $Points = "fleet_points"; + $Counts = "fleet_count"; + $Rank = "fleet_rank"; + $OldRank = "fleet_old_rank"; +} elseif ($type == 3) { + $Order = "tech_count"; + $Points = "tech_points"; + $Counts = "tech_count"; + $Rank = "tech_rank"; + $OldRank = "tech_old_rank"; +} elseif ($type == 4) { + $Order = "build_points"; + $Points = "build_points"; + $Counts = "build_count"; + $Rank = "build_rank"; + $OldRank = "build_old_rank"; +} elseif ($type == 5) { + $Order = "defs_points"; + $Points = "defs_points"; + $Counts = "defs_count"; + $Rank = "defs_rank"; + $OldRank = "defs_old_rank"; +} + +if ($who == 2) { + $MaxAllys = doquery ("SELECT COUNT(*) AS `count` FROM {{table}}", 'alliance', true); + if ($MaxAllys['count'] > 100) { + $LastPage = floor($MaxAllys['count'] / 100); } - $type = (isset($_POST['type'])) ? $_POST['type'] : $_GET['type']; - if (!isset($type)) { - $type = 1; - } - $range = (isset($_POST['range'])) ? $_POST['range'] : $_GET['range']; - if (!isset($range)) { - $range = 1; + $parse['range'] = ""; + for ($Page = 0; $Page <= $LastPage; $Page++) { + $PageValue = ($Page * 100) + 1; + $PageRange = $PageValue + 99; + $parse['range'] .= ""; } - $parse['who'] = ""; - $parse['who'] .= ""; + $parse['stat_header'] = parsetemplate(gettemplate('stat_alliancetable_header'), $parse); - $parse['type'] = ""; - $parse['type'] .= ""; - $parse['type'] .= ""; - $parse['type'] .= ""; - $parse['type'] .= ""; + $start = floor($range / 100 % 100) * 100; + $query = doquery("SELECT * FROM {{table}} WHERE `stat_type` = '2' AND `stat_code` = '1' ORDER BY `". $Order ."` DESC LIMIT ". $start .",100;", 'statpoints'); - if ($type == 1) { - $Order = "total_points"; - $Points = "total_points"; - $Counts = "total_count"; - $Rank = "total_rank"; - $OldRank = "total_old_rank"; - } elseif ($type == 2) { - $Order = "fleet_points"; - $Points = "fleet_points"; - $Counts = "fleet_count"; - $Rank = "fleet_rank"; - $OldRank = "fleet_old_rank"; - } elseif ($type == 3) { - $Order = "tech_count"; - $Points = "tech_points"; - $Counts = "tech_count"; - $Rank = "tech_rank"; - $OldRank = "tech_old_rank"; - } elseif ($type == 4) { - $Order = "build_points"; - $Points = "build_points"; - $Counts = "build_count"; - $Rank = "build_rank"; - $OldRank = "build_old_rank"; - } elseif ($type == 5) { - $Order = "defs_points"; - $Points = "defs_points"; - $Counts = "defs_count"; - $Rank = "defs_rank"; - $OldRank = "defs_old_rank"; - } + $start++; + $parse['stat_date'] = $gameConfig['stats']; + $parse['stat_values'] = ""; + while ($StatRow = $query->fetch(PDO::FETCH_ASSOC)) { + $parse['ally_rank'] = $start; - if ($who == 2) { - $MaxAllys = doquery ("SELECT COUNT(*) AS `count` FROM {{table}} WHERE 1;", 'alliance', true); - if ($MaxAllys['count'] > 100) { - $LastPage = floor($MaxAllys['count'] / 100); + $AllyRow = doquery("SELECT * FROM {{table}} WHERE `id` = '". $StatRow['id_owner'] ."';", 'alliance',true); + + $rank_old = $StatRow[ $OldRank ]; + if ( $rank_old == 0) { + $rank_old = $start; + $QryUpdRank = doquery("UPDATE {{table}} SET `".$Rank."` = '".$start."', `".$OldRank."` = '".$start."' WHERE `stat_type` = '2' AND `stat_code` = '1' AND `id_owner` = '". $StatRow['id_owner'] ."';" , "statpoints"); + } else { + $QryUpdRank = doquery("UPDATE {{table}} SET `".$Rank."` = '".$start."' WHERE `stat_type` = '2' AND `stat_code` = '1' AND `id_owner` = '". $StatRow['id_owner'] ."';" , "statpoints"); } - $parse['range'] = ""; - for ($Page = 0; $Page <= $LastPage; $Page++) { - $PageValue = ($Page * 100) + 1; - $PageRange = $PageValue + 99; - $parse['range'] .= ""; + $rank_new = $start; + $ranking = $rank_old - $rank_new; + if ($ranking == "0") { + $parse['ally_rankplus'] = "*"; } + if ($ranking < "0") { + $parse['ally_rankplus'] = "".$ranking.""; + } + if ($ranking > "0") { + $parse['ally_rankplus'] = "+".$ranking.""; + } + $parse['ally_tag'] = $AllyRow['ally_tag']; + $parse['ally_name'] = $AllyRow['ally_name']; + $parse['ally_mes'] = ''; + $parse['ally_members'] = $AllyRow['ally_members']; + $parse['ally_points'] = pretty_number( $StatRow[ $Order ] ); + $parse['ally_members_points'] = pretty_number( floor($StatRow[ $Order ] / $AllyRow['ally_members']) ); - $parse['stat_header'] = parsetemplate(gettemplate('stat_alliancetable_header'), $parse); - - $start = floor($range / 100 % 100) * 100; - $query = doquery("SELECT * FROM {{table}} WHERE `stat_type` = '2' AND `stat_code` = '1' ORDER BY `". $Order ."` DESC LIMIT ". $start .",100;", 'statpoints'); - + $parse['stat_values'] .= parsetemplate(gettemplate('stat_alliancetable'), $parse); $start++; - $parse['stat_date'] = $gameConfig['stats']; - $parse['stat_values'] = ""; - while ($StatRow = $query->fetch(PDO::FETCH_ASSOC)) { - $parse['ally_rank'] = $start; - - $AllyRow = doquery("SELECT * FROM {{table}} WHERE `id` = '". $StatRow['id_owner'] ."';", 'alliance',true); - - $rank_old = $StatRow[ $OldRank ]; - if ( $rank_old == 0) { - $rank_old = $start; - $QryUpdRank = doquery("UPDATE {{table}} SET `".$Rank."` = '".$start."', `".$OldRank."` = '".$start."' WHERE `stat_type` = '2' AND `stat_code` = '1' AND `id_owner` = '". $StatRow['id_owner'] ."';" , "statpoints"); - } else { - $QryUpdRank = doquery("UPDATE {{table}} SET `".$Rank."` = '".$start."' WHERE `stat_type` = '2' AND `stat_code` = '1' AND `id_owner` = '". $StatRow['id_owner'] ."';" , "statpoints"); - } - $rank_new = $start; - $ranking = $rank_old - $rank_new; - if ($ranking == "0") { - $parse['ally_rankplus'] = "*"; - } - if ($ranking < "0") { - $parse['ally_rankplus'] = "".$ranking.""; - } - if ($ranking > "0") { - $parse['ally_rankplus'] = "+".$ranking.""; - } - $parse['ally_tag'] = $AllyRow['ally_tag']; - $parse['ally_name'] = $AllyRow['ally_name']; - $parse['ally_mes'] = ''; - $parse['ally_members'] = $AllyRow['ally_members']; - $parse['ally_points'] = pretty_number( $StatRow[ $Order ] ); - $parse['ally_members_points'] = pretty_number( floor($StatRow[ $Order ] / $AllyRow['ally_members']) ); - - $parse['stat_values'] .= parsetemplate(gettemplate('stat_alliancetable'), $parse); - $start++; - } - } else { - $MaxUsers = doquery ("SELECT COUNT(*) AS `count` FROM {{table}} WHERE `db_deaktjava` = '0';", 'users', true); - if ($MaxUsers['count'] > 100) { - $LastPage = floor($MaxUsers['count'] / 100); - } - $parse['range'] = ""; - for ($Page = 0; $Page <= $LastPage; $Page++) { - $PageValue = ($Page * 100) + 1; - $PageRange = $PageValue + 99; - $parse['range'] .= ""; - } - - $parse['stat_header'] = parsetemplate(gettemplate('stat_playertable_header'), $parse); - - $start = floor($range / 100 % 100) * 100; - $query = doquery("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' ORDER BY `". $Order ."` DESC LIMIT ". $start .",100;", 'statpoints'); - - $start++; - $parse['stat_date'] = $gameConfig['stats']; - $parse['stat_values'] = ""; - while ($StatRow = $query->fetch(PDO::FETCH_ASSOC)) { - $parse['stat_date'] = date("d M Y - H:i:s", $StatRow['stat_date']); - $parse['player_rank'] = $start; - - $UsrRow = doquery("SELECT * FROM {{table}} WHERE `id` = '". $StatRow['id_owner'] ."';", 'users',true); - - $QryUpdateStats .= "`stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '". $TheRank['id_owner'] ."';"; - - - $rank_old = $StatRow[ $OldRank ]; - if ( $rank_old == 0) { - $rank_old = $start; - $QryUpdRank = doquery("UPDATE {{table}} SET `".$Rank."` = '".$start."', `".$OldRank."` = '".$start."' WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '". $StatRow['id_owner'] ."';" , "statpoints"); - } else { - $QryUpdRank = doquery("UPDATE {{table}} SET `".$Rank."` = '".$start."' WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '". $StatRow['id_owner'] ."';" , "statpoints"); - } - $rank_new = $start; - $ranking = $rank_old - $rank_new; - if ($ranking == "0") { - $parse['player_rankplus'] = "*"; - } - if ($ranking < "0") { - $parse['player_rankplus'] = "".$ranking.""; - } - if ($ranking > "0") { - $parse['player_rankplus'] = "+".$ranking.""; - } - if ($UsrRow['id'] == $user['id']) { - $parse['player_name'] = "".$UsrRow['username'].""; - } else { - $parse['player_name'] = $UsrRow['username']; - } - $parse['player_mes'] = "\""."; - if ($UsrRow['ally_name'] == $user['ally_name']) { - $parse['player_alliance'] = "".$UsrRow['ally_name'].""; - } else { - $parse['player_alliance'] = $UsrRow['ally_name']; - } - $parse['player_points'] = pretty_number( $StatRow[ $Order ] ); - $parse['stat_values'] .= parsetemplate(gettemplate('stat_playertable'), $parse); - $start++; - } + } +} else { + $MaxUsers = doquery ("SELECT COUNT(*) AS `count` FROM {{table}} WHERE `db_deaktjava` = '0';", 'users', true); + if ($MaxUsers['count'] > 100) { + $LastPage = floor($MaxUsers['count'] / 100); + } + $parse['range'] = ""; + for ($Page = 0; $Page <= $LastPage; $Page++) { + $PageValue = ($Page * 100) + 1; + $PageRange = $PageValue + 99; + $parse['range'] .= ""; } - $page = parsetemplate( gettemplate('stat_body'), $parse ); + $parse['stat_header'] = parsetemplate(gettemplate('stat_playertable_header'), $parse); - display($page, $lang['stat_title']); + $start = floor($range / 100 % 100) * 100; + $query = doquery("SELECT * FROM {{table}} WHERE `stat_type` = '1' AND `stat_code` = '1' ORDER BY `". $Order ."` DESC LIMIT ". $start .",100;", 'statpoints'); + + $start++; + $parse['stat_date'] = $gameConfig['stats']; + $parse['stat_values'] = ""; + while ($StatRow = $query->fetch(PDO::FETCH_ASSOC)) { + $parse['stat_date'] = date("d M Y - H:i:s", $StatRow['stat_date']); + $parse['player_rank'] = $start; + + $UsrRow = doquery("SELECT * FROM {{table}} WHERE `id` = '". $StatRow['id_owner'] ."';", 'users',true); + + $QryUpdateStats .= "`stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '". $TheRank['id_owner'] ."';"; + + + $rank_old = $StatRow[ $OldRank ]; + if ( $rank_old == 0) { + $rank_old = $start; + $QryUpdRank = doquery("UPDATE {{table}} SET `".$Rank."` = '".$start."', `".$OldRank."` = '".$start."' WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '". $StatRow['id_owner'] ."';" , "statpoints"); + } else { + $QryUpdRank = doquery("UPDATE {{table}} SET `".$Rank."` = '".$start."' WHERE `stat_type` = '1' AND `stat_code` = '1' AND `id_owner` = '". $StatRow['id_owner'] ."';" , "statpoints"); + } + $rank_new = $start; + $ranking = $rank_old - $rank_new; + if ($ranking == "0") { + $parse['player_rankplus'] = "*"; + } + if ($ranking < "0") { + $parse['player_rankplus'] = "".$ranking.""; + } + if ($ranking > "0") { + $parse['player_rankplus'] = "+".$ranking.""; + } + if ($UsrRow['id'] == $user['id']) { + $parse['player_name'] = "".$UsrRow['username'].""; + } else { + $parse['player_name'] = $UsrRow['username']; + } + $parse['player_mes'] = "\""."; + if ($UsrRow['ally_name'] == $user['ally_name']) { + $parse['player_alliance'] = "".$UsrRow['ally_name'].""; + } else { + $parse['player_alliance'] = $UsrRow['ally_name']; + } + $parse['player_points'] = pretty_number( $StatRow[ $Order ] ); + $parse['stat_values'] .= parsetemplate(gettemplate('stat_playertable'), $parse); + $start++; + } +} + +$page = parsetemplate( gettemplate('stat_body'), $parse ); + +display($page, $lang['stat_title']); // ----------------------------------------------------------------------------------------------------------- // History version