Failed Conditions
Pull Request — master (#1324)
by Nick
34:37 queued 19:37
created
www/docs/freeourbills/sharethis.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 ";
39 39
     $subject = "Help make the laws we have to obey better! - TheyWorkForYou.com";
40 40
 
41
-    print '<a href="mailto:?subject=' . rawurlencode($subject) . '&body='. rawurlencode($email) . '">Click here to open a new email and invite your friends, family and colleagues to get involved.</a>';
41
+    print '<a href="mailto:?subject=' . rawurlencode($subject) . '&body=' . rawurlencode($email) . '">Click here to open a new email and invite your friends, family and colleagues to get involved.</a>';
42 42
 }
43 43
 
44 44
 function freeourbills_share_page() {
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
     print '<p><a href="/freeourbills/doshare"';
59 59
     #print 'onclick="share(this); return false;"';
60 60
     print ' title="' .
61
-        _('E-mail this, post to del.icio.us, etc.'). '" class="share_link" rel="nofollow">'.
62
-        _('Share this'). '</a></p>';
61
+        _('E-mail this, post to del.icio.us, etc.') . '" class="share_link" rel="nofollow">' .
62
+        _('Share this') . '</a></p>';
63 63
     #freeourbills_share_form();
64 64
 }
Please login to merge, or discard this patch.
www/docs/index-election.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 $HANSARDURL = new URL('hansard');
73 73
 $MPURL = new URL('yourmp');
74 74
 
75
-$PAGE->block_start(array ('id'=>'intro', 'title'=>'Election special! Find out how they performed for YOU:'));
75
+$PAGE->block_start(array('id'=>'intro', 'title'=>'Election special! Find out how they performed for YOU:'));
76 76
 ?>
77 77
                         <ol>
78 78
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
     } else {
90 90
         $CHANGEURL = new URL('userchangepc');
91 91
     }
92
-    $MEMBER = new MEMBER(array ('postcode'=>$THEUSER->postcode(), 'house'=>1));
92
+    $MEMBER = new MEMBER(array('postcode'=>$THEUSER->postcode(), 'house'=>1));
93 93
     $mpname = $MEMBER->full_name();
94 94
     ?>
95 95
       <p><a href="<?php echo $MPURL->generate(); ?>"><strong>Find out more about how <?php echo $mpname; ?>, your ex-MP, represented you over the last parliament</strong></a><br>
@@ -185,11 +185,11 @@  discard block
 block discarded – undo
185 185
 //$PAGE->block_end();
186 186
 
187 187
 $PAGE->stripe_end(array(
188
-    array (
188
+    array(
189 189
         'type' => 'include',
190 190
         'content' => 'whatisthissite'
191 191
     ),
192
-    array (
192
+    array(
193 193
         'type' => 'include',
194 194
         'content' => 'sitenews_recent'
195 195
     )
Please login to merge, or discard this patch.
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -43,17 +43,20 @@  discard block
 block discarded – undo
43 43
         if ($todaystime - $debatesdata['timestamp'] == 86400) {
44 44
             $daytext = "yesterday's";
45 45
 
46
-        } elseif ($todaystime - $debatesdata['timestamp'] <= (6 * 86400)) {
46
+        }
47
+        elseif ($todaystime - $debatesdata['timestamp'] <= (6 * 86400)) {
47 48
             // Less than a week ago, so like "last Tuesday's".
48 49
             $daytext = gmdate('l', $debatesdata['timestamp']) . "'s";
49 50
 
50
-        } else {
51
+        }
52
+        else {
51 53
 
52 54
             // Over a week ago.
53 55
             $daytext = "the most recent ";
54 56
         }
55 57
 
56
-    } else {
58
+    }
59
+    else {
57 60
         // Debates and Wrans are from different dates. We'll just do this for now:
58 61
         $daytext = "the most recent ";
59 62
     }
@@ -61,7 +64,8 @@  discard block
 block discarded – undo
61 64
 #	$hansardline = "Comment on $daytext <ul><li>$debatestext</li><li>$wranstext</li><li>$whalltext</li><li>$wmstext</li></ul>";
62 65
     $hansardline = "Comment on $daytext $debatestext, $wranstext, $whalltext, and $wmstext";
63 66
 
64
-} else {
67
+}
68
+else {
65 69
     // We didn't get some or all of the data, so just...
66 70
     $hansardline = "Comment on events in parliament";
67 71
 }
@@ -86,7 +90,8 @@  discard block
 block discarded – undo
86 90
 
87 91
     if ($THEUSER->isloggedin()) {
88 92
         $CHANGEURL = new URL('useredit');
89
-    } else {
93
+    }
94
+    else {
90 95
         $CHANGEURL = new URL('userchangepc');
91 96
     }
92 97
     $MEMBER = new MEMBER(array ('postcode'=>$THEUSER->postcode(), 'house'=>1));
@@ -96,7 +101,8 @@  discard block
 block discarded – undo
96 101
                         In <?php echo strtoupper(_htmlentities($THEUSER->postcode())); ?> (<a href="<?php echo $CHANGEURL->generate(); ?>">Change your postcode</a>)</p>
97 102
 <?php
98 103
 
99
-} else {
104
+}
105
+else {
100 106
     // User is not logged in and doesn't have a personal postcode set.
101 107
     ?>
102 108
                         <form action="<?php echo $MPURL->generate(); ?>" method="get">
Please login to merge, or discard this patch.
www/docs/user/password/index.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@
 block discarded – undo
90 90
 
91 91
 
92 92
 
93
-function display_page ($errors=array()) {
93
+function display_page($errors = array()) {
94 94
     global $this_page, $PAGE;
95 95
 
96 96
     if (isset($errors["sending"])) {
Please login to merge, or discard this patch.
Braces   +14 added lines, -7 removed lines patch added patch discarded remove patch
@@ -31,9 +31,11 @@  discard block
 block discarded – undo
31 31
 
32 32
     if ($email == "") {
33 33
         $errors["email"] = "Please enter your email address";
34
-    } elseif (!validate_email($email)) {
34
+    }
35
+    elseif (!validate_email($email)) {
35 36
         $errors["email"] = "Please enter a valid email address";
36
-    } else {
37
+    }
38
+    else {
37 39
 
38 40
         $USER = new USER;
39 41
         $emailexists = $USER->email_exists($email);
@@ -47,7 +49,8 @@  discard block
 block discarded – undo
47 49
         // Validation errors. Print form again.
48 50
         display_page($errors);
49 51
 
50
-    } else {
52
+    }
53
+    else {
51 54
 
52 55
         // Change the user's password!
53 56
 
@@ -63,7 +66,8 @@  discard block
 block discarded – undo
63 66
 
64 67
                 print "<p>A new password has been sent to " . _htmlentities($email) . "</p>\n";
65 68
 
66
-            } else {
69
+            }
70
+            else {
67 71
 
68 72
                 $errors["sending"] = "Sorry, there was a technical problem sending the email.";
69 73
 
@@ -71,7 +75,8 @@  discard block
 block discarded – undo
71 75
 
72 76
             }
73 77
 
74
-        } else {
78
+        }
79
+        else {
75 80
             // This email address isn't in the DB.
76 81
 
77 82
             $errors["passwordchange"] = "Sorry, there was a problem and we couldn't set a new password for " . _htmlentities($email);
@@ -83,7 +88,8 @@  discard block
 block discarded – undo
83 88
 
84 89
     }
85 90
 
86
-} else {
91
+}
92
+else {
87 93
 
88 94
     display_page();
89 95
 }
@@ -95,7 +101,8 @@  discard block
 block discarded – undo
95 101
 
96 102
     if (isset($errors["sending"])) {
97 103
         $PAGE->error_message($errors["sending"]);
98
-    } else {
104
+    }
105
+    else {
99 106
         print "<p>If you can't remember your password we can send you a new one.</p>\n<p>If you would like a new password, enter your address below.</p>\n";
100 107
     }
101 108
 ?>
Please login to merge, or discard this patch.
www/docs/user/confirm/index.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
         }
69 69
 
70 70
         $PAGE->stripe_end(array(
71
-            array (
71
+            array(
72 72
                 'type'		=> 'include',
73 73
                 'content'	=> 'userconfirmed'
74 74
             )
@@ -80,10 +80,10 @@  discard block
 block discarded – undo
80 80
     // The user's first visit to this page, and they have a registration token.
81 81
     // So let's confirm them and hope they get logged in...
82 82
 
83
-    if (get_http_var('c') == 'email' ) {
84
-        $success = $THEUSER->confirm_email( get_http_var('t') );
83
+    if (get_http_var('c') == 'email') {
84
+        $success = $THEUSER->confirm_email(get_http_var('t'));
85 85
     } else {
86
-        $success = $THEUSER->confirm( get_http_var('t') );
86
+        $success = $THEUSER->confirm(get_http_var('t'));
87 87
     }
88 88
 
89 89
     if (!$success) {
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 
103 103
     $this_page = 'userconfirmfailed';
104 104
 
105
-    if ( !$PAGE->page_started() ) {
105
+    if (!$PAGE->page_started()) {
106 106
         $PAGE->page_start();
107 107
 
108 108
         $PAGE->stripe_start();
Please login to merge, or discard this patch.
Braces   +14 added lines, -7 removed lines patch added patch discarded remove patch
@@ -36,7 +36,8 @@  discard block
 block discarded – undo
36 36
     <p>Do <a href="mailto:<?php echo str_replace('@', '&#64;', CONTACTEMAIL); ?>">let us know</a> if you find a bug, or have a suggestion.</p>
37 37
 
38 38
 <?php
39
-        } else {
39
+        }
40
+        else {
40 41
             // Oops, something must have gone wrong when the user was logged in.
41 42
             // It shouldn't do, but...
42 43
             $PAGE->error_message("Sorry, we couldn't log you in - TheyWorkForYou requires cookies to keep
@@ -46,7 +47,8 @@  discard block
 block discarded – undo
46 47
         $PAGE->page_end();
47 48
 
48 49
 
49
-} elseif (get_http_var('email') == 't') {
50
+}
51
+elseif (get_http_var('email') == 't') {
50 52
         $this_page = 'emailconfirmed';
51 53
 
52 54
         $PAGE->page_start();
@@ -60,7 +62,8 @@  discard block
 block discarded – undo
60 62
     <p>Do <a href="mailto:<?php echo str_replace('@', '&#64;', CONTACTEMAIL); ?>">let us know</a> if you find a bug, or have a suggestion.</p>
61 63
 
62 64
 <?php
63
-        } else {
65
+        }
66
+        else {
64 67
             // Oops, something must have gone wrong when the user was logged in.
65 68
             // It shouldn't do, but...
66 69
             $PAGE->error_message("Sorry, we couldn't log you in - TheyWorkForYou requires cookies to keep
@@ -76,20 +79,23 @@  discard block
 block discarded – undo
76 79
 
77 80
         $PAGE->page_end();
78 81
 
79
-} elseif (get_http_var('t') != '') {
82
+}
83
+elseif (get_http_var('t') != '') {
80 84
     // The user's first visit to this page, and they have a registration token.
81 85
     // So let's confirm them and hope they get logged in...
82 86
 
83 87
     if (get_http_var('c') == 'email' ) {
84 88
         $success = $THEUSER->confirm_email( get_http_var('t') );
85
-    } else {
89
+    }
90
+    else {
86 91
         $success = $THEUSER->confirm( get_http_var('t') );
87 92
     }
88 93
 
89 94
     if (!$success) {
90 95
         confirm_error();
91 96
     }
92
-} else {
97
+}
98
+else {
93 99
     // We have no registration token, and no notification of welcome...
94 100
 
95 101
     confirm_error();
@@ -112,7 +118,8 @@  discard block
 block discarded – undo
112 118
     <p>The link you followed to reach this page appears to be incomplete.</p>
113 119
 
114 120
 <?php
115
-    } else {
121
+    }
122
+    else {
116 123
         $PAGE->stripe_start();
117 124
     }
118 125
 ?>
Please login to merge, or discard this patch.
www/docs/user/prompt/index.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
 $anchor = '#addcomment';
21 21
 
22 22
 $URL = new URL('userjoin');
23
-$URL->insert(array('ret'=>$returl.$anchor));
23
+$URL->insert(array('ret'=>$returl . $anchor));
24 24
 $joinurl = $URL->generate();
25 25
 
26 26
 
Please login to merge, or discard this patch.
www/docs/404.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
32 32
 <?php
33 33
 
34 34
 $includes = array(
35
-    array (
35
+    array(
36 36
         'type' => 'include',
37 37
         'content' => 'whatisthissite'
38 38
     ),
Please login to merge, or discard this patch.
www/docs/random/index.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
 $q = $db->query("select gid from hansard where htype in (10,11) and major=1 and hdate='$date' order by rand() limit 1");
15 15
 $gid = $q->field(0, 'gid');
16 16
 
17
-$args = array (
17
+$args = array(
18 18
     'gid' => fix_gid_from_db($gid),
19 19
     'sort' => 'regexp_replace',
20 20
 );
Please login to merge, or discard this patch.
www/docs/email/index.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -45,15 +45,15 @@  discard block
 block discarded – undo
45 45
 <?php
46 46
 } else {
47 47
     $rep_name = $MEMBER->full_name();
48
-    if ($MEMBER->house_disp==1) $rep_name .= ' MP';
49
-    elseif ($MEMBER->house_disp==3) $rep_name .= ' MLA';
50
-    $data = array (
48
+    if ($MEMBER->house_disp == 1) $rep_name .= ' MP';
49
+    elseif ($MEMBER->house_disp == 3) $rep_name .= ' MLA';
50
+    $data = array(
51 51
         'template'      => 'email_a_friend',
52 52
         'to'            => $recipient_email,
53 53
         'subject'       => 'Find out all about ' . $rep_name
54 54
     );
55 55
     $url = $MEMBER->url(true);
56
-    $merge = array (
56
+    $merge = array(
57 57
         'NAME' => $sender_name,
58 58
         'EMAIL' => $sender_email,
59 59
         'REP_NAME' => $rep_name,
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 
63 63
     $success = send_template_email($data, $merge);
64 64
     if ($success) {
65
-        print "<p>Your email has been sent successfully. Thank you for using TheyWorkForYou.</p> <p><a href=\"$url\">Return to ".$MEMBER->full_name()."'s page</a></p>";
65
+        print "<p>Your email has been sent successfully. Thank you for using TheyWorkForYou.</p> <p><a href=\"$url\">Return to " . $MEMBER->full_name() . "'s page</a></p>";
66 66
     } else {
67 67
         print "<p>Sorry, something went wrong trying to send an email. Please wait a few minutes and try again.</p>";
68 68
     }
Please login to merge, or discard this patch.
Braces   +20 added lines, -9 removed lines patch added patch discarded remove patch
@@ -14,20 +14,25 @@  discard block
 block discarded – undo
14 14
 $sender_email = get_http_var('sender_mail');
15 15
 $sender_name = get_http_var('sender_name');
16 16
 $pid = intval(get_http_var('pid'));
17
-if ($pid)
17
+if ($pid) {
18 18
     $MEMBER = new MEMBER(array('person_id' => $pid));
19
+}
19 20
 
20 21
 //validate them
21 22
 $errors = array();
22 23
 
23
-if (!$pid)
24
+if (!$pid) {
24 25
     $errors[] = 'You did not get to this page from an MP or Peer page. Please go back and try again.';
25
-if (!preg_match('#^[^@]+@#', $recipient_email))
26
+}
27
+if (!preg_match('#^[^@]+@#', $recipient_email)) {
26 28
     $errors[] = "'$recipient_email' is not a valid recipient email address. Please have another go.";
27
-if (!validate_email($sender_email))
29
+}
30
+if (!validate_email($sender_email)) {
28 31
     $errors[] = "'$sender_email' is not a valid sender email address. Please have another go.";
29
-if (!$sender_name)
32
+}
33
+if (!$sender_name) {
30 34
     $errors[] = "If you don't give us your name, we can't tell the recipient who sent them the link. We won't store it or use for any other purpose than sending this email.";
35
+}
31 36
 
32 37
 if (sizeof($errors)) {
33 38
     print '<p>Please correct the following errors:</p>';
@@ -43,10 +48,15 @@  discard block
 block discarded – undo
43 48
 <input type="submit" class="submit" value="Send"></p>
44 49
 </form>
45 50
 <?php
46
-} else {
51
+}
52
+else {
47 53
     $rep_name = $MEMBER->full_name();
48
-    if ($MEMBER->house_disp==1) $rep_name .= ' MP';
49
-    elseif ($MEMBER->house_disp==3) $rep_name .= ' MLA';
54
+    if ($MEMBER->house_disp==1) {
55
+        $rep_name .= ' MP';
56
+    }
57
+    elseif ($MEMBER->house_disp==3) {
58
+        $rep_name .= ' MLA';
59
+    }
50 60
     $data = array (
51 61
         'template'      => 'email_a_friend',
52 62
         'to'            => $recipient_email,
@@ -63,7 +73,8 @@  discard block
 block discarded – undo
63 73
     $success = send_template_email($data, $merge);
64 74
     if ($success) {
65 75
         print "<p>Your email has been sent successfully. Thank you for using TheyWorkForYou.</p> <p><a href=\"$url\">Return to ".$MEMBER->full_name()."'s page</a></p>";
66
-    } else {
76
+    }
77
+    else {
67 78
         print "<p>Sorry, something went wrong trying to send an email. Please wait a few minutes and try again.</p>";
68 79
     }
69 80
 }
Please login to merge, or discard this patch.
www/docs/vote/index.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
         voteerror("Your browser must be able to accept cookies before you can register a vote.");
32 32
     } else {
33 33
         // Delete the test cookie.
34
-        setcookie ('testcookie', '');
34
+        setcookie('testcookie', '');
35 35
     }
36 36
     // On with the voting...!
37 37
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     // We need to check the user can accept cookies, so...
41 41
 
42 42
     // Set a cookie
43
-    setcookie ('testcookie', 'true');
43
+    setcookie('testcookie', 'true');
44 44
 
45 45
     $ret = get_http_var('ret');
46 46
     $id = get_http_var('id');
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 
68 68
     $PAGE->page_start();
69 69
 
70
-    $message = array (
70
+    $message = array(
71 71
         'title'	=> 'Sorry',
72 72
         'text'	=> $text
73 73
     );
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
         $prev_epvotes[] = $epobject_id;
159 159
         $new_cookie = implode('+', $prev_epvotes);
160 160
 
161
-        setcookie ("epvotes", $new_cookie, time()+60*60*24*365, "/", COOKIEDOMAIN);
161
+        setcookie("epvotes", $new_cookie, time() + 60 * 60 * 24 * 365, "/", COOKIEDOMAIN);
162 162
 
163 163
 
164 164
     } else {
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 
190 190
 $PAGE->page_start();
191 191
 
192
-$message = array (
192
+$message = array(
193 193
     'title'	=> "Thanks for your vote",
194 194
     'text'	=> "<strong>Would you like to ask a question like this yourself?</strong> Use our <a href=\"http://www.whatdotheyknow.com\">Freedom of Information site</a>."
195 195
 );
Please login to merge, or discard this patch.
Braces   +18 added lines, -9 removed lines patch added patch discarded remove patch
@@ -29,14 +29,16 @@  discard block
 block discarded – undo
29 29
 
30 30
     if ($testcookie != true) {
31 31
         voteerror("Your browser must be able to accept cookies before you can register a vote.");
32
-    } else {
32
+    }
33
+    else {
33 34
         // Delete the test cookie.
34 35
         setcookie ('testcookie', '');
35 36
     }
36 37
     // On with the voting...!
37 38
 
38 39
 
39
-} else {
40
+}
41
+else {
40 42
     // We need to check the user can accept cookies, so...
41 43
 
42 44
     // Set a cookie
@@ -121,7 +123,8 @@  discard block
 block discarded – undo
121 123
             // We're not checking the validity of the contents of $votecookie,
122 124
             // just doing it.
123 125
             $prev_epvotes = explode('+', $votecookie);
124
-        } else {
126
+        }
127
+        else {
125 128
             $prev_epvotes = array();
126 129
         }
127 130
 
@@ -135,13 +138,16 @@  discard block
 block discarded – undo
135 138
         if ($q->rows() == 1) {
136 139
             if ($vote == 1) {
137 140
                 $q = $db->query("UPDATE anonvotes SET yes_votes = yes_votes + 1 WHERE epobject_id=:epobject_id", array(':epobject_id' => $epobject_id));
138
-            } else {
141
+            }
142
+            else {
139 143
                 $q = $db->query("UPDATE anonvotes SET no_votes = no_votes + 1 WHERE epobject_id=:epobject_id", array(':epobject_id' => $epobject_id));
140 144
             }
141
-        } else {
145
+        }
146
+        else {
142 147
             if ($vote == 1) {
143 148
                 $q = $db->query("INSERT INTO anonvotes (epobject_id, yes_votes) VALUES (:epobject_id, '1')", array(':epobject_id' => $epobject_id));
144
-            } else {
149
+            }
150
+            else {
145 151
                 $q = $db->query("INSERT INTO anonvotes (epobject_id, no_votes) VALUES (:epobject_id, '1')", array(':epobject_id' => $epobject_id));
146 152
             }
147 153
         }
@@ -161,7 +167,8 @@  discard block
 block discarded – undo
161 167
         setcookie ("epvotes", $new_cookie, time()+60*60*24*365, "/", COOKIEDOMAIN);
162 168
 
163 169
 
164
-    } else {
170
+    }
171
+    else {
165 172
         // User is logged in.
166 173
 
167 174
         // See if the user's already voted for this.
@@ -172,7 +179,8 @@  discard block
 block discarded – undo
172 179
 
173 180
         if ($q->rows() == 1) {
174 181
             voteerror("You have already rated this item. You can only rate something once.");
175
-        } else {
182
+        }
183
+        else {
176 184
             // Add the vote.
177 185
             $q = $db->query("INSERT INTO uservotes (user_id, epobject_id, vote) VALUES (:user_id, :epobject_id, :vote)", array(':user_id' => $THEUSER->user_id(), ':vote' => $vote, ':epobject_id' => $epobject_id));
178 186
             if (!$q->success()) {
@@ -181,7 +189,8 @@  discard block
 block discarded – undo
181 189
         }
182 190
     }
183 191
 
184
-} else {
192
+}
193
+else {
185 194
     voteerror("We weren't able to register your vote");
186 195
 }
187 196
 
Please login to merge, or discard this patch.