@@ -67,4 +67,4 @@ |
||
67 | 67 | api_output($out); |
68 | 68 | } else { |
69 | 69 | api_error('Nothing'); |
70 | - } |
|
70 | + } |
@@ -12,7 +12,7 @@ |
||
12 | 12 | |
13 | 13 | $out = array(); |
14 | 14 | if (isset ($data['rows'])) { |
15 | - for ($i=0; $i<count($data['rows']); $i++) { |
|
15 | + for ($i = 0; $i < count($data['rows']); $i++) { |
|
16 | 16 | $row = $data['rows'][$i]; |
17 | 17 | if (count($row) == 0) continue; |
18 | 18 | if ($row['htype'] == '12') { |
@@ -14,13 +14,16 @@ discard block |
||
14 | 14 | if (isset ($data['rows'])) { |
15 | 15 | for ($i=0; $i<count($data['rows']); $i++) { |
16 | 16 | $row = $data['rows'][$i]; |
17 | - if (count($row) == 0) continue; |
|
17 | + if (count($row) == 0) { |
|
18 | + continue; |
|
19 | + } |
|
18 | 20 | if ($row['htype'] == '12') { |
19 | 21 | if (isset($row['speaker']) && count($row['speaker']) > 0) { |
20 | 22 | $speaker = $row['speaker']; |
21 | 23 | if (is_file(BASEDIR . IMAGEPATH . 'mps/' . $speaker['person_id'] . '.jpeg')) { |
22 | 24 | $row['speaker']['image'] = IMAGEPATH . 'mps/' . $speaker['person_id'] . '.jpeg'; |
23 | - } elseif (is_file(BASEDIR . IMAGEPATH . 'mps/' . $speaker['person_id'] . '.jpg')) { |
|
25 | + } |
|
26 | + elseif (is_file(BASEDIR . IMAGEPATH . 'mps/' . $speaker['person_id'] . '.jpg')) { |
|
24 | 27 | $row['speaker']['image'] = IMAGEPATH . 'mps/' . $speaker['person_id'] . '.jpg'; |
25 | 28 | } |
26 | 29 | $desc = ''; |
@@ -36,7 +39,9 @@ discard block |
||
36 | 39 | $desc .= $speaker['constituency'] . ', '; |
37 | 40 | } |
38 | 41 | $desc .= _htmlentities($speaker['party']); |
39 | - if ($desc) $row['speaker']['desc'] = $desc; |
|
42 | + if ($desc) { |
|
43 | + $row['speaker']['desc'] = $desc; |
|
44 | + } |
|
40 | 45 | } |
41 | 46 | } |
42 | 47 | $out[] = $row; |
@@ -46,16 +51,20 @@ discard block |
||
46 | 51 | foreach ($data['subrows'] as $row) { |
47 | 52 | if (isset($row['contentcount']) && $row['contentcount'] > 0) { |
48 | 53 | $has_content = true; |
49 | - } elseif ($row['htype'] == '11' && $hansardmajors[$row['major']]['type'] == 'other') { |
|
54 | + } |
|
55 | + elseif ($row['htype'] == '11' && $hansardmajors[$row['major']]['type'] == 'other') { |
|
50 | 56 | $has_content = true; |
51 | - } else { |
|
57 | + } |
|
58 | + else { |
|
52 | 59 | $has_content = false; |
53 | 60 | } |
54 | 61 | $entry = $row; |
55 | - if (isset($row['excerpt'])) |
|
56 | - $entry['excerpt'] = trim_characters($entry['excerpt'], 0, 200); |
|
62 | + if (isset($row['excerpt'])) { |
|
63 | + $entry['excerpt'] = trim_characters($entry['excerpt'], 0, 200); |
|
64 | + } |
|
57 | 65 | if ($has_content) { |
58 | - } else { |
|
66 | + } |
|
67 | + else { |
|
59 | 68 | unset($entry['listurl']); |
60 | 69 | unset($entry['commentsurl']); |
61 | 70 | unset($entry['comment']); |
@@ -65,6 +74,7 @@ discard block |
||
65 | 74 | } |
66 | 75 | } |
67 | 76 | api_output($out); |
68 | -} else { |
|
77 | +} |
|
78 | +else { |
|
69 | 79 | api_error('Nothing'); |
70 | 80 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | if (isset ($data['rows'])) { |
13 | 13 | $out = array(); |
14 | - for ($i=0; $i<count($data['rows']); $i++) { |
|
14 | + for ($i = 0; $i < count($data['rows']); $i++) { |
|
15 | 15 | $row = $data['rows'][$i]; |
16 | 16 | |
17 | 17 | if ($row['htype'] == '10' && isset($row['excerpt']) && strstr($row['excerpt'], "was asked—")) { |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | if ($row['htype'] == '10') { |
41 | 41 | $out[] = array('entry' => $entry, 'subs' => array()); |
42 | 42 | } else { |
43 | - $out[sizeof($out)-1]['subs'][] = $entry; |
|
43 | + $out[sizeof($out) - 1]['subs'][] = $entry; |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | } |
@@ -18,19 +18,24 @@ discard block |
||
18 | 18 | // We fake it here. We hope this section only has a single line like |
19 | 19 | // "The Secretary of State was asked-" and we don't want to make it a link. |
20 | 20 | $has_content = false; |
21 | - } elseif (isset($row['contentcount']) && $row['contentcount'] > 0) { |
|
21 | + } |
|
22 | + elseif (isset($row['contentcount']) && $row['contentcount'] > 0) { |
|
22 | 23 | $has_content = true; |
23 | - } elseif ($row['htype'] == '11' && $hansardmajors[$row['major']]['type'] == 'other') { |
|
24 | + } |
|
25 | + elseif ($row['htype'] == '11' && $hansardmajors[$row['major']]['type'] == 'other') { |
|
24 | 26 | $has_content = true; |
25 | - } else { |
|
27 | + } |
|
28 | + else { |
|
26 | 29 | $has_content = false; |
27 | 30 | } |
28 | 31 | |
29 | 32 | $entry = $row; |
30 | - if (isset($row['excerpt'])) |
|
31 | - $entry['excerpt'] = trim_characters($entry['excerpt'], 0, 200); |
|
33 | + if (isset($row['excerpt'])) { |
|
34 | + $entry['excerpt'] = trim_characters($entry['excerpt'], 0, 200); |
|
35 | + } |
|
32 | 36 | if ($has_content) { |
33 | - } else { |
|
37 | + } |
|
38 | + else { |
|
34 | 39 | unset($entry['listurl']); |
35 | 40 | unset($entry['commentsurl']); |
36 | 41 | unset($entry['comment']); |
@@ -39,12 +44,14 @@ discard block |
||
39 | 44 | |
40 | 45 | if ($row['htype'] == '10') { |
41 | 46 | $out[] = array('entry' => $entry, 'subs' => array()); |
42 | - } else { |
|
47 | + } |
|
48 | + else { |
|
43 | 49 | $out[sizeof($out)-1]['subs'][] = $entry; |
44 | 50 | } |
45 | 51 | |
46 | 52 | } |
47 | 53 | api_output($out); |
48 | -} else { |
|
54 | +} |
|
55 | +else { |
|
49 | 56 | api_error('No data to display'); |
50 | 57 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | <select id="section" name="section"> |
67 | 67 | <option value="">Any |
68 | 68 | <?php |
69 | - optgroups(array( |
|
69 | + optgroups(array( |
|
70 | 70 | 'UK Parliament' => array( |
71 | 71 | 'uk' => 'All UK', |
72 | 72 | 'debates' => 'House of Commons debates', |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | 'sp' => 'Debates', |
86 | 86 | 'spwrans' => 'Written answers', |
87 | 87 | ), |
88 | - ), $section); |
|
89 | - ?> |
|
88 | + ), $section); |
|
89 | + ?> |
|
90 | 90 | </select> |
91 | 91 | <div class="help"> |
92 | 92 | Restrict results to a particular parliament or assembly that we cover (e.g. the |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | if (preg_match('#\s*([0-9/.-]*)\.\.([0-9/.-]*)#', $filter_ss, $m)) { |
24 | 24 | $from = $m[1]; |
25 | 25 | $to = $m[2]; |
26 | - $filter_ss = preg_replace('#\s*([0-9/.-]*)\.\.([0-9/.-]*)#', '', $filter_ss); |
|
26 | + $filter_ss = preg_replace('#\s*([0-9/.-]*)\.\.([0-9/.-]*)#', '', $filter_ss); |
|
27 | 27 | } |
28 | 28 | $section = get_http_var('section'); |
29 | 29 | if (preg_match('#\s*section:([a-z]*)#', $filter_ss, $m)) { |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $filter_ss = preg_replace('#\s*speaker:[0-9]*#', '', $filter_ss); |
37 | 37 | } |
38 | 38 | |
39 | -$this->block_start(array( 'title' => "Filtering your results")); |
|
39 | +$this->block_start(array('title' => "Filtering your results")); |
|
40 | 40 | |
41 | 41 | ?> |
42 | 42 | <form method="get" action="/search/"> |
@@ -5,7 +5,9 @@ |
||
5 | 5 | echo '<optgroup label="', $key, '">'; |
6 | 6 | foreach ($values as $k => $v) { |
7 | 7 | echo '<option'; |
8 | - if ($current == $k) echo ' selected'; |
|
8 | + if ($current == $k) { |
|
9 | + echo ' selected'; |
|
10 | + } |
|
9 | 11 | echo ' value="', $k, '">', $v; |
10 | 12 | } |
11 | 13 | echo "</optgroup>\n"; |
@@ -210,8 +210,8 @@ |
||
210 | 210 | array(':epobject_id' => $this->epobject_id)); |
211 | 211 | |
212 | 212 | if ($q->rows() > 0) { |
213 | - // If you change stuff here, you might have to change it in |
|
214 | - // $COMMENTLIST->_get_comment_data() too... |
|
213 | + // If you change stuff here, you might have to change it in |
|
214 | + // $COMMENTLIST->_get_comment_data() too... |
|
215 | 215 | |
216 | 216 | $gid = fix_gid_from_db($q->field(0, 'gid')); // In includes/utility.php |
217 | 217 |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | public $body = ''; |
32 | 32 | public $posted = ''; |
33 | 33 | public $visible = false; |
34 | - public $modflagged = NULL; // Is a datetime when set. |
|
34 | + public $modflagged = null; // Is a datetime when set. |
|
35 | 35 | public $firstname = ''; // Of the person who posted it. |
36 | 36 | public $lastname = ''; |
37 | 37 | public $url = ''; |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | $flag = "'$date'"; |
139 | 139 | |
140 | 140 | } elseif ($switch == 'off') { |
141 | - $date = NULL; |
|
141 | + $date = null; |
|
142 | 142 | $flag = 'NULL'; |
143 | 143 | |
144 | 144 | } else { |
@@ -31,8 +31,8 @@ discard block |
||
31 | 31 | public $body = ''; |
32 | 32 | public $posted = ''; |
33 | 33 | public $visible = false; |
34 | - public $modflagged = NULL; // Is a datetime when set. |
|
35 | - public $firstname = ''; // Of the person who posted it. |
|
34 | + public $modflagged = NULL; // Is a datetime when set. |
|
35 | + public $firstname = ''; // Of the person who posted it. |
|
36 | 36 | public $lastname = ''; |
37 | 37 | public $url = ''; |
38 | 38 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | public $exists = false; |
42 | 42 | |
43 | 43 | |
44 | - public function __construct($comment_id='') { |
|
44 | + public function __construct($comment_id = '') { |
|
45 | 45 | |
46 | 46 | $this->db = new ParlDB; |
47 | 47 | |
@@ -69,12 +69,12 @@ discard block |
||
69 | 69 | if ($q->rows() > 0) { |
70 | 70 | |
71 | 71 | $this->comment_id = $comment_id; |
72 | - $this->user_id = $q->field(0, 'user_id'); |
|
72 | + $this->user_id = $q->field(0, 'user_id'); |
|
73 | 73 | $this->epobject_id = $q->field(0, 'epobject_id'); |
74 | - $this->body = $q->field(0, 'body'); |
|
75 | - $this->posted = $q->field(0, 'posted'); |
|
76 | - $this->visible = $q->field(0, 'visible'); |
|
77 | - $this->modflagged = $q->field(0, 'modflagged'); |
|
74 | + $this->body = $q->field(0, 'body'); |
|
75 | + $this->posted = $q->field(0, 'posted'); |
|
76 | + $this->visible = $q->field(0, 'visible'); |
|
77 | + $this->modflagged = $q->field(0, 'modflagged'); |
|
78 | 78 | |
79 | 79 | // Sets the URL and username for this comment. Duh. |
80 | 80 | $this->_set_url(); |
@@ -104,9 +104,9 @@ discard block |
||
104 | 104 | public function comments_enabled() { return $this->comments_enabled; } |
105 | 105 | |
106 | 106 | |
107 | - public function display($format='html', $template='comments') { |
|
107 | + public function display($format = 'html', $template = 'comments') { |
|
108 | 108 | |
109 | - $data['comments'][0] = array ( |
|
109 | + $data['comments'][0] = array( |
|
110 | 110 | 'comment_id' => $this->comment_id, |
111 | 111 | 'user_id' => $this->user_id, |
112 | 112 | 'epobject_id' => $this->epobject_id, |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | $flag = 'NULL'; |
143 | 143 | |
144 | 144 | } else { |
145 | - $PAGE->error_message ("Why are you trying to switch this comment's modflag to '" . _htmlentities($switch) . "'!"); |
|
145 | + $PAGE->error_message("Why are you trying to switch this comment's modflag to '" . _htmlentities($switch) . "'!"); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | $q = $this->db->query("UPDATE comments |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | $this->modflagged = $date; |
155 | 155 | return true; |
156 | 156 | } else { |
157 | - $message = array ( |
|
157 | + $message = array( |
|
158 | 158 | 'title' => 'Sorry', |
159 | 159 | 'text' => "We couldn't update the annotation's modflag." |
160 | 160 | ); |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | if ($q->success()) { |
177 | 177 | return true; |
178 | 178 | } else { |
179 | - $message = array ( |
|
179 | + $message = array( |
|
180 | 180 | 'title' => 'Sorry', |
181 | 181 | 'text' => "We were unable to delete the annotation." |
182 | 182 | ); |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | } |
186 | 186 | |
187 | 187 | } else { |
188 | - $message = array ( |
|
188 | + $message = array( |
|
189 | 189 | 'title' => 'Sorry', |
190 | 190 | 'text' => "You are not authorised to delete annotations." |
191 | 191 | ); |
@@ -48,7 +48,8 @@ discard block |
||
48 | 48 | // Set in init.php |
49 | 49 | if (ALLOWCOMMENTS == true) { |
50 | 50 | $this->comments_enabled = true; |
51 | - } else { |
|
51 | + } |
|
52 | + else { |
|
52 | 53 | $this->comments_enabled = false; |
53 | 54 | } |
54 | 55 | |
@@ -81,7 +82,8 @@ discard block |
||
81 | 82 | $this->_set_username(); |
82 | 83 | |
83 | 84 | $this->exists = true; |
84 | - } else { |
|
85 | + } |
|
86 | + else { |
|
85 | 87 | $this->exists = false; |
86 | 88 | } |
87 | 89 | } |
@@ -137,11 +139,13 @@ discard block |
||
137 | 139 | $date = gmdate("Y-m-d H:i:s"); |
138 | 140 | $flag = "'$date'"; |
139 | 141 | |
140 | - } elseif ($switch == 'off') { |
|
142 | + } |
|
143 | + elseif ($switch == 'off') { |
|
141 | 144 | $date = NULL; |
142 | 145 | $flag = 'NULL'; |
143 | 146 | |
144 | - } else { |
|
147 | + } |
|
148 | + else { |
|
145 | 149 | $PAGE->error_message ("Why are you trying to switch this comment's modflag to '" . _htmlentities($switch) . "'!"); |
146 | 150 | } |
147 | 151 | |
@@ -153,7 +157,8 @@ discard block |
||
153 | 157 | if ($q->success()) { |
154 | 158 | $this->modflagged = $date; |
155 | 159 | return true; |
156 | - } else { |
|
160 | + } |
|
161 | + else { |
|
157 | 162 | $message = array ( |
158 | 163 | 'title' => 'Sorry', |
159 | 164 | 'text' => "We couldn't update the annotation's modflag." |
@@ -175,7 +180,8 @@ discard block |
||
175 | 180 | |
176 | 181 | if ($q->success()) { |
177 | 182 | return true; |
178 | - } else { |
|
183 | + } |
|
184 | + else { |
|
179 | 185 | $message = array ( |
180 | 186 | 'title' => 'Sorry', |
181 | 187 | 'text' => "We were unable to delete the annotation." |
@@ -184,7 +190,8 @@ discard block |
||
184 | 190 | return false; |
185 | 191 | } |
186 | 192 | |
187 | - } else { |
|
193 | + } |
|
194 | + else { |
|
188 | 195 | $message = array ( |
189 | 196 | 'title' => 'Sorry', |
190 | 197 | 'text' => "You are not authorised to delete annotations." |
@@ -67,11 +67,11 @@ discard block |
||
67 | 67 | # Ignore errors we've asked to ignore |
68 | 68 | if (error_reporting()==0) return; |
69 | 69 | |
70 | - // define an assoc array of error string |
|
71 | - // in reality the only entries we should |
|
72 | - // consider are E_WARNING, E_NOTICE, E_USER_ERROR, |
|
73 | - // E_USER_WARNING and E_USER_NOTICE |
|
74 | - # Commented out are ones that a user function cannot handle. |
|
70 | + // define an assoc array of error string |
|
71 | + // in reality the only entries we should |
|
72 | + // consider are E_WARNING, E_NOTICE, E_USER_ERROR, |
|
73 | + // E_USER_WARNING and E_USER_NOTICE |
|
74 | + # Commented out are ones that a user function cannot handle. |
|
75 | 75 | $errortype = array ( |
76 | 76 | #E_ERROR => "Error", |
77 | 77 | E_WARNING => "Warning", |
@@ -200,8 +200,8 @@ discard block |
||
200 | 200 | // pretty prints the backtrace, copied from http://uk.php.net/manual/en/function.debug-backtrace.php |
201 | 201 | function adodb_backtrace($print=true) |
202 | 202 | { |
203 | - $s = ''; |
|
204 | - if (PHPVERSION() >= 4.3) { |
|
203 | + $s = ''; |
|
204 | + if (PHPVERSION() >= 4.3) { |
|
205 | 205 | |
206 | 206 | $MAXSTRLEN = 64; |
207 | 207 | |
@@ -209,33 +209,33 @@ discard block |
||
209 | 209 | array_shift($traceArr); |
210 | 210 | $tabs = sizeof($traceArr)-1; |
211 | 211 | foreach ($traceArr as $arr) { |
212 | - for ($i=0; $i < $tabs; $i++) $s .= ' '; |
|
213 | - $tabs -= 1; |
|
214 | - if (isset($arr['class'])) $s .= $arr['class'].'.'; |
|
215 | - $args = array(); |
|
216 | - if (isset($arr['args'])) foreach ($arr['args'] as $v) { |
|
212 | + for ($i=0; $i < $tabs; $i++) $s .= ' '; |
|
213 | + $tabs -= 1; |
|
214 | + if (isset($arr['class'])) $s .= $arr['class'].'.'; |
|
215 | + $args = array(); |
|
216 | + if (isset($arr['args'])) foreach ($arr['args'] as $v) { |
|
217 | 217 | if (is_null($v)) $args[] = 'null'; |
218 | 218 | elseif (is_array($v)) $args[] = 'Array['.sizeof($v).']'; |
219 | 219 | elseif (is_object($v)) $args[] = 'Object:'.get_class($v); |
220 | 220 | elseif (is_bool($v)) $args[] = $v ? 'true' : 'false'; |
221 | 221 | else { |
222 | - $v = (string) @$v; |
|
223 | - $str = _htmlspecialchars(substr($v,0,$MAXSTRLEN)); |
|
224 | - if (strlen($v) > $MAXSTRLEN) $str .= '...'; |
|
225 | - $args[] = $str; |
|
222 | + $v = (string) @$v; |
|
223 | + $str = _htmlspecialchars(substr($v,0,$MAXSTRLEN)); |
|
224 | + if (strlen($v) > $MAXSTRLEN) $str .= '...'; |
|
225 | + $args[] = $str; |
|
226 | 226 | } |
227 | - } |
|
227 | + } |
|
228 | 228 | |
229 | - $s .= $arr['function'].'('.implode(', ',$args).')'; |
|
230 | - // $s .= sprintf("</font><font color=#808080 size=-1> # line %4d,". |
|
231 | - // " file: <a href=\"file:/%s\">%s</a></font>", |
|
232 | - // $arr['line'],$arr['file'],$arr['file']); |
|
233 | - $s .= "\n"; |
|
229 | + $s .= $arr['function'].'('.implode(', ',$args).')'; |
|
230 | + // $s .= sprintf("</font><font color=#808080 size=-1> # line %4d,". |
|
231 | + // " file: <a href=\"file:/%s\">%s</a></font>", |
|
232 | + // $arr['line'],$arr['file'],$arr['file']); |
|
233 | + $s .= "\n"; |
|
234 | 234 | } |
235 | 235 | if ($print) print $s; |
236 | - } |
|
236 | + } |
|
237 | 237 | |
238 | - return $s; |
|
238 | + return $s; |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | // Far from foolproof, but better than nothing. |
@@ -567,14 +567,14 @@ discard block |
||
567 | 567 | //$tbl["»"] = "»"; |
568 | 568 | //$tbl["«"] = "«"; |
569 | 569 | |
570 | - // lib_filter will replace unmatched < and > with entities so |
|
571 | - // we abuse strtr's only replace once behaviour to not double |
|
572 | - // encode them. May not be robust. |
|
573 | - // This does mean if anyone actually wants to put > or < |
|
574 | - // in a comment they can't but that's a lot less likely than |
|
575 | - // < or > for less than and greater than. |
|
576 | - $tbl['<'] = "<"; |
|
577 | - $tbl['>'] = ">"; |
|
570 | + // lib_filter will replace unmatched < and > with entities so |
|
571 | + // we abuse strtr's only replace once behaviour to not double |
|
572 | + // encode them. May not be robust. |
|
573 | + // This does mean if anyone actually wants to put > or < |
|
574 | + // in a comment they can't but that's a lot less likely than |
|
575 | + // < or > for less than and greater than. |
|
576 | + $tbl['<'] = "<"; |
|
577 | + $tbl['>'] = ">"; |
|
578 | 578 | |
579 | 579 | // Don't want to encode these things |
580 | 580 | unset ($tbl["<"]); |
@@ -764,16 +764,16 @@ discard block |
||
764 | 764 | if (!$from) $from = CONTACTEMAIL; |
765 | 765 | |
766 | 766 | $headers = |
767 | - "From: TheyWorkForYou <$from>\r\n" . |
|
768 | - "Content-Type: text/plain; charset=utf-8\r\n" . |
|
769 | - "MIME-Version: 1.0\r\n" . |
|
770 | - "Content-Transfer-Encoding: 8bit\r\n" . |
|
771 | - ($bulk ? "Precedence: bulk\r\nAuto-Submitted: auto-generated\r\n" : "" ). |
|
772 | - "X-Mailer: PHP/" . phpversion(); |
|
767 | + "From: TheyWorkForYou <$from>\r\n" . |
|
768 | + "Content-Type: text/plain; charset=utf-8\r\n" . |
|
769 | + "MIME-Version: 1.0\r\n" . |
|
770 | + "Content-Transfer-Encoding: 8bit\r\n" . |
|
771 | + ($bulk ? "Precedence: bulk\r\nAuto-Submitted: auto-generated\r\n" : "" ). |
|
772 | + "X-Mailer: PHP/" . phpversion(); |
|
773 | 773 | twfy_debug('EMAIL', "Sending email to $to with subject of '$subject'"); |
774 | 774 | |
775 | 775 | if ($want_bounces) { |
776 | - $envelope_sender = twfy_verp_envelope_sender($to); |
|
776 | + $envelope_sender = twfy_verp_envelope_sender($to); |
|
777 | 777 | $success = mail ($to, $subject, $message, $headers, '-f ' . $envelope_sender); |
778 | 778 | } else { |
779 | 779 | $success = mail ($to, $subject, $message, $headers); |
@@ -1063,7 +1063,7 @@ discard block |
||
1063 | 1063 | |
1064 | 1064 | $return = '<h4>'; |
1065 | 1065 | if (isset($daytext[$major])) { |
1066 | - $return .= $daytext[$major] . ' '; |
|
1066 | + $return .= $daytext[$major] . ' '; |
|
1067 | 1067 | } |
1068 | 1068 | |
1069 | 1069 | $return .= '<a href="'; |
@@ -887,7 +887,7 @@ discard block |
||
887 | 887 | return $string; |
888 | 888 | } |
889 | 889 | |
890 | -function make_member_url($name, $const = '', $house = HOUSE_TYPE_COMMONS, $pid = NULL) { |
|
890 | +function make_member_url($name, $const = '', $house = HOUSE_TYPE_COMMONS, $pid = null) { |
|
891 | 891 | |
892 | 892 | // Case for Elizabeth II |
893 | 893 | if ($house == HOUSE_TYPE_ROYAL) |
@@ -903,7 +903,7 @@ discard block |
||
903 | 903 | $out = ''; |
904 | 904 | |
905 | 905 | // Insert the Person ID if known. |
906 | - if ($pid !== NULL) |
|
906 | + if ($pid !== null) |
|
907 | 907 | { |
908 | 908 | $out .= $pid . '/'; |
909 | 909 | } |
@@ -318,6 +318,9 @@ discard block |
||
318 | 318 | $format_date_months = array('', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); |
319 | 319 | $format_date_months_short = array('', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); |
320 | 320 | |
321 | +/** |
|
322 | + * @param string $format |
|
323 | + */ |
|
321 | 324 | function format_date($date, $format) { |
322 | 325 | global $format_date_months, $format_date_months_short; |
323 | 326 | // Pass it a date (YYYY-MM-DD) and a |
@@ -342,6 +345,9 @@ discard block |
||
342 | 345 | } |
343 | 346 | |
344 | 347 | |
348 | +/** |
|
349 | + * @param string $format |
|
350 | + */ |
|
345 | 351 | function format_time($time, $format) { |
346 | 352 | // Pass it a time (HH:MM:SS) and a |
347 | 353 | // PHP date format string (eg, "H:i") |
@@ -486,6 +492,7 @@ discard block |
||
486 | 492 | |
487 | 493 | /** |
488 | 494 | * Filters user input to remove unwanted HTML tags etc |
495 | + * @param string $filter_type |
|
489 | 496 | */ |
490 | 497 | function filter_user_input($text, $filter_type) { |
491 | 498 | // We use this to filter any major user input, especially comments. |
@@ -750,12 +757,18 @@ discard block |
||
750 | 757 | /* verp_envelope_sender RECIPIENT |
751 | 758 | * Construct a VERP envelope sender for an email to RECIPIENT |
752 | 759 | */ |
760 | +/** |
|
761 | + * @return string|null |
|
762 | + */ |
|
753 | 763 | function twfy_verp_envelope_sender($recipient) { |
754 | 764 | $envelope_sender = verp_envelope_sender($recipient, 'twfy', EMAILDOMAIN); |
755 | 765 | |
756 | 766 | return $envelope_sender; |
757 | 767 | } |
758 | 768 | |
769 | +/** |
|
770 | + * @param string $message |
|
771 | + */ |
|
759 | 772 | function send_email($to, $subject, $message, $bulk = false, $from = '', $want_bounces = false) { |
760 | 773 | // Use this rather than PHP's mail() direct, so we can make alterations |
761 | 774 | // easily to all the emails we send out from the site. |
@@ -814,6 +827,9 @@ discard block |
||
814 | 827 | } |
815 | 828 | |
816 | 829 | // Call this with a key name to get a COOKIE variable. |
830 | +/** |
|
831 | + * @param string $name |
|
832 | + */ |
|
817 | 833 | function get_cookie_var($name, $default='') { |
818 | 834 | if (array_key_exists($name, $_COOKIE)) { |
819 | 835 | return clean_var($_COOKIE[$name]); |
@@ -1058,6 +1074,10 @@ discard block |
||
1058 | 1074 | } |
1059 | 1075 | } |
1060 | 1076 | |
1077 | +/** |
|
1078 | + * @param integer $major |
|
1079 | + * @param MySociety\TheyWorkForYou\Url $LISTURL |
|
1080 | + */ |
|
1061 | 1081 | function _major_summary_title($major, $data, $LISTURL, $daytext) { |
1062 | 1082 | global $hansardmajors; |
1063 | 1083 | |
@@ -1107,6 +1127,9 @@ discard block |
||
1107 | 1127 | return $return; |
1108 | 1128 | } |
1109 | 1129 | |
1130 | +/** |
|
1131 | + * @param string|null $url |
|
1132 | + */ |
|
1110 | 1133 | function redirect($url) { |
1111 | 1134 | if (defined('TESTING')) { |
1112 | 1135 | print "Location: $url"; |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | |
11 | 11 | # Pass it a brief header word and some debug text and it'll be output. |
12 | 12 | # If TEXT is an array, call the user function, assuming it's a class. |
13 | -function twfy_debug($header, $text="") { |
|
13 | +function twfy_debug($header, $text = "") { |
|
14 | 14 | |
15 | 15 | // We set ?DEBUGTAG=n in the URL. |
16 | 16 | // (DEBUGTAG is set in config.php). |
@@ -27,10 +27,10 @@ discard block |
||
27 | 27 | if ($debug_level != '') { |
28 | 28 | |
29 | 29 | // Set which level shows which types of debug info. |
30 | - $levels = array ( |
|
31 | - 1 => array ('THEUSER', 'TIME', 'SQLERROR', 'PAGE', 'TEMPLATE', 'SEARCH', 'ALERTS', 'MP'), |
|
32 | - 2 => array ('SQL', 'EMAIL', 'WIKIPEDIA', 'hansardlist', 'debatelist', 'wranslist', 'whalllist'), |
|
33 | - 3 => array ('SQLRESULT') |
|
30 | + $levels = array( |
|
31 | + 1 => array('THEUSER', 'TIME', 'SQLERROR', 'PAGE', 'TEMPLATE', 'SEARCH', 'ALERTS', 'MP'), |
|
32 | + 2 => array('SQL', 'EMAIL', 'WIKIPEDIA', 'hansardlist', 'debatelist', 'wranslist', 'whalllist'), |
|
33 | + 3 => array('SQLRESULT') |
|
34 | 34 | // Higher than this: 'DATA', etc. |
35 | 35 | ); |
36 | 36 | |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | } |
45 | 45 | |
46 | 46 | for ($n = 1; $n <= $max_level_to_show; $n++) { |
47 | - $allowed_headers = array_merge ($allowed_headers, $levels[$n] ); |
|
47 | + $allowed_headers = array_merge($allowed_headers, $levels[$n]); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | // If we can show this header, then, er, show it. |
51 | - if ( in_array($header, $allowed_headers) || $debug_level >= 4) { |
|
51 | + if (in_array($header, $allowed_headers) || $debug_level >= 4) { |
|
52 | 52 | if (is_array($text)) $text = call_user_func($text); |
53 | 53 | print "<p><span style=\"color:#039;\"><strong>$header</strong></span> $text</p>\n"; |
54 | 54 | } |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | global $PAGE; |
66 | 66 | |
67 | 67 | # Ignore errors we've asked to ignore |
68 | - if (error_reporting()==0) return; |
|
68 | + if (error_reporting() == 0) return; |
|
69 | 69 | |
70 | 70 | // define an assoc array of error string |
71 | 71 | // in reality the only entries we should |
72 | 72 | // consider are E_WARNING, E_NOTICE, E_USER_ERROR, |
73 | 73 | // E_USER_WARNING and E_USER_NOTICE |
74 | 74 | # Commented out are ones that a user function cannot handle. |
75 | - $errortype = array ( |
|
75 | + $errortype = array( |
|
76 | 76 | #E_ERROR => "Error", |
77 | 77 | E_WARNING => "Warning", |
78 | 78 | #E_PARSE => "Parsing Error", |
@@ -131,11 +131,11 @@ discard block |
||
131 | 131 | $source = file($filename); |
132 | 132 | $err .= "\nSource:\n\n"; |
133 | 133 | // Show the line, plus prev and next, with line numbers. |
134 | - $err .= $linenum-2 . " " . $source[$linenum-3]; |
|
135 | - $err .= $linenum-1 . " " . $source[$linenum-2]; |
|
136 | - $err .= $linenum . " " . $source[$linenum-1]; |
|
137 | - $err .= $linenum+1 . " " . $source[$linenum]; |
|
138 | - $err .= $linenum+2 . " " . $source[$linenum+1]; |
|
134 | + $err .= $linenum - 2 . " " . $source[$linenum - 3]; |
|
135 | + $err .= $linenum - 1 . " " . $source[$linenum - 2]; |
|
136 | + $err .= $linenum . " " . $source[$linenum - 1]; |
|
137 | + $err .= $linenum + 1 . " " . $source[$linenum]; |
|
138 | + $err .= $linenum + 2 . " " . $source[$linenum + 1]; |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | |
@@ -179,8 +179,8 @@ discard block |
||
179 | 179 | header('HTTP/1.0 500 Internal Server Error'); |
180 | 180 | print "<p>Oops, sorry, an error has occurred!</p>\n"; |
181 | 181 | } |
182 | - if (!($errno & E_USER_NOTICE) && strpos($errmsg, 'pg_connect')===false && strpos($errmsg, 'mysql_connect')===false) { |
|
183 | - mail(BUGSLIST, "[TWFYBUG]: $errmsg", $err, "From: Bug <" . CONTACTEMAIL . ">\n". "X-Mailer: PHP/" . phpversion() ); |
|
182 | + if (!($errno & E_USER_NOTICE) && strpos($errmsg, 'pg_connect') === false && strpos($errmsg, 'mysql_connect') === false) { |
|
183 | + mail(BUGSLIST, "[TWFYBUG]: $errmsg", $err, "From: Bug <" . CONTACTEMAIL . ">\n" . "X-Mailer: PHP/" . phpversion()); |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | } |
199 | 199 | |
200 | 200 | // pretty prints the backtrace, copied from http://uk.php.net/manual/en/function.debug-backtrace.php |
201 | -function adodb_backtrace($print=true) |
|
201 | +function adodb_backtrace($print = true) |
|
202 | 202 | { |
203 | 203 | $s = ''; |
204 | 204 | if (PHPVERSION() >= 4.3) { |
@@ -207,26 +207,26 @@ discard block |
||
207 | 207 | |
208 | 208 | $traceArr = debug_backtrace(); |
209 | 209 | array_shift($traceArr); |
210 | - $tabs = sizeof($traceArr)-1; |
|
210 | + $tabs = sizeof($traceArr) - 1; |
|
211 | 211 | foreach ($traceArr as $arr) { |
212 | - for ($i=0; $i < $tabs; $i++) $s .= ' '; |
|
212 | + for ($i = 0; $i < $tabs; $i++) $s .= ' '; |
|
213 | 213 | $tabs -= 1; |
214 | - if (isset($arr['class'])) $s .= $arr['class'].'.'; |
|
214 | + if (isset($arr['class'])) $s .= $arr['class'] . '.'; |
|
215 | 215 | $args = array(); |
216 | 216 | if (isset($arr['args'])) foreach ($arr['args'] as $v) { |
217 | 217 | if (is_null($v)) $args[] = 'null'; |
218 | - elseif (is_array($v)) $args[] = 'Array['.sizeof($v).']'; |
|
219 | - elseif (is_object($v)) $args[] = 'Object:'.get_class($v); |
|
218 | + elseif (is_array($v)) $args[] = 'Array[' . sizeof($v) . ']'; |
|
219 | + elseif (is_object($v)) $args[] = 'Object:' . get_class($v); |
|
220 | 220 | elseif (is_bool($v)) $args[] = $v ? 'true' : 'false'; |
221 | 221 | else { |
222 | 222 | $v = (string) @$v; |
223 | - $str = _htmlspecialchars(substr($v,0,$MAXSTRLEN)); |
|
223 | + $str = _htmlspecialchars(substr($v, 0, $MAXSTRLEN)); |
|
224 | 224 | if (strlen($v) > $MAXSTRLEN) $str .= '...'; |
225 | 225 | $args[] = $str; |
226 | 226 | } |
227 | 227 | } |
228 | 228 | |
229 | - $s .= $arr['function'].'('.implode(', ',$args).')'; |
|
229 | + $s .= $arr['function'] . '(' . implode(', ', $args) . ')'; |
|
230 | 230 | // $s .= sprintf("</font><font color=#808080 size=-1> # line %4d,". |
231 | 231 | // " file: <a href=\"file:/%s\">%s</a></font>", |
232 | 232 | // $arr['line'],$arr['file'],$arr['file']); |
@@ -240,9 +240,9 @@ discard block |
||
240 | 240 | |
241 | 241 | // Far from foolproof, but better than nothing. |
242 | 242 | function validate_email($string) { |
243 | - if (!preg_match('/^[-!#$%&\'*+\\.\/0-9=?A-Z^_`a-z{|}~]+'. |
|
244 | - '@'. |
|
245 | - '[-!#$%&\'*.\\+\/0-9=?A-Z^_`a-z{|}~]+\.'. |
|
243 | + if (!preg_match('/^[-!#$%&\'*+\\.\/0-9=?A-Z^_`a-z{|}~]+' . |
|
244 | + '@' . |
|
245 | + '[-!#$%&\'*.\\+\/0-9=?A-Z^_`a-z{|}~]+\.' . |
|
246 | 246 | '[-!#$%&\'*+\\.\/0-9=?A-Z^_`a-z{|}~]+$/', $string)) { |
247 | 247 | return false; |
248 | 248 | } else { |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | $nom = '0123456789'; |
265 | 265 | $gap = '\s\.'; |
266 | 266 | |
267 | - if ( preg_match("/^[$fst][$num][$gap]*[$nom][$in][$in]$/i", $postcode) || |
|
267 | + if (preg_match("/^[$fst][$num][$gap]*[$nom][$in][$in]$/i", $postcode) || |
|
268 | 268 | preg_match("/^[$fst][$num][$num][$gap]*[$nom][$in][$in]$/i", $postcode) || |
269 | 269 | preg_match("/^[$fst][$sec][$num][$gap]*[$nom][$in][$in]$/i", $postcode) || |
270 | 270 | preg_match("/^[$fst][$sec][$num][$num][$gap]*[$nom][$in][$in]$/i", $postcode) || |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | // Returns the unixtime in microseconds. |
281 | 281 | function getmicrotime() { |
282 | 282 | $mtime = microtime(); |
283 | - $mtime = explode(" ",$mtime); |
|
283 | + $mtime = explode(" ", $mtime); |
|
284 | 284 | $mtime = $mtime[1] + $mtime[0]; |
285 | 285 | |
286 | 286 | return $mtime; |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | global $timestamp_last, $timestamp_start; |
294 | 294 | $t = getmicrotime(); |
295 | 295 | twfy_debug("TIME", sprintf("%f msecs since start; %f msecs since last; %s", |
296 | - ($t - $timestamp_start)*1000.0, ($t - $timestamp_last)*1000.0, $label)); |
|
296 | + ($t - $timestamp_start) * 1000.0, ($t - $timestamp_last) * 1000.0, $label)); |
|
297 | 297 | $timestamp_last = $t; |
298 | 298 | } |
299 | 299 | |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | if (preg_match("/^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/", $timestamp, $matches)) { |
308 | 308 | list($string, $year, $month, $day, $hour, $min, $sec) = $matches; |
309 | 309 | |
310 | - return gmdate ($format, gmmktime($hour, $min, $sec, $month, $day, $year)); |
|
310 | + return gmdate($format, gmmktime($hour, $min, $sec, $month, $day, $year)); |
|
311 | 311 | } else { |
312 | 312 | return ""; |
313 | 313 | } |
@@ -328,13 +328,13 @@ discard block |
||
328 | 328 | list($string, $year, $month, $day) = $matches; |
329 | 329 | if ($year < 1902) { # gmdate fns only go back to Dec. 1901 |
330 | 330 | if ($format == SHORTDATEFORMAT) { |
331 | - return ($day+0) . ' ' . $format_date_months_short[$month+0] . " $year"; |
|
331 | + return ($day + 0) . ' ' . $format_date_months_short[$month + 0] . " $year"; |
|
332 | 332 | } else { |
333 | - return ($day+0) . ' ' . $format_date_months[$month+0] . " $year"; |
|
333 | + return ($day + 0) . ' ' . $format_date_months[$month + 0] . " $year"; |
|
334 | 334 | } |
335 | 335 | } |
336 | 336 | |
337 | - return gmdate ($format, gmmktime(0, 0, 0, $month, $day, $year)); |
|
337 | + return gmdate($format, gmmktime(0, 0, 0, $month, $day, $year)); |
|
338 | 338 | } else { |
339 | 339 | return ""; |
340 | 340 | } |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | if (preg_match("/^(\d\d):(\d\d):(\d\d)$/", $time, $matches)) { |
351 | 351 | list($string, $hour, $min, $sec) = $matches; |
352 | 352 | |
353 | - return gmdate ($format, gmmktime($hour, $min, $sec)); |
|
353 | + return gmdate($format, gmmktime($hour, $min, $sec)); |
|
354 | 354 | } else { |
355 | 355 | return ""; |
356 | 356 | } |
@@ -371,16 +371,16 @@ discard block |
||
371 | 371 | $in_seconds = strtotime($datetime); |
372 | 372 | $now = time(); |
373 | 373 | |
374 | - $diff = $now - $in_seconds; |
|
375 | - $months = floor($diff/2419200); |
|
374 | + $diff = $now - $in_seconds; |
|
375 | + $months = floor($diff / 2419200); |
|
376 | 376 | $diff -= $months * 2419200; |
377 | - $weeks = floor($diff/604800); |
|
378 | - $diff -= $weeks*604800; |
|
379 | - $days = floor($diff/86400); |
|
377 | + $weeks = floor($diff / 604800); |
|
378 | + $diff -= $weeks * 604800; |
|
379 | + $days = floor($diff / 86400); |
|
380 | 380 | $diff -= $days * 86400; |
381 | - $hours = floor($diff/3600); |
|
381 | + $hours = floor($diff / 3600); |
|
382 | 382 | $diff -= $hours * 3600; |
383 | - $minutes = floor($diff/60); |
|
383 | + $minutes = floor($diff / 60); |
|
384 | 384 | $diff -= $minutes * 60; |
385 | 385 | $seconds = $diff; |
386 | 386 | |
@@ -394,27 +394,27 @@ discard block |
||
394 | 394 | $relative_date = ''; |
395 | 395 | if ($weeks > 0) { |
396 | 396 | // Weeks and days |
397 | - $relative_date .= ($relative_date?', ':'').$weeks.' week'.($weeks>1?'s':''); |
|
398 | - $relative_date .= $days>0?($relative_date?', ':'').$days.' day'.($days>1?'s':''):''; |
|
397 | + $relative_date .= ($relative_date ? ', ' : '') . $weeks . ' week' . ($weeks > 1 ? 's' : ''); |
|
398 | + $relative_date .= $days > 0 ? ($relative_date ? ', ' : '') . $days . ' day' . ($days > 1 ? 's' : '') : ''; |
|
399 | 399 | } elseif ($days > 0) { |
400 | 400 | // days and hours |
401 | - $relative_date .= ($relative_date?', ':'').$days.' day'.($days>1?'s':''); |
|
402 | - $relative_date .= $hours>0?($relative_date?', ':'').$hours.' hour'.($hours>1?'s':''):''; |
|
401 | + $relative_date .= ($relative_date ? ', ' : '') . $days . ' day' . ($days > 1 ? 's' : ''); |
|
402 | + $relative_date .= $hours > 0 ? ($relative_date ? ', ' : '') . $hours . ' hour' . ($hours > 1 ? 's' : '') : ''; |
|
403 | 403 | } elseif ($hours > 0) { |
404 | 404 | // hours and minutes |
405 | - $relative_date .= ($relative_date?', ':'').$hours.' hour'.($hours>1?'s':''); |
|
406 | - $relative_date .= $minutes>0?($relative_date?', ':'').$minutes.' minute'.($minutes>1?'s':''):''; |
|
405 | + $relative_date .= ($relative_date ? ', ' : '') . $hours . ' hour' . ($hours > 1 ? 's' : ''); |
|
406 | + $relative_date .= $minutes > 0 ? ($relative_date ? ', ' : '') . $minutes . ' minute' . ($minutes > 1 ? 's' : '') : ''; |
|
407 | 407 | } elseif ($minutes > 0) { |
408 | 408 | // minutes only |
409 | - $relative_date .= ($relative_date?', ':'').$minutes.' minute'.($minutes>1?'s':''); |
|
409 | + $relative_date .= ($relative_date ? ', ' : '') . $minutes . ' minute' . ($minutes > 1 ? 's' : ''); |
|
410 | 410 | } else { |
411 | 411 | // seconds only |
412 | - $relative_date .= ($relative_date?', ':'').$seconds.' second'.($seconds>1?'s':''); |
|
412 | + $relative_date .= ($relative_date ? ', ' : '') . $seconds . ' second' . ($seconds > 1 ? 's' : ''); |
|
413 | 413 | } |
414 | 414 | } |
415 | 415 | |
416 | 416 | // Return relative date and add proper verbiage |
417 | - return $relative_date.' ago'; |
|
417 | + return $relative_date . ' ago'; |
|
418 | 418 | |
419 | 419 | } |
420 | 420 | |
@@ -455,10 +455,10 @@ discard block |
||
455 | 455 | $text = substr($text, $start); |
456 | 456 | |
457 | 457 | // Word boundary. |
458 | - if (preg_match ("/.+?\b(.*)/", $text, $matches)) { |
|
458 | + if (preg_match("/.+?\b(.*)/", $text, $matches)) { |
|
459 | 459 | $text = $matches[1]; |
460 | 460 | // Strip spare space at the start. |
461 | - $text = preg_replace ("/^\s/", '', $text); |
|
461 | + $text = preg_replace("/^\s/", '', $text); |
|
462 | 462 | } |
463 | 463 | $text = '...' . $text; |
464 | 464 | } |
@@ -470,10 +470,10 @@ discard block |
||
470 | 470 | $text = substr($text, 0, $length - 3); |
471 | 471 | |
472 | 472 | // Word boundary. |
473 | - if (preg_match ("/(.*)\s.+/", $text, $matches)) { |
|
473 | + if (preg_match("/(.*)\s.+/", $text, $matches)) { |
|
474 | 474 | $text = $matches[1]; |
475 | 475 | // Strip spare space at the end. |
476 | - $text = preg_replace ("/\s$/", '', $text); |
|
476 | + $text = preg_replace("/\s$/", '', $text); |
|
477 | 477 | } |
478 | 478 | // We don't want to use the HTML entity for an ellipsis (…), because then |
479 | 479 | // it screws up when we subsequently use htmlentities() to print the returned |
@@ -505,11 +505,11 @@ discard block |
||
505 | 505 | |
506 | 506 | if ($filter_type == 'strict') { |
507 | 507 | // No tags allowed at all! |
508 | - $filter->allowed = array (); |
|
508 | + $filter->allowed = array(); |
|
509 | 509 | } else { |
510 | 510 | // Comment. |
511 | 511 | // Only allowing <a href>, <b>, <strong>, <i> and <em> |
512 | - $filter->allowed = array ( |
|
512 | + $filter->allowed = array( |
|
513 | 513 | 'a' => array('href'), |
514 | 514 | 'strong' => array(), |
515 | 515 | 'em' => array(), |
@@ -630,10 +630,10 @@ discard block |
||
630 | 630 | // This returns 'debate_2003-02-28.475.3'. |
631 | 631 | |
632 | 632 | if ($keepmajor) { |
633 | - $newgid = substr($gid, strpos($gid, '/')+1 ); |
|
633 | + $newgid = substr($gid, strpos($gid, '/') + 1); |
|
634 | 634 | $newgid = str_replace('/', '_', $newgid); |
635 | 635 | } else { |
636 | - $newgid = substr($gid, strrpos($gid, '/')+1 ); |
|
636 | + $newgid = substr($gid, strrpos($gid, '/') + 1); |
|
637 | 637 | } |
638 | 638 | |
639 | 639 | return $newgid; |
@@ -647,7 +647,7 @@ discard block |
||
647 | 647 | // will be like 2003-11-20.966.0 |
648 | 648 | // This function returns 966.0 |
649 | 649 | |
650 | - return substr( $gid, (strpos($gid, '.') + 1) ); |
|
650 | + return substr($gid, (strpos($gid, '.') + 1)); |
|
651 | 651 | } |
652 | 652 | |
653 | 653 | function preg_replacement_quote($s) { |
@@ -691,7 +691,7 @@ discard block |
||
691 | 691 | global $PAGE; |
692 | 692 | |
693 | 693 | if (!isset($data['to']) || $data['to'] == '') { |
694 | - $PAGE->error_message ("We need an email address to send to."); |
|
694 | + $PAGE->error_message("We need an email address to send to."); |
|
695 | 695 | return false; |
696 | 696 | } |
697 | 697 | |
@@ -715,7 +715,7 @@ discard block |
||
715 | 715 | if (isset($data['subject'])) { |
716 | 716 | $subject = trim($data['subject']); |
717 | 717 | } else { |
718 | - $subject = trim( substr($firstline, 8) ); |
|
718 | + $subject = trim(substr($firstline, 8)); |
|
719 | 719 | } |
720 | 720 | |
721 | 721 | // Either way, remove this subject line from the template. |
@@ -724,7 +724,7 @@ discard block |
||
724 | 724 | } elseif (isset($data['subject'])) { |
725 | 725 | $subject = $data['subject']; |
726 | 726 | } else { |
727 | - $PAGE->error_message ("We don't have a subject line for the email, so it wasn't sent."); |
|
727 | + $PAGE->error_message("We don't have a subject line for the email, so it wasn't sent."); |
|
728 | 728 | return false; |
729 | 729 | } |
730 | 730 | |
@@ -734,14 +734,14 @@ discard block |
||
734 | 734 | $replace = array(); |
735 | 735 | |
736 | 736 | foreach ($merge as $key => $val) { |
737 | - $search[] = '/{'.$key.'}/'; |
|
737 | + $search[] = '/{' . $key . '}/'; |
|
738 | 738 | $replace[] = preg_replacement_quote($val); |
739 | 739 | } |
740 | 740 | |
741 | 741 | $emailtext = preg_replace($search, $replace, $emailtext); |
742 | 742 | |
743 | 743 | // Send it! |
744 | - $success = send_email ($data['to'], $subject, $emailtext, $bulk, 'twfy-DO-NOT-REPLY@' . EMAILDOMAIN, $want_bounces); |
|
744 | + $success = send_email($data['to'], $subject, $emailtext, $bulk, 'twfy-DO-NOT-REPLY@' . EMAILDOMAIN, $want_bounces); |
|
745 | 745 | |
746 | 746 | return $success; |
747 | 747 | |
@@ -768,15 +768,15 @@ discard block |
||
768 | 768 | "Content-Type: text/plain; charset=utf-8\r\n" . |
769 | 769 | "MIME-Version: 1.0\r\n" . |
770 | 770 | "Content-Transfer-Encoding: 8bit\r\n" . |
771 | - ($bulk ? "Precedence: bulk\r\nAuto-Submitted: auto-generated\r\n" : "" ). |
|
771 | + ($bulk ? "Precedence: bulk\r\nAuto-Submitted: auto-generated\r\n" : "") . |
|
772 | 772 | "X-Mailer: PHP/" . phpversion(); |
773 | 773 | twfy_debug('EMAIL', "Sending email to $to with subject of '$subject'"); |
774 | 774 | |
775 | 775 | if ($want_bounces) { |
776 | 776 | $envelope_sender = twfy_verp_envelope_sender($to); |
777 | - $success = mail ($to, $subject, $message, $headers, '-f ' . $envelope_sender); |
|
777 | + $success = mail($to, $subject, $message, $headers, '-f ' . $envelope_sender); |
|
778 | 778 | } else { |
779 | - $success = mail ($to, $subject, $message, $headers); |
|
779 | + $success = mail($to, $subject, $message, $headers); |
|
780 | 780 | } |
781 | 781 | |
782 | 782 | return $success; |
@@ -788,7 +788,7 @@ discard block |
||
788 | 788 | // http://www.iamcal.com/publish/article.php?id=13 |
789 | 789 | |
790 | 790 | // Call this with a key name to get a GET or POST variable. |
791 | -function get_http_var($name, $default='') { |
|
791 | +function get_http_var($name, $default = '') { |
|
792 | 792 | if (array_key_exists($name, $_GET)) { |
793 | 793 | return clean_var($_GET[$name]); |
794 | 794 | } |
@@ -814,7 +814,7 @@ discard block |
||
814 | 814 | } |
815 | 815 | |
816 | 816 | // Call this with a key name to get a COOKIE variable. |
817 | -function get_cookie_var($name, $default='') { |
|
817 | +function get_cookie_var($name, $default = '') { |
|
818 | 818 | if (array_key_exists($name, $_COOKIE)) { |
819 | 819 | return clean_var($_COOKIE[$name]); |
820 | 820 | } |
@@ -825,7 +825,7 @@ discard block |
||
825 | 825 | // Pass it an array of key names that should not be generated as |
826 | 826 | // hidden form variables. It then outputs hidden form variables |
827 | 827 | // based on the session_vars for this page. |
828 | -function hidden_form_vars ($omit = array()) { |
|
828 | +function hidden_form_vars($omit = array()) { |
|
829 | 829 | global $DATA, $this_page; |
830 | 830 | |
831 | 831 | $session_vars = $DATA->page_metadata($this_page, "session_vars"); |
@@ -838,7 +838,7 @@ discard block |
||
838 | 838 | } |
839 | 839 | |
840 | 840 | // Deprecated. Use hidden_form_vars, above, instead. |
841 | -function hidden_vars ($omit = array()) { |
|
841 | +function hidden_vars($omit = array()) { |
|
842 | 842 | global $DATA; |
843 | 843 | |
844 | 844 | foreach ($args as $key => $val) { |
@@ -881,7 +881,7 @@ discard block |
||
881 | 881 | function entities_to_numbers($string) { |
882 | 882 | $string = str_replace( |
883 | 883 | array('Ö', 'â', 'ú', 'á', 'í', 'ô', 'é'), |
884 | - array('Ö', 'â', 'ú', 'á', 'í', 'ô', 'é' ), |
|
884 | + array('Ö', 'â', 'ú', 'á', 'í', 'ô', 'é'), |
|
885 | 885 | $string |
886 | 886 | ); |
887 | 887 | return $string; |
@@ -895,9 +895,9 @@ discard block |
||
895 | 895 | return 'elizabeth_the_second'; |
896 | 896 | } |
897 | 897 | |
898 | - $s = array(' ', '&', 'ô', 'Ö', 'ö', 'â', 'í', 'á', 'ú', 'é', 'ó', 'Ó'); |
|
899 | - $s2 = array(" ", "&", "\xc3\xb4", "\xc3\96", "\xc3\xb6", "\xc3\xa5", "\xc3\xad", "\xc3\xa1", "\xc3\xba", "\xc3\xa9", "\xc3\xb3", "\xc3\x93"); |
|
900 | - $r = array('_', 'and', 'o', 'o', 'o', 'a', 'i', 'a', 'u', 'e', 'o', 'o'); |
|
898 | + $s = array(' ', '&', 'ô', 'Ö', 'ö', 'â', 'í', 'á', 'ú', 'é', 'ó', 'Ó'); |
|
899 | + $s2 = array(" ", "&", "\xc3\xb4", "\xc3\96", "\xc3\xb6", "\xc3\xa5", "\xc3\xad", "\xc3\xa1", "\xc3\xba", "\xc3\xa9", "\xc3\xb3", "\xc3\x93"); |
|
900 | + $r = array('_', 'and', 'o', 'o', 'o', 'a', 'i', 'a', 'u', 'e', 'o', 'o'); |
|
901 | 901 | $name = preg_replace('#^the #', '', strtolower($name)); |
902 | 902 | |
903 | 903 | $out = ''; |
@@ -1037,8 +1037,8 @@ discard block |
||
1037 | 1037 | } |
1038 | 1038 | $out .= '<li>' . $body . '<ul>'; |
1039 | 1039 | } else { |
1040 | - $LISTURL->insert( array( 'id' => $gid ) ); |
|
1041 | - $out .= '<li><a href="'.$LISTURL->generate().'">'; |
|
1040 | + $LISTURL->insert(array('id' => $gid)); |
|
1041 | + $out .= '<li><a href="' . $LISTURL->generate() . '">'; |
|
1042 | 1042 | $out .= $body . '</a>'; |
1043 | 1043 | } |
1044 | 1044 | } |
@@ -39,7 +39,8 @@ discard block |
||
39 | 39 | |
40 | 40 | if ($debug_level > count($levels)) { |
41 | 41 | $max_level_to_show = count($levels); |
42 | - } else { |
|
42 | + } |
|
43 | + else { |
|
43 | 44 | $max_level_to_show = $debug_level; |
44 | 45 | } |
45 | 46 | |
@@ -49,7 +50,9 @@ discard block |
||
49 | 50 | |
50 | 51 | // If we can show this header, then, er, show it. |
51 | 52 | if ( in_array($header, $allowed_headers) || $debug_level >= 4) { |
52 | - if (is_array($text)) $text = call_user_func($text); |
|
53 | + if (is_array($text)) { |
|
54 | + $text = call_user_func($text); |
|
55 | + } |
|
53 | 56 | print "<p><span style=\"color:#039;\"><strong>$header</strong></span> $text</p>\n"; |
54 | 57 | } |
55 | 58 | } |
@@ -65,7 +68,9 @@ discard block |
||
65 | 68 | global $PAGE; |
66 | 69 | |
67 | 70 | # Ignore errors we've asked to ignore |
68 | - if (error_reporting()==0) return; |
|
71 | + if (error_reporting()==0) { |
|
72 | + return; |
|
73 | + } |
|
69 | 74 | |
70 | 75 | // define an assoc array of error string |
71 | 76 | // in reality the only entries we should |
@@ -92,17 +97,20 @@ discard block |
||
92 | 97 | $err = ''; |
93 | 98 | if (isset($_SERVER['REQUEST_URI'])) { |
94 | 99 | $err .= "URL:\t\thttps://" . DOMAIN . $_SERVER['REQUEST_URI'] . "\n"; |
95 | - } else { |
|
100 | + } |
|
101 | + else { |
|
96 | 102 | $err .= "URL:\t\tNone - running from command line?\n"; |
97 | 103 | } |
98 | 104 | if (isset($_SERVER['HTTP_REFERER'])) { |
99 | 105 | $err .= "Referer:\t" . $_SERVER['HTTP_REFERER'] . "\n"; |
100 | - } else { |
|
106 | + } |
|
107 | + else { |
|
101 | 108 | $err .= "Referer:\tNone\n"; |
102 | 109 | } |
103 | 110 | if (isset($_SERVER['HTTP_USER_AGENT'])) { |
104 | 111 | $err .= "User-Agent:\t" . $_SERVER['HTTP_USER_AGENT'] . "\n"; |
105 | - } else { |
|
112 | + } |
|
113 | + else { |
|
106 | 114 | $err .= "User-Agent:\tNone\n"; |
107 | 115 | } |
108 | 116 | $err .= "Number:\t\t$errno\n"; |
@@ -143,7 +151,8 @@ discard block |
||
143 | 151 | $fatal_errors = array(E_ERROR, E_USER_ERROR); |
144 | 152 | if (in_array($errno, $fatal_errors)) { |
145 | 153 | $fatal = true; |
146 | - } else { |
|
154 | + } |
|
155 | + else { |
|
147 | 156 | $fatal = false; |
148 | 157 | } |
149 | 158 | |
@@ -161,11 +170,13 @@ discard block |
||
161 | 170 | ); |
162 | 171 | if (is_object($PAGE)) { |
163 | 172 | $PAGE->error_message($message, $fatal); |
164 | - } else { |
|
173 | + } |
|
174 | + else { |
|
165 | 175 | vardump($message); |
166 | 176 | } |
167 | 177 | |
168 | - } else { |
|
178 | + } |
|
179 | + else { |
|
169 | 180 | // On live sites we display a nice message and email the problem. |
170 | 181 | |
171 | 182 | $message = array( |
@@ -175,7 +186,8 @@ discard block |
||
175 | 186 | |
176 | 187 | if (is_object($PAGE)) { |
177 | 188 | $PAGE->error_message($message, $fatal); |
178 | - } else { |
|
189 | + } |
|
190 | + else { |
|
179 | 191 | header('HTTP/1.0 500 Internal Server Error'); |
180 | 192 | print "<p>Oops, sorry, an error has occurred!</p>\n"; |
181 | 193 | } |
@@ -209,19 +221,33 @@ discard block |
||
209 | 221 | array_shift($traceArr); |
210 | 222 | $tabs = sizeof($traceArr)-1; |
211 | 223 | foreach ($traceArr as $arr) { |
212 | - for ($i=0; $i < $tabs; $i++) $s .= ' '; |
|
224 | + for ($i=0; $i < $tabs; $i++) { |
|
225 | + $s .= ' '; |
|
226 | + } |
|
213 | 227 | $tabs -= 1; |
214 | - if (isset($arr['class'])) $s .= $arr['class'].'.'; |
|
228 | + if (isset($arr['class'])) { |
|
229 | + $s .= $arr['class'].'.'; |
|
230 | + } |
|
215 | 231 | $args = array(); |
216 | - if (isset($arr['args'])) foreach ($arr['args'] as $v) { |
|
232 | + if (isset($arr['args'])) { |
|
233 | + foreach ($arr['args'] as $v) { |
|
217 | 234 | if (is_null($v)) $args[] = 'null'; |
218 | - elseif (is_array($v)) $args[] = 'Array['.sizeof($v).']'; |
|
219 | - elseif (is_object($v)) $args[] = 'Object:'.get_class($v); |
|
220 | - elseif (is_bool($v)) $args[] = $v ? 'true' : 'false'; |
|
235 | + } |
|
236 | + elseif (is_array($v)) { |
|
237 | + $args[] = 'Array['.sizeof($v).']'; |
|
238 | + } |
|
239 | + elseif (is_object($v)) { |
|
240 | + $args[] = 'Object:'.get_class($v); |
|
241 | + } |
|
242 | + elseif (is_bool($v)) { |
|
243 | + $args[] = $v ? 'true' : 'false'; |
|
244 | + } |
|
221 | 245 | else { |
222 | 246 | $v = (string) @$v; |
223 | 247 | $str = _htmlspecialchars(substr($v,0,$MAXSTRLEN)); |
224 | - if (strlen($v) > $MAXSTRLEN) $str .= '...'; |
|
248 | + if (strlen($v) > $MAXSTRLEN) { |
|
249 | + $str .= '...'; |
|
250 | + } |
|
225 | 251 | $args[] = $str; |
226 | 252 | } |
227 | 253 | } |
@@ -232,7 +258,9 @@ discard block |
||
232 | 258 | // $arr['line'],$arr['file'],$arr['file']); |
233 | 259 | $s .= "\n"; |
234 | 260 | } |
235 | - if ($print) print $s; |
|
261 | + if ($print) { |
|
262 | + print $s; |
|
263 | + } |
|
236 | 264 | } |
237 | 265 | |
238 | 266 | return $s; |
@@ -245,7 +273,8 @@ discard block |
||
245 | 273 | '[-!#$%&\'*.\\+\/0-9=?A-Z^_`a-z{|}~]+\.'. |
246 | 274 | '[-!#$%&\'*+\\.\/0-9=?A-Z^_`a-z{|}~]+$/', $string)) { |
247 | 275 | return false; |
248 | - } else { |
|
276 | + } |
|
277 | + else { |
|
249 | 278 | return true; |
250 | 279 | } |
251 | 280 | } |
@@ -272,7 +301,8 @@ discard block |
||
272 | 301 | preg_match("/^[$fst][$sec][$num][$fth][$gap]*[$nom][$in][$in]$/i", $postcode) |
273 | 302 | ) { |
274 | 303 | return true; |
275 | - } else { |
|
304 | + } |
|
305 | + else { |
|
276 | 306 | return false; |
277 | 307 | } |
278 | 308 | } |
@@ -308,7 +338,8 @@ discard block |
||
308 | 338 | list($string, $year, $month, $day, $hour, $min, $sec) = $matches; |
309 | 339 | |
310 | 340 | return gmdate ($format, gmmktime($hour, $min, $sec, $month, $day, $year)); |
311 | - } else { |
|
341 | + } |
|
342 | + else { |
|
312 | 343 | return ""; |
313 | 344 | } |
314 | 345 | |
@@ -326,16 +357,19 @@ discard block |
||
326 | 357 | |
327 | 358 | if (preg_match("/^(\d\d\d\d)-(\d\d?)-(\d\d?)$/", $date, $matches)) { |
328 | 359 | list($string, $year, $month, $day) = $matches; |
329 | - if ($year < 1902) { # gmdate fns only go back to Dec. 1901 |
|
360 | + if ($year < 1902) { |
|
361 | +# gmdate fns only go back to Dec. 1901 |
|
330 | 362 | if ($format == SHORTDATEFORMAT) { |
331 | 363 | return ($day+0) . ' ' . $format_date_months_short[$month+0] . " $year"; |
332 | - } else { |
|
364 | + } |
|
365 | + else { |
|
333 | 366 | return ($day+0) . ' ' . $format_date_months[$month+0] . " $year"; |
334 | 367 | } |
335 | 368 | } |
336 | 369 | |
337 | 370 | return gmdate ($format, gmmktime(0, 0, 0, $month, $day, $year)); |
338 | - } else { |
|
371 | + } |
|
372 | + else { |
|
339 | 373 | return ""; |
340 | 374 | } |
341 | 375 | |
@@ -351,7 +385,8 @@ discard block |
||
351 | 385 | list($string, $hour, $min, $sec) = $matches; |
352 | 386 | |
353 | 387 | return gmdate ($format, gmmktime($hour, $min, $sec)); |
354 | - } else { |
|
388 | + } |
|
389 | + else { |
|
355 | 390 | return ""; |
356 | 391 | } |
357 | 392 | } |
@@ -390,24 +425,29 @@ discard block |
||
390 | 425 | $date = substr($datetime, 0, 10); |
391 | 426 | return format_date($date, LONGDATEFORMAT); |
392 | 427 | |
393 | - } else { |
|
428 | + } |
|
429 | + else { |
|
394 | 430 | $relative_date = ''; |
395 | 431 | if ($weeks > 0) { |
396 | 432 | // Weeks and days |
397 | 433 | $relative_date .= ($relative_date?', ':'').$weeks.' week'.($weeks>1?'s':''); |
398 | 434 | $relative_date .= $days>0?($relative_date?', ':'').$days.' day'.($days>1?'s':''):''; |
399 | - } elseif ($days > 0) { |
|
435 | + } |
|
436 | + elseif ($days > 0) { |
|
400 | 437 | // days and hours |
401 | 438 | $relative_date .= ($relative_date?', ':'').$days.' day'.($days>1?'s':''); |
402 | 439 | $relative_date .= $hours>0?($relative_date?', ':'').$hours.' hour'.($hours>1?'s':''):''; |
403 | - } elseif ($hours > 0) { |
|
440 | + } |
|
441 | + elseif ($hours > 0) { |
|
404 | 442 | // hours and minutes |
405 | 443 | $relative_date .= ($relative_date?', ':'').$hours.' hour'.($hours>1?'s':''); |
406 | 444 | $relative_date .= $minutes>0?($relative_date?', ':'').$minutes.' minute'.($minutes>1?'s':''):''; |
407 | - } elseif ($minutes > 0) { |
|
445 | + } |
|
446 | + elseif ($minutes > 0) { |
|
408 | 447 | // minutes only |
409 | 448 | $relative_date .= ($relative_date?', ':'').$minutes.' minute'.($minutes>1?'s':''); |
410 | - } else { |
|
449 | + } |
|
450 | + else { |
|
411 | 451 | // seconds only |
412 | 452 | $relative_date .= ($relative_date?', ':'').$seconds.' second'.($seconds>1?'s':''); |
413 | 453 | } |
@@ -506,7 +546,8 @@ discard block |
||
506 | 546 | if ($filter_type == 'strict') { |
507 | 547 | // No tags allowed at all! |
508 | 548 | $filter->allowed = array (); |
509 | - } else { |
|
549 | + } |
|
550 | + else { |
|
510 | 551 | // Comment. |
511 | 552 | // Only allowing <a href>, <b>, <strong>, <i> and <em> |
512 | 553 | $filter->allowed = array ( |
@@ -541,7 +582,8 @@ discard block |
||
541 | 582 | function($matches) use ($link_length) { |
542 | 583 | if (strlen($matches[0]) > $link_length) { |
543 | 584 | return '<a href="' . $matches[0] . '" rel="nofollow">' . substr($matches[0], 0, $link_length) . "...</a>"; |
544 | - } else { |
|
585 | + } |
|
586 | + else { |
|
545 | 587 | return '<a href="' . $matches[0] . '" rel="nofollow">' . $matches[0] . '</a>'; |
546 | 588 | } |
547 | 589 | }, |
@@ -607,7 +649,8 @@ discard block |
||
607 | 649 | $q = $db->query("SELECT gid_to FROM gidredirect WHERE gid_from = :gid", array(':gid' => $gid)); |
608 | 650 | if ($q->rows() > 0) { |
609 | 651 | $gid = $q->field(0, 'gid_to'); |
610 | - } else { |
|
652 | + } |
|
653 | + else { |
|
611 | 654 | $might_be_redirected = false; |
612 | 655 | } |
613 | 656 | } |
@@ -632,7 +675,8 @@ discard block |
||
632 | 675 | if ($keepmajor) { |
633 | 676 | $newgid = substr($gid, strpos($gid, '/')+1 ); |
634 | 677 | $newgid = str_replace('/', '_', $newgid); |
635 | - } else { |
|
678 | + } |
|
679 | + else { |
|
636 | 680 | $newgid = substr($gid, strrpos($gid, '/')+1 ); |
637 | 681 | } |
638 | 682 | |
@@ -714,16 +758,19 @@ discard block |
||
714 | 758 | if (preg_match("/Subject:/", $firstline)) { |
715 | 759 | if (isset($data['subject'])) { |
716 | 760 | $subject = trim($data['subject']); |
717 | - } else { |
|
761 | + } |
|
762 | + else { |
|
718 | 763 | $subject = trim( substr($firstline, 8) ); |
719 | 764 | } |
720 | 765 | |
721 | 766 | // Either way, remove this subject line from the template. |
722 | 767 | $emailtext = substr($emailtext, strpos($emailtext, "\n")); |
723 | 768 | |
724 | - } elseif (isset($data['subject'])) { |
|
769 | + } |
|
770 | + elseif (isset($data['subject'])) { |
|
725 | 771 | $subject = $data['subject']; |
726 | - } else { |
|
772 | + } |
|
773 | + else { |
|
727 | 774 | $PAGE->error_message ("We don't have a subject line for the email, so it wasn't sent."); |
728 | 775 | return false; |
729 | 776 | } |
@@ -761,7 +808,9 @@ discard block |
||
761 | 808 | // easily to all the emails we send out from the site. |
762 | 809 | // eg, we might want to add a .sig to everything here... |
763 | 810 | |
764 | - if (!$from) $from = CONTACTEMAIL; |
|
811 | + if (!$from) { |
|
812 | + $from = CONTACTEMAIL; |
|
813 | + } |
|
765 | 814 | |
766 | 815 | $headers = |
767 | 816 | "From: TheyWorkForYou <$from>\r\n" . |
@@ -775,7 +824,8 @@ discard block |
||
775 | 824 | if ($want_bounces) { |
776 | 825 | $envelope_sender = twfy_verp_envelope_sender($to); |
777 | 826 | $success = mail ($to, $subject, $message, $headers, '-f ' . $envelope_sender); |
778 | - } else { |
|
827 | + } |
|
828 | + else { |
|
779 | 829 | $success = mail ($to, $subject, $message, $headers); |
780 | 830 | } |
781 | 831 | |
@@ -807,7 +857,8 @@ discard block |
||
807 | 857 | while (list($key, $val) = each($a)) { |
808 | 858 | $a[$key] = recursive_strip($val); |
809 | 859 | } |
810 | - } else { |
|
860 | + } |
|
861 | + else { |
|
811 | 862 | $a = StripSlashes($a); |
812 | 863 | } |
813 | 864 | return $a; |
@@ -853,17 +904,21 @@ discard block |
||
853 | 904 | $rank = $rank + 0; |
854 | 905 | |
855 | 906 | # 11th, 12th, 13th use "th" not "st", "nd", "rd" |
856 | - if (floor(($rank % 100) / 10) == 1) |
|
857 | - return $rank . "th"; |
|
907 | + if (floor(($rank % 100) / 10) == 1) { |
|
908 | + return $rank . "th"; |
|
909 | + } |
|
858 | 910 | # 1st |
859 | - if ($rank % 10 == 1) |
|
860 | - return $rank . "st"; |
|
911 | + if ($rank % 10 == 1) { |
|
912 | + return $rank . "st"; |
|
913 | + } |
|
861 | 914 | # 2nd |
862 | - if ($rank % 10 == 2) |
|
863 | - return $rank . "nd"; |
|
915 | + if ($rank % 10 == 2) { |
|
916 | + return $rank . "nd"; |
|
917 | + } |
|
864 | 918 | # 3rd |
865 | - if ($rank % 10 == 3) |
|
866 | - return $rank . "rd"; |
|
919 | + if ($rank % 10 == 3) { |
|
920 | + return $rank . "rd"; |
|
921 | + } |
|
867 | 922 | # Everything else use th |
868 | 923 | |
869 | 924 | return $rank . "th"; |
@@ -871,8 +926,9 @@ discard block |
||
871 | 926 | |
872 | 927 | function make_plural($word, $number) |
873 | 928 | { |
874 | - if ($number == 1) |
|
875 | - return $word; |
|
929 | + if ($number == 1) { |
|
930 | + return $word; |
|
931 | + } |
|
876 | 932 | return $word . "s"; |
877 | 933 | } |
878 | 934 | |
@@ -890,8 +946,7 @@ discard block |
||
890 | 946 | function make_member_url($name, $const = '', $house = HOUSE_TYPE_COMMONS, $pid = NULL) { |
891 | 947 | |
892 | 948 | // Case for Elizabeth II |
893 | - if ($house == HOUSE_TYPE_ROYAL) |
|
894 | - { |
|
949 | + if ($house == HOUSE_TYPE_ROYAL) { |
|
895 | 950 | return 'elizabeth_the_second'; |
896 | 951 | } |
897 | 952 | |
@@ -903,8 +958,7 @@ discard block |
||
903 | 958 | $out = ''; |
904 | 959 | |
905 | 960 | // Insert the Person ID if known. |
906 | - if ($pid !== NULL) |
|
907 | - { |
|
961 | + if ($pid !== NULL) { |
|
908 | 962 | $out .= $pid . '/'; |
909 | 963 | } |
910 | 964 | |
@@ -912,8 +966,7 @@ discard block |
||
912 | 966 | $out .= urlencode(str_replace($s2, $r, str_replace($s, $r, $name))); |
913 | 967 | |
914 | 968 | // If there is a constituency, inject that too |
915 | - if ($const && $house == HOUSE_TYPE_COMMONS) |
|
916 | - { |
|
969 | + if ($const && $house == HOUSE_TYPE_COMMONS) { |
|
917 | 970 | $out .= '/' . urlencode(str_replace($s2, $r, str_replace($s, $r, strtolower($const)))); |
918 | 971 | } |
919 | 972 | |
@@ -927,13 +980,22 @@ discard block |
||
927 | 980 | if ($title) { |
928 | 981 | $s = $title . ' ' . $s; |
929 | 982 | } |
930 | - } elseif ($house == HOUSE_TYPE_LORDS) { |
|
983 | + } |
|
984 | + elseif ($house == HOUSE_TYPE_LORDS) { |
|
931 | 985 | $s = ''; |
932 | - if (!$family_name) $s = 'the '; |
|
986 | + if (!$family_name) { |
|
987 | + $s = 'the '; |
|
988 | + } |
|
933 | 989 | $s .= $title; |
934 | - if ($family_name) $s .= ' ' . $family_name; |
|
935 | - if ($lordofname) $s .= ' of ' . $lordofname; |
|
936 | - } elseif ($house == HOUSE_TYPE_ROYAL) { # Queen |
|
990 | + if ($family_name) { |
|
991 | + $s .= ' ' . $family_name; |
|
992 | + } |
|
993 | + if ($lordofname) { |
|
994 | + $s .= ' of ' . $lordofname; |
|
995 | + } |
|
996 | + } |
|
997 | + elseif ($house == HOUSE_TYPE_ROYAL) { |
|
998 | +# Queen |
|
937 | 999 | $s = "$given_name $family_name"; |
938 | 1000 | } |
939 | 1001 | return $s; |
@@ -962,12 +1024,18 @@ discard block |
||
962 | 1024 | 'Lords in Waiting (HM Household)' => 'Government Whip', |
963 | 1025 | 'Baronesses in Waiting, HM Household' => 'Government Whip', |
964 | 1026 | ); |
965 | - if ($pos) { # Government post, or Chairman of Select Committee |
|
1027 | + if ($pos) { |
|
1028 | +# Government post, or Chairman of Select Committee |
|
966 | 1029 | $pretty = $pos; |
967 | - if ($dept && $dept != 'No Department') $pretty .= ", $dept"; |
|
968 | - if (array_key_exists($pretty, $lookup)) |
|
969 | - $pretty = $lookup[$pretty]; |
|
970 | - } else { # Member of Select Committee |
|
1030 | + if ($dept && $dept != 'No Department') { |
|
1031 | + $pretty .= ", $dept"; |
|
1032 | + } |
|
1033 | + if (array_key_exists($pretty, $lookup)) { |
|
1034 | + $pretty = $lookup[$pretty]; |
|
1035 | + } |
|
1036 | + } |
|
1037 | + else { |
|
1038 | +# Member of Select Committee |
|
971 | 1039 | $pretty = "Member, $dept"; |
972 | 1040 | } |
973 | 1041 | return $pretty; |
@@ -985,13 +1053,16 @@ discard block |
||
985 | 1053 | } |
986 | 1054 | |
987 | 1055 | // single date? |
988 | - if (isset($data['date'])) $one_date = true; |
|
1056 | + if (isset($data['date'])) { |
|
1057 | + $one_date = true; |
|
1058 | + } |
|
989 | 1059 | |
990 | 1060 | // remove empty entries, so they don't produce errors |
991 | 1061 | foreach (array_keys($hansardmajors) as $major) { |
992 | 1062 | if (array_key_exists($major, $data)) { |
993 | - if (count($data[$major]) == 0) |
|
994 | - unset($data[$major]); |
|
1063 | + if (count($data[$major]) == 0) { |
|
1064 | + unset($data[$major]); |
|
1065 | + } |
|
995 | 1066 | } |
996 | 1067 | } |
997 | 1068 | |
@@ -1000,22 +1071,33 @@ discard block |
||
1000 | 1071 | if (!$one_date) { |
1001 | 1072 | $todaystime = gmmktime(0, 0, 0, date('m'), date('d'), date('Y')); |
1002 | 1073 | foreach ($data as $major => $array) { |
1003 | - if (!in_array('timestamp', $array)) $daytext[$major] = "The most recent "; |
|
1004 | - elseif ($todaystime - $array['timestamp'] == 86400) $daytext[$major] = "Yesterday’s"; |
|
1005 | - elseif ($todaystime - $array['timestamp'] <= (6 * 86400)) $daytext[$major] = gmdate('l', $array['timestamp']) . "’s"; |
|
1006 | - else $daytext[$major] = "The most recent "; |
|
1074 | + if (!in_array('timestamp', $array)) { |
|
1075 | + $daytext[$major] = "The most recent "; |
|
1076 | + } |
|
1077 | + elseif ($todaystime - $array['timestamp'] == 86400) { |
|
1078 | + $daytext[$major] = "Yesterday’s"; |
|
1079 | + } |
|
1080 | + elseif ($todaystime - $array['timestamp'] <= (6 * 86400)) { |
|
1081 | + $daytext[$major] = gmdate('l', $array['timestamp']) . "’s"; |
|
1082 | + } |
|
1083 | + else { |
|
1084 | + $daytext[$major] = "The most recent "; |
|
1085 | + } |
|
1007 | 1086 | } |
1008 | 1087 | } |
1009 | 1088 | |
1010 | 1089 | //build html |
1011 | 1090 | foreach ($printed_majors as $p_major) { |
1012 | - if (!array_key_exists($p_major, $data)) |
|
1013 | - continue; |
|
1091 | + if (!array_key_exists($p_major, $data)) { |
|
1092 | + continue; |
|
1093 | + } |
|
1014 | 1094 | |
1015 | - if ($one_date) |
|
1016 | - $date = $data['date']; |
|
1017 | - else |
|
1018 | - $date = $data[$p_major]['hdate']; |
|
1095 | + if ($one_date) { |
|
1096 | + $date = $data['date']; |
|
1097 | + } |
|
1098 | + else { |
|
1099 | + $date = $data[$p_major]['hdate']; |
|
1100 | + } |
|
1019 | 1101 | $q = $db->query('SELECT section_id, body, gid |
1020 | 1102 | FROM hansard, epobject |
1021 | 1103 | WHERE hansard.epobject_id = epobject.epobject_id ' |
@@ -1036,7 +1118,8 @@ discard block |
||
1036 | 1118 | $out .= '</ul>'; |
1037 | 1119 | } |
1038 | 1120 | $out .= '<li>' . $body . '<ul>'; |
1039 | - } else { |
|
1121 | + } |
|
1122 | + else { |
|
1040 | 1123 | $LISTURL->insert( array( 'id' => $gid ) ); |
1041 | 1124 | $out .= '<li><a href="'.$LISTURL->generate().'">'; |
1042 | 1125 | $out .= $body . '</a>'; |
@@ -1053,7 +1136,8 @@ discard block |
||
1053 | 1136 | |
1054 | 1137 | if ($echo) { |
1055 | 1138 | print $html; |
1056 | - } else { |
|
1139 | + } |
|
1140 | + else { |
|
1057 | 1141 | return $html; |
1058 | 1142 | } |
1059 | 1143 | } |
@@ -1067,14 +1151,17 @@ discard block |
||
1067 | 1151 | } |
1068 | 1152 | |
1069 | 1153 | $return .= '<a href="'; |
1070 | - if (isset($data[$major]['listurl'])) |
|
1071 | - $return .= $data[$major]['listurl']; |
|
1154 | + if (isset($data[$major]['listurl'])) { |
|
1155 | + $return .= $data[$major]['listurl']; |
|
1156 | + } |
|
1072 | 1157 | else { |
1073 | 1158 | $LISTURL->reset(); |
1074 | 1159 | $return .= $LISTURL->generate(); |
1075 | 1160 | } |
1076 | 1161 | $return .= '">' . $hansardmajors[$major]['title'] . '</a>'; |
1077 | - if (isset($daytext[$major])) $return; |
|
1162 | + if (isset($daytext[$major])) { |
|
1163 | + $return; |
|
1164 | + } |
|
1078 | 1165 | $return .= '</h4>'; |
1079 | 1166 | |
1080 | 1167 | return $return; |
@@ -1082,20 +1169,27 @@ discard block |
||
1082 | 1169 | |
1083 | 1170 | function score_to_strongly($dmpscore) { |
1084 | 1171 | $dmpdesc = "unknown about"; |
1085 | - if ($dmpscore > 0.95 && $dmpscore <= 1.0) |
|
1086 | - $dmpdesc = "consistently voted against"; |
|
1087 | - elseif ($dmpscore > 0.85) |
|
1088 | - $dmpdesc = "almost always voted against"; |
|
1089 | - elseif ($dmpscore > 0.6) |
|
1090 | - $dmpdesc = "generally voted against"; |
|
1091 | - elseif ($dmpscore > 0.4) |
|
1092 | - $dmpdesc = "voted a mixture of for and against"; |
|
1093 | - elseif ($dmpscore > 0.15) |
|
1094 | - $dmpdesc = "generally voted for"; |
|
1095 | - elseif ($dmpscore > 0.05) |
|
1096 | - $dmpdesc = "almost always voted for"; |
|
1097 | - elseif ($dmpscore >= 0.0) |
|
1098 | - $dmpdesc = "consistently voted for"; |
|
1172 | + if ($dmpscore > 0.95 && $dmpscore <= 1.0) { |
|
1173 | + $dmpdesc = "consistently voted against"; |
|
1174 | + } |
|
1175 | + elseif ($dmpscore > 0.85) { |
|
1176 | + $dmpdesc = "almost always voted against"; |
|
1177 | + } |
|
1178 | + elseif ($dmpscore > 0.6) { |
|
1179 | + $dmpdesc = "generally voted against"; |
|
1180 | + } |
|
1181 | + elseif ($dmpscore > 0.4) { |
|
1182 | + $dmpdesc = "voted a mixture of for and against"; |
|
1183 | + } |
|
1184 | + elseif ($dmpscore > 0.15) { |
|
1185 | + $dmpdesc = "generally voted for"; |
|
1186 | + } |
|
1187 | + elseif ($dmpscore > 0.05) { |
|
1188 | + $dmpdesc = "almost always voted for"; |
|
1189 | + } |
|
1190 | + elseif ($dmpscore >= 0.0) { |
|
1191 | + $dmpdesc = "consistently voted for"; |
|
1192 | + } |
|
1099 | 1193 | return $dmpdesc; |
1100 | 1194 | } |
1101 | 1195 | |
@@ -1110,7 +1204,8 @@ discard block |
||
1110 | 1204 | function redirect($url) { |
1111 | 1205 | if (defined('TESTING')) { |
1112 | 1206 | print "Location: $url"; |
1113 | - } else { |
|
1207 | + } |
|
1208 | + else { |
|
1114 | 1209 | header("Location: $url", true, 301); |
1115 | 1210 | } |
1116 | 1211 | exit; |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | ); |
125 | 125 | $hansardmajors[104] = $hansardmajors[4]; |
126 | 126 | |
127 | -$parties = array ( |
|
127 | +$parties = array( |
|
128 | 128 | 'Bp' => 'Bishop', |
129 | 129 | 'Con' => 'Conservative', |
130 | 130 | 'CWM' => 'Deputy Speaker', |
@@ -166,9 +166,9 @@ discard block |
||
166 | 166 | */ |
167 | 167 | |
168 | 168 | // Constants for various house types |
169 | -define ('HOUSE_TYPE_ROYAL', 0); |
|
170 | -define ('HOUSE_TYPE_COMMONS', 1); |
|
171 | -define ('HOUSE_TYPE_LORDS', 2); |
|
172 | -define ('HOUSE_TYPE_NI', 3); |
|
173 | -define ('HOUSE_TYPE_SCOTLAND', 4); |
|
174 | -define ('HOUSE_TYPE_WALES', 5); |
|
169 | +define('HOUSE_TYPE_ROYAL', 0); |
|
170 | +define('HOUSE_TYPE_COMMONS', 1); |
|
171 | +define('HOUSE_TYPE_LORDS', 2); |
|
172 | +define('HOUSE_TYPE_NI', 3); |
|
173 | +define('HOUSE_TYPE_SCOTLAND', 4); |
|
174 | +define('HOUSE_TYPE_WALES', 5); |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | <p></p> |
17 | 17 | <?php |
18 | 18 | |
19 | -$PAGE->block_start(array ('title'=>'Share this with your friends')); |
|
19 | +$PAGE->block_start(array('title'=>'Share this with your friends')); |
|
20 | 20 | |
21 | 21 | #foi2009_sharethis_link(); |
22 | 22 | #foi2009_share_page(); |
@@ -25,4 +25,4 @@ discard block |
||
25 | 25 | |
26 | 26 | $PAGE->block_end(); |
27 | 27 | $PAGE->stripe_end(); |
28 | -$PAGE->page_end (); |
|
28 | +$PAGE->page_end(); |
@@ -7,7 +7,7 @@ |
||
7 | 7 | |
8 | 8 | $PAGE->page_start(); |
9 | 9 | $PAGE->stripe_start(); |
10 | -$PAGE->block_start(array ('id'=>'intro', 'title'=>'We need your help:')); |
|
10 | +$PAGE->block_start(array('id'=>'intro', 'title'=>'We need your help:')); |
|
11 | 11 | |
12 | 12 | echo '<div id="foi2009">'; |
13 | 13 | echo $foi2009_message; |
@@ -14,7 +14,7 @@ |
||
14 | 14 | } elseif ($constituency == "") { |
15 | 15 | $errors['pc'] = "Sorry, " . _htmlentities($pc) . " isn't a known postcode"; |
16 | 16 | twfy_debug ('MP', "Can't display an MP, as submitted postcode didn't match a constituency"); |
17 | - } else { |
|
17 | + } else { |
|
18 | 18 | $MEMBER = new MEMBER(array('constituency' => $constituency)); |
19 | 19 | if ($MEMBER->person_id()) { |
20 | 20 | // This will cookie the postcode. |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | include_once '../../includes/easyparliament/init.php'; |
4 | -include_once INCLUDESPATH."easyparliament/member.php"; |
|
4 | +include_once INCLUDESPATH . "easyparliament/member.php"; |
|
5 | 5 | |
6 | 6 | $pc = get_http_var('pc'); |
7 | 7 | $pc = preg_replace('#[^a-z0-9 ]#i', '', $pc); |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | $errors['pc'] = "Sorry, we couldn't check your postcode right now. Please use the 'All Mps' link above to browse MPs"; |
14 | 14 | } elseif ($constituency == "") { |
15 | 15 | $errors['pc'] = "Sorry, " . _htmlentities($pc) . " isn't a known postcode"; |
16 | - twfy_debug ('MP', "Can't display an MP, as submitted postcode didn't match a constituency"); |
|
16 | + twfy_debug('MP', "Can't display an MP, as submitted postcode didn't match a constituency"); |
|
17 | 17 | } else { |
18 | 18 | $MEMBER = new MEMBER(array('constituency' => $constituency)); |
19 | 19 | if ($MEMBER->person_id()) { |
@@ -27,5 +27,5 @@ discard block |
||
27 | 27 | } |
28 | 28 | } else { |
29 | 29 | $errors['pc'] = "Sorry, " . _htmlentities($pc) . " isn't a valid postcode"; |
30 | - twfy_debug ('MP', "Can't display an MP because the submitted postcode wasn't of a valid form."); |
|
30 | + twfy_debug('MP', "Can't display an MP because the submitted postcode wasn't of a valid form."); |
|
31 | 31 | } |
@@ -5,16 +5,20 @@ discard block |
||
5 | 5 | |
6 | 6 | $pc = get_http_var('pc'); |
7 | 7 | $pc = preg_replace('#[^a-z0-9 ]#i', '', $pc); |
8 | -if (!$pc) exit; |
|
8 | +if (!$pc) { |
|
9 | + exit; |
|
10 | +} |
|
9 | 11 | |
10 | 12 | if (validate_postcode($pc)) { |
11 | 13 | $constituency = strtolower(MySociety\TheyWorkForYou\Utility\Postcode::postcodeToConstituency($pc)); |
12 | 14 | if ($constituency == "CONNECTION_TIMED_OUT") { |
13 | 15 | $errors['pc'] = "Sorry, we couldn't check your postcode right now. Please use the 'All Mps' link above to browse MPs"; |
14 | - } elseif ($constituency == "") { |
|
16 | + } |
|
17 | + elseif ($constituency == "") { |
|
15 | 18 | $errors['pc'] = "Sorry, " . _htmlentities($pc) . " isn't a known postcode"; |
16 | 19 | twfy_debug ('MP', "Can't display an MP, as submitted postcode didn't match a constituency"); |
17 | - } else { |
|
20 | + } |
|
21 | + else { |
|
18 | 22 | $MEMBER = new MEMBER(array('constituency' => $constituency)); |
19 | 23 | if ($MEMBER->person_id()) { |
20 | 24 | // This will cookie the postcode. |
@@ -25,7 +29,8 @@ discard block |
||
25 | 29 | header('Location: /rss/mp/' . $MEMBER->person_id() . '.rdf'); |
26 | 30 | } |
27 | 31 | } |
28 | - } else { |
|
32 | + } |
|
33 | + else { |
|
29 | 34 | $errors['pc'] = "Sorry, " . _htmlentities($pc) . " isn't a valid postcode"; |
30 | 35 | twfy_debug ('MP', "Can't display an MP because the submitted postcode wasn't of a valid form."); |
31 | 36 | } |