@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | function api_getAlerts_start_date($start_date) { |
4 | - $args = array ('start_date' => $start_date, 'end_date' => get_http_var('end_date')); |
|
5 | - $alert = new ALERT(); |
|
6 | - $data = $alert->fetch_between($confirmed=1, $deleted=0, $args['start_date'], $args['end_date']); |
|
7 | - api_output($data); |
|
4 | + $args = array ('start_date' => $start_date, 'end_date' => get_http_var('end_date')); |
|
5 | + $alert = new ALERT(); |
|
6 | + $data = $alert->fetch_between($confirmed=1, $deleted=0, $args['start_date'], $args['end_date']); |
|
7 | + api_output($data); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | ?> |
@@ -1,9 +1,9 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | function api_getAlerts_start_date($start_date) { |
4 | - $args = array ('start_date' => $start_date, 'end_date' => get_http_var('end_date')); |
|
4 | + $args = array('start_date' => $start_date, 'end_date' => get_http_var('end_date')); |
|
5 | 5 | $alert = new ALERT(); |
6 | - $data = $alert->fetch_between($confirmed=1, $deleted=0, $args['start_date'], $args['end_date']); |
|
6 | + $data = $alert->fetch_between($confirmed = 1, $deleted = 0, $args['start_date'], $args['end_date']); |
|
7 | 7 | api_output($data); |
8 | 8 | } |
9 | 9 |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | } |
25 | 25 | |
26 | 26 | function api_getComments_start_date($start_date) { |
27 | - $args = array ( |
|
27 | + $args = array( |
|
28 | 28 | 'start_date' => $start_date, |
29 | 29 | 'end_date' => get_http_var('end_date') |
30 | 30 | ); |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | } |
34 | 34 | |
35 | 35 | function api_getComments_search($s) { |
36 | - $args = array ( |
|
36 | + $args = array( |
|
37 | 37 | 's' => $s, |
38 | 38 | 'p' => get_http_var('page'), |
39 | 39 | 'num' => get_http_var('num'), |
@@ -26,17 +26,17 @@ discard block |
||
26 | 26 | $match = 0; |
27 | 27 | foreach ($methods as $method => $data) { |
28 | 28 | if (strtolower($q_method) == strtolower($method)) { |
29 | - if (isset($data['superuser']) && $data['superuser']) { |
|
29 | + if (isset($data['superuser']) && $data['superuser']) { |
|
30 | 30 | $super_check = api_is_superuser_key($key); |
31 | 31 | if (!$super_check) { |
32 | 32 | if (get_http_var('docs')) { |
33 | - api_front_page(); |
|
33 | + api_front_page(); |
|
34 | 34 | } else { |
35 | - api_error('Invalid API key.'); |
|
36 | - exit; |
|
37 | - } |
|
35 | + api_error('Invalid API key.'); |
|
36 | + exit; |
|
37 | + } |
|
38 | 38 | } |
39 | - } |
|
39 | + } |
|
40 | 40 | |
41 | 41 | api_log_call($key); |
42 | 42 | $match++; |
@@ -73,9 +73,9 @@ discard block |
||
73 | 73 | '". Possible functions are: ' . |
74 | 74 | join(', ', array_keys($methods)); |
75 | 75 | if (get_http_var('output')) { |
76 | - api_error($msg); |
|
76 | + api_error($msg); |
|
77 | 77 | } else { |
78 | - api_front_page($msg); |
|
78 | + api_front_page($msg); |
|
79 | 79 | } |
80 | 80 | } else { |
81 | 81 | if (get_http_var('docs')) { |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | foreach ($data['parameters'] as $parameter) { |
48 | 48 | if ($q_param = trim(get_http_var($parameter))) { |
49 | 49 | $match++; |
50 | - include_once 'api_'. $method . '.php'; |
|
50 | + include_once 'api_' . $method . '.php'; |
|
51 | 51 | api_call_user_func_or_error('api_' . $method . '_' . $parameter, array($q_param), 'API call not yet functional', 'api'); |
52 | 52 | break; |
53 | 53 | } |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | api_error('No parameter provided to function "' . |
58 | 58 | _htmlspecialchars($q_method) . |
59 | 59 | '". Possible choices are: ' . |
60 | - join(', ', $data['parameters']) ); |
|
60 | + join(', ', $data['parameters'])); |
|
61 | 61 | } else { |
62 | - include_once 'api_'. $method . '.php'; |
|
62 | + include_once 'api_' . $method . '.php'; |
|
63 | 63 | api_call_user_func_or_error('api_' . $method, array(), 'API call not yet functional', 'api'); |
64 | 64 | break; |
65 | 65 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | $DATA->set_page_metadata($this_page, 'title', "$method function"); |
94 | 94 | $PAGE->page_start(); |
95 | 95 | $PAGE->stripe_start(); |
96 | - include_once 'api_'. $method . '.php'; |
|
96 | + include_once 'api_' . $method . '.php'; |
|
97 | 97 | print '<p align="center"><strong>https://www.theyworkforyou.com/api/' . $method . '</strong></p>'; |
98 | 98 | api_call_user_func_or_error('api_' . $method . '_front', array(), 'No documentation yet', 'html'); |
99 | 99 | ?> |
@@ -102,20 +102,20 @@ discard block |
||
102 | 102 | <form method="get" action="?#output"> |
103 | 103 | <p> |
104 | 104 | <?php foreach ($methods[$method]['parameters'] as $parameter) { |
105 | - print $parameter . ': <input type="text" name="'.$parameter.'" value="'; |
|
105 | + print $parameter . ': <input type="text" name="' . $parameter . '" value="'; |
|
106 | 106 | if ($val = get_http_var($parameter)) |
107 | 107 | print _htmlspecialchars($val); |
108 | 108 | print '" size="30"><br>'; |
109 | 109 | } |
110 | 110 | ?> |
111 | 111 | Output: |
112 | -<input id="output_js" type="radio" name="output" value="js"<?php if (get_http_var('output')=='js' || !get_http_var('output')) print ' checked'?>> |
|
112 | +<input id="output_js" type="radio" name="output" value="js"<?php if (get_http_var('output') == 'js' || !get_http_var('output')) print ' checked'?>> |
|
113 | 113 | <label for="output_js">JS</label> |
114 | -<input id="output_xml" type="radio" name="output" value="xml"<?php if (get_http_var('output')=='xml') print ' checked'?>> |
|
114 | +<input id="output_xml" type="radio" name="output" value="xml"<?php if (get_http_var('output') == 'xml') print ' checked'?>> |
|
115 | 115 | <label for="output_xml">XML</label> |
116 | -<input id="output_php" type="radio" name="output" value="php"<?php if (get_http_var('output')=='php') print ' checked'?>> |
|
116 | +<input id="output_php" type="radio" name="output" value="php"<?php if (get_http_var('output') == 'php') print ' checked'?>> |
|
117 | 117 | <label for="output_php">Serialised PHP</label> |
118 | -<input id="output_rabx" type="radio" name="output" value="rabx"<?php if (get_http_var('output')=='rabx') print ' checked'?>> |
|
118 | +<input id="output_rabx" type="radio" name="output" value="rabx"<?php if (get_http_var('output') == 'rabx') print ' checked'?>> |
|
119 | 119 | <label for="output_rabx">RABX</label> |
120 | 120 | |
121 | 121 | <input type="submit" value="Go"> |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | } |
131 | 131 | print '<h4><a name="output"></a>Output</h4>'; |
132 | 132 | print '<p>URL for this: <strong>https://www.theyworkforyou.com/api/'; |
133 | - print $method . '?' . join('&', $qs) . '&output='._htmlspecialchars(get_http_var('output')).'</strong></p>'; |
|
133 | + print $method . '?' . join('&', $qs) . '&output=' . _htmlspecialchars(get_http_var('output')) . '</strong></p>'; |
|
134 | 134 | print '<pre>' . _htmlspecialchars($explorer) . '</pre>'; |
135 | 135 | } |
136 | 136 | $sidebar = api_sidebar(); |
@@ -8,7 +8,8 @@ discard block |
||
8 | 8 | if ($q_method = get_http_var('method')) { |
9 | 9 | if (get_http_var('docs')) { |
10 | 10 | $key = 'DOCS'; |
11 | - } else { |
|
11 | + } |
|
12 | + else { |
|
12 | 13 | $key = get_http_var('key'); |
13 | 14 | if (!$key) { |
14 | 15 | api_error('No API key provided. Please see https://www.theyworkforyou.com/api/key for more information.'); |
@@ -18,7 +19,8 @@ discard block |
||
18 | 19 | if (!$check) { |
19 | 20 | api_error('Invalid API key.'); |
20 | 21 | exit; |
21 | - } elseif ($check === 'disabled') { |
|
22 | + } |
|
23 | + elseif ($check === 'disabled') { |
|
22 | 24 | api_error('Your API key has been disabled.'); |
23 | 25 | exit; |
24 | 26 | } |
@@ -31,7 +33,8 @@ discard block |
||
31 | 33 | if (!$super_check) { |
32 | 34 | if (get_http_var('docs')) { |
33 | 35 | api_front_page(); |
34 | - } else { |
|
36 | + } |
|
37 | + else { |
|
35 | 38 | api_error('Invalid API key.'); |
36 | 39 | exit; |
37 | 40 | } |
@@ -58,7 +61,8 @@ discard block |
||
58 | 61 | _htmlspecialchars($q_method) . |
59 | 62 | '". Possible choices are: ' . |
60 | 63 | join(', ', $data['parameters']) ); |
61 | - } else { |
|
64 | + } |
|
65 | + else { |
|
62 | 66 | include_once 'api_'. $method . '.php'; |
63 | 67 | api_call_user_func_or_error('api_' . $method, array(), 'API call not yet functional', 'api'); |
64 | 68 | break; |
@@ -74,16 +78,19 @@ discard block |
||
74 | 78 | join(', ', array_keys($methods)); |
75 | 79 | if (get_http_var('output')) { |
76 | 80 | api_error($msg); |
77 | - } else { |
|
81 | + } |
|
82 | + else { |
|
78 | 83 | api_front_page($msg); |
79 | 84 | } |
80 | - } else { |
|
85 | + } |
|
86 | + else { |
|
81 | 87 | if (get_http_var('docs')) { |
82 | 88 | $explorer = ob_get_clean(); |
83 | 89 | api_documentation_front($method, $explorer); |
84 | 90 | } |
85 | 91 | } |
86 | -} else { |
|
92 | +} |
|
93 | +else { |
|
87 | 94 | api_front_page(); |
88 | 95 | } |
89 | 96 | |
@@ -103,13 +110,15 @@ discard block |
||
103 | 110 | <p> |
104 | 111 | <?php foreach ($methods[$method]['parameters'] as $parameter) { |
105 | 112 | print $parameter . ': <input type="text" name="'.$parameter.'" value="'; |
106 | - if ($val = get_http_var($parameter)) |
|
107 | - print _htmlspecialchars($val); |
|
113 | + if ($val = get_http_var($parameter)) { |
|
114 | + print _htmlspecialchars($val); |
|
115 | + } |
|
108 | 116 | print '" size="30"><br>'; |
109 | 117 | } |
110 | 118 | ?> |
111 | 119 | Output: |
112 | -<input id="output_js" type="radio" name="output" value="js"<?php if (get_http_var('output')=='js' || !get_http_var('output')) print ' checked'?>> |
|
120 | +<input id="output_js" type="radio" name="output" value="js"<?php if (get_http_var('output')=='js' || !get_http_var('output')) { |
|
121 | + print ' checked'?>> |
|
113 | 122 | <label for="output_js">JS</label> |
114 | 123 | <input id="output_xml" type="radio" name="output" value="xml"<?php if (get_http_var('output')=='xml') print ' checked'?>> |
115 | 124 | <label for="output_xml">XML</label> |
@@ -124,9 +133,11 @@ discard block |
||
124 | 133 | <?php |
125 | 134 | if ($explorer) { |
126 | 135 | $qs = array(); |
136 | +} |
|
127 | 137 | foreach ($methods[$method]['parameters'] as $parameter) { |
128 | - if (get_http_var($parameter)) |
|
129 | - $qs[] = _htmlspecialchars(rawurlencode($parameter) . '=' . urlencode(get_http_var($parameter))); |
|
138 | + if (get_http_var($parameter)) { |
|
139 | + $qs[] = _htmlspecialchars(rawurlencode($parameter) . '=' . urlencode(get_http_var($parameter))); |
|
140 | + } |
|
130 | 141 | } |
131 | 142 | print '<h4><a name="output"></a>Output</h4>'; |
132 | 143 | print '<p>URL for this: <strong>https://www.theyworkforyou.com/api/'; |
@@ -2,12 +2,12 @@ discard block |
||
2 | 2 | |
3 | 3 | $this_page = 'bill_index'; |
4 | 4 | include_once '../../../../includes/easyparliament/init.php'; |
5 | -$DATA->set_page_metadata($this_page, 'heading','Identity Cards Act 2006'); |
|
5 | +$DATA->set_page_metadata($this_page, 'heading', 'Identity Cards Act 2006'); |
|
6 | 6 | |
7 | 7 | $PAGE->page_start(); |
8 | 8 | $PAGE->stripe_start(); |
9 | 9 | |
10 | -$PAGE->block_start(array ('title'=>'House of Commons - Normal Run')); |
|
10 | +$PAGE->block_start(array('title'=>'House of Commons - Normal Run')); |
|
11 | 11 | ?> |
12 | 12 | <ul> <li>Back on 25th May 2005, a bill was introduced: the <a |
13 | 13 | href="http://www.publications.parliament.uk/pa/cm200506/cmbills/009/2006009.htm">Identity |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | <?php |
34 | 34 | $PAGE->block_end(); |
35 | -$PAGE->block_start(array ('title'=>'House of Lords - Normal Run')); |
|
35 | +$PAGE->block_start(array('title'=>'House of Lords - Normal Run')); |
|
36 | 36 | ?> |
37 | 37 | |
38 | 38 | <ul> |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | <?php |
51 | 51 | $PAGE->block_end(); |
52 | -$PAGE->block_start(array ('title'=>'Ping Pong')); |
|
52 | +$PAGE->block_start(array('title'=>'Ping Pong')); |
|
53 | 53 | ?> |
54 | 54 | |
55 | 55 | <ul> |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | $PAGE->block_end(); |
95 | 95 | |
96 | 96 | $includes = array( |
97 | - array ( |
|
97 | + array( |
|
98 | 98 | 'type' => 'include', |
99 | 99 | 'content' => 'bills_intro' |
100 | 100 | ), |
@@ -43,11 +43,11 @@ |
||
43 | 43 | $data['mp_vote']['with_majority'] = true; |
44 | 44 | } |
45 | 45 | } else { |
46 | - if ($data['division']['date'] < $MEMBER->entered_house(1)['date']) { |
|
47 | - $data['before_mp'] = true; |
|
48 | - } else if ($data['division']['date'] > $MEMBER->left_house(1)['date']) { |
|
49 | - $data['after_mp'] = true; |
|
50 | - } |
|
46 | + if ($data['division']['date'] < $MEMBER->entered_house(1)['date']) { |
|
47 | + $data['before_mp'] = true; |
|
48 | + } else if ($data['division']['date'] > $MEMBER->left_house(1)['date']) { |
|
49 | + $data['after_mp'] = true; |
|
50 | + } |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 |
@@ -51,7 +51,7 @@ |
||
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
54 | -$data['debate_time_human'] = False; |
|
54 | +$data['debate_time_human'] = false; |
|
55 | 55 | $data['debate_day_human'] = format_date($data['division']['date'], LONGDATEFORMAT); |
56 | 56 | $data['col_country'] = 'UK'; |
57 | 57 | $data['location'] = 'in the House of Commons'; |
@@ -16,7 +16,8 @@ discard block |
||
16 | 16 | if ($mp = get_http_var('p')) { |
17 | 17 | $MEMBER = new MySociety\TheyWorkForYou\Member(array('person_id' => $mp, 'house' => HOUSE_TYPE_COMMONS)); |
18 | 18 | $main_vote_mp = true; |
19 | -} else if ($THEUSER->postcode_is_set()) { |
|
19 | +} |
|
20 | +else if ($THEUSER->postcode_is_set()) { |
|
20 | 21 | $MEMBER = new MySociety\TheyWorkForYou\Member(array('postcode' => $THEUSER->postcode(), 'house' => HOUSE_TYPE_COMMONS)); |
21 | 22 | } |
22 | 23 | |
@@ -42,10 +43,12 @@ discard block |
||
42 | 43 | if ($data['mp_vote']['vote'] == $data['division']['vote']) { |
43 | 44 | $data['mp_vote']['with_majority'] = true; |
44 | 45 | } |
45 | - } else { |
|
46 | + } |
|
47 | + else { |
|
46 | 48 | if ($data['division']['date'] < $MEMBER->entered_house(1)['date']) { |
47 | 49 | $data['before_mp'] = true; |
48 | - } else if ($data['division']['date'] > $MEMBER->left_house(1)['date']) { |
|
50 | + } |
|
51 | + else if ($data['division']['date'] > $MEMBER->left_house(1)['date']) { |
|
49 | 52 | $data['after_mp'] = true; |
50 | 53 | } |
51 | 54 | } |
@@ -10,12 +10,12 @@ |
||
10 | 10 | } |
11 | 11 | |
12 | 12 | if (isset($MEMBER)) { |
13 | - $divisions = new MySociety\TheyWorkForYou\Divisions($MEMBER); |
|
14 | - $data = array('divisions' => $divisions->getRecentMemberDivisions(30, 'Parliament')); |
|
15 | - $data['mp_name'] = ucfirst($MEMBER->full_name()); |
|
13 | + $divisions = new MySociety\TheyWorkForYou\Divisions($MEMBER); |
|
14 | + $data = array('divisions' => $divisions->getRecentMemberDivisions(30, 'Parliament')); |
|
15 | + $data['mp_name'] = ucfirst($MEMBER->full_name()); |
|
16 | 16 | } else { |
17 | - $divisions = new MySociety\TheyWorkForYou\Divisions(); |
|
18 | - $data = $divisions->getRecentDivisions(30); |
|
17 | + $divisions = new MySociety\TheyWorkForYou\Divisions(); |
|
18 | + $data = $divisions->getRecentDivisions(30); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | $data['last_updated'] = MySociety\TheyWorkForYou\Divisions::getMostRecentDivisionDate()['latest']; |
@@ -13,7 +13,8 @@ |
||
13 | 13 | $divisions = new MySociety\TheyWorkForYou\Divisions($MEMBER); |
14 | 14 | $data = array('divisions' => $divisions->getRecentMemberDivisions(30, 'Parliament')); |
15 | 15 | $data['mp_name'] = ucfirst($MEMBER->full_name()); |
16 | -} else { |
|
16 | +} |
|
17 | +else { |
|
17 | 18 | $divisions = new MySociety\TheyWorkForYou\Divisions(); |
18 | 19 | $data = $divisions->getRecentDivisions(30); |
19 | 20 | } |
@@ -16,39 +16,39 @@ discard block |
||
16 | 16 | contributions('212.35.252.2'); # LibDem |
17 | 17 | |
18 | 18 | function contributions($ip) { |
19 | - global $dir; |
|
19 | + global $dir; |
|
20 | 20 | |
21 | - $file = fetch("/w/index.php?title=Special:Contributions&limit=100&target=$ip"); |
|
22 | - if (!$file) return; |
|
23 | - $fp = fopen($dir . $ip, 'w'); |
|
24 | - fwrite($fp, $file['body']); |
|
25 | - fclose($fp); |
|
26 | - preg_match_all('#<li>(.*?) \(<a[^>]*>hist</a>\) \(<a href="(.*?title=(.*?)&.*?oldid=(.*?))"[^>]*>diff</a>\) <a[^>]*>(.*?)</a> .*?</li>#', $file['body'], $m, PREG_SET_ORDER); |
|
27 | - foreach ($m as $row) { |
|
28 | - # print "$row[3] / $row[4]"; |
|
29 | - $filename = html_entity_decode("$row[3].$row[4]"); |
|
30 | - $path = $dir; |
|
31 | - if (strstr($filename, '/')) { |
|
32 | - $bits = explode('/', $filename); |
|
33 | - array_pop($bits); |
|
34 | - foreach ($bits as $bit) { |
|
35 | - @mkdir($path . $bit); |
|
36 | - $path .= "$bit/"; |
|
37 | - } |
|
38 | - } |
|
39 | - $cache = $dir . $filename; |
|
40 | - if (!is_file($cache)) { |
|
41 | - # print " - fetching"; |
|
42 | - $file = fetch(html_entity_decode($row[2])); |
|
43 | - if (!$file) continue; |
|
44 | - $fp = fopen($cache, 'w'); |
|
45 | - if ($fp) { |
|
46 | - fwrite($fp, $file['body']); |
|
47 | - fclose($fp); |
|
48 | - } |
|
49 | - } |
|
50 | - # print "\n"; |
|
51 | - } |
|
21 | + $file = fetch("/w/index.php?title=Special:Contributions&limit=100&target=$ip"); |
|
22 | + if (!$file) return; |
|
23 | + $fp = fopen($dir . $ip, 'w'); |
|
24 | + fwrite($fp, $file['body']); |
|
25 | + fclose($fp); |
|
26 | + preg_match_all('#<li>(.*?) \(<a[^>]*>hist</a>\) \(<a href="(.*?title=(.*?)&.*?oldid=(.*?))"[^>]*>diff</a>\) <a[^>]*>(.*?)</a> .*?</li>#', $file['body'], $m, PREG_SET_ORDER); |
|
27 | + foreach ($m as $row) { |
|
28 | + # print "$row[3] / $row[4]"; |
|
29 | + $filename = html_entity_decode("$row[3].$row[4]"); |
|
30 | + $path = $dir; |
|
31 | + if (strstr($filename, '/')) { |
|
32 | + $bits = explode('/', $filename); |
|
33 | + array_pop($bits); |
|
34 | + foreach ($bits as $bit) { |
|
35 | + @mkdir($path . $bit); |
|
36 | + $path .= "$bit/"; |
|
37 | + } |
|
38 | + } |
|
39 | + $cache = $dir . $filename; |
|
40 | + if (!is_file($cache)) { |
|
41 | + # print " - fetching"; |
|
42 | + $file = fetch(html_entity_decode($row[2])); |
|
43 | + if (!$file) continue; |
|
44 | + $fp = fopen($cache, 'w'); |
|
45 | + if ($fp) { |
|
46 | + fwrite($fp, $file['body']); |
|
47 | + fclose($fp); |
|
48 | + } |
|
49 | + } |
|
50 | + # print "\n"; |
|
51 | + } |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | function fetch($url) { |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $host = 'en.wikipedia.org'; |
57 | 57 | $fp = @fsockopen($host, 80, $errno, $errstr, 10); |
58 | 58 | if (!$fp) { |
59 | - #print "$errstr ($errno)\n"; |
|
59 | + #print "$errstr ($errno)\n"; |
|
60 | 60 | return ''; |
61 | 61 | } |
62 | 62 | $out = "GET $url HTTP/1.1\r\n"; |
@@ -19,7 +19,9 @@ discard block |
||
19 | 19 | global $dir; |
20 | 20 | |
21 | 21 | $file = fetch("/w/index.php?title=Special:Contributions&limit=100&target=$ip"); |
22 | - if (!$file) return; |
|
22 | + if (!$file) { |
|
23 | + return; |
|
24 | + } |
|
23 | 25 | $fp = fopen($dir . $ip, 'w'); |
24 | 26 | fwrite($fp, $file['body']); |
25 | 27 | fclose($fp); |
@@ -40,7 +42,9 @@ discard block |
||
40 | 42 | if (!is_file($cache)) { |
41 | 43 | # print " - fetching"; |
42 | 44 | $file = fetch(html_entity_decode($row[2])); |
43 | - if (!$file) continue; |
|
45 | + if (!$file) { |
|
46 | + continue; |
|
47 | + } |
|
44 | 48 | $fp = fopen($cache, 'w'); |
45 | 49 | if ($fp) { |
46 | 50 | fwrite($fp, $file['body']); |
@@ -59,7 +59,7 @@ |
||
59 | 59 | #print "$errstr ($errno)\n"; |
60 | 60 | return ''; |
61 | 61 | } |
62 | - $out = "GET $url HTTP/1.1\r\n"; |
|
62 | + $out = "get $url HTTP/1.1\r\n"; |
|
63 | 63 | $out .= "Host: $host\r\n"; |
64 | 64 | $out .= "User-Agent: $ua\r\n"; |
65 | 65 | $out .= "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9;text/plain;q=0.8,image/png,*/*;q=0.5\r\n"; |
@@ -22,26 +22,26 @@ discard block |
||
22 | 22 | $toemail = ''; |
23 | 23 | $template = 'alert_new_mp'; |
24 | 24 | for ($k=1; $k<$argc; $k++) { |
25 | - if ($argv[$k] == '--nomail') |
|
26 | - $nomail = true; |
|
27 | - if (preg_match('#^--only=(.*)$#', $argv[$k], $m)) |
|
28 | - $onlyemail = $m[1]; |
|
29 | - if (preg_match('#^--from=(.*)$#', $argv[$k], $m)) |
|
30 | - $fromemail = $m[1]; |
|
31 | - if (preg_match('#^--to=(.*)$#', $argv[$k], $m)) |
|
32 | - $toemail = $m[1]; |
|
25 | + if ($argv[$k] == '--nomail') |
|
26 | + $nomail = true; |
|
27 | + if (preg_match('#^--only=(.*)$#', $argv[$k], $m)) |
|
28 | + $onlyemail = $m[1]; |
|
29 | + if (preg_match('#^--from=(.*)$#', $argv[$k], $m)) |
|
30 | + $fromemail = $m[1]; |
|
31 | + if (preg_match('#^--to=(.*)$#', $argv[$k], $m)) |
|
32 | + $toemail = $m[1]; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | if (DEVSITE) |
36 | - $nomail = true; |
|
36 | + $nomail = true; |
|
37 | 37 | |
38 | 38 | # Change this to the end date |
39 | 39 | $END_DATE = '2017-05-03'; |
40 | 40 | |
41 | 41 | if ($nomail) mlog("NOT SENDING EMAIL\n"); |
42 | 42 | if (($fromemail && $onlyemail) || ($toemail && $onlyemail)) { |
43 | - mlog("Can't have both from/to and only!\n"); |
|
44 | - exit; |
|
43 | + mlog("Can't have both from/to and only!\n"); |
|
44 | + exit; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | $active = 0; |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | $members = array(); |
67 | 67 | $start_time = time(); |
68 | 68 | foreach ($alertdata as $alertitem) { |
69 | - $active++; |
|
70 | - $email = $alertitem['email']; |
|
69 | + $active++; |
|
70 | + $email = $alertitem['email']; |
|
71 | 71 | if ($onlyemail && $email != $onlyemail) continue; |
72 | 72 | if ($fromemail && strtolower($email) == $fromemail) $fromflag = true; |
73 | 73 | if ($fromemail && !$fromflag) continue; |
@@ -143,9 +143,9 @@ discard block |
||
143 | 143 | |
144 | 144 | $sss = "Active alerts: $active\nEmail lookups: $registered registered, $unregistered unregistered\nQuery lookups: $queries\nSent emails: $sentemails\n"; |
145 | 145 | if ($globalsuccess) { |
146 | - $sss .= 'Everything went swimmingly, in '; |
|
146 | + $sss .= 'Everything went swimmingly, in '; |
|
147 | 147 | } else { |
148 | - $sss .= 'Something went wrong! Total time: '; |
|
148 | + $sss .= 'Something went wrong! Total time: '; |
|
149 | 149 | } |
150 | 150 | $sss .= (getmicrotime()-$global_start)."\n\n"; |
151 | 151 | mlog($sss); |
@@ -155,7 +155,7 @@ |
||
155 | 155 | global $globalsuccess, $sentemails, $nomail, $start_time; |
156 | 156 | |
157 | 157 | $sentemails++; |
158 | - mlog("SEND $sentemails : Sending email to $current[email] ... "); |
|
158 | + mlog("send $sentemails : Sending email to $current[email] ... "); |
|
159 | 159 | $d = array('to' => $current['email'], 'template' => $template); |
160 | 160 | $m = array( |
161 | 161 | 'DATA' => join("\n", $data), |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | $fromflag = false; |
22 | 22 | $toemail = ''; |
23 | 23 | $template = 'alert_new_mp'; |
24 | -for ($k=1; $k<$argc; $k++) { |
|
24 | +for ($k = 1; $k < $argc; $k++) { |
|
25 | 25 | if ($argv[$k] == '--nomail') |
26 | 26 | $nomail = true; |
27 | 27 | if (preg_match('#^--only=(.*)$#', $argv[$k], $m)) |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | // skip if they didn't lose their westminster seat in the most recent election |
92 | 92 | if ($member->left_house(1)['date'] != $END_DATE) continue; |
93 | 93 | |
94 | - if ( !isset($cons[$member->constituency]) ) { |
|
94 | + if (!isset($cons[$member->constituency])) { |
|
95 | 95 | $cons_member = new MEMBER(array('constituency' => $member->constituency, 'house' => 1)); |
96 | - if ( !$cons_member ) { |
|
96 | + if (!$cons_member) { |
|
97 | 97 | continue; |
98 | 98 | } |
99 | 99 | $cons[$member->constituency] = $cons_member; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | } |
103 | 103 | |
104 | 104 | // these should never happen but let's just be sure |
105 | - if ( $cons_member->person_id == $member->person_id ) continue; |
|
105 | + if ($cons_member->person_id == $member->person_id) continue; |
|
106 | 106 | if (!$cons_member->current_member_anywhere()) continue; |
107 | 107 | |
108 | 108 | if ($email != $current['email']) { |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | $user_id = 0; |
123 | 123 | $unregistered++; |
124 | 124 | } |
125 | - mlog("\nEMAIL: $email, uid $user_id; memory usage : ".memory_get_usage()."\n"); |
|
125 | + mlog("\nEMAIL: $email, uid $user_id; memory usage : " . memory_get_usage() . "\n"); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | $lh = $member->left_house(); |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | } else { |
148 | 148 | $sss .= 'Something went wrong! Total time: '; |
149 | 149 | } |
150 | -$sss .= (getmicrotime()-$global_start)."\n\n"; |
|
150 | +$sss .= (getmicrotime() - $global_start) . "\n\n"; |
|
151 | 151 | mlog($sss); |
152 | 152 | mlog(date('r') . "\n"); |
153 | 153 | |
@@ -160,18 +160,18 @@ discard block |
||
160 | 160 | $m = array( |
161 | 161 | 'DATA' => join("\n", $data), |
162 | 162 | 'CHANGE' => join("\n", $change), |
163 | - 'ALERT_IS' => count($data)==1 ? 'alert is' : 'alerts are', |
|
164 | - 'MPS' => count($data)==1 ? 'This MP' : 'These MPs', |
|
165 | - 'MPS2' => count($data)==1 ? 'MP' : 'MPs', |
|
166 | - 'ALERTS' => count($data)==1 ? 'an alert' : 'some alerts', |
|
167 | - 'ALERTS2' => count($data)==1 ? 'alert' : 'alerts', |
|
168 | - 'LINKS' => count($data)==1 ? 'link' : 'links', |
|
163 | + 'ALERT_IS' => count($data) == 1 ? 'alert is' : 'alerts are', |
|
164 | + 'MPS' => count($data) == 1 ? 'This MP' : 'These MPs', |
|
165 | + 'MPS2' => count($data) == 1 ? 'MP' : 'MPs', |
|
166 | + 'ALERTS' => count($data) == 1 ? 'an alert' : 'some alerts', |
|
167 | + 'ALERTS2' => count($data) == 1 ? 'alert' : 'alerts', |
|
168 | + 'LINKS' => count($data) == 1 ? 'link' : 'links', |
|
169 | 169 | ); |
170 | 170 | if (!$nomail) { |
171 | 171 | $success = send_template_email($d, $m, true); |
172 | 172 | mlog("sent ... "); |
173 | 173 | # sleep if time between sending mails is less than a certain number of seconds on average |
174 | - if (((time() - $start_time) / $sentemails) < 0.5 ) { # number of seconds per mail not to be quicker than |
|
174 | + if (((time() - $start_time) / $sentemails) < 0.5) { # number of seconds per mail not to be quicker than |
|
175 | 175 | mlog("pausing ... "); |
176 | 176 | sleep(1); |
177 | 177 | } |
@@ -22,23 +22,30 @@ discard block |
||
22 | 22 | $toemail = ''; |
23 | 23 | $template = 'alert_new_mp'; |
24 | 24 | for ($k=1; $k<$argc; $k++) { |
25 | - if ($argv[$k] == '--nomail') |
|
26 | - $nomail = true; |
|
27 | - if (preg_match('#^--only=(.*)$#', $argv[$k], $m)) |
|
28 | - $onlyemail = $m[1]; |
|
29 | - if (preg_match('#^--from=(.*)$#', $argv[$k], $m)) |
|
30 | - $fromemail = $m[1]; |
|
31 | - if (preg_match('#^--to=(.*)$#', $argv[$k], $m)) |
|
32 | - $toemail = $m[1]; |
|
33 | -} |
|
34 | - |
|
35 | -if (DEVSITE) |
|
25 | + if ($argv[$k] == '--nomail') { |
|
26 | + $nomail = true; |
|
27 | + } |
|
28 | + if (preg_match('#^--only=(.*)$#', $argv[$k], $m)) { |
|
29 | + $onlyemail = $m[1]; |
|
30 | + } |
|
31 | + if (preg_match('#^--from=(.*)$#', $argv[$k], $m)) { |
|
32 | + $fromemail = $m[1]; |
|
33 | + } |
|
34 | + if (preg_match('#^--to=(.*)$#', $argv[$k], $m)) { |
|
35 | + $toemail = $m[1]; |
|
36 | + } |
|
37 | + } |
|
38 | + |
|
39 | +if (DEVSITE) { |
|
36 | 40 | $nomail = true; |
41 | +} |
|
37 | 42 | |
38 | 43 | # Change this to the end date |
39 | 44 | $END_DATE = '2017-05-03'; |
40 | 45 | |
41 | -if ($nomail) mlog("NOT SENDING EMAIL\n"); |
|
46 | +if ($nomail) { |
|
47 | + mlog("NOT SENDING EMAIL\n"); |
|
48 | +} |
|
42 | 49 | if (($fromemail && $onlyemail) || ($toemail && $onlyemail)) { |
43 | 50 | mlog("Can't have both from/to and only!\n"); |
44 | 51 | exit; |
@@ -68,14 +75,24 @@ discard block |
||
68 | 75 | foreach ($alertdata as $alertitem) { |
69 | 76 | $active++; |
70 | 77 | $email = $alertitem['email']; |
71 | - if ($onlyemail && $email != $onlyemail) continue; |
|
72 | - if ($fromemail && strtolower($email) == $fromemail) $fromflag = true; |
|
73 | - if ($fromemail && !$fromflag) continue; |
|
74 | - if ($toemail && strtolower($email) >= $toemail) continue; |
|
78 | + if ($onlyemail && $email != $onlyemail) { |
|
79 | + continue; |
|
80 | + } |
|
81 | + if ($fromemail && strtolower($email) == $fromemail) { |
|
82 | + $fromflag = true; |
|
83 | + } |
|
84 | + if ($fromemail && !$fromflag) { |
|
85 | + continue; |
|
86 | + } |
|
87 | + if ($toemail && strtolower($email) >= $toemail) { |
|
88 | + continue; |
|
89 | + } |
|
75 | 90 | $criteria_raw = $alertitem['criteria']; |
76 | 91 | |
77 | 92 | // we only care about alerts for people speaking |
78 | - if (!strstr($criteria_raw, 'speaker:')) continue; |
|
93 | + if (!strstr($criteria_raw, 'speaker:')) { |
|
94 | + continue; |
|
95 | + } |
|
79 | 96 | |
80 | 97 | preg_match('#speaker:(\d+)#', $criteria_raw, $m); |
81 | 98 | $person_id = $m[1]; |
@@ -86,10 +103,14 @@ discard block |
||
86 | 103 | $member = $members[$person_id]; |
87 | 104 | |
88 | 105 | // if they're still elected then don't send the email |
89 | - if ($member->current_member_anywhere()) continue; |
|
106 | + if ($member->current_member_anywhere()) { |
|
107 | + continue; |
|
108 | + } |
|
90 | 109 | |
91 | 110 | // skip if they didn't lose their westminster seat in the most recent election |
92 | - if ($member->left_house(1)['date'] != $END_DATE) continue; |
|
111 | + if ($member->left_house(1)['date'] != $END_DATE) { |
|
112 | + continue; |
|
113 | + } |
|
93 | 114 | |
94 | 115 | if ( !isset($cons[$member->constituency]) ) { |
95 | 116 | $cons_member = new MEMBER(array('constituency' => $member->constituency, 'house' => 1)); |
@@ -97,13 +118,18 @@ discard block |
||
97 | 118 | continue; |
98 | 119 | } |
99 | 120 | $cons[$member->constituency] = $cons_member; |
100 | - } else { |
|
121 | + } |
|
122 | + else { |
|
101 | 123 | $cons_member = $cons[$member->constituency]; |
102 | 124 | } |
103 | 125 | |
104 | 126 | // these should never happen but let's just be sure |
105 | - if ( $cons_member->person_id == $member->person_id ) continue; |
|
106 | - if (!$cons_member->current_member_anywhere()) continue; |
|
127 | + if ( $cons_member->person_id == $member->person_id ) { |
|
128 | + continue; |
|
129 | + } |
|
130 | + if (!$cons_member->current_member_anywhere()) { |
|
131 | + continue; |
|
132 | + } |
|
107 | 133 | |
108 | 134 | if ($email != $current['email']) { |
109 | 135 | if ($email_text && $change_text) { |
@@ -118,7 +144,8 @@ discard block |
||
118 | 144 | if ($q->rows() > 0) { |
119 | 145 | $user_id = $q->field(0, 'user_id'); |
120 | 146 | $registered++; |
121 | - } else { |
|
147 | + } |
|
148 | + else { |
|
122 | 149 | $user_id = 0; |
123 | 150 | $unregistered++; |
124 | 151 | } |
@@ -144,7 +171,8 @@ discard block |
||
144 | 171 | $sss = "Active alerts: $active\nEmail lookups: $registered registered, $unregistered unregistered\nQuery lookups: $queries\nSent emails: $sentemails\n"; |
145 | 172 | if ($globalsuccess) { |
146 | 173 | $sss .= 'Everything went swimmingly, in '; |
147 | -} else { |
|
174 | +} |
|
175 | +else { |
|
148 | 176 | $sss .= 'Something went wrong! Total time: '; |
149 | 177 | } |
150 | 178 | $sss .= (getmicrotime()-$global_start)."\n\n"; |
@@ -171,11 +199,13 @@ discard block |
||
171 | 199 | $success = send_template_email($d, $m, true); |
172 | 200 | mlog("sent ... "); |
173 | 201 | # sleep if time between sending mails is less than a certain number of seconds on average |
174 | - if (((time() - $start_time) / $sentemails) < 0.5 ) { # number of seconds per mail not to be quicker than |
|
202 | + if (((time() - $start_time) / $sentemails) < 0.5 ) { |
|
203 | +# number of seconds per mail not to be quicker than |
|
175 | 204 | mlog("pausing ... "); |
176 | 205 | sleep(1); |
177 | 206 | } |
178 | - } else { |
|
207 | + } |
|
208 | + else { |
|
179 | 209 | mlog(join('', $data)); |
180 | 210 | $success = 1; |
181 | 211 | } |
@@ -16,7 +16,9 @@ discard block |
||
16 | 16 | |
17 | 17 | $date = substr($from, 0, 10); |
18 | 18 | $from = 'uk.org.publicwhip/debate/' . $from; |
19 | -if ($to) $to = 'uk.org.publicwhip/debate/' . $to; |
|
19 | +if ($to) { |
|
20 | + $to = 'uk.org.publicwhip/debate/' . $to; |
|
21 | +} |
|
20 | 22 | |
21 | 23 | $q = $db->query('select hpos from hansard where gid="' . $from . '"'); |
22 | 24 | $hpos_from = $q->field(0, 'hpos'); |
@@ -34,8 +36,9 @@ discard block |
||
34 | 36 | |
35 | 37 | $query = "update hansard set video_status = video_status | 8 |
36 | 38 | where major=1 and hdate='$date' and hpos>=$hpos_from"; |
37 | -if ($to) |
|
39 | +if ($to) { |
|
38 | 40 | $query .= " and hpos<=$hpos_to"; |
41 | +} |
|
39 | 42 | |
40 | 43 | print "Executing $query...\n"; |
41 | 44 | $q = $db->query($query); |
@@ -37,6 +37,6 @@ |
||
37 | 37 | if ($to) |
38 | 38 | $query .= " and hpos<=$hpos_to"; |
39 | 39 | |
40 | -print "Executing $query...\n"; |
|
40 | +print "executing $query...\n"; |
|
41 | 41 | $q = $db->query($query); |
42 | 42 | print ' ' . $q->affected_rows() . " rows have been marked as missing\n"; |