@@ -264,9 +264,9 @@ discard block |
||
264 | 264 | } |
265 | 265 | |
266 | 266 | protected function compileFrom() { |
267 | - $this->_compiledQuery[] = 'FROM `{{' . $this->stringEscape($this->table) . '}}`'; |
|
267 | + $this->_compiledQuery[] = 'FROM `{{'.$this->stringEscape($this->table).'}}`'; |
|
268 | 268 | if (!empty($this->alias)) { |
269 | - $this->_compiledQuery[] = 'AS `' . $this->stringEscape($this->alias) . '`'; |
|
269 | + $this->_compiledQuery[] = 'AS `'.$this->stringEscape($this->alias).'`'; |
|
270 | 270 | } |
271 | 271 | } |
272 | 272 | |
@@ -276,29 +276,29 @@ discard block |
||
276 | 276 | |
277 | 277 | protected function compileWhere() { |
278 | 278 | // TODO - fields should be escaped !! |
279 | - !empty($this->where) ? $this->_compiledQuery[] = 'WHERE ' . implode(' AND ', $this->where) : false; |
|
279 | + !empty($this->where) ? $this->_compiledQuery[] = 'WHERE '.implode(' AND ', $this->where) : false; |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | protected function compileGroupBy() { |
283 | 283 | // TODO - fields should be escaped !! |
284 | 284 | // !empty($this->groupBy) ? $this->_compiledQuery[] = 'GROUP BY ' . implode(',', $this->arrayEscape($this->groupBy)) : false; |
285 | - !empty($this->groupBy) ? $this->_compiledQuery[] = 'GROUP BY ' . $this->selectFieldsToString($this->groupBy) : false; |
|
285 | + !empty($this->groupBy) ? $this->_compiledQuery[] = 'GROUP BY '.$this->selectFieldsToString($this->groupBy) : false; |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | protected function compileOrderBy() { |
289 | 289 | // TODO - fields should be escaped !! |
290 | - !empty($this->orderBy) ? $this->_compiledQuery[] = 'ORDER BY ' . implode(',', $this->arrayEscape($this->orderBy)) : false; |
|
290 | + !empty($this->orderBy) ? $this->_compiledQuery[] = 'ORDER BY '.implode(',', $this->arrayEscape($this->orderBy)) : false; |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | protected function compileHaving() { |
294 | 294 | // TODO - fields should be escaped !! |
295 | - !empty($this->having) ? $this->_compiledQuery[] = 'HAVING ' . implode(' AND ', $this->having) : false; |
|
295 | + !empty($this->having) ? $this->_compiledQuery[] = 'HAVING '.implode(' AND ', $this->having) : false; |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | protected function compileLimit() { |
299 | 299 | // TODO - fields should be escaped !! |
300 | 300 | if ($limit = $this->fetchOne ? 1 : $this->limit) { |
301 | - $this->_compiledQuery[] = 'LIMIT ' . $limit . (!empty($this->offset) ? ' OFFSET ' . $this->offset : ''); |
|
301 | + $this->_compiledQuery[] = 'LIMIT '.$limit.(!empty($this->offset) ? ' OFFSET '.$this->offset : ''); |
|
302 | 302 | } |
303 | 303 | } |
304 | 304 | |
@@ -373,15 +373,15 @@ discard block |
||
373 | 373 | */ |
374 | 374 | protected function processField($fieldName) { |
375 | 375 | if (is_bool($fieldName)) { |
376 | - $result = (string)intval($fieldName); |
|
376 | + $result = (string) intval($fieldName); |
|
377 | 377 | } elseif (is_numeric($fieldName)) { |
378 | 378 | $result = $fieldName; |
379 | 379 | } elseif (is_null($fieldName)) { |
380 | 380 | $result = 'NULL'; |
381 | 381 | } else { |
382 | 382 | // Field has other type - string or should be convertible to string |
383 | - $result = (string)$fieldName; |
|
384 | - if(!$fieldName instanceof DbSqlLiteral) { |
|
383 | + $result = (string) $fieldName; |
|
384 | + if (!$fieldName instanceof DbSqlLiteral) { |
|
385 | 385 | $result = $this->makeFieldFromString($fieldName); |
386 | 386 | } |
387 | 387 | } |
@@ -68,13 +68,13 @@ discard block |
||
68 | 68 | public function commentRemove() { |
69 | 69 | if (!empty($this->values[static::COMMENT_PLACEHOLDER])) { |
70 | 70 | unset($this->values[static::COMMENT_PLACEHOLDER]); |
71 | - $this->query = str_replace(' ' . static::COMMENT_PLACEHOLDER, '', $this->query); |
|
71 | + $this->query = str_replace(' '.static::COMMENT_PLACEHOLDER, '', $this->query); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
75 | 75 | public function commentAdd($comment) { |
76 | 76 | if (empty($this->values[static::COMMENT_PLACEHOLDER])) { |
77 | - $this->query .= ' ' . static::COMMENT_PLACEHOLDER; |
|
77 | + $this->query .= ' '.static::COMMENT_PLACEHOLDER; |
|
78 | 78 | } |
79 | 79 | $this->values[static::COMMENT_PLACEHOLDER] = $comment; |
80 | 80 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | // Removing comment placeholder from statement |
114 | 114 | $this->queryPrepared = str_replace(static::COMMENT_PLACEHOLDER, $this->comment, $this->queryPrepared); |
115 | 115 | // Removing comment value from values list |
116 | - $this->paramsPrepared = array_filter($this->paramsPrepared, function ($value) { return $value != DbSqlPrepare::COMMENT_PLACEHOLDER; }); |
|
116 | + $this->paramsPrepared = array_filter($this->paramsPrepared, function($value) { return $value != DbSqlPrepare::COMMENT_PLACEHOLDER; }); |
|
117 | 117 | // TODO - Add comment value directly to statement |
118 | 118 | } |
119 | 119 |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | $alias = $this->makeAliasFromField($functionName, $field); |
51 | 51 | } |
52 | 52 | |
53 | - $this->literal = strtoupper($functionName) . '(' . $this->makeFieldFromString($field) . ')'; |
|
53 | + $this->literal = strtoupper($functionName).'('.$this->makeFieldFromString($field).')'; |
|
54 | 54 | |
55 | 55 | if (!empty($alias)) { |
56 | - $this->literal .= ' AS `' . $alias . '`'; |
|
56 | + $this->literal .= ' AS `'.$alias.'`'; |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | return $this; |
@@ -110,10 +110,10 @@ discard block |
||
110 | 110 | $alias = $this->makeAliasFromField($functionName, $field); |
111 | 111 | } |
112 | 112 | |
113 | - $this->literal = $this->makeFieldFromString($field) . ' IS NULL'; |
|
113 | + $this->literal = $this->makeFieldFromString($field).' IS NULL'; |
|
114 | 114 | |
115 | 115 | if (!empty($alias)) { |
116 | - $this->literal .= ' AS `' . $alias . '`'; |
|
116 | + $this->literal .= ' AS `'.$alias.'`'; |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | return $this; |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | static::buildSelect() |
53 | 53 | ->fields('id') |
54 | 54 | ->where(array( |
55 | - "`user_as_ally` IS NULL AND `user_bot` = " . USER_BOT_PLAYER . " FOR UPDATE;" |
|
55 | + "`user_as_ally` IS NULL AND `user_bot` = ".USER_BOT_PLAYER." FOR UPDATE;" |
|
56 | 56 | )) |
57 | 57 | ); |
58 | 58 | |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | public static function db_user_lock_with_target_owner_and_acs($user, $planet = array()) { |
65 | 65 | static::execute( |
66 | 66 | static::buildSelectLock() |
67 | - ->where(array("`id` = " . idval($user['id']) . |
|
68 | - (isset($planet['id_owner']) ? ' OR `id` = ' . idval($planet['id_owner']) : ''))) |
|
67 | + ->where(array("`id` = ".idval($user['id']). |
|
68 | + (isset($planet['id_owner']) ? ' OR `id` = '.idval($planet['id_owner']) : ''))) |
|
69 | 69 | ); |
70 | 70 | |
71 | 71 | // doquery("SELECT 1 FROM {{users}} WHERE `id` = " . idval($user['id']) . |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | } |
76 | 76 | |
77 | 77 | public static function db_user_count($online = false) { |
78 | - $result = doquery('SELECT COUNT(id) AS user_count FROM `{{users}}` WHERE user_as_ally IS NULL' . ($online ? ' AND onlinetime > ' . (SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : ''), true); |
|
78 | + $result = doquery('SELECT COUNT(id) AS user_count FROM `{{users}}` WHERE user_as_ally IS NULL'.($online ? ' AND onlinetime > '.(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : ''), true); |
|
79 | 79 | |
80 | 80 | return isset($result['user_count']) ? $result['user_count'] : 0; |
81 | 81 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | LEFT JOIN |
143 | 143 | {{referrals}} as r on r.id_partner = u.id |
144 | 144 | WHERE " . |
145 | - ($online ? "`onlinetime` >= :onlineTime" : 'user_as_ally IS NULL') . |
|
145 | + ($online ? "`onlinetime` >= :onlineTime" : 'user_as_ally IS NULL'). |
|
146 | 146 | " GROUP BY u.id |
147 | 147 | ORDER BY user_as_ally, {$sort} ASC", array( |
148 | 148 | ':onlineTime' => SN_TIME_NOW - classSupernova::$config->game_users_online_timeout, |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | } |
200 | 200 | |
201 | 201 | public static function db_user_list_set_mass_mail(&$owners_list, $set) { |
202 | - return classSupernova::db_upd_record_list(LOC_USER, !empty($owners_list) ? '`id` IN (' . implode(',', $owners_list) . ');' : '', $set); |
|
202 | + return classSupernova::db_upd_record_list(LOC_USER, !empty($owners_list) ? '`id` IN ('.implode(',', $owners_list).');' : '', $set); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | public static function db_user_list_set_by_ally_and_rank($ally_id, $ally_rank_id, $set) { |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | public function load_db_settings() { |
66 | 66 | $dbsettings = array(); |
67 | 67 | |
68 | - require(SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX); |
|
68 | + require(SN_ROOT_PHYSICAL."config".DOT_PHP_EX); |
|
69 | 69 | |
70 | 70 | $this->dbsettings = $dbsettings; |
71 | 71 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | $sql = $query; |
131 | 131 | if (strpos($sql, '{{') !== false) { |
132 | 132 | foreach ($this->table_list as $tableName) { |
133 | - $sql = str_replace("{{{$tableName}}}", $this->db_prefix . $tableName, $sql); |
|
133 | + $sql = str_replace("{{{$tableName}}}", $this->db_prefix.$tableName, $sql); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | $arr = debug_backtrace(); |
151 | 151 | $file = end(explode('/', $arr[0]['file'])); |
152 | 152 | $line = $arr[0]['line']; |
153 | - classSupernova::$debug->add("<tr><th>Query {$this->queryCount}: </th><th>$query</th><th>{$file} @ {$line}</th><th> </th><th> " . ($fetch ? '+' : ' ') . " </th></tr>"); |
|
153 | + classSupernova::$debug->add("<tr><th>Query {$this->queryCount}: </th><th>$query</th><th>{$file} @ {$line}</th><th> </th><th> ".($fetch ? '+' : ' ')." </th></tr>"); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | classSupernova::$debug->add_to_array($sql_comment); |
170 | 170 | } |
171 | 171 | |
172 | - $sql_commented = '/* ' . implode("<br />", $sql_comment) . '<br /> */ '; |
|
172 | + $sql_commented = '/* '.implode("<br />", $sql_comment).'<br /> */ '; |
|
173 | 173 | if (defined('DEBUG_SQL_ONLINE') && constant('DEBUG_SQL_ONLINE') === true) { |
174 | 174 | classSupernova::$debug->warning($sql_commented, 'SQL Debug', LOG_DEBUG_SQL); |
175 | 175 | } |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | * @return array|bool|mysqli_result|null |
184 | 184 | */ |
185 | 185 | public function execute($statement) { |
186 | - return $this->doquery((string)$statement); |
|
186 | + return $this->doquery((string) $statement); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | /** |
@@ -238,13 +238,13 @@ discard block |
||
238 | 238 | ->execute() |
239 | 239 | ->getResult(); |
240 | 240 | } else { |
241 | - $queryResult = $this->db_sql_query($stringQuery . $queryTrace); |
|
241 | + $queryResult = $this->db_sql_query($stringQuery.$queryTrace); |
|
242 | 242 | } |
243 | 243 | if (!$queryResult) { |
244 | 244 | throw new Exception(); |
245 | 245 | } |
246 | 246 | } catch (Exception $e) { |
247 | - classSupernova::$debug->error($this->db_error() . "<br />{$query}<br />", 'SQL Error'); |
|
247 | + classSupernova::$debug->error($this->db_error()."<br />{$query}<br />", 'SQL Error'); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | if ($fetch) { |
@@ -269,10 +269,10 @@ discard block |
||
269 | 269 | $this->isWatching = true; |
270 | 270 | $msg = "\$query = \"{$query}\"\n\r"; |
271 | 271 | if (!empty($_POST)) { |
272 | - $msg .= "\n\r" . dump($_POST, '$_POST'); |
|
272 | + $msg .= "\n\r".dump($_POST, '$_POST'); |
|
273 | 273 | } |
274 | 274 | if (!empty($_GET)) { |
275 | - $msg .= "\n\r" . dump($_GET, '$_GET'); |
|
275 | + $msg .= "\n\r".dump($_GET, '$_GET'); |
|
276 | 276 | } |
277 | 277 | classSupernova::$debug->warning($msg, "Watching user {$user['id']}", 399, array('base_dump' => true)); |
278 | 278 | $this->isWatching = false; |
@@ -298,37 +298,37 @@ discard block |
||
298 | 298 | case stripos($query, 'RPG_POINTS') != false && stripos(trim($query), 'UPDATE ') === 0 && !$dm_change_legit: |
299 | 299 | case stripos($query, 'METAMATTER') != false && stripos(trim($query), 'UPDATE ') === 0 && !$mm_change_legit: |
300 | 300 | case stripos($query, 'AUTHLEVEL') != false && $user['authlevel'] < 3 && stripos($query, 'SELECT') !== 0: |
301 | - $report = "Hacking attempt (" . date("d.m.Y H:i:s") . " - [" . time() . "]):\n"; |
|
301 | + $report = "Hacking attempt (".date("d.m.Y H:i:s")." - [".time()."]):\n"; |
|
302 | 302 | $report .= ">Database Inforamation\n"; |
303 | - $report .= "\tID - " . $user['id'] . "\n"; |
|
304 | - $report .= "\tUser - " . $user['username'] . "\n"; |
|
305 | - $report .= "\tAuth level - " . $user['authlevel'] . "\n"; |
|
306 | - $report .= "\tAdmin Notes - " . $user['adminNotes'] . "\n"; |
|
307 | - $report .= "\tCurrent Planet - " . $user['current_planet'] . "\n"; |
|
308 | - $report .= "\tUser IP - " . $user['user_lastip'] . "\n"; |
|
309 | - $report .= "\tUser IP at Reg - " . $user['ip_at_reg'] . "\n"; |
|
310 | - $report .= "\tUser Agent- " . $_SERVER['HTTP_USER_AGENT'] . "\n"; |
|
311 | - $report .= "\tCurrent Page - " . $user['current_page'] . "\n"; |
|
312 | - $report .= "\tRegister Time - " . $user['register_time'] . "\n"; |
|
303 | + $report .= "\tID - ".$user['id']."\n"; |
|
304 | + $report .= "\tUser - ".$user['username']."\n"; |
|
305 | + $report .= "\tAuth level - ".$user['authlevel']."\n"; |
|
306 | + $report .= "\tAdmin Notes - ".$user['adminNotes']."\n"; |
|
307 | + $report .= "\tCurrent Planet - ".$user['current_planet']."\n"; |
|
308 | + $report .= "\tUser IP - ".$user['user_lastip']."\n"; |
|
309 | + $report .= "\tUser IP at Reg - ".$user['ip_at_reg']."\n"; |
|
310 | + $report .= "\tUser Agent- ".$_SERVER['HTTP_USER_AGENT']."\n"; |
|
311 | + $report .= "\tCurrent Page - ".$user['current_page']."\n"; |
|
312 | + $report .= "\tRegister Time - ".$user['register_time']."\n"; |
|
313 | 313 | $report .= "\n"; |
314 | 314 | |
315 | 315 | $report .= ">Query Information\n"; |
316 | - $report .= "\tQuery - " . $query . "\n"; |
|
316 | + $report .= "\tQuery - ".$query."\n"; |
|
317 | 317 | $report .= "\n"; |
318 | 318 | |
319 | 319 | $report .= ">\$_SERVER Information\n"; |
320 | - $report .= "\tIP - " . $_SERVER['REMOTE_ADDR'] . "\n"; |
|
321 | - $report .= "\tHost Name - " . $_SERVER['HTTP_HOST'] . "\n"; |
|
322 | - $report .= "\tUser Agent - " . $_SERVER['HTTP_USER_AGENT'] . "\n"; |
|
323 | - $report .= "\tRequest Method - " . $_SERVER['REQUEST_METHOD'] . "\n"; |
|
324 | - $report .= "\tCame From - " . $_SERVER['HTTP_REFERER'] . "\n"; |
|
325 | - $report .= "\tPage is - " . $_SERVER['SCRIPT_NAME'] . "\n"; |
|
326 | - $report .= "\tUses Port - " . $_SERVER['REMOTE_PORT'] . "\n"; |
|
327 | - $report .= "\tServer Protocol - " . $_SERVER['SERVER_PROTOCOL'] . "\n"; |
|
320 | + $report .= "\tIP - ".$_SERVER['REMOTE_ADDR']."\n"; |
|
321 | + $report .= "\tHost Name - ".$_SERVER['HTTP_HOST']."\n"; |
|
322 | + $report .= "\tUser Agent - ".$_SERVER['HTTP_USER_AGENT']."\n"; |
|
323 | + $report .= "\tRequest Method - ".$_SERVER['REQUEST_METHOD']."\n"; |
|
324 | + $report .= "\tCame From - ".$_SERVER['HTTP_REFERER']."\n"; |
|
325 | + $report .= "\tPage is - ".$_SERVER['SCRIPT_NAME']."\n"; |
|
326 | + $report .= "\tUses Port - ".$_SERVER['REMOTE_PORT']."\n"; |
|
327 | + $report .= "\tServer Protocol - ".$_SERVER['SERVER_PROTOCOL']."\n"; |
|
328 | 328 | |
329 | 329 | $report .= "\n--------------------------------------------------------------------------------------------------\n"; |
330 | 330 | |
331 | - $fp = fopen(SN_ROOT_PHYSICAL . 'badqrys.txt', 'a'); |
|
331 | + $fp = fopen(SN_ROOT_PHYSICAL.'badqrys.txt', 'a'); |
|
332 | 332 | fwrite($fp, $report); |
333 | 333 | fclose($fp); |
334 | 334 |