@@ -15,6 +15,9 @@ |
||
15 | 15 | |
16 | 16 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ |
17 | 17 | |
18 | +/** |
|
19 | + * @param string $config |
|
20 | + */ |
|
18 | 21 | function displayPqp($output, $config) { |
19 | 22 | |
20 | 23 | $cssUrl = $config.'css/pQp.css'; |
@@ -167,8 +167,7 @@ discard block |
||
167 | 167 | |
168 | 168 | if($logCount == 0) { |
169 | 169 | echo '<h3>This panel has no log items.</h3>'; |
170 | -} |
|
171 | -else { |
|
170 | +} else { |
|
172 | 171 | echo '<table class="side" cellspacing="0"> |
173 | 172 | <tr> |
174 | 173 | <td class="alt1"><var>'.$output['logs']['logCount'].'</var><h4>Logs</h4></td> |
@@ -188,20 +187,20 @@ discard block |
||
188 | 187 | <td class="'.$class.'">'; |
189 | 188 | if($log['type'] == 'log') { |
190 | 189 | echo '<div><pre>'.$log['data'].'</pre></div>'; |
191 | - } |
|
192 | - elseif($log['type'] == 'memory') { |
|
190 | + } elseif($log['type'] == 'memory') { |
|
193 | 191 | echo '<div><pre>'.$log['data'].'</pre> <em>'.$log['dataType'].'</em>: '.$log['name'].' </div>'; |
194 | - } |
|
195 | - elseif($log['type'] == 'speed') { |
|
192 | + } elseif($log['type'] == 'speed') { |
|
196 | 193 | echo '<div><pre>'.$log['data'].'</pre> <em>'.$log['name'].'</em></div>'; |
197 | - } |
|
198 | - elseif($log['type'] == 'error') { |
|
194 | + } elseif($log['type'] == 'error') { |
|
199 | 195 | echo '<div><em>Line '.$log['line'].'</em> : '.$log['data'].' <pre>'.$log['file'].'</pre></div>'; |
200 | 196 | } |
201 | 197 | |
202 | 198 | echo '</td></tr>'; |
203 | - if($class == '') $class = 'alt'; |
|
204 | - else $class = ''; |
|
199 | + if($class == '') { |
|
200 | + $class = 'alt'; |
|
201 | + } else { |
|
202 | + $class = ''; |
|
203 | + } |
|
205 | 204 | } |
206 | 205 | |
207 | 206 | echo '</table>'; |
@@ -213,8 +212,7 @@ discard block |
||
213 | 212 | |
214 | 213 | if($output['logs']['speedCount'] == 0) { |
215 | 214 | echo '<h3>This panel has no log items.</h3>'; |
216 | -} |
|
217 | -else { |
|
215 | +} else { |
|
218 | 216 | echo '<table class="side" cellspacing="0"> |
219 | 217 | <tr><td><var>'.$output['speedTotals']['total'].'</var><h4>Load Time</h4></td></tr> |
220 | 218 | <tr><td class="alt"><var>'.$output['speedTotals']['allowed'].'</var> <h4>Max Execution Time</h4></td></tr> |
@@ -228,8 +226,11 @@ discard block |
||
228 | 226 | <td class="'.$class.'">'; |
229 | 227 | echo '<div><pre>'.$log['data'].'</pre> <em>'.$log['name'].'</em></div>'; |
230 | 228 | echo '</td></tr>'; |
231 | - if($class == '') $class = 'alt'; |
|
232 | - else $class = ''; |
|
229 | + if($class == '') { |
|
230 | + $class = 'alt'; |
|
231 | + } else { |
|
232 | + $class = ''; |
|
233 | + } |
|
233 | 234 | } |
234 | 235 | } |
235 | 236 | |
@@ -242,8 +243,7 @@ discard block |
||
242 | 243 | |
243 | 244 | if($output['queryTotals']['count'] == 0) { |
244 | 245 | echo '<h3>This panel has no log items.</h3>'; |
245 | -} |
|
246 | -else { |
|
246 | +} else { |
|
247 | 247 | echo '<table class="side" cellspacing="0"> |
248 | 248 | <tr><td><var>'.$output['queryTotals']['count'].'</var><h4>Total Queries</h4></td></tr> |
249 | 249 | <tr><td class="alt"><var>'.$output['queryTotals']['time'].'</var> <h4>Total Time</h4></td></tr> |
@@ -265,8 +265,11 @@ discard block |
||
265 | 265 | </em>'; |
266 | 266 | } |
267 | 267 | echo '</td></tr>'; |
268 | - if($class == '') $class = 'alt'; |
|
269 | - else $class = ''; |
|
268 | + if($class == '') { |
|
269 | + $class = 'alt'; |
|
270 | + } else { |
|
271 | + $class = ''; |
|
272 | + } |
|
270 | 273 | } |
271 | 274 | |
272 | 275 | echo '</table>'; |
@@ -278,8 +281,7 @@ discard block |
||
278 | 281 | |
279 | 282 | if($output['logs']['memoryCount'] == 0) { |
280 | 283 | echo '<h3>This panel has no log items.</h3>'; |
281 | -} |
|
282 | -else { |
|
284 | +} else { |
|
283 | 285 | echo '<table class="side" cellspacing="0"> |
284 | 286 | <tr><td><var>'.$output['memoryTotals']['used'].'</var><h4>Used Memory</h4></td></tr> |
285 | 287 | <tr><td class="alt"><var>'.$output['memoryTotals']['total'].'</var> <h4>Total Available</h4></td></tr> |
@@ -292,8 +294,11 @@ discard block |
||
292 | 294 | echo '<tr class="log-'.$log['type'].'">'; |
293 | 295 | echo '<td class="'.$class.'"><b>'.$log['data'].'</b> <em>'.$log['dataType'].'</em>: '.$log['name'].'</td>'; |
294 | 296 | echo '</tr>'; |
295 | - if($class == '') $class = 'alt'; |
|
296 | - else $class = ''; |
|
297 | + if($class == '') { |
|
298 | + $class = 'alt'; |
|
299 | + } else { |
|
300 | + $class = ''; |
|
301 | + } |
|
297 | 302 | } |
298 | 303 | } |
299 | 304 | |
@@ -306,8 +311,7 @@ discard block |
||
306 | 311 | |
307 | 312 | if($output['fileTotals']['count'] == 0) { |
308 | 313 | echo '<h3>This panel has no log items.</h3>'; |
309 | -} |
|
310 | -else { |
|
314 | +} else { |
|
311 | 315 | echo '<table class="side" cellspacing="0"> |
312 | 316 | <tr><td><var>'.$output['fileTotals']['count'].'</var><h4>Total Files</h4></td></tr> |
313 | 317 | <tr><td class="alt"><var>'.$output['fileTotals']['size'].'</var> <h4>Total Size</h4></td></tr> |
@@ -318,8 +322,11 @@ discard block |
||
318 | 322 | $class =''; |
319 | 323 | foreach($output['files'] as $file) { |
320 | 324 | echo '<tr><td class="'.$class.'"><b>'.$file['size'].'</b> '.$file['name'].'</td></tr>'; |
321 | - if($class == '') $class = 'alt'; |
|
322 | - else $class = ''; |
|
325 | + if($class == '') { |
|
326 | + $class = 'alt'; |
|
327 | + } else { |
|
328 | + $class = ''; |
|
329 | + } |
|
323 | 330 | } |
324 | 331 | |
325 | 332 | echo '</table>'; |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | |
18 | 18 | function displayPqp($output, $config) { |
19 | 19 | |
20 | -$css = file_get_contents(__DIR__ . '/css/pQp.css'); |
|
20 | +$css = file_get_contents(__DIR__.'/css/pQp.css'); |
|
21 | 21 | |
22 | 22 | echo <<<JAVASCRIPT |
23 | 23 | <!-- JavaScript --> |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | |
162 | 162 | echo '<div id="pqp-console" class="pqp-box">'; |
163 | 163 | |
164 | -if($logCount == 0) { |
|
164 | +if ($logCount == 0) { |
|
165 | 165 | echo '<h3>This panel has no log items.</h3>'; |
166 | 166 | } |
167 | 167 | else { |
@@ -178,25 +178,25 @@ discard block |
||
178 | 178 | <table class="main" cellspacing="0">'; |
179 | 179 | |
180 | 180 | $class = ''; |
181 | - foreach($output['logs']['console'] as $log) { |
|
181 | + foreach ($output['logs']['console'] as $log) { |
|
182 | 182 | echo '<tr class="log-'.$log['type'].'"> |
183 | 183 | <td class="type">'.$log['type'].'</td> |
184 | 184 | <td class="'.$class.'">'; |
185 | - if($log['type'] == 'log') { |
|
185 | + if ($log['type'] == 'log') { |
|
186 | 186 | echo '<div><pre>'.$log['data'].'</pre></div>'; |
187 | 187 | } |
188 | - elseif($log['type'] == 'memory') { |
|
188 | + elseif ($log['type'] == 'memory') { |
|
189 | 189 | echo '<div><pre>'.$log['data'].'</pre> <em>'.$log['dataType'].'</em>: '.$log['name'].' </div>'; |
190 | 190 | } |
191 | - elseif($log['type'] == 'speed') { |
|
191 | + elseif ($log['type'] == 'speed') { |
|
192 | 192 | echo '<div><pre>'.$log['data'].'</pre> <em>'.$log['name'].'</em></div>'; |
193 | 193 | } |
194 | - elseif($log['type'] == 'error') { |
|
194 | + elseif ($log['type'] == 'error') { |
|
195 | 195 | echo '<div><em>Line '.$log['line'].'</em> : '.$log['data'].' <pre>'.$log['file'].'</pre></div>'; |
196 | 196 | } |
197 | 197 | |
198 | 198 | echo '</td></tr>'; |
199 | - if($class == '') $class = 'alt'; |
|
199 | + if ($class == '') $class = 'alt'; |
|
200 | 200 | else $class = ''; |
201 | 201 | } |
202 | 202 | |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | |
208 | 208 | echo '<div id="pqp-speed" class="pqp-box">'; |
209 | 209 | |
210 | -if($output['logs']['speedCount'] == 0) { |
|
210 | +if ($output['logs']['speedCount'] == 0) { |
|
211 | 211 | echo '<h3>This panel has no log items.</h3>'; |
212 | 212 | } |
213 | 213 | else { |
@@ -218,13 +218,13 @@ discard block |
||
218 | 218 | <table class="main" cellspacing="0">'; |
219 | 219 | |
220 | 220 | $class = ''; |
221 | - foreach($output['logs']['console'] as $log) { |
|
222 | - if($log['type'] == 'speed') { |
|
221 | + foreach ($output['logs']['console'] as $log) { |
|
222 | + if ($log['type'] == 'speed') { |
|
223 | 223 | echo '<tr class="log-'.$log['type'].'"> |
224 | 224 | <td class="'.$class.'">'; |
225 | 225 | echo '<div><pre>'.$log['data'].'</pre> <em>'.$log['name'].'</em></div>'; |
226 | 226 | echo '</td></tr>'; |
227 | - if($class == '') $class = 'alt'; |
|
227 | + if ($class == '') $class = 'alt'; |
|
228 | 228 | else $class = ''; |
229 | 229 | } |
230 | 230 | } |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | |
237 | 237 | echo '<div id="pqp-queries" class="pqp-box">'; |
238 | 238 | |
239 | -if($output['queryTotals']['count'] == 0) { |
|
239 | +if ($output['queryTotals']['count'] == 0) { |
|
240 | 240 | echo '<h3>This panel has no log items.</h3>'; |
241 | 241 | } |
242 | 242 | else { |
@@ -248,10 +248,10 @@ discard block |
||
248 | 248 | <table class="main" cellspacing="0">'; |
249 | 249 | |
250 | 250 | $class = ''; |
251 | - foreach($output['queries'] as $query) { |
|
251 | + foreach ($output['queries'] as $query) { |
|
252 | 252 | echo '<tr> |
253 | 253 | <td class="'.$class.'">'.$query['sql']; |
254 | - if($query['explain']) { |
|
254 | + if ($query['explain']) { |
|
255 | 255 | echo '<em> |
256 | 256 | Possible keys: <b>'.$query['explain']['possible_keys'].'</b> · |
257 | 257 | Key Used: <b>'.$query['explain']['key'].'</b> · |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | </em>'; |
262 | 262 | } |
263 | 263 | echo '</td></tr>'; |
264 | - if($class == '') $class = 'alt'; |
|
264 | + if ($class == '') $class = 'alt'; |
|
265 | 265 | else $class = ''; |
266 | 266 | } |
267 | 267 | |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | |
273 | 273 | echo '<div id="pqp-memory" class="pqp-box">'; |
274 | 274 | |
275 | -if($output['logs']['memoryCount'] == 0) { |
|
275 | +if ($output['logs']['memoryCount'] == 0) { |
|
276 | 276 | echo '<h3>This panel has no log items.</h3>'; |
277 | 277 | } |
278 | 278 | else { |
@@ -283,12 +283,12 @@ discard block |
||
283 | 283 | <table class="main" cellspacing="0">'; |
284 | 284 | |
285 | 285 | $class = ''; |
286 | - foreach($output['logs']['console'] as $log) { |
|
287 | - if($log['type'] == 'memory') { |
|
286 | + foreach ($output['logs']['console'] as $log) { |
|
287 | + if ($log['type'] == 'memory') { |
|
288 | 288 | echo '<tr class="log-'.$log['type'].'">'; |
289 | 289 | echo '<td class="'.$class.'"><b>'.$log['data'].'</b> <em>'.$log['dataType'].'</em>: '.$log['name'].'</td>'; |
290 | 290 | echo '</tr>'; |
291 | - if($class == '') $class = 'alt'; |
|
291 | + if ($class == '') $class = 'alt'; |
|
292 | 292 | else $class = ''; |
293 | 293 | } |
294 | 294 | } |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | |
301 | 301 | echo '<div id="pqp-files" class="pqp-box">'; |
302 | 302 | |
303 | -if($output['fileTotals']['count'] == 0) { |
|
303 | +if ($output['fileTotals']['count'] == 0) { |
|
304 | 304 | echo '<h3>This panel has no log items.</h3>'; |
305 | 305 | } |
306 | 306 | else { |
@@ -311,10 +311,10 @@ discard block |
||
311 | 311 | </table> |
312 | 312 | <table class="main" cellspacing="0">'; |
313 | 313 | |
314 | - $class =''; |
|
315 | - foreach($output['files'] as $file) { |
|
314 | + $class = ''; |
|
315 | + foreach ($output['files'] as $file) { |
|
316 | 316 | echo '<tr><td class="'.$class.'"><b>'.$file['size'].'</b> '.$file['name'].'</td></tr>'; |
317 | - if($class == '') $class = 'alt'; |
|
317 | + if ($class == '') $class = 'alt'; |
|
318 | 318 | else $class = ''; |
319 | 319 | } |
320 | 320 |
@@ -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 | } |
@@ -48,8 +48,7 @@ |
||
48 | 48 | Console::logMemory($this, 'PQP Example Class : Line '.__LINE__); |
49 | 49 | Console::log('Ending log below with a sample error.'); |
50 | 50 | throw new Exception('Unable to write to log!'); |
51 | - } |
|
52 | - catch(Exception $e) { |
|
51 | + } catch(Exception $e) { |
|
53 | 52 | Console::logError($e, 'Sample error logging.'); |
54 | 53 | } |
55 | 54 | } |
@@ -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 | } |
@@ -36,7 +36,9 @@ 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) { |
|
40 | + $memory = strlen(serialize($object)); |
|
41 | + } |
|
40 | 42 | $logItem = array( |
41 | 43 | "data" => $memory, |
42 | 44 | "type" => 'memory', |
@@ -81,10 +83,18 @@ discard block |
||
81 | 83 | ------------------------------------*/ |
82 | 84 | |
83 | 85 | 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; |
|
86 | + if(!$GLOBALS['debugger_logs']['memoryCount']) { |
|
87 | + $GLOBALS['debugger_logs']['memoryCount'] = 0; |
|
88 | + } |
|
89 | + if(!$GLOBALS['debugger_logs']['logCount']) { |
|
90 | + $GLOBALS['debugger_logs']['logCount'] = 0; |
|
91 | + } |
|
92 | + if(!$GLOBALS['debugger_logs']['speedCount']) { |
|
93 | + $GLOBALS['debugger_logs']['speedCount'] = 0; |
|
94 | + } |
|
95 | + if(!$GLOBALS['debugger_logs']['errorCount']) { |
|
96 | + $GLOBALS['debugger_logs']['errorCount'] = 0; |
|
97 | + } |
|
88 | 98 | return $GLOBALS['debugger_logs']; |
89 | 99 | } |
90 | 100 | } |
@@ -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 |
@@ -53,7 +53,9 @@ 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) { |
|
57 | + $this->changeDatabase($this->database); |
|
58 | + } |
|
57 | 59 | } |
58 | 60 | |
59 | 61 | /*----------------------------------- |
@@ -61,7 +63,9 @@ discard block |
||
61 | 63 | ------------------------------------*/ |
62 | 64 | |
63 | 65 | function query($sql) { |
64 | - if(!$this->conn) $this->lazyLoadConnection(); |
|
66 | + if(!$this->conn) { |
|
67 | + $this->lazyLoadConnection(); |
|
68 | + } |
|
65 | 69 | $start = $this->getTime(); |
66 | 70 | $rs = mysql_query($sql, $this->conn); |
67 | 71 | $this->queryCount += 1; |
@@ -153,19 +153,19 @@ |
||
153 | 153 | } |
154 | 154 | |
155 | 155 | public function getReadableFileSize($size, $retstring = null) { |
156 | - // adapted from code at http://aidanlister.com/repos/v/function.size_readable.php |
|
157 | - $sizes = array('bytes', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); |
|
156 | + // adapted from code at http://aidanlister.com/repos/v/function.size_readable.php |
|
157 | + $sizes = array('bytes', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); |
|
158 | 158 | |
159 | - if ($retstring === null) { $retstring = '%01.2f %s'; } |
|
159 | + if ($retstring === null) { $retstring = '%01.2f %s'; } |
|
160 | 160 | |
161 | 161 | $lastsizestring = end($sizes); |
162 | 162 | |
163 | 163 | foreach ($sizes as $sizestring) { |
164 | - if ($size < 1024) { break; } |
|
165 | - if ($sizestring != $lastsizestring) { $size /= 1024; } |
|
166 | - } |
|
167 | - if ($sizestring == $sizes[0]) { $retstring = '%01d %s'; } // Bytes aren't normally fractional |
|
168 | - return sprintf($retstring, $size, $sizestring); |
|
164 | + if ($size < 1024) { break; } |
|
165 | + if ($sizestring != $lastsizestring) { $size /= 1024; } |
|
166 | + } |
|
167 | + if ($sizestring == $sizes[0]) { $retstring = '%01d %s'; } // Bytes aren't normally fractional |
|
168 | + return sprintf($retstring, $size, $sizestring); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | public function getReadableTime($time) { |
@@ -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 | |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | $this->gatherMemoryData(); |
197 | 197 | $this->gatherQueryData(); |
198 | 198 | $this->gatherSpeedData(); |
199 | - require_once __DIR__ . '/../display.php'; |
|
199 | + require_once __DIR__.'/../display.php'; |
|
200 | 200 | displayPqp($this->output, $this->config); |
201 | 201 | } |
202 | 202 |
@@ -37,11 +37,9 @@ discard block |
||
37 | 37 | foreach($logs['console'] as $key => $log) { |
38 | 38 | if($log['type'] == 'log') { |
39 | 39 | $logs['console'][$key]['data'] = print_r($log['data'], true); |
40 | - } |
|
41 | - elseif($log['type'] == 'memory') { |
|
40 | + } elseif($log['type'] == 'memory') { |
|
42 | 41 | $logs['console'][$key]['data'] = $this->getReadableFileSize($log['data']); |
43 | - } |
|
44 | - elseif($log['type'] == 'speed') { |
|
42 | + } elseif($log['type'] == 'speed') { |
|
45 | 43 | $logs['console'][$key]['data'] = $this->getReadableTime(($log['data'] - $this->startTime)*1000); |
46 | 44 | } |
47 | 45 | } |
@@ -69,7 +67,9 @@ discard block |
||
69 | 67 | 'size' => $this->getReadableFileSize($size) |
70 | 68 | ); |
71 | 69 | $fileTotals['size'] += $size; |
72 | - if($size > $fileTotals['largest']) $fileTotals['largest'] = $size; |
|
70 | + if($size > $fileTotals['largest']) { |
|
71 | + $fileTotals['largest'] = $size; |
|
72 | + } |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | $fileTotals['size'] = $this->getReadableFileSize($fileTotals['size']); |
@@ -122,8 +122,7 @@ discard block |
||
122 | 122 | try { |
123 | 123 | $sql = 'EXPLAIN '.$query['sql']; |
124 | 124 | $rs = $this->db->query($sql); |
125 | - } |
|
126 | - catch(Exception $e) {} |
|
125 | + } catch(Exception $e) {} |
|
127 | 126 | if($rs) { |
128 | 127 | $row = mysql_fetch_array($rs, MYSQL_ASSOC); |
129 | 128 | $query['explain'] = $row; |