Passed
Pull Request — master (#1700)
by Struan
04:10
created
scripts/alertgonemps.php 4 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -139,7 +139,7 @@
 block discarded – undo
139 139
 	global $globalsuccess, $sentemails, $nomail, $start_time;
140 140
 
141 141
 	$sentemails++;
142
-	mlog("SEND $sentemails : Sending email to $current[email] ... ");
142
+	mlog("send $sentemails : Sending email to $current[email] ... ");
143 143
 	$d = array('to' => $current['email'], 'template' => $template);
144 144
 	$m = array(
145 145
 		'DATA' => join("\n", $data),
Please login to merge, or discard this patch.
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -23,23 +23,23 @@  discard block
 block discarded – undo
23 23
 $toemail = '';
24 24
 $template = 'alert_gone';
25 25
 for ($k=1; $k<$argc; $k++) {
26
-	if ($argv[$k] == '--nomail') {
27
-		$nomail = true;
28
-	}
29
-	if (preg_match('#^--only=(.*)$#', $argv[$k], $m)) {
30
-		$onlyemail = $m[1];
31
-	}
32
-	if (preg_match('#^--from=(.*)$#', $argv[$k], $m)) {
33
-		$fromemail = $m[1];
34
-	}
35
-	if (preg_match('#^--to=(.*)$#', $argv[$k], $m)) {
36
-		$toemail = $m[1];
37
-	}
38
-	if (preg_match('#^--template=(.*)$#', $argv[$k], $m)) {
39
-		$template = $m[1];
40
-		# Tee hee
41
-		$template = "../../../../../../../../../../home/twfy-live/email-alert-templates/alert_mailout_$template";
42
-	}
26
+    if ($argv[$k] == '--nomail') {
27
+        $nomail = true;
28
+    }
29
+    if (preg_match('#^--only=(.*)$#', $argv[$k], $m)) {
30
+        $onlyemail = $m[1];
31
+    }
32
+    if (preg_match('#^--from=(.*)$#', $argv[$k], $m)) {
33
+        $fromemail = $m[1];
34
+    }
35
+    if (preg_match('#^--to=(.*)$#', $argv[$k], $m)) {
36
+        $toemail = $m[1];
37
+    }
38
+    if (preg_match('#^--template=(.*)$#', $argv[$k], $m)) {
39
+        $template = $m[1];
40
+        # Tee hee
41
+        $template = "../../../../../../../../../../home/twfy-live/email-alert-templates/alert_mailout_$template";
42
+    }
43 43
 }
44 44
 
45 45
 #if (DEVSITE)
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
     mlog("NOT SENDING EMAIL\n");
50 50
 }
51 51
 if (($fromemail && $onlyemail) || ($toemail && $onlyemail)) {
52
-	mlog("Can't have both from/to and only!\n");
53
-	exit;
52
+    mlog("Can't have both from/to and only!\n");
53
+    exit;
54 54
 }
55 55
 
56 56
 $active = 0;
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
 $members = array();
75 75
 $start_time = time();
76 76
 foreach ($alertdata as $alertitem) {
77
-	$active++;
78
-	$email = $alertitem['email'];
77
+    $active++;
78
+    $email = $alertitem['email'];
79 79
     if ($onlyemail && $email != $onlyemail) {
80 80
         continue;
81 81
     }
@@ -90,39 +90,39 @@  discard block
 block discarded – undo
90 90
     }
91 91
     $criteria_raw = $alertitem['criteria'];
92 92
 
93
-	if (!strstr($criteria_raw, 'speaker:')) {
94
-	    continue;
95
-	}
93
+    if (!strstr($criteria_raw, 'speaker:')) {
94
+        continue;
95
+    }
96 96
 
97
-	preg_match('#speaker:(\d+)#', $criteria_raw, $m);
98
-	$person_id = $m[1];
99
-	if (!isset($members[$person_id])) {
97
+    preg_match('#speaker:(\d+)#', $criteria_raw, $m);
98
+    $person_id = $m[1];
99
+    if (!isset($members[$person_id])) {
100 100
         $queries++;
101 101
         $members[$person_id] = new MEMBER(array('person_id' => $person_id));
102
-	}
102
+    }
103 103
     $member = $members[$person_id];
104 104
     if ($member->current_member_anywhere()) {
105 105
         continue;
106 106
     }
107 107
 
108
-	if ($email != $current['email']) {
109
-		if ($email_text) {
110
-		    write_and_send_email($current, $email_text, $template);
111
-		}
112
-		$current['email'] = $email;
113
-		$current['token'] = $alertitem['alert_id'] . '-' . $alertitem['registrationtoken'];
114
-		$email_text = array();
115
-		$q = $db->query('SELECT user_id FROM users WHERE email = :email', array(
108
+    if ($email != $current['email']) {
109
+        if ($email_text) {
110
+            write_and_send_email($current, $email_text, $template);
111
+        }
112
+        $current['email'] = $email;
113
+        $current['token'] = $alertitem['alert_id'] . '-' . $alertitem['registrationtoken'];
114
+        $email_text = array();
115
+        $q = $db->query('SELECT user_id FROM users WHERE email = :email', array(
116 116
             ':email' => $email))->first();
117 117
         if ($q) {
118 118
             $user_id = $q['user_id'];
119 119
             $registered++;
120
-		} else {
121
-			$user_id = 0;
122
-			$unregistered++;
123
-		}	
124
-		mlog("\nEMAIL: $email, uid $user_id; memory usage : ".memory_get_usage()."\n");
125
-	}
120
+        } else {
121
+            $user_id = 0;
122
+            $unregistered++;
123
+        }	
124
+        mlog("\nEMAIL: $email, uid $user_id; memory usage : ".memory_get_usage()."\n");
125
+    }
126 126
 
127 127
     $lh = $member->left_house();
128 128
     $lh = array_shift($lh);
@@ -148,32 +148,32 @@  discard block
 block discarded – undo
148 148
 mlog(date('r') . "\n");
149 149
 
150 150
 function write_and_send_email($current, $data, $template) {
151
-	global $globalsuccess, $sentemails, $nomail, $start_time;
152
-
153
-	$sentemails++;
154
-	mlog("SEND $sentemails : Sending email to $current[email] ... ");
155
-	$d = array('to' => $current['email'], 'template' => $template);
156
-	$m = array(
157
-		'DATA' => join("\n", $data),
158
-		'MANAGE' => 'https://www.theyworkforyou.com/D/' . $current['token'],
151
+    global $globalsuccess, $sentemails, $nomail, $start_time;
152
+
153
+    $sentemails++;
154
+    mlog("SEND $sentemails : Sending email to $current[email] ... ");
155
+    $d = array('to' => $current['email'], 'template' => $template);
156
+    $m = array(
157
+        'DATA' => join("\n", $data),
158
+        'MANAGE' => 'https://www.theyworkforyou.com/D/' . $current['token'],
159 159
         'ALERT_IS' => count($data)==1 ? 'alert is' : 'alerts are',
160 160
         'ALERTS' => count($data)==1 ? 'an alert' : 'some alerts',
161
-	);
162
-	if (!$nomail) {
163
-		$success = send_template_email($d, $m, true);
164
-		mlog("sent ... ");
165
-		# sleep if time between sending mails is less than a certain number of seconds on average
166
-		if (((time() - $start_time) / $sentemails) < 0.5 ) { # number of seconds per mail not to be quicker than
167
-			mlog("pausing ... ");
168
-			sleep(1);
169
-		}
170
-	} else {
171
-		mlog(join('', $data));
172
-		$success = 1;
173
-	}
174
-	mlog("done\n");
175
-	if (!$success) {
176
-	    $globalsuccess = 0;
177
-	}
161
+    );
162
+    if (!$nomail) {
163
+        $success = send_template_email($d, $m, true);
164
+        mlog("sent ... ");
165
+        # sleep if time between sending mails is less than a certain number of seconds on average
166
+        if (((time() - $start_time) / $sentemails) < 0.5 ) { # number of seconds per mail not to be quicker than
167
+            mlog("pausing ... ");
168
+            sleep(1);
169
+        }
170
+    } else {
171
+        mlog(join('', $data));
172
+        $success = 1;
173
+    }
174
+    mlog("done\n");
175
+    if (!$success) {
176
+        $globalsuccess = 0;
177
+    }
178 178
 }
179 179
 
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 $fromflag = false;
23 23
 $toemail = '';
24 24
 $template = 'alert_gone';
25
-for ($k=1; $k<$argc; $k++) {
25
+for ($k = 1; $k < $argc; $k++) {
26 26
 	if ($argv[$k] == '--nomail') {
27 27
 		$nomail = true;
28 28
 	}
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 			$user_id = 0;
122 122
 			$unregistered++;
123 123
 		}	
124
-		mlog("\nEMAIL: $email, uid $user_id; memory usage : ".memory_get_usage()."\n");
124
+		mlog("\nEMAIL: $email, uid $user_id; memory usage : " . memory_get_usage() . "\n");
125 125
 	}
126 126
 
127 127
     $lh = $member->left_house();
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 } else {
144 144
     $sss .= 'Something went wrong! Total time: ';
145 145
 }
146
-$sss .= (getmicrotime()-$global_start)."\n\n";
146
+$sss .= (getmicrotime() - $global_start) . "\n\n";
147 147
 mlog($sss);
148 148
 mlog(date('r') . "\n");
149 149
 
@@ -156,14 +156,14 @@  discard block
 block discarded – undo
156 156
 	$m = array(
157 157
 		'DATA' => join("\n", $data),
158 158
 		'MANAGE' => 'https://www.theyworkforyou.com/D/' . $current['token'],
159
-        'ALERT_IS' => count($data)==1 ? 'alert is' : 'alerts are',
160
-        'ALERTS' => count($data)==1 ? 'an alert' : 'some alerts',
159
+        'ALERT_IS' => count($data) == 1 ? 'alert is' : 'alerts are',
160
+        'ALERTS' => count($data) == 1 ? 'an alert' : 'some alerts',
161 161
 	);
162 162
 	if (!$nomail) {
163 163
 		$success = send_template_email($d, $m, true);
164 164
 		mlog("sent ... ");
165 165
 		# sleep if time between sending mails is less than a certain number of seconds on average
166
-		if (((time() - $start_time) / $sentemails) < 0.5 ) { # number of seconds per mail not to be quicker than
166
+		if (((time() - $start_time) / $sentemails) < 0.5) { # number of seconds per mail not to be quicker than
167 167
 			mlog("pausing ... ");
168 168
 			sleep(1);
169 169
 		}
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -163,7 +163,8 @@
 block discarded – undo
163 163
 		$success = send_template_email($d, $m, true);
164 164
 		mlog("sent ... ");
165 165
 		# sleep if time between sending mails is less than a certain number of seconds on average
166
-		if (((time() - $start_time) / $sentemails) < 0.5 ) { # number of seconds per mail not to be quicker than
166
+		if (((time() - $start_time) / $sentemails) < 0.5 ) {
167
+# number of seconds per mail not to be quicker than
167 168
 			mlog("pausing ... ");
168 169
 			sleep(1);
169 170
 		}
Please login to merge, or discard this patch.
scripts/alertmpchanged.php 3 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -155,7 +155,7 @@
 block discarded – undo
155 155
     global $globalsuccess, $sentemails, $nomail, $start_time;
156 156
 
157 157
     $sentemails++;
158
-    mlog("SEND $sentemails : Sending email to $current[email] ... ");
158
+    mlog("send $sentemails : Sending email to $current[email] ... ");
159 159
     $d = array('to' => $current['email'], 'template' => $template);
160 160
     $m = array(
161 161
         'DATA' => join("\n", $data),
Please login to merge, or discard this patch.
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -22,18 +22,18 @@  discard block
 block discarded – undo
22 22
 $toemail = '';
23 23
 $template = 'alert_new_mp';
24 24
 for ($k=1; $k<$argc; $k++) {
25
-	if ($argv[$k] == '--nomail') {
26
-		$nomail = true;
27
-	}
28
-	if (preg_match('#^--only=(.*)$#', $argv[$k], $m)) {
29
-		$onlyemail = $m[1];
30
-	}
31
-	if (preg_match('#^--from=(.*)$#', $argv[$k], $m)) {
32
-		$fromemail = $m[1];
33
-	}
34
-	if (preg_match('#^--to=(.*)$#', $argv[$k], $m)) {
35
-		$toemail = $m[1];
36
-	}
25
+    if ($argv[$k] == '--nomail') {
26
+        $nomail = true;
27
+    }
28
+    if (preg_match('#^--only=(.*)$#', $argv[$k], $m)) {
29
+        $onlyemail = $m[1];
30
+    }
31
+    if (preg_match('#^--from=(.*)$#', $argv[$k], $m)) {
32
+        $fromemail = $m[1];
33
+    }
34
+    if (preg_match('#^--to=(.*)$#', $argv[$k], $m)) {
35
+        $toemail = $m[1];
36
+    }
37 37
 }
38 38
 
39 39
 if (DEVSITE) {
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
     mlog("NOT SENDING EMAIL\n");
48 48
 }
49 49
 if (($fromemail && $onlyemail) || ($toemail && $onlyemail)) {
50
-	mlog("Can't have both from/to and only!\n");
51
-	exit;
50
+    mlog("Can't have both from/to and only!\n");
51
+    exit;
52 52
 }
53 53
 
54 54
 $active = 0;
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
 $members = array();
74 74
 $start_time = time();
75 75
 foreach ($alertdata as $alertitem) {
76
-	$active++;
77
-	$email = $alertitem['email'];
76
+    $active++;
77
+    $email = $alertitem['email'];
78 78
     if ($onlyemail && $email != $onlyemail) {
79 79
         continue;
80 80
     }
@@ -168,9 +168,9 @@  discard block
 block discarded – undo
168 168
 
169 169
 $sss = "Active alerts: $active\nEmail lookups: $registered registered, $unregistered unregistered\nQuery lookups: $queries\nSent emails: $sentemails\n";
170 170
 if ($globalsuccess) {
171
-      $sss .= 'Everything went swimmingly, in ';
171
+        $sss .= 'Everything went swimmingly, in ';
172 172
 } else {
173
-      $sss .= 'Something went wrong! Total time: ';
173
+        $sss .= 'Something went wrong! Total time: ';
174 174
 }
175 175
 $sss .= (getmicrotime()-$global_start)."\n\n";
176 176
 mlog($sss);
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 $fromflag = false;
22 22
 $toemail = '';
23 23
 $template = 'alert_new_mp';
24
-for ($k=1; $k<$argc; $k++) {
24
+for ($k = 1; $k < $argc; $k++) {
25 25
 	if ($argv[$k] == '--nomail') {
26 26
 		$nomail = true;
27 27
 	}
@@ -112,9 +112,9 @@  discard block
 block discarded – undo
112 112
         continue;
113 113
     }
114 114
 
115
-    if ( !isset($cons[$member->constituency]) ) {
115
+    if (!isset($cons[$member->constituency])) {
116 116
         $cons_member = new MEMBER(array('constituency' => $member->constituency, 'house' => 1));
117
-        if ( !$cons_member ) {
117
+        if (!$cons_member) {
118 118
             continue;
119 119
         }
120 120
         $cons[$member->constituency] = $cons_member;
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
     }
124 124
 
125 125
     // these should never happen but let's just be sure
126
-    if ( $cons_member->person_id == $member->person_id ) {
126
+    if ($cons_member->person_id == $member->person_id) {
127 127
         continue;
128 128
     }
129 129
     if (!$cons_member->current_member_anywhere()) {
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
             $user_id = 0;
148 148
             $unregistered++;
149 149
         }
150
-        mlog("\nEMAIL: $email, uid $user_id; memory usage : ".memory_get_usage()."\n");
150
+        mlog("\nEMAIL: $email, uid $user_id; memory usage : " . memory_get_usage() . "\n");
151 151
     }
152 152
 
153 153
     $lh = $member->left_house();
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 } else {
173 173
       $sss .= 'Something went wrong! Total time: ';
174 174
 }
175
-$sss .= (getmicrotime()-$global_start)."\n\n";
175
+$sss .= (getmicrotime() - $global_start) . "\n\n";
176 176
 mlog($sss);
177 177
 mlog(date('r') . "\n");
178 178
 
@@ -185,18 +185,18 @@  discard block
 block discarded – undo
185 185
     $m = array(
186 186
         'DATA' => join("\n", $data),
187 187
         'CHANGE' => join("\n", $change),
188
-        'ALERT_IS' => count($data)==1 ? 'alert is' : 'alerts are',
189
-        'MPS' => count($data)==1 ? 'This MP' : 'These MPs',
190
-        'MPS2' => count($data)==1 ? 'MP' : 'MPs',
191
-        'ALERTS' => count($data)==1 ? 'an alert' : 'some alerts',
192
-        'ALERTS2' => count($data)==1 ? 'alert' : 'alerts',
193
-        'LINKS' => count($data)==1 ? 'link' : 'links',
188
+        'ALERT_IS' => count($data) == 1 ? 'alert is' : 'alerts are',
189
+        'MPS' => count($data) == 1 ? 'This MP' : 'These MPs',
190
+        'MPS2' => count($data) == 1 ? 'MP' : 'MPs',
191
+        'ALERTS' => count($data) == 1 ? 'an alert' : 'some alerts',
192
+        'ALERTS2' => count($data) == 1 ? 'alert' : 'alerts',
193
+        'LINKS' => count($data) == 1 ? 'link' : 'links',
194 194
     );
195 195
     if (!$nomail) {
196 196
         $success = send_template_email($d, $m, true);
197 197
         mlog("sent ... ");
198 198
         # sleep if time between sending mails is less than a certain number of seconds on average
199
-        if (((time() - $start_time) / $sentemails) < 0.5 ) {
199
+        if (((time() - $start_time) / $sentemails) < 0.5) {
200 200
             # number of seconds per mail not to be quicker than
201 201
             mlog("pausing ... ");
202 202
             sleep(1);
Please login to merge, or discard this patch.
scripts/populate-policy-images.php 2 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@
 block discarded – undo
46 46
 }
47 47
 
48 48
 $count = 0;
49
-while ( ( $policy = fgetcsv($file) ) !== FALSE ) {
49
+while ( ( $policy = fgetcsv($file) ) !== false ) {
50 50
     if ( intval($policy[0]) ) {
51 51
         $policy_id = $policy[0];
52 52
         $img_id = $policy[1] ? $policy[1] : $policy_id;
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
     exit(1);
34 34
 }
35 35
 
36
-if ( !file_exists($csvfile) ) {
36
+if (!file_exists($csvfile)) {
37 37
     print "$csvfile cannot be found\n";
38 38
     exit(1);
39 39
 }
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 }
47 47
 
48 48
 $count = 0;
49
-while ( ( $policy = fgetcsv($file) ) !== FALSE ) {
50
-    if ( intval($policy[0]) ) {
49
+while (($policy = fgetcsv($file)) !== FALSE) {
50
+    if (intval($policy[0])) {
51 51
         $policy_id = $policy[0];
52 52
         $img_id = $policy[1] ? $policy[1] : $policy_id;
53 53
         $title = $policy[2];
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
                 ':image_attribution' => $attribution,
70 70
                 ':license_url' => $licence_url)
71 71
         );
72
-        if ( $q->success() ) {
72
+        if ($q->success()) {
73 73
             $count += $q->affected_rows();
74 74
         } else {
75 75
             print "failed to update data for $policy_id\n";
Please login to merge, or discard this patch.
www/docs/alert/update-mp/index.php 1 patch
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-$new_style_template = TRUE;
3
+$new_style_template = true;
4 4
 
5 5
 include_once '../../../includes/easyparliament/init.php';
6 6
 include_once INCLUDESPATH . 'easyparliament/member.php';
Please login to merge, or discard this patch.
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   +75 added lines, -75 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,20 +994,20 @@  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;
@@ -1021,28 +1021,28 @@  discard block
 block discarded – undo
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);
@@ -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.