Completed
Pull Request — master (#965)
by Nick
05:26
created
www/docs/boundaries/index.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 $this_page = 'boundaries';
4 4
 include_once '../../includes/easyparliament/init.php';
5
-include_once INCLUDESPATH . '../../commonlib/phplib/mapit.php';
5
+include_once INCLUDESPATH.'../../commonlib/phplib/mapit.php';
6 6
 
7 7
 $PAGE->page_start();
8 8
 ?>
@@ -66,16 +66,16 @@  discard block
 block discarded – undo
66 66
     $db = new ParlDB;
67 67
     # Just left politicians
68 68
     $q = $db->query("SELECT person_id, first_name, last_name, constituency, house FROM member
69
-        WHERE constituency IN ('" . join("','", $a) . "')
69
+        WHERE constituency IN ('" . join("','", $a)."')
70 70
         AND ( ( house = 3 and left_house = '2011-03-24' ) or ( house = 4 and left_house = '2011-03-23') )");
71 71
     $mreg = array();
72
-    for ($i=0; $i<$q->rows(); $i++) {
72
+    for ($i = 0; $i < $q->rows(); $i++) {
73 73
         $cons = $q->field($i, 'constituency');
74 74
         $house = $q->field($i, 'house');
75 75
         if (($house == 4 && $cons == $current['SPC']) || ($house == 3 && $cons == $current['NIE'])) {
76
-            $name = $q->field($i, 'first_name') . ' ' . $q->field($i, 'last_name');
76
+            $name = $q->field($i, 'first_name').' '.$q->field($i, 'last_name');
77 77
         } elseif ($house == 4 && $cons == $current['SPE']) {
78
-            $mreg[] = $q->field($i, 'first_name') . ' ' . $q->field($i, 'last_name');
78
+            $mreg[] = $q->field($i, 'first_name').' '.$q->field($i, 'last_name');
79 79
         }
80 80
     }
81 81
 
@@ -129,17 +129,17 @@  discard block
 block discarded – undo
129 129
     }
130 130
 
131 131
     if ($country == 'S') {
132
-        $mp_url = '/msp/' . make_member_url($name, '', 4);
132
+        $mp_url = '/msp/'.make_member_url($name, '', 4);
133 133
 ?>
134 134
 <li>You were in the <strong><?=$current['SPC']?></strong> constituency, in the <strong><?=$current['SPE']?></strong> region; your constituency MSP was <a href='<?=$mp_url?>'><?=$name?></a>, and your regional MSPs were <?php
135 135
         foreach ($mreg as $k => $n) {
136
-            print "<a href='/msp/" . make_member_url($n, '', 4) . "'>$n</a>";
137
-            if ($k < count($mreg)-2) print ', ';
138
-            elseif ($k == count($mreg)-2) print ' and ';
136
+            print "<a href='/msp/".make_member_url($n, '', 4)."'>$n</a>";
137
+            if ($k < count($mreg) - 2) print ', ';
138
+            elseif ($k == count($mreg) - 2) print ' and ';
139 139
         }
140 140
         echo '.</li>';
141 141
     } elseif ($country == 'N') {
142
-        $mp_url = '/mla/' . make_member_url($name, '', 3);
142
+        $mp_url = '/mla/'.make_member_url($name, '', 3);
143 143
 ?>
144 144
 <li>You were in the <strong><?=$current['NIE']?></strong> constituency; your constituency MLA was <a href='<?=$mp_url?>'><?=$name?></a>.</li>
145 145
 <?php
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -134,8 +134,11 @@
 block discarded – undo
134 134
 <li>You were in the <strong><?=$current['SPC']?></strong> constituency, in the <strong><?=$current['SPE']?></strong> region; your constituency MSP was <a href='<?=$mp_url?>'><?=$name?></a>, and your regional MSPs were <?php
135 135
         foreach ($mreg as $k => $n) {
136 136
             print "<a href='/msp/" . make_member_url($n, '', 4) . "'>$n</a>";
137
-            if ($k < count($mreg)-2) print ', ';
138
-            elseif ($k == count($mreg)-2) print ' and ';
137
+            if ($k < count($mreg)-2) {
138
+                print ', ';
139
+            } elseif ($k == count($mreg)-2) {
140
+                print ' and ';
141
+            }
139 142
         }
140 143
         echo '.</li>';
141 144
     } elseif ($country == 'N') {
Please login to merge, or discard this patch.
www/docs/divisions/division.php 3 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -43,11 +43,11 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
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
 $this_page = 'divisions_vote';
7 7
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
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';
Please login to merge, or discard this patch.
www/docs/divisions/index.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -10,12 +10,12 @@
 block discarded – undo
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'];
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
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
 $this_page = 'divisions_recent';
7 7
 
Please login to merge, or discard this patch.
www/docs/wikipedia/index.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
     $ip = '194.60.38.10';
14 14
 
15 15
 $this_page = 'wikipedia';
16
-$DATA->set_page_metadata($this_page, 'title', 'Latest 100 changes to Wikipedia by non-logged-in computers in ' . $site[$ip]);
16
+$DATA->set_page_metadata($this_page, 'title', 'Latest 100 changes to Wikipedia by non-logged-in computers in '.$site[$ip]);
17 17
 $PAGE->page_start();
18 18
 $PAGE->stripe_start();
19 19
 ?>
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 preg_match_all('#<li>.*? \(<a[^>]*>hist</a>\) \(<a href=".*?title=(.*?)&.*?oldid=(.*?)"[^>]*>diff</a>\)  <a[^>]*>(.*?)</a> .*?</li>#', $file, $m, PREG_SET_ORDER);
52 52
 foreach ($m as $row) {
53 53
     $file = file_get_contents("cache/$row[1].$row[2]");
54
-    $file = str_replace(array("\xe2\x86\x90","\xe2\x86\x92"), array('&larr;', '&rarr;'), $file);
54
+    $file = str_replace(array("\xe2\x86\x90", "\xe2\x86\x92"), array('&larr;', '&rarr;'), $file);
55 55
     print "<h3>$row[3]</h3>";
56 56
     if (preg_match('#<table.*?</table>#s', $file, $m))
57 57
         print preg_replace('#href=(\'|")(.*?)\1#', 'href=\1http://en.wikipedia.org\2\1', $m[0]);
Please login to merge, or discard this patch.
Braces   +13 added lines, -10 removed lines patch added patch discarded remove patch
@@ -9,8 +9,9 @@  discard block
 block discarded – undo
9 9
     '212.35.252.2' => 'Liberal Democrats',
10 10
 );
11 11
 $ip = get_http_var('ip');
12
-if (!array_key_exists($ip, $site))
12
+if (!array_key_exists($ip, $site)) {
13 13
     $ip = '194.60.38.10';
14
+}
14 15
 
15 16
 $this_page = 'wikipedia';
16 17
 $DATA->set_page_metadata($this_page, 'title', 'Latest 100 changes to Wikipedia by non-logged-in computers in ' . $site[$ip]);
@@ -28,10 +29,11 @@  discard block
 block discarded – undo
28 29
 <p align="center"><?php
29 30
 $out = array();
30 31
 foreach ($site as $k => $v) {
31
-    if ($k == $ip)
32
-        $o = "<strong>$v</strong>";
33
-    else
34
-        $o = "<a href=\"./?ip=$k\">$v</a>";
32
+    if ($k == $ip) {
33
+            $o = "<strong>$v</strong>";
34
+    } else {
35
+            $o = "<a href=\"./?ip=$k\">$v</a>";
36
+    }
35 37
     $out[] = $o;
36 38
 }
37 39
 print join(' | ', $out);
@@ -53,11 +55,12 @@  discard block
 block discarded – undo
53 55
     $file = file_get_contents("cache/$row[1].$row[2]");
54 56
     $file = str_replace(array("\xe2\x86\x90","\xe2\x86\x92"), array('&larr;', '&rarr;'), $file);
55 57
     print "<h3>$row[3]</h3>";
56
-    if (preg_match('#<table.*?</table>#s', $file, $m))
57
-        print preg_replace('#href=(\'|")(.*?)\1#', 'href=\1http://en.wikipedia.org\2\1', $m[0]);
58
-    elseif (preg_match('#<div class="firstrevisionheader.*?</div>#s', $file, $m))
59
-        print preg_replace('#href=(\'|")(.*?)\1#', 'href=\1http://en.wikipedia.org\2\1', $m[0]);
60
-}
58
+    if (preg_match('#<table.*?</table>#s', $file, $m)) {
59
+            print preg_replace('#href=(\'|")(.*?)\1#', 'href=\1http://en.wikipedia.org\2\1', $m[0]);
60
+    } elseif (preg_match('#<div class="firstrevisionheader.*?</div>#s', $file, $m)) {
61
+            print preg_replace('#href=(\'|")(.*?)\1#', 'href=\1http://en.wikipedia.org\2\1', $m[0]);
62
+    }
63
+    }
61 64
 
62 65
 $PAGE->stripe_end();
63 66
 $PAGE->page_end();
Please login to merge, or discard this patch.
www/docs/images/mps/photo-status.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
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
 $DATA->set_page_metadata($this_page, 'heading', 'MPs photo status on TheyWorkForYou');
6 6
 $PAGE->page_start();
7 7
 $PAGE->stripe_start();
@@ -9,17 +9,17 @@  discard block
 block discarded – undo
9 9
 $query = 'SELECT person_id, constituency, party
10 10
     FROM member
11 11
     WHERE house=1 AND left_house = (SELECT MAX(left_house) FROM member) ';
12
-$q = $db->query($query . "ORDER BY person_id");
12
+$q = $db->query($query."ORDER BY person_id");
13 13
 $out = array('both'=>'', 'small'=>'', 'none'=>array());
14
-for ($i=0; $i<$q->rows(); $i++) {
14
+for ($i = 0; $i < $q->rows(); $i++) {
15 15
     $p_id = $q->field($i, 'person_id');
16 16
     list($dummy, $sz) = MySociety\TheyWorkForYou\Utility\Member::findMemberImage($p_id);
17 17
     if ($sz == 'L') {
18
-        $out['both'] .= $q->field($i, 'person_id') . ', ';
18
+        $out['both'] .= $q->field($i, 'person_id').', ';
19 19
     } elseif ($sz == 'S') {
20
-        $out['small'] .= $q->field($i, 'person_id') . ', ';
20
+        $out['small'] .= $q->field($i, 'person_id').', ';
21 21
     } else {
22
-        array_push($out['none'], '<li>' . $q->field($i, 'person_id') . ' (' . $q->field($i, 'party') . ')' . ', ' . $q->field($i, 'constituency'));
22
+        array_push($out['none'], '<li>'.$q->field($i, 'person_id').' ('.$q->field($i, 'party').')'.', '.$q->field($i, 'constituency'));
23 23
     }
24 24
 }
25 25
 print '<h3>Missing completely ('.count($out['none']).')</h3> <ul>';
Please login to merge, or discard this patch.
scripts/populate-policy-images.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
  */
22 22
 
23 23
 include '../www/includes/easyparliament/init.php';
24
-include_once INCLUDESPATH . 'easyparliament/member.php';
24
+include_once INCLUDESPATH.'easyparliament/member.php';
25 25
 
26 26
 $ARGV = $_SERVER['argv'];
27 27
 $db = new ParlDB();
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
     exit(1);
34 34
 }
35 35
 
36
-if ( !file_exists($csvfile) ) {
36
+if (!file_exists($csvfile)) {
37 37
     print "$csvfile cannot be found\n";
38 38
     exit(1);
39 39
 }
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 }
47 47
 
48 48
 $count = 0;
49
-while ( ( $policy = fgetcsv($file) ) !== FALSE ) {
50
-    if ( intval($policy[0]) ) {
49
+while (($policy = fgetcsv($file)) !== FALSE) {
50
+    if (intval($policy[0])) {
51 51
         $policy_id = $policy[0];
52 52
         $img_id = $policy[1] ? $policy[1] : $policy_id;
53 53
         $title = $policy[2];
@@ -64,12 +64,12 @@  discard block
 block discarded – undo
64 64
                 ':policy_id' => $policy_id,
65 65
                 ':title' => $title,
66 66
                 ':description' => $description,
67
-                ':image' => "/images/policies/" . $img_id . ".jpg",
67
+                ':image' => "/images/policies/".$img_id.".jpg",
68 68
                 ':image_source' => $source,
69 69
                 ':image_attribution' => $attribution,
70 70
                 ':license_url' => $licence_url)
71 71
         );
72
-        if ( $q->success() ) {
72
+        if ($q->success()) {
73 73
             $count += $q->affected_rows();
74 74
         } else {
75 75
             print "failed to update data for $policy_id\n";
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@
 block discarded – undo
46 46
 }
47 47
 
48 48
 $count = 0;
49
-while ( ( $policy = fgetcsv($file) ) !== FALSE ) {
49
+while ( ( $policy = fgetcsv($file) ) !== false ) {
50 50
     if ( intval($policy[0]) ) {
51 51
         $policy_id = $policy[0];
52 52
         $img_id = $policy[1] ? $policy[1] : $policy_id;
Please login to merge, or discard this patch.
scripts/wikipedia-cron.php 4 patches
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -16,39 +16,39 @@  discard block
 block discarded – undo
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
 block discarded – undo
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";
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -5,9 +5,9 @@  discard block
 block discarded – undo
5 5
 # from Parliament, political party IP addresses etc.
6 6
 # (the stuff for Wikipedia title links is elsewhere)
7 7
 
8
-require_once dirname(__FILE__) . '/../conf/general';
8
+require_once dirname(__FILE__).'/../conf/general';
9 9
 
10
-$dir = BASEDIR . '/wikipedia/cache/';
10
+$dir = BASEDIR.'/wikipedia/cache/';
11 11
 
12 12
 contributions('194.60.38.10'); # Parliament
13 13
 contributions('194.203.158.97'); # Conservative
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 
21 21
 	$file = fetch("/w/index.php?title=Special:Contributions&limit=100&target=$ip");
22 22
 	if (!$file) return;
23
-	$fp = fopen($dir . $ip, 'w');
23
+	$fp = fopen($dir.$ip, 'w');
24 24
 	fwrite($fp, $file['body']);
25 25
 	fclose($fp);
26 26
 	preg_match_all('#<li>(.*?) \(<a[^>]*>hist</a>\) \(<a href="(.*?title=(.*?)&.*?oldid=(.*?))"[^>]*>diff</a>\)  <a[^>]*>(.*?)</a> .*?</li>#', $file['body'], $m, PREG_SET_ORDER);
@@ -32,11 +32,11 @@  discard block
 block discarded – undo
32 32
 			$bits = explode('/', $filename);
33 33
 			array_pop($bits);
34 34
 			foreach ($bits as $bit) {
35
-				@mkdir($path . $bit);
35
+				@mkdir($path.$bit);
36 36
 				$path .= "$bit/";
37 37
 			}
38 38
 		}
39
-		$cache = $dir . $filename;
39
+		$cache = $dir.$filename;
40 40
 		if (!is_file($cache)) {
41 41
 			# print " - fetching";
42 42
 			$file = fetch(html_entity_decode($row[2]));
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,7 +19,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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']);
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@
 block discarded – undo
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";
Please login to merge, or discard this patch.
scripts/alertmpchanged.php 4 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -22,26 +22,26 @@  discard block
 block discarded – undo
22 22
 $toemail = '';
23 23
 $template = 'alert_new_mp';
24 24
 for ($k=1; $k<$argc; $k++) {
25
-	if ($argv[$k] == '--nomail')
26
-		$nomail = true;
27
-	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
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -8,9 +8,9 @@  discard block
 block discarded – undo
8 8
     print $message;
9 9
 }
10 10
 
11
-include_once dirname(__FILE__) . '/../www/includes/easyparliament/init.php';
11
+include_once dirname(__FILE__).'/../www/includes/easyparliament/init.php';
12 12
 ini_set('memory_limit', -1);
13
-include_once INCLUDESPATH . 'easyparliament/member.php';
13
+include_once INCLUDESPATH.'easyparliament/member.php';
14 14
 
15 15
 $global_start = getmicrotime();
16 16
 $db = new ParlDB;
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 $fromflag = false;
22 22
 $toemail = '';
23 23
 $template = 'alert_new_mp';
24
-for ($k=1; $k<$argc; $k++) {
24
+for ($k = 1; $k < $argc; $k++) {
25 25
 	if ($argv[$k] == '--nomail')
26 26
 		$nomail = true;
27 27
 	if (preg_match('#^--only=(.*)$#', $argv[$k], $m))
@@ -91,9 +91,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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']) {
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
             write_and_send_email($current, $email_text, $change_text, $template);
111 111
         }
112 112
         $current['email'] = $email;
113
-        $current['token'] = $alertitem['alert_id'] . '-' . $alertitem['registrationtoken'];
113
+        $current['token'] = $alertitem['alert_id'].'-'.$alertitem['registrationtoken'];
114 114
         $email_text = array();
115 115
         $change_text = array();
116 116
         $q = $db->query('SELECT user_id FROM users WHERE email = :email', array(
@@ -127,11 +127,11 @@  discard block
 block discarded – undo
127 127
 
128 128
     $lh = $member->left_house();
129 129
     $lh = array_shift($lh);
130
-    $text = '* ' . $member->full_name();
130
+    $text = '* '.$member->full_name();
131 131
     if (!in_array($text, $email_text)) {
132 132
         $email_text[] = $text;
133 133
 
134
-        $change = '* ' . $member->full_name() . ': https://' . DOMAIN . '/C/' . $alertitem['registrationtoken'];
134
+        $change = '* '.$member->full_name().': https://'.DOMAIN.'/C/'.$alertitem['registrationtoken'];
135 135
         $change_text[] = $change;
136 136
     }
137 137
 }
@@ -147,9 +147,9 @@  discard block
 block discarded – undo
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
-mlog(date('r') . "\n");
152
+mlog(date('r')."\n");
153 153
 
154 154
 function write_and_send_email($current, $data, $change, $template) {
155 155
     global $globalsuccess, $sentemails, $nomail, $start_time;
@@ -160,18 +160,18 @@  discard block
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
Braces   +46 added lines, -21 removed lines patch added patch discarded remove patch
@@ -22,23 +22,30 @@  discard block
 block discarded – undo
22 22
 $toemail = '';
23 23
 $template = 'alert_new_mp';
24 24
 for ($k=1; $k<$argc; $k++) {
25
-	if ($argv[$k] == '--nomail')
26
-		$nomail = true;
27
-	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
 block discarded – undo
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
 block discarded – undo
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));
@@ -102,8 +123,12 @@  discard block
 block discarded – undo
102 123
     }
103 124
 
104 125
     // 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;
126
+    if ( $cons_member->person_id == $member->person_id ) {
127
+        continue;
128
+    }
129
+    if (!$cons_member->current_member_anywhere()) {
130
+        continue;
131
+    }
107 132
 
108 133
     if ($email != $current['email']) {
109 134
         if ($email_text && $change_text) {
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -155,7 +155,7 @@
 block discarded – undo
155 155
     global $globalsuccess, $sentemails, $nomail, $start_time;
156 156
 
157 157
     $sentemails++;
158
-    mlog("SEND $sentemails : Sending email to $current[email] ... ");
158
+    mlog("send $sentemails : Sending email to $current[email] ... ");
159 159
     $d = array('to' => $current['email'], 'template' => $template);
160 160
     $m = array(
161 161
         'DATA' => join("\n", $data),
Please login to merge, or discard this patch.
scripts/video-mark-missing.php 3 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -15,17 +15,17 @@  discard block
 block discarded – undo
15 15
 }
16 16
 
17 17
 $date = substr($from, 0, 10);
18
-$from = 'uk.org.publicwhip/debate/' . $from;
19
-if ($to) $to = 'uk.org.publicwhip/debate/' . $to;
18
+$from = 'uk.org.publicwhip/debate/'.$from;
19
+if ($to) $to = 'uk.org.publicwhip/debate/'.$to;
20 20
 
21
-$q = $db->query('select hpos from hansard where gid="' . $from . '"');
21
+$q = $db->query('select hpos from hansard where gid="'.$from.'"');
22 22
 $hpos_from = $q->field(0, 'hpos');
23 23
 if (!$hpos_from) {
24 24
     print "No hpos for from gid!\n"; exit;
25 25
 }
26 26
 
27 27
 if ($to) {
28
-    $q = $db->query('select hpos from hansard where gid="' . $to . '"');
28
+    $q = $db->query('select hpos from hansard where gid="'.$to.'"');
29 29
     $hpos_to = $q->field(0, 'hpos');
30 30
     if (!$hpos_to) {
31 31
         print "No hpos for to gid!\n"; exit;
@@ -39,4 +39,4 @@  discard block
 block discarded – undo
39 39
 
40 40
 print "Executing $query...\n";
41 41
 $q = $db->query($query);
42
-print '  ' . $q->affected_rows() . " rows have been marked as missing\n";
42
+print '  '.$q->affected_rows()." rows have been marked as missing\n";
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,7 +16,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,6 +37,6 @@
 block discarded – undo
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";
Please login to merge, or discard this patch.