diff --git a/src/application/code/core/Wootook/Core/Database/Adapter/Adapter.php b/src/application/code/core/Wootook/Core/Database/Adapter/Adapter.php index d0c4c34..1bcf543 100644 --- a/src/application/code/core/Wootook/Core/Database/Adapter/Adapter.php +++ b/src/application/code/core/Wootook/Core/Database/Adapter/Adapter.php @@ -31,6 +31,14 @@ abstract class Wootook_Core_Database_Adapter_Adapter return $this->_tablePrefix; } + /** + * @return string + */ + public function getTable($table) + { + return $this->getTablePrefix() . $table; + } + /** * @return Wootook_Core_Database_Sql_Select */ @@ -123,7 +131,8 @@ abstract class Wootook_Core_Database_Adapter_Adapter { $statement = $this->prepare($sql); if (!$statement->execute()) { - throw new Wootook_Core_Exception_Database_AdapterError($this, 'Could not execute query.'); + $message = sprintf('[SQLSTATE %s] Could not execute query: %s', $statement->errorState(), $statement->errorMessage()); + throw new Wootook_Core_Exception_Database_StatementError($statement, $message); } return $statement; diff --git a/src/application/code/core/Wootook/Core/Database/ConnectionManager.php b/src/application/code/core/Wootook/Core/Database/ConnectionManager.php index c39649e..cbbad44 100644 --- a/src/application/code/core/Wootook/Core/Database/ConnectionManager.php +++ b/src/application/code/core/Wootook/Core/Database/ConnectionManager.php @@ -177,7 +177,15 @@ class Wootook_Core_Database_ConnectionManager $options = $event->getData('options'); - $connection = $this->load($engine, false, array($params, $options)); + try { + $connection = $this->load($engine, false, array($params, $options)); + } catch (Wootook_Core_Exception_Database_AdapterError $e) { + //Wootook_Core_ErrorProfiler::getSingleton()->addException($e); + return null; + } + if (!$connection) { + throw new Wootook_Core_Exception_DataAccessException('Could not find data connection handler.'); + } if (($prefix = Wootook::getConfig("resource/database/{$connectionName}/table_prefix")) !== null) { $connection->setTablePrefix($prefix); diff --git a/src/application/code/core/Wootook/Core/Database/Sql/DmlQuery.php b/src/application/code/core/Wootook/Core/Database/Sql/DmlQuery.php index 4b74350..6872426 100644 --- a/src/application/code/core/Wootook/Core/Database/Sql/DmlQuery.php +++ b/src/application/code/core/Wootook/Core/Database/Sql/DmlQuery.php @@ -37,6 +37,9 @@ abstract class Wootook_Core_Database_Sql_DmlQuery $this->_init($tableName); } + /** + * @return Wootook_Core_Database_Adapter_Adapter + */ public function getConnection() { return $this->_connection; @@ -265,7 +268,7 @@ abstract class Wootook_Core_Database_Sql_DmlQuery public function beforePrepare(Wootook_Core_Database_Statement_Statement $statement) { foreach ($this->_placeholders as $placeholder) { - $placeholder->befrePrepare($statement); + $placeholder->beforePrepare($statement); } return $this; diff --git a/src/application/code/core/Wootook/Core/Database/Sql/Placeholder/Expression.php b/src/application/code/core/Wootook/Core/Database/Sql/Placeholder/Expression.php index f13c3a9..e39501f 100644 --- a/src/application/code/core/Wootook/Core/Database/Sql/Placeholder/Expression.php +++ b/src/application/code/core/Wootook/Core/Database/Sql/Placeholder/Expression.php @@ -3,4 +3,15 @@ class Wootook_Core_Database_Sql_Placeholder_Expression extends Wootook_Core_Database_Sql_Placeholder_Placeholder { + protected $_expression = null; + + public function __construct($expression) + { + $this->_expression = (string) $expression; + } + + public function __toString() + { + return $this->_expression; + } } \ No newline at end of file diff --git a/src/application/code/core/Wootook/Core/Database/Sql/Placeholder/Placeholder.php b/src/application/code/core/Wootook/Core/Database/Sql/Placeholder/Placeholder.php index 15cb69f..f0981ef 100644 --- a/src/application/code/core/Wootook/Core/Database/Sql/Placeholder/Placeholder.php +++ b/src/application/code/core/Wootook/Core/Database/Sql/Placeholder/Placeholder.php @@ -4,22 +4,22 @@ abstract class Wootook_Core_Database_Sql_Placeholder_Placeholder { abstract public function __toString(); - abstract public function beforePrepare(Wootook_Core_Database_Statement_Statement $statement) + public function beforePrepare(Wootook_Core_Database_Statement_Statement $statement) { return $this; } - abstract public function afterPrepare(Wootook_Core_Database_Statement_Statement $statement) + public function afterPrepare(Wootook_Core_Database_Statement_Statement $statement) { return $this; } - abstract public function beforeExcute(Wootook_Core_Database_Statement_Statement $statement) + public function beforeExcute(Wootook_Core_Database_Statement_Statement $statement) { return $this; } - abstract public function afterExecute(Wootook_Core_Database_Statement_Statement $statement) + public function afterExecute(Wootook_Core_Database_Statement_Statement $statement) { return $this; } diff --git a/src/application/code/core/Wootook/Core/Database/Sql/Select.php b/src/application/code/core/Wootook/Core/Database/Sql/Select.php index e4b0b95..a64034b 100644 --- a/src/application/code/core/Wootook/Core/Database/Sql/Select.php +++ b/src/application/code/core/Wootook/Core/Database/Sql/Select.php @@ -87,6 +87,10 @@ abstract class Wootook_Core_Database_Sql_Select } } } else { + if ($column instanceof Wootook_Core_Database_Sql_Placeholder_Placeholder) { + $this->_placeholders[] = $column; + } + $this->_parts[self::COLUMNS][] = array( 'table' => $table, 'alias' => null, @@ -120,17 +124,17 @@ abstract class Wootook_Core_Database_Sql_Select $this->column($fields); if (is_array($table)) { $alias = key($table); - $table = current($table); + $table = $this->_connection->getTable(current($table)); if ($schema !== null) { - $this->_parts[self::JOIN][] = "\n{$mode} JOIN {$this->_connection->quoteIdentifier($schema)}{$this->_connection->quoteIdentifier($this->_connection->getTable($table))} AS {$this->_connection->quoteIdentifier($alias)}" + $this->_parts[self::JOIN][] = "\n{$mode} JOIN {$this->_connection->quoteIdentifier($schema)}{$this->_connection->quoteIdentifier($table)} AS {$this->_connection->quoteIdentifier($alias)}" . "\n ON {$condition}"; } else { - $this->_parts[self::JOIN][] = "\n{$mode} JOIN {$this->_connection->quoteIdentifier($this->_connection->getTable($table))} AS {$this->_connection->quoteIdentifier($alias)}" + $this->_parts[self::JOIN][] = "\n{$mode} JOIN {$this->_connection->quoteIdentifier($table)} AS {$this->_connection->quoteIdentifier($alias)}" . "\n ON {$condition}"; } } else { - $this->_parts[self::JOIN][] = "\n{$mode} JOIN {$this->_connection->quoteIdentifier($this->_connection->getTable($table))}" + $this->_parts[self::JOIN][] = "\n{$mode} JOIN {$this->_connection->quoteIdentifier($table)}" . "\n ON {$condition}"; } @@ -233,8 +237,6 @@ abstract class Wootook_Core_Database_Sql_Select $fields[] = "({$field['field']})"; } } else if ($field['field'] instanceof Wootook_Core_Database_Sql_Placeholder_Placeholder) { - $field['field']->prepare($this); - if ($field['alias'] !== null) { $fields[] = "({$field['field']}) AS {$field['alias']}"; } else { @@ -256,7 +258,7 @@ abstract class Wootook_Core_Database_Sql_Select if (!empty($fields)) { return 'SELECT ' . implode(", ", $fields); } - return '*'; + return 'SELECT *'; } public function renderFrom() diff --git a/src/application/code/core/Wootook/Core/Database/Statement/Pdo/Mysql.php b/src/application/code/core/Wootook/Core/Database/Statement/Pdo/Mysql.php index d0add13..388bbc3 100644 --- a/src/application/code/core/Wootook/Core/Database/Statement/Pdo/Mysql.php +++ b/src/application/code/core/Wootook/Core/Database/Statement/Pdo/Mysql.php @@ -241,4 +241,66 @@ class Wootook_Core_Database_Statement_Pdo_Mysql } return null; } + + /** + * @return bool + */ + public function closeCursor() + { + try { + return $this->_handler->closeCursor(); + } catch (PDOException $e) { + throw new Wootook_Core_Exception_Database_AdapterError($this, $e->getMessage(), null, $e); + } + return false; + } + + /** + * @return bool + */ + public function nextRowset() + { + try { + return $this->_handler->nextRowset(); + } catch (PDOException $e) { + throw new Wootook_Core_Exception_Database_AdapterError($this, $e->getMessage(), null, $e); + } + return false; + } + + /** + * @return string + */ + public function errorCode() + { + return $this->_handler->errorCode(); + } + + /** + * @return array + */ + public function errorInfo() + { + return $this->_handler->errorInfo(); + } + + /** + * @return string + */ + public function errorMessage() + { + $info = $this->_handler->errorInfo(); + + return $info[2]; + } + + /** + * @return string + */ + public function errorState() + { + $info = $this->_handler->errorInfo(); + + return $info[0]; + } } \ No newline at end of file diff --git a/src/application/code/core/Wootook/Core/Database/Statement/Statement.php b/src/application/code/core/Wootook/Core/Database/Statement/Statement.php index 4feef44..4bcac28 100644 --- a/src/application/code/core/Wootook/Core/Database/Statement/Statement.php +++ b/src/application/code/core/Wootook/Core/Database/Statement/Statement.php @@ -136,11 +136,41 @@ abstract class Wootook_Core_Database_Statement_Statement */ abstract public function columnCount(); + /** + * @return string + */ + abstract public function errorCode(); + + /** + * @return string + */ + abstract public function errorMessage(); + + /** + * @return array + */ + abstract public function errorInfo(); + + /** + * @return string + */ + abstract public function errorState(); + /** * @return int */ abstract public function rowCount(); + /** + * @return bool + */ + abstract public function closeCursor(); + + /** + * @return bool + */ + abstract public function nextRowset(); + public function current() { return $this->_currentRow; diff --git a/src/application/code/core/Wootook/Core/Entity/SubTable.php b/src/application/code/core/Wootook/Core/Entity/SubTable.php index b512222..ee90f75 100644 --- a/src/application/code/core/Wootook/Core/Entity/SubTable.php +++ b/src/application/code/core/Wootook/Core/Entity/SubTable.php @@ -67,18 +67,16 @@ SQL_EOF; $idValues = func_get_arg(0); $database = $this->getReadConnection(); + $select = $database->select() + ->from(array('main_table' => $database->getTable($this->getTableName()))) + ->limit(1); + $idFields = array(); foreach ($this->_idFieldNames as $field) { - $idFields[] = "{$field}=:{$field}"; + $select->where("{$database->quoteIdentifier($field)}=:{$field}"); } - $idFields = '(' . implode(') AND (', $idFields) . ')'; - $sql =<<getTable(self::getTableName())} - WHERE $idFields - LIMIT 1 -SQL_EOF; - $statement = $database->prepare($sql); + $statement = $database->prepare($select); $statement->execute($idValues); $datas = $statement->fetch(PDO::FETCH_ASSOC); @@ -86,7 +84,9 @@ SQL_EOF; throw new Wootook_Core_Exception_DataAccessException('Could not load data: this id combination could not be found.'); } - $this->_data = $datas; + $this->_data = array(); + $this->getDataMapper()->decode($this, $datas); + $this->_isLoaded = true; return $this; diff --git a/src/application/code/core/Wootook/Core/Exception/Database/StatementError.php b/src/application/code/core/Wootook/Core/Exception/Database/StatementError.php index e9df9c3..c9842cd 100644 --- a/src/application/code/core/Wootook/Core/Exception/Database/StatementError.php +++ b/src/application/code/core/Wootook/Core/Exception/Database/StatementError.php @@ -1,6 +1,6 @@ _queryVars = $_GET; + $this->_postVars = $_POST; + $this->_cookieVars = $_COOKIE; + $this->_serverVars = $_SERVER; + $this->_postFiles = $_FILES; + + $this->clearData(); + + $this->addData($this->_serverVars); + $this->addData($this->_cookieVars); + $this->addData($this->_queryVars); + $this->addData($this->_postVars); + } + public function setParam($key, $value) { return $this->setData($key, $value); @@ -74,86 +96,103 @@ class Wootook_Core_Mvc_Controller_Request_Http if ($this->hasData($key)) { return $this->getData($key); } - if (isset($_POST[$key])) { - return $_POST[$key]; + if ($this->hasPost($key)) { + return $this->getPost($key); } - if (isset($_GET[$key])) { - return $_GET[$key]; + if ($this->hasQuery($key)) { + return $this->getQuery($key); } - if (isset($_FILES[$key])) { - return $_FILES[$key]; + if ($this->hasCookie($key)) { + return $this->getCookie($key); } - if (isset($_COOKIE[$key])) { - return $_COOKIE[$key]; - } - if (isset($_SERVER[$key])) { - return $_SERVER[$key]; - } - return $default; + + return $this->getServer($key, $default); } public function getQuery($key, $default = null) { - if (!isset($_GET[$key])) { + if (!isset($this->_queryVars[$key])) { return $default; } - return $_GET[$key]; - } - - public function getFile($key, $default = null) - { - if (!isset($_FILES[$key])) { - return $default; - } - return $_FILES[$key]; - } - - public function getCookie($key, $default = null) - { - if (!isset($_COOKIE[$key])) { - return $default; - } - return unserialize(stripslashes($_COOKIE[$key])); - } - - public function getRawCookie($key, $default = null) - { - if (!isset($_COOKIE[$key])) { - return $default; - } - return $_COOKIE[$key]; - } - - public function getPost($key, $default = null) - { - if (!isset($_POST[$key])) { - return $default; - } - return $_POST[$key]; - } - - public function getServer($key, $default = null) - { - if (!isset($_SERVER[$key])) { - return $default; - } - return $_SERVER[$key]; + return $this->_queryVars[$key]; } public function getAllQueryData() { - return $_GET; + return $this->_queryVars; } - public function getAllFilesData() + public function hasQuery($key) { - return $_FILES; + return isset($this->_queryVars[$key]); + } + + public function setQuery($key, $value) + { + $this->_queryVars[$key] = (string) $value; + + return $this; + } + + public function unsetQuery($key) + { + unset($this->_queryVars[$key]); + + return $this; + } + + public function getPost($key, $default = null) + { + if (!isset($this->_postVars[$key])) { + return $default; + } + return $this->_postVars[$key]; + } + + public function getAllPostData() + { + return $this->_postVars; + } + + public function hasPost($key) + { + return isset($this->_postVars[$key]); + } + + public function setPost($key, $value) + { + $this->_postVars[$key] = (string) $value; + + return $this; + } + + public function unsetPost($key) + { + unset($this->_postVars[$key]); + + return $this; + } + + public function getCookie($key, $default = null) + { + if (!isset($this->_cookieVars[$key])) { + return $default; + } + return unserialize(stripslashes($this->_cookieVars[$key])); + } + + public function getRawCookie($key, $default = null) + { + if (!isset($this->_cookieVars[$key])) { + return $default; + } + return $this->_cookieVars[$key]; } public function getAllCookieData() { $data = array(); - foreach ($_COOKIE as $key => $value) { + foreach ($this->_cookieVars as $key => $value) { $data[$key] = unserialize(stripslashes($value)); } return $data; @@ -161,17 +200,59 @@ class Wootook_Core_Mvc_Controller_Request_Http public function getAllRawCookieData() { - return $_COOKIE; + return $this->_cookieVars; } - public function getAllPostData() + public function hasCookie($key) { - return $_POST; + return isset($this->_cookieVars[$key]); + } + + public function setCookie($key, $value) + { + $this->_cookieVars[$key] = addslashes(serialize((string) $value)); + + return $this; + } + + public function setRawCookie($key, $value) + { + $this->_cookieVars[$key] = (string) $value; + + return $this; + } + + public function unsetCookie($key) + { + unset($this->_cookieVars[$key]); + + return $this; + } + + public function getServer($key, $default = null) + { + if (!isset($this->_serverVars[$key])) { + return $default; + } + return $this->_serverVars[$key]; } public function getAllServerData() { - return $_SERVER; + return $this->_serverVars; + } + + public function getFile($key, $default = null) + { + if (!isset($this->_postFiles[$key])) { + return $default; + } + return $this->_postFiles[$key]; + } + + public function getAllFilesData() + { + return $this->_postFiles; } public function isPost() diff --git a/src/application/code/core/Wootook/Core/Mvc/Controller/Request/Request.php b/src/application/code/core/Wootook/Core/Mvc/Controller/Request/Request.php index abd9dca..3a77073 100644 --- a/src/application/code/core/Wootook/Core/Mvc/Controller/Request/Request.php +++ b/src/application/code/core/Wootook/Core/Mvc/Controller/Request/Request.php @@ -3,6 +3,13 @@ abstract class Wootook_Core_Mvc_Controller_Request_Request extends Wootook_Object { + public function __construct(Array $data = array()) + { + $this->init(); + + parent::__construct($data); + } + public function setParam($key, $value) { return $this->setData($key, $value); @@ -16,6 +23,8 @@ abstract class Wootook_Core_Mvc_Controller_Request_Request return $default; } + abstract public function init(); + abstract public function getModuleName(); abstract public function getControllerName(); abstract public function getActionName(); diff --git a/src/application/code/core/Wootook/Core/Resource/CollectionAbstract.php b/src/application/code/core/Wootook/Core/Resource/EntityCollection.php similarity index 98% rename from src/application/code/core/Wootook/Core/Resource/CollectionAbstract.php rename to src/application/code/core/Wootook/Core/Resource/EntityCollection.php index 2dbdb39..f333e5c 100644 --- a/src/application/code/core/Wootook/Core/Resource/CollectionAbstract.php +++ b/src/application/code/core/Wootook/Core/Resource/EntityCollection.php @@ -1,6 +1,6 @@ _select === null) { - $this->_select = $this->getReadConnection()->select($this->_entityTable); + $this->_select = $this->getReadConnection() + ->select(array('main_table' => $this->getReadConnection()->getTable($this->_entityTable))); $this->_prepareSelect($this->_select); } diff --git a/src/application/code/core/Wootook/Empire/Model/Planet.php b/src/application/code/core/Wootook/Empire/Model/Planet.php index 5e329d3..e2b7683 100644 --- a/src/application/code/core/Wootook/Empire/Model/Planet.php +++ b/src/application/code/core/Wootook/Empire/Model/Planet.php @@ -122,6 +122,15 @@ class Wootook_Empire_Model_Planet return self::factory($planetId); } + public function __construct(Array $data = array(), Wootook_Player_Model_Entity $player = null) + { + parent::__construct($data); + + if ($player !== null) { + $this->setPlayer($player); + } + } + public function _init() { $this->_tableName = 'planets'; @@ -258,7 +267,7 @@ class Wootook_Empire_Model_Planet $resources = Wootook_Empire_Helper_Config_Resources::getSingleton(); $production = Wootook_Empire_Helper_Config_Production::getSingleton(); - if (!$this->isPlanet()) { + if (!$this->isPlanet() || !$this->getPlayer()) { return $this; } @@ -437,7 +446,8 @@ class Wootook_Empire_Model_Planet public function getPlayer() { if ($this->_player === null && $this->getPlayerId()) { - $this->_player = Wootook_Player_Model_Entity::factory($this->getPlayerId()); + $this->_player = new Wootook_Player_Model_Entity(); + $this->_player->load($this->getPlayerId()); } return $this->_player; } @@ -445,6 +455,7 @@ class Wootook_Empire_Model_Planet public function setPlayer(Wootook_Player_Model_Entity $player) { $this->_player = $player; + $this->setData('id_owner', $player->getId()); return $this; } @@ -756,7 +767,7 @@ class Wootook_Empire_Model_Planet */ public function getBuildingQueue() { - if ($this->_builder === null) { + if ($this->_builder === null && $this->getPlayer()) { $this->_builder = new Wootook_Empire_Model_Planet_Builder($this, $this->getPlayer()); } return $this->_builder; @@ -843,12 +854,12 @@ class Wootook_Empire_Model_Planet { $adapter = Wootook_Core_Database_ConnectionManager::getSingleton() ->getConnection('core_read'); - $select = $adapter->select(array('galaxy' => 'galaxy')); + $select = $adapter->select(array('galaxy' => $adapter->getTable('galaxy'))); $select ->column(array( - 'galaxy' => 'galaxy.galaxy', - 'system' => 'galaxy.system', - 'count' => 'COUNT(*)' + 'galaxy' => 'galaxy', + 'system' => 'system', + 'count' => new Wootook_Core_Database_Sql_Placeholder_Expression('COUNT(*)') )) ->group('galaxy.galaxy') ->group('galaxy.system') @@ -860,7 +871,7 @@ class Wootook_Empire_Model_Planet if ($galaxyList !== null) { array_walk($galaxyList, array(__CLASS__, '_cleanItemRanges')); - $select->where('galaxy.galaxy IN(' . implode(', ', $galaxyList) . ')'); + $select->where('galaxy', array(array(Wootook_Core_Database_Sql_Select::OPERATOR_IN => $galaxyList))); } if ($systemList === null && Wootook::getGameConfig('user/registration/system_list')) { @@ -869,7 +880,7 @@ class Wootook_Empire_Model_Planet if ($systemList !== null) { array_walk($systemList, array(__CLASS__, '_cleanItemRanges')); - $select->where('galaxy.system IN(' . implode(', ', $systemList) . ')'); + $select->where('system', array(array(Wootook_Core_Database_Sql_Select::OPERATOR_IN => $systemList))); } $orders = array( @@ -879,7 +890,7 @@ class Wootook_Empire_Model_Planet "RAND() / 1000", ); $select - ->order('((' . implode(') * (', $orders) . '))', 'ASC') + ->order(new Wootook_Core_Database_Sql_Placeholder_Expression('((' . implode(') * (', $orders) . '))'), 'ASC') //->order("ABS(galaxy.system - CEIL({$collection->quote(Wootook::getGameConfig('engine/universe/systems'))} / 2))", 'ASC') //->order("ABS(galaxy.galaxy - CEIL({$collection->quote(Wootook::getGameConfig('engine/universe/galaxies'))} / 2))", 'ASC') //->order("1.5 / COUNT(*)", 'ASC') diff --git a/src/application/code/core/Wootook/Empire/Resource/Fleet/Collection.php b/src/application/code/core/Wootook/Empire/Resource/Fleet/Collection.php index fb1befc..f754241 100644 --- a/src/application/code/core/Wootook/Empire/Resource/Fleet/Collection.php +++ b/src/application/code/core/Wootook/Empire/Resource/Fleet/Collection.php @@ -1,7 +1,7 @@ $request->getServer('HTTP_USER_AGENT') )); - $player->getWriteConnection()->beginTransaction(); + //$player->getWriteConnection()->beginTransaction(); $player->save(); @@ -150,9 +150,9 @@ class Wootook_Player_Model_Entity if (!$statement->execute()) { throw new Wootook_Empire_Exception_RuntimeException('No more planet to colonize!'); // Oops, no more free place } - } catch (PDOException $e) { - Wootook_Core_ErrorProfiler::getSingleton()->exceptionManager($e); - $this->getWriteConnection()->rollback(); + } catch (Wootook_Core_Exception_Database_Error $e) { + Wootook_Core_ErrorProfiler::getSingleton()->addException($e); + //$this->getWriteConnection()->rollback(); return null; } @@ -161,7 +161,7 @@ class Wootook_Player_Model_Entity throw new Wootook_Empire_Exception_RuntimeException('No more planet to colonize!'); // Oops, no more free place } - $collection = new Wootook_Empire_Resource_Planet_Collection($player->getReadConneciton()); + $collection = new Wootook_Empire_Resource_Planet_Collection($player->getReadConnection()); $collection->addTypeToFilter(Wootook_Empire_Model_Planet::TYPE_PLANET) ->addFieldToFilter('galaxy', $systemInfo['galaxy']) ->addFieldToFilter('system', $systemInfo['system']) @@ -178,8 +178,8 @@ class Wootook_Player_Model_Entity $finalPosition = $positions[$key]; $planet = $player->createNewPlanet( - $systemInfo->getData('galaxy'), - $systemInfo->getData('system'), + $systemInfo['galaxy'], + $systemInfo['system'], $finalPosition, Wootook_Empire_Model_Planet::TYPE_PLANET, Wootook::getRequest()->getParam('planet'), @@ -200,21 +200,21 @@ class Wootook_Player_Model_Entity $player->save(); } catch (Wootook_Core_Exception_DataAccessException $e) { - $player->getWriteConnection()->rollback(); + //$player->getWriteConnection()->rollback(); $session = Wootook_Core_Model_Session::factory(Wootook_Player_Model_Entity::SESSION_KEY); - Wootook_Core_ErrorProfiler::getSingleton()->exceptionManager($e); + Wootook_Core_ErrorProfiler::getSingleton()->addException($e); $session->addError($e->getMessage()); return null; } catch (Wootook_Empire_Exception_RuntimeException $e) { - $player->getWriteConnection()->rollback(); + //$player->getWriteConnection()->rollback(); $session = Wootook_Core_Model_Session::factory(Wootook_Player_Model_Entity::SESSION_KEY); - Wootook_Core_ErrorProfiler::getSingleton()->exceptionManager($e); + Wootook_Core_ErrorProfiler::getSingleton()->addException($e); $session->addError($e->getMessage()); return null; } - $player->getWriteConnection()->commit(); + //$player->getWriteConnection()->commit(); return $player; } @@ -230,10 +230,9 @@ class Wootook_Player_Model_Entity $size = mt_rand(floor($factor / 10), ceil($factor * 5 / 4)) + mt_rand(0, $fuzz); } - $now = time(); - $planet = new Wootook_Empire_Model_Planet(); + $now = new Wootook_Core_DateTime(); + $planet = new Wootook_Empire_Model_Planet(array(), $this); $planet - ->setData('id_owner', $this->getId()) ->setData('name', $name) ->setData('galaxy', $galaxy) ->setData('system', $system) diff --git a/src/application/code/core/Wootook/Player/Resource/Entity/Collection.php b/src/application/code/core/Wootook/Player/Resource/Entity/Collection.php index 56fbd0f..496d991 100644 --- a/src/application/code/core/Wootook/Player/Resource/Entity/Collection.php +++ b/src/application/code/core/Wootook/Player/Resource/Entity/Collection.php @@ -1,7 +1,7 @@ array( 'database' => array( 'default' => array( - 'engine' => 'mysql', + 'engine' => 'pdo_mysql', 'options' => array( ), 'params' => array( diff --git a/src/floten1.php b/src/floten1.php index 13f1890..a3c0816 100644 --- a/src/floten1.php +++ b/src/floten1.php @@ -119,7 +119,6 @@ $session['speed'] = $speedArray; $session['consumption'] = $consumptionArray; $session['capacity'] = $capacityArray; -var_dump($_SESSION); if (empty($fleetArray)) { message($lang['fl_unselectall'], $lang['fl_error'], "fleet." . PHPEXT, 1); } else { diff --git a/src/floten2.php b/src/floten2.php index cde2b2c..1f5f728 100644 --- a/src/floten2.php +++ b/src/floten2.php @@ -132,7 +132,6 @@ $mission = isset($_POST['target_mission']) ? $_POST['target_mission'] : 0; $SpeedFactor = GetGameSpeedFactor(); $AllFleetSpeed = GetFleetMaxSpeed($fleetArray, 0, $user); -var_dump($AllFleetSpeed, $fleetArray); $MaxFleetSpeed = min($AllFleetSpeed); $distance = GetTargetDistance($planetrow->getGalaxy(), $galaxy, $planetrow->getSystem(), $system, $planetrow->getPosition(), $planet); diff --git a/src/install/index.php b/src/install/index.php index dce60e1..fab8ac6 100644 --- a/src/install/index.php +++ b/src/install/index.php @@ -109,7 +109,7 @@ if (isset($_SERVER['REQUEST_URI'])) { if ($offset == (strlen($_SERVER['REQUEST_URI']) - 1)) { $baseUrl .= substr($_SERVER['REQUEST_URI'], 0, strpos(substr($_SERVER['REQUEST_URI'], 0, -1), '/')) . '/'; } else { - $baseUrl .= substr($_SERVER['REQUEST_URI'], 0, strrpos(substr($_SERVER['REQUEST_URI'], 0, $offset), '/', strlen($_SERVER['REQUEST_URI']) - $offset - 1)) . '/'; + $baseUrl .= substr($_SERVER['REQUEST_URI'], 0, strpos(substr($_SERVER['REQUEST_URI'], 0, $offset), '/', strlen($_SERVER['REQUEST_URI']) - $offset - 1)) . '/'; } } $session = Wootook::getSession('install'); @@ -230,6 +230,7 @@ case 'install': 'web' => array( 'url' => array( 'base' => $request->getPost('url_path'), + 'link' => $request->getPost('url_path'), 'skin' => $request->getPost('url_path') . 'skin/', 'js' => $request->getPost('url_path') . 'js/', 'css' => $request->getPost('url_path') . 'css/', @@ -237,8 +238,9 @@ case 'install': ), 'system' => array( 'path' => array( - 'base' => ROOT_PATH, - 'skin' => ROOT_PATH . 'skin' . DIRECTORY_SEPARATOR, + 'base' => ROOT_PATH, + 'skin' => ROOT_PATH . 'skin' . DIRECTORY_SEPARATOR, + 'design' => ROOT_PATH . 'application' . DIRECTORY_SEPARATOR . 'design' . DIRECTORY_SEPARATOR, ), 'date' => array( 'timezone' => $request->getPost('timezone') @@ -515,7 +517,7 @@ case 'install': if ($request->getPost('email') != $request->getPost('email_confirm')) { $session->setData('step', STEP_PROFILE); - $session->setFormData($request->getData()); + $session->setFormData($request->getAllDatas()); $session->addError(Wootook::__('Both e-mails does not match.')); $response->setRedirect(Wootook::getStaticUrl('install/index.php', array('mode' => 'install', 'step' => STEP_PROFILE))); $response->sendHeaders(); @@ -526,16 +528,17 @@ case 'install': $user = Wootook_Player_Model_Entity::register($request->getPost('username'), $request->getPost('email'), $request->getPost('password')); } catch (Wootook_Empire_Exception_RuntimeException $e) { } + $layout->getMessagesBlock()->prepareMessages('user'); if (!$user || !$user->getId()) { $session->setData('step', STEP_PROFILE); - $session->setFormData($request->getData()); + $session->setFormData($request->getAllDatas()); $session->addError(Wootook::__('Could not create user.')); $response->setRedirect(Wootook::getStaticUrl('install/index.php', array('mode' => 'install', 'step' => STEP_PROFILE))); $response->sendHeaders(); exit(0); } else { - Wootook_Player_Model_Entity::setLoggedIn($user); + Wootook_Player_Model_Session::getSingleton()->setLoggedIn($user); $user->setData('authlevel', LEVEL_ADMIN)->save(); @@ -543,7 +546,7 @@ case 'install': } $session->setData('step', STEP_CONFIG); - //$response->setRedirect(Wootook::getStaticUrl('install/index.php', array('mode' => 'install', 'step' => STEP_CONFIG))); + $response->setRedirect(Wootook::getStaticUrl('install/index.php', array('mode' => 'install', 'step' => STEP_CONFIG))); $response->setRedirect(Wootook::getStaticUrl('install/index.php', array('mode' => 'summary'))); $response->sendHeaders(); exit(0);