Completed
Pull Request — master (#2472)
by Kevin
11:06
created
html/inc/user_util.inc 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 function check_passwd($user, $passwd) {
34 34
     $passwd_hash = md5($passwd.$user->email_addr);
35 35
     
36
-    if ( password_verify($passwd_hash, $user->passwd_hash) ) {
36
+    if (password_verify($passwd_hash, $user->passwd_hash)) {
37 37
         return true;
38 38
     }
39 39
     
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 }
49 49
 
50 50
 function check_passwd_ui($user, $passwd) {
51
-    if( !check_passwd($user, $passwd) ) {
51
+    if (!check_passwd($user, $passwd)) {
52 52
         sleep(LOGIN_FAIL_SLEEP_SEC);
53 53
         page_head("Password incorrect");
54 54
         echo "The password you entered is incorrect. Please go back and try again.\n";
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 function is_banned_email_addr($email_addr) {
61 61
     global $banned_email_domains;
62 62
     if (isset($banned_email_domains)) {
63
-        foreach($banned_email_domains as $d) {
63
+        foreach ($banned_email_domains as $d) {
64 64
             $x = strstr($email_addr, $d);
65 65
             if ($x == $d) return true;
66 66
         }
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 //
89 89
 function make_user(
90 90
     $email_addr, $name, $passwd_hash,
91
-    $country=null, $postal_code=null, $project_prefs=null, $teamid=0
91
+    $country = null, $postal_code = null, $project_prefs = null, $teamid = 0
92 92
 ) {
93 93
     if (!is_valid_email_addr($email_addr)) return null;
94 94
     if (is_banned_email_addr($email_addr)) return null;
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
         show_error(tra("Passwords may only include ASCII characters."));
217 217
     }
218 218
 
219
-    if (strlen($passwd)<$min_passwd_length) {
219
+    if (strlen($passwd) < $min_passwd_length) {
220 220
         show_error(
221 221
             tra("New password is too short: minimum password length is %1 characters.", $min_passwd_length)
222 222
         );
Please login to merge, or discard this patch.
html/ops/test_token.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,13 +28,13 @@
 block discarded – undo
28 28
 echo "---------------\n";
29 29
 $boincToken = BoincToken::lookup_valid_token(0, $token, 'T');
30 30
 if ( $boincToken != null ) {
31
-   echo "Found valid token\n";
31
+    echo "Found valid token\n";
32 32
 }
33 33
 
34 34
 echo "---------------\n";
35 35
 $boincToken = BoincToken::lookup_valid_token(0, 'notrealtoken', 'T');
36 36
 if ( $boincToken == null ) {
37
-   echo "Successfully didn't find invalid token\n";
37
+    echo "Successfully didn't find invalid token\n";
38 38
 }
39 39
 
40 40
 echo "---------------\n";
Please login to merge, or discard this patch.
html/user/delete_account_request.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@
 block discarded – undo
37 37
         ."</ul><br/>";
38 38
     
39 39
     form_start(secure_url_base()."delete_account_request.php", "post");
40
-    form_input_text(tra("Password"), "passwd", "", "password",'id="passwd"',passwd_visible_checkbox("passwd"));
40
+    form_input_text(tra("Password"), "passwd", "", "password", 'id="passwd"', passwd_visible_checkbox("passwd"));
41 41
     form_submit(tra("Send Confirmation Email"));
42 42
     form_end();
43 43
     
Please login to merge, or discard this patch.
html/inc/token.inc 1 patch
Doc Comments   +7 added lines patch added patch discarded remove patch
@@ -25,6 +25,10 @@  discard block
 block discarded – undo
25 25
 // Constants for token durations
26 26
 define("TOKEN_DURATION_ONE_DAY", 86400);
27 27
 
28
+/**
29
+ * @param string $type
30
+ * @param integer $duration
31
+ */
28 32
 function create_token($userid, $type, $duration) {
29 33
     $token = random_string();
30 34
     $now = time();
@@ -37,6 +41,9 @@  discard block
 block discarded – undo
37 41
     return $token;
38 42
 }
39 43
 
44
+/**
45
+ * @param string $type
46
+ */
40 47
 function is_valid_token($userid, $token, $type) {
41 48
     $boincToken = BoincToken::lookup_valid_token($userid, $token, $type);
42 49
     if ( $boincToken == null ) {
Please login to merge, or discard this patch.
html/inc/email.inc 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 
26 26
 // send an email, using PHPMailer or not.
27 27
 //
28
-function send_email($user, $subject, $body, $body_html=null) {
28
+function send_email($user, $subject, $body, $body_html = null) {
29 29
     if (function_exists("make_php_mailer")) {
30 30
         require_once("../inc/phpmailer/class.phpmailer.php");
31 31
         $mail = make_php_mailer();
@@ -44,11 +44,11 @@  discard block
 block discarded – undo
44 44
             return true;
45 45
         }
46 46
     } else {
47
-        $headers ="";
47
+        $headers = "";
48 48
         if (defined('EMAIL_FROM') && defined('EMAIL_FROM_NAME')) {
49 49
             $headers = "From: ".EMAIL_FROM_NAME." <".EMAIL_FROM.">";
50 50
         } else if (defined('EMAIL_FROM')) {
51
-            $headers = "From: ". EMAIL_FROM;
51
+            $headers = "From: ".EMAIL_FROM;
52 52
         }
53 53
         return mail($user->email_addr, $subject, $body, $headers);
54 54
     }
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
     if (defined("USE_STOPFORUMSPAM") && USE_STOPFORUMSPAM && array_key_exists('REMOTE_ADDR', $_SERVER)) {
97 97
         $ip = $_SERVER['REMOTE_ADDR'];
98 98
         // For obviously private IPs check just the email against SFS, otherwise check both IP and email
99
-        if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) {
99
+        if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE|FILTER_FLAG_NO_RES_RANGE)) {
100 100
             $x = @file_get_contents("https://www.stopforumspam.com/api?ip=".$ip."&email=".$addr);
101 101
         } else {
102 102
             $x = @file_get_contents("https://www.stopforumspam.com/api?email=".$addr);
@@ -107,12 +107,12 @@  discard block
 block discarded – undo
107 107
     }
108 108
     $pattern = '/^([^@]+)@([^@\.]+)\.([^@]{2,})$/';
109 109
     $match = preg_match($pattern, $addr);
110
-    return (bool) $match;
110
+    return (bool)$match;
111 111
 }
112 112
 
113 113
 function send_confirm_delete_email($user) {
114 114
     $token = create_token($user->id, TOKEN_TYPE_DELETE_ACCOUNT, TOKEN_DURATION_ONE_DAY);
115
-    if ( $token == null ) {
115
+    if ($token == null) {
116 116
         error_page("Error creating token.  Please try again later.");
117 117
     }
118 118
     
Please login to merge, or discard this patch.
html/inc/delete_account.inc 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -27,6 +27,9 @@
 block discarded – undo
27 27
     );
28 28
 }
29 29
 
30
+/**
31
+ * @param null|integer $userid
32
+ */
30 33
 function check_delete_account_token($userid, $token) {
31 34
     if( !is_valid_token($userid, $token, TOKEN_TYPE_DELETE_ACCOUNT) ) {
32 35
         sleep(LOGIN_FAIL_SLEEP_SEC);
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -26,14 +26,14 @@  discard block
 block discarded – undo
26 26
 define("DELETE_ACCOUNT_METHOD_WIPE", 2);
27 27
 
28 28
 $config = get_config();
29
-if ( !parse_bool($config, "enable_delete_account") ) {
29
+if (!parse_bool($config, "enable_delete_account")) {
30 30
     error_page(
31 31
         tra("This feature is disabled.  Please contact the project administrator.")
32 32
     );
33 33
 }
34 34
 
35 35
 function check_delete_account_token($userid, $token) {
36
-    if( !is_valid_token($userid, $token, TOKEN_TYPE_DELETE_ACCOUNT) ) {
36
+    if (!is_valid_token($userid, $token, TOKEN_TYPE_DELETE_ACCOUNT)) {
37 37
         sleep(LOGIN_FAIL_SLEEP_SEC);
38 38
         error_page(
39 39
             tra("The token you used has expired or is otherwise not valid.  Please request a new one <a href=\"delete_account_request.php\">here</a>")
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
 function delete_account($user) {
49 49
     $config = get_config();
50 50
     $enable_delete_account = parse_config($config, "<enable_delete_account>");
51
-    if ( $enable_delete_account == DELETE_ACCOUNT_METHOD_OBFUSCATE ) {
51
+    if ($enable_delete_account == DELETE_ACCOUNT_METHOD_OBFUSCATE) {
52 52
         return obfuscate_account($user);
53
-    } else if ( $enable_delete_account == DELETE_ACCOUNT_METHOD_WIPE ) {
53
+    } else if ($enable_delete_account == DELETE_ACCOUNT_METHOD_WIPE) {
54 54
         return wipe_account($user);
55 55
     } else {
56 56
         error_page(
Please login to merge, or discard this patch.
html/user/delete_account_confirm.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -32,9 +32,9 @@
 block discarded – undo
32 32
     page_head(tra("Delete Account"));
33 33
     
34 34
     echo "<p>".tra("Thank you for verifying ownership of your account.")."</p>"
35
-         ."<p>".tra("You can now delete your account by entering in your password below and clicking the \"Delete Account\" button.")."</p>"
36
-         ."<p>".tra("As a reminder, your account <b>cannot be recovered</b> once you delete it.")."</p>"
37
-         ."<br/>";
35
+            ."<p>".tra("You can now delete your account by entering in your password below and clicking the \"Delete Account\" button.")."</p>"
36
+            ."<p>".tra("As a reminder, your account <b>cannot be recovered</b> once you delete it.")."</p>"
37
+            ."<br/>";
38 38
     
39 39
     form_start(secure_url_base()."delete_account_confirm.php", "post");
40 40
     form_input_hidden("token",$token);
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -37,9 +37,9 @@  discard block
 block discarded – undo
37 37
          ."<br/>";
38 38
     
39 39
     form_start(secure_url_base()."delete_account_confirm.php", "post");
40
-    form_input_hidden("token",$token);
41
-    form_input_hidden("id",$userid);
42
-    form_input_text(tra("Password"), "passwd", "", "password",'id="passwd"',passwd_visible_checkbox("passwd"));
40
+    form_input_hidden("token", $token);
41
+    form_input_hidden("id", $userid);
42
+    form_input_text(tra("Password"), "passwd", "", "password", 'id="passwd"', passwd_visible_checkbox("passwd"));
43 43
     form_submit(tra("Delete Account"));
44 44
     form_end();
45 45
     
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
     $passwd = post_str("passwd");
58 58
     check_passwd_ui($user, $passwd);
59 59
     
60
-    if ( !delete_account($user) ) {
60
+    if (!delete_account($user)) {
61 61
         error_page(
62 62
             tra("Failed to delete your account.  Please contact the project administrator.")
63 63
         );    
Please login to merge, or discard this patch.
html/inc/user.inc 1 patch
Spacing   +17 added lines, -17 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();
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
     }
175 175
 
176 176
     if (!NO_STATS) {
177
-        $cpid = md5($user->cross_project_id . $user->email_addr);
177
+        $cpid = md5($user->cross_project_id.$user->email_addr);
178 178
         $x = "";
179 179
         shuffle($cpid_stats_sites);
180 180
         foreach ($cpid_stats_sites as $site) {
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
     } else {
263 263
         $delete_account_str = "";
264 264
         $config = get_config();
265
-        if ( parse_bool($config, "enable_delete_account") ) {
265
+        if (parse_bool($config, "enable_delete_account")) {
266 266
             $delete_account_str = " &middot; <a href=\"delete_account_request.php\">".tra("delete account")."</a>";
267 267
         }
268 268
         
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 // show user name, with links to profile if present.
328 328
 // if $badge_height is > 0, show badges
329 329
 //
330
-function user_links($user, $badge_height=0) {
330
+function user_links($user, $badge_height = 0) {
331 331
     BoincForumPrefs::lookup($user);
332 332
     if (is_banished($user)) {
333 333
         return "(banished: ID $user->id)";
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
         $x .= ' <a href="'.url_base().'view_profile.php?userid='.$user->id.'"><img title="View the profile of '.$user->name.'" src="'.$img_url.'" alt="Profile"></a>';
339 339
     }
340 340
     $x .= " <a href=\"".url_base()."show_user.php?userid=".$user->id."\">".$user->name."</a>";
341
-    if (function_exists("project_user_links")){
341
+    if (function_exists("project_user_links")) {
342 342
         $x .= project_user_links($user);
343 343
     }
344 344
     if ($badge_height) {
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 
392 392
             // if there's a foundership request, notify the founder
393 393
             //
394
-            if ($user->id==$team->userid && $team->ping_user >0) {
394
+            if ($user->id == $team->userid && $team->ping_user > 0) {
395 395
                 $x .= "<p class=\"text-danger\">".tra("(foundership change request pending)")."</p>";
396 396
             }
397 397
             row2(tra("Member of team"), $x);
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
     $x = "<a href=\"user_search.php\">".tra("Find friends")."</a><br/>\n";
417 417
     $n = count($friends);
418 418
     if ($n) {
419
-        foreach($friends as $friend) {
419
+        foreach ($friends as $friend) {
420 420
             $fuser = BoincUser::lookup_id($friend->user_dest);
421 421
             if (!$fuser) continue;
422 422
             $x .= friend_links($fuser);
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
 // Returns a cacheable community links data object
460 460
 // @param user The user to produce a community links object for
461 461
 
462
-function get_community_links_object($user){
462
+function get_community_links_object($user) {
463 463
     $cache_object = new StdClass;
464 464
     $cache_object->post_count = total_posts($user);
465 465
     $cache_object->user = $user;
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
     $cache_object->friends = array();
468 468
 
469 469
     $friends = BoincFriend::enum("user_src=$user->id and reciprocated=1");
470
-    foreach($friends as $friend) {
470
+    foreach ($friends as $friend) {
471 471
         $fuser = BoincUser::lookup_id($friend->user_dest);
472 472
         if (!$fuser) continue;
473 473
         $cache_object->friends[] = $fuser;
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
     return $cache_object;
476 476
 }
477 477
 
478
-function community_links($clo, $logged_in_user){
478
+function community_links($clo, $logged_in_user) {
479 479
     $user = $clo->user;
480 480
     $team = $clo->team;
481 481
     $friends = $clo->friends;
@@ -501,15 +501,15 @@  discard block
 block discarded – undo
501 501
                 "<a href=\"friend.php?action=cancel_confirm&userid=$user->id\">".tra("Cancel friendship")."</a>"
502 502
             );
503 503
         } else if ($friend) {
504
-            row2(tra("Friends"),  "<a href=\"friend.php?action=add&userid=$user->id\">".tra("Request pending")."</a>");
504
+            row2(tra("Friends"), "<a href=\"friend.php?action=add&userid=$user->id\">".tra("Request pending")."</a>");
505 505
         } else {
506
-            row2(tra("Friends"),  "<a href=\"friend.php?action=add&userid=$user->id\">".tra("Add as friend")."</a>");
506
+            row2(tra("Friends"), "<a href=\"friend.php?action=add&userid=$user->id\">".tra("Add as friend")."</a>");
507 507
         }
508 508
     }
509 509
     
510 510
     if ($friends) {
511 511
         $x = "";
512
-        foreach($friends as $friend) {
512
+        foreach ($friends as $friend) {
513 513
             $x .= friend_links($friend);
514 514
         }
515 515
         row2(tra("Friends")." (".sizeof($friends).")", $x);
@@ -554,6 +554,6 @@  discard block
 block discarded – undo
554 554
 }
555 555
 
556 556
 
557
-$cvs_version_tracker[]="\$Id$";  //Generated automatically - do not edit
557
+$cvs_version_tracker[] = "\$Id$"; //Generated automatically - do not edit
558 558
 
559 559
 ?>
Please login to merge, or discard this patch.