@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | * @return string |
305 | 305 | */ |
306 | 306 | protected function stringValue($value) { |
307 | - return "'" . $this->escape((string)$value) . "'"; |
|
307 | + return "'".$this->escape((string) $value)."'"; |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | /** |
@@ -315,20 +315,20 @@ discard block |
||
315 | 315 | * @return string |
316 | 316 | */ |
317 | 317 | public function quote($fieldName) { |
318 | - return "`" . $this->escape((string)$fieldName) . "`"; |
|
318 | + return "`".$this->escape((string) $fieldName)."`"; |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | public function makeAdjustString($fieldValue, $fieldName) { |
322 | 322 | return is_int($fieldName) |
323 | 323 | ? $fieldValue |
324 | - : (($fieldNameQuoted = $this->quote($fieldName)) . " = " . |
|
325 | - $fieldNameQuoted . " + (" . $this->castAsDbValue($fieldValue) . ")"); |
|
324 | + : (($fieldNameQuoted = $this->quote($fieldName))." = ". |
|
325 | + $fieldNameQuoted." + (".$this->castAsDbValue($fieldValue).")"); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | public function makeFieldEqualValue($fieldValue, $fieldName) { |
329 | 329 | return is_int($fieldName) |
330 | 330 | ? $fieldValue |
331 | - : ($this->quote($fieldName) . " = " . $this->castAsDbValue($fieldValue)); |
|
331 | + : ($this->quote($fieldName)." = ".$this->castAsDbValue($fieldValue)); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | /** |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | * @return string |
340 | 340 | */ |
341 | 341 | protected function quoteTable($tableName) { |
342 | - return "`{{" . $this->escape((string)$tableName) . "}}`"; |
|
342 | + return "`{{".$this->escape((string) $tableName)."}}`"; |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | public function castAsDbValue($value) { |
@@ -376,21 +376,21 @@ discard block |
||
376 | 376 | protected function buildCommand() { |
377 | 377 | switch ($this->command) { |
378 | 378 | case static::UPDATE: |
379 | - $this->build[] = $this->command . " " . $this->quoteTable($this->table); |
|
379 | + $this->build[] = $this->command." ".$this->quoteTable($this->table); |
|
380 | 380 | break; |
381 | 381 | |
382 | 382 | case static::DELETE: |
383 | - $this->build[] = $this->command . " FROM " . $this->quoteTable($this->table); |
|
383 | + $this->build[] = $this->command." FROM ".$this->quoteTable($this->table); |
|
384 | 384 | break; |
385 | 385 | |
386 | 386 | case static::REPLACE: |
387 | 387 | case static::INSERT_IGNORE: |
388 | 388 | case static::INSERT: |
389 | - $this->build[] = $this->command . " INTO " . $this->quoteTable($this->table); |
|
389 | + $this->build[] = $this->command." INTO ".$this->quoteTable($this->table); |
|
390 | 390 | break; |
391 | 391 | |
392 | 392 | case static::SELECT: |
393 | - $this->build[] = $this->command . " "; |
|
393 | + $this->build[] = $this->command." "; |
|
394 | 394 | break; |
395 | 395 | } |
396 | 396 | } |
@@ -431,12 +431,12 @@ discard block |
||
431 | 431 | protected function buildValuesVector() { |
432 | 432 | $compiled = array(); |
433 | 433 | |
434 | - if(!empty($this->valuesDanger)) { |
|
434 | + if (!empty($this->valuesDanger)) { |
|
435 | 435 | $compiled = $this->valuesDanger; |
436 | 436 | } |
437 | 437 | |
438 | 438 | foreach ($this->values as $valuesVector) { |
439 | - $compiled[] = '(' . implode(',', HelperArray::map($valuesVector, array($this, 'castAsDbValue'))) . ')'; |
|
439 | + $compiled[] = '('.implode(',', HelperArray::map($valuesVector, array($this, 'castAsDbValue'))).')'; |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | $this->build[] = implode(',', $compiled); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | public function load_db_settings($configFile = '') { |
92 | 92 | $dbsettings = array(); |
93 | 93 | |
94 | - empty($configFile) ? $configFile = SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX : false; |
|
94 | + empty($configFile) ? $configFile = SN_ROOT_PHYSICAL."config".DOT_PHP_EX : false; |
|
95 | 95 | |
96 | 96 | require $configFile; |
97 | 97 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | } |
112 | 112 | |
113 | 113 | if (empty($this->dbsettings)) { |
114 | - $this->load_db_settings(SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX); |
|
114 | + $this->load_db_settings(SN_ROOT_PHYSICAL."config".DOT_PHP_EX); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | // TODO - фатальные (?) ошибки на каждом шагу. Хотя - скорее Эксепшны |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | $sql = $query; |
164 | 164 | if (strpos($sql, '{{') !== false) { |
165 | 165 | foreach ($this->table_list as $tableName) { |
166 | - $sql = str_replace("{{{$tableName}}}", $this->db_prefix . $tableName, $sql); |
|
166 | + $sql = str_replace("{{{$tableName}}}", $this->db_prefix.$tableName, $sql); |
|
167 | 167 | } |
168 | 168 | } |
169 | 169 | |
@@ -234,12 +234,12 @@ discard block |
||
234 | 234 | |
235 | 235 | $queryResult = null; |
236 | 236 | try { |
237 | - $queryResult = $this->db_sql_query($stringQuery . DbSqlHelper::quoteComment($queryTrace)); |
|
237 | + $queryResult = $this->db_sql_query($stringQuery.DbSqlHelper::quoteComment($queryTrace)); |
|
238 | 238 | if (!$queryResult) { |
239 | 239 | throw new Exception(); |
240 | 240 | } |
241 | 241 | } catch (Exception $e) { |
242 | - classSupernova::$debug->error($this->db_error() . "<br />{$query}<br />", 'SQL Error'); |
|
242 | + classSupernova::$debug->error($this->db_error()."<br />{$query}<br />", 'SQL Error'); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | return $queryResult; |
@@ -291,19 +291,19 @@ discard block |
||
291 | 291 | */ |
292 | 292 | public function doSelectDanger($table, $fields, $where = array(), $isOneRecord = DB_RECORDS_ALL, $forUpdate = DB_SELECT_PLAIN) { |
293 | 293 | // TODO - TEMPORARY UNTIL DbQuery |
294 | - if(!empty($where)) { |
|
294 | + if (!empty($where)) { |
|
295 | 295 | foreach ($where as $key => &$value) { |
296 | - if(!is_int($key)) { |
|
297 | - $value = "`$key` = '" . $this->db_escape($value). "'"; |
|
296 | + if (!is_int($key)) { |
|
297 | + $value = "`$key` = '".$this->db_escape($value)."'"; |
|
298 | 298 | } |
299 | 299 | } |
300 | 300 | } |
301 | 301 | |
302 | 302 | $query = |
303 | - "SELECT " . implode(',', $fields) . |
|
304 | - " FROM `{{{$table}}}`" . |
|
305 | - (!empty($where) ? ' WHERE ' . implode(' AND ', $where) : '') . |
|
306 | - ($isOneRecord == DB_RECORD_ONE ? ' LIMIT 1' : '') . |
|
303 | + "SELECT ".implode(',', $fields). |
|
304 | + " FROM `{{{$table}}}`". |
|
305 | + (!empty($where) ? ' WHERE '.implode(' AND ', $where) : ''). |
|
306 | + ($isOneRecord == DB_RECORD_ONE ? ' LIMIT 1' : ''). |
|
307 | 307 | ($forUpdate == DB_SELECT_FOR_UPDATE ? ' FOR UPDATE' : '') |
308 | 308 | ; |
309 | 309 | |
@@ -613,10 +613,10 @@ discard block |
||
613 | 613 | $this->isWatching = true; |
614 | 614 | $msg = "\$query = \"{$query}\"\n\r"; |
615 | 615 | if (!empty($_POST)) { |
616 | - $msg .= "\n\r" . dump($_POST, '$_POST'); |
|
616 | + $msg .= "\n\r".dump($_POST, '$_POST'); |
|
617 | 617 | } |
618 | 618 | if (!empty($_GET)) { |
619 | - $msg .= "\n\r" . dump($_GET, '$_GET'); |
|
619 | + $msg .= "\n\r".dump($_GET, '$_GET'); |
|
620 | 620 | } |
621 | 621 | classSupernova::$debug->warning($msg, "Watching user {$user['id']}", 399, array('base_dump' => true)); |
622 | 622 | $this->isWatching = false; |
@@ -642,37 +642,37 @@ discard block |
||
642 | 642 | case stripos($query, 'RPG_POINTS') != false && stripos(trim($query), 'UPDATE ') === 0 && !$dm_change_legit: |
643 | 643 | case stripos($query, 'METAMATTER') != false && stripos(trim($query), 'UPDATE ') === 0 && !$mm_change_legit: |
644 | 644 | case stripos($query, 'AUTHLEVEL') != false && $user['authlevel'] < 3 && stripos($query, 'SELECT') !== 0: |
645 | - $report = "Hacking attempt (" . date("d.m.Y H:i:s") . " - [" . time() . "]):\n"; |
|
645 | + $report = "Hacking attempt (".date("d.m.Y H:i:s")." - [".time()."]):\n"; |
|
646 | 646 | $report .= ">Database Inforamation\n"; |
647 | - $report .= "\tID - " . $user['id'] . "\n"; |
|
648 | - $report .= "\tUser - " . $user['username'] . "\n"; |
|
649 | - $report .= "\tAuth level - " . $user['authlevel'] . "\n"; |
|
650 | - $report .= "\tAdmin Notes - " . $user['adminNotes'] . "\n"; |
|
651 | - $report .= "\tCurrent Planet - " . $user['current_planet'] . "\n"; |
|
652 | - $report .= "\tUser IP - " . $user['user_lastip'] . "\n"; |
|
653 | - $report .= "\tUser IP at Reg - " . $user['ip_at_reg'] . "\n"; |
|
654 | - $report .= "\tUser Agent- " . $_SERVER['HTTP_USER_AGENT'] . "\n"; |
|
655 | - $report .= "\tCurrent Page - " . $user['current_page'] . "\n"; |
|
656 | - $report .= "\tRegister Time - " . $user['register_time'] . "\n"; |
|
647 | + $report .= "\tID - ".$user['id']."\n"; |
|
648 | + $report .= "\tUser - ".$user['username']."\n"; |
|
649 | + $report .= "\tAuth level - ".$user['authlevel']."\n"; |
|
650 | + $report .= "\tAdmin Notes - ".$user['adminNotes']."\n"; |
|
651 | + $report .= "\tCurrent Planet - ".$user['current_planet']."\n"; |
|
652 | + $report .= "\tUser IP - ".$user['user_lastip']."\n"; |
|
653 | + $report .= "\tUser IP at Reg - ".$user['ip_at_reg']."\n"; |
|
654 | + $report .= "\tUser Agent- ".$_SERVER['HTTP_USER_AGENT']."\n"; |
|
655 | + $report .= "\tCurrent Page - ".$user['current_page']."\n"; |
|
656 | + $report .= "\tRegister Time - ".$user['register_time']."\n"; |
|
657 | 657 | $report .= "\n"; |
658 | 658 | |
659 | 659 | $report .= ">Query Information\n"; |
660 | - $report .= "\tQuery - " . $query . "\n"; |
|
660 | + $report .= "\tQuery - ".$query."\n"; |
|
661 | 661 | $report .= "\n"; |
662 | 662 | |
663 | 663 | $report .= ">\$_SERVER Information\n"; |
664 | - $report .= "\tIP - " . $_SERVER['REMOTE_ADDR'] . "\n"; |
|
665 | - $report .= "\tHost Name - " . $_SERVER['HTTP_HOST'] . "\n"; |
|
666 | - $report .= "\tUser Agent - " . $_SERVER['HTTP_USER_AGENT'] . "\n"; |
|
667 | - $report .= "\tRequest Method - " . $_SERVER['REQUEST_METHOD'] . "\n"; |
|
668 | - $report .= "\tCame From - " . $_SERVER['HTTP_REFERER'] . "\n"; |
|
669 | - $report .= "\tPage is - " . $_SERVER['SCRIPT_NAME'] . "\n"; |
|
670 | - $report .= "\tUses Port - " . $_SERVER['REMOTE_PORT'] . "\n"; |
|
671 | - $report .= "\tServer Protocol - " . $_SERVER['SERVER_PROTOCOL'] . "\n"; |
|
664 | + $report .= "\tIP - ".$_SERVER['REMOTE_ADDR']."\n"; |
|
665 | + $report .= "\tHost Name - ".$_SERVER['HTTP_HOST']."\n"; |
|
666 | + $report .= "\tUser Agent - ".$_SERVER['HTTP_USER_AGENT']."\n"; |
|
667 | + $report .= "\tRequest Method - ".$_SERVER['REQUEST_METHOD']."\n"; |
|
668 | + $report .= "\tCame From - ".$_SERVER['HTTP_REFERER']."\n"; |
|
669 | + $report .= "\tPage is - ".$_SERVER['SCRIPT_NAME']."\n"; |
|
670 | + $report .= "\tUses Port - ".$_SERVER['REMOTE_PORT']."\n"; |
|
671 | + $report .= "\tServer Protocol - ".$_SERVER['SERVER_PROTOCOL']."\n"; |
|
672 | 672 | |
673 | 673 | $report .= "\n--------------------------------------------------------------------------------------------------\n"; |
674 | 674 | |
675 | - $fp = fopen(SN_ROOT_PHYSICAL . 'badqrys.txt', 'a'); |
|
675 | + $fp = fopen(SN_ROOT_PHYSICAL.'badqrys.txt', 'a'); |
|
676 | 676 | fwrite($fp, $report); |
677 | 677 | fclose($fp); |
678 | 678 |