@@ -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 | } |
@@ -252,13 +252,13 @@ discard block |
||
252 | 252 | ->execute() |
253 | 253 | ->getResult(); |
254 | 254 | } else { |
255 | - $queryResult = $this->db_sql_query($stringQuery . $queryTrace); |
|
255 | + $queryResult = $this->db_sql_query($stringQuery.$queryTrace); |
|
256 | 256 | } |
257 | 257 | if (!$queryResult) { |
258 | 258 | throw new Exception(); |
259 | 259 | } |
260 | 260 | } catch (Exception $e) { |
261 | - classSupernova::$debug->error($this->db_error() . "<br />{$query}<br />", 'SQL Error'); |
|
261 | + classSupernova::$debug->error($this->db_error()."<br />{$query}<br />", 'SQL Error'); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | if ($fetch) { |
@@ -283,10 +283,10 @@ discard block |
||
283 | 283 | $this->isWatching = true; |
284 | 284 | $msg = "\$query = \"{$query}\"\n\r"; |
285 | 285 | if (!empty($_POST)) { |
286 | - $msg .= "\n\r" . dump($_POST, '$_POST'); |
|
286 | + $msg .= "\n\r".dump($_POST, '$_POST'); |
|
287 | 287 | } |
288 | 288 | if (!empty($_GET)) { |
289 | - $msg .= "\n\r" . dump($_GET, '$_GET'); |
|
289 | + $msg .= "\n\r".dump($_GET, '$_GET'); |
|
290 | 290 | } |
291 | 291 | classSupernova::$debug->warning($msg, "Watching user {$user['id']}", 399, array('base_dump' => true)); |
292 | 292 | $this->isWatching = false; |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | |
302 | 302 | global $user, $dm_change_legit, $mm_change_legit; |
303 | 303 | |
304 | - switch(true) { |
|
304 | + switch (true) { |
|
305 | 305 | case stripos($query, 'RUNCATE TABL') != false: |
306 | 306 | case stripos($query, 'ROP TABL') != false: |
307 | 307 | case stripos($query, 'ENAME TABL') != false: |
@@ -312,37 +312,37 @@ discard block |
||
312 | 312 | case stripos($query, 'RPG_POINTS') != false && stripos(trim($query), 'UPDATE ') === 0 && !$dm_change_legit: |
313 | 313 | case stripos($query, 'METAMATTER') != false && stripos(trim($query), 'UPDATE ') === 0 && !$mm_change_legit: |
314 | 314 | case stripos($query, 'AUTHLEVEL') != false && $user['authlevel'] < 3 && stripos($query, 'SELECT') !== 0: |
315 | - $report = "Hacking attempt (" . date("d.m.Y H:i:s") . " - [" . time() . "]):\n"; |
|
315 | + $report = "Hacking attempt (".date("d.m.Y H:i:s")." - [".time()."]):\n"; |
|
316 | 316 | $report .= ">Database Inforamation\n"; |
317 | - $report .= "\tID - " . $user['id'] . "\n"; |
|
318 | - $report .= "\tUser - " . $user['username'] . "\n"; |
|
319 | - $report .= "\tAuth level - " . $user['authlevel'] . "\n"; |
|
320 | - $report .= "\tAdmin Notes - " . $user['adminNotes'] . "\n"; |
|
321 | - $report .= "\tCurrent Planet - " . $user['current_planet'] . "\n"; |
|
322 | - $report .= "\tUser IP - " . $user['user_lastip'] . "\n"; |
|
323 | - $report .= "\tUser IP at Reg - " . $user['ip_at_reg'] . "\n"; |
|
324 | - $report .= "\tUser Agent- " . $_SERVER['HTTP_USER_AGENT'] . "\n"; |
|
325 | - $report .= "\tCurrent Page - " . $user['current_page'] . "\n"; |
|
326 | - $report .= "\tRegister Time - " . $user['register_time'] . "\n"; |
|
317 | + $report .= "\tID - ".$user['id']."\n"; |
|
318 | + $report .= "\tUser - ".$user['username']."\n"; |
|
319 | + $report .= "\tAuth level - ".$user['authlevel']."\n"; |
|
320 | + $report .= "\tAdmin Notes - ".$user['adminNotes']."\n"; |
|
321 | + $report .= "\tCurrent Planet - ".$user['current_planet']."\n"; |
|
322 | + $report .= "\tUser IP - ".$user['user_lastip']."\n"; |
|
323 | + $report .= "\tUser IP at Reg - ".$user['ip_at_reg']."\n"; |
|
324 | + $report .= "\tUser Agent- ".$_SERVER['HTTP_USER_AGENT']."\n"; |
|
325 | + $report .= "\tCurrent Page - ".$user['current_page']."\n"; |
|
326 | + $report .= "\tRegister Time - ".$user['register_time']."\n"; |
|
327 | 327 | $report .= "\n"; |
328 | 328 | |
329 | 329 | $report .= ">Query Information\n"; |
330 | - $report .= "\tQuery - " . $query . "\n"; |
|
330 | + $report .= "\tQuery - ".$query."\n"; |
|
331 | 331 | $report .= "\n"; |
332 | 332 | |
333 | 333 | $report .= ">\$_SERVER Information\n"; |
334 | - $report .= "\tIP - " . $_SERVER['REMOTE_ADDR'] . "\n"; |
|
335 | - $report .= "\tHost Name - " . $_SERVER['HTTP_HOST'] . "\n"; |
|
336 | - $report .= "\tUser Agent - " . $_SERVER['HTTP_USER_AGENT'] . "\n"; |
|
337 | - $report .= "\tRequest Method - " . $_SERVER['REQUEST_METHOD'] . "\n"; |
|
338 | - $report .= "\tCame From - " . $_SERVER['HTTP_REFERER'] . "\n"; |
|
339 | - $report .= "\tPage is - " . $_SERVER['SCRIPT_NAME'] . "\n"; |
|
340 | - $report .= "\tUses Port - " . $_SERVER['REMOTE_PORT'] . "\n"; |
|
341 | - $report .= "\tServer Protocol - " . $_SERVER['SERVER_PROTOCOL'] . "\n"; |
|
334 | + $report .= "\tIP - ".$_SERVER['REMOTE_ADDR']."\n"; |
|
335 | + $report .= "\tHost Name - ".$_SERVER['HTTP_HOST']."\n"; |
|
336 | + $report .= "\tUser Agent - ".$_SERVER['HTTP_USER_AGENT']."\n"; |
|
337 | + $report .= "\tRequest Method - ".$_SERVER['REQUEST_METHOD']."\n"; |
|
338 | + $report .= "\tCame From - ".$_SERVER['HTTP_REFERER']."\n"; |
|
339 | + $report .= "\tPage is - ".$_SERVER['SCRIPT_NAME']."\n"; |
|
340 | + $report .= "\tUses Port - ".$_SERVER['REMOTE_PORT']."\n"; |
|
341 | + $report .= "\tServer Protocol - ".$_SERVER['SERVER_PROTOCOL']."\n"; |
|
342 | 342 | |
343 | 343 | $report .= "\n--------------------------------------------------------------------------------------------------\n"; |
344 | 344 | |
345 | - $fp = fopen(SN_ROOT_PHYSICAL . 'badqrys.txt', 'a'); |
|
345 | + $fp = fopen(SN_ROOT_PHYSICAL.'badqrys.txt', 'a'); |
|
346 | 346 | fwrite($fp, $report); |
347 | 347 | fclose($fp); |
348 | 348 | |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | $prefix_length = strlen($this->db_prefix); |
364 | 364 | |
365 | 365 | $tl = array(); |
366 | - while($row = $this->db_fetch($query)) { |
|
366 | + while ($row = $this->db_fetch($query)) { |
|
367 | 367 | foreach ($row as $table_name) { |
368 | 368 | if (strpos($table_name, $this->db_prefix) === 0) { |
369 | 369 | $table_name = substr($table_name, $prefix_length); |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | if (is_bool($query)) { |
495 | 495 | throw new Exception('Result of SHOW STATUS command is boolean - which should never happen. Connection to DB is lost?'); |
496 | 496 | } |
497 | - while($row = db_fetch($query)) { |
|
497 | + while ($row = db_fetch($query)) { |
|
498 | 498 | $result[$row['Variable_name']] = $row['Value']; |
499 | 499 | } |
500 | 500 |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * @return array|null |
84 | 84 | */ |
85 | 85 | public static function getRecordById($recordId, $fieldList = '*', $forUpdate = false) { |
86 | - return static::getRecord(array(static::$_idField . '=' . $recordId), $fieldList, $forUpdate); |
|
86 | + return static::getRecord(array(static::$_idField.'='.$recordId), $fieldList, $forUpdate); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * @return array|bool|mysqli_result|null |
93 | 93 | */ |
94 | 94 | protected static function execute($statement) { |
95 | - return static::$dbStatic->execute((string)$statement); |
|
95 | + return static::$dbStatic->execute((string) $statement); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $query = static::execute( |
121 | 121 | static::buildSelectAll() |
122 | 122 | ->fields(static::$_idField) |
123 | - ->where(array("`" . static::$_idField . "` IN (" . implode(',', $idList) . ")")) |
|
123 | + ->where(array("`".static::$_idField."` IN (".implode(',', $idList).")")) |
|
124 | 124 | ); |
125 | 125 | } |
126 | 126 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | $result = array(); |
141 | 141 | if (!empty($idList)) { |
142 | 142 | $query = static::queryExistsIdInList($idList); |
143 | - while($row = db_fetch($query)) { |
|
143 | + while ($row = db_fetch($query)) { |
|
144 | 144 | $result[] = $row[static::$_idField]; |
145 | 145 | } |
146 | 146 | } |
@@ -108,11 +108,11 @@ discard block |
||
108 | 108 | $arguments = func_get_args(); |
109 | 109 | |
110 | 110 | // Special case - call method with array of fields |
111 | - if(count($arguments) == 1 && is_array($arguments[0])) { |
|
111 | + if (count($arguments) == 1 && is_array($arguments[0])) { |
|
112 | 112 | $arguments = array_shift($arguments); |
113 | 113 | } |
114 | 114 | |
115 | - foreach($arguments as $arg) { |
|
115 | + foreach ($arguments as $arg) { |
|
116 | 116 | $this->fields[] = $arg; |
117 | 117 | } |
118 | 118 | |
@@ -293,9 +293,9 @@ discard block |
||
293 | 293 | } |
294 | 294 | |
295 | 295 | protected function compileFrom() { |
296 | - $this->_compiledQuery[] = 'FROM `{{' . $this->stringEscape($this->table) . '}}`'; |
|
296 | + $this->_compiledQuery[] = 'FROM `{{'.$this->stringEscape($this->table).'}}`'; |
|
297 | 297 | if (!empty($this->alias)) { |
298 | - $this->_compiledQuery[] = 'AS `' . $this->stringEscape($this->alias) . '`'; |
|
298 | + $this->_compiledQuery[] = 'AS `'.$this->stringEscape($this->alias).'`'; |
|
299 | 299 | } |
300 | 300 | } |
301 | 301 | |
@@ -305,29 +305,29 @@ discard block |
||
305 | 305 | |
306 | 306 | protected function compileWhere() { |
307 | 307 | // TODO - fields should be escaped !! |
308 | - !empty($this->where) ? $this->_compiledQuery[] = 'WHERE ' . implode(' AND ', $this->where) : false; |
|
308 | + !empty($this->where) ? $this->_compiledQuery[] = 'WHERE '.implode(' AND ', $this->where) : false; |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | protected function compileGroupBy() { |
312 | 312 | // TODO - fields should be escaped !! |
313 | 313 | // !empty($this->groupBy) ? $this->_compiledQuery[] = 'GROUP BY ' . implode(',', $this->arrayEscape($this->groupBy)) : false; |
314 | - !empty($this->groupBy) ? $this->_compiledQuery[] = 'GROUP BY ' . $this->selectFieldsToString($this->groupBy) : false; |
|
314 | + !empty($this->groupBy) ? $this->_compiledQuery[] = 'GROUP BY '.$this->selectFieldsToString($this->groupBy) : false; |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | protected function compileOrderBy() { |
318 | 318 | // TODO - fields should be escaped !! |
319 | - !empty($this->orderBy) ? $this->_compiledQuery[] = 'ORDER BY ' . implode(',', $this->arrayEscape($this->orderBy)) : false; |
|
319 | + !empty($this->orderBy) ? $this->_compiledQuery[] = 'ORDER BY '.implode(',', $this->arrayEscape($this->orderBy)) : false; |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | protected function compileHaving() { |
323 | 323 | // TODO - fields should be escaped !! |
324 | - !empty($this->having) ? $this->_compiledQuery[] = 'HAVING ' . implode(' AND ', $this->having) : false; |
|
324 | + !empty($this->having) ? $this->_compiledQuery[] = 'HAVING '.implode(' AND ', $this->having) : false; |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | protected function compileLimit() { |
328 | 328 | // TODO - fields should be escaped !! |
329 | 329 | if ($limit = $this->fetchOne ? 1 : $this->limit) { |
330 | - $this->_compiledQuery[] = 'LIMIT ' . $limit . (!empty($this->offset) ? ' OFFSET ' . $this->offset : ''); |
|
330 | + $this->_compiledQuery[] = 'LIMIT '.$limit.(!empty($this->offset) ? ' OFFSET '.$this->offset : ''); |
|
331 | 331 | } |
332 | 332 | } |
333 | 333 | |
@@ -371,14 +371,14 @@ discard block |
||
371 | 371 | */ |
372 | 372 | protected function processField($fieldName) { |
373 | 373 | if (is_bool($fieldName)) { |
374 | - $result = (string)intval($fieldName); |
|
374 | + $result = (string) intval($fieldName); |
|
375 | 375 | } elseif (is_numeric($fieldName)) { |
376 | 376 | $result = $fieldName; |
377 | 377 | } elseif (is_null($fieldName)) { |
378 | 378 | $result = 'NULL'; |
379 | 379 | } else { |
380 | 380 | // Field has other type - string or should be convertible to string |
381 | - $result = (string)$fieldName; |
|
381 | + $result = (string) $fieldName; |
|
382 | 382 | if (!$fieldName instanceof DbSqlLiteral) { |
383 | 383 | $result = $this->makeFieldFromString($fieldName); |
384 | 384 | } |