@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | Console::log('Ending log below with a sample error.'); |
| 50 | 50 | throw new Exception('Unable to write to log!'); |
| 51 | 51 | } |
| 52 | - catch(Exception $e) { |
|
| 52 | + catch (Exception $e) { |
|
| 53 | 53 | Console::logError($e, 'Sample error logging.'); |
| 54 | 54 | } |
| 55 | 55 | } |
@@ -84,8 +84,8 @@ discard block |
||
| 84 | 84 | $ret = ''; |
| 85 | 85 | $longString = 'This is a really long string that when appended with the . symbol |
| 86 | 86 | will cause memory to be duplicated in order to create the new string.'; |
| 87 | - for($i = 0; $i < 10; $i++) { |
|
| 88 | - $ret = $ret . $longString; |
|
| 87 | + for ($i = 0; $i < 10; $i++) { |
|
| 88 | + $ret = $ret.$longString; |
|
| 89 | 89 | Console::logMemory($ret, 'Watch memory leak -- iteration '.$i); |
| 90 | 90 | } |
| 91 | 91 | } |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | |
| 166 | 166 | echo '<div id="pqp-console" class="pqp-box">'; |
| 167 | 167 | |
| 168 | -if($logCount == 0) { |
|
| 168 | +if ($logCount == 0) { |
|
| 169 | 169 | echo '<h3>This panel has no log items.</h3>'; |
| 170 | 170 | } |
| 171 | 171 | else { |
@@ -182,25 +182,25 @@ discard block |
||
| 182 | 182 | <table class="main" cellspacing="0">'; |
| 183 | 183 | |
| 184 | 184 | $class = ''; |
| 185 | - foreach($output['logs']['console'] as $log) { |
|
| 185 | + foreach ($output['logs']['console'] as $log) { |
|
| 186 | 186 | echo '<tr class="log-'.$log['type'].'"> |
| 187 | 187 | <td class="type">'.$log['type'].'</td> |
| 188 | 188 | <td class="'.$class.'">'; |
| 189 | - if($log['type'] == 'log') { |
|
| 189 | + if ($log['type'] == 'log') { |
|
| 190 | 190 | echo '<div><pre>'.$log['data'].'</pre></div>'; |
| 191 | 191 | } |
| 192 | - elseif($log['type'] == 'memory') { |
|
| 192 | + elseif ($log['type'] == 'memory') { |
|
| 193 | 193 | echo '<div><pre>'.$log['data'].'</pre> <em>'.$log['dataType'].'</em>: '.$log['name'].' </div>'; |
| 194 | 194 | } |
| 195 | - elseif($log['type'] == 'speed') { |
|
| 195 | + elseif ($log['type'] == 'speed') { |
|
| 196 | 196 | echo '<div><pre>'.$log['data'].'</pre> <em>'.$log['name'].'</em></div>'; |
| 197 | 197 | } |
| 198 | - elseif($log['type'] == 'error') { |
|
| 198 | + elseif ($log['type'] == 'error') { |
|
| 199 | 199 | echo '<div><em>Line '.$log['line'].'</em> : '.$log['data'].' <pre>'.$log['file'].'</pre></div>'; |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | echo '</td></tr>'; |
| 203 | - if($class == '') $class = 'alt'; |
|
| 203 | + if ($class == '') $class = 'alt'; |
|
| 204 | 204 | else $class = ''; |
| 205 | 205 | } |
| 206 | 206 | |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | |
| 212 | 212 | echo '<div id="pqp-speed" class="pqp-box">'; |
| 213 | 213 | |
| 214 | -if($output['logs']['speedCount'] == 0) { |
|
| 214 | +if ($output['logs']['speedCount'] == 0) { |
|
| 215 | 215 | echo '<h3>This panel has no log items.</h3>'; |
| 216 | 216 | } |
| 217 | 217 | else { |
@@ -222,13 +222,13 @@ discard block |
||
| 222 | 222 | <table class="main" cellspacing="0">'; |
| 223 | 223 | |
| 224 | 224 | $class = ''; |
| 225 | - foreach($output['logs']['console'] as $log) { |
|
| 226 | - if($log['type'] == 'speed') { |
|
| 225 | + foreach ($output['logs']['console'] as $log) { |
|
| 226 | + if ($log['type'] == 'speed') { |
|
| 227 | 227 | echo '<tr class="log-'.$log['type'].'"> |
| 228 | 228 | <td class="'.$class.'">'; |
| 229 | 229 | echo '<div><pre>'.$log['data'].'</pre> <em>'.$log['name'].'</em></div>'; |
| 230 | 230 | echo '</td></tr>'; |
| 231 | - if($class == '') $class = 'alt'; |
|
| 231 | + if ($class == '') $class = 'alt'; |
|
| 232 | 232 | else $class = ''; |
| 233 | 233 | } |
| 234 | 234 | } |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | |
| 241 | 241 | echo '<div id="pqp-queries" class="pqp-box">'; |
| 242 | 242 | |
| 243 | -if($output['queryTotals']['count'] == 0) { |
|
| 243 | +if ($output['queryTotals']['count'] == 0) { |
|
| 244 | 244 | echo '<h3>This panel has no log items.</h3>'; |
| 245 | 245 | } |
| 246 | 246 | else { |
@@ -252,10 +252,10 @@ discard block |
||
| 252 | 252 | <table class="main" cellspacing="0">'; |
| 253 | 253 | |
| 254 | 254 | $class = ''; |
| 255 | - foreach($output['queries'] as $query) { |
|
| 255 | + foreach ($output['queries'] as $query) { |
|
| 256 | 256 | echo '<tr> |
| 257 | 257 | <td class="'.$class.'">'.$query['sql']; |
| 258 | - if($query['explain']) { |
|
| 258 | + if ($query['explain']) { |
|
| 259 | 259 | echo '<em> |
| 260 | 260 | Possible keys: <b>'.$query['explain']['possible_keys'].'</b> · |
| 261 | 261 | Key Used: <b>'.$query['explain']['key'].'</b> · |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | </em>'; |
| 266 | 266 | } |
| 267 | 267 | echo '</td></tr>'; |
| 268 | - if($class == '') $class = 'alt'; |
|
| 268 | + if ($class == '') $class = 'alt'; |
|
| 269 | 269 | else $class = ''; |
| 270 | 270 | } |
| 271 | 271 | |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | |
| 277 | 277 | echo '<div id="pqp-memory" class="pqp-box">'; |
| 278 | 278 | |
| 279 | -if($output['logs']['memoryCount'] == 0) { |
|
| 279 | +if ($output['logs']['memoryCount'] == 0) { |
|
| 280 | 280 | echo '<h3>This panel has no log items.</h3>'; |
| 281 | 281 | } |
| 282 | 282 | else { |
@@ -287,12 +287,12 @@ discard block |
||
| 287 | 287 | <table class="main" cellspacing="0">'; |
| 288 | 288 | |
| 289 | 289 | $class = ''; |
| 290 | - foreach($output['logs']['console'] as $log) { |
|
| 291 | - if($log['type'] == 'memory') { |
|
| 290 | + foreach ($output['logs']['console'] as $log) { |
|
| 291 | + if ($log['type'] == 'memory') { |
|
| 292 | 292 | echo '<tr class="log-'.$log['type'].'">'; |
| 293 | 293 | echo '<td class="'.$class.'"><b>'.$log['data'].'</b> <em>'.$log['dataType'].'</em>: '.$log['name'].'</td>'; |
| 294 | 294 | echo '</tr>'; |
| 295 | - if($class == '') $class = 'alt'; |
|
| 295 | + if ($class == '') $class = 'alt'; |
|
| 296 | 296 | else $class = ''; |
| 297 | 297 | } |
| 298 | 298 | } |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | |
| 305 | 305 | echo '<div id="pqp-files" class="pqp-box">'; |
| 306 | 306 | |
| 307 | -if($output['fileTotals']['count'] == 0) { |
|
| 307 | +if ($output['fileTotals']['count'] == 0) { |
|
| 308 | 308 | echo '<h3>This panel has no log items.</h3>'; |
| 309 | 309 | } |
| 310 | 310 | else { |
@@ -315,10 +315,10 @@ discard block |
||
| 315 | 315 | </table> |
| 316 | 316 | <table class="main" cellspacing="0">'; |
| 317 | 317 | |
| 318 | - $class =''; |
|
| 319 | - foreach($output['files'] as $file) { |
|
| 318 | + $class = ''; |
|
| 319 | + foreach ($output['files'] as $file) { |
|
| 320 | 320 | echo '<tr><td class="'.$class.'"><b>'.$file['size'].'</b> '.$file['name'].'</td></tr>'; |
| 321 | - if($class == '') $class = 'alt'; |
|
| 321 | + if ($class == '') $class = 'alt'; |
|
| 322 | 322 | else $class = ''; |
| 323 | 323 | } |
| 324 | 324 | |
@@ -33,16 +33,16 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | public function gatherConsoleData() { |
| 35 | 35 | $logs = Console::getLogs(); |
| 36 | - if($logs['console']) { |
|
| 37 | - foreach($logs['console'] as $key => $log) { |
|
| 38 | - if($log['type'] == 'log') { |
|
| 36 | + if ($logs['console']) { |
|
| 37 | + foreach ($logs['console'] as $key => $log) { |
|
| 38 | + if ($log['type'] == 'log') { |
|
| 39 | 39 | $logs['console'][$key]['data'] = print_r($log['data'], true); |
| 40 | 40 | } |
| 41 | - elseif($log['type'] == 'memory') { |
|
| 41 | + elseif ($log['type'] == 'memory') { |
|
| 42 | 42 | $logs['console'][$key]['data'] = $this->getReadableFileSize($log['data']); |
| 43 | 43 | } |
| 44 | - elseif($log['type'] == 'speed') { |
|
| 45 | - $logs['console'][$key]['data'] = $this->getReadableTime(($log['data'] - $this->startTime)*1000); |
|
| 44 | + elseif ($log['type'] == 'speed') { |
|
| 45 | + $logs['console'][$key]['data'] = $this->getReadableTime(($log['data'] - $this->startTime) * 1000); |
|
| 46 | 46 | } |
| 47 | 47 | } |
| 48 | 48 | } |
@@ -62,14 +62,14 @@ discard block |
||
| 62 | 62 | "largest" => 0, |
| 63 | 63 | ); |
| 64 | 64 | |
| 65 | - foreach($files as $key => $file) { |
|
| 65 | + foreach ($files as $key => $file) { |
|
| 66 | 66 | $size = filesize($file); |
| 67 | 67 | $fileList[] = array( |
| 68 | 68 | 'name' => $file, |
| 69 | 69 | 'size' => $this->getReadableFileSize($size) |
| 70 | 70 | ); |
| 71 | 71 | $fileTotals['size'] += $size; |
| 72 | - if($size > $fileTotals['largest']) $fileTotals['largest'] = $size; |
|
| 72 | + if ($size > $fileTotals['largest']) $fileTotals['largest'] = $size; |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | $fileTotals['size'] = $this->getReadableFileSize($fileTotals['size']); |
@@ -99,9 +99,9 @@ discard block |
||
| 99 | 99 | $queryTotals['time'] = 0; |
| 100 | 100 | $queries = array(); |
| 101 | 101 | |
| 102 | - if($this->db != '') { |
|
| 102 | + if ($this->db != '') { |
|
| 103 | 103 | $queryTotals['count'] += $this->db->queryCount; |
| 104 | - foreach($this->db->queries as $key => $query) { |
|
| 104 | + foreach ($this->db->queries as $key => $query) { |
|
| 105 | 105 | $query = $this->attemptToExplainQuery($query); |
| 106 | 106 | $queryTotals['time'] += $query['time']; |
| 107 | 107 | $query['time'] = $this->getReadableTime($query['time']); |
@@ -123,8 +123,8 @@ discard block |
||
| 123 | 123 | $sql = 'EXPLAIN '.$query['sql']; |
| 124 | 124 | $rs = $this->db->query($sql); |
| 125 | 125 | } |
| 126 | - catch(Exception $e) {} |
|
| 127 | - if($rs) { |
|
| 126 | + catch (Exception $e) {} |
|
| 127 | + if ($rs) { |
|
| 128 | 128 | $row = mysql_fetch_array($rs, MYSQL_ASSOC); |
| 129 | 129 | $query['explain'] = $row; |
| 130 | 130 | } |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | |
| 138 | 138 | public function gatherSpeedData() { |
| 139 | 139 | $speedTotals = array(); |
| 140 | - $speedTotals['total'] = $this->getReadableTime(($this->getMicroTime() - $this->startTime)*1000); |
|
| 140 | + $speedTotals['total'] = $this->getReadableTime(($this->getMicroTime() - $this->startTime) * 1000); |
|
| 141 | 141 | $speedTotals['allowed'] = ini_get("max_execution_time"); |
| 142 | 142 | $this->output['speedTotals'] = $speedTotals; |
| 143 | 143 | } |
@@ -172,15 +172,15 @@ discard block |
||
| 172 | 172 | $ret = $time; |
| 173 | 173 | $formatter = 0; |
| 174 | 174 | $formats = array('ms', 's', 'm'); |
| 175 | - if($time >= 1000 && $time < 60000) { |
|
| 175 | + if ($time >= 1000 && $time < 60000) { |
|
| 176 | 176 | $formatter = 1; |
| 177 | 177 | $ret = ($time / 1000); |
| 178 | 178 | } |
| 179 | - if($time >= 60000) { |
|
| 179 | + if ($time >= 60000) { |
|
| 180 | 180 | $formatter = 2; |
| 181 | 181 | $ret = ($time / 1000) / 60; |
| 182 | 182 | } |
| 183 | - $ret = number_format($ret,3,'.','') . ' ' . $formats[$formatter]; |
|
| 183 | + $ret = number_format($ret, 3, '.', '').' '.$formats[$formatter]; |
|
| 184 | 184 | return $ret; |
| 185 | 185 | } |
| 186 | 186 | |
@@ -37,15 +37,15 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | function connect($new = false) { |
| 39 | 39 | $this->conn = mysql_connect($this->host, $this->user, $this->password, $new); |
| 40 | - if(!$this->conn) { |
|
| 40 | + if (!$this->conn) { |
|
| 41 | 41 | throw new Exception('We\'re working on a few connection issues.'); |
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | function changeDatabase($database) { |
| 46 | 46 | $this->database = $database; |
| 47 | - if($this->conn) { |
|
| 48 | - if(!mysql_select_db($database, $this->conn)) { |
|
| 47 | + if ($this->conn) { |
|
| 48 | + if (!mysql_select_db($database, $this->conn)) { |
|
| 49 | 49 | throw new CustomException('We\'re working on a few connection issues.'); |
| 50 | 50 | } |
| 51 | 51 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | function lazyLoadConnection() { |
| 55 | 55 | $this->connect(true); |
| 56 | - if($this->database) $this->changeDatabase($this->database); |
|
| 56 | + if ($this->database) $this->changeDatabase($this->database); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /*----------------------------------- |
@@ -61,12 +61,12 @@ discard block |
||
| 61 | 61 | ------------------------------------*/ |
| 62 | 62 | |
| 63 | 63 | function query($sql) { |
| 64 | - if(!$this->conn) $this->lazyLoadConnection(); |
|
| 64 | + if (!$this->conn) $this->lazyLoadConnection(); |
|
| 65 | 65 | $start = $this->getTime(); |
| 66 | 66 | $rs = mysql_query($sql, $this->conn); |
| 67 | 67 | $this->queryCount += 1; |
| 68 | 68 | $this->logQuery($sql, $start); |
| 69 | - if(!$rs) { |
|
| 69 | + if (!$rs) { |
|
| 70 | 70 | throw new Exception('Could not execute query.'); |
| 71 | 71 | } |
| 72 | 72 | return $rs; |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | function logQuery($sql, $start) { |
| 80 | 80 | $query = array( |
| 81 | 81 | 'sql' => $sql, |
| 82 | - 'time' => ($this->getTime() - $start)*1000 |
|
| 82 | + 'time' => ($this->getTime() - $start) * 1000 |
|
| 83 | 83 | ); |
| 84 | 84 | array_push($this->queries, $query); |
| 85 | 85 | } |
@@ -96,19 +96,19 @@ discard block |
||
| 96 | 96 | $ret = $time; |
| 97 | 97 | $formatter = 0; |
| 98 | 98 | $formats = array('ms', 's', 'm'); |
| 99 | - if($time >= 1000 && $time < 60000) { |
|
| 99 | + if ($time >= 1000 && $time < 60000) { |
|
| 100 | 100 | $formatter = 1; |
| 101 | 101 | $ret = ($time / 1000); |
| 102 | 102 | } |
| 103 | - if($time >= 60000) { |
|
| 103 | + if ($time >= 60000) { |
|
| 104 | 104 | $formatter = 2; |
| 105 | 105 | $ret = ($time / 1000) / 60; |
| 106 | 106 | } |
| 107 | - $ret = number_format($ret,3,'.','') . ' ' . $formats[$formatter]; |
|
| 107 | + $ret = number_format($ret, 3, '.', '').' '.$formats[$formatter]; |
|
| 108 | 108 | return $ret; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - function __destruct() { |
|
| 111 | + function __destruct() { |
|
| 112 | 112 | @mysql_close($this->conn); |
| 113 | 113 | } |
| 114 | 114 | |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | public function logMemory($object = false, $name = 'PHP') { |
| 38 | 38 | $memory = memory_get_usage(); |
| 39 | - if($object) $memory = strlen(serialize($object)); |
|
| 39 | + if ($object) $memory = strlen(serialize($object)); |
|
| 40 | 40 | $logItem = array( |
| 41 | 41 | "data" => $memory, |
| 42 | 42 | "type" => 'memory', |
@@ -81,10 +81,10 @@ discard block |
||
| 81 | 81 | ------------------------------------*/ |
| 82 | 82 | |
| 83 | 83 | public function getLogs() { |
| 84 | - if(!$GLOBALS['debugger_logs']['memoryCount']) $GLOBALS['debugger_logs']['memoryCount'] = 0; |
|
| 85 | - if(!$GLOBALS['debugger_logs']['logCount']) $GLOBALS['debugger_logs']['logCount'] = 0; |
|
| 86 | - if(!$GLOBALS['debugger_logs']['speedCount']) $GLOBALS['debugger_logs']['speedCount'] = 0; |
|
| 87 | - if(!$GLOBALS['debugger_logs']['errorCount']) $GLOBALS['debugger_logs']['errorCount'] = 0; |
|
| 84 | + if (!$GLOBALS['debugger_logs']['memoryCount']) $GLOBALS['debugger_logs']['memoryCount'] = 0; |
|
| 85 | + if (!$GLOBALS['debugger_logs']['logCount']) $GLOBALS['debugger_logs']['logCount'] = 0; |
|
| 86 | + if (!$GLOBALS['debugger_logs']['speedCount']) $GLOBALS['debugger_logs']['speedCount'] = 0; |
|
| 87 | + if (!$GLOBALS['debugger_logs']['errorCount']) $GLOBALS['debugger_logs']['errorCount'] = 0; |
|
| 88 | 88 | return $GLOBALS['debugger_logs']; |
| 89 | 89 | } |
| 90 | 90 | } |