Fixed DML queries errors
Signed-off-by: Gregory PLANCHAT <g.planchat@gmail.com>
This commit is contained in:
parent
70145967d0
commit
347952319a
27 changed files with 196 additions and 489 deletions
|
|
@ -109,9 +109,6 @@ $lang = array();
|
|||
|
||||
define('DEFAULT_LANG', 'fr');
|
||||
|
||||
include(ROOT_PATH . 'includes/debug.class.'.PHPEXT);
|
||||
$debug = new Debug();
|
||||
|
||||
include(ROOT_PATH . 'includes/functions.' . PHPEXT);
|
||||
include(ROOT_PATH . 'includes/unlocalised.' . PHPEXT);
|
||||
include(ROOT_PATH . 'includes/todofleetcontrol.' . PHPEXT);
|
||||
|
|
|
|||
|
|
@ -287,21 +287,20 @@ CREATE TABLE IF NOT EXISTS {$this->getTableName('planets')} (
|
|||
`last_update` DATETIME NOT NULL,
|
||||
`planet_type` TINYINT UNSIGNED NOT NULL,
|
||||
`destruyed` BOOL NOT NULL DEFAULT FALSE,
|
||||
`b_building` INT UNSIGNED NOT NULL,
|
||||
`b_building` DATETIME NOT NULL,
|
||||
`b_building_id` TEXT NOT NULL,
|
||||
`b_tech` INT UNSIGNED NOT NULL,
|
||||
`b_tech_id` SMALLINT UNSIGNED NOT NULL,
|
||||
`b_hangar` INT UNSIGNED NOT NULL,
|
||||
`b_tech` DATETIME NOT NULL,
|
||||
`b_tech_id` TEXT NOT NULL,
|
||||
`b_hangar` DATETIME NOT NULL,
|
||||
`b_hangar_id` TEXT NOT NULL,
|
||||
`b_hangar_plus` SMALLINT UNSIGNED NOT NULL,
|
||||
`image` VARCHAR(50) NOT NULL DEFAULT 'normaltempplanet01',
|
||||
`diameter` INT UNSIGNED NOT NULL DEFAULT 12800,
|
||||
`points` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
`ranks` BIGINT UNSIGNED NOT NULL,
|
||||
`field_current` INT UNSIGNED NOT NULL DEFAULT 163,
|
||||
`field_max` INT UNSIGNED NOT NULL DEFAULT 163,
|
||||
`temp_min` INT NOT NULL DEFAULT 0,
|
||||
`temp_max` INT NOT NULL DEFAULT 0,
|
||||
`field_current` SMALLINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`field_max` SMALLINT UNSIGNED NOT NULL DEFAULT 163,
|
||||
`temp_min` SMALLINT NOT NULL DEFAULT 0,
|
||||
`temp_max` SMALLINT NOT NULL DEFAULT 0,
|
||||
`metal` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
`metal_perhour` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
`metal_max` DECIMAL(65,0) NOT NULL DEFAULT 0,
|
||||
|
|
|
|||
|
|
@ -287,6 +287,10 @@ class Wootook
|
|||
return $preferredLocale;
|
||||
}
|
||||
|
||||
/**
|
||||
* @static
|
||||
* @return Wootook_Core_DateTime
|
||||
*/
|
||||
public static function now()
|
||||
{
|
||||
if (self::$_now === null) {
|
||||
|
|
@ -381,6 +385,7 @@ class Wootook
|
|||
->getConnection('core_read');
|
||||
} catch (Wootook_Core_Exception_Database_AdapterError $e) {
|
||||
self::$isInstalled = false;
|
||||
Wootook_Core_ErrorProfiler::getSingleton()->addException($e);
|
||||
return $config;
|
||||
}
|
||||
|
||||
|
|
@ -388,20 +393,20 @@ class Wootook
|
|||
|
||||
switch ($type) {
|
||||
case 'website':
|
||||
$select->where('website_id = :website_id');
|
||||
$select->where(new Wootook_Core_Database_Sql_Placeholder_Expression('website_id = :website_id', array('website_id' => $model->getId())));
|
||||
$statement = $adapter->prepare($select);
|
||||
$statement->execute(array('website_id' => $model->getId()));
|
||||
$statement->execute();
|
||||
break;
|
||||
|
||||
case 'game':
|
||||
$select->where('game_id = :game_id');
|
||||
$select->where(new Wootook_Core_Database_Sql_Placeholder_Expression('game_id = :game_id', array('game_id' => $model->getId())));
|
||||
$statement = $adapter->prepare($select);
|
||||
$statement->execute(array('game_id' => $model->getId()));
|
||||
$statement->execute();
|
||||
break;
|
||||
|
||||
default:
|
||||
$select->where('website_id = 0');
|
||||
$select->where('game_id = 0');
|
||||
$select->where('website_id', 0);
|
||||
$select->where('game_id', 0);
|
||||
$statement = $adapter->prepare($select);
|
||||
$statement->execute();
|
||||
break;
|
||||
|
|
@ -556,6 +561,7 @@ class Wootook
|
|||
$website = self::getWebsite($websiteId);
|
||||
} catch (Wootook_Core_Exception_WebsiteError $e) {
|
||||
self::$isInstalled = false;
|
||||
Wootook_Core_ErrorProfiler::getSingleton()->addException($e);
|
||||
|
||||
$website = new Wootook_Core_Model_Website();
|
||||
$website->setId(0)->setData('code', 'install');
|
||||
|
|
@ -609,6 +615,7 @@ class Wootook
|
|||
$game = self::getGame($gameId);
|
||||
} catch (Wootook_Core_Exception_GameError $e) {
|
||||
self::$isInstalled = false;
|
||||
Wootook_Core_ErrorProfiler::getSingleton()->addException($e);
|
||||
|
||||
$game = new Wootook_Core_Model_Game();
|
||||
$game->setId(0)->setData('code', 'install')->setData('website_id', self::getDefaultWebsite()->getId());
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ abstract class Wootook_Core_Database_Adapter_Adapter
|
|||
*/
|
||||
public function quoteInto($string, $values)
|
||||
{
|
||||
$parts = preg_split('#(\?|:[\w_]+)#', $string, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
|
||||
$parts = preg_split('#(:[\w_]+|[?])#', $string, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
|
||||
|
||||
$result = '';
|
||||
if (is_array($values)) {
|
||||
|
|
@ -97,7 +97,7 @@ abstract class Wootook_Core_Database_Adapter_Adapter
|
|||
foreach ($parts as $part) {
|
||||
if ($part == '?') {
|
||||
$result .= $this->quote($values[$index++]);
|
||||
} else if ($part[0] == ':') {
|
||||
} else if (!empty($part) && $part[0] == ':') {
|
||||
$key = substr($part, 1);
|
||||
|
||||
if (isset($values[$key])) {
|
||||
|
|
@ -127,9 +127,9 @@ abstract class Wootook_Core_Database_Adapter_Adapter
|
|||
/**
|
||||
* @return Wootook_Core_Database_Statement_Statement
|
||||
*/
|
||||
public function query($sql)
|
||||
public function query($sql, Array $params = null)
|
||||
{
|
||||
$statement = $this->prepare($sql);
|
||||
$statement = $this->prepare($sql, $params);
|
||||
if (!$statement->execute()) {
|
||||
$message = sprintf('[SQLSTATE %s] Could not execute query: %s', $statement->errorState(), $statement->errorMessage());
|
||||
throw new Wootook_Core_Exception_Database_StatementError($statement, $message);
|
||||
|
|
@ -141,16 +141,16 @@ abstract class Wootook_Core_Database_Adapter_Adapter
|
|||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function execute($sql)
|
||||
public function execute($sql, Array $params = null)
|
||||
{
|
||||
$statement = $this->prepare($sql);
|
||||
return $statement->execute();
|
||||
return $statement->execute($params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Wootook_Core_Database_Statement_Statement
|
||||
*/
|
||||
abstract public function prepare($sql);
|
||||
abstract public function prepare($sql, Array $params = null);
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
|
|
|
|||
|
|
@ -67,9 +67,17 @@ class Wootook_Core_Database_Adapter_Pdo_Mysql
|
|||
/**
|
||||
* @return Wootook_Core_Database_Statement_Statement
|
||||
*/
|
||||
public function prepare($sql)
|
||||
public function prepare($sql, Array $params = null)
|
||||
{
|
||||
return new Wootook_Core_Database_Statement_Pdo_Mysql($this, $sql);
|
||||
$statement = new Wootook_Core_Database_Statement_Pdo_Mysql($this, $sql);
|
||||
|
||||
if ($params !== null) {
|
||||
foreach ($params as $paramKey => $paramValue) {
|
||||
$statement->bindValue($paramKey, $paramValue, $statement->getParamType($paramValue));
|
||||
}
|
||||
}
|
||||
|
||||
return $statement;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -3,11 +3,12 @@
|
|||
class Wootook_Core_Database_Sql_Delete
|
||||
extends Wootook_Core_Database_Sql_DmlFilterableQuery
|
||||
{
|
||||
const SET = 'SET';
|
||||
const INTO = 'INTO';
|
||||
const FROM = 'FROM';
|
||||
|
||||
protected function _init($tableName = null)
|
||||
{
|
||||
parent::_init($tableName);
|
||||
|
||||
if ($tableName !== null) {
|
||||
$this->into($tableName);
|
||||
}
|
||||
|
|
@ -19,8 +20,10 @@ class Wootook_Core_Database_Sql_Delete
|
|||
{
|
||||
if ($part === null) {
|
||||
$this->_parts = array(
|
||||
self::INTO => array(),
|
||||
self::SET => array(),
|
||||
self::FROM => null,
|
||||
self::WHERE => array(),
|
||||
self::OFFSET => null,
|
||||
self::LIMIT => null,
|
||||
);
|
||||
} else if (isset($this->_parts[$part])) {
|
||||
$this->_parts[$part] = array();
|
||||
|
|
@ -29,25 +32,11 @@ class Wootook_Core_Database_Sql_Delete
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function set($column, $value)
|
||||
public function from($table, $schema = null)
|
||||
{
|
||||
if ($value instanceof Wootook_Core_Database_Sql_Placeholder_Placeholder) {
|
||||
$this->_placeholders[] = $column;
|
||||
}
|
||||
|
||||
$this->_parts[self::COLUMNS][] = array(
|
||||
'value' => $value,
|
||||
'field' => $column
|
||||
);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function into($table, $schema = null)
|
||||
{
|
||||
$this->_parts[self::INTO] = array(
|
||||
$this->_parts[self::FROM] = array(
|
||||
'table' => $table,
|
||||
'schema' => $schema,
|
||||
'schema' => $schema
|
||||
);
|
||||
|
||||
return $this;
|
||||
|
|
@ -65,56 +54,36 @@ class Wootook_Core_Database_Sql_Delete
|
|||
}
|
||||
|
||||
switch ($part) {
|
||||
case self::COLUMNS:
|
||||
return $this->renderSet();
|
||||
case self::FROM:
|
||||
return $this->renderFrom();
|
||||
break;
|
||||
case self::INTO:
|
||||
return $this->renderInto();
|
||||
case self::WHERE:
|
||||
return $this->renderWhere();
|
||||
break;
|
||||
case self::WHERE:
|
||||
return $this->renderWhere();
|
||||
break;
|
||||
case self::LIMIT:
|
||||
return $this->renderLimit();
|
||||
break;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function renderSet()
|
||||
public function renderFrom()
|
||||
{
|
||||
$fields = array();
|
||||
foreach ($this->_parts[self::SET] as $field) {
|
||||
if ($field['value'] instanceof Wootook_Core_Database_Sql_Placeholder_Placeholder) {
|
||||
$fields[] = "{$this->_connection->quoteIdentifier($field['field'])}={$field['value']->toString()}";
|
||||
} else {
|
||||
$fields[] = "{$this->_connection->quoteIdentifier($field['field'])}={$this->_connection->quote($field['value'])}";
|
||||
if ($this->_parts[self::FROM]['schema'] !== null) {
|
||||
return "DELETE FROM {$this->getConnection()->quoteIdentifier($this->_parts[self::FROM]['schema'])}.{$this->getConnection()->quoteIdentifier($this->_parts[self::FROM]['schema'])}";
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($fields)) {
|
||||
return "\nSET " . implode(", ", $fields);
|
||||
}
|
||||
}
|
||||
|
||||
public function renderInto()
|
||||
{
|
||||
if ($this->_parts[self::INTO]['schema'] !== null) {
|
||||
$output = "{$this->_connection->quoteIdentifier($this->_parts[self::INTO]['schema'])}.{$this->_connection->quoteIdentifier($this->_parts[self::INTO]['table'])}";
|
||||
} else {
|
||||
$output = "{$this->_connection->quoteIdentifier($this->_parts[self::INTO]['table'])}";
|
||||
}
|
||||
|
||||
return "INSERT INTO " . $output;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
if (empty($this->_parts[self::SELECT])) {
|
||||
return implode('', array(
|
||||
$this->renderInto(),
|
||||
$this->renderColumns(),
|
||||
));
|
||||
} else {
|
||||
return implode('', array(
|
||||
$this->renderInto(),
|
||||
$this->renderSelect(),
|
||||
return implode("\n", array(
|
||||
$this->renderFrom(),
|
||||
$this->renderWhere(),
|
||||
$this->renderLimit(),
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,18 +28,15 @@ abstract class Wootook_Core_Database_Sql_DmlFilterableQuery
|
|||
if ($condition instanceof Wootook_Core_Database_Sql_Placeholder_Placeholder) {
|
||||
$this->_placeholders[] = $condition;
|
||||
$this->_parts[self::WHERE][] = $condition;
|
||||
} else if (is_string($condition)) {
|
||||
if ($value === null) {
|
||||
$this->_parts[self::WHERE][] = $condition;
|
||||
} else {
|
||||
$adapter = $this->getReadConnection();
|
||||
$this->_parts[self::WHERE][] = $adapter->quoteInto($condition, $value);
|
||||
}
|
||||
} else if (is_array($condition)) {
|
||||
} else if (is_array($value)) {
|
||||
$where = $this->_translateSqlWhere($condition, 'or', $value);
|
||||
if ($where !== null) {
|
||||
$this->_parts[self::WHERE][] = $where;
|
||||
}
|
||||
} else if ($value instanceof Wootook_Core_Database_Sql_Placeholder_Placeholder) {
|
||||
$this->_parts[self::WHERE][] = "{$this->getConnection()->quoteIdentifier($condition)}=" . $value;
|
||||
} else {
|
||||
$this->_parts[self::WHERE][] = $this->getConnection()->quoteInto("{$this->getConnection()->quoteIdentifier($condition)}=?", $value);
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
|
@ -59,7 +56,7 @@ abstract class Wootook_Core_Database_Sql_DmlFilterableQuery
|
|||
return '';
|
||||
}
|
||||
|
||||
return "\nWHERE (" . implode(') AND (', $this->_parts[self::WHERE]) . ')';
|
||||
return " WHERE (" . implode(")\n AND (", $this->_parts[self::WHERE]) . ')';
|
||||
}
|
||||
|
||||
public function renderLimit()
|
||||
|
|
@ -68,9 +65,9 @@ abstract class Wootook_Core_Database_Sql_DmlFilterableQuery
|
|||
return '';
|
||||
}
|
||||
if (!$this->_parts[self::OFFSET]) {
|
||||
return sprintf("\nLIMIT %d", $this->_parts[self::LIMIT]);
|
||||
return sprintf(" LIMIT %d", $this->_parts[self::LIMIT]);
|
||||
}
|
||||
return sprintf("\nLIMIT %d,%d", $this->_parts[self::LIMIT], $this->_parts[self::OFFSET]);
|
||||
return sprintf(" LIMIT %d,%d", $this->_parts[self::LIMIT], $this->_parts[self::OFFSET]);
|
||||
}
|
||||
|
||||
protected function _translateSqlWhere($field, $operator, $value)
|
||||
|
|
@ -79,7 +76,7 @@ abstract class Wootook_Core_Database_Sql_DmlFilterableQuery
|
|||
return null;
|
||||
}
|
||||
$operator = strtoupper($operator);
|
||||
$adapter = $this->getReadConnection();
|
||||
$adapter = $this->getConnection();
|
||||
|
||||
$basicBinayOperatorList = array(
|
||||
self::OPERATOR_EQUALS => '=',
|
||||
|
|
|
|||
|
|
@ -61,11 +61,10 @@ abstract class Wootook_Core_Database_Sql_DmlQuery
|
|||
|
||||
public function beforePrepare(Wootook_Core_Database_Statement_Statement $statement)
|
||||
{
|
||||
/*
|
||||
foreach ($this->_placeholders as $placeholder) {
|
||||
$placeholder->beforePrepare($statement);
|
||||
}
|
||||
*/
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -101,8 +100,8 @@ abstract class Wootook_Core_Database_Sql_DmlQuery
|
|||
return $this->getConnection()->prepare($this);
|
||||
}
|
||||
|
||||
public function execute()
|
||||
public function execute(Array $params = null)
|
||||
{
|
||||
return $this->getConnection()->execute($this);
|
||||
return $this->getConnection()->execute($this, $params);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ class Wootook_Core_Database_Sql_Insert
|
|||
|
||||
protected function _init($tableName = null)
|
||||
{
|
||||
parent::_init($tableName);
|
||||
|
||||
if ($tableName !== null) {
|
||||
$this->into($tableName);
|
||||
}
|
||||
|
|
@ -38,8 +40,8 @@ class Wootook_Core_Database_Sql_Insert
|
|||
}
|
||||
|
||||
foreach ($column as $field => $value) {
|
||||
if ($field instanceof Wootook_Core_Database_Sql_Placeholder_Placeholder) {
|
||||
$this->_placeholders[] = $field;
|
||||
if ($value instanceof Wootook_Core_Database_Sql_Placeholder_Placeholder) {
|
||||
$this->_placeholders[] = $value;
|
||||
}
|
||||
|
||||
$this->_parts[self::SET][] = array(
|
||||
|
|
@ -108,7 +110,7 @@ class Wootook_Core_Database_Sql_Insert
|
|||
}
|
||||
|
||||
if (!empty($fields)) {
|
||||
return "\nSET " . implode(", ", $fields);
|
||||
return "SET " . implode(", ", $fields);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -134,12 +136,12 @@ class Wootook_Core_Database_Sql_Insert
|
|||
public function render()
|
||||
{
|
||||
if (empty($this->_parts[self::SELECT])) {
|
||||
return implode('', array(
|
||||
return implode("\n", array(
|
||||
$this->renderInto(),
|
||||
$this->renderColumns(),
|
||||
$this->renderSet(),
|
||||
));
|
||||
} else {
|
||||
return implode('', array(
|
||||
return implode("\n", array(
|
||||
$this->renderInto(),
|
||||
$this->renderSelect(),
|
||||
));
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ class Wootook_Core_Database_Sql_Placeholder_Expression
|
|||
protected $_expression = null;
|
||||
protected $_params = array();
|
||||
|
||||
public function __construct($expression, Array $params)
|
||||
public function __construct($expression, Array $params = array())
|
||||
{
|
||||
$this->_expression = (string) $expression;
|
||||
$this->_params = $params;
|
||||
|
|
@ -22,7 +22,7 @@ class Wootook_Core_Database_Sql_Placeholder_Expression
|
|||
parent::beforeExecute($statement);
|
||||
|
||||
foreach ($this->_params as $paramName => $value) {
|
||||
$statement->bindValue($paramName, $value);
|
||||
$statement->bindValue($paramName, $value, $statement->getParamType($value));
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
|
|
|||
|
|
@ -3,12 +3,14 @@
|
|||
class Wootook_Core_Database_Sql_Placeholder_Param
|
||||
extends Wootook_Core_Database_Sql_Placeholder_Placeholder
|
||||
{
|
||||
protected $_paramType = null;
|
||||
protected $_paramName = null;
|
||||
protected $_value = null;
|
||||
|
||||
public function __construct($paramName, $value)
|
||||
public function __construct($paramName, $value, $type = null)
|
||||
{
|
||||
$this->_paramName = $paramName;
|
||||
$this->_paramType = $type;
|
||||
$this->_value = $value;
|
||||
}
|
||||
|
||||
|
|
@ -17,20 +19,11 @@ class Wootook_Core_Database_Sql_Placeholder_Param
|
|||
return ':' . $this->_paramName;
|
||||
}
|
||||
|
||||
public function beforeExcute(Wootook_Core_Database_Statement_Statement $statement)
|
||||
public function beforeExecute(Wootook_Core_Database_Statement_Statement $statement)
|
||||
{
|
||||
parent::beforeExcute($statement);
|
||||
|
||||
if (is_numeric($this->_value)) {
|
||||
$type = Wootook_Core_Database_ConnectionManager::PARAM_INT;
|
||||
} else if (is_bool($this->_value)) {
|
||||
$type = Wootook_Core_Database_ConnectionManager::PARAM_BOOL;
|
||||
} else if (is_string($this->_value)) {
|
||||
$type = Wootook_Core_Database_ConnectionManager::PARAM_STR;
|
||||
} else {
|
||||
$type = null;
|
||||
}
|
||||
parent::beforeExecute($statement);
|
||||
|
||||
$type = $this->_paramType !== null ? $this->_paramType : $statement->getParamType($this->_value);
|
||||
$statement->bindValue($this->_paramName, $this->_value, $type);
|
||||
|
||||
return $this;
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ class Wootook_Core_Database_Sql_Select
|
|||
|
||||
protected function _init($tableName = null)
|
||||
{
|
||||
parent::_init($tableName);
|
||||
|
||||
if ($tableName !== null) {
|
||||
$this->from($tableName);
|
||||
}
|
||||
|
|
@ -263,7 +265,7 @@ class Wootook_Core_Database_Sql_Select
|
|||
}
|
||||
}
|
||||
|
||||
return "\nFROM " . implode(', ', $tables);
|
||||
return " FROM " . implode(', ', $tables);
|
||||
}
|
||||
|
||||
public function renderJoin()
|
||||
|
|
@ -276,7 +278,7 @@ class Wootook_Core_Database_Sql_Select
|
|||
if (count($this->_parts[self::ORDER]) <= 0) {
|
||||
return null;
|
||||
}
|
||||
return "\n ORDER BY " . implode(', ', $this->_parts[self::ORDER]);
|
||||
return " ORDER BY " . implode(', ', $this->_parts[self::ORDER]);
|
||||
}
|
||||
|
||||
public function renderUnion()
|
||||
|
|
@ -286,7 +288,7 @@ class Wootook_Core_Database_Sql_Select
|
|||
$statements[] = $statement->render();
|
||||
}
|
||||
|
||||
return "(" . implode(")\nUNION\n(", $statements) . ")";
|
||||
return " (\n" . implode(" )\n UNION\n (\n", $statements) . "\n )";
|
||||
}
|
||||
|
||||
public function renderGroup()
|
||||
|
|
@ -294,7 +296,7 @@ class Wootook_Core_Database_Sql_Select
|
|||
if (count($this->_parts[self::GROUP]) <= 0) {
|
||||
return null;
|
||||
}
|
||||
return "\n GROUP BY " . implode(', ', $this->_parts[self::GROUP]);
|
||||
return " GROUP BY " . implode(', ', $this->_parts[self::GROUP]);
|
||||
}
|
||||
|
||||
public function renderHaving()
|
||||
|
|
@ -302,13 +304,13 @@ class Wootook_Core_Database_Sql_Select
|
|||
if (count($this->_parts[self::HAVING]) <= 0) {
|
||||
return null;
|
||||
}
|
||||
return "\n HAVING " . implode(', ', $this->_parts[self::HAVING]);
|
||||
return " HAVING " . implode(', ', $this->_parts[self::HAVING]);
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
if (empty($this->_parts[self::UNION])) {
|
||||
return implode('', array(
|
||||
return implode("\n", array(
|
||||
$this->renderColumns(),
|
||||
$this->renderFrom(),
|
||||
$this->renderJoin(),
|
||||
|
|
@ -319,7 +321,7 @@ class Wootook_Core_Database_Sql_Select
|
|||
$this->renderLimit()
|
||||
));
|
||||
} else {
|
||||
return implode('', array(
|
||||
return implode("\n", array(
|
||||
$this->renderUnion(),
|
||||
$this->renderWhere(),
|
||||
$this->renderOrder(),
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ class Wootook_Core_Database_Sql_Update
|
|||
|
||||
protected function _init($tableName = null)
|
||||
{
|
||||
parent::_init($tableName);
|
||||
|
||||
if ($tableName !== null) {
|
||||
$this->into($tableName);
|
||||
}
|
||||
|
|
@ -39,8 +41,8 @@ class Wootook_Core_Database_Sql_Update
|
|||
}
|
||||
|
||||
foreach ($column as $field => $value) {
|
||||
if ($field instanceof Wootook_Core_Database_Sql_Placeholder_Placeholder) {
|
||||
$this->_placeholders[] = $field;
|
||||
if ($value instanceof Wootook_Core_Database_Sql_Placeholder_Placeholder) {
|
||||
$this->_placeholders[] = $value;
|
||||
}
|
||||
|
||||
$this->_parts[self::SET][] = array(
|
||||
|
|
@ -87,20 +89,17 @@ class Wootook_Core_Database_Sql_Update
|
|||
|
||||
public function renderSet()
|
||||
{
|
||||
$values = array();
|
||||
$fields = array();
|
||||
foreach ($this->_parts[self::SET] as $field) {
|
||||
if ($field['value'] instanceof Wootook_Core_Database_Sql_Placeholder_Placeholder) {
|
||||
$values[] = $field['value']->toString();
|
||||
$fields[] = $this->_connection->quoteIdentifier($field['field']);
|
||||
$fields[] = "{$this->_connection->quoteIdentifier($field['field'])}={$field['value']->toString()}";
|
||||
} else {
|
||||
$values[] = $this->_connection->quote($field['value']);
|
||||
$fields[] = $this->_connection->quoteIdentifier($field['field']);
|
||||
$fields[] = "{$this->_connection->quoteIdentifier($field['field'])}={$this->_connection->quote($field['value'])}";
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($fields)) {
|
||||
return ' (' . implode(', ', $fields). ")\nVALUES (" . implode(", ", $values) . ')';
|
||||
return ' SET ' . implode(', ', $fields);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -117,7 +116,7 @@ class Wootook_Core_Database_Sql_Update
|
|||
|
||||
public function render()
|
||||
{
|
||||
return implode('', array(
|
||||
return implode("\n", array(
|
||||
$this->renderInto(),
|
||||
$this->renderSet(),
|
||||
$this->renderWhere(),
|
||||
|
|
|
|||
|
|
@ -171,6 +171,19 @@ abstract class Wootook_Core_Database_Statement_Statement
|
|||
*/
|
||||
abstract public function nextRowset();
|
||||
|
||||
public function getParamType($value)
|
||||
{
|
||||
if (is_numeric($value)) {
|
||||
return Wootook_Core_Database_ConnectionManager::PARAM_INT;
|
||||
} else if (is_bool($value)) {
|
||||
return Wootook_Core_Database_ConnectionManager::PARAM_BOOL;
|
||||
} else if (is_string($value)) {
|
||||
return Wootook_Core_Database_ConnectionManager::PARAM_STR;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function current()
|
||||
{
|
||||
return $this->_currentRow;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,15 @@ class Wootook_Core_Mvc_Controller_Request_Http
|
|||
parent::__construct($options);
|
||||
|
||||
$this->_baseUrl = Wootook::getBaseUrl('link');
|
||||
$baseUri = substr($this->_baseUrl, strpos($this->_baseUrl, '/', 8)); // Get the path from the DocumentRoot
|
||||
if ($this->_baseUrl === null) {
|
||||
$this->_baseUrl = 'http://' . $this->getServer('HTTP_HOST') . $this->getServer('REQUEST_URI');
|
||||
}
|
||||
$offset = strpos($this->_baseUrl, '/', 8);
|
||||
if ($offset !== false) {
|
||||
$baseUri = substr($this->_baseUrl, $offset); // Get the path from the DocumentRoot
|
||||
} else {
|
||||
$baseUri = '/';
|
||||
}
|
||||
|
||||
$params = '';
|
||||
if (($offset = strpos($this->getServer('REQUEST_URI'), $baseUri)) !== false) {
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ abstract class Wootook_Core_Mvc_Model_Entity
|
|||
|
||||
$select = $database->select()
|
||||
->from(array('main_table' => $database->getTable($this->getTableName())))
|
||||
->where("{$database->quoteIdentifier($idFieldName)}=:id")
|
||||
->where($idFieldName, new Wootook_Core_Database_Sql_Placeholder_Param('id', $id))
|
||||
->limit(1);
|
||||
|
||||
$statement = $select->prepare();
|
||||
|
|
@ -97,7 +97,7 @@ abstract class Wootook_Core_Mvc_Model_Entity
|
|||
->into($adapter->getTable($this->getTableName()));
|
||||
|
||||
foreach ($this->getDataMapper()->encode($this, $this->getAllDatas()) as $field => $value) {
|
||||
$insert->set($field, new Wootook_Core_Database_Sql_Placeholder_Param($field, $value, $type));
|
||||
$insert->set($field, new Wootook_Core_Database_Sql_Placeholder_Param($field, $value));
|
||||
}
|
||||
try {
|
||||
$statement = $insert->prepare();
|
||||
|
|
@ -117,28 +117,25 @@ abstract class Wootook_Core_Mvc_Model_Entity
|
|||
|
||||
protected function _delete()
|
||||
{
|
||||
$fields = array();
|
||||
foreach ($this->getAllDatas() as $field => $value) {
|
||||
if ($field == $this->getIdFieldName()) {
|
||||
continue;
|
||||
$adapter = $this->getWriteConnection();
|
||||
if ($adapter === null) {
|
||||
throw new Wootook_Core_Exception_DataAccessException('Could not delete data: no write connection configured.');
|
||||
}
|
||||
$fields[] = "{$field}=:{$field}";
|
||||
$delete = $adapter
|
||||
->delete()
|
||||
->from($adapter->getTable($this->getTableName()))
|
||||
->where($this->getIdFieldName(), $this->getId())
|
||||
->limit(1);
|
||||
|
||||
try {
|
||||
$statement = $adapter->prepare($delete);
|
||||
$statement->execute();
|
||||
} catch (Wootook_Core_Exception_Database_AdapterError $e) {
|
||||
throw new Wootook_Core_Exception_DataAccessException('Could not delete data: ' . $e->getMessage(), null, $e);
|
||||
} catch (Wootook_Core_Exception_Database_StatementError $e) {
|
||||
throw new Wootook_Core_Exception_DataAccessException('Could not delete data: ' . $e->getMessage(), null, $e);
|
||||
}
|
||||
|
||||
$fieldsImploded = implod(', ', $fields);
|
||||
$idFieldName = $this->getIdFieldName();
|
||||
$database = $this->getWriteConnection();
|
||||
if ($database === null) {
|
||||
throw new Wootook_Core_Exception_DataAccessException('Could not load data: no write connection configured.');
|
||||
}
|
||||
|
||||
$sql =<<<SQL_EOF
|
||||
DELETE {$database->getTable($this->getTableName())}
|
||||
WHERE {$idFieldName}=:{$idFieldName}
|
||||
SQL_EOF;
|
||||
|
||||
$statement->execute($this->getAllDatas());
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -178,10 +178,12 @@ class Wootook_Core_Mvc_View_View
|
|||
|
||||
public function getSkinUrl($uri, Array $params = array(), $theme = null, $package = null)
|
||||
{
|
||||
if (Wootook::$isInstalled) {
|
||||
$player = Wootook_Player_Model_Session::getSingleton()->getPlayer();
|
||||
if ($player !== null && $player->getId()) {
|
||||
$theme = $player->getSkinPath();
|
||||
}
|
||||
}
|
||||
if ($theme === null || empty($theme)) {
|
||||
$theme = $this->getLayout()->getTheme();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,8 @@ abstract class Wootook_Core_Resource_EntityCollection
|
|||
{
|
||||
if ($this->_select === null) {
|
||||
$this->_select = $this->getReadConnection()
|
||||
->select(array('main_table' => $this->getReadConnection()->getTable($this->_entityTable)));
|
||||
->select()
|
||||
->from(array('main_table' => $this->getReadConnection()->getTable($this->_entityTable)));
|
||||
|
||||
$this->_prepareSelect($this->_select);
|
||||
}
|
||||
|
|
@ -64,6 +65,9 @@ abstract class Wootook_Core_Resource_EntityCollection
|
|||
return $this->_dataMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Wootook_Core_Database_Adapter_Adapter
|
||||
*/
|
||||
public function getReadConnection()
|
||||
{
|
||||
return $this->_connection;
|
||||
|
|
@ -127,8 +131,7 @@ abstract class Wootook_Core_Resource_EntityCollection
|
|||
}
|
||||
}
|
||||
|
||||
$database = $this->getReadConnection();
|
||||
$statement = $database->prepare($select);
|
||||
$statement = $select->prepare();
|
||||
|
||||
$args = func_get_args();
|
||||
$statement->execute(array_shift($args));
|
||||
|
|
@ -224,155 +227,13 @@ abstract class Wootook_Core_Resource_EntityCollection
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function addFieldToFilter($field, $value)
|
||||
public function addFieldToFilter($field, $value = null)
|
||||
{
|
||||
$adapter = $this->getReadConnection();
|
||||
|
||||
if (is_array($value)) {
|
||||
$where = $this->_translateSqlWhere($field, 'or', $value);
|
||||
|
||||
if ($where !== null) {
|
||||
$this->getSelect()->where($where);
|
||||
}
|
||||
} else {
|
||||
$this->getSelect()->where("{$adapter->quoteIdentifier($field)}={$adapter->quote($value)}");
|
||||
}
|
||||
$this->getSelect()->where($field, $value);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function _translateSqlWhere($field, $operator, $value)
|
||||
{
|
||||
if ($value === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$adapter = $this->getReadConnection();
|
||||
|
||||
$simpleOperatorList = array(
|
||||
'eq' => '=',
|
||||
'neq' => '!=',
|
||||
'lt' => '<',
|
||||
'gt' => '>',
|
||||
'lteq' => '<=',
|
||||
'gteq' => '>='
|
||||
);
|
||||
|
||||
if (in_array($operator, $simpleOperatorList)) {
|
||||
if ($value === true) {
|
||||
return "{$adapter->quoteIdentifier($field)}{$simpleOperatorList[$operator]}TRUE";
|
||||
} else if ($value === false) {
|
||||
return "{$adapter->quoteIdentifier($field)}{$simpleOperatorList[$operator]}FALSE";
|
||||
} else {
|
||||
return "{$adapter->quoteIdentifier($field)}{$simpleOperatorList[$operator]}{$adapter->quote($value)}";
|
||||
}
|
||||
}
|
||||
|
||||
switch (strtolower($operator)) {
|
||||
case 'null':
|
||||
if ($value == false) {
|
||||
return "{$adapter->quoteIdentifier($field)} IS NOT NULL";
|
||||
} else {
|
||||
return "{$adapter->quoteIdentifier($field)} IS NULL";
|
||||
}
|
||||
break;
|
||||
|
||||
case 'and':
|
||||
case 'or':
|
||||
case 'xor':
|
||||
$where = array();
|
||||
foreach ($value as $valueItem) {
|
||||
$subOperator = key($valueItem);
|
||||
$realValue = current($valueItem);
|
||||
|
||||
if (is_array($realValue) && isset($realValue['field'])) {
|
||||
if (!isset($realValue['value'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$realField = $realValue['field'];
|
||||
$realValue = $realValue['value'];
|
||||
} else {
|
||||
$realField = $field;
|
||||
}
|
||||
|
||||
if ($realValue === null) {
|
||||
continue;
|
||||
}
|
||||
$actualValue = $this->_translateSqlWhere($realField, $subOperator, $realValue);
|
||||
if ($actualValue !== null) {
|
||||
$where[] = $actualValue;
|
||||
}
|
||||
}
|
||||
|
||||
if (count($where)) {
|
||||
return '((' . implode(') ' . strtoupper($operator) . ' (', $where) . '))';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'in':
|
||||
$valueList = array();
|
||||
foreach ($value as $setValue) {
|
||||
$valueList[] = $adapter->quote($setValue);
|
||||
}
|
||||
$implodedList = implode(',', $valueList);
|
||||
return "{$adapter->quoteIdentifier($field)} IN({$implodedList})";
|
||||
break;
|
||||
|
||||
case 'nin':
|
||||
$valueList = array();
|
||||
foreach ($value as $setValue) {
|
||||
$valueList[] = $adapter->quote($setValue);
|
||||
}
|
||||
$implodedList = implode(',', $valueList);
|
||||
return "{$adapter->quoteIdentifier($field)} NOT IN({$implodedList})";
|
||||
break;
|
||||
|
||||
case 'finset':
|
||||
if (is_array($value)) {
|
||||
$subField = current($value);
|
||||
$subOperator = key($value);
|
||||
|
||||
if (in_array($subOperator, $simpleOperatorList)) {
|
||||
return "FIND_IN_SET({$adapter->quote($value)}, {$adapter->quoteIdentifier($field)}){$simpleOperatorList[$operator]}{$adapter->quoteIdentifier($subField)}";
|
||||
}
|
||||
} else {
|
||||
return "0 < FIND_IN_SET({$adapter->quote($value)}, {$adapter->quoteIdentifier($field)})";
|
||||
}
|
||||
break;
|
||||
|
||||
case 'nfinset':
|
||||
return "0 = FIND_IN_SET({$adapter->quote($value)}, {$adapter->quoteIdentifier($field)})";
|
||||
break;
|
||||
|
||||
case 'date':
|
||||
$dateValues = array();
|
||||
if (isset($value['from'])) {
|
||||
if ($value['from'] instanceof Wootook_Core_DateTime) {
|
||||
$dateValues['from'] = "{$adapter->quoteIdentifier($field)} >= {$adapter->quote($this->getDataMapper()->load('DateTime')->encode($value['from']))}";
|
||||
} else if (is_string($value['from'])) {
|
||||
$dateValues['from'] = "{$adapter->quoteIdentifier($field)} >= {$adapter->quote($value['from'])}";
|
||||
} else if (is_numeric($value['from'])) {
|
||||
$dateValues['from'] = "UNIX_TIMESTAMP({$adapter->quoteIdentifier($field)}) >= {$adapter->quote($value['from'])}";
|
||||
}
|
||||
}
|
||||
if (isset($value['to'])) {
|
||||
if ($value['to'] instanceof Wootook_Core_DateTime) {
|
||||
$dateValues['to'] = "{$adapter->quoteIdentifier($field)} <= {$adapter->quote($this->getDataMapper()->load('DateTime')->encode($value['to']))}";
|
||||
} else if (is_string($value['to'])) {
|
||||
$dateValues['to'] = "{$adapter->quoteIdentifier($field)} <= {$adapter->quote($value['to'])}";
|
||||
} else if (is_numeric($value['to'])) {
|
||||
$dateValues['to'] = "UNIX_TIMESTAMP({$adapter->quoteIdentifier($field)}) <= {$adapter->quote($value['to'])}";
|
||||
}
|
||||
}
|
||||
|
||||
return '(' . implode(' AND ', $dateValues) . ')';
|
||||
break;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function setPage($curPage, $pageSize)
|
||||
{
|
||||
$this->setCurPage($curPage)->setPageSize($pageSize);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ class Wootook_Empire_Resource_Fleet_Collection
|
|||
{
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_init(array('fleet' => 'fleets'), 'Wootook_Empire_Model_Fleet');
|
||||
$this->_init('fleets', 'Wootook_Empire_Model_Fleet');
|
||||
}
|
||||
|
||||
public function addPlanetToFilter(Wootook_Empire_Model_Planet $planet, $time = null)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ class Wootook_Empire_Resource_Planet_Collection
|
|||
{
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_init(array('planet' => 'planets'), 'Wootook_Empire_Model_Planet');
|
||||
$this->_init('planets', 'Wootook_Empire_Model_Planet');
|
||||
}
|
||||
|
||||
public function addPlayerToFilter(Wootook_Player_Model_Entity $player)
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ class Wootook_Player_Model_Entity
|
|||
$systemInfo['system'],
|
||||
$finalPosition,
|
||||
Wootook_Empire_Model_Planet::TYPE_PLANET,
|
||||
Wootook::getRequest()->getParam('planet'),
|
||||
Wootook::__('Planet'),
|
||||
Wootook::getGameConfig('resource/initial/fields')
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -85,7 +85,8 @@ class Wootook_Player_Model_Session
|
|||
throw new Wootook_Core_Exception_DataAccessException('Session error.', null, $e);
|
||||
}
|
||||
} else {
|
||||
throw new Wootook_Player_Exception_Session('Your session has expired, please login.');
|
||||
//throw new Wootook_Player_Exception_Session('Your session has expired, please login.');
|
||||
return $this->_player;
|
||||
}
|
||||
} catch (Wootook_Player_Exception_Session $e) {
|
||||
$this->addError($e->getMessage());
|
||||
|
|
@ -141,10 +142,10 @@ class Wootook_Player_Model_Session
|
|||
'login_rememberme' => new Wootook_Core_Database_Sql_Placeholder_Expression('CONCAT((@salt:=MID(MD5(RAND()), 0, 4)), SHA1(CONCAT(user.username, user.password, @salt)))'),
|
||||
'login_success' => new Wootook_Core_Database_Sql_Placeholder_Expression("(CASE WHEN user.password={$adapter->quote($passwordHash)} THEN 1 ELSE 0 END)")
|
||||
))
|
||||
->where('user.username=:username');
|
||||
->where(new Wootook_Core_Database_Sql_Placeholder_Expression('user.username=:username', array('username' => $username)));
|
||||
|
||||
$statement = $adapter->prepare($select);
|
||||
if (!$statement->execute(array('username' => $username))) {
|
||||
if (!$statement->execute()) {
|
||||
$this->addError(Wootook::__('No such user.'));
|
||||
return $this->_player;
|
||||
}
|
||||
|
|
@ -163,8 +164,8 @@ class Wootook_Player_Model_Session
|
|||
if (intval($login['login_success']) == 1) {
|
||||
$this->_player->load($login['id']);
|
||||
|
||||
if ($login['banaday'] != 0) {
|
||||
if ($login['banaday'] <= time()) {
|
||||
if ($login['is_banned'] != 0) {
|
||||
if ($login['is_banned'] <= time()) {
|
||||
$this->_player->setData('banaday', 0)
|
||||
->setData('bana', 0)
|
||||
->setData('urlaubs_modus', 0)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ class Wootook_Player_Resource_Entity_Collection
|
|||
{
|
||||
public function _construct()
|
||||
{
|
||||
$this->_init(array('user' => 'users'), 'Wootook_Player_Model_Entity');
|
||||
$this->_init('users', 'Wootook_Player_Model_Entity');
|
||||
}
|
||||
|
||||
public function addAuthlevelToFilter(Array $levels, $exclude = false)
|
||||
|
|
@ -21,8 +21,12 @@ class Wootook_Player_Resource_Entity_Collection
|
|||
|
||||
public function addIsOnlineToFilter($onlineTime = 900)
|
||||
{
|
||||
$onlineTime = (int) $onlineTime;
|
||||
|
||||
if ($onlineTime > 0) {
|
||||
$this->getSelect()->where("user.onlinetime>(UNIX_TIMESTAMP() - {$this->getReadConnection()->quote($onlineTime)}))");
|
||||
$this->addFieldToFilter('onlinetime', array(array(
|
||||
'gt' => new Wootook_Core_Database_Sql_Placeholder_Expression('UNIX_TIMESTAMP() - :online_time))', array('online_time' => $onlineTime))
|
||||
)));
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ class Wootook_Player_Resource_Message_Collection
|
|||
{
|
||||
public function _construct()
|
||||
{
|
||||
$this->_init(array('message' => 'messages'), 'Wootook_Player_Model_Message');
|
||||
$this->_init('messages', 'Wootook_Player_Model_Message');
|
||||
}
|
||||
|
||||
public function addPlayerToFilter(Wootook_Player_Model_Entity $player)
|
||||
|
|
|
|||
|
|
@ -1,154 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Wootook
|
||||
*
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
* @see http://wootook.org/
|
||||
*
|
||||
* Copyright (c) 2009-Present, Wootook Support Team <http://wootook.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* --> NOTICE <--
|
||||
* This file is part of the core development branch, changing its contents will
|
||||
* make you unable to use the automatic updates manager. Please refer to the
|
||||
* documentation for further information about customizing Wootook.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Debug class
|
||||
*
|
||||
* @todo Clean up source code
|
||||
*/
|
||||
class Nova_Core_Debug
|
||||
{
|
||||
const CRITICAL = 0x80;
|
||||
const ERROR = 0x40;
|
||||
const WARNING = 0x20;
|
||||
const INFO = 0x10;
|
||||
const MESSAGE = 0x08;
|
||||
const AUDIT_FAILED = 0x04;
|
||||
const AUDIT_SUCCESS = 0x02;
|
||||
const DEBUG = 0x01;
|
||||
|
||||
const DEFAULT_LOGFILE = 'var/log/system.log';
|
||||
|
||||
protected $_logLevelNames = array(
|
||||
self::CRITICAL => 'CRITICAL',
|
||||
self::ERROR => 'ERROR',
|
||||
self::WARNING => 'WARNING',
|
||||
self::INFO => 'INFO',
|
||||
self::MESSAGE => 'MESSAGE',
|
||||
self::AUDIT_FAILED => 'AUDIT_FAILED',
|
||||
self::AUDIT_SUCCESS => 'AUDIT_SUCCESS',
|
||||
self::DEBUG => 'DEBUG'
|
||||
);
|
||||
|
||||
/**
|
||||
* Clean logging method
|
||||
*
|
||||
* @param string $message
|
||||
* @param string $resource
|
||||
* @param int $level
|
||||
* @return unknown_type
|
||||
*/
|
||||
public function log($message, $resource = self::DEFAULT_LOGFILE, $level = self::DEBUG)
|
||||
{
|
||||
if(!($fp = fopen($resource, 'a'))) {
|
||||
trigger_error('Unable to open logs.', E_USER_ERROR);
|
||||
trigger_error($message, E_USER_ERROR);
|
||||
return false;
|
||||
}
|
||||
fprintf($fp, '[%s] | %s - %s', $this->_logLevelNames[$level], date('r'), $message);
|
||||
fclose($fp);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @todo Clean up source code
|
||||
*/
|
||||
class Debug
|
||||
extends Nova_Core_Debug
|
||||
{
|
||||
protected $_logMessages = array();
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @param string $message
|
||||
* @return void
|
||||
*/
|
||||
function add($message)
|
||||
{
|
||||
$this->log($message);
|
||||
$this->_logMessages[] = $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @return void
|
||||
*/
|
||||
function echo_log()
|
||||
{
|
||||
$messages = implode(PHP_EOL, $this->_logMessages);
|
||||
echo <<<EOF
|
||||
<dl class="k">
|
||||
<dt>
|
||||
<a href="admin/settings.php">Debug Log</a>:
|
||||
</dt>
|
||||
<dd>
|
||||
<pre><code>{$messages}</code></pre>
|
||||
</dd>
|
||||
</dl>
|
||||
EOF;
|
||||
die();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @todo Clean up source code
|
||||
* @param $message
|
||||
* @param $title
|
||||
* @return unknown_type
|
||||
*/
|
||||
public function error($message, $title)
|
||||
{
|
||||
if (defined('DEBUG')) {
|
||||
echo "<h2>$title</h2><br><font color=red>$message</font><br><hr>";
|
||||
echo "<table>".$this->log."</table>";
|
||||
}
|
||||
|
||||
$user = Legacies_Empire_Model_User::getSingleton();
|
||||
|
||||
$db = Legacies_Database::getSingleton();
|
||||
$config = include ROOT_PATH . 'config.' . PHPEXT;
|
||||
if(!$link) die('La base de donnee n est pas disponible pour le moment, desole pour la gene occasionnee...');
|
||||
$query = "INSERT INTO {$db->getTable('errors')} SET
|
||||
`error_sender` = {$user->getId()} ,
|
||||
`error_time` = {$db->quote(time())},
|
||||
`error_type` = {$db->quote($title)},
|
||||
`error_text` = {$db->quote($message)}";
|
||||
|
||||
$db->query($query);
|
||||
$id = $db->lastInsertId($db->getTable('errors'));
|
||||
if (!function_exists('message')) {
|
||||
echo "Erreur, merci de contacter l'admin. Erreur n<>: <b>".$id."</b>";
|
||||
} else {
|
||||
message("Erreur, merci de contacter l'admin. Erreur n<>: <b>".$id."</b>", "Erreur");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -105,12 +105,8 @@ $baseUrl = (isset($_SERVER["HTTPS"]) && strtolower($_SERVER["HTTPS"]) == "on" ?
|
|||
. $_SERVER["SERVER_NAME"] . ($_SERVER["SERVER_PORT"] != "80" ? ":{$_SERVER["SERVER_PORT"]}" : '');
|
||||
|
||||
if (isset($_SERVER['REQUEST_URI'])) {
|
||||
$offset = strrpos($_SERVER['REQUEST_URI'], '/');
|
||||
if ($offset == (strlen($_SERVER['REQUEST_URI']) - 1)) {
|
||||
$pathOffset = strrpos($_SERVER['REQUEST_URI'], 'install/');
|
||||
$baseUrl .= substr($_SERVER['REQUEST_URI'], 0, strpos(substr($_SERVER['REQUEST_URI'], 0, -1), '/')) . '/';
|
||||
} else {
|
||||
$baseUrl .= substr($_SERVER['REQUEST_URI'], 0, strpos(substr($_SERVER['REQUEST_URI'], 0, $offset), '/', strlen($_SERVER['REQUEST_URI']) - $offset - 1)) . '/';
|
||||
}
|
||||
}
|
||||
$session = Wootook::getSession('install');
|
||||
|
||||
|
|
@ -310,7 +306,7 @@ case 'install':
|
|||
|
||||
if (!$form->validate()) {
|
||||
$session->setData('step', STEP_DATABASE);
|
||||
$session->setFormData($request->getData());
|
||||
$session->setFormData($request->getAllDatas());
|
||||
$response->setRedirect(Wootook::getStaticUrl('install/index.php', array('mode' => 'install', 'step' => STEP_DATABASE)));
|
||||
$response->sendHeaders();
|
||||
exit(0);
|
||||
|
|
@ -397,7 +393,7 @@ case 'install':
|
|||
|
||||
if (!$form->validate()) {
|
||||
$session->setData('step', STEP_UNIVERSE);
|
||||
$session->setFormData($request->getData());
|
||||
$session->setFormData($request->getAllDatas());
|
||||
$response->setRedirect(Wootook::getStaticUrl('install/index.php', array('mode' => 'install', 'step' => STEP_PROFILE)));
|
||||
$response->sendHeaders();
|
||||
exit(0);
|
||||
|
|
@ -499,7 +495,7 @@ case 'install':
|
|||
|
||||
if (!$form->validate()) {
|
||||
$session->setData('step', STEP_PROFILE);
|
||||
$session->setFormData($request->getData());
|
||||
$session->setFormData($request->getAllDatas());
|
||||
$session->addError(Wootook::__('Form data error.'));
|
||||
$response->setRedirect(Wootook::getStaticUrl('install/index.php', array('mode' => 'install', 'step' => STEP_PROFILE)));
|
||||
$response->sendHeaders();
|
||||
|
|
@ -508,7 +504,7 @@ case 'install':
|
|||
|
||||
if ($request->getPost('password') != $request->getPost('password_confirm')) {
|
||||
$session->setData('step', STEP_PROFILE);
|
||||
$session->setFormData($request->getData());
|
||||
$session->setFormData($request->getAllDatas());
|
||||
$session->addError(Wootook::__('Passwords does not match.'));
|
||||
$response->setRedirect(Wootook::getStaticUrl('install/index.php', array('mode' => 'install', 'step' => STEP_PROFILE)));
|
||||
$response->sendHeaders();
|
||||
|
|
|
|||
|
|
@ -16,3 +16,10 @@ ALTER TABLE `game_planets`
|
|||
|
||||
ALTER TABLE `game_messages`
|
||||
ADD `message_read_at` INT UNSIGNED NOT NULL AFTER `message_time`;
|
||||
|
||||
ALTER TABLE `game_users`
|
||||
`last_update` `last_update` DATETIME NOT NULL,
|
||||
`b_building` `b_building` DATETIME NOT NULL,
|
||||
`b_tech` `b_tech` DATETIME NOT NULL,
|
||||
`b_tech_id` `b_tech_id` TEXT NOT NULL,
|
||||
`b_hangar` `b_hangar` DATETIME NOT NULL;
|
||||
|
|
|
|||
Loading…
Reference in a new issue