Passed
Pull Request — master (#5656)
by Vitalii
08:54
created
html/inc/text_transform.inc 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -26,13 +26,13 @@  discard block
 block discarded – undo
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
 block discarded – undo
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);
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
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("[", "&#91;", $x);
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
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("[", "&#91;", $x);
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
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("[", "&#91;", $x);
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
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("[", "&#91;", $x);
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
227 227
             "<a href=\"https://github.com/BOINC/boinc/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
 block discarded – undo
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);
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 // for example inside <pre> containers
275 275
 // The original \n was retained after the br when it was added
276 276
 //
277
-function remove_br($text){
277
+function remove_br($text) {
278 278
     return str_replace("<br />", "", $text);
279 279
 }
280 280
 
@@ -282,19 +282,19 @@  discard block
 block discarded – undo
282 282
 //
283 283
 function externalize_links($text) {
284 284
     // TODO:  Convert this to PCRE
285
-    $i=0;
286
-    $linkpos=true;
285
+    $i = 0;
286
+    $linkpos = true;
287 287
     $out = "";
288
-    while (true){
288
+    while (true) {
289 289
         //Find a link
290 290
         //
291
-        $linkpos=strpos($text, "<a ", $i);
292
-        if ($linkpos===false) break;
291
+        $linkpos = strpos($text, "<a ", $i);
292
+        if ($linkpos === false) break;
293 293
 
294 294
         //Replace with target='_new'
295 295
         //
296
-        $out .= substr($text, $i, $linkpos-$i)."<a target=\"_new\" ";
297
-        $i = $linkpos+3;
296
+        $out .= substr($text, $i, $linkpos - $i)."<a target=\"_new\" ";
297
+        $i = $linkpos + 3;
298 298
     }
299 299
     $out .= substr($text, $i);
300 300
     return $out;
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 
303 303
 // Converts image tags to links to the images.
304 304
 
305
-function image_as_link($text){
305
+function image_as_link($text) {
306 306
     /* This function depends on sanitized HTML */
307 307
     // Build some regex (should be a *lot* faster)
308 308
     $pattern = '@<img([\S\s]+?)src=([^>]+?)>@si';
@@ -327,5 +327,5 @@  discard block
 block discarded – undo
327 327
     }
328 328
 }
329 329
 
330
-$cvs_version_tracker[]="\$Id$";  //Generated automatically - do not edit
330
+$cvs_version_tracker[] = "\$Id$"; //Generated automatically - do not edit
331 331
 ?>
Please login to merge, or discard this patch.
html/inc/sandbox.inc 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 // Return path of sandbox directory for the given user.
33 33
 // Create dir if not present.
34 34
 //
35
-if (!function_exists("sandbox_dir")){
35
+if (!function_exists("sandbox_dir")) {
36 36
 function sandbox_dir($user) {
37 37
     $dir = parse_config(get_config(), "<sandbox_dir>");
38 38
     if (!$dir) {
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     foreach ($files as $file) {
64 64
         $path = "$dir/$file";
65 65
         [$err, $file_size, $file_md5] = sandbox_parse_link_file($path);
66
-        if (!$err){
66
+        if (!$err) {
67 67
             if (strcmp($md5, $file_md5) == 0) {
68 68
                 $exist = true;
69 69
                 $elf = $file;
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
     }
131 131
     $files = sandbox_file_names($user);
132 132
     foreach ($files as $f) {
133
-        if ($regexp && !preg_match("/$regexp/",$f)) continue;
133
+        if ($regexp && !preg_match("/$regexp/", $f)) continue;
134 134
         $x .= "<option value=\"$f\">$f</option>\n";
135 135
     }
136 136
     $x .= "</select>\n";
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 // TODO: this is a kludge.
153 153
 // Should we use the job_file and batch_file_assoc tables instead?
154 154
 //
155
-function sandbox_file_in_use($user, $file){
155
+function sandbox_file_in_use($user, $file) {
156 156
     $ufiles = array();
157 157
 
158 158
     $pbatches = BoincBatch::enum(
@@ -162,16 +162,16 @@  discard block
 block discarded – undo
162 162
     );
163 163
     if (!$pbatches) return false;
164 164
 
165
-    foreach ($pbatches as $batch){
166
-        $wus = BoincWorkUnit::enum("batch = $batch->id limit 1" );
167
-        if ($wus == null){
165
+    foreach ($pbatches as $batch) {
166
+        $wus = BoincWorkUnit::enum("batch = $batch->id limit 1");
167
+        if ($wus == null) {
168 168
             continue;
169 169
         }
170
-        foreach($wus as $wu){
170
+        foreach ($wus as $wu) {
171 171
             $x = "<in>".$wu->xml_doc."</in>";
172 172
             $x = simplexml_load_string($x);
173 173
             global $fanout;
174
-            foreach($x->workunit->file_ref as $fr){
174
+            foreach ($x->workunit->file_ref as $fr) {
175 175
                 $pname = (string)$fr->file_name;
176 176
                 $ufiles[] = $pname;
177 177
             }
@@ -180,10 +180,10 @@  discard block
 block discarded – undo
180 180
     $dir = sandbox_dir($user);
181 181
     $path = $dir."/".$file;
182 182
     list($err, $size, $md5) = sandbox_parse_link_file($path);
183
-    if (!$err){
183
+    if (!$err) {
184 184
         $f = sandbox_file_name($user, $md5);
185
-        foreach($ufiles as $uf) {
186
-            if (strcmp($f,$uf) == 0){
185
+        foreach ($ufiles as $uf) {
186
+            if (strcmp($f, $uf) == 0) {
187 187
                 return true;
188 188
             }
189 189
 
Please login to merge, or discard this patch.
html/inc/submit_util.inc 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
         }
137 137
     }
138 138
     if ($fp_total) {
139
-        $batch->fraction_done = $fp_done / $fp_total;
139
+        $batch->fraction_done = $fp_done/$fp_total;
140 140
     }
141 141
     if ($completed && $batch->state == BATCH_STATE_IN_PROGRESS) {
142 142
         $batch->state = BATCH_STATE_COMPLETE;
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 // get the total size of output files of a batch
228 228
 //
229 229
 function batch_output_file_size($batchid) {
230
-    $batch_td_size=0;
230
+    $batch_td_size = 0;
231 231
     $wus = BoincWorkunit::enum("batch=$batchid");
232 232
     $fanout = parse_config(get_config(), "<uldl_dir_fanout>");
233 233
     $upload_dir = parse_config(get_config(), "<upload_dir>");
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 }
258 258
 
259 259
 function boinc_get_wu_output_files_url($user, $wu_id) {
260
-    $auth_str =  md5($user->authenticator.$wu_id);
260
+    $auth_str = md5($user->authenticator.$wu_id);
261 261
     return "get_output.php?cmd=workunit_files&wu_id=$wu_id&auth_str=$auth_str";
262 262
 }
263 263
 
Please login to merge, or discard this patch.
html/inc/dir_hier.inc 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@
 block discarded – undo
37 37
 }
38 38
 
39 39
 function upload_path($filename) {
40
-    static $upload_dir=null;
40
+    static $upload_dir = null;
41 41
     if (!$upload_dir) {
42 42
         $config = get_config();
43 43
         $upload_dir = parse_config($config, '<upload_dir>');
Please login to merge, or discard this patch.
html/user/get_output2.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
     if ($user->authenticator != $auth) die('bad auth');
52 52
 }
53 53
 
54
-function do_result_aux($result, $batch, $file_num=null) {
54
+function do_result_aux($result, $batch, $file_num = null) {
55 55
     $phys_names = get_outfile_names($result);
56 56
     $log_names = get_outfile_log_names($result);
57 57
     if ($file_num !== null) {
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
         $dir_path = "submit/$batch->id/$result->name";
72 72
         system("rm -r $dir_path");
73 73
         mkdir($dir_path);
74
-        for ($i=0; $i<count($phys_names); $i++) {
74
+        for ($i = 0; $i < count($phys_names); $i++) {
75 75
             $cmd = sprintf('ln -s %s %s/%s',
76 76
                 upload_path($phys_names[$i]),
77 77
                 $dir_path,
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
     }
89 89
 }
90 90
 
91
-function do_result($result_id, $auth, $file_num=null) {
91
+function do_result($result_id, $auth, $file_num = null) {
92 92
     $result = BoincResult::lookup_id($result_id);
93 93
     if (!$result) die("no result $result_id");
94 94
     $workunit = BoincWorkunit::lookup_id($result->workunitid);
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
             system($cmd);
136 136
         } else {
137 137
             mkdir(sprintf('%s/%s', $dir_path, $result->name));
138
-            for ($i=0; $i<count($phys_names); $i++) {
138
+            for ($i = 0; $i < count($phys_names); $i++) {
139 139
                 $cmd = sprintf('ln -s %s %s/%s/%s',
140 140
                     upload_path($phys_names[$i]),
141 141
                     $dir_path,
Please login to merge, or discard this patch.
html/inc/cert.inc 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
43 43
     credit_to_ops($credit, $ops, $unit);
44 44
 
45 45
     if ($bolden) {
46
-        $lbold="[[";
47
-        $rbold="]]";
46
+        $lbold = "[[";
47
+        $rbold = "]]";
48 48
     } else {
49
-        $lbold="";        $rbold="";
49
+        $lbold = ""; $rbold = "";
50 50
     }
51 51
     return " $lbold$cobbs Cobblestones$rbold of computation ($ops $unit floating-point operations)";
52 52
 }
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 //
87 87
 function show_share_buttons() {
88 88
     echo '<p>';
89
-    $current_url = (empty($_SERVER['HTTPS']) ? 'http' : 'https') . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
89
+    $current_url = (empty($_SERVER['HTTPS']) ? 'http' : 'https')."://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
90 90
     $cert_url = urlencode($current_url);
91 91
 
92 92
     // Share on Facebook
Please login to merge, or discard this patch.
html/user/cert_team.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -27,10 +27,10 @@  discard block
 block discarded – undo
27 27
 if (DISABLE_TEAMS) error_page("Teams are disabled");
28 28
 
29 29
 $border = get_str("border", true);
30
-if ($border=="no") {
31
-    $border=0;
30
+if ($border == "no") {
31
+    $border = 0;
32 32
 } else {
33
-    $border=8;
33
+    $border = 8;
34 34
 }
35 35
 
36 36
 // Make sure user_id is in the URL so that share functions work
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 if (!$user_id) {
40 40
     $user = get_logged_in_user();
41 41
     Header(sprintf('Location: %s/cert_team.php?user_id=%d%s',
42
-        url_base(), $user->id, $border==0?'&border=no':''
42
+        url_base(), $user->id, $border == 0 ? '&border=no' : ''
43 43
     ));
44 44
     exit;
45 45
 }
Please login to merge, or discard this patch.
html/user/cert1.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -24,10 +24,10 @@  discard block
 block discarded – undo
24 24
 require_once("../inc/cert.inc");
25 25
 
26 26
 $border = get_str("border", true);
27
-if ($border=="no") {
28
-    $border=0;
27
+if ($border == "no") {
28
+    $border = 0;
29 29
 } else {
30
-    $border=8;
30
+    $border = 8;
31 31
 }
32 32
 
33 33
 // Make sure user_id is in the URL so that share functions work
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 if (!$user_id) {
37 37
     $user = get_logged_in_user();
38 38
     Header(sprintf('Location: %s/cert1.php?user_id=%d%s',
39
-        url_base(), $user->id, $border==0?'&border=no':''
39
+        url_base(), $user->id, $border == 0 ? '&border=no' : ''
40 40
     ));
41 41
     exit;
42 42
 }
Please login to merge, or discard this patch.
html/user/cert_all.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -25,10 +25,10 @@  discard block
 block discarded – undo
25 25
 require_once("../inc/user.inc");
26 26
 
27 27
 $border = get_str("border", true);
28
-if ($border=="no") {
29
-    $border=0;
28
+if ($border == "no") {
29
+    $border = 0;
30 30
 } else {
31
-    $border=8;
31
+    $border = 8;
32 32
 }
33 33
 
34 34
 // Make sure user_id is in the URL so that share functions work
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 if (!$user_id) {
38 38
     $user = get_logged_in_user();
39 39
     Header(sprintf('Location: %s/cert_all.php?user_id=%d%s',
40
-        url_base(), $user->id, $border==0?'&border=no':''
40
+        url_base(), $user->id, $border == 0 ? '&border=no' : ''
41 41
     ));
42 42
     exit;
43 43
 }
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
     <tr><th align=left>Project</th><th align=left>Cobblestones</th><th align=left>Joined</th></tr>
92 92
 ";
93 93
 foreach ($user->projects as $p) {
94
-    if ($p->total_credit<100) continue;
94
+    if ($p->total_credit < 100) continue;
95 95
     show_proj($p);
96 96
 }
97 97
 echo "
Please login to merge, or discard this patch.