Passed
Push — master ( d7c477...ca5311 )
by Sam
05:11
created
www/includes/easyparliament/templates/html/user/form.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -125,7 +125,7 @@
 block discarded – undo
125 125
                   <span class="label">Security status:</span>
126 126
                   <span class="formw"><select name="status">
127 127
                   <?php
128
-                  foreach ($statuses as $n => $status_name) { ?>
128
+                    foreach ($statuses as $n => $status_name) { ?>
129 129
                     <option value="<?= $status_name ?>"<?= $status_name == $status ? ' selected' : '' ?>>
130 130
                       <?= $status_name ?>
131 131
                     </option>
Please login to merge, or discard this patch.
www/includes/easyparliament/user.php 2 patches
Braces   +27 added lines, -9 removed lines patch added patch discarded remove patch
@@ -445,9 +445,15 @@  discard block
 block discarded – undo
445 445
                 // Generates the password ....
446 446
                 for ($x=0; $x < 6;) {
447 447
                     $y = rand(1,1000);
448
-                    if($y>350 && $y<601) $d=chr(rand(48,57));
449
-                    if($y<351) $d=chr(rand(65,90));
450
-                    if($y>600) $d=chr(rand(97,122));
448
+                    if($y>350 && $y<601) {
449
+                        $d=chr(rand(48,57));
450
+                    }
451
+                    if($y<351) {
452
+                        $d=chr(rand(65,90));
453
+                    }
454
+                    if($y>600) {
455
+                        $d=chr(rand(97,122));
456
+                    }
451 457
                     if ($d!=$o && !preg_match('#[O01lI]#', $d)) {
452 458
                         $o=$d; $pwd.=$d; $x++;
453 459
                     }
@@ -1171,8 +1177,12 @@  discard block
 block discarded – undo
1171 1177
 
1172 1178
     public function confirm_email($token, $redirect=true) {
1173 1179
         $arg = '';
1174
-        if (strstr($token, '::')) $arg = '::';
1175
-        if (strstr($token, '-')) $arg = '-';
1180
+        if (strstr($token, '::')) {
1181
+            $arg = '::';
1182
+        }
1183
+        if (strstr($token, '-')) {
1184
+            $arg = '-';
1185
+        }
1176 1186
         list($user_id, $registrationtoken) = explode($arg, $token);
1177 1187
 
1178 1188
         if (!is_numeric($user_id) || $registrationtoken == '') {
@@ -1254,8 +1264,12 @@  discard block
 block discarded – undo
1254 1264
 
1255 1265
         // Split the token into its parts.
1256 1266
         $arg = '';
1257
-        if (strstr($token, '::')) $arg = '::';
1258
-        if (strstr($token, '-')) $arg = '-';
1267
+        if (strstr($token, '::')) {
1268
+            $arg = '::';
1269
+        }
1270
+        if (strstr($token, '-')) {
1271
+            $arg = '-';
1272
+        }
1259 1273
         list($user_id, $registrationtoken) = explode($arg, $token);
1260 1274
 
1261 1275
         if (!is_numeric($user_id) || $registrationtoken == '') {
@@ -1385,15 +1399,19 @@  discard block
 block discarded – undo
1385 1399
         // not-logged-in users.
1386 1400
 
1387 1401
         $this->postcode = $pc;
1388
-        if (!headers_sent()) // if in debug mode
1402
+        if (!headers_sent()) {
1403
+            // if in debug mode
1389 1404
             setcookie (POSTCODE_COOKIE, $pc, time()+7*86400, "/", COOKIEDOMAIN);
1405
+        }
1390 1406
 
1391 1407
         twfy_debug('USER', "Set the cookie named '" . POSTCODE_COOKIE . " to '$pc' for " . COOKIEDOMAIN . " domain");
1392 1408
     }
1393 1409
 
1394 1410
     public function unset_postcode_cookie() {
1395
-        if (!headers_sent()) // if in debug mode
1411
+        if (!headers_sent()) {
1412
+            // if in debug mode
1396 1413
             setcookie (POSTCODE_COOKIE, '', time() - 3600, '/', COOKIEDOMAIN);
1414
+        }
1397 1415
     }
1398 1416
 
1399 1417
     // mostly here for updating from facebook where we do not need
Please login to merge, or discard this patch.
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -56,21 +56,21 @@  discard block
 block discarded – undo
56 56
 
57 57
 class USER {
58 58
 
59
-    public $user_id = "0";         // So we have an ID for non-logged in users reporting comments etc.
60
-    public $firstname = "Guest";   // So we have something to print for non-logged in users.
59
+    public $user_id = "0"; // So we have an ID for non-logged in users reporting comments etc.
60
+    public $firstname = "Guest"; // So we have something to print for non-logged in users.
61 61
     public $lastname = "";
62
-    public $password = "";         // This will be a hashed version of a plaintext pw.
62
+    public $password = ""; // This will be a hashed version of a plaintext pw.
63 63
     public $email = "";
64 64
     public $postcode = "";
65 65
     public $url = "";
66
-    public $lastvisit = "";        // Last time the logged-in user loaded a page (GMT).
66
+    public $lastvisit = ""; // Last time the logged-in user loaded a page (GMT).
67 67
     public $registrationtime = ""; // When they registered (GMT).
68
-    public $registrationip = "";   // Where they registered from.
69
-    public $optin = "";            // boolean - Do they want emails from us?
70
-    public $deleted = "";          // User can't log in or have their info displayed.
71
-    public $confirmed = '';        // boolean - Has the user confirmed via email?
72
-    public $facebook_id = '';      // Facebook ID for users who login with FB
73
-    public $facebook_token = '';   // Facebook token for users who login with FB
68
+    public $registrationip = ""; // Where they registered from.
69
+    public $optin = ""; // boolean - Do they want emails from us?
70
+    public $deleted = ""; // User can't log in or have their info displayed.
71
+    public $confirmed = ''; // boolean - Has the user confirmed via email?
72
+    public $facebook_id = ''; // Facebook ID for users who login with FB
73
+    public $facebook_token = ''; // Facebook token for users who login with FB
74 74
     // Don't use the status to check access privileges - use the is_able_to() function.
75 75
     public $status = "Viewer";
76 76
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 
143 143
     }
144 144
 
145
-    public function add($details, $confirmation_required=true) {
145
+    public function add($details, $confirmation_required = true) {
146 146
         // Adds a new user's info into the db.
147 147
         // Then optionally (and usually) calls another function to
148 148
         // send them a confirmation email.
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
             // This will be sent to them via email, so we can confirm they exist.
225 225
             // The token will be the first 16 characters of a hash.
226 226
 
227
-            $token = substr( password_hash($details["email"] . microtime(), PASSWORD_BCRYPT), 29, 16 );
227
+            $token = substr(password_hash($details["email"] . microtime(), PASSWORD_BCRYPT), 29, 16);
228 228
 
229 229
             // Full stops don't work well at the end of URLs in emails, so
230 230
             // replace them. And double slash would be treated as single and
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
             $r = $this->db->query("UPDATE users
238 238
                             SET registrationtoken = :registrationtoken
239 239
                             WHERE   user_id = :user_id
240
-                            ", array (
240
+                            ", array(
241 241
                                 ':registrationtoken' => $this->registrationtoken,
242 242
                                 ':user_id' => $this->user_id
243 243
                             ));
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
     }
285 285
 
286 286
     public function add_facebook_id($facebook_id) {
287
-        $q = $this->db->query ("UPDATE users SET facebook_id = :facebook_id WHERE email = :email",
287
+        $q = $this->db->query("UPDATE users SET facebook_id = :facebook_id WHERE email = :email",
288 288
             array(
289 289
                 ':facebook_id' => $facebook_id,
290 290
                 ':email' => $this->email
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
             !isset($details['email']) ||
306 306
             $details['email'] == '' ||
307 307
             !isset($details['token']) ||
308
-            $details['token'] == '' ) {
308
+            $details['token'] == '') {
309 309
             return false;
310 310
         }
311 311
 
@@ -317,12 +317,12 @@  discard block
 block discarded – undo
317 317
         $confirmurl = 'https://' . DOMAIN . '/E/' . $urltoken;
318 318
 
319 319
         // Arrays we need to send a templated email.
320
-        $data = array (
320
+        $data = array(
321 321
             'to'        => $details['email'],
322 322
             'template'  => 'email_confirmation'
323 323
         );
324 324
 
325
-        $merge = array (
325
+        $merge = array(
326 326
             'CONFIRMURL'    => $confirmurl
327 327
         );
328 328
 
@@ -360,12 +360,12 @@  discard block
 block discarded – undo
360 360
         }
361 361
 
362 362
         // Arrays we need to send a templated email.
363
-        $data = array (
363
+        $data = array(
364 364
             'to'        => $details['email'],
365 365
             'template'  => 'join_confirmation'
366 366
         );
367 367
 
368
-        $merge = array (
368
+        $merge = array(
369 369
             'CONFIRMURL'    => $confirmurl
370 370
         );
371 371
 
@@ -425,23 +425,23 @@  discard block
 block discarded – undo
425 425
             $this->email = $email;
426 426
             for (;;) {
427 427
 
428
-                $pwd=null;
429
-                $o=null;
428
+                $pwd = null;
429
+                $o = null;
430 430
 
431 431
                 // Generates the password ....
432
-                for ($x=0; $x < 6;) {
433
-                    $y = rand(1,1000);
434
-                    if($y>350 && $y<601) $d=chr(rand(48,57));
435
-                    if($y<351) $d=chr(rand(65,90));
436
-                    if($y>600) $d=chr(rand(97,122));
437
-                    if ($d!=$o && !preg_match('#[O01lI]#', $d)) {
438
-                        $o=$d; $pwd.=$d; $x++;
432
+                for ($x = 0; $x < 6;) {
433
+                    $y = rand(1, 1000);
434
+                    if ($y > 350 && $y < 601) $d = chr(rand(48, 57));
435
+                    if ($y < 351) $d = chr(rand(65, 90));
436
+                    if ($y > 600) $d = chr(rand(97, 122));
437
+                    if ($d != $o && !preg_match('#[O01lI]#', $d)) {
438
+                        $o = $d; $pwd .= $d; $x++;
439 439
                     }
440 440
                 }
441 441
 
442 442
                 // If the PW fits your purpose (e.g. this regexpression) return it, else make a new one
443 443
                 // (You can change this regular-expression how you want ....)
444
-                if (preg_match("/^[a-zA-Z]{1}([a-zA-Z]+[0-9][a-zA-Z]+)+/",$pwd)) {
444
+                if (preg_match("/^[a-zA-Z]{1}([a-zA-Z]+[0-9][a-zA-Z]+)+/", $pwd)) {
445 445
                     break;
446 446
                 }
447 447
 
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
 
460 460
         $passwordforDB = password_hash($pwd, PASSWORD_BCRYPT);
461 461
 
462
-        $q = $this->db->query ("UPDATE users SET password = :password WHERE email = :email",
462
+        $q = $this->db->query("UPDATE users SET password = :password WHERE email = :email",
463 463
             array(
464 464
                 ':password' => $passwordforDB,
465 465
                 ':email' => $email
@@ -487,14 +487,14 @@  discard block
 block discarded – undo
487 487
             return false;
488 488
         }
489 489
 
490
-        $data = array (
490
+        $data = array(
491 491
             'to'            => $this->email(),
492 492
             'template'      => 'new_password'
493 493
         );
494 494
 
495 495
         $URL = new \MySociety\TheyWorkForYou\Url("userlogin");
496 496
 
497
-        $merge = array (
497
+        $merge = array(
498 498
             'EMAIL'         => $this->email(),
499 499
             'LOGINURL'      => "https://" . DOMAIN . $URL->generate(),
500 500
             'PASSWORD'      => $this->password()
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
     public function facebook_id_exists($id, $return_id = false) {
550 550
         // Returns true if there's a user with this facebook id.
551 551
 
552
-        if ($id!= "") {
552
+        if ($id != "") {
553 553
             $q = $this->db->query("SELECT user_id FROM users WHERE facebook_id = :id", array(':id' => $id))->first();
554 554
             if ($q) {
555 555
                 if ($return_id) {
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
                 /* Everyone */              return true;
625 625
 
626 626
             default:
627
-                $PAGE->error_message ("You need to set permissions for '$action'!");
627
+                $PAGE->error_message("You need to set permissions for '$action'!");
628 628
 
629 629
                 return false;
630 630
 
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
         // Maybe there's a way of fetching these from the DB,
643 643
         // so we don't duplicate them here...?
644 644
 
645
-        $statuses = array ("Viewer", "User", "Moderator", "Administrator", "Superuser");
645
+        $statuses = array("Viewer", "User", "Moderator", "Administrator", "Superuser");
646 646
 
647 647
         return $statuses;
648 648
 
@@ -797,7 +797,7 @@  discard block
 block discarded – undo
797 797
             return $details;
798 798
 
799 799
         } else {
800
-            $PAGE->error_message ("Sorry, we were unable to update user id '" . _htmlentities($details["user_id"]) . "'");
800
+            $PAGE->error_message("Sorry, we were unable to update user id '" . _htmlentities($details["user_id"]) . "'");
801 801
 
802 802
             return false;
803 803
         }
@@ -870,13 +870,13 @@  discard block
 block discarded – undo
870 870
 
871 871
                     if ($this->facebook_user) {
872 872
                         if (md5($this->facebook_token()) == $matches[2] && $this->deleted() == false) {
873
-                            twfy_debug ("THEUSER", "init SUCCESS: setting as logged in");
873
+                            twfy_debug("THEUSER", "init SUCCESS: setting as logged in");
874 874
                             $this->loggedin = true;
875
-                        } elseif (md5 ($this->facebook_token()) != $matches[2]) {
876
-                            twfy_debug ("THEUSER", "init FAILED: Facebook token doesn't match cookie");
875
+                        } elseif (md5($this->facebook_token()) != $matches[2]) {
876
+                            twfy_debug("THEUSER", "init FAILED: Facebook token doesn't match cookie");
877 877
                             $this->loggedin = false;
878 878
                         } else {
879
-                            twfy_debug ("THEUSER", "init FAILED: User is deleted");
879
+                            twfy_debug("THEUSER", "init FAILED: User is deleted");
880 880
                             $this->loggedin = false;
881 881
                         }
882 882
                     } else {
@@ -889,30 +889,30 @@  discard block
 block discarded – undo
889 889
                             // to need. Their preferences and saved things or something.
890 890
 
891 891
 
892
-                            twfy_debug ("THEUSER init SUCCEEDED", "setting as logged in");
892
+                            twfy_debug("THEUSER init SUCCEEDED", "setting as logged in");
893 893
                             $this->loggedin = true;
894 894
 
895
-                        } elseif (md5 ($this->password()) != $matches[2]) {
896
-                            twfy_debug ("THEUSER init FAILED", "Password doesn't match cookie");
895
+                        } elseif (md5($this->password()) != $matches[2]) {
896
+                            twfy_debug("THEUSER init FAILED", "Password doesn't match cookie");
897 897
                             $this->loggedin = false;
898 898
                         } else {
899
-                            twfy_debug ("THEUSER init FAILED", "User is deleted");
899
+                            twfy_debug("THEUSER init FAILED", "User is deleted");
900 900
                             $this->loggedin = false;
901 901
                         }
902 902
                     }
903 903
 
904 904
                 } else {
905
-                    twfy_debug ("THEUSER init FAILED", "didn't get 1 row from db");
905
+                    twfy_debug("THEUSER init FAILED", "didn't get 1 row from db");
906 906
                     $this->loggedin = false;
907 907
                 }
908 908
 
909 909
             } else {
910
-                twfy_debug ("THEUSER init FAILED", "cookie's user_id is not numeric");
910
+                twfy_debug("THEUSER init FAILED", "cookie's user_id is not numeric");
911 911
                 $this->loggedin = false;
912 912
             }
913 913
 
914 914
         } else {
915
-            twfy_debug ("THEUSER init FAILED", "cookie is not of the correct form");
915
+            twfy_debug("THEUSER init FAILED", "cookie is not of the correct form");
916 916
             $this->loggedin = false;
917 917
         }
918 918
 
@@ -938,7 +938,7 @@  discard block
 block discarded – undo
938 938
             // Set last_visit to now.
939 939
             $date_now = gmdate("Y-m-d H:i:s");
940 940
             $this->db->query("UPDATE users SET lastvisit = :lastvisit WHERE user_id = :user_id",
941
-                [ ':lastvisit' => $date_now, ':user_id' => $this->user_id() ]);
941
+                [':lastvisit' => $date_now, ':user_id' => $this->user_id()]);
942 942
 
943 943
             $this->lastvisit = $date_now;
944 944
         }
@@ -994,55 +994,55 @@  discard block
 block discarded – undo
994 994
 
995 995
             } else {
996 996
                 // Failed.
997
-                return array ("invalidemail" => $error_string);
997
+                return array("invalidemail" => $error_string);
998 998
 
999 999
             }
1000 1000
 
1001 1001
         } else {
1002 1002
             // Failed.
1003
-            return array ("invalidemail" => $error_string);
1003
+            return array("invalidemail" => $error_string);
1004 1004
         }
1005 1005
 
1006 1006
     }
1007 1007
 
1008 1008
     public function has_postcode() {
1009 1009
         $has_postcode = false;
1010
-        if ( $this->isloggedin() && $this->postcode() != '' || $this->postcode_is_set() ) {
1010
+        if ($this->isloggedin() && $this->postcode() != '' || $this->postcode_is_set()) {
1011 1011
             $has_postcode = true;
1012 1012
         }
1013 1013
         return $has_postcode;
1014 1014
     }
1015 1015
 
1016 1016
 
1017
-    public function facebook_login($returl="", $expire, $accessToken) {
1017
+    public function facebook_login($returl = "", $expire, $accessToken) {
1018 1018
         global $PAGE;
1019 1019
 
1020 1020
         twfy_debug("THEUSER", "Faceook login, user_id " . $this->user_id);
1021 1021
         twfy_debug("THEUSER", "Faceook login, facebook_id " . $this->facebook_id);
1022 1022
         twfy_debug("THEUSER", "Faceook login, email" . $this->email);
1023 1023
         if ($this->facebook_id() == "") {
1024
-            $PAGE->error_message ("We don't have a facebook id for this user.", true);
1024
+            $PAGE->error_message("We don't have a facebook id for this user.", true);
1025 1025
 
1026 1026
             return;
1027 1027
         }
1028 1028
 
1029 1029
         twfy_debug("THEUSER", "Faceook login, facebook_token: " . $accessToken);
1030 1030
 
1031
-        $q = $this->db->query ("UPDATE users SET facebook_token = :token WHERE email = :email",
1031
+        $q = $this->db->query("UPDATE users SET facebook_token = :token WHERE email = :email",
1032 1032
             array(
1033 1033
                 ':token' => $accessToken,
1034 1034
                 ':email' => $this->email
1035 1035
             ));
1036 1036
 
1037 1037
         if (!$q->success()) {
1038
-            $PAGE->error_message ("There was a problem logging you in", true);
1038
+            $PAGE->error_message("There was a problem logging you in", true);
1039 1039
             twfy_debug("THEUSER", "Faceook login, failed to set accessToken");
1040 1040
 
1041 1041
             return false;
1042 1042
         }
1043 1043
 
1044 1044
         // facebook login users probably don't have a password
1045
-        $cookie = $this->user_id() . "." . md5 ($accessToken);
1045
+        $cookie = $this->user_id() . "." . md5($accessToken);
1046 1046
         twfy_debug("THEUSER", "Faceook login, cookie: " . $cookie);
1047 1047
 
1048 1048
         twfy_debug("USER", "logging in user from facebook " . $this->user_id);
@@ -1052,7 +1052,7 @@  discard block
 block discarded – undo
1052 1052
         return true;
1053 1053
     }
1054 1054
 
1055
-    public function login($returl="", $expire) {
1055
+    public function login($returl = "", $expire) {
1056 1056
 
1057 1057
         // This is used to log the user in. Duh.
1058 1058
         // You should already have checked the user's email and password using
@@ -1074,21 +1074,21 @@  discard block
 block discarded – undo
1074 1074
 
1075 1075
         // Various checks about the user - if they fail, we exit.
1076 1076
         if ($this->user_id() == "" || $this->password == "") {
1077
-            $PAGE->error_message ("We don't have the user_id or password to make the cookie.", true);
1077
+            $PAGE->error_message("We don't have the user_id or password to make the cookie.", true);
1078 1078
 
1079 1079
             return;
1080 1080
         } elseif ($this->deleted) {
1081
-            $PAGE->error_message ("This user has been deleted.", true);
1081
+            $PAGE->error_message("This user has been deleted.", true);
1082 1082
 
1083 1083
             return;
1084 1084
         } elseif (!$this->confirmed) {
1085
-            $PAGE->error_message ("You have not yet confirmed your account by clicking the link in the confirmation email we sent to you. If you don't have the email, you can <a href='/user/login/?resend=" . $this->user_id() . "'>have it resent</a>. If it still doesn't arrive, get in touch.", true);
1085
+            $PAGE->error_message("You have not yet confirmed your account by clicking the link in the confirmation email we sent to you. If you don't have the email, you can <a href='/user/login/?resend=" . $this->user_id() . "'>have it resent</a>. If it still doesn't arrive, get in touch.", true);
1086 1086
 
1087 1087
             return;
1088 1088
         }
1089 1089
 
1090 1090
         // Reminder: $this->password is actually a hashed version of the plaintext pw.
1091
-        $cookie = $this->user_id() . "." . md5 ($this->password());
1091
+        $cookie = $this->user_id() . "." . md5($this->password());
1092 1092
 
1093 1093
         $this->_login($returl, $expire, $cookie);
1094 1094
     }
@@ -1104,7 +1104,7 @@  discard block
 block discarded – undo
1104 1104
         $cookie_expires = 0;
1105 1105
         if ($expire == 'never') {
1106 1106
             twfy_debug("THEUSER", "cookie never expires");
1107
-            $cookie_expires = time()+86400*365*20;
1107
+            $cookie_expires = time() + 86400 * 365 * 20;
1108 1108
         } elseif (is_int($expire) && $expire > time()) {
1109 1109
             twfy_debug("THEUSER", "cookie expires at " . $expire);
1110 1110
             $cookie_expires = $expire;
@@ -1142,7 +1142,7 @@  discard block
 block discarded – undo
1142 1142
         }
1143 1143
     }
1144 1144
 
1145
-    public function confirm_email($token, $redirect=true) {
1145
+    public function confirm_email($token, $redirect = true) {
1146 1146
         $arg = '';
1147 1147
         if (strstr($token, '::')) $arg = '::';
1148 1148
         if (strstr($token, '-')) $arg = '-';
@@ -1155,24 +1155,24 @@  discard block
 block discarded – undo
1155 1155
             FROM    tokens
1156 1156
             WHERE   token = :token
1157 1157
             AND   type = 'E'
1158
-        ", array (':token' => $registrationtoken))->first();
1158
+        ", array(':token' => $registrationtoken))->first();
1159 1159
 
1160 1160
         if ($q) {
1161 1161
             $expires = $q['expires'];
1162 1162
             $expire_time = strtotime($expires);
1163
-            if ( $expire_time < time() ) {
1163
+            if ($expire_time < time()) {
1164 1164
                 global $PAGE;
1165 1165
                 if ($PAGE && $redirect) {
1166
-                    $PAGE->error_message ("Sorry, that token seems to have expired");
1166
+                    $PAGE->error_message("Sorry, that token seems to have expired");
1167 1167
                 }
1168 1168
 
1169 1169
                 return false;
1170 1170
             }
1171 1171
 
1172
-            list( $user_id, $email ) = explode('::', $q['data']);
1172
+            list($user_id, $email) = explode('::', $q['data']);
1173 1173
 
1174 1174
             // if we are logged in as someone else don't change the email
1175
-            if ( $this->user_id() != 0 && $this->user_id() != $user_id ) {
1175
+            if ($this->user_id() != 0 && $this->user_id() != $user_id) {
1176 1176
                 return false;
1177 1177
             }
1178 1178
 
@@ -1321,7 +1321,7 @@  discard block
 block discarded – undo
1321 1321
 
1322 1322
             twfy_debug("THEUSER", "User with ID found to confirm: " . $this->user_id());
1323 1323
             // We'll need these to be set before logging the user in.
1324
-            $this->email    = $q['email'];
1324
+            $this->email = $q['email'];
1325 1325
 
1326 1326
             // Set that they're confirmed in the DB.
1327 1327
             $r = $this->db->query("UPDATE users
@@ -1368,14 +1368,14 @@  discard block
 block discarded – undo
1368 1368
 
1369 1369
         $this->postcode = $pc;
1370 1370
         if (!headers_sent()) // if in debug mode
1371
-            setcookie (POSTCODE_COOKIE, $pc, time()+7*86400, "/", COOKIEDOMAIN);
1371
+            setcookie(POSTCODE_COOKIE, $pc, time() + 7 * 86400, "/", COOKIEDOMAIN);
1372 1372
 
1373 1373
         twfy_debug('USER', "Set the cookie named '" . POSTCODE_COOKIE . " to '$pc' for " . COOKIEDOMAIN . " domain");
1374 1374
     }
1375 1375
 
1376 1376
     public function unset_postcode_cookie() {
1377 1377
         if (!headers_sent()) // if in debug mode
1378
-            setcookie (POSTCODE_COOKIE, '', time() - 3600, '/', COOKIEDOMAIN);
1378
+            setcookie(POSTCODE_COOKIE, '', time() - 3600, '/', COOKIEDOMAIN);
1379 1379
     }
1380 1380
 
1381 1381
     // mostly here for updating from facebook where we do not need
@@ -1388,8 +1388,8 @@  discard block
 block discarded – undo
1388 1388
 
1389 1389
             // this is checked elsewhere but just in case we check here and
1390 1390
             // bail out to be on the safe side
1391
-            if ( isset($details['email'] ) ) {
1392
-                if ( $details['email'] != $this->email() && $this->email_exists( $details['email'] ) ) {
1391
+            if (isset($details['email'])) {
1392
+                if ($details['email'] != $this->email() && $this->email_exists($details['email'])) {
1393 1393
                     return false;
1394 1394
                 }
1395 1395
             }
@@ -1437,8 +1437,8 @@  discard block
 block discarded – undo
1437 1437
             // this is checked elsewhere but just in case we check here and
1438 1438
             // bail out to be on the safe side
1439 1439
             $email = '';
1440
-            if ( isset($details['email'] ) ) {
1441
-                if ( $details['email'] != $this->email() && $this->email_exists( $details['email'] ) ) {
1440
+            if (isset($details['email'])) {
1441
+                if ($details['email'] != $this->email() && $this->email_exists($details['email'])) {
1442 1442
                     return false;
1443 1443
                 }
1444 1444
                 $email = $details['email'];
@@ -1465,7 +1465,7 @@  discard block
 block discarded – undo
1465 1465
                 }
1466 1466
 
1467 1467
                 if ($email && $email != $this->email) {
1468
-                    $token = substr( password_hash($email . microtime(), PASSWORD_BCRYPT), 29, 16 );
1468
+                    $token = substr(password_hash($email . microtime(), PASSWORD_BCRYPT), 29, 16);
1469 1469
                     $data = $this->user_id() . '::' . $email;
1470 1470
                     $r = $this->db->query("INSERT INTO tokens
1471 1471
                         ( expires, token, type, data )
@@ -1482,7 +1482,7 @@  discard block
 block discarded – undo
1482 1482
                     ));
1483 1483
 
1484 1484
                     // send confirmation email here
1485
-                    if ( $r->success() ) {
1485
+                    if ($r->success()) {
1486 1486
                         $newdetails['email'] = $email;
1487 1487
                         $newdetails['token'] = $token;
1488 1488
                         if ($confirm_email) {
Please login to merge, or discard this patch.
www/docs/user/login/fb.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -27,11 +27,11 @@
 block discarded – undo
27 27
 
28 28
 $data['fb_login_url'] = $login->getLoginURL();
29 29
 if (isset($data['token'])) {
30
-  $success = $login->loginUser($data['token']);
31
-  if (!$success) {
30
+    $success = $login->loginUser($data['token']);
31
+    if (!$success) {
32 32
     $data['error'] = 'Could not login using Facebook token';
33 33
     \MySociety\TheyWorkForYou\Renderer::output('login/facebook', $data);
34
-  }
34
+    }
35 35
 } else {
36 36
     \MySociety\TheyWorkForYou\Renderer::output('login/facebook', $data);
37 37
 }
Please login to merge, or discard this patch.
www/docs/user/login/index.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -19,14 +19,14 @@  discard block
 block discarded – undo
19 19
 if (get_http_var("submitted") == "true") {
20 20
     // Form has been submitted, so check input.
21 21
 
22
-    $email 		= get_http_var("email");
22
+    $email = get_http_var("email");
23 23
     $password 	= get_http_var("password");
24 24
     $remember 	= get_http_var("remember");
25 25
 
26 26
     // The user may have tried to do something that requires being logged in.
27 27
     // In which case we should arrive here with that page's URL in 'ret'.
28 28
     // We can then send the user there after log in.
29
-    $returnurl 	= get_http_var("ret");
29
+    $returnurl = get_http_var("ret");
30 30
 
31 31
     $errors = array();
32 32
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
             if ($remember == "true") {
54 54
                 $expire = "never";
55 55
             } else {
56
-                $expire ="session";
56
+                $expire = "session";
57 57
             }
58 58
 
59 59
             // $returnurl is the url of where we'll send the user after login.
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 }
97 97
 
98 98
 
99
-function display_page( $errors=array() ) {
99
+function display_page($errors = array()) {
100 100
     global $PAGE, $this_page, $THEUSER;
101 101
 
102 102
     $PAGE->page_start();
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
     <?php
128 128
 
129 129
         $PAGE->stripe_end(array(
130
-            array (
130
+            array(
131 131
                 'type' => 'include',
132 132
                 'content' => 'userlogin'
133 133
             )
Please login to merge, or discard this patch.
classes/Memcache.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -26,9 +26,9 @@  discard block
 block discarded – undo
26 26
 
27 27
     public function set($key, $value, $timeout = 3600) {
28 28
         if (class_exists('\Memcached')) {
29
-            self::$memcache->set(OPTION_TWFY_DB_NAME.':'.$key, $value, $timeout);
29
+            self::$memcache->set(OPTION_TWFY_DB_NAME . ':' . $key, $value, $timeout);
30 30
         } else {
31
-            self::$memcache->set(OPTION_TWFY_DB_NAME.':'.$key, $value, MEMCACHE_COMPRESSED, $timeout);
31
+            self::$memcache->set(OPTION_TWFY_DB_NAME . ':' . $key, $value, MEMCACHE_COMPRESSED, $timeout);
32 32
         }
33 33
     }
34 34
 
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
         // see http://php.net/manual/en/memcache.get.php#112056 for explanation of this
37 37
         $was_found = false;
38 38
         if (class_exists('\Memcached')) {
39
-            $value = self::$memcache->get(OPTION_TWFY_DB_NAME.':'.$key, null, $was_found);
39
+            $value = self::$memcache->get(OPTION_TWFY_DB_NAME . ':' . $key, null, $was_found);
40 40
         } else {
41
-            $value = self::$memcache->get(OPTION_TWFY_DB_NAME.':'.$key, $was_found);
41
+            $value = self::$memcache->get(OPTION_TWFY_DB_NAME . ':' . $key, $was_found);
42 42
         }
43 43
         if ($was_found === false) {
44 44
             return false; // mmmmm
Please login to merge, or discard this patch.
classes/Search.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
         $this->searchstring = $argparser->construct_search_string();
20 20
         $this->searchkeyword = $argparser->searchkeyword;
21 21
 
22
-        if ( !$this->searchstring ) {
22
+        if (!$this->searchstring) {
23 23
             $data = $this->get_form_params($data);
24 24
             $data['searchstring'] = '';
25 25
             $data['template'] = 'search/results';
@@ -28,14 +28,14 @@  discard block
 block discarded – undo
28 28
 
29 29
         $this->searchstring = filter_user_input($this->searchstring, 'strict');
30 30
         $warnings = $this->validate_search_string();
31
-        if ( $warnings ) {
31
+        if ($warnings) {
32 32
             $data['warnings'] = $warnings;
33 33
             $data['template'] = 'search/results';
34 34
             $data['searchstring'] = $this->searchstring;
35 35
             $data = $this->get_form_params($data);
36 36
             return $data;
37 37
         } else {
38
-            if (get_http_var('o')=='p') {
38
+            if (get_http_var('o') == 'p') {
39 39
                 $search = new Search\ByUsage();
40 40
                 $data = $search->search($this->searchstring);
41 41
                 $data['template'] = 'search/by-person';
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
             $data['person_name'] = $MEMBER->full_name();
53 53
         }
54 54
 
55
-        if ( isset($data['info']['spelling_correction']) ) {
55
+        if (isset($data['info']['spelling_correction'])) {
56 56
             $data['info']['spelling_correction_display'] = $this->prettifySearchString($data['info']['spelling_correction']);
57 57
         }
58 58
 
@@ -144,15 +144,15 @@  discard block
 block discarded – undo
144 144
         $data['search_keyword'] = $this->searchkeyword;
145 145
 
146 146
         $is_adv = false;
147
-        foreach ( array('to', 'from', 'person', 'section', 'column', 'phrase', 'exclude' ) as $var ) {
147
+        foreach (array('to', 'from', 'person', 'section', 'column', 'phrase', 'exclude') as $var) {
148 148
             $key = "search_$var";
149
-            $data[$key] = get_http_var( $var );
150
-            if ( $data[$key] ) {
149
+            $data[$key] = get_http_var($var);
150
+            if ($data[$key]) {
151 151
                 $is_adv = true;
152 152
             }
153 153
         }
154 154
 
155
-        if ( isset($data['search_section']) ) {
155
+        if (isset($data['search_section'])) {
156 156
             $data['search_section_pretty'] = $this->prettify_search_section($data['search_section']);
157 157
         }
158 158
 
@@ -162,16 +162,16 @@  discard block
 block discarded – undo
162 162
 
163 163
     private function set_wtt_options($data) {
164 164
         $data['wtt'] = '';
165
-        if ( $wtt = get_http_var('wtt') ) {
165
+        if ($wtt = get_http_var('wtt')) {
166 166
             $data['wtt'] = $wtt;
167
-            if ( $wtt == 2 && $pid = get_http_var('pid') ) {
167
+            if ($wtt == 2 && $pid = get_http_var('pid')) {
168 168
                 $data['pid'] = null;
169 169
                 try {
170 170
                     $lord = new Member(array('person_id' => $pid, 'house' => 2));
171
-                } catch ( MemberException $e ) {
171
+                } catch (MemberException $e) {
172 172
                     return $data;
173 173
                 }
174
-                if ( $lord->valid ) {
174
+                if ($lord->valid) {
175 175
                     $data['pid'] = $pid;
176 176
                     $data['wtt_lord_name'] = $lord->full_name();
177 177
                 }
@@ -196,11 +196,11 @@  discard block
 block discarded – undo
196 196
             $url->insert(array('q' => $value));
197 197
         }
198 198
 
199
-        if ( $params ) {
200
-            if ( get_http_var('house') ) {
199
+        if ($params) {
200
+            if (get_http_var('house')) {
201 201
                 $url->insert(array('house' => get_http_var('house')));
202 202
             }
203
-            if ( get_http_var('wtt') ) {
203
+            if (get_http_var('wtt')) {
204 204
                 $url->insert(array('wtt' => get_http_var('wtt')));
205 205
             }
206 206
         } else {
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
         global $DATA, $this_page;
215 215
 
216 216
         $pagetitle = '';
217
-        if ( isset($data['search_type']) && $data['search_type'] == 'person' ) {
217
+        if (isset($data['search_type']) && $data['search_type'] == 'person') {
218 218
             if (isset($data['wtt']) && $data['wtt'] > 0) {
219 219
                 $pagetitle = 'League table of Lords who say ' . $data['pagetitle'];
220 220
             } else {
Please login to merge, or discard this patch.
classes/Utility/Video.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
 {
13 13
 
14 14
     public static function dbConnect() {
15
-        $connstr = 'host='.OPTION_BBC_DB_HOST.' port='.OPTION_BBC_DB_PORT.' dbname='.OPTION_BBC_DB_NAME.' user='.OPTION_BBC_DB_USER.' password='.OPTION_BBC_DB_PASS;
15
+        $connstr = 'host=' . OPTION_BBC_DB_HOST . ' port=' . OPTION_BBC_DB_PORT . ' dbname=' . OPTION_BBC_DB_NAME . ' user=' . OPTION_BBC_DB_USER . ' password=' . OPTION_BBC_DB_PASS;
16 16
         $videodb = pg_connect($connstr);
17 17
 
18 18
         return $videodb;
Please login to merge, or discard this patch.
tests/MemberTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
      */
12 12
     public function getDataSet()
13 13
     {
14
-        return $this->createMySQLXMLDataSet(dirname(__FILE__).'/_fixtures/member.xml');
14
+        return $this->createMySQLXMLDataSet(dirname(__FILE__) . '/_fixtures/member.xml');
15 15
     }
16 16
 
17 17
     /**
Please login to merge, or discard this patch.
tests/TopicsTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
      */
12 12
     public function getDataSet()
13 13
     {
14
-        return $this->createMySQLXMLDataSet(dirname(__FILE__).'/_fixtures/topics.xml');
14
+        return $this->createMySQLXMLDataSet(dirname(__FILE__) . '/_fixtures/topics.xml');
15 15
     }
16 16
 
17 17
     private function fetch_topics_page($vars)
Please login to merge, or discard this patch.