Completed
Pull Request — master (#2457)
by Christian
09:50
created
html/ops/fix_prefs.php 1 patch
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -12,6 +12,9 @@
 block discarded – undo
12 12
 // insert "\n</venue>\n" before "</global_preferences>"
13 13
 // This fixes an XML error introduced at some point in the past
14 14
 //
15
+/**
16
+ * @return string
17
+ */
15 18
 function repair_prefs($prefs) {
16 19
     if (strstr($prefs, '\"')) {
17 20
         return str_replace('\"', '"', $prefs);
Please login to merge, or discard this patch.
html/ops/make_puser.php 1 patch
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -24,12 +24,18 @@
 block discarded – undo
24 24
 
25 25
 db_init();
26 26
 
27
+/**
28
+ * @param string $tag
29
+ */
27 30
 function parse_num($xml, $tag) {
28 31
     $x = parse_element($xml, $tag);
29 32
     if (!$x) return 0;
30 33
     return $x;
31 34
 }
32 35
 
36
+/**
37
+ * @param string $tag
38
+ */
33 39
 function parse_boolint($xml, $tag) {
34 40
     $x = parse_bool($xml, $tag);
35 41
     if ($x) return 1;
Please login to merge, or discard this patch.
html/ops/mass_email_script.php 2 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -231,6 +231,9 @@  discard block
 block discarded – undo
231 231
     }
232 232
 }
233 233
 
234
+/**
235
+ * @param resource $log
236
+ */
234 237
 function do_batch($startid, $n, $log) {
235 238
     $result = _mysql_query(
236 239
         "select * from user where id>$startid order by id limit $n"
@@ -245,6 +248,9 @@  discard block
 block discarded – undo
245 248
     return $startid;
246 249
 }
247 250
 
251
+/**
252
+ * @param resource $log
253
+ */
248 254
 function do_one($thisid, $log) {
249 255
     $result = _mysql_query(
250 256
         "select * from user where id=$thisid"
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 $globals->batch = 1000;
56 56
 $globals->lapsed_interval = 60*86400;
57 57
 
58
-for ($i=1; $i<$argc; $i++) {
58
+for ($i = 1; $i < $argc; $i++) {
59 59
     if ($argv[$i] == "--batch") {
60 60
         $i++;
61 61
         $globals->batch = $argv[$i];
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
         gmdate('d F Y', $user->create_time),
170 170
         number_format($user->total_credit, 0),
171 171
         opt_out_url($user),
172
-        floor((time() - $user->last_rpc_time) / 86400),
172
+        floor((time() - $user->last_rpc_time)/86400),
173 173
     );
174 174
     return preg_replace($pat, $rep, $template);
175 175
 }
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
     while ($user = _mysql_fetch_object($result)) {
239 239
         handle_user($user);
240 240
         $startid = $user->id;
241
-        fputs($log, $user->id . "\n");
241
+        fputs($log, $user->id."\n");
242 242
         fflush($log);
243 243
     }
244 244
     _mysql_free_result($result);
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
     $user = _mysql_fetch_object($result);
253 253
     if ($user) {
254 254
         handle_user($user);
255
-        fputs($log, $user->id . "\n");
255
+        fputs($log, $user->id."\n");
256 256
         fflush($log);
257 257
     }
258 258
     _mysql_free_result($result);
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
     } else {
290 290
         $fid = fopen($id_file, 'r'); 
291 291
         if (!$fid) {
292
-            echo  $id_file . ' not found - create ID list and run again\n';
292
+            echo  $id_file.' not found - create ID list and run again\n';
293 293
             exit();
294 294
         }
295 295
         $thisid = 0;
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
         }
301 301
         fclose($fid);
302 302
     }
303
-    echo 'All done!' . "\n";
303
+    echo 'All done!'."\n";
304 304
 }
305 305
 
306 306
 if (!function_exists('make_php_mailer')) {
Please login to merge, or discard this patch.
html/ops/notify.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -39,6 +39,9 @@
 block discarded – undo
39 39
     BoincNotify::delete_aux("create_time < $t");
40 40
 }
41 41
 
42
+/**
43
+ * @param string $message
44
+ */
42 45
 function send_notify_email($userid, $message) {
43 46
     $user = BoincUser::lookup_id($userid);
44 47
     $subject = "Daily notification summary from ".PROJECT;
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 // delete notifications older than 90 days
36 36
 //
37 37
 function delete_old_notifies() {
38
-    $t = time()-90*86400;
38
+    $t = time() - 90*86400;
39 39
     BoincNotify::delete_aux("create_time < $t");
40 40
 }
41 41
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 function send_notify_emails() {
62 62
     $db = BoincDb::get();
63 63
 
64
-    $t = time() - (86400 + 3600);  // 1-hour slop factor
64
+    $t = time() - (86400 + 3600); // 1-hour slop factor
65 65
     $query = "select notify.* from ".$db->db_name.".notify, ".$db->db_name.".forum_preferences where forum_preferences.pm_notification=2 and notify.userid = forum_preferences.userid and notify.create_time > $t";
66 66
 
67 67
     $notifies = BoincNotify::enum_general($query);
Please login to merge, or discard this patch.
html/ops/remote_server_status.php 2 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -41,6 +41,9 @@  discard block
 block discarded – undo
41 41
 
42 42
 // see if a web server is running at the given URL
43 43
 //
44
+/**
45
+ * @param string $url
46
+ */
44 47
 function web_server_running($url) {
45 48
     $u = parse_url($url);
46 49
     $url = $u['scheme']."://".$u['host'];
@@ -56,6 +59,9 @@  discard block
 block discarded – undo
56 59
 
57 60
 // see if the given daemon is running on the host by checking its PID
58 61
 //
62
+/**
63
+ * @param string $host
64
+ */
59 65
 function is_daemon_running($host, $d) {
60 66
     if ($d->pid_file) {
61 67
         $path = "../../pid_$host/".(string)$d->pid_file;
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -80,41 +80,41 @@
 block discarded – undo
80 80
         die("can't parse config file\n");
81 81
     }
82 82
     $config = $c->config;
83
-    $master_url = (string) $config->master_url;
83
+    $master_url = (string)$config->master_url;
84 84
     $u = parse_url($master_url);
85 85
     $master_host = $u["host"];
86 86
 
87
-    $url = (string) $config->download_url;
87
+    $url = (string)$config->download_url;
88 88
     $u = parse_url($url);
89 89
     $h = $u["host"];
90 90
     if ($h != $master_host) {
91 91
         $y = new StdClass;
92 92
         $y->cmd = 'Download server';
93 93
         $y->host = $h;
94
-        $y->status = web_server_running($url)?1:0;
94
+        $y->status = web_server_running($url) ? 1 : 0;
95 95
         $x[] = $y;
96 96
     }
97
-    $url = (string) $config->upload_url;
97
+    $url = (string)$config->upload_url;
98 98
     $u = parse_url($url);
99 99
     $h = $u["host"];
100 100
     if ($h != $master_host) {
101 101
         $y = new StdClass;
102 102
         $y->cmd = 'Upload server';
103 103
         $y->host = $h;
104
-        $y->status = web_server_running($url)?1:0;
104
+        $y->status = web_server_running($url) ? 1 : 0;
105 105
         $x[] = $y;
106 106
     }
107 107
 
108 108
     $main_host = (string)$c->config->host;
109 109
     if ($c->config->www_host) {
110
-        $web_host = (string) $c->config->www_host;
110
+        $web_host = (string)$c->config->www_host;
111 111
     } else {
112 112
         $web_host = $main_host;
113 113
     }
114 114
     $daemons = $c->daemons;
115 115
     foreach ($daemons->daemon as $d) {
116 116
         if ((int)$d->disabled != 0) continue;
117
-        $host = $d->host?(string)$d->host:$main_host;
117
+        $host = $d->host ? (string)$d->host : $main_host;
118 118
         if ($host != $web_host) {
119 119
             $y = new StdClass;
120 120
             $y->cmd = (string)$d->cmd;
Please login to merge, or discard this patch.
html/ops/single_job_setup.php 1 patch
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -107,10 +107,18 @@
 block discarded – undo
107 107
     }
108 108
 }
109 109
 
110
+/**
111
+ * @param integer $i
112
+ *
113
+ * @return string
114
+ */
110 115
 function app_version_dir($app_name, $i, $platform) {
111 116
     return "apps/$app_name/1.$i/$platform";
112 117
 }
113 118
 
119
+/**
120
+ * @param integer $i
121
+ */
114 122
 function make_app_version_dir($app_name, $i, $platform) {
115 123
     @mkdir("apps/$app_name");
116 124
     @mkdir("apps/$app_name/1.$i");
Please login to merge, or discard this patch.
html/ops/team_export.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -58,6 +58,9 @@
 block discarded – undo
58 58
     return $x;
59 59
 }
60 60
 
61
+/**
62
+ * @param resource $f
63
+ */
61 64
 function handle_team($team, $f) {
62 65
     echo "Team: $team->name\n";
63 66
     $user = BoincUser::lookup_id($team->userid);
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -100,7 +100,7 @@
 block discarded – undo
100 100
     $f = fopen("temp.xml", "w");
101 101
     $teams = BoincTeam::enum(null);
102 102
     fwrite($f, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<teams>\n");
103
-    foreach($teams as $team) {
103
+    foreach ($teams as $team) {
104 104
         handle_team($team, $f);
105 105
     }
106 106
     fwrite($f, "</teams>\n");
Please login to merge, or discard this patch.
html/ops/team_import.php 4 patches
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -88,6 +88,9 @@  discard block
 block discarded – undo
88 88
     return null;
89 89
 }
90 90
 
91
+/**
92
+ * @param stdClass $t
93
+ */
91 94
 function valid_team($t) {
92 95
     if (!$t->id) return false;
93 96
     if (!$t->name) return false;
@@ -96,6 +99,9 @@  discard block
 block discarded – undo
96 99
     return true;
97 100
 }
98 101
 
102
+/**
103
+ * @param stdClass $t
104
+ */
99 105
 function update_team($t, $team, $user) {
100 106
     global $dry_run;
101 107
     if (
@@ -126,6 +132,9 @@  discard block
 block discarded – undo
126 132
     }
127 133
 }
128 134
 
135
+/**
136
+ * @param stdClass $t
137
+ */
129 138
 function insert_case($t, $user) {
130 139
     global $master_url;
131 140
     global $dry_run;
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -227,7 +227,7 @@
 block discarded – undo
227 227
         if ($team->seti_id) {
228 228
             if ($team->seti_id == $t->id) {
229 229
                 echo "   case 1\n";
230
-                update_team($t, $team, $user);      // update1 case
230
+                update_team($t, $team, $user); // update1 case
231 231
             } else {
232 232
                 echo "   team exists but has wrong seti_id\n";
233 233
             }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -63,8 +63,7 @@  discard block
 block discarded – undo
63 63
             $t->user_postal_code = decode($t->user_postal_code);
64 64
             $t->user_url = decode($t->user_url);
65 65
             return $t;
66
-        }
67
-        else if (strstr($s, '<name>')) $t->name = parse_element($s, '<name>');
66
+        } else if (strstr($s, '<name>')) $t->name = parse_element($s, '<name>');
68 67
         else if (strstr($s, '<url>')) $t->url = parse_element($s, '<url>');
69 68
         else if (strstr($s, '<type>')) $t->type = parse_element($s, '<type>');
70 69
         else if (strstr($s, '<name_html>')) $t->name_html = parse_element($s, '<name_html>');
@@ -73,14 +72,12 @@  discard block
 block discarded – undo
73 72
                 if (strstr($s, '</description>')) break;
74 73
                 $t->description .= $s;
75 74
             }
76
-        }
77
-        else if (strstr($s, '<country>')) $t->country = parse_element($s, '<country>');
75
+        } else if (strstr($s, '<country>')) $t->country = parse_element($s, '<country>');
78 76
         else if (strstr($s, '<id>')) $t->id = parse_element($s, '<id>');
79 77
         else if (strstr($s, '<user_email_munged>')) {
80 78
             $user_email_munged = parse_element($s, '<user_email_munged>');
81 79
             $t->user_email = str_rot13($user_email_munged);
82
-        }
83
-        else if (strstr($s, '<user_name>')) $t->user_name = parse_element($s, '<user_name>');
80
+        } else if (strstr($s, '<user_name>')) $t->user_name = parse_element($s, '<user_name>');
84 81
         else if (strstr($s, '<user_country>')) $t->user_country = parse_element($s, '<user_country>');
85 82
         else if (strstr($s, '<user_postal_code>')) $t->user_postal_code = parse_element($s, '<user_postal_code>');
86 83
         else if (strstr($s, '<user_url>')) $t->user_url = parse_element($s, '<user_url>');
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -212,7 +212,7 @@
 block discarded – undo
212 212
         return;
213 213
     }
214 214
 
215
-    echo "Processing $t->name $t->user_email\n";
215
+    echo "processing $t->name $t->user_email\n";
216 216
     $user = BoincUser::lookup_email_addr($t->user_email);
217 217
     $team = BoincTeam::lookup_name($t->name);
218 218
     if ($team) {
Please login to merge, or discard this patch.
html/ops/update_profile_pages.php 4 patches
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -98,6 +98,9 @@  discard block
 block discarded – undo
98 98
 // Generates a standard set of links between associated multi-page documents.
99 99
 //  All linked files must be of the form "$filename_<page number>.html".
100 100
 
101
+/**
102
+ * @param integer $currPageNum
103
+ */
101 104
 function write_page_links($filename, $currPageNum, $numPages) {
102 105
     echo "<p>Page $currPageNum of $numPages</p>";
103 106
 
@@ -332,6 +335,11 @@  discard block
 block discarded – undo
332 335
 // A generalized function to produce some number of pages summarizing a
333 336
 // set of user profiles.
334 337
 
338
+/**
339
+ * @param integer $rowsPerPage
340
+ * @param integer $colsPerPage
341
+ * @param string $dir
342
+ */
335 343
 function build_profile_pages(
336 344
     $members, $title, $rowsPerPage, $colsPerPage, $dir, $base_filename
337 345
 ) {
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -200,7 +200,7 @@
 block discarded – undo
200 200
         for ($row = 0; $row < $height; $row++) {
201 201
             echo "<tr>";
202 202
             for ($col = 0; $col < $width; $col++) {
203
-	            if ($count < $numIds) {
203
+                if ($count < $numIds) {
204 204
                     echo "<td class=\"bordered\" align=\"center\">
205 205
                         <a href=\"".secure_url_base()."view_profile.php?userid=".$userIds[$count]."\"><img src=\"".secure_url_base().IMAGE_URL.$userIds[$count]."_sm.jpg\"></a>
206 206
                     </td>";
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 
40 40
 // TODO: convert to new DB interface
41 41
 
42
-$alphabet = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','0','1','2','3','4','5','6','7','8','9');
42
+$alphabet = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9');
43 43
 
44 44
 
45 45
 // Builds a summary table of user profiles.
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 function show_user_table($members, $offset, $numToDisplay, $cols) {
54 54
     start_table();
55 55
 
56
-    $rows = ceil($numToDisplay / $cols);
56
+    $rows = ceil($numToDisplay/$cols);
57 57
     $count = $offset;
58 58
     $numMembers = count($members);
59 59
 
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
     // Build an array of IDs of all users with pictures in their profiles.
152 152
     $userIds = array();
153 153
     $numIds = 0;
154
-    foreach($profiles as $profile) {
154
+    foreach ($profiles as $profile) {
155 155
         $user = BoincUser::lookup_id($profile->userid);
156 156
         if (!$user) continue; // maybe we should delete the profile if user is non-existent anymore?
157 157
         if ($user->name) {
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 //        shuffle($userIds);
172 172
 //    }
173 173
 
174
-    $numPages = ceil(count($userIds)/($width * $height));
174
+    $numPages = ceil(count($userIds)/($width*$height));
175 175
 
176 176
     // Make sure that a page is generated even when no profiles with pictures
177 177
     // exist in order to avoid 404 errors from the profile_menu page.
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
     $count = 0;
186 186
 
187 187
     for ($page = 1; $page <= $numPages; $page++) {
188
-        $filename = PROFILE_PATH . "user_gallery_" . $page . ".html";
188
+        $filename = PROFILE_PATH."user_gallery_".$page.".html";
189 189
         open_output_buffer();
190 190
 
191 191
         page_head("Profile gallery: page $page of $numPages", null, false, "../");
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
     // of the userids who belong to those countries.
245 245
     // Format: array[country][index] = userid.
246 246
 
247
-    foreach($profiles as $profile) {
247
+    foreach ($profiles as $profile) {
248 248
         $user = BoincUser::lookup_id($profile->userid);
249 249
         if (!$user) continue; // maybe we should delete the profile if user is non-existent anymore?
250 250
         if ($user->country) {
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
     // TODO: Define a constant for the desired number of rows per page.
265 265
 
266 266
     foreach ($countries as $country) {
267
-        $baseFileName =  "profile_country_" . get_legal_filename($country);
267
+        $baseFileName = "profile_country_".get_legal_filename($country);
268 268
         build_profile_pages(
269 269
             $countryMembers[$country],
270 270
             "User Profiles from $country", 5, 2,
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
     $numIds = 0;
291 291
     $members = array();
292 292
 
293
-    foreach($profiles as $profile) {
293
+    foreach ($profiles as $profile) {
294 294
         $user = BoincUser::lookup_id($profile->userid);
295 295
         if (!$user) continue; // maybe we should delete the profile if user is non-existent anymore?
296 296
         if ($user->name) {
@@ -335,11 +335,11 @@  discard block
 block discarded – undo
335 335
 function build_profile_pages(
336 336
     $members, $title, $rowsPerPage, $colsPerPage, $dir, $base_filename
337 337
 ) {
338
-    $numPerPage = $rowsPerPage * $colsPerPage;
339
-    $numPages = ceil(count($members) / $numPerPage);
338
+    $numPerPage = $rowsPerPage*$colsPerPage;
339
+    $numPages = ceil(count($members)/$numPerPage);
340 340
 
341 341
     for ($page = 1; $page <= $numPages; $page++) {
342
-        $filename = $dir . $base_filename . "_" . $page . ".html";
342
+        $filename = $dir.$base_filename."_".$page.".html";
343 343
         open_output_buffer();
344 344
 
345 345
         $pagetitle = $title.": Page $page of $numPages";
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 
348 348
         echo "Last updated ", pretty_time_str(time()), "<p>\n";
349 349
 
350
-        $offset = (($page-1) * $rowsPerPage * $colsPerPage);
350
+        $offset = (($page - 1)*$rowsPerPage*$colsPerPage);
351 351
 
352 352
         show_user_table($members, $offset, $numPerPage, $colsPerPage);
353 353
 
@@ -364,11 +364,11 @@  discard block
 block discarded – undo
364 364
     print_debug_msg("Beginning to build country summary page...");
365 365
     $countries = array_keys($countryMembers);
366 366
 
367
-    $filename = PROFILE_PATH . "profile_country.html";
367
+    $filename = PROFILE_PATH."profile_country.html";
368 368
     open_output_buffer();
369 369
 
370 370
     page_head("User Profiles by Country", null, null, "../");
371
-    echo "Last updated " . pretty_time_str(time()) . "<p>";
371
+    echo "Last updated ".pretty_time_str(time())."<p>";
372 372
 
373 373
     start_table();
374 374
     row_heading_array(array("Country", "Profiles"));
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
 
414 414
 $caching = true;
415 415
 
416
-if (@$argv[1]=="-d") $debug=true;
416
+if (@$argv[1] == "-d") $debug = true;
417 417
 
418 418
 build_country_pages();
419 419
 build_alpha_pages();
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -180,7 +180,7 @@
 block discarded – undo
180 180
         $numPages = 1;
181 181
     }
182 182
 
183
-    print_debug_msg("Generating $numPages pages");
183
+    print_debug_msg("generating $numPages pages");
184 184
 
185 185
     $count = 0;
186 186
 
Please login to merge, or discard this patch.