Completed
Pull Request — master (#1827)
by Christian
08:16
created
html/inc/sandbox.inc 3 patches
Doc Comments   +12 added lines patch added patch discarded remove patch
@@ -26,6 +26,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
             
Please login to merge, or discard this patch.
Braces   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
             
Please login to merge, or discard this patch.
html/inc/submit.inc 2 patches
Doc Comments   +24 added lines patch added patch discarded remove patch
@@ -145,6 +145,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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>
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
     $b->create_time = (double)($batch->create_time);
159 159
     $b->est_completion_time = (double)($batch->est_completion_time);
160 160
     $b->njobs = (int)($batch->njobs);
161
-    $b->fraction_done = (double) $batch->fraction_done;
161
+    $b->fraction_done = (double)$batch->fraction_done;
162 162
     $b->nerror_jobs = (int)($batch->nerror_jobs);
163 163
     $b->state = (int)($batch->state);
164 164
     $b->completion_time = (double)($batch->completion_time);
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
     </result>
387 387
 </output_template>
388 388
 ";
389
-    for ($i=0; $i<2; $i++) {
389
+    for ($i = 0; $i < 2; $i++) {
390 390
         $job->rsc_fpops_est = $i*1e9;
391 391
         $job->command_line = "--t $i";
392 392
         $job->wu_template = $it;
Please login to merge, or discard this patch.
html/inc/submit_db.inc 1 patch
Doc Comments   +16 added lines patch added patch discarded remove patch
@@ -34,6 +34,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
html/inc/submit_util.inc 2 patches
Doc Comments   +11 added lines patch added patch discarded remove patch
@@ -26,6 +26,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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";
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
html/inc/team.inc 2 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -524,6 +524,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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://")) {
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
     }
169 169
     row1(tra('Members'));
170 170
     row2(tra('Founder'),
171
-        $team->founder?user_links($team->founder, BADGE_HEIGHT_MEDIUM):"---"
171
+        $team->founder ? user_links($team->founder, BADGE_HEIGHT_MEDIUM) : "---"
172 172
     );
173 173
     if (count($team->admins)) {
174 174
         $first = true;
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
         foreach ($deltas as $delta) {
347 347
             $u = BoincUser::lookup_id($delta->userid);
348 348
             if ($u->teamid == $teamid) {
349
-                $new_members[] = $u;  // they might have later quit
349
+                $new_members[] = $u; // they might have later quit
350 350
             }
351 351
         }
352 352
     }
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
     if (!$user->teamid) return;
418 418
     $user->update("teamid=0");
419 419
     $team = BoincTeam::lookup_id($user->teamid);
420
-    if ($team && $team->ping_user=$user->id) {
420
+    if ($team && $team->ping_user = $user->id) {
421 421
         $team->update("ping_user=-ping_user");
422 422
     }
423 423
     BoincTeamAdmin::delete("teamid=$user->teamid and userid=$user->id");
@@ -443,34 +443,34 @@  discard block
 block discarded – undo
443 443
     start_table();
444 444
     row2(tra('Team name, text version').'
445 445
         <br><p class=\"text-muted\">'.tra('Don\'t use HTML tags.').'</p>',
446
-        '<input class="form-control" name="name" type="text" size="50" value="'.($team?$team->name:"").'">'
446
+        '<input class="form-control" name="name" type="text" size="50" value="'.($team ? $team->name : "").'">'
447 447
     );
448 448
     row2(tra('Team name, HTML version').'
449 449
         <br><p class=\"text-muted\">
450 450
         '.tra('You may use %1limited HTML tags%2.', '<a href="html.php" target="_new">', '</a>').'
451 451
         '.tra('If you don\'t know HTML, leave this box blank.').'</p>',
452
-        '<input class="form-control" name="name_html" type="text" size="50" value="'.str_replace('"',"'",($team?$team->name_html:"")).'">'
452
+        '<input class="form-control" name="name_html" type="text" size="50" value="'.str_replace('"', "'", ($team ? $team->name_html : "")).'">'
453 453
     );
454 454
     row2(tra('URL of team web page, if any').':<br><font size=-2>('.tra('without "http://"').')
455 455
         '.tra('This URL will be linked to from the team\'s page on this site.'),
456
-        '<input class="form-control" type="text" name="url" size="60" value="'.($team?$team->url:"").'">'
456
+        '<input class="form-control" type="text" name="url" size="60" value="'.($team ? $team->url : "").'">'
457 457
     );
458 458
     row2(tra('Description of team').':
459 459
         <br><p class=\"text-muted\">
460 460
         '.tra('You may use %1limited HTML tags%2.', '<a href="html.php" target="_new">', '</a>').'
461 461
         </p>',
462
-        '<textarea class="form-control" name="description" rows=10>'.($team?$team->description:"").'</textarea>'
462
+        '<textarea class="form-control" name="description" rows=10>'.($team ? $team->description : "").'</textarea>'
463 463
     );
464 464
 
465
-    row2(tra('Type of team').':', team_type_select($team?$team->type:null));
465
+    row2(tra('Type of team').':', team_type_select($team ? $team->type : null));
466 466
 
467 467
     row2_init(tra('Country'),
468 468
         '<select class="form-control" name="country">'
469 469
     );
470
-    echo country_select_options($team?$team->country:null);
470
+    echo country_select_options($team ? $team->country : null);
471 471
 
472 472
     echo "</select></td></tr>\n";
473
-    $x = (!$team || $team->joinable)?"checked":"";
473
+    $x = (!$team || $team->joinable) ? "checked" : "";
474 474
     row2(tra("Accept new members?"), "<input type=checkbox name=joinable $x>");
475 475
     row2("",
476 476
         "<input class=\"btn btn-primary\" type=submit name=new value='$label'>"
@@ -526,12 +526,12 @@  discard block
 block discarded – undo
526 526
 //
527 527
 function new_transfer_request_ok($team, $now) {
528 528
     if ($team->ping_user <= 0) {
529
-        if ($team->ping_time < $now - 60 * 86400) {
529
+        if ($team->ping_time < $now - 60*86400) {
530 530
             return true;
531 531
         }
532 532
         return false;
533 533
     }
534
-    if ($team->ping_time < $now - 90 * 86400) {
534
+    if ($team->ping_time < $now - 90*86400) {
535 535
         return true;
536 536
     }
537 537
     return false;
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
     if (!is_valid_country($country)) {
567 567
         $country = tra('None');
568 568
     }
569
-    $country = BoincDb::escape_string($country);  // for Cote d'Ivoire
569
+    $country = BoincDb::escape_string($country); // for Cote d'Ivoire
570 570
 
571 571
     $clause = sprintf(
572 572
         "(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())",
@@ -589,6 +589,6 @@  discard block
 block discarded – undo
589 589
     }
590 590
 }
591 591
 
592
-$cvs_version_tracker[]="\$Id$";  //Generated automatically - do not edit
592
+$cvs_version_tracker[] = "\$Id$"; //Generated automatically - do not edit
593 593
 
594 594
 ?>
Please login to merge, or discard this patch.
html/inc/text_transform.inc 4 patches
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -105,6 +105,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 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
 
@@ -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-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
 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);
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 ?>
Please login to merge, or discard this patch.
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
html/inc/time.inc 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -19,6 +19,9 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -22,21 +22,21 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
html/inc/translation.inc 3 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -112,6 +112,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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, '"');
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -64,11 +64,11 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 ?>
Please login to merge, or discard this patch.
Braces   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
             }
Please login to merge, or discard this patch.
html/inc/user.inc 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -113,6 +113,9 @@
 block discarded – undo
113 113
     return ($a->expavg_credit < $b->expavg_credit)? 1 : -1;
114 114
 }
115 115
 
116
+/**
117
+ * @param boolean $personal
118
+ */
116 119
 function show_other_projects($user, $personal) {
117 120
     if (!isset($user->projects)) return;
118 121
     if (count($user->projects) < 2) return;
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -33,13 +33,13 @@  discard block
 block discarded – undo
33 33
 // they've participated in
34 34
 //
35 35
 function get_other_projects($user) {
36
-    $cpid = md5($user->cross_project_id . $user->email_addr);
36
+    $cpid = md5($user->cross_project_id.$user->email_addr);
37 37
     $url = "http://boinc.netsoft-online.com/get_user.php?cpid=".$cpid;
38 38
 
39 39
     // Check the cache for that URL
40 40
     //
41 41
     $cacheddata = get_cached_data(REMOTE_PROJECTS_TTL, $url);
42
-    if ($cacheddata){
42
+    if ($cacheddata) {
43 43
         $remote = unserialize($cacheddata);
44 44
     } else {
45 45
         // Fetch the XML, use curl if fopen() is disallowed
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 
111 111
 function cmp($a, $b) {
112 112
     if ($a->expavg_credit == $b->expavg_credit) return 0;
113
-    return ($a->expavg_credit < $b->expavg_credit)? 1 : -1;
113
+    return ($a->expavg_credit < $b->expavg_credit) ? 1 : -1;
114 114
 }
115 115
 
116 116
 function show_other_projects($user, $personal) {
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
         ),
134 134
         array("", ALIGN_RIGHT, ALIGN_RIGHT, ALIGN_RIGHT)
135 135
     );
136
-    foreach($user->projects as $project) {
136
+    foreach ($user->projects as $project) {
137 137
         show_project($project);
138 138
     }
139 139
     end_table();
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
     $config = get_config();
162 162
     row2(tra("Computers on this account"), "<a href=\"hosts_user.php\">".tra("View")."</a>");
163 163
     row2(tra("Tasks"), "<a href=\"results.php?userid=$user->id\">".tra("View")."</a>");
164
-    $cpid = md5($user->cross_project_id . $user->email_addr);
164
+    $cpid = md5($user->cross_project_id.$user->email_addr);
165 165
     $x = "";
166 166
     shuffle($cpid_stats_sites);
167 167
     foreach ($cpid_stats_sites as $site) {
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 // show user name, with links to profile if present.
309 309
 // if $badge_height is > 0, show badges
310 310
 //
311
-function user_links($user, $badge_height=0) {
311
+function user_links($user, $badge_height = 0) {
312 312
     BoincForumPrefs::lookup($user);
313 313
     if (is_banished($user)) {
314 314
         return "(banished: ID $user->id)";
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
     if ($badge_height) {
331 331
         $x .= badges_string(true, $user, $badge_height);
332 332
     }
333
-    if (function_exists("project_user_links")){
333
+    if (function_exists("project_user_links")) {
334 334
         $x .= project_user_links($user);
335 335
     }
336 336
     return $x;
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 
384 384
             // if there's a foundership request, notify the founder
385 385
             //
386
-            if ($user->id==$team->userid && $team->ping_user >0) {
386
+            if ($user->id == $team->userid && $team->ping_user > 0) {
387 387
                 $x .= "<p class=\"text-danger\">".tra("(foundership change request pending)")."</p>";
388 388
             }
389 389
             row2(tra("Member of team"), $x);
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
     $x = "<a href=\"user_search.php\">".tra("Find friends")."</a><br/>\n";
409 409
     $n = count($friends);
410 410
     if ($n) {
411
-        foreach($friends as $friend) {
411
+        foreach ($friends as $friend) {
412 412
             $fuser = BoincUser::lookup_id($friend->user_dest);
413 413
             if (!$fuser) continue;
414 414
             $x .= friend_links($fuser);
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 // Returns a cacheable community links data object
462 462
 // @param user The user to produce a community links object for
463 463
 
464
-function get_community_links_object($user){
464
+function get_community_links_object($user) {
465 465
     $cache_object = new StdClass;
466 466
     $cache_object->post_count = total_posts($user);
467 467
     $cache_object->user = $user;
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
     $cache_object->friends = array();
470 470
 
471 471
     $friends = BoincFriend::enum("user_src=$user->id and reciprocated=1");
472
-    foreach($friends as $friend) {
472
+    foreach ($friends as $friend) {
473 473
         $fuser = BoincUser::lookup_id($friend->user_dest);
474 474
         if (!$fuser) continue;
475 475
         $cache_object->friends[] = $fuser;
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
     return $cache_object;
478 478
 }
479 479
 
480
-function community_links($clo, $logged_in_user){
480
+function community_links($clo, $logged_in_user) {
481 481
     $user = $clo->user;
482 482
     $team = $clo->team;
483 483
     $friends = $clo->friends;
@@ -503,15 +503,15 @@  discard block
 block discarded – undo
503 503
                 "<a href=\"friend.php?action=cancel_confirm&userid=$user->id\">".tra("Cancel friendship")."</a>"
504 504
             );
505 505
         } else if ($friend) {
506
-            row2(tra("Friends"),  "<a href=\"friend.php?action=add&userid=$user->id\">".tra("Request pending")."</a>");
506
+            row2(tra("Friends"), "<a href=\"friend.php?action=add&userid=$user->id\">".tra("Request pending")."</a>");
507 507
         } else {
508
-            row2(tra("Friends"),  "<a href=\"friend.php?action=add&userid=$user->id\">".tra("Add as friend")."</a>");
508
+            row2(tra("Friends"), "<a href=\"friend.php?action=add&userid=$user->id\">".tra("Add as friend")."</a>");
509 509
         }
510 510
     }
511 511
     
512 512
     if ($friends) {
513 513
         $x = "";
514
-        foreach($friends as $friend) {
514
+        foreach ($friends as $friend) {
515 515
             $x .= friend_links($friend);
516 516
         }
517 517
         row2(tra("Friends")." (".sizeof($friends).")", $x);
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
 function is_banned_email_addr($email_addr) {
555 555
     global $banned_email_domains;
556 556
     if (isset($banned_email_domains)) {
557
-        foreach($banned_email_domains as $d) {
557
+        foreach ($banned_email_domains as $d) {
558 558
             $x = strstr($email_addr, $d);
559 559
             if ($x == $d) return true;
560 560
         }
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
 //
583 583
 function make_user(
584 584
     $email_addr, $name, $passwd_hash,
585
-    $country=null, $postal_code=null, $project_prefs=null, $teamid=0
585
+    $country = null, $postal_code = null, $project_prefs = null, $teamid = 0
586 586
 ) {
587 587
     if (!is_valid_email_addr($email_addr)) return null;
588 588
     if (is_banned_email_addr($email_addr)) return null;
@@ -654,6 +654,6 @@  discard block
 block discarded – undo
654 654
     $user->delete();
655 655
 }
656 656
 
657
-$cvs_version_tracker[]="\$Id$";  //Generated automatically - do not edit
657
+$cvs_version_tracker[] = "\$Id$"; //Generated automatically - do not edit
658 658
 
659 659
 ?>
Please login to merge, or discard this patch.
Braces   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
     // Check the cache for that URL
40 40
     //
41 41
     $cacheddata = get_cached_data(REMOTE_PROJECTS_TTL, $url);
42
-    if ($cacheddata){
42
+    if ($cacheddata) {
43 43
         $remote = unserialize($cacheddata);
44 44
     } else {
45 45
         // Fetch the XML, use curl if fopen() is disallowed
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
     if ($badge_height) {
331 331
         $x .= badges_string(true, $user, $badge_height);
332 332
     }
333
-    if (function_exists("project_user_links")){
333
+    if (function_exists("project_user_links")) {
334 334
         $x .= project_user_links($user);
335 335
     }
336 336
     return $x;
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
             row2(tra("Computers"), tra("hidden"));
445 445
         }
446 446
     }
447
-    if ($user->donated == 1) { 
447
+    if ($user->donated == 1) {
448 448
         if (file_exists("../project/donations.inc")) {
449 449
             require_once("../project/donations.inc");
450 450
             row2(tra("Donor"), DONATION_LINK);
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 // Returns a cacheable community links data object
462 462
 // @param user The user to produce a community links object for
463 463
 
464
-function get_community_links_object($user){
464
+function get_community_links_object($user) {
465 465
     $cache_object = new StdClass;
466 466
     $cache_object->post_count = total_posts($user);
467 467
     $cache_object->user = $user;
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
     return $cache_object;
478 478
 }
479 479
 
480
-function community_links($clo, $logged_in_user){
480
+function community_links($clo, $logged_in_user) {
481 481
     $user = $clo->user;
482 482
     $team = $clo->team;
483 483
     $friends = $clo->friends;
Please login to merge, or discard this patch.