Failed Conditions
Pull Request — master (#1325)
by Nick
26:10 queued 21:10
created
www/docs/api/key.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 include_once '../../includes/easyparliament/init.php';
4 4
 include_once './api_functions.php';
5
-include_once INCLUDESPATH . '../../commonlib/phplib/auth.php';
5
+include_once INCLUDESPATH.'../../commonlib/phplib/auth.php';
6 6
 
7 7
 $a = auth_ab64_encode(urandom_bytes(32));
8 8
 
@@ -21,15 +21,15 @@  discard block
 block discarded – undo
21 21
     if (get_http_var('create_key') && get_http_var('reason')) {
22 22
         $estimated_usage = (int) get_http_var('estimated_usage');
23 23
         $commercial = get_http_var('commercial');
24
-        create_key($commercial, get_http_var('reason'),  $estimated_usage);
24
+        create_key($commercial, get_http_var('reason'), $estimated_usage);
25 25
         if ($commercial == '1' || $estimated_usage > 50000) {
26 26
             echo '<p><strong>It looks like your usage may fall outside of our free-of-charge bracket: if that\'s the case, this key might get blocked, so we\'d advise you to email us at <a href="[email protected]">[email protected]</a> to discuss licensing options.</strong></p>';
27 27
         }
28 28
     }
29 29
     $db = new ParlDB;
30
-    $q = $db->query('SELECT api_key, commercial, created, reason, estimated_usage FROM api_key WHERE user_id=' . $THEUSER->user_id());
30
+    $q = $db->query('SELECT api_key, commercial, created, reason, estimated_usage FROM api_key WHERE user_id='.$THEUSER->user_id());
31 31
     $keys = array();
32
-    for ($i=0; $i<$q->rows(); $i++) {
32
+    for ($i = 0; $i < $q->rows(); $i++) {
33 33
         $keys[] = array($q->field($i, 'api_key'), $q->field($i, 'commercial'), $q->field($i, 'created'), $q->field($i, 'reason'), $q->field($i, 'estimated_usage'));
34 34
     }
35 35
     if ($keys) {
@@ -37,19 +37,19 @@  discard block
 block discarded – undo
37 37
     }
38 38
     foreach ($keys as $keyarr) {
39 39
         list($key, $commercial, $created, $reason, $estimated_usage) = $keyarr;
40
-        echo '<li><span style="font-size:200%">' . $key . '</span><br><span style="color: #666666;">';
41
-        if ($commercial==1) echo 'Commercial key,';
42
-        elseif ($commercial==-1) echo 'Key';
40
+        echo '<li><span style="font-size:200%">'.$key.'</span><br><span style="color: #666666;">';
41
+        if ($commercial == 1) echo 'Commercial key,';
42
+        elseif ($commercial == -1) echo 'Key';
43 43
         else echo 'Non-commercial key,';
44 44
         echo ' created ', $created, '; ', $reason, '; estimated usage ', $estimated_usage;
45 45
         echo '</span><br><em>Usage statistics</em>: ';
46
-        $q = $db->query('SELECT count(*) as count FROM api_stats WHERE api_key="' . $key . '" AND query_time > NOW() - interval 1 day');
46
+        $q = $db->query('SELECT count(*) as count FROM api_stats WHERE api_key="'.$key.'" AND query_time > NOW() - interval 1 day');
47 47
         $c = $q->field(0, 'count');
48 48
         echo "last 24 hours: $c, ";
49
-        $q = $db->query('SELECT count(*) as count FROM api_stats WHERE api_key="' . $key . '" AND query_time > NOW() - interval 1 week');
49
+        $q = $db->query('SELECT count(*) as count FROM api_stats WHERE api_key="'.$key.'" AND query_time > NOW() - interval 1 week');
50 50
         $c = $q->field(0, 'count');
51 51
         echo "last week: $c, ";
52
-        $q = $db->query('SELECT count(*) as count FROM api_stats WHERE api_key="' . $key . '" AND query_time > NOW() - interval 1 month');
52
+        $q = $db->query('SELECT count(*) as count FROM api_stats WHERE api_key="'.$key.'" AND query_time > NOW() - interval 1 month');
53 53
         $c = $q->field(0, 'count');
54 54
         echo "last month: $c";
55 55
         echo '</p>';
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
     global $THEUSER;
76 76
     $key = auth_ab64_encode(urandom_bytes(16));
77 77
     $db = new ParlDB;
78
-    if ($commercial=='') $commercial = 0;
78
+    if ($commercial == '') $commercial = 0;
79 79
     $db->query('INSERT INTO api_key (user_id, api_key, commercial, created, reason, estimated_usage) VALUES
80 80
         (:user_id, :key, :commercial, NOW(), :reason, :estimated_usage)', array(
81 81
         ':user_id' => $THEUSER->user_id(),
Please login to merge, or discard this patch.
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -38,9 +38,13 @@  discard block
 block discarded – undo
38 38
     foreach ($keys as $keyarr) {
39 39
         list($key, $commercial, $created, $reason, $estimated_usage) = $keyarr;
40 40
         echo '<li><span style="font-size:200%">' . $key . '</span><br><span style="color: #666666;">';
41
-        if ($commercial==1) echo 'Commercial key,';
42
-        elseif ($commercial==-1) echo 'Key';
43
-        else echo 'Non-commercial key,';
41
+        if ($commercial==1) {
42
+            echo 'Commercial key,';
43
+        } elseif ($commercial==-1) {
44
+            echo 'Key';
45
+        } else {
46
+            echo 'Non-commercial key,';
47
+        }
44 48
         echo ' created ', $created, '; ', $reason, '; estimated usage ', $estimated_usage;
45 49
         echo '</span><br><em>Usage statistics</em>: ';
46 50
         $q = $db->query('SELECT count(*) as count FROM api_stats WHERE api_key="' . $key . '" AND query_time > NOW() - interval 1 day');
@@ -75,7 +79,9 @@  discard block
 block discarded – undo
75 79
     global $THEUSER;
76 80
     $key = auth_ab64_encode(urandom_bytes(16));
77 81
     $db = new ParlDB;
78
-    if ($commercial=='') $commercial = 0;
82
+    if ($commercial=='') {
83
+        $commercial = 0;
84
+    }
79 85
     $db->query('INSERT INTO api_key (user_id, api_key, commercial, created, reason, estimated_usage) VALUES
80 86
         (:user_id, :key, :commercial, NOW(), :reason, :estimated_usage)', array(
81 87
         ':user_id' => $THEUSER->user_id(),
Please login to merge, or discard this patch.
www/docs/api/api_getCommittee.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -57,16 +57,16 @@  discard block
 block discarded – undo
57 57
     $name = preg_replace('#\s+Committee#', '', $name);
58 58
 
59 59
     $date = parse_date(get_http_var('date'));
60
-    if ($date) $date = '"' . $date['iso'] . '"';
60
+    if ($date) $date = '"'.$date['iso'].'"';
61 61
     else $date = 'date(now())';
62 62
     $q = $db->query("select distinct(dept) from moffice
63 63
         where dept like :department
64 64
         and from_date <= $date and $date <= to_date", array(
65
-            ':department' => '%' . $name . '%Committee',
65
+            ':department' => '%'.$name.'%Committee',
66 66
             ));
67 67
     if ($q->rows() > 1) {
68 68
         # More than one committee matches
69
-        for ($i=0; $i<$q->rows(); $i++) {
69
+        for ($i = 0; $i < $q->rows(); $i++) {
70 70
             $output['committees'][] = array(
71 71
                 'name' => $q->field($i, 'dept')
72 72
             );
@@ -80,15 +80,15 @@  discard block
 block discarded – undo
80 80
             and dept like :department
81 81
             and from_date <= $date and $date <= to_date
82 82
             and entered_house <= $date and $date <= left_house", array(
83
-                ':department' => '%' . $name . '%Committee',
83
+                ':department' => '%'.$name.'%Committee',
84 84
             ));
85 85
         if ($q->rows()) {
86 86
             $output = array();
87 87
             $output['committee'] = $q->field(0, 'dept');
88
-            for ($i=0; $i<$q->rows(); $i++) {
88
+            for ($i = 0; $i < $q->rows(); $i++) {
89 89
                 $member = array(
90 90
                     'person_id' => $q->field($i, 'person'),
91
-                    'name' => $q->field($i, 'given_name') . ' ' . $q->field($i, 'family_name'),
91
+                    'name' => $q->field($i, 'given_name').' '.$q->field($i, 'family_name'),
92 92
                 );
93 93
                 if ($q->field($i, 'position') == 'Chairman') {
94 94
                     $member['position'] = $q->field($i, 'position');
@@ -108,13 +108,13 @@  discard block
 block discarded – undo
108 108
     $db = new ParlDB;
109 109
 
110 110
     $date = parse_date($date);
111
-    if ($date) $date = '"' . $date['iso'] . '"';
111
+    if ($date) $date = '"'.$date['iso'].'"';
112 112
     else $date = 'date(now())';
113 113
     $q = $db->query("select distinct(dept) from moffice
114 114
         where source = 'chgpages/selctee'
115 115
         and from_date <= $date and $date <= to_date");
116 116
     if ($q->rows()) {
117
-        for ($i=0; $i<$q->rows(); $i++) {
117
+        for ($i = 0; $i < $q->rows(); $i++) {
118 118
             $output['committees'][] = array(
119 119
                 'name' => $q->field($i, 'dept')
120 120
             );
Please login to merge, or discard this patch.
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -57,8 +57,11 @@  discard block
 block discarded – undo
57 57
     $name = preg_replace('#\s+Committee#', '', $name);
58 58
 
59 59
     $date = parse_date(get_http_var('date'));
60
-    if ($date) $date = '"' . $date['iso'] . '"';
61
-    else $date = 'date(now())';
60
+    if ($date) {
61
+        $date = '"' . $date['iso'] . '"';
62
+    } else {
63
+        $date = 'date(now())';
64
+    }
62 65
     $q = $db->query("select distinct(dept) from moffice
63 66
         where dept like :department
64 67
         and from_date <= $date and $date <= to_date", array(
@@ -108,8 +111,11 @@  discard block
 block discarded – undo
108 111
     $db = new ParlDB;
109 112
 
110 113
     $date = parse_date($date);
111
-    if ($date) $date = '"' . $date['iso'] . '"';
112
-    else $date = 'date(now())';
114
+    if ($date) {
115
+        $date = '"' . $date['iso'] . '"';
116
+    } else {
117
+        $date = 'date(now())';
118
+    }
113 119
     $q = $db->query("select distinct(dept) from moffice
114 120
         where source = 'chgpages/selctee'
115 121
         and from_date <= $date and $date <= to_date");
Please login to merge, or discard this patch.
www/docs/api/api_convertURL.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     $LISTURL = new URL($hansardmajors[$id_data['major']]['page_all']);
41 41
     $fragment = '';
42 42
     if ($id_data['htype'] == '11' || $id_data['htype'] == '10') {
43
-        $LISTURL->insert( array( 'id' => $id_data['gid'] ) );
43
+        $LISTURL->insert(array('id' => $id_data['gid']));
44 44
     } else {
45 45
         $parent_epobject_id = $id_data['subsection_id'];
46 46
         $parent_gid = '';
@@ -50,14 +50,14 @@  discard block
 block discarded – undo
50 50
                     ':epobject_id' => $parent_epobject_id
51 51
                     ));
52 52
         if ($r->rows() > 0) {
53
-            $parent_gid = fix_gid_from_db( $r->field(0, 'gid') );
53
+            $parent_gid = fix_gid_from_db($r->field(0, 'gid'));
54 54
         }
55 55
         if ($parent_gid != '') {
56
-            $LISTURL->insert( array( 'id' => $parent_gid ) );
57
-            $fragment = '#g' . gid_to_anchor($id_data['gid']);
56
+            $LISTURL->insert(array('id' => $parent_gid));
57
+            $fragment = '#g'.gid_to_anchor($id_data['gid']);
58 58
         }
59 59
     }
60
-    return $LISTURL->generate('none') . $fragment;
60
+    return $LISTURL->generate('none').$fragment;
61 61
 }
62 62
 
63 63
 function api_converturl_url_output($q) {
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
     $url = get_listurl($q);
66 66
     $output = array(
67 67
         'gid' => $gid,
68
-        'url' => 'https://www.theyworkforyou.com' . $url
68
+        'url' => 'https://www.theyworkforyou.com'.$url
69 69
     );
70 70
     api_output($output);
71 71
 }
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
         return api_converturl_url_output($q);
80 80
 
81 81
     $q = $db->query('select gid,major,htype,subsection_id from hansard where source_url like :url order by gid limit 1', array(
82
-        ':url' => $url_nohash . '%'
82
+        ':url' => $url_nohash.'%'
83 83
         ));
84 84
     if ($q->rows())
85 85
         return api_converturl_url_output($q);
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
     $url_bound = str_replace('cmhansrd/cm', 'cmhansrd/vo', $url_nohash);
88 88
     if ($url_bound != $url_nohash) {
89 89
         $q = $db->query('select gid,major,htype,subsection_id from hansard where source_url like :url order by gid limit 1', array(
90
-            ':url' => $url_bound . '%'
90
+            ':url' => $url_bound.'%'
91 91
             ));
92 92
         if ($q->rows())
93 93
             return api_converturl_url_output($q);
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -75,22 +75,25 @@
 block discarded – undo
75 75
     $q = $db->query('select gid,major,htype,subsection_id from hansard where source_url = :url order by gid limit 1', array(
76 76
         ':url' => $url
77 77
         ));
78
-    if ($q->rows())
79
-        return api_converturl_url_output($q);
78
+    if ($q->rows()) {
79
+            return api_converturl_url_output($q);
80
+    }
80 81
 
81 82
     $q = $db->query('select gid,major,htype,subsection_id from hansard where source_url like :url order by gid limit 1', array(
82 83
         ':url' => $url_nohash . '%'
83 84
         ));
84
-    if ($q->rows())
85
-        return api_converturl_url_output($q);
85
+    if ($q->rows()) {
86
+            return api_converturl_url_output($q);
87
+    }
86 88
 
87 89
     $url_bound = str_replace('cmhansrd/cm', 'cmhansrd/vo', $url_nohash);
88 90
     if ($url_bound != $url_nohash) {
89 91
         $q = $db->query('select gid,major,htype,subsection_id from hansard where source_url like :url order by gid limit 1', array(
90 92
             ':url' => $url_bound . '%'
91 93
             ));
92
-        if ($q->rows())
93
-            return api_converturl_url_output($q);
94
+        if ($q->rows()) {
95
+                    return api_converturl_url_output($q);
96
+        }
94 97
     }
95 98
     api_error('Sorry, URL could not be converted');
96 99
 }
Please login to merge, or discard this patch.
www/docs/api/api_getLords.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-include_once dirname(__FILE__) . '/api_getMembers.php';
3
+include_once dirname(__FILE__).'/api_getMembers.php';
4 4
 
5 5
 function api_getLords_front() {
6 6
 ?>
Please login to merge, or discard this patch.
www/docs/api/api_getLord.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-include_once dirname(__FILE__) . '/api_getPerson.php';
3
+include_once dirname(__FILE__).'/api_getPerson.php';
4 4
 
5 5
 function api_getLord_front() {
6 6
 ?>
Please login to merge, or discard this patch.
www/docs/api/api_getComments.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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'),
Please login to merge, or discard this patch.
www/docs/api/api_getMLA.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-include_once INCLUDESPATH . 'easyparliament/member.php';
4
-include_once dirname(__FILE__) . '/api_getPerson.php';
3
+include_once INCLUDESPATH.'easyparliament/member.php';
4
+include_once dirname(__FILE__).'/api_getPerson.php';
5 5
 
6 6
 function api_getMLA_front() {
7 7
 ?>
Please login to merge, or discard this patch.
www/docs/api/api_getMSPs.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-include_once dirname(__FILE__) . '/api_getMembers.php';
3
+include_once dirname(__FILE__).'/api_getMembers.php';
4 4
 
5 5
 function api_getMSPs_front() {
6 6
 ?>
Please login to merge, or discard this patch.
www/docs/api/api_getWMS.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-include_once dirname(__FILE__) . '/api_getHansard.php';
3
+include_once dirname(__FILE__).'/api_getHansard.php';
4 4
 
5 5
 function api_getWMS_front() {
6 6
 ?>
@@ -100,11 +100,11 @@  discard block
 block discarded – undo
100 100
     _api_getHansard_year('WMS', $y);
101 101
 }
102 102
 function api_getWMS_search($s) {
103
-    _api_getHansard_search( array(
103
+    _api_getHansard_search(array(
104 104
         's' => $s,
105 105
         'pid' => get_http_var('person'),
106 106
         'type' => 'wms',
107
-    ) );
107
+    ));
108 108
 }
109 109
 function api_getWMS_person($pid) {
110 110
     _api_getHansard_search(array(
Please login to merge, or discard this patch.