@@ -53,6 +53,9 @@ discard block |
||
| 53 | 53 | return $platforms[$id]; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | +/** |
|
| 57 | + * @param string $rsc_name |
|
| 58 | + */ |
|
| 56 | 59 | function anon_platform_string($result, $rsc_name=null) { |
| 57 | 60 | $app = get_app($result->appid); |
| 58 | 61 | $n = $app->user_friendly_name."<br>". tra("Anonymous platform"); |
@@ -92,6 +95,9 @@ discard block |
||
| 92 | 95 | return "$n v$v $c<br>$platform->name"; |
| 93 | 96 | } |
| 94 | 97 | |
| 98 | +/** |
|
| 99 | + * @param string $string_to_show |
|
| 100 | + */ |
|
| 95 | 101 | function result_granted_credit_string($result, $string_to_show) { |
| 96 | 102 | if ($result->server_state == RESULT_SERVER_STATE_IN_PROGRESS && $result->granted_credit > 0) { |
| 97 | 103 | return $string_to_show; |
@@ -356,6 +362,10 @@ discard block |
||
| 356 | 362 | return "results.php?$c&offset=$o&show_names=$sn&state=$st&appid=$appid"; |
| 357 | 363 | } |
| 358 | 364 | |
| 365 | +/** |
|
| 366 | + * @param boolean $show_wu_link |
|
| 367 | + * @param boolean $show_host_link |
|
| 368 | + */ |
|
| 359 | 369 | function result_table_start($show_wu_link, $show_host_link, $info) { |
| 360 | 370 | start_table('table-striped'); |
| 361 | 371 | $x = array(); |
@@ -417,6 +427,11 @@ discard block |
||
| 417 | 427 | return false; |
| 418 | 428 | } |
| 419 | 429 | |
| 430 | +/** |
|
| 431 | + * @param boolean $show_wu_link |
|
| 432 | + * @param boolean $show_host_link |
|
| 433 | + * @param boolean $show_name |
|
| 434 | + */ |
|
| 420 | 435 | function show_result_row($result, $show_wu_link, $show_host_link, $show_name) { |
| 421 | 436 | $s = time_str($result->sent_time); |
| 422 | 437 | // if result has been reported, show the received time, |
@@ -500,9 +500,9 @@ discard block |
||
| 500 | 500 | // @return String A human readable error message |
| 501 | 501 | // @param Integer $x An error number |
| 502 | 502 | // |
| 503 | -function windows_error_code_str($x){ |
|
| 503 | +function windows_error_code_str($x) { |
|
| 504 | 504 | $h=int2hex($x); |
| 505 | - switch($h){ |
|
| 505 | + switch($h) { |
|
| 506 | 506 | case "0xC0000005": return "STATUS_ACCESS_VIOLATION"; |
| 507 | 507 | case "0xC000001D": return "STATUS_ILLEGAL_INSTRUCTION"; |
| 508 | 508 | case "0xC0000094": return "STATUS_INTEGER_DIVIDE_BY_ZERO"; |
@@ -523,10 +523,10 @@ discard block |
||
| 523 | 523 | // @return String A human readable error message |
| 524 | 524 | // @param Integer $x An error number |
| 525 | 525 | // |
| 526 | -function error_code_str($x){ |
|
| 526 | +function error_code_str($x) { |
|
| 527 | 527 | // severe Windows error numbers are always large negative integers |
| 528 | 528 | if ($x<-400) return windows_error_code_str($x); |
| 529 | - switch($x){ |
|
| 529 | + switch($x) { |
|
| 530 | 530 | case 0: return ""; |
| 531 | 531 | case 192: return "EXIT_STATEFILE_WRITE"; |
| 532 | 532 | case 193: return "EXIT_SIGNAL"; |
@@ -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 | } |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | return $string_to_show; |
| 98 | 98 | } |
| 99 | 99 | if ($result->server_state <> RESULT_SERVER_STATE_OVER) return "---"; |
| 100 | - switch($result->outcome) { |
|
| 100 | + switch ($result->outcome) { |
|
| 101 | 101 | case RESULT_OUTCOME_SUCCESS: |
| 102 | 102 | switch ($result->validate_state) { |
| 103 | 103 | case VALIDATE_STATE_INIT: |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | ) { |
| 213 | 213 | return tra("Not started by deadline - canceled"); |
| 214 | 214 | } |
| 215 | - switch($result->client_state) { |
|
| 215 | + switch ($result->client_state) { |
|
| 216 | 216 | case RESULT_FILES_DOWNLOADING: return tra("Error while downloading"); |
| 217 | 217 | case RESULT_FILES_DOWNLOADED: |
| 218 | 218 | case RESULT_COMPUTE_ERROR: return tra("Error while computing"); |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | function result_server_state_string($result) { |
| 234 | - switch($result->server_state) { |
|
| 234 | + switch ($result->server_state) { |
|
| 235 | 235 | case RESULT_SERVER_STATE_INACTIVE: return tra("Inactive"); |
| 236 | 236 | case RESULT_SERVER_STATE_UNSENT: return tra("Unsent"); |
| 237 | 237 | case RESULT_SERVER_STATE_IN_PROGRESS: return tra("In progress"); |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | function result_outcome_string($result) { |
| 244 | - switch($result->outcome) { |
|
| 244 | + switch ($result->outcome) { |
|
| 245 | 245 | case RESULT_OUTCOME_INIT: return "---"; |
| 246 | 246 | case RESULT_OUTCOME_SUCCESS: return tra("Success"); |
| 247 | 247 | case RESULT_OUTCOME_COULDNT_SEND: return tra("Couldn't send"); |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | function result_client_state_string($result) { |
| 262 | - switch($result->client_state) { |
|
| 262 | + switch ($result->client_state) { |
|
| 263 | 263 | case RESULT_NEW: return tra("New"); |
| 264 | 264 | case RESULT_FILES_DOWNLOADING: return tra("Downloading"); |
| 265 | 265 | case RESULT_FILES_DOWNLOADED: return tra("Processing"); |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | function validate_state_str($result) { |
| 280 | - switch($result->validate_state) { |
|
| 280 | + switch ($result->validate_state) { |
|
| 281 | 281 | case VALIDATE_STATE_INIT: return tra("Initial"); |
| 282 | 282 | case VALIDATE_STATE_VALID: return tra("Valid"); |
| 283 | 283 | case VALIDATE_STATE_INVALID: |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | function assimilate_state_str($s) { |
| 296 | - switch($s) { |
|
| 296 | + switch ($s) { |
|
| 297 | 297 | case ASSIMILATE_INIT: return "Initial"; |
| 298 | 298 | case ASSIMILATE_READY: return "Ready to assimilate"; |
| 299 | 299 | case ASSIMILATE_DONE: return "Assimilated"; |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | function file_delete_state_str($s) { |
| 305 | - switch($s) { |
|
| 305 | + switch ($s) { |
|
| 306 | 306 | case FILE_DELETE_INIT: return "Initial"; |
| 307 | 307 | case FILE_DELETE_READY: return "Ready to delete"; |
| 308 | 308 | case FILE_DELETE_DONE: return "Deleted"; |
@@ -312,27 +312,27 @@ discard block |
||
| 312 | 312 | } |
| 313 | 313 | function wu_error_mask_str($s) { |
| 314 | 314 | $x = ""; |
| 315 | - if ($s & WU_ERROR_COULDNT_SEND_RESULT) { |
|
| 315 | + if ($s&WU_ERROR_COULDNT_SEND_RESULT) { |
|
| 316 | 316 | $x = $x." ".tra("Couldn't send result"); |
| 317 | 317 | $s -= WU_ERROR_COULDNT_SEND_RESULT; |
| 318 | 318 | } |
| 319 | - if ($s & WU_ERROR_TOO_MANY_ERROR_RESULTS) { |
|
| 319 | + if ($s&WU_ERROR_TOO_MANY_ERROR_RESULTS) { |
|
| 320 | 320 | $x = $x." ".tra("Too many errors (may have bug)"); |
| 321 | 321 | $s -= WU_ERROR_TOO_MANY_ERROR_RESULTS; |
| 322 | 322 | } |
| 323 | - if ($s & WU_ERROR_TOO_MANY_SUCCESS_RESULTS) { |
|
| 323 | + if ($s&WU_ERROR_TOO_MANY_SUCCESS_RESULTS) { |
|
| 324 | 324 | $x = $x." ".tra("Too many results (may be nondeterministic)"); |
| 325 | 325 | $s -= WU_ERROR_TOO_MANY_SUCCESS_RESULTS; |
| 326 | 326 | } |
| 327 | - if ($s & WU_ERROR_TOO_MANY_TOTAL_RESULTS) { |
|
| 327 | + if ($s&WU_ERROR_TOO_MANY_TOTAL_RESULTS) { |
|
| 328 | 328 | $x = $x." ".tra("Too many total results"); |
| 329 | 329 | $s -= WU_ERROR_TOO_MANY_TOTAL_RESULTS; |
| 330 | 330 | } |
| 331 | - if ($s & WU_ERROR_CANCELLED) { |
|
| 331 | + if ($s&WU_ERROR_CANCELLED) { |
|
| 332 | 332 | $x = $x." ".tra("WU cancelled"); |
| 333 | 333 | $s -= WU_ERROR_CANCELLED; |
| 334 | 334 | } |
| 335 | - if ($s & WU_ERROR_NO_CANONICAL_RESULT) { |
|
| 335 | + if ($s&WU_ERROR_NO_CANONICAL_RESULT) { |
|
| 336 | 336 | $x = $x." ".tra("Canonical result is missing"); |
| 337 | 337 | $s -= WU_ERROR_NO_CANONICAL_RESULT; |
| 338 | 338 | } |
@@ -340,9 +340,9 @@ discard block |
||
| 340 | 340 | $x = $x." ".tra("Unrecognized Error: %1", $s); |
| 341 | 341 | } |
| 342 | 342 | if (strlen($x)) { |
| 343 | - $x="<font color=\"#ff3333\">".$x."</font>"; |
|
| 343 | + $x = "<font color=\"#ff3333\">".$x."</font>"; |
|
| 344 | 344 | } else { |
| 345 | - $x=""; |
|
| 345 | + $x = ""; |
|
| 346 | 346 | } |
| 347 | 347 | return $x; |
| 348 | 348 | } |
@@ -426,10 +426,10 @@ discard block |
||
| 426 | 426 | if ($result->received_time) { |
| 427 | 427 | $r = time_str($result->received_time); |
| 428 | 428 | } else if ($result->report_deadline) { |
| 429 | - if ($result->report_deadline>time()) { |
|
| 430 | - $r = "<font color='#33cc33'>" . time_str($result->report_deadline) . "</font>"; |
|
| 429 | + if ($result->report_deadline > time()) { |
|
| 430 | + $r = "<font color='#33cc33'>".time_str($result->report_deadline)."</font>"; |
|
| 431 | 431 | } else { |
| 432 | - $r = "<font color='#ff3333'>" . time_str($result->report_deadline) . "</font>"; |
|
| 432 | + $r = "<font color='#ff3333'>".time_str($result->report_deadline)."</font>"; |
|
| 433 | 433 | } |
| 434 | 434 | } else { |
| 435 | 435 | $r = "---"; |
@@ -490,7 +490,7 @@ discard block |
||
| 490 | 490 | // @param Integer $dec A signed integer |
| 491 | 491 | // |
| 492 | 492 | function int2hex($dec) { |
| 493 | - return "0x".strtoupper(substr(sprintf("%08x",$dec), -8)); |
|
| 493 | + return "0x".strtoupper(substr(sprintf("%08x", $dec), -8)); |
|
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | // Decode a windows error number into semi-human-readable, |
@@ -500,9 +500,9 @@ discard block |
||
| 500 | 500 | // @return String A human readable error message |
| 501 | 501 | // @param Integer $x An error number |
| 502 | 502 | // |
| 503 | -function windows_error_code_str($x){ |
|
| 504 | - $h=int2hex($x); |
|
| 505 | - switch($h){ |
|
| 503 | +function windows_error_code_str($x) { |
|
| 504 | + $h = int2hex($x); |
|
| 505 | + switch ($h) { |
|
| 506 | 506 | case "0xC0000005": return "STATUS_ACCESS_VIOLATION"; |
| 507 | 507 | case "0xC000001D": return "STATUS_ILLEGAL_INSTRUCTION"; |
| 508 | 508 | case "0xC0000094": return "STATUS_INTEGER_DIVIDE_BY_ZERO"; |
@@ -523,10 +523,10 @@ discard block |
||
| 523 | 523 | // @return String A human readable error message |
| 524 | 524 | // @param Integer $x An error number |
| 525 | 525 | // |
| 526 | -function error_code_str($x){ |
|
| 526 | +function error_code_str($x) { |
|
| 527 | 527 | // severe Windows error numbers are always large negative integers |
| 528 | - if ($x<-400) return windows_error_code_str($x); |
|
| 529 | - switch($x){ |
|
| 528 | + if ($x < -400) return windows_error_code_str($x); |
|
| 529 | + switch ($x) { |
|
| 530 | 530 | case 0: return ""; |
| 531 | 531 | case 192: return "EXIT_STATEFILE_WRITE"; |
| 532 | 532 | case 193: return "EXIT_SIGNAL"; |
@@ -687,7 +687,7 @@ discard block |
||
| 687 | 687 | return $x." (".int2hex($x).") ".error_code_str($x); |
| 688 | 688 | } |
| 689 | 689 | |
| 690 | -function show_result($result, $show_outfile_links=false) { |
|
| 690 | +function show_result($result, $show_outfile_links = false) { |
|
| 691 | 691 | start_table(); |
| 692 | 692 | row2(tra("Name"), $result->name); |
| 693 | 693 | row2(tra("Workunit"), "<a href=\"workunit.php?wuid=$result->workunitid\">$result->workunitid</a>"); |
@@ -736,7 +736,7 @@ discard block |
||
| 736 | 736 | echo "<h3>".tra("Stderr output")."</h3> <pre>" |
| 737 | 737 | .htmlspecialchars( |
| 738 | 738 | $result->stderr_out, |
| 739 | - ENT_QUOTES | (defined('ENT_SUBSTITUTE')?ENT_SUBSTITUTE:0), |
|
| 739 | + ENT_QUOTES|(defined('ENT_SUBSTITUTE') ?ENT_SUBSTITUTE:0), |
|
| 740 | 740 | 'utf-8' |
| 741 | 741 | ) |
| 742 | 742 | ."</pre>" |
@@ -751,7 +751,7 @@ discard block |
||
| 751 | 751 | |
| 752 | 752 | $apps = BoincApp::enum('deprecated=0 ORDER BY user_friendly_name'); |
| 753 | 753 | |
| 754 | - for ($i=0; $i<NSTATES; $i++) { |
|
| 754 | + for ($i = 0; $i < NSTATES; $i++) { |
|
| 755 | 755 | $state_count[$i] = 0; |
| 756 | 756 | } |
| 757 | 757 | foreach ($apps as $app) { |
@@ -793,7 +793,7 @@ discard block |
||
| 793 | 793 | $x .= "<a href=$url>".tra("Next")." ".$info->results_per_page."</a>"; |
| 794 | 794 | } |
| 795 | 795 | $x .= "<br>".tra("State").": "; |
| 796 | - for ($i=0; $i<NSTATES; $i++) { |
|
| 796 | + for ($i = 0; $i < NSTATES; $i++) { |
|
| 797 | 797 | if ($i) $x .= " · "; |
| 798 | 798 | if ($info->state == $i) { |
| 799 | 799 | $x .= $state_name[$i]; |
@@ -838,6 +838,6 @@ discard block |
||
| 838 | 838 | return $x; |
| 839 | 839 | } |
| 840 | 840 | |
| 841 | -$cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit |
|
| 841 | +$cvs_version_tracker[] = "\$Id$"; //Generated automatically - do not edit |
|
| 842 | 842 | |
| 843 | 843 | ?> |
@@ -26,6 +26,9 @@ discard block |
||
| 26 | 26 | // Create dir if not present. |
| 27 | 27 | // |
| 28 | 28 | if (!function_exists("sandbox_dir")){ |
| 29 | +/** |
|
| 30 | + * @return string |
|
| 31 | + */ |
|
| 29 | 32 | function sandbox_dir($user) { |
| 30 | 33 | $dir = parse_config(get_config(), "<sandbox_dir>"); |
| 31 | 34 | if (!$dir) { $dir = "../../sandbox/"; } |
@@ -40,12 +43,18 @@ discard block |
||
| 40 | 43 | } |
| 41 | 44 | } |
| 42 | 45 | |
| 46 | +/** |
|
| 47 | + * @param string $md5 |
|
| 48 | + */ |
|
| 43 | 49 | function sandbox_write_link_file($path, $size, $md5) { |
| 44 | 50 | file_put_contents($path, "sb $size $md5"); |
| 45 | 51 | } |
| 46 | 52 | |
| 47 | 53 | // check if a newly update files already exists in sandbox via its md5 sum |
| 48 | 54 | // |
| 55 | +/** |
|
| 56 | + * @param string $md5 |
|
| 57 | + */ |
|
| 49 | 58 | function sandbox_lf_exist($user, $md5) { |
| 50 | 59 | $exist = 0; |
| 51 | 60 | $elf = ""; |
@@ -115,6 +124,9 @@ discard block |
||
| 115 | 124 | // return a <select> for files in sandbox |
| 116 | 125 | // |
| 117 | 126 | if (!function_exists('sandbox_file_select')) { |
| 127 | +/** |
|
| 128 | + * @param string $select_name |
|
| 129 | + */ |
|
| 118 | 130 | function sandbox_file_select($user, $select_name, $regexp = null, $allow_none = false) { |
| 119 | 131 | if ($regexp === null) { |
| 120 | 132 | $regexp = $select_name; |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | // Return path of sandbox directory for the given user. |
| 26 | 26 | // Create dir if not present. |
| 27 | 27 | // |
| 28 | -if (!function_exists("sandbox_dir")){ |
|
| 28 | +if (!function_exists("sandbox_dir")) { |
|
| 29 | 29 | function sandbox_dir($user) { |
| 30 | 30 | $dir = parse_config(get_config(), "<sandbox_dir>"); |
| 31 | 31 | if (!$dir) { $dir = "../../sandbox/"; } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | foreach ($files as $file) { |
| 55 | 55 | $path = $dir."/".$file; |
| 56 | 56 | list($err, $file_size, $file_md5) = sandbox_parse_link_file($path); |
| 57 | - if (!$err){ |
|
| 57 | + if (!$err) { |
|
| 58 | 58 | if (strcmp($md5, $file_md5) == 0) { |
| 59 | 59 | //echo "this file with $md5 already exisits with another name $file"; |
| 60 | 60 | $exist = 1; |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | } |
| 126 | 126 | $files = sandbox_file_names($user); |
| 127 | 127 | foreach ($files as $f) { |
| 128 | - if(preg_match("/$regexp/",$f)){ |
|
| 128 | + if (preg_match("/$regexp/", $f)) { |
|
| 129 | 129 | $x .= "<option value=\"$f\">$f</option>\n"; |
| 130 | 130 | } |
| 131 | 131 | } |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | |
| 137 | 137 | //check if a file is still being used by a unfinished batch |
| 138 | 138 | // |
| 139 | -function sandbox_file_in_use($user, $file){ |
|
| 139 | +function sandbox_file_in_use($user, $file) { |
|
| 140 | 140 | $ufiles = array(); |
| 141 | 141 | |
| 142 | 142 | // batch status: 2(completed), 3(aborted) |
@@ -144,17 +144,17 @@ discard block |
||
| 144 | 144 | $pbatches = BoincBatch::enum("user_id = $user->id and state != 2 and state != 3"); |
| 145 | 145 | if (!$pbatches) return false; |
| 146 | 146 | |
| 147 | - foreach ($pbatches as $batch){ |
|
| 148 | - $wus = BoincWorkUnit::enum("batch = $batch->id limit 1" ); |
|
| 149 | - if ($wus == null){ |
|
| 147 | + foreach ($pbatches as $batch) { |
|
| 148 | + $wus = BoincWorkUnit::enum("batch = $batch->id limit 1"); |
|
| 149 | + if ($wus == null) { |
|
| 150 | 150 | //echo " no workunit for this batch<br/>"; |
| 151 | 151 | continue; |
| 152 | 152 | } |
| 153 | - foreach($wus as $wu){ |
|
| 153 | + foreach ($wus as $wu) { |
|
| 154 | 154 | $x = "<in>".$wu->xml_doc."</in>"; |
| 155 | 155 | $x = simplexml_load_string($x); |
| 156 | 156 | global $fanout; |
| 157 | - foreach($x->workunit->file_ref as $fr){ |
|
| 157 | + foreach ($x->workunit->file_ref as $fr) { |
|
| 158 | 158 | $pname = (string)$fr->file_name; |
| 159 | 159 | $ufiles[] = $pname; |
| 160 | 160 | } |
@@ -165,10 +165,10 @@ discard block |
||
| 165 | 165 | $dir = sandbox_dir($user); |
| 166 | 166 | $path = $dir."/".$file; |
| 167 | 167 | list($err, $size, $md5) = sandbox_parse_link_file($path); |
| 168 | - if (!$err){ |
|
| 168 | + if (!$err) { |
|
| 169 | 169 | $f = sandbox_file_name($user, $md5); |
| 170 | - foreach($ufiles as $uf) { |
|
| 171 | - if (strcmp($f,$uf) == 0){ |
|
| 170 | + foreach ($ufiles as $uf) { |
|
| 171 | + if (strcmp($f, $uf) == 0) { |
|
| 172 | 172 | return true; |
| 173 | 173 | } |
| 174 | 174 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | // Return path of sandbox directory for the given user. |
| 26 | 26 | // Create dir if not present. |
| 27 | 27 | // |
| 28 | -if (!function_exists("sandbox_dir")){ |
|
| 28 | +if (!function_exists("sandbox_dir")) { |
|
| 29 | 29 | function sandbox_dir($user) { |
| 30 | 30 | $dir = parse_config(get_config(), "<sandbox_dir>"); |
| 31 | 31 | if (!$dir) { $dir = "../../sandbox/"; } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | foreach ($files as $file) { |
| 55 | 55 | $path = $dir."/".$file; |
| 56 | 56 | list($err, $file_size, $file_md5) = sandbox_parse_link_file($path); |
| 57 | - if (!$err){ |
|
| 57 | + if (!$err) { |
|
| 58 | 58 | if (strcmp($md5, $file_md5) == 0) { |
| 59 | 59 | //echo "this file with $md5 already exisits with another name $file"; |
| 60 | 60 | $exist = 1; |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | } |
| 126 | 126 | $files = sandbox_file_names($user); |
| 127 | 127 | foreach ($files as $f) { |
| 128 | - if(preg_match("/$regexp/",$f)){ |
|
| 128 | + if(preg_match("/$regexp/",$f)) { |
|
| 129 | 129 | $x .= "<option value=\"$f\">$f</option>\n"; |
| 130 | 130 | } |
| 131 | 131 | } |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | |
| 137 | 137 | //check if a file is still being used by a unfinished batch |
| 138 | 138 | // |
| 139 | -function sandbox_file_in_use($user, $file){ |
|
| 139 | +function sandbox_file_in_use($user, $file) { |
|
| 140 | 140 | $ufiles = array(); |
| 141 | 141 | |
| 142 | 142 | // batch status: 2(completed), 3(aborted) |
@@ -144,17 +144,17 @@ discard block |
||
| 144 | 144 | $pbatches = BoincBatch::enum("user_id = $user->id and state != 2 and state != 3"); |
| 145 | 145 | if (!$pbatches) return false; |
| 146 | 146 | |
| 147 | - foreach ($pbatches as $batch){ |
|
| 147 | + foreach ($pbatches as $batch) { |
|
| 148 | 148 | $wus = BoincWorkUnit::enum("batch = $batch->id limit 1" ); |
| 149 | - if ($wus == null){ |
|
| 149 | + if ($wus == null) { |
|
| 150 | 150 | //echo " no workunit for this batch<br/>"; |
| 151 | 151 | continue; |
| 152 | 152 | } |
| 153 | - foreach($wus as $wu){ |
|
| 153 | + foreach($wus as $wu) { |
|
| 154 | 154 | $x = "<in>".$wu->xml_doc."</in>"; |
| 155 | 155 | $x = simplexml_load_string($x); |
| 156 | 156 | global $fanout; |
| 157 | - foreach($x->workunit->file_ref as $fr){ |
|
| 157 | + foreach($x->workunit->file_ref as $fr) { |
|
| 158 | 158 | $pname = (string)$fr->file_name; |
| 159 | 159 | $ufiles[] = $pname; |
| 160 | 160 | } |
@@ -165,10 +165,10 @@ discard block |
||
| 165 | 165 | $dir = sandbox_dir($user); |
| 166 | 166 | $path = $dir."/".$file; |
| 167 | 167 | list($err, $size, $md5) = sandbox_parse_link_file($path); |
| 168 | - if (!$err){ |
|
| 168 | + if (!$err) { |
|
| 169 | 169 | $f = sandbox_file_name($user, $md5); |
| 170 | 170 | foreach($ufiles as $uf) { |
| 171 | - if (strcmp($f,$uf) == 0){ |
|
| 171 | + if (strcmp($f,$uf) == 0) { |
|
| 172 | 172 | return true; |
| 173 | 173 | } |
| 174 | 174 | |
@@ -145,6 +145,9 @@ discard block |
||
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | +/** |
|
| 149 | + * @param string $op |
|
| 150 | + */ |
|
| 148 | 151 | function do_batch_op($req, $op) { |
| 149 | 152 | $retval = validate_request($req); |
| 150 | 153 | if ($retval) return array(null, $retval); |
@@ -172,6 +175,9 @@ discard block |
||
| 172 | 175 | |
| 173 | 176 | // if RPC had a fatal error, return the message |
| 174 | 177 | // |
| 178 | +/** |
|
| 179 | + * @param string $outer_tag |
|
| 180 | + */ |
|
| 175 | 181 | function get_error($reply, $outer_tag) { |
| 176 | 182 | $name = $reply->getName(); |
| 177 | 183 | if ($name != $outer_tag) { |
@@ -187,6 +193,9 @@ discard block |
||
| 187 | 193 | |
| 188 | 194 | //// API functions follow |
| 189 | 195 | |
| 196 | +/** |
|
| 197 | + * @param stdClass $req |
|
| 198 | + */ |
|
| 190 | 199 | function boinc_estimate_batch($req) { |
| 191 | 200 | list($reply, $errmsg) = do_batch_op($req, "estimate_batch"); |
| 192 | 201 | if ($errmsg) return array(0, $errmsg); |
@@ -205,6 +214,9 @@ discard block |
||
| 205 | 214 | return array((int)$reply->batch_id, null); |
| 206 | 215 | } |
| 207 | 216 | |
| 217 | +/** |
|
| 218 | + * @param stdClass $req |
|
| 219 | + */ |
|
| 208 | 220 | function boinc_query_batches($req) { |
| 209 | 221 | $req_xml = "<query_batches> |
| 210 | 222 | <authenticator>$req->authenticator</authenticator> |
@@ -255,6 +267,9 @@ discard block |
||
| 255 | 267 | return array($r, null); |
| 256 | 268 | } |
| 257 | 269 | |
| 270 | +/** |
|
| 271 | + * @param stdClass $req |
|
| 272 | + */ |
|
| 258 | 273 | function boinc_query_job($req) { |
| 259 | 274 | $req_xml = "<query_job> |
| 260 | 275 | <authenticator>$req->authenticator</authenticator> |
@@ -285,6 +300,9 @@ discard block |
||
| 285 | 300 | return array($r, null); |
| 286 | 301 | } |
| 287 | 302 | |
| 303 | +/** |
|
| 304 | + * @return string |
|
| 305 | + */ |
|
| 288 | 306 | function boinc_abort_batch($req) { |
| 289 | 307 | $req_xml = "<abort_batch> |
| 290 | 308 | <authenticator>$req->authenticator</authenticator> |
@@ -299,6 +317,9 @@ discard block |
||
| 299 | 317 | return array(true, null); |
| 300 | 318 | } |
| 301 | 319 | |
| 320 | +/** |
|
| 321 | + * @param stdClass $req |
|
| 322 | + */ |
|
| 302 | 323 | function boinc_get_output_file($req) { |
| 303 | 324 | $auth_str = md5($req->authenticator.$req->instance_name); |
| 304 | 325 | $name = $req->instance_name; |
@@ -312,6 +333,9 @@ discard block |
||
| 312 | 333 | return $req->project."/get_output.php?cmd=batch_files&batch_id=$batch_id&auth_str=$auth_str"; |
| 313 | 334 | } |
| 314 | 335 | |
| 336 | +/** |
|
| 337 | + * @return string |
|
| 338 | + */ |
|
| 315 | 339 | function boinc_retire_batch($req) { |
| 316 | 340 | $req_xml = "<retire_batch> |
| 317 | 341 | <authenticator>$req->authenticator</authenticator> |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | $b->create_time = (double)($batch->create_time); |
| 171 | 171 | $b->est_completion_time = (double)($batch->est_completion_time); |
| 172 | 172 | $b->njobs = (int)($batch->njobs); |
| 173 | - $b->fraction_done = (double) $batch->fraction_done; |
|
| 173 | + $b->fraction_done = (double)$batch->fraction_done; |
|
| 174 | 174 | $b->nerror_jobs = (int)($batch->nerror_jobs); |
| 175 | 175 | $b->state = (int)($batch->state); |
| 176 | 176 | $b->completion_time = (double)($batch->completion_time); |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | </result> |
| 399 | 399 | </output_template> |
| 400 | 400 | "; |
| 401 | - for ($i=0; $i<2; $i++) { |
|
| 401 | + for ($i = 0; $i < 2; $i++) { |
|
| 402 | 402 | $job = new StdClass; |
| 403 | 403 | $job->input_files = array(); |
| 404 | 404 | $job->input_files[] = $f; |
@@ -34,6 +34,10 @@ discard block |
||
| 34 | 34 | $db = BoincDb::get(); |
| 35 | 35 | return $db->enum('batch', 'BoincBatch', $clause); |
| 36 | 36 | } |
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * @param string $clause |
|
| 40 | + */ |
|
| 37 | 41 | static function insert($clause) { |
| 38 | 42 | $db = BoincDb::get(); |
| 39 | 43 | $ret = $db->insert('batch', $clause); |
@@ -44,6 +48,10 @@ discard block |
||
| 44 | 48 | $db = BoincDb::get(); |
| 45 | 49 | return $db->update($this, 'batch', $clause); |
| 46 | 50 | } |
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * @param string $clause |
|
| 54 | + */ |
|
| 47 | 55 | static function update_aux($clause) { |
| 48 | 56 | $db = BoincDb::get(); |
| 49 | 57 | return $db->update_aux('batch', $clause); |
@@ -59,6 +67,10 @@ discard block |
||
| 59 | 67 | } |
| 60 | 68 | |
| 61 | 69 | class BoincUserSubmit { |
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * @param string $clause |
|
| 73 | + */ |
|
| 62 | 74 | static function enum($clause) { |
| 63 | 75 | $db = BoincDb::get(); |
| 64 | 76 | return $db->enum('user_submit', 'BoincUserSubmit', $clause); |
@@ -77,6 +89,10 @@ discard block |
||
| 77 | 89 | $db = BoincDb::get(); |
| 78 | 90 | return $db->update_aux('user_submit', "$clause where user_id=$this->user_id"); |
| 79 | 91 | } |
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * @param string $clause |
|
| 95 | + */ |
|
| 80 | 96 | static function update_aux($clause) { |
| 81 | 97 | $db = BoincDb::get(); |
| 82 | 98 | return $db->update_aux('user_submit', $clause); |
@@ -26,6 +26,9 @@ discard block |
||
| 26 | 26 | // we need to give a unique physical name based on its content. |
| 27 | 27 | // Prepend the jf_ to make the origin of the file clear |
| 28 | 28 | // |
| 29 | +/** |
|
| 30 | + * @param string $md5 |
|
| 31 | + */ |
|
| 29 | 32 | function job_file_name($md5) { |
| 30 | 33 | return "jf_$md5"; |
| 31 | 34 | } |
@@ -179,12 +182,20 @@ discard block |
||
| 179 | 182 | return $batch_td_size; |
| 180 | 183 | } |
| 181 | 184 | |
| 185 | +/** |
|
| 186 | + * @param integer $i |
|
| 187 | + * |
|
| 188 | + * @return double |
|
| 189 | + */ |
|
| 182 | 190 | function boinc_get_output_file_url($user, $result, $i) { |
| 183 | 191 | $name = $result->name; |
| 184 | 192 | $auth_str = md5($user->authenticator.$name); |
| 185 | 193 | return "get_output.php?cmd=result_file&result_name=$name&file_num=$i&auth_str=$auth_str"; |
| 186 | 194 | } |
| 187 | 195 | |
| 196 | +/** |
|
| 197 | + * @param null|integer $batch_id |
|
| 198 | + */ |
|
| 188 | 199 | function boinc_get_output_files_url($user, $batch_id) { |
| 189 | 200 | $auth_str = md5($user->authenticator.$batch_id); |
| 190 | 201 | return "get_output.php?cmd=batch_files&batch_id=$batch_id&auth_str=$auth_str"; |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | if ($fp_total) { |
| 76 | - $batch->fraction_done = $fp_done / $fp_total; |
|
| 76 | + $batch->fraction_done = $fp_done/$fp_total; |
|
| 77 | 77 | } |
| 78 | 78 | if ($completed && $batch->state == BATCH_STATE_IN_PROGRESS) { |
| 79 | 79 | $batch->state = BATCH_STATE_COMPLETE; |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | // get the total size of output files of a batch |
| 160 | 160 | // |
| 161 | 161 | function batch_output_file_size($batchid) { |
| 162 | - $batch_td_size=0; |
|
| 162 | + $batch_td_size = 0; |
|
| 163 | 163 | $wus = BoincWorkunit::enum("batch=$batchid"); |
| 164 | 164 | $fanout = parse_config(get_config(), "<uldl_dir_fanout>"); |
| 165 | 165 | $upload_dir = parse_config(get_config(), "<upload_dir>"); |
@@ -170,9 +170,9 @@ discard block |
||
| 170 | 170 | foreach ($names as $name) { |
| 171 | 171 | $path = dir_hier_path($name, $upload_dir, $fanout); |
| 172 | 172 | if (is_file($path)) { |
| 173 | - $s=stat($path); |
|
| 174 | - $size=$s['size']; |
|
| 175 | - $batch_td_size+=$size; |
|
| 173 | + $s = stat($path); |
|
| 174 | + $size = $s['size']; |
|
| 175 | + $batch_td_size += $size; |
|
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | 178 | } |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | function boinc_get_wu_output_files_url($user, $wu_id) { |
| 194 | - $auth_str = md5($user->authenticator.$wu_id); |
|
| 194 | + $auth_str = md5($user->authenticator.$wu_id); |
|
| 195 | 195 | return "get_output.php?cmd=workunit_files&wu_id=$wu_id&auth_str=$auth_str"; |
| 196 | 196 | } |
| 197 | 197 | |
@@ -524,6 +524,9 @@ discard block |
||
| 524 | 524 | // an active request, i.e. after the 60 days elapse X has another |
| 525 | 525 | // 30 days to assume foundership before someone elase can request it |
| 526 | 526 | // |
| 527 | +/** |
|
| 528 | + * @param integer $now |
|
| 529 | + */ |
|
| 527 | 530 | function new_transfer_request_ok($team, $now) { |
| 528 | 531 | if ($team->ping_user <= 0) { |
| 529 | 532 | if ($team->ping_time < $now - 60 * 86400) { |
@@ -544,6 +547,9 @@ discard block |
||
| 544 | 547 | return $team->ping_time + 60*86400; |
| 545 | 548 | } |
| 546 | 549 | |
| 550 | +/** |
|
| 551 | + * @param integer $now |
|
| 552 | + */ |
|
| 547 | 553 | function transfer_ok($team, $now) { |
| 548 | 554 | if ($now > transfer_ok_time($team)) return true; |
| 549 | 555 | return false; |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | row2('<b>'.tra('Search criteria (use one or more)').'</b>', ''); |
| 41 | 41 | row2( |
| 42 | 42 | tra('Key words').'<br><small>'.tra('Find teams with these words in their names or descriptions').'</small>', |
| 43 | - '<input class="form-control" type="text" name="keywords" value="' . htmlspecialchars($params->keywords) . '">'); |
|
| 43 | + '<input class="form-control" type="text" name="keywords" value="'.htmlspecialchars($params->keywords).'">'); |
|
| 44 | 44 | row2_init(tra('Country'), ''); |
| 45 | 45 | echo '<select class="form-control" name="country"><option value="" selected>---</option>'; |
| 46 | 46 | $country = $params->country; |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | echo country_select_options($country); |
| 49 | 49 | echo "</select></td></tr>\n"; |
| 50 | 50 | row2(tra('Type of team'), team_type_select($params->type, true)); |
| 51 | - $checked = $params->active?"checked":""; |
|
| 51 | + $checked = $params->active ? "checked" : ""; |
|
| 52 | 52 | row2(tra('Show only active teams'), "<input type=checkbox name=active $checked>"); |
| 53 | 53 | row2("", "<input class=\"btn btn-primary\" type=submit name=submit value=\"".tra('Search')."\">"); |
| 54 | 54 | end_table(); |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | row2("Created", date_str($team->create_time)); |
| 97 | 97 | if (defined("SHOW_NONVALIDATED_TEAMS")) { |
| 98 | 98 | $founder = $team->founder; |
| 99 | - row2("Founder email validated", $founder->email_validated?"Yes":"No (team will not be exported)"); |
|
| 99 | + row2("Founder email validated", $founder->email_validated ? "Yes" : "No (team will not be exported)"); |
|
| 100 | 100 | } |
| 101 | 101 | if (strlen($team->url)) {; |
| 102 | 102 | if (strstr($team->url, "http://")) { |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | } |
| 170 | 170 | row1(tra('Members')); |
| 171 | 171 | row2(tra('Founder'), |
| 172 | - $team->founder?user_links($team->founder, BADGE_HEIGHT_MEDIUM):"---" |
|
| 172 | + $team->founder ?user_links($team->founder, BADGE_HEIGHT_MEDIUM) : "---" |
|
| 173 | 173 | ); |
| 174 | 174 | if (count($team->admins)) { |
| 175 | 175 | $first = true; |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | foreach ($deltas as $delta) { |
| 354 | 354 | $u = BoincUser::lookup_id($delta->userid); |
| 355 | 355 | if ($u->teamid == $teamid) { |
| 356 | - $new_members[] = $u; // they might have later quit |
|
| 356 | + $new_members[] = $u; // they might have later quit |
|
| 357 | 357 | } |
| 358 | 358 | } |
| 359 | 359 | } |
@@ -436,7 +436,7 @@ discard block |
||
| 436 | 436 | if (!$user->teamid) return; |
| 437 | 437 | $user->update("teamid=0"); |
| 438 | 438 | $team = BoincTeam::lookup_id($user->teamid); |
| 439 | - if ($team && $team->ping_user==$user->id) { |
|
| 439 | + if ($team && $team->ping_user == $user->id) { |
|
| 440 | 440 | $team->update("ping_user=-ping_user"); |
| 441 | 441 | } |
| 442 | 442 | BoincTeamAdmin::delete("teamid=$user->teamid and userid=$user->id"); |
@@ -475,34 +475,34 @@ discard block |
||
| 475 | 475 | start_table(); |
| 476 | 476 | row2(tra('Team name, text version').' |
| 477 | 477 | <br><p class=\"text-muted\">'.tra('Don\'t use HTML tags.').'</p>', |
| 478 | - '<input class="form-control" name="name" type="text" size="50" value="'.($team?$team->name:"").'">' |
|
| 478 | + '<input class="form-control" name="name" type="text" size="50" value="'.($team ? $team->name : "").'">' |
|
| 479 | 479 | ); |
| 480 | 480 | row2(tra('Team name, HTML version').' |
| 481 | 481 | <br><p class=\"text-muted\"> |
| 482 | 482 | '.tra('You may use %1 limited HTML tags %2.', '<a href="html.php" target="_new">', '</a>').' |
| 483 | 483 | '.tra('If you don\'t know HTML, leave this box blank.').'</p>', |
| 484 | - '<input class="form-control" name="name_html" type="text" size="50" value="'.str_replace('"',"'",($team?$team->name_html:"")).'">' |
|
| 484 | + '<input class="form-control" name="name_html" type="text" size="50" value="'.str_replace('"', "'", ($team ? $team->name_html : "")).'">' |
|
| 485 | 485 | ); |
| 486 | 486 | row2(tra('URL of team web page, if any').':<br><font size=-2>('.tra('without "http://"').') |
| 487 | 487 | '.tra('This URL will be linked to from the team\'s page on this site.'), |
| 488 | - '<input class="form-control" type="text" name="url" size="60" value="'.($team?$team->url:"").'">' |
|
| 488 | + '<input class="form-control" type="text" name="url" size="60" value="'.($team ? $team->url : "").'">' |
|
| 489 | 489 | ); |
| 490 | 490 | row2(tra('Description of team').': |
| 491 | 491 | <br><p class=\"text-muted\"> |
| 492 | 492 | '.tra('You may use %1 limited HTML tags %2.', '<a href="html.php" target="_new">', '</a>').' |
| 493 | 493 | </p>', |
| 494 | - '<textarea class="form-control" name="description" rows=10>'.($team?$team->description:"").'</textarea>' |
|
| 494 | + '<textarea class="form-control" name="description" rows=10>'.($team ? $team->description : "").'</textarea>' |
|
| 495 | 495 | ); |
| 496 | 496 | |
| 497 | - row2(tra('Type of team').':', team_type_select($team?$team->type:null)); |
|
| 497 | + row2(tra('Type of team').':', team_type_select($team ? $team->type : null)); |
|
| 498 | 498 | |
| 499 | 499 | row2_init(tra('Country'), |
| 500 | 500 | '<select class="form-control" name="country">' |
| 501 | 501 | ); |
| 502 | - echo country_select_options($team?$team->country:null); |
|
| 502 | + echo country_select_options($team ? $team->country : null); |
|
| 503 | 503 | |
| 504 | 504 | echo "</select></td></tr>\n"; |
| 505 | - $x = (!$team || $team->joinable)?"checked":""; |
|
| 505 | + $x = (!$team || $team->joinable) ? "checked" : ""; |
|
| 506 | 506 | row2(tra("Accept new members?"), "<input type=checkbox name=joinable $x>"); |
| 507 | 507 | // Check if we're using reCaptcha to prevent spam accounts |
| 508 | 508 | // |
@@ -566,12 +566,12 @@ discard block |
||
| 566 | 566 | // |
| 567 | 567 | function new_transfer_request_ok($team, $now) { |
| 568 | 568 | if ($team->ping_user <= 0) { |
| 569 | - if ($team->ping_time < $now - 60 * 86400) { |
|
| 569 | + if ($team->ping_time < $now - 60*86400) { |
|
| 570 | 570 | return true; |
| 571 | 571 | } |
| 572 | 572 | return false; |
| 573 | 573 | } |
| 574 | - if ($team->ping_time < $now - 90 * 86400) { |
|
| 574 | + if ($team->ping_time < $now - 90*86400) { |
|
| 575 | 575 | return true; |
| 576 | 576 | } |
| 577 | 577 | return false; |
@@ -606,7 +606,7 @@ discard block |
||
| 606 | 606 | if (!is_valid_country($country)) { |
| 607 | 607 | $country = tra('None'); |
| 608 | 608 | } |
| 609 | - $country = BoincDb::escape_string($country); // for Cote d'Ivoire |
|
| 609 | + $country = BoincDb::escape_string($country); // for Cote d'Ivoire |
|
| 610 | 610 | |
| 611 | 611 | $clause = sprintf( |
| 612 | 612 | "(userid, create_time, name, name_lc, url, type, name_html, description, country, nusers, expavg_time) values(%d, %d, '%s', '%s', '%s', %d, '%s', '%s', '%s', %d, unix_timestamp())", |
@@ -629,6 +629,6 @@ discard block |
||
| 629 | 629 | } |
| 630 | 630 | } |
| 631 | 631 | |
| 632 | -$cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit |
|
| 632 | +$cvs_version_tracker[] = "\$Id$"; //Generated automatically - do not edit |
|
| 633 | 633 | |
| 634 | 634 | ?> |
@@ -105,6 +105,9 @@ discard block |
||
| 105 | 105 | |
| 106 | 106 | // handle [pre] and [code] separately because we need to remove <br />s |
| 107 | 107 | // |
| 108 | +/** |
|
| 109 | + * @param boolean $export |
|
| 110 | + */ |
|
| 108 | 111 | function replace_pre_code($text, $export) { |
| 109 | 112 | if ($export) { |
| 110 | 113 | $text = preg_replace_callback( |
@@ -272,6 +275,11 @@ discard block |
||
| 272 | 275 | // for example inside <pre> containers |
| 273 | 276 | // The original \n was retained after the br when it was added |
| 274 | 277 | // |
| 278 | +/** |
|
| 279 | + * @param string $text |
|
| 280 | + * |
|
| 281 | + * @return string |
|
| 282 | + */ |
|
| 275 | 283 | function remove_br($text){ |
| 276 | 284 | return str_replace("<br />", "", $text); |
| 277 | 285 | } |
@@ -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 | |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | if ($export) { |
| 110 | 110 | $text = preg_replace_callback( |
| 111 | 111 | "@\[pre\](.*?)\[/pre\]@is", |
| 112 | - function ($matches) { |
|
| 112 | + function($matches) { |
|
| 113 | 113 | $x = remove_br(substr($matches[0], 5, -6)); |
| 114 | 114 | $x = htmlspecialchars($x, ENT_COMPAT, "UTF-8", false); |
| 115 | 115 | $x = str_replace("[", "[", $x); |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | ); |
| 120 | 120 | return preg_replace_callback( |
| 121 | 121 | "@\[code\](.*?)\[/code\]@is", |
| 122 | - function ($matches) { |
|
| 122 | + function($matches) { |
|
| 123 | 123 | $x = remove_br(substr($matches[0], 6, -7)); |
| 124 | 124 | $x = htmlspecialchars($x, ENT_COMPAT, "UTF-8", false); |
| 125 | 125 | $x = str_replace("[", "[", $x); |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | } else { |
| 131 | 131 | $text = preg_replace_callback( |
| 132 | 132 | "@\[pre\](.*?)\[/pre\]@is", |
| 133 | - function ($matches) { |
|
| 133 | + function($matches) { |
|
| 134 | 134 | $x = remove_br(substr($matches[0], 5, -6)); |
| 135 | 135 | $x = htmlspecialchars($x, ENT_COMPAT, "UTF-8", false); |
| 136 | 136 | $x = str_replace("[", "[", $x); |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | ); |
| 141 | 141 | return preg_replace_callback( |
| 142 | 142 | "@\[code\](.*?)\[/code\]@is", |
| 143 | - function ($matches) { |
|
| 143 | + function($matches) { |
|
| 144 | 144 | $x = remove_br(substr($matches[0], 6, -7)); |
| 145 | 145 | $x = htmlspecialchars($x, ENT_COMPAT, "UTF-8", false); |
| 146 | 146 | $x = str_replace("[", "[", $x); |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | } |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | -function bb2html($text, $export=false) { |
|
| 154 | +function bb2html($text, $export = false) { |
|
| 155 | 155 | $urlregex = "(?:\"?)(?:(http\:\/\/)?)([^\[\"<\ ]+)(?:\"?)"; |
| 156 | 156 | // NOTE: |
| 157 | 157 | // This matches https:// too; I don't understand why. |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | |
| 172 | 172 | $httpsregex = "(?:\"?)https\:\/\/([^\[\"<\ ]+)(?:\"?)"; |
| 173 | 173 | // List of allowable tags |
| 174 | - $bbtags = array ( |
|
| 174 | + $bbtags = array( |
|
| 175 | 175 | "@\[b\](.*?)\[/b\]@is", |
| 176 | 176 | "@\[i\](.*?)\[/i\]@is", |
| 177 | 177 | "@\[u\](.*?)\[/u\]@is", |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | |
| 201 | 201 | // What the above tags are turned in to |
| 202 | 202 | if ($export) { |
| 203 | - $htmltags = array ( |
|
| 203 | + $htmltags = array( |
|
| 204 | 204 | "<b>\\1</b>", |
| 205 | 205 | "<i>\\1</i>", |
| 206 | 206 | "<u>\\1</u>", |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | "<a href=\"https://github.com/BOINC/boinc-dev-doc/wiki/\\1\">\\1</a>", |
| 228 | 228 | ); |
| 229 | 229 | } else { |
| 230 | - $htmltags = array ( |
|
| 230 | + $htmltags = array( |
|
| 231 | 231 | "<b>\\1</b>", |
| 232 | 232 | "<i>\\1</i>", |
| 233 | 233 | "<u>\\1</u>", |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | $lasttext = ""; |
| 260 | 260 | $i = 0; |
| 261 | 261 | // $i<1000 to prevent DoS |
| 262 | - while ($text != $lasttext && $i<1000) { |
|
| 262 | + while ($text != $lasttext && $i < 1000) { |
|
| 263 | 263 | $lasttext = $text; |
| 264 | 264 | $text = replace_pre_code($text, $export); |
| 265 | 265 | $text = preg_replace($bbtags, $htmltags, $text); |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | // for example inside <pre> containers |
| 273 | 273 | // The original \n was retained after the br when it was added |
| 274 | 274 | // |
| 275 | -function remove_br($text){ |
|
| 275 | +function remove_br($text) { |
|
| 276 | 276 | return str_replace("<br />", "", $text); |
| 277 | 277 | } |
| 278 | 278 | |
@@ -280,19 +280,19 @@ discard block |
||
| 280 | 280 | // |
| 281 | 281 | function externalize_links($text) { |
| 282 | 282 | // TODO: Convert this to PCRE |
| 283 | - $i=0; |
|
| 284 | - $linkpos=true; |
|
| 283 | + $i = 0; |
|
| 284 | + $linkpos = true; |
|
| 285 | 285 | $out = ""; |
| 286 | - while (true){ |
|
| 286 | + while (true) { |
|
| 287 | 287 | //Find a link |
| 288 | 288 | // |
| 289 | - $linkpos=strpos($text, "<a ", $i); |
|
| 290 | - if ($linkpos===false) break; |
|
| 289 | + $linkpos = strpos($text, "<a ", $i); |
|
| 290 | + if ($linkpos === false) break; |
|
| 291 | 291 | |
| 292 | 292 | //Replace with target='_new' |
| 293 | 293 | // |
| 294 | - $out .= substr($text, $i, $linkpos-$i)."<a target=\"_new\" "; |
|
| 295 | - $i = $linkpos+3; |
|
| 294 | + $out .= substr($text, $i, $linkpos - $i)."<a target=\"_new\" "; |
|
| 295 | + $i = $linkpos + 3; |
|
| 296 | 296 | } |
| 297 | 297 | $out .= substr($text, $i); |
| 298 | 298 | return $out; |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | |
| 301 | 301 | // Converts image tags to links to the images. |
| 302 | 302 | |
| 303 | -function image_as_link($text){ |
|
| 303 | +function image_as_link($text) { |
|
| 304 | 304 | /* This function depends on sanitized HTML */ |
| 305 | 305 | // Build some regex (should be a *lot* faster) |
| 306 | 306 | $pattern = '@<img([\S\s]+?)src=([^>]+?)>@si'; |
@@ -325,5 +325,5 @@ discard block |
||
| 325 | 325 | } |
| 326 | 326 | } |
| 327 | 327 | |
| 328 | -$cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit |
|
| 328 | +$cvs_version_tracker[] = "\$Id$"; //Generated automatically - do not edit |
|
| 329 | 329 | ?> |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | // for example inside <pre> containers |
| 273 | 273 | // The original \n was retained after the br when it was added |
| 274 | 274 | // |
| 275 | -function remove_br($text){ |
|
| 275 | +function remove_br($text) { |
|
| 276 | 276 | return str_replace("<br />", "", $text); |
| 277 | 277 | } |
| 278 | 278 | |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | $i=0; |
| 284 | 284 | $linkpos=true; |
| 285 | 285 | $out = ""; |
| 286 | - while (true){ |
|
| 286 | + while (true) { |
|
| 287 | 287 | //Find a link |
| 288 | 288 | // |
| 289 | 289 | $linkpos=strpos($text, "<a ", $i); |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | |
| 301 | 301 | // Converts image tags to links to the images. |
| 302 | 302 | |
| 303 | -function image_as_link($text){ |
|
| 303 | +function image_as_link($text) { |
|
| 304 | 304 | /* This function depends on sanitized HTML */ |
| 305 | 305 | // Build some regex (should be a *lot* faster) |
| 306 | 306 | $pattern = '@<img([\S\s]+?)src=([^>]+?)>@si'; |
@@ -318,7 +318,8 @@ discard block |
||
| 318 | 318 | foreach ($search as $key => $value) { |
| 319 | 319 | $replace[$key] = "<span class=\"mark\">".$value."</span>"; |
| 320 | 320 | } |
| 321 | - if (substr(phpversion(), 0, 1) > 4) { // PHP 4.x doesn't support str_ireplace |
|
| 321 | + if (substr(phpversion(), 0, 1) > 4) { |
|
| 322 | +// PHP 4.x doesn't support str_ireplace |
|
| 322 | 323 | return str_ireplace($search, $replace, $text); |
| 323 | 324 | } else { |
| 324 | 325 | return str_replace($search, $replace, $text); |
@@ -62,7 +62,7 @@ |
||
| 62 | 62 | // Do the actual transformation of the text. |
| 63 | 63 | // TODO: Make this part of the above class. |
| 64 | 64 | |
| 65 | -function output_transform($text, $options = NULL) { |
|
| 65 | +function output_transform($text, $options = null) { |
|
| 66 | 66 | // Options is a output_options object, defined above |
| 67 | 67 | if (!$options) { |
| 68 | 68 | $options = new output_options; // Defaults in the class definition |
@@ -19,6 +19,9 @@ |
||
| 19 | 19 | // express a time difference in readable form, e.g. "7 days ago". |
| 20 | 20 | // If it's more than 30 days, just show the date |
| 21 | 21 | // |
| 22 | +/** |
|
| 23 | + * @param integer $t2 |
|
| 24 | + */ |
|
| 22 | 25 | function time_diff_str($t1, $t2) { |
| 23 | 26 | if (!$t1 || !$t2) return "---"; |
| 24 | 27 | $diff = $t2 - $t1; |
@@ -22,21 +22,21 @@ discard block |
||
| 22 | 22 | function time_diff_str($t1, $t2) { |
| 23 | 23 | if (!$t1 || !$t2) return "---"; |
| 24 | 24 | $diff = $t2 - $t1; |
| 25 | - if ($diff<0){ |
|
| 26 | - $pre="In "; |
|
| 27 | - $post=""; |
|
| 28 | - $diff=-$diff; |
|
| 25 | + if ($diff < 0) { |
|
| 26 | + $pre = "In "; |
|
| 27 | + $post = ""; |
|
| 28 | + $diff = -$diff; |
|
| 29 | 29 | } else { |
| 30 | 30 | if ($diff > 86400*30) { |
| 31 | 31 | return date_str($t1); |
| 32 | 32 | } |
| 33 | - $pre=""; |
|
| 34 | - $post=" ago"; |
|
| 33 | + $pre = ""; |
|
| 34 | + $post = " ago"; |
|
| 35 | 35 | } |
| 36 | 36 | $x = ""; |
| 37 | 37 | |
| 38 | 38 | if ($diff >= 3600*24) { |
| 39 | - $n = (int) ($diff/(3600*24)); |
|
| 39 | + $n = (int)($diff/(3600*24)); |
|
| 40 | 40 | if ($n == 1) { |
| 41 | 41 | $x .= "1 day "; |
| 42 | 42 | } else { |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | return $pre.$x.$post; |
| 46 | 46 | //$diff -= $n*3600*24; |
| 47 | 47 | } elseif ($diff >= 3600) { |
| 48 | - $n = (int) ($diff/3600); |
|
| 48 | + $n = (int)($diff/3600); |
|
| 49 | 49 | if ($n == 1) { |
| 50 | 50 | $x .= "1 hour "; |
| 51 | 51 | } else { |
@@ -54,16 +54,16 @@ discard block |
||
| 54 | 54 | return $pre.$x.$post; |
| 55 | 55 | //$diff -= $n*3600; |
| 56 | 56 | } elseif ($diff >= 60) { |
| 57 | - $n = (int) ($diff/60); |
|
| 57 | + $n = (int)($diff/60); |
|
| 58 | 58 | if ($n == 1) { |
| 59 | 59 | $x .= "1 minute "; |
| 60 | 60 | } else { |
| 61 | 61 | $x .= $n." minutes "; |
| 62 | 62 | } |
| 63 | 63 | return $pre.$x.$post; |
| 64 | - } elseif($diff > 1 || $diff==0) { |
|
| 64 | + } elseif ($diff > 1 || $diff == 0) { |
|
| 65 | 65 | return $pre."$diff seconds".$post; |
| 66 | - } elseif($diff == 1){ |
|
| 66 | + } elseif ($diff == 1) { |
|
| 67 | 67 | return $pre."$diff seconds".$post; |
| 68 | 68 | } |
| 69 | 69 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | function time_diff_str($t1, $t2) { |
| 23 | 23 | if (!$t1 || !$t2) return "---"; |
| 24 | 24 | $diff = $t2 - $t1; |
| 25 | - if ($diff<0){ |
|
| 25 | + if ($diff<0) { |
|
| 26 | 26 | $pre="In "; |
| 27 | 27 | $post=""; |
| 28 | 28 | $diff=-$diff; |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | return $pre.$x.$post; |
| 64 | 64 | } elseif($diff > 1 || $diff==0) { |
| 65 | 65 | return $pre."$diff seconds".$post; |
| 66 | - } elseif($diff == 1){ |
|
| 66 | + } elseif($diff == 1) { |
|
| 67 | 67 | return $pre."$diff seconds".$post; |
| 68 | 68 | } |
| 69 | 69 | } |
@@ -112,6 +112,9 @@ discard block |
||
| 112 | 112 | // @param file The file to parse |
| 113 | 113 | // checking for inconsistencies if needed. |
| 114 | 114 | // |
| 115 | +/** |
|
| 116 | + * @param string $file |
|
| 117 | + */ |
|
| 115 | 118 | function parse_po_file($file) { |
| 116 | 119 | $translation_file = file($file); |
| 117 | 120 | $first_entry = true; |
@@ -157,6 +160,9 @@ discard block |
||
| 157 | 160 | |
| 158 | 161 | // Returns the contents of a line (ie removes "" from start and end) |
| 159 | 162 | // |
| 163 | +/** |
|
| 164 | + * @param string $line |
|
| 165 | + */ |
|
| 160 | 166 | function get_po_line($line, $file) { |
| 161 | 167 | $start = strpos($line, '"')+1; |
| 162 | 168 | $stop = strrpos($line, '"'); |
@@ -64,11 +64,11 @@ discard block |
||
| 64 | 64 | $dh = opendir($langdir.$transdir); |
| 65 | 65 | if (!$dh) die("can't open translation dir"); |
| 66 | 66 | while (($file = readdir($dh)) !== false) { |
| 67 | - if ($file==".." || $file==".") { |
|
| 67 | + if ($file == ".." || $file == ".") { |
|
| 68 | 68 | continue; |
| 69 | 69 | } |
| 70 | 70 | // only do files ending in .po |
| 71 | - if (substr($file,-3) != ".po"){ |
|
| 71 | + if (substr($file, -3) != ".po") { |
|
| 72 | 72 | //debug("File $file with unknown extension found in $info_dir"); |
| 73 | 73 | continue; |
| 74 | 74 | } |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | "-------------Compiling $transdir$file------------", 0 |
| 77 | 77 | ); |
| 78 | 78 | $language = parse_po_file($langdir.$transdir.$file); |
| 79 | - if (!$language){ |
|
| 79 | + if (!$language) { |
|
| 80 | 80 | language_log( |
| 81 | 81 | "WARNING: Could not parse language ".$file |
| 82 | 82 | ); |
@@ -95,10 +95,10 @@ discard block |
||
| 95 | 95 | ); |
| 96 | 96 | exit; |
| 97 | 97 | } |
| 98 | - foreach ($language as $key => $value){ |
|
| 98 | + foreach ($language as $key => $value) { |
|
| 99 | 99 | if ($value !== "") { |
| 100 | 100 | // Skip if the msgstr is empty |
| 101 | - fwrite($fh, "\$language_lookup_array[\"".str_replace("\"", "\\\"", substr($file,0,-3))."\"][\"".$key."\"] = \"".$value."\";\n"); |
|
| 101 | + fwrite($fh, "\$language_lookup_array[\"".str_replace("\"", "\\\"", substr($file, 0, -3))."\"][\"".$key."\"] = \"".$value."\";\n"); |
|
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | 104 | // don't write \?\> - may append |
@@ -115,26 +115,26 @@ discard block |
||
| 115 | 115 | function parse_po_file($file) { |
| 116 | 116 | $translation_file = file($file); |
| 117 | 117 | $first_entry = true; |
| 118 | - $current_token_text=""; |
|
| 119 | - $current_token =""; |
|
| 118 | + $current_token_text = ""; |
|
| 119 | + $current_token = ""; |
|
| 120 | 120 | $parsing_token = false; |
| 121 | 121 | $parsing_text = false; |
| 122 | 122 | $output = array(); |
| 123 | - for ($i=0; $i<sizeof($translation_file); $i++){ |
|
| 123 | + for ($i = 0; $i < sizeof($translation_file); $i++) { |
|
| 124 | 124 | $entry = trim($translation_file[$i]); |
| 125 | 125 | //echo "line $i: $entry\n"; |
| 126 | - if (substr($entry, 0, 1)=="#") { |
|
| 126 | + if (substr($entry, 0, 1) == "#") { |
|
| 127 | 127 | continue; |
| 128 | 128 | } elseif (strpos($entry, "msgid") !== false) { |
| 129 | - if (!$first_entry){ |
|
| 129 | + if (!$first_entry) { |
|
| 130 | 130 | //If this is not the first, save the previous entry |
| 131 | - $output[$current_token]=$current_token_text; |
|
| 131 | + $output[$current_token] = $current_token_text; |
|
| 132 | 132 | } |
| 133 | 133 | $current_token = get_po_line($entry, $file); |
| 134 | - $current_token_text=""; |
|
| 134 | + $current_token_text = ""; |
|
| 135 | 135 | $parsing_token = true; |
| 136 | 136 | $parsing_text = false; |
| 137 | - $first_entry=false; |
|
| 137 | + $first_entry = false; |
|
| 138 | 138 | } elseif (strpos($entry, "msgstr") !== false) { |
| 139 | 139 | $current_token_text = get_po_line($entry, $file); |
| 140 | 140 | $parsing_token = false; |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | |
| 149 | 149 | // Get the last token |
| 150 | 150 | // |
| 151 | - if ($current_token && $current_token_text){ |
|
| 151 | + if ($current_token && $current_token_text) { |
|
| 152 | 152 | $output[$current_token] = $current_token_text; |
| 153 | 153 | } |
| 154 | 154 | return $output; |
@@ -158,9 +158,9 @@ discard block |
||
| 158 | 158 | // Returns the contents of a line (ie removes "" from start and end) |
| 159 | 159 | // |
| 160 | 160 | function get_po_line($line, $file) { |
| 161 | - $start = strpos($line, '"')+1; |
|
| 161 | + $start = strpos($line, '"') + 1; |
|
| 162 | 162 | $stop = strrpos($line, '"'); |
| 163 | - $x = substr($line, $start, $stop-$start); |
|
| 163 | + $x = substr($line, $start, $stop - $start); |
|
| 164 | 164 | $n = preg_match("/[^\\\\]\"/", $x); |
| 165 | 165 | if ($n) { |
| 166 | 166 | echo "ERROR - MISMATCHED QUOTES IN $file: $line\n"; |
@@ -179,11 +179,11 @@ discard block |
||
| 179 | 179 | |
| 180 | 180 | // Find the string in the user's language |
| 181 | 181 | // |
| 182 | - foreach ($languages_in_use as $language){ |
|
| 182 | + foreach ($languages_in_use as $language) { |
|
| 183 | 183 | if (isset($language_lookup_array[$language][$text])) { |
| 184 | 184 | $text = $language_lookup_array[$language][$text]; |
| 185 | 185 | break; |
| 186 | - } else if ($language=="en"){ |
|
| 186 | + } else if ($language == "en") { |
|
| 187 | 187 | // This language is defined in the code and is always available |
| 188 | 188 | break; |
| 189 | 189 | } |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | // Replace relevant substrings with given arguments. |
| 193 | 193 | // Use strtr to avoid problems if an argument contains %n. |
| 194 | 194 | $replacements = array(); |
| 195 | - for ($i=1; $i<func_num_args(); $i++){ |
|
| 195 | + for ($i = 1; $i < func_num_args(); $i++) { |
|
| 196 | 196 | $replacements["%".$i] = func_get_arg($i); |
| 197 | 197 | } |
| 198 | 198 | $text = strtr($text, $replacements); |
@@ -210,13 +210,13 @@ discard block |
||
| 210 | 210 | return $text; |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | -function language_log($message, $loglevel=0) { |
|
| 213 | +function language_log($message, $loglevel = 0) { |
|
| 214 | 214 | global $lang_log_level; |
| 215 | - if ($loglevel==0) $msg = "[ Debug ]"; |
|
| 216 | - if ($loglevel==1) $msg = "[ Warning ]"; |
|
| 217 | - if ($loglevel==2) $msg = "[ CRITICAL ]"; |
|
| 215 | + if ($loglevel == 0) $msg = "[ Debug ]"; |
|
| 216 | + if ($loglevel == 1) $msg = "[ Warning ]"; |
|
| 217 | + if ($loglevel == 2) $msg = "[ CRITICAL ]"; |
|
| 218 | 218 | |
| 219 | - if ($loglevel >= $lang_log_level){ |
|
| 219 | + if ($loglevel >= $lang_log_level) { |
|
| 220 | 220 | echo gmdate("Y-m-d H:i:s", time())." ".$msg." ".$message."\n"; |
| 221 | 221 | } |
| 222 | 222 | } |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | // (by looking at cookies and browser settings) |
| 226 | 226 | // cookies have highest priority. |
| 227 | 227 | |
| 228 | -if (isset($_COOKIE['lang'])){ |
|
| 228 | +if (isset($_COOKIE['lang'])) { |
|
| 229 | 229 | $language_string = $_COOKIE['lang'].","; |
| 230 | 230 | } else { |
| 231 | 231 | $language_string = ''; |
@@ -255,10 +255,10 @@ discard block |
||
| 255 | 255 | |
| 256 | 256 | // Loop over languages that the client requests |
| 257 | 257 | // |
| 258 | -for ($i=0; $i<sizeof($client_languages); $i++) { |
|
| 259 | - if ((strlen($client_languages[$i])>2) |
|
| 258 | +for ($i = 0; $i < sizeof($client_languages); $i++) { |
|
| 259 | + if ((strlen($client_languages[$i]) > 2) |
|
| 260 | 260 | && (substr($client_languages[$i], 2, 1) == "_" || substr($client_languages[$i], 2, 1) == "-") |
| 261 | - ){ |
|
| 261 | + ) { |
|
| 262 | 262 | // If this is defined as primary-secondary, represent it as xx_YY |
| 263 | 263 | // |
| 264 | 264 | $language = substr( |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | |
| 278 | 278 | // if main language is english, look no further |
| 279 | 279 | // |
| 280 | - if ((count($languages_in_use)==0) && ($language == 'en' || $language2 == 'en')) { |
|
| 280 | + if ((count($languages_in_use) == 0) && ($language == 'en' || $language2 == 'en')) { |
|
| 281 | 281 | break; |
| 282 | 282 | } |
| 283 | 283 | |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | // |
| 286 | 286 | $file_name = $lang_language_dir.$lang_compiled_dir.$language.".po.inc"; |
| 287 | 287 | if (file_exists($file_name)) { |
| 288 | - if (!in_array($language, $languages_in_use)){ |
|
| 288 | + if (!in_array($language, $languages_in_use)) { |
|
| 289 | 289 | require_once($file_name); |
| 290 | 290 | $languages_in_use[] = $language; |
| 291 | 291 | } |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | if ($language2) { |
| 294 | 294 | $file_name = $lang_language_dir.$lang_compiled_dir.$language2.".po.inc"; |
| 295 | 295 | if (file_exists($file_name)) { |
| 296 | - if (!in_array($language2, $languages_in_use)){ |
|
| 296 | + if (!in_array($language2, $languages_in_use)) { |
|
| 297 | 297 | require_once($file_name); |
| 298 | 298 | $languages_in_use[] = $language2; |
| 299 | 299 | } |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | } |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | -$GLOBALS['languages_in_use'] = $languages_in_use; // for Drupal |
|
| 304 | +$GLOBALS['languages_in_use'] = $languages_in_use; // for Drupal |
|
| 305 | 305 | |
| 306 | -$cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit |
|
| 306 | +$cvs_version_tracker[] = "\$Id$"; //Generated automatically - do not edit |
|
| 307 | 307 | ?> |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | continue; |
| 69 | 69 | } |
| 70 | 70 | // only do files ending in .po |
| 71 | - if (substr($file,-3) != ".po"){ |
|
| 71 | + if (substr($file,-3) != ".po") { |
|
| 72 | 72 | //debug("File $file with unknown extension found in $info_dir"); |
| 73 | 73 | continue; |
| 74 | 74 | } |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | "-------------Compiling $transdir$file------------", 0 |
| 77 | 77 | ); |
| 78 | 78 | $language = parse_po_file($langdir.$transdir.$file); |
| 79 | - if (!$language){ |
|
| 79 | + if (!$language) { |
|
| 80 | 80 | language_log( |
| 81 | 81 | "WARNING: Could not parse language ".$file |
| 82 | 82 | ); |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | ); |
| 96 | 96 | exit; |
| 97 | 97 | } |
| 98 | - foreach ($language as $key => $value){ |
|
| 98 | + foreach ($language as $key => $value) { |
|
| 99 | 99 | if ($value !== "") { |
| 100 | 100 | // Skip if the msgstr is empty |
| 101 | 101 | fwrite($fh, "\$language_lookup_array[\"".str_replace("\"", "\\\"", substr($file,0,-3))."\"][\"".$key."\"] = \"".$value."\";\n"); |
@@ -120,13 +120,13 @@ discard block |
||
| 120 | 120 | $parsing_token = false; |
| 121 | 121 | $parsing_text = false; |
| 122 | 122 | $output = array(); |
| 123 | - for ($i=0; $i<sizeof($translation_file); $i++){ |
|
| 123 | + for ($i=0; $i<sizeof($translation_file); $i++) { |
|
| 124 | 124 | $entry = trim($translation_file[$i]); |
| 125 | 125 | //echo "line $i: $entry\n"; |
| 126 | 126 | if (substr($entry, 0, 1)=="#") { |
| 127 | 127 | continue; |
| 128 | 128 | } elseif (strpos($entry, "msgid") !== false) { |
| 129 | - if (!$first_entry){ |
|
| 129 | + if (!$first_entry) { |
|
| 130 | 130 | //If this is not the first, save the previous entry |
| 131 | 131 | $output[$current_token]=$current_token_text; |
| 132 | 132 | } |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | |
| 149 | 149 | // Get the last token |
| 150 | 150 | // |
| 151 | - if ($current_token && $current_token_text){ |
|
| 151 | + if ($current_token && $current_token_text) { |
|
| 152 | 152 | $output[$current_token] = $current_token_text; |
| 153 | 153 | } |
| 154 | 154 | return $output; |
@@ -179,11 +179,11 @@ discard block |
||
| 179 | 179 | |
| 180 | 180 | // Find the string in the user's language |
| 181 | 181 | // |
| 182 | - foreach ($languages_in_use as $language){ |
|
| 182 | + foreach ($languages_in_use as $language) { |
|
| 183 | 183 | if (isset($language_lookup_array[$language][$text])) { |
| 184 | 184 | $text = $language_lookup_array[$language][$text]; |
| 185 | 185 | break; |
| 186 | - } else if ($language=="en"){ |
|
| 186 | + } else if ($language=="en") { |
|
| 187 | 187 | // This language is defined in the code and is always available |
| 188 | 188 | break; |
| 189 | 189 | } |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | // Replace relevant substrings with given arguments. |
| 193 | 193 | // Use strtr to avoid problems if an argument contains %n. |
| 194 | 194 | $replacements = array(); |
| 195 | - for ($i=1; $i<func_num_args(); $i++){ |
|
| 195 | + for ($i=1; $i<func_num_args(); $i++) { |
|
| 196 | 196 | $replacements["%".$i] = func_get_arg($i); |
| 197 | 197 | } |
| 198 | 198 | $text = strtr($text, $replacements); |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | if ($loglevel==1) $msg = "[ Warning ]"; |
| 217 | 217 | if ($loglevel==2) $msg = "[ CRITICAL ]"; |
| 218 | 218 | |
| 219 | - if ($loglevel >= $lang_log_level){ |
|
| 219 | + if ($loglevel >= $lang_log_level) { |
|
| 220 | 220 | echo gmdate("Y-m-d H:i:s", time())." ".$msg." ".$message."\n"; |
| 221 | 221 | } |
| 222 | 222 | } |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | // (by looking at cookies and browser settings) |
| 226 | 226 | // cookies have highest priority. |
| 227 | 227 | |
| 228 | -if (isset($_COOKIE['lang'])){ |
|
| 228 | +if (isset($_COOKIE['lang'])) { |
|
| 229 | 229 | $language_string = $_COOKIE['lang'].","; |
| 230 | 230 | } else { |
| 231 | 231 | $language_string = ''; |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | for ($i=0; $i<sizeof($client_languages); $i++) { |
| 259 | 259 | if ((strlen($client_languages[$i])>2) |
| 260 | 260 | && (substr($client_languages[$i], 2, 1) == "_" || substr($client_languages[$i], 2, 1) == "-") |
| 261 | - ){ |
|
| 261 | + ) { |
|
| 262 | 262 | // If this is defined as primary-secondary, represent it as xx_YY |
| 263 | 263 | // |
| 264 | 264 | $language = substr( |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | // |
| 286 | 286 | $file_name = $lang_language_dir.$lang_compiled_dir.$language.".po.inc"; |
| 287 | 287 | if (file_exists($file_name)) { |
| 288 | - if (!in_array($language, $languages_in_use)){ |
|
| 288 | + if (!in_array($language, $languages_in_use)) { |
|
| 289 | 289 | require_once($file_name); |
| 290 | 290 | $languages_in_use[] = $language; |
| 291 | 291 | } |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | if ($language2) { |
| 294 | 294 | $file_name = $lang_language_dir.$lang_compiled_dir.$language2.".po.inc"; |
| 295 | 295 | if (file_exists($file_name)) { |
| 296 | - if (!in_array($language2, $languages_in_use)){ |
|
| 296 | + if (!in_array($language2, $languages_in_use)) { |
|
| 297 | 297 | require_once($file_name); |
| 298 | 298 | $languages_in_use[] = $language2; |
| 299 | 299 | } |