Completed
Push — work-fleets ( e155c0...addb18 )
by SuperNova.WS
06:08
created
includes/classes/Entity.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
        * @param static $that
54 54
        */
55 55
       // Alas! No bindTo() method in 5.3 closures! So we should use what we have
56
-      $propertyData[P_DB_ROW_EXPORT] = function ($that, &$row) use ($propertyName, $fieldName, $propertyData) {
56
+      $propertyData[P_DB_ROW_EXPORT] = function($that, &$row) use ($propertyName, $fieldName, $propertyData) {
57 57
         $row[$fieldName] = $that->$propertyName;
58 58
       };
59 59
     }
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
        * @param static $that
70 70
        */
71 71
       // Alas! No bindTo() method in 5.3 closures! So we should use what we have
72
-      $propertyData[P_DB_ROW_IMPORT] = function ($that, &$row) use ($propertyName, $fieldName, $propertyData) {
72
+      $propertyData[P_DB_ROW_IMPORT] = function($that, &$row) use ($propertyName, $fieldName, $propertyData) {
73 73
         $type = !empty($propertyData[P_DB_TYPE]) ? $propertyData[P_DB_TYPE] : '';
74 74
 
75 75
         // "array"
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 
95 95
           // No-type defaults to string
96 96
           default:
97
-            $value = (string)$row[$fieldName];
97
+            $value = (string) $row[$fieldName];
98 98
           break;
99 99
         }
100 100
 
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
         // TODO - however for a sake of uniformity may be we should consider use call_user_func
189 189
 //      call_user_func($propertyData[P_DB_ROW_EXPORT], $this);
190 190
       } else {
191
-        throw new \Exception('There is no valid DB row ' . $desc . ' for ' . get_called_class() . '::' . $propertyName);
191
+        throw new \Exception('There is no valid DB row '.$desc.' for '.get_called_class().'::'.$propertyName);
192 192
       }
193 193
     }
194 194
   }
Please login to merge, or discard this patch.
includes/classes/debug.php 1 patch
Spacing   +74 added lines, -75 removed lines patch added patch discarded remove patch
@@ -30,10 +30,10 @@  discard block
 block discarded – undo
30 30
 
31 31
 defined('INSIDE') || die();
32 32
 
33
-if(php_sapi_name() == "cli") {
33
+if (php_sapi_name() == "cli") {
34 34
   // In cli-mode
35 35
   define('__DEBUG_CRLF', "\r\n");
36
-  define('__DEBUG_LINE', '-------------------------------------------------' . __DEBUG_CRLF);
36
+  define('__DEBUG_LINE', '-------------------------------------------------'.__DEBUG_CRLF);
37 37
 } else {
38 38
   // Not in cli-mode
39 39
   define('__DEBUG_CRLF', '<br />');
@@ -50,17 +50,17 @@  discard block
 block discarded – undo
50 50
   function log_file($message, $ident_change = 0) {
51 51
     static $ident = 0;
52 52
 
53
-    if(!defined('SN_DEBUG_LOG')) {
53
+    if (!defined('SN_DEBUG_LOG')) {
54 54
       return;
55 55
     }
56 56
 
57
-    if($this->log_file_handler === null) {
58
-      $this->log_file_handler = @fopen(SN_ROOT_PHYSICAL . '/.logs/supernova.log', 'a+');
57
+    if ($this->log_file_handler === null) {
58
+      $this->log_file_handler = @fopen(SN_ROOT_PHYSICAL.'/.logs/supernova.log', 'a+');
59 59
       @fwrite($this->log_file_handler, "\r\n\r\n");
60 60
     }
61 61
     $ident_change < 0 ? $ident += $ident_change * 2 : false;
62
-    if($this->log_file_handler) {
63
-      @fwrite($this->log_file_handler, date(FMT_DATE_TIME_SQL, time()) . str_repeat(' ', $ident + 1) . $message . "\r\n");
62
+    if ($this->log_file_handler) {
63
+      @fwrite($this->log_file_handler, date(FMT_DATE_TIME_SQL, time()).str_repeat(' ', $ident + 1).$message."\r\n");
64 64
     }
65 65
     $ident_change > 0 ? $ident += $ident_change * 2 : false;
66 66
   }
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
   }
81 81
 
82 82
   function echo_log() {
83
-    echo '<br><table><tr><td class=k colspan=4><a href="' . SN_ROOT_PHYSICAL . "admin/settings.php\">Debug Log</a>:</td></tr>{$this->log}</table>";
83
+    echo '<br><table><tr><td class=k colspan=4><a href="'.SN_ROOT_PHYSICAL."admin/settings.php\">Debug Log</a>:</td></tr>{$this->log}</table>";
84 84
     die();
85 85
   }
86 86
 
@@ -90,25 +90,25 @@  discard block
 block discarded – undo
90 90
     $result = array();
91 91
     $transaction_id = classSupernova::db_transaction_check(false) ? classSupernova::$transaction_id : classSupernova::$transaction_id++;
92 92
     $result[] = "tID {$transaction_id}";
93
-    foreach($backtrace as $a_trace) {
94
-      if(in_array($a_trace['function'], $exclude_functions)) {
93
+    foreach ($backtrace as $a_trace) {
94
+      if (in_array($a_trace['function'], $exclude_functions)) {
95 95
         continue;
96 96
       }
97 97
       $function =
98 98
         ($a_trace['type']
99 99
           ? ($a_trace['type'] == '->'
100
-            ? "({$a_trace['class']})" . get_class($a_trace['object'])
100
+            ? "({$a_trace['class']})".get_class($a_trace['object'])
101 101
             : $a_trace['class']
102
-          ) . $a_trace['type']
102
+          ).$a_trace['type']
103 103
           : ''
104
-        ) . $a_trace['function'] . '()';
104
+        ).$a_trace['function'].'()';
105 105
 
106 106
       $file = str_replace(SN_ROOT_PHYSICAL, '', str_replace('\\', '/', $a_trace['file']));
107 107
 
108 108
       // $result[] = "{$function} ({$a_trace['line']})'{$file}'";
109 109
       $result[] = "{$function} - '{$file}' Line {$a_trace['line']}";
110 110
 
111
-      if(!$long_comment) {
111
+      if (!$long_comment) {
112 112
         break;
113 113
       }
114 114
     }
@@ -122,26 +122,26 @@  discard block
 block discarded – undo
122 122
   function dump($dump = false, $force_base = false, $deadlock = false) {
123 123
     global $user, $planetrow;
124 124
 
125
-    if($dump === false) {
125
+    if ($dump === false) {
126 126
       return;
127 127
     }
128 128
 
129 129
     $error_backtrace = array();
130 130
     $base_dump = false;
131 131
 
132
-    if($force_base === true) {
132
+    if ($force_base === true) {
133 133
       $base_dump = true;
134 134
     }
135 135
 
136
-    if($dump === true) {
136
+    if ($dump === true) {
137 137
       $base_dump = true;
138 138
     } else {
139
-      if(!is_array($dump)) {
139
+      if (!is_array($dump)) {
140 140
         $dump = array('var' => $dump);
141 141
       }
142 142
 
143
-      foreach($dump as $dump_var_name => $dump_var) {
144
-        if($dump_var_name == 'base_dump') {
143
+      foreach ($dump as $dump_var_name => $dump_var) {
144
+        if ($dump_var_name == 'base_dump') {
145 145
           $base_dump = $dump_var;
146 146
         } else {
147 147
           $error_backtrace[$dump_var_name] = $dump_var;
@@ -149,22 +149,21 @@  discard block
 block discarded – undo
149 149
       }
150 150
     }
151 151
 
152
-    if($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) {
152
+    if ($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) {
153 153
       $error_backtrace['deadlock'] = explode("\n", $q['Status']);
154 154
       $error_backtrace['locks'] = SnCache::getLocks();
155 155
       $error_backtrace['cSN_data'] = SnCache::getData();
156
-      foreach($error_backtrace['cSN_data'] as &$location) {
157
-        foreach($location as $location_id => &$location_data) {
158
-          $location_data = isset($location_data['username']) ? $location_data['username'] :
159
-            (isset($location_data['name']) ? $location_data['name'] : $location_id);
156
+      foreach ($error_backtrace['cSN_data'] as &$location) {
157
+        foreach ($location as $location_id => &$location_data) {
158
+          $location_data = isset($location_data['username']) ? $location_data['username'] : (isset($location_data['name']) ? $location_data['name'] : $location_id);
160 159
         }
161 160
       }
162 161
       $error_backtrace['cSN_queries'] = SnCache::getQueries();
163 162
     }
164 163
 
165
-    if($base_dump) {
166
-      if(is_array($this->log_array) && count($this->log_array) > 0) {
167
-        foreach($this->log_array as $log) {
164
+    if ($base_dump) {
165
+      if (is_array($this->log_array) && count($this->log_array) > 0) {
166
+        foreach ($this->log_array as $log) {
168 167
           $error_backtrace['queries'][] = $log;
169 168
         }
170 169
       }
@@ -193,14 +192,14 @@  discard block
 block discarded – undo
193 192
   function error($message = 'There is a error on page', $title = 'Internal Error', $error_code = 500, $dump = true) {
194 193
     global $sys_stop_log_hit, $sys_log_disabled, $user;
195 194
 
196
-    if(empty(classSupernova::$db->connected)) {
195
+    if (empty(classSupernova::$db->connected)) {
197 196
       // TODO - писать ошибку в файл
198 197
       die('SQL server currently unavailable. Please contact Administration...');
199 198
     }
200 199
 
201 200
     sn_db_transaction_rollback();
202 201
 
203
-    if(classSupernova::$config->debug == 1) {
202
+    if (classSupernova::$config->debug == 1) {
204 203
       echo "<h2>{$title}</h2><br><font color=red>{$message}</font><br><hr>";
205 204
       echo "<table>{$this->log}</table>";
206 205
     }
@@ -212,16 +211,16 @@  discard block
 block discarded – undo
212 211
 
213 212
     $userId = empty($user['id']) ? 0 : $user['id'];
214 213
 
215
-    if(!$sys_log_disabled) {
214
+    if (!$sys_log_disabled) {
216 215
       $query = "INSERT INTO `{{logs}}` SET
217
-        `log_time` = '" . time() . "', `log_code` = '" . db_escape($error_code) . "', `log_sender` = '" . db_escape($userId) . "',
218
-        `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "',  `log_text` = '" . db_escape($message) . "',
219
-        `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE))) . "'" .
216
+        `log_time` = '" . time()."', `log_code` = '".db_escape($error_code)."', `log_sender` = '".db_escape($userId)."',
217
+        `log_username` = '" . db_escape($user['user_name'])."', `log_title` = '".db_escape($title)."',  `log_text` = '".db_escape($message)."',
218
+        `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE)))."'".
220 219
 //        ($error_backtrace ? ", `log_dump` = '" . db_escape(serialize($error_backtrace)) . "'" : '') . ";";
221
-      ", `log_dump` = '" . ($error_backtrace ? db_escape(serialize($error_backtrace)) : '') . "'" . ";";
222
-      doquery($query, '', false, true) or die($fatal_error . classSupernova::$db->db_error());
220
+      ", `log_dump` = '".($error_backtrace ? db_escape(serialize($error_backtrace)) : '')."'".";";
221
+      doquery($query, '', false, true) or die($fatal_error.classSupernova::$db->db_error());
223 222
 
224
-      $message = "Пожалуйста, свяжитесь с админом, если ошибка повторится. Ошибка №: <b>" . classSupernova::$db->db_insert_id() . "</b>";
223
+      $message = "Пожалуйста, свяжитесь с админом, если ошибка повторится. Ошибка №: <b>".classSupernova::$db->db_insert_id()."</b>";
225 224
 
226 225
       $sys_stop_log_hit = true;
227 226
       $sys_log_disabled = true;
@@ -231,7 +230,7 @@  discard block
 block discarded – undo
231 230
       ob_start();
232 231
       print("<hr>User ID {$user['id']} raised error code {$error_code} titled '{$title}' with text '{$error_text}' on page {$_SERVER['SCRIPT_NAME']}");
233 232
 
234
-      foreach($error_backtrace as $name => $value) {
233
+      foreach ($error_backtrace as $name => $value) {
235 234
         print(__DEBUG_LINE);
236 235
         pdump($value, $name);
237 236
       }
@@ -243,7 +242,7 @@  discard block
 block discarded – undo
243 242
   function warning($message, $title = 'System Message', $log_code = 300, $dump = false) {
244 243
     global $user, $sys_log_disabled;
245 244
 
246
-    if(empty(classSupernova::$db->connected)) {
245
+    if (empty(classSupernova::$db->connected)) {
247 246
       // TODO - писать ошибку в файл
248 247
       die('SQL server currently unavailable. Please contact Administration...');
249 248
     }
@@ -252,12 +251,12 @@  discard block
 block discarded – undo
252 251
 
253 252
     $userId = empty($user['id']) ? 0 : $user['id'];
254 253
 
255
-    if(!$sys_log_disabled) {
254
+    if (!$sys_log_disabled) {
256 255
       $query = "INSERT INTO `{{logs}}` SET
257
-        `log_time` = '" . time() . "', `log_code` = '" . db_escape($log_code) . "', `log_sender` = '" . db_escape($userId) . "',
258
-        `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "',  `log_text` = '" . db_escape($message) . "',
259
-        `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE))) . "'" .
260
-        ", `log_dump` = '" . ($error_backtrace ? db_escape(serialize($error_backtrace)) : '') . "'" . ";";
256
+        `log_time` = '" . time()."', `log_code` = '".db_escape($log_code)."', `log_sender` = '".db_escape($userId)."',
257
+        `log_username` = '" . db_escape($user['user_name'])."', `log_title` = '".db_escape($title)."',  `log_text` = '".db_escape($message)."',
258
+        `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE)))."'".
259
+        ", `log_dump` = '".($error_backtrace ? db_escape(serialize($error_backtrace)) : '')."'".";";
261 260
       doquery($query, '', false, true);
262 261
     } else {
263 262
 //        // TODO Здесь надо писать в файло
@@ -270,11 +269,11 @@  discard block
 block discarded – undo
270 269
 // Dump variables nicer then var_dump()
271 270
 
272 271
 function dump($value, $varname = null, $level = 0, $dumper = '') {
273
-  if(isset($varname)) {
272
+  if (isset($varname)) {
274 273
     $varname .= " = ";
275 274
   }
276 275
 
277
-  if($level == -1) {
276
+  if ($level == -1) {
278 277
     $trans[' '] = '&there4;';
279 278
     $trans["\t"] = '&rArr;';
280 279
     $trans["\n"] = '&para;;';
@@ -283,31 +282,31 @@  discard block
 block discarded – undo
283 282
 
284 283
     return strtr(htmlspecialchars($value), $trans);
285 284
   }
286
-  if($level == 0) {
285
+  if ($level == 0) {
287 286
 //    $dumper = '<pre>' . mt_rand(10, 99) . '|' . $varname;
288
-    $dumper = mt_rand(10, 99) . '|' . $varname;
287
+    $dumper = mt_rand(10, 99).'|'.$varname;
289 288
   }
290 289
 
291 290
   $type = gettype($value);
292 291
   $dumper .= $type;
293 292
 
294
-  if($type == TYPE_STRING) {
295
-    $dumper .= '(' . strlen($value) . ')';
293
+  if ($type == TYPE_STRING) {
294
+    $dumper .= '('.strlen($value).')';
296 295
     $value = dump($value, '', -1);
297
-  } elseif($type == TYPE_BOOLEAN) {
296
+  } elseif ($type == TYPE_BOOLEAN) {
298 297
     $value = ($value ? 'true' : 'false');
299
-  } elseif($type == 'object') {
298
+  } elseif ($type == 'object') {
300 299
     $props = get_class_vars(get_class($value));
301
-    $dumper .= '(' . count($props) . ') <u>' . get_class($value) . '</u>';
302
-    foreach($props as $key => $val) {
303
-      $dumper .= "\n" . str_repeat("\t", $level + 1) . $key . ' => ';
300
+    $dumper .= '('.count($props).') <u>'.get_class($value).'</u>';
301
+    foreach ($props as $key => $val) {
302
+      $dumper .= "\n".str_repeat("\t", $level + 1).$key.' => ';
304 303
       $dumper .= dump($value->$key, '', $level + 1);
305 304
     }
306 305
     $value = '';
307
-  } elseif($type == TYPE_ARRAY) {
308
-    $dumper .= '(' . count($value) . ')';
309
-    foreach($value as $key => $val) {
310
-      $dumper .= "\n" . str_repeat("\t", $level + 1) . dump($key, '', -1) . ' => ';
306
+  } elseif ($type == TYPE_ARRAY) {
307
+    $dumper .= '('.count($value).')';
308
+    foreach ($value as $key => $val) {
309
+      $dumper .= "\n".str_repeat("\t", $level + 1).dump($key, '', -1).' => ';
311 310
       $dumper .= dump($val, '', $level + 1);
312 311
     }
313 312
     $value = '';
@@ -326,24 +325,24 @@  discard block
 block discarded – undo
326 325
 //  $backtrace = $backtrace[1];
327 326
 
328 327
   $caller = '';
329
-  if(defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) {
330
-    $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : '') .
331
-      (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : '') .
332
-      $backtrace[1]['function'] .
328
+  if (defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) {
329
+    $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : '').
330
+      (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : '').
331
+      $backtrace[1]['function'].
333 332
       (!empty($backtrace[0]['file'])
334 333
         ? (
335
-          ' (' . substr($backtrace[0]['file'], SN_ROOT_PHYSICAL_STR_LEN) .
336
-          (!empty($backtrace[0]['line']) ? ':' . $backtrace[0]['line'] : '') .
334
+          ' ('.substr($backtrace[0]['file'], SN_ROOT_PHYSICAL_STR_LEN).
335
+          (!empty($backtrace[0]['line']) ? ':'.$backtrace[0]['line'] : '').
337 336
           ')'
338 337
         )
339 338
         : ''
340 339
       );
341
-    $caller = "\r\n" . $caller;
340
+    $caller = "\r\n".$caller;
342 341
   }
343 342
 
344
-  print('<pre style="text-align: left; background-color: #111111; color: #0A0; font-family: Courier, monospace !important; padding: 1em 0; font-weight: 800; font-size: 14px;">' .
345
-    dump($value, $varname) .
346
-    $caller .
343
+  print('<pre style="text-align: left; background-color: #111111; color: #0A0; font-family: Courier, monospace !important; padding: 1em 0; font-weight: 800; font-size: 14px;">'.
344
+    dump($value, $varname).
345
+    $caller.
347 346
     '</pre>'
348 347
   );
349 348
 }
@@ -353,24 +352,24 @@  discard block
 block discarded – undo
353 352
 }
354 353
 
355 354
 function pr($prePrint = false) {
356
-  if($prePrint) {
355
+  if ($prePrint) {
357 356
     print(__DEBUG_CRLF);
358 357
   }
359
-  print(mt_rand() . __DEBUG_CRLF);
358
+  print(mt_rand().__DEBUG_CRLF);
360 359
 }
361 360
 
362 361
 function pc($prePrint = false) {
363 362
   global $_PRINT_COUNT_VALUE;
364 363
   $_PRINT_COUNT_VALUE++;
365 364
 
366
-  if($prePrint) {
365
+  if ($prePrint) {
367 366
     print(__DEBUG_CRLF);
368 367
   }
369
-  print($_PRINT_COUNT_VALUE . __DEBUG_CRLF);
368
+  print($_PRINT_COUNT_VALUE.__DEBUG_CRLF);
370 369
 }
371 370
 
372 371
 function prep($message) {
373
-  print('<pre>' . $message . '</pre>');
372
+  print('<pre>'.$message.'</pre>');
374 373
 }
375 374
 
376 375
 function backtrace_no_arg() {
@@ -393,5 +392,5 @@  discard block
 block discarded – undo
393 392
  */
394 393
 function pdie($message = '') {
395 394
   $backtrace = debug_backtrace();
396
-  die(__DEBUG_LINE . ($message ? $message . ' @ ' : '') . $backtrace[0]['file'] . ':' . $backtrace[0]['line']);
395
+  die(__DEBUG_LINE.($message ? $message.' @ ' : '').$backtrace[0]['file'].':'.$backtrace[0]['line']);
397 396
 }
Please login to merge, or discard this patch.