@@ -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 | } |
@@ -49,7 +49,9 @@ discard block |
||
49 | 49 | |
50 | 50 | // If we can show this header, then, er, show it. |
51 | 51 | if ( in_array($header, $allowed_headers) || $debug_level >= 4) { |
52 | - if (is_array($text)) $text = call_user_func($text); |
|
52 | + if (is_array($text)) { |
|
53 | + $text = call_user_func($text); |
|
54 | + } |
|
53 | 55 | print "<p><span style=\"color:#039;\"><strong>$header</strong></span> $text</p>\n"; |
54 | 56 | } |
55 | 57 | } |
@@ -65,7 +67,9 @@ discard block |
||
65 | 67 | global $PAGE; |
66 | 68 | |
67 | 69 | # Ignore errors we've asked to ignore |
68 | - if (error_reporting()==0) return; |
|
70 | + if (error_reporting()==0) { |
|
71 | + return; |
|
72 | + } |
|
69 | 73 | |
70 | 74 | // define an assoc array of error string |
71 | 75 | // in reality the only entries we should |
@@ -209,19 +213,29 @@ discard block |
||
209 | 213 | array_shift($traceArr); |
210 | 214 | $tabs = sizeof($traceArr)-1; |
211 | 215 | foreach ($traceArr as $arr) { |
212 | - for ($i=0; $i < $tabs; $i++) $s .= ' '; |
|
216 | + for ($i=0; $i < $tabs; $i++) { |
|
217 | + $s .= ' '; |
|
218 | + } |
|
213 | 219 | $tabs -= 1; |
214 | - if (isset($arr['class'])) $s .= $arr['class'].'.'; |
|
220 | + if (isset($arr['class'])) { |
|
221 | + $s .= $arr['class'].'.'; |
|
222 | + } |
|
215 | 223 | $args = array(); |
216 | - if (isset($arr['args'])) foreach ($arr['args'] as $v) { |
|
224 | + if (isset($arr['args'])) { |
|
225 | + foreach ($arr['args'] as $v) { |
|
217 | 226 | 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'; |
|
221 | - else { |
|
227 | + } elseif (is_array($v)) { |
|
228 | + $args[] = 'Array['.sizeof($v).']'; |
|
229 | + } elseif (is_object($v)) { |
|
230 | + $args[] = 'Object:'.get_class($v); |
|
231 | + } elseif (is_bool($v)) { |
|
232 | + $args[] = $v ? 'true' : 'false'; |
|
233 | + } else { |
|
222 | 234 | $v = (string) @$v; |
223 | 235 | $str = _htmlspecialchars(substr($v,0,$MAXSTRLEN)); |
224 | - if (strlen($v) > $MAXSTRLEN) $str .= '...'; |
|
236 | + if (strlen($v) > $MAXSTRLEN) { |
|
237 | + $str .= '...'; |
|
238 | + } |
|
225 | 239 | $args[] = $str; |
226 | 240 | } |
227 | 241 | } |
@@ -232,7 +246,9 @@ discard block |
||
232 | 246 | // $arr['line'],$arr['file'],$arr['file']); |
233 | 247 | $s .= "\n"; |
234 | 248 | } |
235 | - if ($print) print $s; |
|
249 | + if ($print) { |
|
250 | + print $s; |
|
251 | + } |
|
236 | 252 | } |
237 | 253 | |
238 | 254 | return $s; |
@@ -326,7 +342,8 @@ discard block |
||
326 | 342 | |
327 | 343 | if (preg_match("/^(\d\d\d\d)-(\d\d?)-(\d\d?)$/", $date, $matches)) { |
328 | 344 | list($string, $year, $month, $day) = $matches; |
329 | - if ($year < 1902) { # gmdate fns only go back to Dec. 1901 |
|
345 | + if ($year < 1902) { |
|
346 | +# gmdate fns only go back to Dec. 1901 |
|
330 | 347 | if ($format == SHORTDATEFORMAT) { |
331 | 348 | return ($day+0) . ' ' . $format_date_months_short[$month+0] . " $year"; |
332 | 349 | } else { |
@@ -755,7 +772,9 @@ discard block |
||
755 | 772 | // easily to all the emails we send out from the site. |
756 | 773 | // eg, we might want to add a .sig to everything here... |
757 | 774 | |
758 | - if (!$from) $from = CONTACTEMAIL; |
|
775 | + if (!$from) { |
|
776 | + $from = CONTACTEMAIL; |
|
777 | + } |
|
759 | 778 | |
760 | 779 | $headers = |
761 | 780 | "From: TheyWorkForYou <$from>\r\n" . |
@@ -847,17 +866,21 @@ discard block |
||
847 | 866 | $rank = $rank + 0; |
848 | 867 | |
849 | 868 | # 11th, 12th, 13th use "th" not "st", "nd", "rd" |
850 | - if (floor(($rank % 100) / 10) == 1) |
|
851 | - return $rank . "th"; |
|
869 | + if (floor(($rank % 100) / 10) == 1) { |
|
870 | + return $rank . "th"; |
|
871 | + } |
|
852 | 872 | # 1st |
853 | - if ($rank % 10 == 1) |
|
854 | - return $rank . "st"; |
|
873 | + if ($rank % 10 == 1) { |
|
874 | + return $rank . "st"; |
|
875 | + } |
|
855 | 876 | # 2nd |
856 | - if ($rank % 10 == 2) |
|
857 | - return $rank . "nd"; |
|
877 | + if ($rank % 10 == 2) { |
|
878 | + return $rank . "nd"; |
|
879 | + } |
|
858 | 880 | # 3rd |
859 | - if ($rank % 10 == 3) |
|
860 | - return $rank . "rd"; |
|
881 | + if ($rank % 10 == 3) { |
|
882 | + return $rank . "rd"; |
|
883 | + } |
|
861 | 884 | # Everything else use th |
862 | 885 | |
863 | 886 | return $rank . "th"; |
@@ -865,8 +888,9 @@ discard block |
||
865 | 888 | |
866 | 889 | function make_plural($word, $number) |
867 | 890 | { |
868 | - if ($number == 1) |
|
869 | - return $word; |
|
891 | + if ($number == 1) { |
|
892 | + return $word; |
|
893 | + } |
|
870 | 894 | return $word . "s"; |
871 | 895 | } |
872 | 896 | |
@@ -884,8 +908,7 @@ discard block |
||
884 | 908 | function make_member_url($name, $const = '', $house = HOUSE_TYPE_COMMONS, $pid = NULL) { |
885 | 909 | |
886 | 910 | // Case for Elizabeth II |
887 | - if ($house == HOUSE_TYPE_ROYAL) |
|
888 | - { |
|
911 | + if ($house == HOUSE_TYPE_ROYAL) { |
|
889 | 912 | return 'elizabeth_the_second'; |
890 | 913 | } |
891 | 914 | |
@@ -897,8 +920,7 @@ discard block |
||
897 | 920 | $out = ''; |
898 | 921 | |
899 | 922 | // Insert the Person ID if known. |
900 | - if ($pid !== NULL) |
|
901 | - { |
|
923 | + if ($pid !== NULL) { |
|
902 | 924 | $out .= $pid . '/'; |
903 | 925 | } |
904 | 926 | |
@@ -906,8 +928,7 @@ discard block |
||
906 | 928 | $out .= urlencode(str_replace($s2, $r, str_replace($s, $r, $name))); |
907 | 929 | |
908 | 930 | // If there is a constituency, inject that too |
909 | - if ($const && $house == HOUSE_TYPE_COMMONS) |
|
910 | - { |
|
931 | + if ($const && $house == HOUSE_TYPE_COMMONS) { |
|
911 | 932 | $out .= '/' . urlencode(str_replace($s2, $r, str_replace($s, $r, strtolower($const)))); |
912 | 933 | } |
913 | 934 | |
@@ -919,10 +940,16 @@ discard block |
||
919 | 940 | switch ($house) { |
920 | 941 | case HOUSE_TYPE_LORDS: |
921 | 942 | $s = ''; |
922 | - if (!$family_name) $s = 'the '; |
|
943 | + if (!$family_name) { |
|
944 | + $s = 'the '; |
|
945 | + } |
|
923 | 946 | $s .= $title; |
924 | - if ($family_name) $s .= ' ' . $family_name; |
|
925 | - if ($lordofname) $s .= ' of ' . $lordofname; |
|
947 | + if ($family_name) { |
|
948 | + $s .= ' ' . $family_name; |
|
949 | + } |
|
950 | + if ($lordofname) { |
|
951 | + $s .= ' of ' . $lordofname; |
|
952 | + } |
|
926 | 953 | return $s; |
927 | 954 | |
928 | 955 | case HOUSE_TYPE_ROYAL: |
@@ -940,14 +967,18 @@ discard block |
||
940 | 967 | } |
941 | 968 | |
942 | 969 | function by_peer_name($a, $b) { |
943 | - if (!$a['family_name'] && !$b['family_name']) |
|
944 | - return strcmp($a['lordofname'], $b['lordofname']); |
|
945 | - if (!$a['family_name']) |
|
946 | - return strcmp($a['lordofname'], $b['family_name']); |
|
947 | - if (!$b['family_name']) |
|
948 | - return strcmp($a['family_name'], $b['lordofname']); |
|
949 | - if (strcmp($a['family_name'], $b['family_name'])) |
|
950 | - return strcmp($a['family_name'], $b['family_name']); |
|
970 | + if (!$a['family_name'] && !$b['family_name']) { |
|
971 | + return strcmp($a['lordofname'], $b['lordofname']); |
|
972 | + } |
|
973 | + if (!$a['family_name']) { |
|
974 | + return strcmp($a['lordofname'], $b['family_name']); |
|
975 | + } |
|
976 | + if (!$b['family_name']) { |
|
977 | + return strcmp($a['family_name'], $b['lordofname']); |
|
978 | + } |
|
979 | + if (strcmp($a['family_name'], $b['family_name'])) { |
|
980 | + return strcmp($a['family_name'], $b['family_name']); |
|
981 | + } |
|
951 | 982 | return strcmp($a['lordofname'], $b['lordofname']); |
952 | 983 | } |
953 | 984 | |
@@ -974,12 +1005,17 @@ discard block |
||
974 | 1005 | 'Lords in Waiting (HM Household)' => 'Government Whip', |
975 | 1006 | 'Baronesses in Waiting, HM Household' => 'Government Whip', |
976 | 1007 | ); |
977 | - if ($pos) { # Government post, or Chairman of Select Committee |
|
1008 | + if ($pos) { |
|
1009 | +# Government post, or Chairman of Select Committee |
|
978 | 1010 | $pretty = $pos; |
979 | - if ($dept && $dept != 'No Department') $pretty .= ", $dept"; |
|
980 | - if (array_key_exists($pretty, $lookup)) |
|
981 | - $pretty = $lookup[$pretty]; |
|
982 | - } else { # Member of Select Committee |
|
1011 | + if ($dept && $dept != 'No Department') { |
|
1012 | + $pretty .= ", $dept"; |
|
1013 | + } |
|
1014 | + if (array_key_exists($pretty, $lookup)) { |
|
1015 | + $pretty = $lookup[$pretty]; |
|
1016 | + } |
|
1017 | + } else { |
|
1018 | +# Member of Select Committee |
|
983 | 1019 | $pretty = "Member, $dept"; |
984 | 1020 | } |
985 | 1021 | return $pretty; |
@@ -997,13 +1033,16 @@ discard block |
||
997 | 1033 | } |
998 | 1034 | |
999 | 1035 | // single date? |
1000 | - if (isset($data['date'])) $one_date = true; |
|
1036 | + if (isset($data['date'])) { |
|
1037 | + $one_date = true; |
|
1038 | + } |
|
1001 | 1039 | |
1002 | 1040 | // remove empty entries, so they don't produce errors |
1003 | 1041 | foreach (array_keys($hansardmajors) as $major) { |
1004 | 1042 | if (array_key_exists($major, $data)) { |
1005 | - if (count($data[$major]) == 0) |
|
1006 | - unset($data[$major]); |
|
1043 | + if (count($data[$major]) == 0) { |
|
1044 | + unset($data[$major]); |
|
1045 | + } |
|
1007 | 1046 | } |
1008 | 1047 | } |
1009 | 1048 | |
@@ -1012,22 +1051,29 @@ discard block |
||
1012 | 1051 | if (!$one_date) { |
1013 | 1052 | $todaystime = gmmktime(0, 0, 0, date('m'), date('d'), date('Y')); |
1014 | 1053 | foreach ($data as $major => $array) { |
1015 | - if (!in_array('timestamp', $array)) $daytext[$major] = "The most recent "; |
|
1016 | - elseif ($todaystime - $array['timestamp'] == 86400) $daytext[$major] = "Yesterday’s"; |
|
1017 | - elseif ($todaystime - $array['timestamp'] <= (6 * 86400)) $daytext[$major] = gmdate('l', $array['timestamp']) . "’s"; |
|
1018 | - else $daytext[$major] = "The most recent "; |
|
1054 | + if (!in_array('timestamp', $array)) { |
|
1055 | + $daytext[$major] = "The most recent "; |
|
1056 | + } elseif ($todaystime - $array['timestamp'] == 86400) { |
|
1057 | + $daytext[$major] = "Yesterday’s"; |
|
1058 | + } elseif ($todaystime - $array['timestamp'] <= (6 * 86400)) { |
|
1059 | + $daytext[$major] = gmdate('l', $array['timestamp']) . "’s"; |
|
1060 | + } else { |
|
1061 | + $daytext[$major] = "The most recent "; |
|
1062 | + } |
|
1019 | 1063 | } |
1020 | 1064 | } |
1021 | 1065 | |
1022 | 1066 | //build html |
1023 | 1067 | foreach ($printed_majors as $p_major) { |
1024 | - if (!array_key_exists($p_major, $data)) |
|
1025 | - continue; |
|
1068 | + if (!array_key_exists($p_major, $data)) { |
|
1069 | + continue; |
|
1070 | + } |
|
1026 | 1071 | |
1027 | - if ($one_date) |
|
1028 | - $date = $data['date']; |
|
1029 | - else |
|
1030 | - $date = $data[$p_major]['hdate']; |
|
1072 | + if ($one_date) { |
|
1073 | + $date = $data['date']; |
|
1074 | + } else { |
|
1075 | + $date = $data[$p_major]['hdate']; |
|
1076 | + } |
|
1031 | 1077 | $q = $db->query('SELECT section_id, body, gid |
1032 | 1078 | FROM hansard, epobject |
1033 | 1079 | WHERE hansard.epobject_id = epobject.epobject_id ' |
@@ -1079,14 +1125,16 @@ discard block |
||
1079 | 1125 | } |
1080 | 1126 | |
1081 | 1127 | $return .= '<a href="'; |
1082 | - if (isset($data[$major]['listurl'])) |
|
1083 | - $return .= $data[$major]['listurl']; |
|
1084 | - else { |
|
1128 | + if (isset($data[$major]['listurl'])) { |
|
1129 | + $return .= $data[$major]['listurl']; |
|
1130 | + } else { |
|
1085 | 1131 | $LISTURL->reset(); |
1086 | 1132 | $return .= $LISTURL->generate(); |
1087 | 1133 | } |
1088 | 1134 | $return .= '">' . $hansardmajors[$major]['title'] . '</a>'; |
1089 | - if (isset($daytext[$major])) $return; |
|
1135 | + if (isset($daytext[$major])) { |
|
1136 | + $return; |
|
1137 | + } |
|
1090 | 1138 | $return .= '</h4>'; |
1091 | 1139 | |
1092 | 1140 | return $return; |
@@ -1094,20 +1142,21 @@ discard block |
||
1094 | 1142 | |
1095 | 1143 | function score_to_strongly($dmpscore) { |
1096 | 1144 | $dmpdesc = "unknown about"; |
1097 | - if ($dmpscore > 0.95 && $dmpscore <= 1.0) |
|
1098 | - $dmpdesc = "consistently voted against"; |
|
1099 | - elseif ($dmpscore > 0.85) |
|
1100 | - $dmpdesc = "almost always voted against"; |
|
1101 | - elseif ($dmpscore > 0.6) |
|
1102 | - $dmpdesc = "generally voted against"; |
|
1103 | - elseif ($dmpscore > 0.4) |
|
1104 | - $dmpdesc = "voted a mixture of for and against"; |
|
1105 | - elseif ($dmpscore > 0.15) |
|
1106 | - $dmpdesc = "generally voted for"; |
|
1107 | - elseif ($dmpscore > 0.05) |
|
1108 | - $dmpdesc = "almost always voted for"; |
|
1109 | - elseif ($dmpscore >= 0.0) |
|
1110 | - $dmpdesc = "consistently voted for"; |
|
1145 | + if ($dmpscore > 0.95 && $dmpscore <= 1.0) { |
|
1146 | + $dmpdesc = "consistently voted against"; |
|
1147 | + } elseif ($dmpscore > 0.85) { |
|
1148 | + $dmpdesc = "almost always voted against"; |
|
1149 | + } elseif ($dmpscore > 0.6) { |
|
1150 | + $dmpdesc = "generally voted against"; |
|
1151 | + } elseif ($dmpscore > 0.4) { |
|
1152 | + $dmpdesc = "voted a mixture of for and against"; |
|
1153 | + } elseif ($dmpscore > 0.15) { |
|
1154 | + $dmpdesc = "generally voted for"; |
|
1155 | + } elseif ($dmpscore > 0.05) { |
|
1156 | + $dmpdesc = "almost always voted for"; |
|
1157 | + } elseif ($dmpscore >= 0.0) { |
|
1158 | + $dmpdesc = "consistently voted for"; |
|
1159 | + } |
|
1111 | 1160 | return $dmpdesc; |
1112 | 1161 | } |
1113 | 1162 |
@@ -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 | |
@@ -463,10 +463,10 @@ discard block |
||
463 | 463 | $text = substr($text, $start); |
464 | 464 | |
465 | 465 | // Word boundary. |
466 | - if (preg_match ("/.+?\b(.*)/", $text, $matches)) { |
|
466 | + if (preg_match("/.+?\b(.*)/", $text, $matches)) { |
|
467 | 467 | $text = $matches[1]; |
468 | 468 | // Strip spare space at the start. |
469 | - $text = preg_replace ("/^\s/", '', $text); |
|
469 | + $text = preg_replace("/^\s/", '', $text); |
|
470 | 470 | } |
471 | 471 | $text = '...' . $text; |
472 | 472 | } |
@@ -478,10 +478,10 @@ discard block |
||
478 | 478 | $text = substr($text, 0, $length - 3); |
479 | 479 | |
480 | 480 | // Word boundary. |
481 | - if (preg_match ("/(.*)\s.+/", $text, $matches)) { |
|
481 | + if (preg_match("/(.*)\s.+/", $text, $matches)) { |
|
482 | 482 | $text = $matches[1]; |
483 | 483 | // Strip spare space at the end. |
484 | - $text = preg_replace ("/\s$/", '', $text); |
|
484 | + $text = preg_replace("/\s$/", '', $text); |
|
485 | 485 | } |
486 | 486 | // We don't want to use the HTML entity for an ellipsis (…), because then |
487 | 487 | // it screws up when we subsequently use htmlentities() to print the returned |
@@ -513,11 +513,11 @@ discard block |
||
513 | 513 | |
514 | 514 | if ($filter_type == 'strict') { |
515 | 515 | // No tags allowed at all! |
516 | - $filter->allowed = array (); |
|
516 | + $filter->allowed = array(); |
|
517 | 517 | } else { |
518 | 518 | // Comment. |
519 | 519 | // Only allowing <a href>, <b>, <strong>, <i> and <em> |
520 | - $filter->allowed = array ( |
|
520 | + $filter->allowed = array( |
|
521 | 521 | 'a' => array('href'), |
522 | 522 | 'strong' => array(), |
523 | 523 | 'em' => array(), |
@@ -630,7 +630,7 @@ discard block |
||
630 | 630 | |
631 | 631 | // $gid will be like 'uk.org.publicwhip/debate/2003-02-28.475.3'. |
632 | 632 | |
633 | - $newgid = substr($gid, strrpos($gid, '/')+1 ); |
|
633 | + $newgid = substr($gid, strrpos($gid, '/') + 1); |
|
634 | 634 | return $newgid; |
635 | 635 | } |
636 | 636 | |
@@ -641,7 +641,7 @@ discard block |
||
641 | 641 | // will be like 2003-11-20.966.0 |
642 | 642 | // This function returns 966.0 |
643 | 643 | |
644 | - return substr( $gid, (strpos($gid, '.') + 1) ); |
|
644 | + return substr($gid, (strpos($gid, '.') + 1)); |
|
645 | 645 | } |
646 | 646 | |
647 | 647 | function preg_replacement_quote($s) { |
@@ -685,7 +685,7 @@ discard block |
||
685 | 685 | global $PAGE; |
686 | 686 | |
687 | 687 | if (!isset($data['to']) || $data['to'] == '') { |
688 | - $PAGE->error_message ("We need an email address to send to."); |
|
688 | + $PAGE->error_message("We need an email address to send to."); |
|
689 | 689 | return false; |
690 | 690 | } |
691 | 691 | |
@@ -709,7 +709,7 @@ discard block |
||
709 | 709 | if (isset($data['subject'])) { |
710 | 710 | $subject = trim($data['subject']); |
711 | 711 | } else { |
712 | - $subject = trim( substr($firstline, 8) ); |
|
712 | + $subject = trim(substr($firstline, 8)); |
|
713 | 713 | } |
714 | 714 | |
715 | 715 | // Either way, remove this subject line from the template. |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | } elseif (isset($data['subject'])) { |
719 | 719 | $subject = $data['subject']; |
720 | 720 | } else { |
721 | - $PAGE->error_message ("We don't have a subject line for the email, so it wasn't sent."); |
|
721 | + $PAGE->error_message("We don't have a subject line for the email, so it wasn't sent."); |
|
722 | 722 | return false; |
723 | 723 | } |
724 | 724 | |
@@ -728,14 +728,14 @@ discard block |
||
728 | 728 | $replace = array(); |
729 | 729 | |
730 | 730 | foreach ($merge as $key => $val) { |
731 | - $search[] = '/{'.$key.'}/'; |
|
731 | + $search[] = '/{' . $key . '}/'; |
|
732 | 732 | $replace[] = preg_replacement_quote($val); |
733 | 733 | } |
734 | 734 | |
735 | 735 | $emailtext = preg_replace($search, $replace, $emailtext); |
736 | 736 | |
737 | 737 | // Send it! |
738 | - $success = send_email ($data['to'], $subject, $emailtext, $bulk, 'twfy-DO-NOT-REPLY@' . EMAILDOMAIN, $want_bounces); |
|
738 | + $success = send_email($data['to'], $subject, $emailtext, $bulk, 'twfy-DO-NOT-REPLY@' . EMAILDOMAIN, $want_bounces); |
|
739 | 739 | |
740 | 740 | return $success; |
741 | 741 | |
@@ -762,15 +762,15 @@ discard block |
||
762 | 762 | "Content-Type: text/plain; charset=utf-8\r\n" . |
763 | 763 | "MIME-Version: 1.0\r\n" . |
764 | 764 | "Content-Transfer-Encoding: 8bit\r\n" . |
765 | - ($bulk ? "Precedence: bulk\r\nAuto-Submitted: auto-generated\r\n" : "" ). |
|
765 | + ($bulk ? "Precedence: bulk\r\nAuto-Submitted: auto-generated\r\n" : "") . |
|
766 | 766 | "X-Mailer: PHP/" . phpversion(); |
767 | 767 | twfy_debug('EMAIL', "Sending email to $to with subject of '$subject'"); |
768 | 768 | |
769 | 769 | if ($want_bounces) { |
770 | 770 | $envelope_sender = twfy_verp_envelope_sender($to); |
771 | - $success = mail ($to, $subject, $message, $headers, '-f ' . $envelope_sender); |
|
771 | + $success = mail($to, $subject, $message, $headers, '-f ' . $envelope_sender); |
|
772 | 772 | } else { |
773 | - $success = mail ($to, $subject, $message, $headers); |
|
773 | + $success = mail($to, $subject, $message, $headers); |
|
774 | 774 | } |
775 | 775 | |
776 | 776 | return $success; |
@@ -782,7 +782,7 @@ discard block |
||
782 | 782 | // http://www.iamcal.com/publish/article.php?id=13 |
783 | 783 | |
784 | 784 | // Call this with a key name to get a GET or POST variable. |
785 | -function get_http_var($name, $default='') { |
|
785 | +function get_http_var($name, $default = '') { |
|
786 | 786 | if (array_key_exists($name, $_GET)) { |
787 | 787 | return clean_var($_GET[$name]); |
788 | 788 | } |
@@ -808,7 +808,7 @@ discard block |
||
808 | 808 | } |
809 | 809 | |
810 | 810 | // Call this with a key name to get a COOKIE variable. |
811 | -function get_cookie_var($name, $default='') { |
|
811 | +function get_cookie_var($name, $default = '') { |
|
812 | 812 | if (array_key_exists($name, $_COOKIE)) { |
813 | 813 | return clean_var($_COOKIE[$name]); |
814 | 814 | } |
@@ -819,7 +819,7 @@ discard block |
||
819 | 819 | // Pass it an array of key names that should not be generated as |
820 | 820 | // hidden form variables. It then outputs hidden form variables |
821 | 821 | // based on the session_vars for this page. |
822 | -function hidden_form_vars ($omit = array()) { |
|
822 | +function hidden_form_vars($omit = array()) { |
|
823 | 823 | global $DATA, $this_page; |
824 | 824 | |
825 | 825 | $session_vars = $DATA->page_metadata($this_page, "session_vars"); |
@@ -832,7 +832,7 @@ discard block |
||
832 | 832 | } |
833 | 833 | |
834 | 834 | // Deprecated. Use hidden_form_vars, above, instead. |
835 | -function hidden_vars ($omit = array()) { |
|
835 | +function hidden_vars($omit = array()) { |
|
836 | 836 | global $DATA; |
837 | 837 | |
838 | 838 | foreach ($args as $key => $val) { |
@@ -875,7 +875,7 @@ discard block |
||
875 | 875 | function entities_to_numbers($string) { |
876 | 876 | $string = str_replace( |
877 | 877 | array('Ö', 'â', 'ú', 'á', 'í', 'ô', 'é'), |
878 | - array('Ö', 'â', 'ú', 'á', 'í', 'ô', 'é' ), |
|
878 | + array('Ö', 'â', 'ú', 'á', 'í', 'ô', 'é'), |
|
879 | 879 | $string |
880 | 880 | ); |
881 | 881 | return $string; |
@@ -889,9 +889,9 @@ discard block |
||
889 | 889 | return 'elizabeth_the_second'; |
890 | 890 | } |
891 | 891 | |
892 | - $s = array(' ', '&', 'ô', 'Ö', 'ö', 'â', 'í', 'á', 'ú', 'é', 'ó', 'Ó'); |
|
893 | - $s2 = array(" ", "&", "\xc3\xb4", "\xc3\96", "\xc3\xb6", "\xc3\xa5", "\xc3\xad", "\xc3\xa1", "\xc3\xba", "\xc3\xa9", "\xc3\xb3", "\xc3\x93"); |
|
894 | - $r = array('_', 'and', 'o', 'o', 'o', 'a', 'i', 'a', 'u', 'e', 'o', 'o'); |
|
892 | + $s = array(' ', '&', 'ô', 'Ö', 'ö', 'â', 'í', 'á', 'ú', 'é', 'ó', 'Ó'); |
|
893 | + $s2 = array(" ", "&", "\xc3\xb4", "\xc3\96", "\xc3\xb6", "\xc3\xa5", "\xc3\xad", "\xc3\xa1", "\xc3\xba", "\xc3\xa9", "\xc3\xb3", "\xc3\x93"); |
|
894 | + $r = array('_', 'and', 'o', 'o', 'o', 'a', 'i', 'a', 'u', 'e', 'o', 'o'); |
|
895 | 895 | $name = preg_replace('#^the #', '', strtolower($name)); |
896 | 896 | |
897 | 897 | $out = ''; |
@@ -1049,8 +1049,8 @@ discard block |
||
1049 | 1049 | } |
1050 | 1050 | $out .= '<li>' . $body . '<ul>'; |
1051 | 1051 | } else { |
1052 | - $LISTURL->insert( array( 'id' => $gid ) ); |
|
1053 | - $out .= '<li><a href="'.$LISTURL->generate().'">'; |
|
1052 | + $LISTURL->insert(array('id' => $gid)); |
|
1053 | + $out .= '<li><a href="' . $LISTURL->generate() . '">'; |
|
1054 | 1054 | $out .= $body . '</a>'; |
1055 | 1055 | } |
1056 | 1056 | } |
@@ -1119,7 +1119,7 @@ discard block |
||
1119 | 1119 | return $return; |
1120 | 1120 | } |
1121 | 1121 | |
1122 | -function redirect($url, $code=302) { |
|
1122 | +function redirect($url, $code = 302) { |
|
1123 | 1123 | if (defined('TESTING')) { |
1124 | 1124 | print "Location: $url"; |
1125 | 1125 | } else { |
@@ -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. |
@@ -5,7 +5,9 @@ |
||
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)); |
@@ -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 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | <?php |
17 | 17 | } |
18 | 18 | |
19 | -$PAGE->block_start(array ('title'=>'Share the \'Free our Bills!\' campaign')); |
|
19 | +$PAGE->block_start(array('title'=>'Share the \'Free our Bills!\' campaign')); |
|
20 | 20 | freeourbills_styles(); |
21 | 21 | |
22 | 22 | freeourbills_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(); |
@@ -144,4 +144,4 @@ |
||
144 | 144 | <?php |
145 | 145 | #$PAGE->block_end(); |
146 | 146 | $PAGE->stripe_end(); |
147 | -$PAGE->page_end (); |
|
147 | +$PAGE->page_end(); |
@@ -138,4 +138,4 @@ |
||
138 | 138 | 'type' => 'html', |
139 | 139 | 'content' => '<p align="center"><img title="Duck-billed platypus" src="bill3.jpg" alt="" hspace="10"></p>' |
140 | 140 | ))); |
141 | -$PAGE->page_end (); |
|
141 | +$PAGE->page_end(); |
@@ -16,8 +16,9 @@ discard block |
||
16 | 16 | $email = get_http_var('email'); |
17 | 17 | $sign = get_http_var('sign'); |
18 | 18 | $pid = get_http_var('pid'); |
19 | -if (!$pid || !ctype_digit($pid)) print 'not valid'; |
|
20 | -else { |
|
19 | +if (!$pid || !ctype_digit($pid)) { |
|
20 | + print 'not valid'; |
|
21 | +} else { |
|
21 | 22 | $authed = auth_verify_with_shared_secret($email, OPTION_AUTH_SHARED_SECRET, $sign); |
22 | 23 | if ($authed) { |
23 | 24 | $db = new ParlDB; |
@@ -26,10 +27,11 @@ discard block |
||
26 | 27 | ':criteria' => 'speaker:' . $pid |
27 | 28 | )); |
28 | 29 | $already_signed = $q->rows(); |
29 | - if ($already_signed) |
|
30 | - print "already signed"; |
|
31 | - else |
|
32 | - print "not signed"; |
|
30 | + if ($already_signed) { |
|
31 | + print "already signed"; |
|
32 | + } else { |
|
33 | + print "not signed"; |
|
34 | + } |
|
33 | 35 | } else { |
34 | 36 | print "not authed"; |
35 | 37 | } |
@@ -13,7 +13,7 @@ |
||
13 | 13 | rsort($files); |
14 | 14 | |
15 | 15 | if (!DEVSITE) { |
16 | - header('Cache-Control: max-age=3600'); |
|
16 | + header('Cache-Control: max-age=3600'); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | $PAGE->page_start(); |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | $file = file_get_contents($_); |
68 | 68 | $date = preg_replace("#$dir/regmem(.*?)\.xml#", '$1', $_); |
69 | 69 | $data[$_] = array(); |
70 | - if (preg_match('#<regmem personid="uk.org.publicwhip/person/'.$p.'" (?:memberid="(.*?)" )?membername="(.*?)" date="(.*?)">(.*?)</regmem>#s', $file, $m)) { |
|
70 | + if (preg_match('#<regmem personid="uk.org.publicwhip/person/' . $p . '" (?:memberid="(.*?)" )?membername="(.*?)" date="(.*?)">(.*?)</regmem>#s', $file, $m)) { |
|
71 | 71 | $earliest = $_; |
72 | 72 | if (!$name) { |
73 | 73 | $name = $m[2]; |
@@ -103,21 +103,21 @@ discard block |
||
103 | 103 | break; |
104 | 104 | } |
105 | 105 | $date_pre = preg_replace("#$dir/regmem(.*?)\.xml#", '$1', $_); |
106 | - $date_post = preg_replace("#$dir/regmem(.*?)\.xml#", '$1', $files[$i+1]); |
|
106 | + $date_post = preg_replace("#$dir/regmem(.*?)\.xml#", '$1', $files[$i + 1]); |
|
107 | 107 | $pretty = format_date($date_pre, LONGDATEFORMAT); |
108 | 108 | $oout = ''; |
109 | 109 | foreach ($data[$_] as $cat_type => $cat_data) { |
110 | - $old = array_key_exists($cat_type, $data[$files[$i+1]]) ? $data[$files[$i+1]][$cat_type] : ''; |
|
110 | + $old = array_key_exists($cat_type, $data[$files[$i + 1]]) ? $data[$files[$i + 1]][$cat_type] : ''; |
|
111 | 111 | $new = $data[$_][$cat_type]; |
112 | 112 | if ($diff = clean_diff($old, $new)) { |
113 | 113 | $oout .= cat_heading($cat_type, $date_pre, $date_post) . $diff; |
114 | 114 | } |
115 | 115 | } |
116 | - foreach ($data[$files[$i+1]] as $cat_type => $cat_data) { |
|
116 | + foreach ($data[$files[$i + 1]] as $cat_type => $cat_data) { |
|
117 | 117 | if (array_key_exists($cat_type, $data[$_])) { |
118 | 118 | continue; |
119 | 119 | } |
120 | - if ($diff = clean_diff($data[$files[$i+1]][$cat_type], '')) { |
|
120 | + if ($diff = clean_diff($data[$files[$i + 1]][$cat_type], '')) { |
|
121 | 121 | $oout .= cat_heading($cat_type, $date_pre, $date_post) . $diff; |
122 | 122 | } |
123 | 123 | } |
@@ -149,14 +149,14 @@ discard block |
||
149 | 149 | if ($f) { |
150 | 150 | $f = "$dir/regmem$f.xml"; |
151 | 151 | $count = count($files); |
152 | - for ($i=0; $i<$count; ++$i) { |
|
152 | + for ($i = 0; $i < $count; ++$i) { |
|
153 | 153 | if ($files[$i] == $f) { |
154 | 154 | $new = $i; |
155 | 155 | break; |
156 | 156 | } |
157 | 157 | } |
158 | 158 | } |
159 | - $old = $new+1; |
|
159 | + $old = $new + 1; |
|
160 | 160 | $old = $files[$old]; |
161 | 161 | $old_iso = preg_replace("#$dir/regmem(.*?)\.xml#", '$1', $old); |
162 | 162 | $old_pretty = format_date($old_iso, LONGDATEFORMAT); |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | $old = file_get_contents($old); |
167 | 167 | $new = file_get_contents($new); |
168 | 168 | |
169 | - $DATA->set_page_metadata($this_page, 'heading', 'Changes from '.$old_pretty.' to '.$new_pretty); |
|
169 | + $DATA->set_page_metadata($this_page, 'heading', 'Changes from ' . $old_pretty . ' to ' . $new_pretty); |
|
170 | 170 | $PAGE->stripe_start(); |
171 | 171 | print $link; |
172 | 172 | $data = array(); |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | $out .= clean_diff($old, $new); |
189 | 189 | } |
190 | 190 | if ($out) { |
191 | - print span_row('<h2>'.$names[$person_id].' - <a href="?p='.$person_id.'">Register history</a> | <a href="/mp/?pid='.$person_id.'">MP’s page</a></h2>', true) . $out; |
|
191 | + print span_row('<h2>' . $names[$person_id] . ' - <a href="?p=' . $person_id . '">Register history</a> | <a href="/mp/?pid=' . $person_id . '">MP’s page</a></h2>', true) . $out; |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | print '</table>'; |
@@ -239,28 +239,28 @@ discard block |
||
239 | 239 | $c = 0; $year = 0; |
240 | 240 | $view = ''; $compare = ''; |
241 | 241 | $count = count($files); |
242 | - for ($i=0; $i<$count; ++$i) { |
|
242 | + for ($i = 0; $i < $count; ++$i) { |
|
243 | 243 | preg_match('/(\d\d\d\d)-(\d\d-\d\d)/', $files[$i], $m); |
244 | 244 | $y = $m[1]; $md = $m[2]; |
245 | 245 | if ($c++) { |
246 | 246 | $view .= ' | '; |
247 | - if ($i < $count-1) { |
|
247 | + if ($i < $count - 1) { |
|
248 | 248 | $compare .= ' | '; |
249 | 249 | } |
250 | 250 | } |
251 | 251 | if ($year != $y) { |
252 | 252 | $year = $y; |
253 | 253 | $view .= "<em>$year</em> "; |
254 | - if ($i < $count-1) { |
|
254 | + if ($i < $count - 1) { |
|
255 | 255 | $compare .= "<em>$year</em> "; |
256 | 256 | } |
257 | 257 | } |
258 | 258 | $months = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); |
259 | 259 | preg_match('/(\d\d)-(\d\d)/', $md, $m); |
260 | - $date = ($m[2]+0) . ' '. $months[$m[1]-1]; |
|
261 | - $view .= '<a href="./?d='.$y.'-'.$md.'">'.$date.'</a>'; |
|
262 | - if ($i < $count-1) { |
|
263 | - $compare .= '<a href="?f='.$y.'-'.$md.'">'.$date.'</a>'; |
|
260 | + $date = ($m[2] + 0) . ' ' . $months[$m[1] - 1]; |
|
261 | + $view .= '<a href="./?d=' . $y . '-' . $md . '">' . $date . '</a>'; |
|
262 | + if ($i < $count - 1) { |
|
263 | + $compare .= '<a href="?f=' . $y . '-' . $md . '">' . $date . '</a>'; |
|
264 | 264 | } |
265 | 265 | } |
266 | 266 | ?> |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | <?php |
277 | 277 | uasort($names, 'by_name'); |
278 | 278 | foreach ($names as $_ => $value) { |
279 | - print '<li><a href="?p='.$_.'">'.$value.'</a>'; |
|
279 | + print '<li><a href="?p=' . $_ . '">' . $value . '</a>'; |
|
280 | 280 | } |
281 | 281 | print '</ul>'; |
282 | 282 | |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | $data = array(); |
295 | 295 | parse_file($d, $d_iso, 'only', $data); |
296 | 296 | $this_page = 'regmem_date'; |
297 | - $DATA->set_page_metadata($this_page, 'heading', "The Register of Members' Interests, $d_pretty");; |
|
297 | + $DATA->set_page_metadata($this_page, 'heading', "The Register of Members' Interests, $d_pretty"); ; |
|
298 | 298 | $PAGE->stripe_start(); |
299 | 299 | print $link; |
300 | 300 | ?> |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | foreach ($v as $cat_type => $vv) { |
309 | 309 | $out .= cat_heading($cat_type, $d_iso, $d_iso, false); |
310 | 310 | $d = (array_key_exists('only', $data[$person_id][$cat_type]) ? $data[$person_id][$cat_type]['only'] : ''); |
311 | - $out .= prettify($d)."\n"; |
|
311 | + $out .= prettify($d) . "\n"; |
|
312 | 312 | } |
313 | 313 | if ($out) { |
314 | 314 | print '<div class="block">'; |
@@ -359,8 +359,8 @@ discard block |
||
359 | 359 | if (!count($r) && !count($a)) { |
360 | 360 | return ''; |
361 | 361 | } |
362 | - $r = join("\n", $r); $r = $r ? '<td class="r"><ul>'.$r.'</ul></td>' : '<td> </td>'; |
|
363 | - $a = join("\n", $a); $a = $a ? '<td class="a"><ul>'.$a.'</ul></td>' : '<td> </td>'; |
|
362 | + $r = join("\n", $r); $r = $r ? '<td class="r"><ul>' . $r . '</ul></td>' : '<td> </td>'; |
|
363 | + $a = join("\n", $a); $a = $a ? '<td class="a"><ul>' . $a . '</ul></td>' : '<td> </td>'; |
|
364 | 364 | $diff = '<tr>' . $r . $a . '</tr>'; |
365 | 365 | $diff = preg_replace('#<item.*?>(.*?)</item>#', '<li>$1</li>', $diff); |
366 | 366 | return $diff; |