@@ -26,13 +26,13 @@ discard block |
||
26 | 26 | require_once('../inc/sanitize_html.inc'); |
27 | 27 | |
28 | 28 | class output_options { |
29 | - var $bb2html; // BBCode as HTML? (on) |
|
30 | - var $images_as_links; // Images as hyperlinks? (off) |
|
31 | - var $link_popup; // Links in new windows? (off) |
|
32 | - var $nl2br; // Convert newlines to <br>'s? (on) |
|
33 | - var $htmlitems; // Convert special chars to HTML entities? (on) |
|
34 | - var $htmlscrub; // Scrub "bad" HTML tags? (off) |
|
35 | - var $highlight_terms;// Array of terms to be highlighted (off) |
|
29 | + var $bb2html; // BBCode as HTML? (on) |
|
30 | + var $images_as_links; // Images as hyperlinks? (off) |
|
31 | + var $link_popup; // Links in new windows? (off) |
|
32 | + var $nl2br; // Convert newlines to <br>'s? (on) |
|
33 | + var $htmlitems; // Convert special chars to HTML entities? (on) |
|
34 | + var $htmlscrub; // Scrub "bad" HTML tags? (off) |
|
35 | + var $highlight_terms; // Array of terms to be highlighted (off) |
|
36 | 36 | |
37 | 37 | // Constructor - set the defaults. |
38 | 38 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $options = new output_options; // Defaults in the class definition |
69 | 69 | } |
70 | 70 | if ($options->htmlitems) { |
71 | - $text = htmlspecialchars($text, ENT_COMPAT | ENT_HTML401 | ENT_SUBSTITUTE); |
|
71 | + $text = htmlspecialchars($text, ENT_COMPAT|ENT_HTML401|ENT_SUBSTITUTE); |
|
72 | 72 | } |
73 | 73 | if (is_array($options->highlight_terms)) { |
74 | 74 | $text = highlight_terms($text, $options->highlight_terms); |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | // If $export is true, don't use BOINC CSS |
105 | 105 | |
106 | 106 | function substr2($s, $n1, $n2) { |
107 | - return substr($s, $n1, $n2-$n1); |
|
107 | + return substr($s, $n1, $n2 - $n1); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | // process non-nestable constructs: [pre] and [code] |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | |
178 | 178 | $httpsregex = "(?:\"?)https\:\/\/([^\[\"<\ ]+)(?:\"?)"; |
179 | 179 | // List of allowable tags |
180 | - $bbtags = array ( |
|
180 | + $bbtags = array( |
|
181 | 181 | "@\[b\](.*?)\[/b\]@is", |
182 | 182 | "@\[i\](.*?)\[/i\]@is", |
183 | 183 | "@\[u\](.*?)\[/u\]@is", |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | |
207 | 207 | // What the above tags are turned in to |
208 | 208 | if ($export) { |
209 | - $htmltags = array ( |
|
209 | + $htmltags = array( |
|
210 | 210 | "<b>\\1</b>", |
211 | 211 | "<i>\\1</i>", |
212 | 212 | "<u>\\1</u>", |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | "<a href=\"https://github.com/BOINC/boinc/wiki/\\1\">\\1</a>", |
234 | 234 | ); |
235 | 235 | } else { |
236 | - $htmltags = array ( |
|
236 | + $htmltags = array( |
|
237 | 237 | "<b>\\1</b>", |
238 | 238 | "<i>\\1</i>", |
239 | 239 | "<u>\\1</u>", |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | $lasttext = ""; |
266 | 266 | $i = 0; |
267 | 267 | // $i<1000 to prevent DoS |
268 | - while ($text != $lasttext && $i<1000) { |
|
268 | + while ($text != $lasttext && $i < 1000) { |
|
269 | 269 | $lasttext = $text; |
270 | 270 | $text = preg_replace($bbtags, $htmltags, $text); |
271 | 271 | $i = $i + 1; |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | return $text; |
276 | 276 | } |
277 | 277 | |
278 | -function bb2html($text, $export=false) { |
|
278 | +function bb2html($text, $export = false) { |
|
279 | 279 | $text = replace_pre_code($text, $export); |
280 | 280 | return bb2html_aux($text, $export); |
281 | 281 | } |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | // for example inside <pre> containers |
285 | 285 | // The original \n was retained after the br when it was added |
286 | 286 | // |
287 | -function remove_br($text){ |
|
287 | +function remove_br($text) { |
|
288 | 288 | return str_replace("<br />", "", $text); |
289 | 289 | } |
290 | 290 | |
@@ -292,19 +292,19 @@ discard block |
||
292 | 292 | // |
293 | 293 | function externalize_links($text) { |
294 | 294 | // TODO: Convert this to PCRE |
295 | - $i=0; |
|
296 | - $linkpos=true; |
|
295 | + $i = 0; |
|
296 | + $linkpos = true; |
|
297 | 297 | $out = ""; |
298 | - while (true){ |
|
298 | + while (true) { |
|
299 | 299 | // Find a link |
300 | 300 | // |
301 | - $linkpos=strpos($text, "<a ", $i); |
|
302 | - if ($linkpos===false) break; |
|
301 | + $linkpos = strpos($text, "<a ", $i); |
|
302 | + if ($linkpos === false) break; |
|
303 | 303 | |
304 | 304 | // Replace with target='_new' |
305 | 305 | // |
306 | - $out .= substr($text, $i, $linkpos-$i)."<a target=\"_new\" "; |
|
307 | - $i = $linkpos+3; |
|
306 | + $out .= substr($text, $i, $linkpos - $i)."<a target=\"_new\" "; |
|
307 | + $i = $linkpos + 3; |
|
308 | 308 | } |
309 | 309 | $out .= substr($text, $i); |
310 | 310 | return $out; |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | |
313 | 313 | // Converts image tags to links to the images. |
314 | 314 | // |
315 | -function image_as_link($text){ |
|
315 | +function image_as_link($text) { |
|
316 | 316 | $pattern = '@<img([\S\s]+?)src=([^>]+?)>@si'; |
317 | 317 | $replacement = '<a href=${2}>[Image link]</a>'; |
318 | 318 | return preg_replace($pattern, $replacement, $text); |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | return $platforms[$id]; |
54 | 54 | } |
55 | 55 | |
56 | -function anon_platform_string($result, $rsc_name=null) { |
|
56 | +function anon_platform_string($result, $rsc_name = null) { |
|
57 | 57 | $app = get_app($result->appid); |
58 | - $n = $app->user_friendly_name."<br>". tra("Anonymous platform"); |
|
58 | + $n = $app->user_friendly_name."<br>".tra("Anonymous platform"); |
|
59 | 59 | if ($rsc_name) { |
60 | 60 | $n .= " ($rsc_name)"; |
61 | 61 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | return $string_to_show; |
100 | 100 | } |
101 | 101 | if ($result->server_state <> RESULT_SERVER_STATE_OVER) return "---"; |
102 | - switch($result->outcome) { |
|
102 | + switch ($result->outcome) { |
|
103 | 103 | case RESULT_OUTCOME_SUCCESS: |
104 | 104 | switch ($result->validate_state) { |
105 | 105 | case VALIDATE_STATE_INIT: |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | ) { |
215 | 215 | return tra("Not started by deadline - canceled"); |
216 | 216 | } |
217 | - switch($result->client_state) { |
|
217 | + switch ($result->client_state) { |
|
218 | 218 | case RESULT_FILES_DOWNLOADING: return tra("Error while downloading"); |
219 | 219 | case RESULT_FILES_DOWNLOADED: |
220 | 220 | case RESULT_COMPUTE_ERROR: return tra("Error while computing"); |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | } |
234 | 234 | |
235 | 235 | function result_server_state_string($result) { |
236 | - switch($result->server_state) { |
|
236 | + switch ($result->server_state) { |
|
237 | 237 | case RESULT_SERVER_STATE_INACTIVE: return tra("Inactive"); |
238 | 238 | case RESULT_SERVER_STATE_UNSENT: return tra("Unsent"); |
239 | 239 | case RESULT_SERVER_STATE_IN_PROGRESS: return tra("In progress"); |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | } |
244 | 244 | |
245 | 245 | function result_outcome_string($result) { |
246 | - switch($result->outcome) { |
|
246 | + switch ($result->outcome) { |
|
247 | 247 | case RESULT_OUTCOME_INIT: return "---"; |
248 | 248 | case RESULT_OUTCOME_SUCCESS: return tra("Success"); |
249 | 249 | case RESULT_OUTCOME_COULDNT_SEND: return tra("Couldn't send"); |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | } |
262 | 262 | |
263 | 263 | function result_client_state_string($result) { |
264 | - switch($result->client_state) { |
|
264 | + switch ($result->client_state) { |
|
265 | 265 | case RESULT_NEW: return tra("New"); |
266 | 266 | case RESULT_FILES_DOWNLOADING: return tra("Downloading"); |
267 | 267 | case RESULT_FILES_DOWNLOADED: return tra("Processing"); |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | } |
280 | 280 | |
281 | 281 | function validate_state_str($result) { |
282 | - switch($result->validate_state) { |
|
282 | + switch ($result->validate_state) { |
|
283 | 283 | case VALIDATE_STATE_INIT: return tra("Initial"); |
284 | 284 | case VALIDATE_STATE_VALID: return tra("Valid"); |
285 | 285 | case VALIDATE_STATE_INVALID: |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | } |
296 | 296 | |
297 | 297 | function assimilate_state_str($s) { |
298 | - switch($s) { |
|
298 | + switch ($s) { |
|
299 | 299 | case ASSIMILATE_INIT: return "Initial"; |
300 | 300 | case ASSIMILATE_READY: return "Ready to assimilate"; |
301 | 301 | case ASSIMILATE_DONE: return "Assimilated"; |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | } |
305 | 305 | |
306 | 306 | function file_delete_state_str($s) { |
307 | - switch($s) { |
|
307 | + switch ($s) { |
|
308 | 308 | case FILE_DELETE_INIT: return "Initial"; |
309 | 309 | case FILE_DELETE_READY: return "Ready to delete"; |
310 | 310 | case FILE_DELETE_DONE: return "Deleted"; |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | // convert WU error bitmask to str. |
317 | 317 | // If $color, add HTML red color |
318 | 318 | // |
319 | -function wu_error_mask_str($s, $color=false) { |
|
319 | +function wu_error_mask_str($s, $color = false) { |
|
320 | 320 | $x = ""; |
321 | 321 | if ($s & WU_ERROR_COULDNT_SEND_RESULT) { |
322 | 322 | $x = $x." ".tra("Couldn't send result"); |
@@ -430,10 +430,10 @@ discard block |
||
430 | 430 | if ($result->received_time) { |
431 | 431 | $r = time_str($result->received_time); |
432 | 432 | } else if ($result->report_deadline) { |
433 | - if ($result->report_deadline>time()) { |
|
434 | - $r = "<font color='#33cc33'>" . time_str($result->report_deadline) . "</font>"; |
|
433 | + if ($result->report_deadline > time()) { |
|
434 | + $r = "<font color='#33cc33'>".time_str($result->report_deadline)."</font>"; |
|
435 | 435 | } else { |
436 | - $r = "<font color='#ff3333'>" . time_str($result->report_deadline) . "</font>"; |
|
436 | + $r = "<font color='#ff3333'>".time_str($result->report_deadline)."</font>"; |
|
437 | 437 | } |
438 | 438 | } else { |
439 | 439 | $r = "---"; |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | // @param Integer $dec A signed integer |
495 | 495 | // |
496 | 496 | function int2hex($dec) { |
497 | - return "0x".strtoupper(substr(sprintf("%08x",$dec), -8)); |
|
497 | + return "0x".strtoupper(substr(sprintf("%08x", $dec), -8)); |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | // Decode a windows error number into semi-human-readable, |
@@ -504,9 +504,9 @@ discard block |
||
504 | 504 | // @return String A human readable error message |
505 | 505 | // @param Integer $x An error number |
506 | 506 | // |
507 | -function windows_error_code_str($x){ |
|
508 | - $h=int2hex($x); |
|
509 | - switch($h){ |
|
507 | +function windows_error_code_str($x) { |
|
508 | + $h = int2hex($x); |
|
509 | + switch ($h) { |
|
510 | 510 | case "0xC0000005": return "STATUS_ACCESS_VIOLATION"; |
511 | 511 | case "0xC000001D": return "STATUS_ILLEGAL_INSTRUCTION"; |
512 | 512 | case "0xC0000094": return "STATUS_INTEGER_DIVIDE_BY_ZERO"; |
@@ -527,10 +527,10 @@ discard block |
||
527 | 527 | // @return String A human readable error message |
528 | 528 | // @param Integer $x An error number |
529 | 529 | // |
530 | -function error_code_str($x){ |
|
530 | +function error_code_str($x) { |
|
531 | 531 | // severe Windows error numbers are always large negative integers |
532 | - if ($x<-400) return windows_error_code_str($x); |
|
533 | - switch($x){ |
|
532 | + if ($x < -400) return windows_error_code_str($x); |
|
533 | + switch ($x) { |
|
534 | 534 | case 0: return ""; |
535 | 535 | case 192: return "EXIT_STATEFILE_WRITE"; |
536 | 536 | case 193: return "EXIT_SIGNAL"; |
@@ -691,7 +691,7 @@ discard block |
||
691 | 691 | return $x." (".int2hex($x).") ".error_code_str($x); |
692 | 692 | } |
693 | 693 | |
694 | -function show_result($result, $show_outfile_links=false) { |
|
694 | +function show_result($result, $show_outfile_links = false) { |
|
695 | 695 | start_table(); |
696 | 696 | row2(tra("Name"), $result->name); |
697 | 697 | row2(tra("Workunit"), "<a href=\"workunit.php?wuid=$result->workunitid\">$result->workunitid</a>"); |
@@ -742,7 +742,7 @@ discard block |
||
742 | 742 | echo "<h3>".tra("Stderr output")."</h3> <pre>" |
743 | 743 | .htmlspecialchars( |
744 | 744 | $result->stderr_out, |
745 | - ENT_QUOTES | (defined('ENT_SUBSTITUTE')?ENT_SUBSTITUTE:0), |
|
745 | + ENT_QUOTES|(defined('ENT_SUBSTITUTE') ?ENT_SUBSTITUTE:0), |
|
746 | 746 | 'utf-8' |
747 | 747 | ) |
748 | 748 | ."</pre>" |
@@ -757,7 +757,7 @@ discard block |
||
757 | 757 | |
758 | 758 | $apps = BoincApp::enum('deprecated=0 ORDER BY user_friendly_name'); |
759 | 759 | |
760 | - for ($i=0; $i<NSTATES; $i++) { |
|
760 | + for ($i = 0; $i < NSTATES; $i++) { |
|
761 | 761 | $state_count[$i] = 0; |
762 | 762 | } |
763 | 763 | foreach ($apps as $app) { |
@@ -800,7 +800,7 @@ discard block |
||
800 | 800 | $x .= "<a href=$url>".tra("Next")." ".$info->results_per_page."</a>"; |
801 | 801 | } |
802 | 802 | $x .= "<br>".tra("State").": "; |
803 | - for ($i=0; $i<NSTATES; $i++) { |
|
803 | + for ($i = 0; $i < NSTATES; $i++) { |
|
804 | 804 | if ($i) $x .= " · "; |
805 | 805 | if ($info->state == $i) { |
806 | 806 | $x .= $state_name[$i]; |
@@ -27,25 +27,25 @@ |
||
27 | 27 | row_array(array("Name", "Engine", "Version", "Row Format", "Rows", "Avg Row Length (KB)", "Data Length (MB)", "Max Data Length (MB)", "Index Length (MB)", "Data free (MB)", "Create Time", "Update Time", "Check Time", "Create Options", "Comment")); |
28 | 28 | db_init(); |
29 | 29 | $result = _mysql_query("show table status"); |
30 | - while($row = _mysql_fetch_array($result)) { |
|
30 | + while ($row = _mysql_fetch_array($result)) { |
|
31 | 31 | $size += ($row["Data_length"] + $row["Index_length"]); |
32 | 32 | $engine = $row["Engine"]; |
33 | 33 | //if (!$engine) $engine = $row["Type"]; |
34 | 34 | row_array(array( |
35 | 35 | $row["Name"], |
36 | 36 | $engine, |
37 | - $row["Version"] , |
|
38 | - $row["Row_format"] , |
|
39 | - $row["Rows"] , |
|
40 | - round($row["Avg_row_length"]/1024,2) , |
|
41 | - round($row["Data_length"]/(1024*1024),2) , |
|
42 | - round($row["Max_data_length"]/(1024*1024),2) , |
|
43 | - round($row["Index_length"]/(1024*1024),2) , |
|
44 | - round($row["Data_free"]/(1024*1024),2) , |
|
45 | - $row["Create_time"] , |
|
46 | - $row["Update_time"] , |
|
47 | - $row["Check_time"] , |
|
48 | - $row["Create_options"] , |
|
37 | + $row["Version"], |
|
38 | + $row["Row_format"], |
|
39 | + $row["Rows"], |
|
40 | + round($row["Avg_row_length"]/1024, 2), |
|
41 | + round($row["Data_length"]/(1024*1024), 2), |
|
42 | + round($row["Max_data_length"]/(1024*1024), 2), |
|
43 | + round($row["Index_length"]/(1024*1024), 2), |
|
44 | + round($row["Data_free"]/(1024*1024), 2), |
|
45 | + $row["Create_time"], |
|
46 | + $row["Update_time"], |
|
47 | + $row["Check_time"], |
|
48 | + $row["Create_options"], |
|
49 | 49 | $row["Comment"] |
50 | 50 | )); |
51 | 51 | } |