Passed
Pull Request — master (#5571)
by
unknown
09:06
created
html/inc/boinc_db.inc 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -358,10 +358,10 @@
 block discarded – undo
358 358
         $db = BoincDb::get();
359 359
         return $db->enum('result', 'BoincResult', $where_clause);
360 360
     }
361
-	static function enum_fields($fields, $where_clause, $order_clause) {
361
+    static function enum_fields($fields, $where_clause, $order_clause) {
362 362
         $db = BoincDb::get();
363
-		return $db->enum_fields('result', 'BoincResult', $fields, $where_clause, $order_clause);
364
-	}
363
+        return $db->enum_fields('result', 'BoincResult', $fields, $where_clause, $order_clause);
364
+    }
365 365
     function update($clause) {
366 366
         $db = BoincDb::get();
367 367
         return $db->update($this, 'result', $clause);
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -208,11 +208,11 @@  discard block
 block discarded – undo
208 208
         $db = BoincDb::get();
209 209
         return $db->update($this, 'user', $clause);
210 210
     }
211
-    static function enum($where_clause, $order_clause=null) {
211
+    static function enum($where_clause, $order_clause = null) {
212 212
         $db = BoincDb::get();
213 213
         return $db->enum('user', 'BoincUser', $where_clause, $order_clause);
214 214
     }
215
-    static function enum_fields($fields, $where_clause, $order_clause=null) {
215
+    static function enum_fields($fields, $where_clause, $order_clause = null) {
216 216
         $db = BoincDb::get();
217 217
         return $db->enum_fields(
218 218
             'user', 'BoincUser', $fields, $where_clause, $order_clause
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
         $db = BoincDb::get();
262 262
         return $db->update($this, 'team', $clause);
263 263
     }
264
-    static function enum($where_clause, $order_clause=null) {
264
+    static function enum($where_clause, $order_clause = null) {
265 265
         $db = BoincDb::get();
266 266
         return $db->enum('team', 'BoincTeam', $where_clause, $order_clause);
267 267
     }
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
         $db = BoincDb::get();
287 287
         return $db->max('team', $field);
288 288
     }
289
-    static function enum_fields($fields, $where_clause, $order_clause=null) {
289
+    static function enum_fields($fields, $where_clause, $order_clause = null) {
290 290
         $db = BoincDb::get();
291 291
         return $db->enum_fields(
292 292
             'team', 'BoincTeam', $fields, $where_clause, $order_clause
@@ -322,11 +322,11 @@  discard block
 block discarded – undo
322 322
         $db = BoincDb::get();
323 323
         return $db->delete($this, 'host');
324 324
     }
325
-    static function enum($where_clause, $order_clause=null) {
325
+    static function enum($where_clause, $order_clause = null) {
326 326
         $db = BoincDb::get();
327 327
         return $db->enum('host', 'BoincHost', $where_clause, $order_clause);
328 328
     }
329
-    static function enum_fields($fields, $where_clause, $order_clause=null) {
329
+    static function enum_fields($fields, $where_clause, $order_clause = null) {
330 330
         $db = BoincDb::get();
331 331
         return $db->enum_fields(
332 332
             'host', 'BoincHost', $fields, $where_clause, $order_clause
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
         $db = BoincDb::get();
446 446
         return $db->update($this, 'app', $clause);
447 447
     }
448
-    static function sum($field, $clause=null) {
448
+    static function sum($field, $clause = null) {
449 449
         $db = BoincDb::get();
450 450
         return $db->sum('app', $field, $clause);
451 451
     }
@@ -501,11 +501,11 @@  discard block
 block discarded – undo
501 501
         $db = BoincDb::get();
502 502
         return $db->insert('profile', $clause);
503 503
     }
504
-    static function enum($where_clause=null, $order_clause=null) {
504
+    static function enum($where_clause = null, $order_clause = null) {
505 505
         $db = BoincDb::get();
506 506
         return $db->enum('profile', 'BoincProfile', $where_clause, $order_clause);
507 507
     }
508
-    static function enum_fields($fields, $where_clause=null, $order_clause=null) {
508
+    static function enum_fields($fields, $where_clause = null, $order_clause = null) {
509 509
         $db = BoincDb::get();
510 510
         return $db->enum_fields('profile', 'BoincProfile', $fields, $where_clause, $order_clause);
511 511
     }
@@ -889,12 +889,12 @@  discard block
 block discarded – undo
889 889
         return $db->enum('consent', 'BoincConsent', $where_clause);
890 890
     }
891 891
 
892
-    static function insert ($clause) {
892
+    static function insert($clause) {
893 893
         $db = BoincDb::get();
894 894
         return $db->insert('consent', $clause);
895 895
     }
896 896
 
897
-    static function update ($clause) {
897
+    static function update($clause) {
898 898
         $db = BoincDb::get();
899 899
         return $db->update_aux('consent', $clause);
900 900
     }
@@ -918,17 +918,17 @@  discard block
 block discarded – undo
918 918
         return $db->lookup('consent_type', 'BoincConsentType', $clause);
919 919
     }
920 920
 
921
-    static function enum($where_clause, $order_clause=null) {
921
+    static function enum($where_clause, $order_clause = null) {
922 922
         $db = BoincDb::get();
923 923
         return $db->enum('consent_type', 'BoincConsentType', $where_clause, $order_clause);
924 924
     }
925 925
 
926
-    static function insert ($clause) {
926
+    static function insert($clause) {
927 927
         $db = BoincDb::get();
928 928
         return $db->insert('consent_type', $clause);
929 929
     }
930 930
 
931
-    static function update ($clause) {
931
+    static function update($clause) {
932 932
         $db = BoincDb::get();
933 933
         return $db->update_aux('consent_type', $clause);
934 934
     }
@@ -953,7 +953,7 @@  discard block
 block discarded – undo
953 953
         return $db->lookup('latest_consent', 'BoincLatestConsent', $clause);
954 954
     }
955 955
 
956
-    static function enum($where_clause, $order_clause=null) {
956
+    static function enum($where_clause, $order_clause = null) {
957 957
         $db = BoincDb::get();
958 958
         return $db->enum('latest_consent', 'BoincLatestConsent', $where_clause, $order_clause);
959 959
     }
@@ -964,7 +964,7 @@  discard block
 block discarded – undo
964 964
 // apply this to any user-supplied strings used in queries
965 965
 //
966 966
 function boinc_real_escape_string($x) {
967
-    if (version_compare(phpversion(),"4.3.0")>=0) {
967
+    if (version_compare(phpversion(), "4.3.0") >= 0) {
968 968
         return BoincDb::escape_string($x);
969 969
     } else {
970 970
         $x = str_replace("'", "\'", $x);
Please login to merge, or discard this patch.
html/inc/profile.inc 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -191,7 +191,7 @@
 block discarded – undo
191 191
     $min_credit = parse_config(get_config(), "<profile_min_credit>");
192 192
     if (!$logged_in_user && $min_credit && $user->expavg_credit < $min_credit ) {
193 193
         error_page(
194
-           tra("To prevent spam, profiles of users with an average credit of less than %1 are displayed only to logged-in users. We apologize for this inconvenience.", $min_credit)
194
+            tra("To prevent spam, profiles of users with an average credit of less than %1 are displayed only to logged-in users. We apologize for this inconvenience.", $min_credit)
195 195
         );
196 196
     }
197 197
     if (is_banished($user)) {
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
     if (!$user->has_profile) return null;
72 72
     $profile = BoincProfile::lookup("userid=$user->id");
73 73
     if (!$profile->has_picture) return null;
74
-    if (profile_screening() && $profile->verification!=1) return null;
74
+    if (profile_screening() && $profile->verification != 1) return null;
75 75
     return profile_thumb_url($user->id);
76 76
 }
77 77
 
@@ -125,18 +125,18 @@  discard block
 block discarded – undo
125 125
         return $image;
126 126
     }
127 127
 
128
-    ($origWidth > $origHeight)? $scalar = ($origWidth / $targetWidth) : $scalar = ($origHeight / $targetHeight);
128
+    ($origWidth > $origHeight) ? $scalar = ($origWidth/$targetWidth) : $scalar = ($origHeight/$targetHeight);
129 129
 
130 130
     if ($scalar != 0) {
131
-        $destWidth = $origWidth / $scalar;
132
-        $destHeight = $origHeight / $scalar;
131
+        $destWidth = $origWidth/$scalar;
132
+        $destHeight = $origHeight/$scalar;
133 133
     } else {
134 134
         $destWidth = $origWidth;
135 135
         $destHeight = $origHeight;
136 136
     }
137 137
 
138 138
     $gd_info = gd_info();
139
-    $newGD = (strstr($gd_info["GD Version"], "2.0")!="");
139
+    $newGD = (strstr($gd_info["GD Version"], "2.0") != "");
140 140
     if ($newGD) {
141 141
         // If you are using a modern PHP/GD installation that does
142 142
         // 'truecolor' images, this is what's needed.
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
         $options->htmlitems = false;
180 180
         $temp = output_transform($profile->response1, $options);
181 181
         $temp = sanitize_tags($temp);
182
-        $description = "(\"" . sub_sentence($temp, ' ', MAX_DESC_LENGTH, true) . "\")";
182
+        $description = "(\"".sub_sentence($temp, ' ', MAX_DESC_LENGTH, true)."\")";
183 183
 
184 184
     }
185 185
 
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 
190 190
 function check_whether_to_show_profile($user, $logged_in_user) {
191 191
     $min_credit = parse_config(get_config(), "<profile_min_credit>");
192
-    if (!$logged_in_user && $min_credit && $user->expavg_credit < $min_credit ) {
192
+    if (!$logged_in_user && $min_credit && $user->expavg_credit < $min_credit) {
193 193
         error_page(
194 194
            tra("To prevent spam, profiles of users with an average credit of less than %1 are displayed only to logged-in users. We apologize for this inconvenience.", $min_credit)
195 195
         );
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
     //
228 228
     $show_picture = $profile->has_picture;
229 229
     if (profile_screening()) {
230
-        if (!$screen_mode && !$can_edit && $profile->verification!=1) {
230
+        if (!$screen_mode && !$can_edit && $profile->verification != 1) {
231 231
             $show_picture = false;
232 232
         }
233 233
     }
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
     // yet verified.  This will tell them if other users can't view it yet, or
244 244
     // if there is a problem with it and they need to replace it.
245 245
     //
246
-    if (profile_screening() && $profile->has_picture && $can_edit && $profile->verification!=1) {
246
+    if (profile_screening() && $profile->has_picture && $can_edit && $profile->verification != 1) {
247 247
         row1(offensive_profile_warning($profile->verification));
248 248
     }
249 249
 
@@ -276,6 +276,6 @@  discard block
 block discarded – undo
276 276
     }
277 277
 }
278 278
 
279
-$cvs_version_tracker[]="\$Id$";  //Generated automatically - do not edit
279
+$cvs_version_tracker[] = "\$Id$"; //Generated automatically - do not edit
280 280
 
281 281
 ?>
Please login to merge, or discard this patch.
html/inc/db.inc 2 patches
Switch Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -86,14 +86,14 @@
 block discarded – undo
86 86
     function _mysql_field_attrs($r, $i) {
87 87
         $x = mysqli_fetch_field_direct($r, $i);
88 88
         switch ($x->type) {
89
-            case 1: $x->type = 'tinyint'; break;
90
-            case 2: $x->type = 'smallint'; break;
91
-            case 3: $x->type = 'int'; break;
92
-            case 5: $x->type = 'double'; break;
93
-            case 7: $x->type = 'timestamp'; break;
94
-            case 252: $x->type = 'blob'; break;
95
-            case 253: $x->type = 'varchar'; break;
96
-            case 254: $x->type = 'char'; break;
89
+        case 1: $x->type = 'tinyint'; break;
90
+        case 2: $x->type = 'smallint'; break;
91
+        case 3: $x->type = 'int'; break;
92
+        case 5: $x->type = 'double'; break;
93
+        case 7: $x->type = 'timestamp'; break;
94
+        case 252: $x->type = 'blob'; break;
95
+        case 253: $x->type = 'varchar'; break;
96
+        case 254: $x->type = 'char'; break;
97 97
         }
98 98
         return $x;
99 99
     }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     function _mysql_connect($host, $user, $pass, $dbname) {
44 44
         global $mysqli;
45 45
         $x = explode(":", $host);
46
-        if (sizeof($x)>1) {
46
+        if (sizeof($x) > 1) {
47 47
             $host = $x[0];
48 48
             $port = $x[1];
49 49
         } else {
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
     }
163 163
 }
164 164
 
165
-function db_init_aux($try_replica=false) {
165
+function db_init_aux($try_replica = false) {
166 166
     $config = get_config();
167 167
     $user = parse_config($config, "<db_user>");
168 168
     $pass = parse_config($config, "<db_passwd>");
Please login to merge, or discard this patch.
html/inc/wap.inc 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -23,9 +23,9 @@  discard block
 block discarded – undo
23 23
     header("Expires: Thu, 01 Jan 1970 00:00:00 GMT");
24 24
 
25 25
     echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>"
26
-     . "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" "
27
-     . "\"http://www.wapforum.org/DTD/wml_1.2.xml\">"
28
-     . "<wml><card id=\"cd1\"><p>";
26
+        . "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" "
27
+        . "\"http://www.wapforum.org/DTD/wml_1.2.xml\">"
28
+        . "<wml><card id=\"cd1\"><p>";
29 29
 }
30 30
 
31 31
 function wap_end() {
@@ -33,6 +33,6 @@  discard block
 block discarded – undo
33 33
 }
34 34
 
35 35
 function wap_timestamp() {
36
-  return gmdate('j M Y G:i:s', time()) . " UTC";
36
+    return gmdate('j M Y G:i:s', time()) . " UTC";
37 37
 }
38 38
 ?>
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,6 +33,6 @@
 block discarded – undo
33 33
 }
34 34
 
35 35
 function wap_timestamp() {
36
-  return gmdate('j M Y G:i:s', time()) . " UTC";
36
+  return gmdate('j M Y G:i:s', time())." UTC";
37 37
 }
38 38
 ?>
Please login to merge, or discard this patch.
html/inc/image.inc 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -23,10 +23,10 @@  discard block
 block discarded – undo
23 23
     $gd_info = gd_info();
24 24
     // libgd version numbers seem to be always three numbers
25 25
     preg_match('/(\d).(\d).(\d)/', $gd_info['GD Version'], $match);
26
-    $newGD = ($match[1]>=2);
26
+    $newGD = ($match[1] >= 2);
27 27
 
28 28
     list($ow, $oh, $from_type) = getimagesize($sourcefile);
29
-    switch($from_type) {
29
+    switch ($from_type) {
30 30
     case 1: // GIF
31 31
         $srcImage = imageCreateFromGif($sourcefile);
32 32
         break;
@@ -41,12 +41,12 @@  discard block
 block discarded – undo
41 41
     $tempw = $fw;
42 42
     $temph = number_format((($oh*$fw)/$ow), 0);
43 43
 
44
-    if($temph < $fh) {
44
+    if ($temph < $fh) {
45 45
         $tempw = number_format((($ow*$fh)/$oh), 0);
46 46
         $temph = $fh;
47 47
     }
48 48
 
49
-    if ($newGD){
49
+    if ($newGD) {
50 50
         $tempImage = imageCreateTrueColor($tempw, $temph);
51 51
         // Seems not to work:
52 52
         // imageAntiAlias($tempImage, true);
@@ -58,15 +58,15 @@  discard block
 block discarded – undo
58 58
 
59 59
 
60 60
     // Calculate offsets
61
-    if($temph < $fh) {
62
-        $offsety = number_format(($temph/2)-($fh/2), 0);
61
+    if ($temph < $fh) {
62
+        $offsety = number_format(($temph/2) - ($fh/2), 0);
63 63
         $offsetx = 0;
64 64
     } else {
65 65
         $offsety = 0;
66
-        $offsetx = number_format(($tempw/2)-($fw/2), 0);
66
+        $offsetx = number_format(($tempw/2) - ($fw/2), 0);
67 67
     }
68 68
 
69
-    if ($newGD){
69
+    if ($newGD) {
70 70
         $destImage = imageCreateTrueColor($fw, $fh);
71 71
         // Seems not to work:
72 72
         // imageAntiAlias($tempImage, true);
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
         $temph = $fh;
47 47
     }
48 48
 
49
-    if ($newGD){
49
+    if ($newGD) {
50 50
         $tempImage = imageCreateTrueColor($tempw, $temph);
51 51
         // Seems not to work:
52 52
         // imageAntiAlias($tempImage, true);
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
         $offsetx = number_format(($tempw/2)-($fw/2), 0);
67 67
     }
68 68
 
69
-    if ($newGD){
69
+    if ($newGD) {
70 70
         $destImage = imageCreateTrueColor($fw, $fh);
71 71
         // Seems not to work:
72 72
         // imageAntiAlias($tempImage, true);
Please login to merge, or discard this patch.
html/inc/team_types.inc 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 
38 38
 function team_type_name($num) {
39 39
     global $team_types;
40
-    if ($num>0 && $num<count($team_types)) {
40
+    if ($num > 0 && $num < count($team_types)) {
41 41
         return $team_types[$num];
42 42
     }
43 43
     return "None";
@@ -53,13 +53,13 @@  discard block
 block discarded – undo
53 53
 
54 54
 function team_type_num($name) {
55 55
     global $team_types;
56
-    for ($i=0; $i<sizeof($team_types); $i++) {
56
+    for ($i = 0; $i < sizeof($team_types); $i++) {
57 57
         if ($name == $team_types[$i]) return $i;
58 58
     }
59 59
     return 0;
60 60
 }
61 61
 
62
-function team_type_select($selected_type, $allow_none=false){
62
+function team_type_select($selected_type, $allow_none = false) {
63 63
     global $team_types;
64 64
 
65 65
     $types = $team_types;
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@
 block discarded – undo
59 59
     return 0;
60 60
 }
61 61
 
62
-function team_type_select($selected_type, $allow_none=false){
62
+function team_type_select($selected_type, $allow_none=false) {
63 63
     global $team_types;
64 64
 
65 65
     $types = $team_types;
Please login to merge, or discard this patch.
html/inc/db_conn.inc 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
     function init_conn($user, $passwd, $host, $name, $readonly) {
30 30
         if (MYSQLI) {
31 31
             $x = explode(":", $host);
32
-            if (sizeof($x)>1) {
32
+            if (sizeof($x) > 1) {
33 33
                 $host = $x[0];
34 34
                 $port = $x[1];
35 35
             } else {
@@ -143,10 +143,10 @@  discard block
 block discarded – undo
143 143
             $where_clause = "where $where_clause";
144 144
         }
145 145
         $query = "select $fields from DBNAME.$table $where_clause $order_clause";
146
-        return $this->enum_general($classname,$query);
146
+        return $this->enum_general($classname, $query);
147 147
     }
148 148
 
149
-    function enum($table, $classname, $where_clause=null, $order_clause=null) {
149
+    function enum($table, $classname, $where_clause = null, $order_clause = null) {
150 150
         return self::enum_fields(
151 151
             $table, $classname, '*', $where_clause, $order_clause
152 152
         );
@@ -205,15 +205,15 @@  discard block
 block discarded – undo
205 205
         if ($x) return (double)$x->$field;
206 206
         return false;
207 207
     }
208
-    function count($table, $clause="TRUE") {
208
+    function count($table, $clause = "TRUE") {
209 209
         $query = "select count(*) as total from DBNAME.$table where $clause";
210 210
         return $this->get_int($query, 'total');
211 211
     }
212
-    function sum($table, $field, $clause="") {
212
+    function sum($table, $field, $clause = "") {
213 213
         $query = "select sum($field) as total from DBNAME.$table $clause";
214 214
         return $this->get_double($query, 'total');
215 215
     }
216
-    function max($table, $field, $clause="") {
216
+    function max($table, $field, $clause = "") {
217 217
         $query = "select max($field) as total from DBNAME.$table $clause";
218 218
         return $this->get_double($query, 'total');
219 219
     }
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,8 @@
 block discarded – undo
36 36
                 $port = null;
37 37
             }
38 38
             //if (version_compare(PHP_VERSION, '5.3.0') < 0) {
39
-            if (1) {        // don't use persistent connections for now
39
+            if (1) {
40
+// don't use persistent connections for now
40 41
                 $this->db_conn = @new mysqli($host, $user, $passwd, $name, $port);
41 42
             } else {
42 43
                 $this->db_conn = @new mysqli("p:".$host, $user, $passwd, $name, $port);
Please login to merge, or discard this patch.
html/inc/geoip.inc 4 patches
Indentation   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -213,26 +213,26 @@  discard block
 block discarded – undo
213 213
 }
214 214
 function geoip_load_shared_mem ($file) {
215 215
 
216
-  $fp = fopen($file, "rb");
217
-  if (!$fp) {
216
+    $fp = fopen($file, "rb");
217
+    if (!$fp) {
218 218
     print "error opening $file: $php_errormsg\n";
219 219
     exit;
220
-  }
221
-  $s_array = fstat($fp);
222
-  $size = $s_array['size'];
223
-  if ($shmid = @shmop_open (GEOIP_SHM_KEY, "w", 0, 0)) {
220
+    }
221
+    $s_array = fstat($fp);
222
+    $size = $s_array['size'];
223
+    if ($shmid = @shmop_open (GEOIP_SHM_KEY, "w", 0, 0)) {
224 224
     shmop_delete ($shmid);
225 225
     shmop_close ($shmid);
226
-  }
227
-  $shmid = shmop_open (GEOIP_SHM_KEY, "c", 0644, $size);
228
-  shmop_write ($shmid, fread($fp, $size), 0);
229
-  shmop_close ($shmid);
226
+    }
227
+    $shmid = shmop_open (GEOIP_SHM_KEY, "c", 0644, $size);
228
+    shmop_write ($shmid, fread($fp, $size), 0);
229
+    shmop_close ($shmid);
230 230
 }
231 231
 
232 232
 function _setup_segments($gi){
233
-  $gi->databaseType = GEOIP_COUNTRY_EDITION;
234
-  $gi->record_length = STANDARD_RECORD_LENGTH;
235
-  if ($gi->flags & GEOIP_SHARED_MEMORY) {
233
+    $gi->databaseType = GEOIP_COUNTRY_EDITION;
234
+    $gi->record_length = STANDARD_RECORD_LENGTH;
235
+    if ($gi->flags & GEOIP_SHARED_MEMORY) {
236 236
     $offset = @shmop_size ($gi->shmid) - 3;
237 237
     for ($i = 0; $i < STRUCTURE_INFO_MAX_SIZE; $i++) {
238 238
         $delim = @shmop_read ($gi->shmid, $offset, 3);
@@ -245,19 +245,19 @@  discard block
 block discarded – undo
245 245
                 $gi->databaseSegments = GEOIP_STATE_BEGIN_REV0;
246 246
             } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){
247 247
                 $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1;
248
-	    } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0)||
248
+        } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0)||
249 249
                      ($gi->databaseType == GEOIP_CITY_EDITION_REV1) 
250 250
                     || ($gi->databaseType == GEOIP_ORG_EDITION)
251
-		    || ($gi->databaseType == GEOIP_ISP_EDITION)
252
-		    || ($gi->databaseType == GEOIP_ASNUM_EDITION)){
251
+            || ($gi->databaseType == GEOIP_ISP_EDITION)
252
+            || ($gi->databaseType == GEOIP_ASNUM_EDITION)){
253 253
                 $gi->databaseSegments = 0;
254 254
                 $buf = @shmop_read ($gi->shmid, $offset, SEGMENT_RECORD_LENGTH);
255 255
                 for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){
256 256
                     $gi->databaseSegments += (ord($buf[$j]) << ($j * 8));
257 257
                 }
258
-	            if (($gi->databaseType == GEOIP_ORG_EDITION)||
259
-			($gi->databaseType == GEOIP_ISP_EDITION)) {
260
-	                $gi->record_length = ORG_RECORD_LENGTH;
258
+                if (($gi->databaseType == GEOIP_ORG_EDITION)||
259
+            ($gi->databaseType == GEOIP_ISP_EDITION)) {
260
+                    $gi->record_length = ORG_RECORD_LENGTH;
261 261
                 }
262 262
             }
263 263
             break;
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
         ($gi->databaseType == GEOIP_NETSPEED_EDITION)){
271 271
         $gi->databaseSegments = GEOIP_COUNTRY_BEGIN;
272 272
     }
273
-  } else {
273
+    } else {
274 274
     $filepos = ftell($gi->filehandle);
275 275
     fseek($gi->filehandle, -3, SEEK_END);
276 276
     for ($i = 0; $i < STRUCTURE_INFO_MAX_SIZE; $i++) {
@@ -281,19 +281,19 @@  discard block
 block discarded – undo
281 281
             $gi->databaseSegments = GEOIP_STATE_BEGIN_REV0;
282 282
         }
283 283
         else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){
284
-	    $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1;
284
+        $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1;
285 285
                 }  else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0) ||
286 286
                  ($gi->databaseType == GEOIP_CITY_EDITION_REV1) || 
287 287
                  ($gi->databaseType == GEOIP_ORG_EDITION) || 
288
-		 ($gi->databaseType == GEOIP_ISP_EDITION) || 
288
+         ($gi->databaseType == GEOIP_ISP_EDITION) || 
289 289
                  ($gi->databaseType == GEOIP_ASNUM_EDITION)){
290 290
             $gi->databaseSegments = 0;
291 291
             $buf = fread($gi->filehandle,SEGMENT_RECORD_LENGTH);
292 292
             for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){
293 293
             $gi->databaseSegments += (ord($buf[$j]) << ($j * 8));
294 294
             }
295
-	    if ($gi->databaseType == GEOIP_ORG_EDITION) {
296
-	    $gi->record_length = ORG_RECORD_LENGTH;
295
+        if ($gi->databaseType == GEOIP_ORG_EDITION) {
296
+        $gi->record_length = ORG_RECORD_LENGTH;
297 297
             }
298 298
         }
299 299
         break;
@@ -304,17 +304,17 @@  discard block
 block discarded – undo
304 304
     if (($gi->databaseType == GEOIP_COUNTRY_EDITION)||
305 305
         ($gi->databaseType == GEOIP_PROXY_EDITION)||
306 306
         ($gi->databaseType == GEOIP_NETSPEED_EDITION)){
307
-         $gi->databaseSegments = GEOIP_COUNTRY_BEGIN;
307
+            $gi->databaseSegments = GEOIP_COUNTRY_BEGIN;
308 308
     }
309 309
     fseek($gi->filehandle,$filepos,SEEK_SET);
310
-  }
311
-  return $gi;
310
+    }
311
+    return $gi;
312 312
 }
313 313
 
314 314
 function geoip_open($filename, $flags) {
315
-  $gi = new GeoIP;
316
-  $gi->flags = $flags;
317
-  if ($gi->flags & GEOIP_SHARED_MEMORY) {
315
+    $gi = new GeoIP;
316
+    $gi->flags = $flags;
317
+    if ($gi->flags & GEOIP_SHARED_MEMORY) {
318 318
     $gi->shmid = @shmop_open (GEOIP_SHM_KEY, "a", 0, 0);
319 319
     } else {
320 320
     $gi->filehandle = fopen($filename,"rb");
@@ -322,174 +322,174 @@  discard block
 block discarded – undo
322 322
         $s_array = fstat($gi->filehandle);
323 323
         $gi->memory_buffer = fread($gi->filehandle, $s_array[size]);
324 324
     }
325
-  }
325
+    }
326 326
 
327
-  $gi = _setup_segments($gi);
328
-  return $gi;
327
+    $gi = _setup_segments($gi);
328
+    return $gi;
329 329
 }
330 330
 
331 331
 function geoip_close($gi) {
332
-  if ($gi->flags & GEOIP_SHARED_MEMORY) {
332
+    if ($gi->flags & GEOIP_SHARED_MEMORY) {
333 333
     return true;
334
-  }
334
+    }
335 335
 
336
-  return fclose($gi->filehandle);
336
+    return fclose($gi->filehandle);
337 337
 }
338 338
 
339 339
 function geoip_country_id_by_name($gi, $name) {
340
-  $addr = gethostbyname($name);
341
-  if (!$addr || $addr == $name) {
340
+    $addr = gethostbyname($name);
341
+    if (!$addr || $addr == $name) {
342 342
     return false;
343
-  }
344
-  return geoip_country_id_by_addr($gi, $addr);
343
+    }
344
+    return geoip_country_id_by_addr($gi, $addr);
345 345
 }
346 346
 
347 347
 function geoip_country_code_by_name($gi, $name) {
348
-  $country_id = geoip_country_id_by_name($gi,$name);
349
-  if ($country_id !== false) {
348
+    $country_id = geoip_country_id_by_name($gi,$name);
349
+    if ($country_id !== false) {
350 350
         return $gi->GEOIP_COUNTRY_CODES[$country_id];
351
-  }
352
-  return false;
351
+    }
352
+    return false;
353 353
 }
354 354
 
355 355
 function geoip_country_name_by_name($gi, $name) {
356
-  $country_id = geoip_country_id_by_name($gi,$name);
357
-  if ($country_id !== false) {
356
+    $country_id = geoip_country_id_by_name($gi,$name);
357
+    if ($country_id !== false) {
358 358
         return $gi->GEOIP_COUNTRY_NAMES[$country_id];
359
-  }
360
-  return false;
359
+    }
360
+    return false;
361 361
 }
362 362
 
363 363
 function geoip_country_id_by_addr($gi, $addr) {
364
-  $ipnum = ip2long($addr);
365
-  return _geoip_seek_country($gi, $ipnum) - GEOIP_COUNTRY_BEGIN;
364
+    $ipnum = ip2long($addr);
365
+    return _geoip_seek_country($gi, $ipnum) - GEOIP_COUNTRY_BEGIN;
366 366
 }
367 367
 
368 368
 function geoip_country_code_by_addr($gi, $addr) {
369
-  $country_id = geoip_country_id_by_addr($gi,$addr);
370
-  if ($country_id !== false) {
369
+    $country_id = geoip_country_id_by_addr($gi,$addr);
370
+    if ($country_id !== false) {
371 371
     return $gi->GEOIP_COUNTRY_CODES[$country_id];
372
-  }
373
-  return false;
372
+    }
373
+    return false;
374 374
 }
375 375
 
376 376
 function geoip_country_name_by_addr($gi, $addr) {
377
-  $country_id = geoip_country_id_by_addr($gi,$addr);
378
-  if ($country_id !== false) {
377
+    $country_id = geoip_country_id_by_addr($gi,$addr);
378
+    if ($country_id !== false) {
379 379
         return $gi->GEOIP_COUNTRY_NAMES[$country_id];
380
-  }
381
-  return false;
380
+    }
381
+    return false;
382 382
 }
383 383
 
384 384
 function _geoip_seek_country($gi, $ipnum) {
385
-  $offset = 0;
386
-  for ($depth = 31; $depth >= 0; --$depth) {
385
+    $offset = 0;
386
+    for ($depth = 31; $depth >= 0; --$depth) {
387 387
     if ($gi->flags & GEOIP_MEMORY_CACHE) {
388
-      $buf = substr($gi->memory_buffer,
388
+        $buf = substr($gi->memory_buffer,
389 389
                             2 * $gi->record_length * $offset,
390 390
                             2 * $gi->record_length);
391 391
         } elseif ($gi->flags & GEOIP_SHARED_MEMORY) {
392
-      $buf = @shmop_read ($gi->shmid, 
392
+        $buf = @shmop_read ($gi->shmid, 
393 393
                             2 * $gi->record_length * $offset,
394 394
                             2 * $gi->record_length );
395 395
         } else {
396
-      fseek($gi->filehandle, 2 * $gi->record_length * $offset, SEEK_SET) == 0
396
+        fseek($gi->filehandle, 2 * $gi->record_length * $offset, SEEK_SET) == 0
397 397
         or die("fseek failed");
398
-      $buf = fread($gi->filehandle, 2 * $gi->record_length);
398
+        $buf = fread($gi->filehandle, 2 * $gi->record_length);
399 399
     }
400 400
     $x = array(0,0);
401 401
     for ($i = 0; $i < 2; ++$i) {
402
-      for ($j = 0; $j < $gi->record_length; ++$j) {
402
+        for ($j = 0; $j < $gi->record_length; ++$j) {
403 403
         $x[$i] += ord($buf[$gi->record_length * $i + $j]) << ($j * 8);
404
-      }
404
+        }
405 405
     }
406 406
     if ($ipnum & (1 << $depth)) {
407
-      if ($x[1] >= $gi->databaseSegments) {
407
+        if ($x[1] >= $gi->databaseSegments) {
408 408
         return $x[1];
409
-      }
410
-      $offset = $x[1];
409
+        }
410
+        $offset = $x[1];
411 411
         } else {
412
-      if ($x[0] >= $gi->databaseSegments) {
412
+        if ($x[0] >= $gi->databaseSegments) {
413 413
         return $x[0];
414
-      }
415
-      $offset = $x[0];
414
+        }
415
+        $offset = $x[0];
416
+    }
416 417
     }
417
-  }
418
-  trigger_error("error traversing database - perhaps it is corrupt?", E_USER_ERROR);
419
-  return false;
418
+    trigger_error("error traversing database - perhaps it is corrupt?", E_USER_ERROR);
419
+    return false;
420 420
 }
421 421
 
422 422
 function _get_org($gi,$ipnum){
423
-  $seek_org = _geoip_seek_country($gi,$ipnum);
424
-  if ($seek_org == $gi->databaseSegments) {
423
+    $seek_org = _geoip_seek_country($gi,$ipnum);
424
+    if ($seek_org == $gi->databaseSegments) {
425 425
     return NULL;
426
-  }
427
-  $record_pointer = $seek_org + (2 * $gi->record_length - 1) * $gi->databaseSegments;
428
-  if ($gi->flags & GEOIP_SHARED_MEMORY) {
426
+    }
427
+    $record_pointer = $seek_org + (2 * $gi->record_length - 1) * $gi->databaseSegments;
428
+    if ($gi->flags & GEOIP_SHARED_MEMORY) {
429 429
     $org_buf = @shmop_read ($gi->shmid, $record_pointer, MAX_ORG_RECORD_LENGTH);
430 430
     } else {
431 431
     fseek($gi->filehandle, $record_pointer, SEEK_SET);
432 432
     $org_buf = fread($gi->filehandle,MAX_ORG_RECORD_LENGTH);
433
-  }
434
-  $org_buf = substr($org_buf, 0, strpos($org_buf, 0));
435
-  return $org_buf;
433
+    }
434
+    $org_buf = substr($org_buf, 0, strpos($org_buf, 0));
435
+    return $org_buf;
436 436
 }
437 437
 
438 438
 function geoip_org_by_addr ($gi,$addr) {
439
-  if ($addr == NULL) {
439
+    if ($addr == NULL) {
440 440
     return 0;
441
-  }
442
-  $ipnum = ip2long($addr);
443
-  return _get_org($gi, $ipnum);
441
+    }
442
+    $ipnum = ip2long($addr);
443
+    return _get_org($gi, $ipnum);
444 444
 }
445 445
 
446 446
 function _get_region($gi,$ipnum){
447
-  if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
447
+    if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
448 448
     $seek_region = _geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV0;
449 449
     if ($seek_region >= 1000){
450
-      $country_code = "US";
451
-      $region = chr(($seek_region - 1000)/26 + 65) . chr(($seek_region - 1000)%26 + 65);
450
+        $country_code = "US";
451
+        $region = chr(($seek_region - 1000)/26 + 65) . chr(($seek_region - 1000)%26 + 65);
452 452
     } else {
453 453
             $country_code = $gi->GEOIP_COUNTRY_CODES[$seek_region];
454
-      $region = "";
454
+        $region = "";
455 455
     }
456
-  return array ($country_code,$region);
456
+    return array ($country_code,$region);
457 457
     }  else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) {
458 458
     $seek_region = _geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV1;
459 459
     //print $seek_region;
460 460
     if ($seek_region < US_OFFSET){
461
-      $country_code = "";
462
-      $region = "";  
461
+        $country_code = "";
462
+        $region = "";  
463 463
         } else if ($seek_region < CANADA_OFFSET) {
464
-      $country_code = "US";
465
-      $region = chr(($seek_region - US_OFFSET)/26 + 65) . chr(($seek_region - US_OFFSET)%26 + 65);
464
+        $country_code = "US";
465
+        $region = chr(($seek_region - US_OFFSET)/26 + 65) . chr(($seek_region - US_OFFSET)%26 + 65);
466 466
         } else if ($seek_region < WORLD_OFFSET) {
467
-      $country_code = "CA";
468
-      $region = chr(($seek_region - CANADA_OFFSET)/26 + 65) . chr(($seek_region - CANADA_OFFSET)%26 + 65);
467
+        $country_code = "CA";
468
+        $region = chr(($seek_region - CANADA_OFFSET)/26 + 65) . chr(($seek_region - CANADA_OFFSET)%26 + 65);
469 469
     } else {
470 470
             $country_code = $gi->GEOIP_COUNTRY_CODES[($seek_region - WORLD_OFFSET) / FIPS_RANGE];
471
-      $region = "";
471
+        $region = "";
472
+    }
473
+    return array ($country_code,$region);
472 474
     }
473
-  return array ($country_code,$region);
474
-  }
475 475
 }
476 476
 
477 477
 function geoip_region_by_addr ($gi,$addr) {
478
-  if ($addr == NULL) {
478
+    if ($addr == NULL) {
479 479
     return 0;
480
-  }
481
-  $ipnum = ip2long($addr);
482
-  return _get_region($gi, $ipnum);
480
+    }
481
+    $ipnum = ip2long($addr);
482
+    return _get_region($gi, $ipnum);
483 483
 }
484 484
 
485 485
 function getdnsattributes ($l,$ip){
486
-  $r = new Net_DNS_Resolver();
487
-  $r->nameservers = array("ws1.maxmind.com");
488
-  $p = $r->search($l."." . $ip .".s.maxmind.com","TXT","IN");
489
-  $str = is_object($p->answer[0])?$p->answer[0]->string():'';
490
-  ereg("\"(.*)\"",$str,$regs);
491
-  $str = $regs[1];
492
-  return $str;
486
+    $r = new Net_DNS_Resolver();
487
+    $r->nameservers = array("ws1.maxmind.com");
488
+    $p = $r->search($l."." . $ip .".s.maxmind.com","TXT","IN");
489
+    $str = is_object($p->answer[0])?$p->answer[0]->string():'';
490
+    ereg("\"(.*)\"",$str,$regs);
491
+    $str = $regs[1];
492
+    return $str;
493 493
 }
494 494
 
495 495
 ?>
Please login to merge, or discard this patch.
Braces   +20 added lines, -21 removed lines patch added patch discarded remove patch
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
   shmop_close ($shmid);
230 230
 }
231 231
 
232
-function _setup_segments($gi){
232
+function _setup_segments($gi) {
233 233
   $gi->databaseType = GEOIP_COUNTRY_EDITION;
234 234
   $gi->record_length = STANDARD_RECORD_LENGTH;
235 235
   if ($gi->flags & GEOIP_SHARED_MEMORY) {
@@ -241,18 +241,18 @@  discard block
 block discarded – undo
241 241
             $gi->databaseType = ord(@shmop_read ($gi->shmid, $offset, 1));
242 242
             $offset++;
243 243
 
244
-            if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
244
+            if ($gi->databaseType == GEOIP_REGION_EDITION_REV0) {
245 245
                 $gi->databaseSegments = GEOIP_STATE_BEGIN_REV0;
246
-            } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){
246
+            } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) {
247 247
                 $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1;
248 248
 	    } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0)||
249 249
                      ($gi->databaseType == GEOIP_CITY_EDITION_REV1) 
250 250
                     || ($gi->databaseType == GEOIP_ORG_EDITION)
251 251
 		    || ($gi->databaseType == GEOIP_ISP_EDITION)
252
-		    || ($gi->databaseType == GEOIP_ASNUM_EDITION)){
252
+		    || ($gi->databaseType == GEOIP_ASNUM_EDITION)) {
253 253
                 $gi->databaseSegments = 0;
254 254
                 $buf = @shmop_read ($gi->shmid, $offset, SEGMENT_RECORD_LENGTH);
255
-                for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){
255
+                for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++) {
256 256
                     $gi->databaseSegments += (ord($buf[$j]) << ($j * 8));
257 257
                 }
258 258
 	            if (($gi->databaseType == GEOIP_ORG_EDITION)||
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
     }
268 268
     if (($gi->databaseType == GEOIP_COUNTRY_EDITION)||
269 269
         ($gi->databaseType == GEOIP_PROXY_EDITION)||
270
-        ($gi->databaseType == GEOIP_NETSPEED_EDITION)){
270
+        ($gi->databaseType == GEOIP_NETSPEED_EDITION)) {
271 271
         $gi->databaseSegments = GEOIP_COUNTRY_BEGIN;
272 272
     }
273 273
   } else {
@@ -275,21 +275,20 @@  discard block
 block discarded – undo
275 275
     fseek($gi->filehandle, -3, SEEK_END);
276 276
     for ($i = 0; $i < STRUCTURE_INFO_MAX_SIZE; $i++) {
277 277
         $delim = fread($gi->filehandle,3);
278
-        if ($delim == (chr(255).chr(255).chr(255))){
278
+        if ($delim == (chr(255).chr(255).chr(255))) {
279 279
         $gi->databaseType = ord(fread($gi->filehandle,1));
280
-        if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
280
+        if ($gi->databaseType == GEOIP_REGION_EDITION_REV0) {
281 281
             $gi->databaseSegments = GEOIP_STATE_BEGIN_REV0;
282
-        }
283
-        else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){
282
+        } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) {
284 283
 	    $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1;
285
-                }  else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0) ||
284
+                } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0) ||
286 285
                  ($gi->databaseType == GEOIP_CITY_EDITION_REV1) || 
287 286
                  ($gi->databaseType == GEOIP_ORG_EDITION) || 
288 287
 		 ($gi->databaseType == GEOIP_ISP_EDITION) || 
289
-                 ($gi->databaseType == GEOIP_ASNUM_EDITION)){
288
+                 ($gi->databaseType == GEOIP_ASNUM_EDITION)) {
290 289
             $gi->databaseSegments = 0;
291 290
             $buf = fread($gi->filehandle,SEGMENT_RECORD_LENGTH);
292
-            for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){
291
+            for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++) {
293 292
             $gi->databaseSegments += (ord($buf[$j]) << ($j * 8));
294 293
             }
295 294
 	    if ($gi->databaseType == GEOIP_ORG_EDITION) {
@@ -303,7 +302,7 @@  discard block
 block discarded – undo
303 302
     }
304 303
     if (($gi->databaseType == GEOIP_COUNTRY_EDITION)||
305 304
         ($gi->databaseType == GEOIP_PROXY_EDITION)||
306
-        ($gi->databaseType == GEOIP_NETSPEED_EDITION)){
305
+        ($gi->databaseType == GEOIP_NETSPEED_EDITION)) {
307 306
          $gi->databaseSegments = GEOIP_COUNTRY_BEGIN;
308 307
     }
309 308
     fseek($gi->filehandle,$filepos,SEEK_SET);
@@ -419,7 +418,7 @@  discard block
 block discarded – undo
419 418
   return false;
420 419
 }
421 420
 
422
-function _get_org($gi,$ipnum){
421
+function _get_org($gi,$ipnum) {
423 422
   $seek_org = _geoip_seek_country($gi,$ipnum);
424 423
   if ($seek_org == $gi->databaseSegments) {
425 424
     return NULL;
@@ -443,10 +442,10 @@  discard block
 block discarded – undo
443 442
   return _get_org($gi, $ipnum);
444 443
 }
445 444
 
446
-function _get_region($gi,$ipnum){
447
-  if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
445
+function _get_region($gi,$ipnum) {
446
+  if ($gi->databaseType == GEOIP_REGION_EDITION_REV0) {
448 447
     $seek_region = _geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV0;
449
-    if ($seek_region >= 1000){
448
+    if ($seek_region >= 1000) {
450 449
       $country_code = "US";
451 450
       $region = chr(($seek_region - 1000)/26 + 65) . chr(($seek_region - 1000)%26 + 65);
452 451
     } else {
@@ -454,10 +453,10 @@  discard block
 block discarded – undo
454 453
       $region = "";
455 454
     }
456 455
   return array ($country_code,$region);
457
-    }  else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) {
456
+    } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) {
458 457
     $seek_region = _geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV1;
459 458
     //print $seek_region;
460
-    if ($seek_region < US_OFFSET){
459
+    if ($seek_region < US_OFFSET) {
461 460
       $country_code = "";
462 461
       $region = "";  
463 462
         } else if ($seek_region < CANADA_OFFSET) {
@@ -482,7 +481,7 @@  discard block
 block discarded – undo
482 481
   return _get_region($gi, $ipnum);
483 482
 }
484 483
 
485
-function getdnsattributes ($l,$ip){
484
+function getdnsattributes ($l,$ip) {
486 485
   $r = new Net_DNS_Resolver();
487 486
   $r->nameservers = array("ws1.maxmind.com");
488 487
   $p = $r->search($l."." . $ip .".s.maxmind.com","TXT","IN");
Please login to merge, or discard this patch.
Upper-Lower-Casing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 function _get_org($gi,$ipnum){
423 423
   $seek_org = _geoip_seek_country($gi,$ipnum);
424 424
   if ($seek_org == $gi->databaseSegments) {
425
-    return NULL;
425
+    return null;
426 426
   }
427 427
   $record_pointer = $seek_org + (2 * $gi->record_length - 1) * $gi->databaseSegments;
428 428
   if ($gi->flags & GEOIP_SHARED_MEMORY) {
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 }
437 437
 
438 438
 function geoip_org_by_addr ($gi,$addr) {
439
-  if ($addr == NULL) {
439
+  if ($addr == null) {
440 440
     return 0;
441 441
   }
442 442
   $ipnum = ip2long($addr);
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
 }
476 476
 
477 477
 function geoip_region_by_addr ($gi,$addr) {
478
-  if ($addr == NULL) {
478
+  if ($addr == null) {
479 479
     return 0;
480 480
   }
481 481
   $ipnum = ip2long($addr);
Please login to merge, or discard this patch.
Spacing   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -138,25 +138,25 @@  discard block
 block discarded – undo
138 138
 "VU", "WF", "WS", "YE", "YT", "CS", "ZA", "ZM", "ZR", "ZW", "A1", "A2", "O1"
139 139
 );
140 140
     var $GEOIP_COUNTRY_CODES3 = array(
141
-"","AP","EU","AND","ARE","AFG","ATG","AIA","ALB","ARM","ANT","AGO","AQ","ARG",
142
-"ASM","AUT","AUS","ABW","AZE","BIH","BRB","BGD","BEL","BFA","BGR","BHR","BDI",
143
-"BEN","BMU","BRN","BOL","BRA","BHS","BTN","BV","BWA","BLR","BLZ","CAN","CC",
144
-"COD","CAF","COG","CHE","CIV","COK","CHL","CMR","CHN","COL","CRI","CUB","CPV",
145
-"CX","CYP","CZE","DEU","DJI","DNK","DMA","DOM","DZA","ECU","EST","EGY","ESH",
146
-"ERI","ESP","ETH","FIN","FJI","FLK","FSM","FRO","FRA","FX","GAB","GBR","GRD",
147
-"GEO","GUF","GHA","GIB","GRL","GMB","GIN","GLP","GNQ","GRC","GS","GTM","GUM",
148
-"GNB","GUY","HKG","HM","HND","HRV","HTI","HUN","IDN","IRL","ISR","IND","IO",
149
-"IRQ","IRN","ISL","ITA","JAM","JOR","JPN","KEN","KGZ","KHM","KIR","COM","KNA",
150
-"PRK","KOR","KWT","CYM","KAZ","LAO","LBN","LCA","LIE","LKA","LBR","LSO","LTU",
151
-"LUX","LVA","LBY","MAR","MCO","MDA","MDG","MHL","MKD","MLI","MMR","MNG","MAC",
152
-"MNP","MTQ","MRT","MSR","MLT","MUS","MDV","MWI","MEX","MYS","MOZ","NAM","NCL",
153
-"NER","NFK","NGA","NIC","NLD","NOR","NPL","NRU","NIU","NZL","OMN","PAN","PER",
154
-"PYF","PNG","PHL","PAK","POL","SPM","PCN","PRI","PSE","PRT","PLW","PRY","QAT",
155
-"REU","ROU","RUS","RWA","SAU","SLB","SYC","SDN","SWE","SGP","SHN","SVN","SJM",
156
-"SVK","SLE","SMR","SEN","SOM","SUR","STP","SLV","SYR","SWZ","TCA","TCD","TF",
157
-"TGO","THA","TJK","TKL","TLS","TKM","TUN","TON","TUR","TTO","TUV","TWN","TZA",
158
-"UKR","UGA","UM","USA","URY","UZB","VAT","VCT","VEN","VGB","VIR","VNM","VUT",
159
-        "WLF","WSM","YEM","YT","SCG","ZAF","ZMB","ZR","ZWE","A1","A2","O1"
141
+"", "AP", "EU", "AND", "ARE", "AFG", "ATG", "AIA", "ALB", "ARM", "ANT", "AGO", "AQ", "ARG",
142
+"ASM", "AUT", "AUS", "ABW", "AZE", "BIH", "BRB", "BGD", "BEL", "BFA", "BGR", "BHR", "BDI",
143
+"BEN", "BMU", "BRN", "BOL", "BRA", "BHS", "BTN", "BV", "BWA", "BLR", "BLZ", "CAN", "CC",
144
+"COD", "CAF", "COG", "CHE", "CIV", "COK", "CHL", "CMR", "CHN", "COL", "CRI", "CUB", "CPV",
145
+"CX", "CYP", "CZE", "DEU", "DJI", "DNK", "DMA", "DOM", "DZA", "ECU", "EST", "EGY", "ESH",
146
+"ERI", "ESP", "ETH", "FIN", "FJI", "FLK", "FSM", "FRO", "FRA", "FX", "GAB", "GBR", "GRD",
147
+"GEO", "GUF", "GHA", "GIB", "GRL", "GMB", "GIN", "GLP", "GNQ", "GRC", "GS", "GTM", "GUM",
148
+"GNB", "GUY", "HKG", "HM", "HND", "HRV", "HTI", "HUN", "IDN", "IRL", "ISR", "IND", "IO",
149
+"IRQ", "IRN", "ISL", "ITA", "JAM", "JOR", "JPN", "KEN", "KGZ", "KHM", "KIR", "COM", "KNA",
150
+"PRK", "KOR", "KWT", "CYM", "KAZ", "LAO", "LBN", "LCA", "LIE", "LKA", "LBR", "LSO", "LTU",
151
+"LUX", "LVA", "LBY", "MAR", "MCO", "MDA", "MDG", "MHL", "MKD", "MLI", "MMR", "MNG", "MAC",
152
+"MNP", "MTQ", "MRT", "MSR", "MLT", "MUS", "MDV", "MWI", "MEX", "MYS", "MOZ", "NAM", "NCL",
153
+"NER", "NFK", "NGA", "NIC", "NLD", "NOR", "NPL", "NRU", "NIU", "NZL", "OMN", "PAN", "PER",
154
+"PYF", "PNG", "PHL", "PAK", "POL", "SPM", "PCN", "PRI", "PSE", "PRT", "PLW", "PRY", "QAT",
155
+"REU", "ROU", "RUS", "RWA", "SAU", "SLB", "SYC", "SDN", "SWE", "SGP", "SHN", "SVN", "SJM",
156
+"SVK", "SLE", "SMR", "SEN", "SOM", "SUR", "STP", "SLV", "SYR", "SWZ", "TCA", "TCD", "TF",
157
+"TGO", "THA", "TJK", "TKL", "TLS", "TKM", "TUN", "TON", "TUR", "TTO", "TUV", "TWN", "TZA",
158
+"UKR", "UGA", "UM", "USA", "URY", "UZB", "VAT", "VCT", "VEN", "VGB", "VIR", "VNM", "VUT",
159
+        "WLF", "WSM", "YEM", "YT", "SCG", "ZAF", "ZMB", "ZR", "ZWE", "A1", "A2", "O1"
160 160
     );
161 161
     var $GEOIP_COUNTRY_NAMES = array(
162 162
 "", "Asia/Pacific Region", "Europe", "Andorra", "United Arab Emirates",
@@ -208,10 +208,10 @@  discard block
 block discarded – undo
208 208
 Grenadines", "Venezuela", "Virgin Islands, British", "Virgin Islands, U.S.",
209 209
 "Vietnam", "Vanuatu", "Wallis and Futuna", "Samoa", "Yemen", "Mayotte",
210 210
 "Serbia and Montenegro", "South Africa", "Zambia", "Zaire", "Zimbabwe",
211
-"Anonymous Proxy","Satellite Provider","Other"
211
+"Anonymous Proxy", "Satellite Provider", "Other"
212 212
 );
213 213
 }
214
-function geoip_load_shared_mem ($file) {
214
+function geoip_load_shared_mem($file) {
215 215
 
216 216
   $fp = fopen($file, "rb");
217 217
   if (!$fp) {
@@ -220,42 +220,42 @@  discard block
 block discarded – undo
220 220
   }
221 221
   $s_array = fstat($fp);
222 222
   $size = $s_array['size'];
223
-  if ($shmid = @shmop_open (GEOIP_SHM_KEY, "w", 0, 0)) {
224
-    shmop_delete ($shmid);
225
-    shmop_close ($shmid);
223
+  if ($shmid = @shmop_open(GEOIP_SHM_KEY, "w", 0, 0)) {
224
+    shmop_delete($shmid);
225
+    shmop_close($shmid);
226 226
   }
227
-  $shmid = shmop_open (GEOIP_SHM_KEY, "c", 0644, $size);
228
-  shmop_write ($shmid, fread($fp, $size), 0);
229
-  shmop_close ($shmid);
227
+  $shmid = shmop_open(GEOIP_SHM_KEY, "c", 0644, $size);
228
+  shmop_write($shmid, fread($fp, $size), 0);
229
+  shmop_close($shmid);
230 230
 }
231 231
 
232
-function _setup_segments($gi){
232
+function _setup_segments($gi) {
233 233
   $gi->databaseType = GEOIP_COUNTRY_EDITION;
234 234
   $gi->record_length = STANDARD_RECORD_LENGTH;
235 235
   if ($gi->flags & GEOIP_SHARED_MEMORY) {
236
-    $offset = @shmop_size ($gi->shmid) - 3;
236
+    $offset = @shmop_size($gi->shmid) - 3;
237 237
     for ($i = 0; $i < STRUCTURE_INFO_MAX_SIZE; $i++) {
238
-        $delim = @shmop_read ($gi->shmid, $offset, 3);
238
+        $delim = @shmop_read($gi->shmid, $offset, 3);
239 239
         $offset += 3;
240 240
         if ($delim == (chr(255).chr(255).chr(255))) {
241
-            $gi->databaseType = ord(@shmop_read ($gi->shmid, $offset, 1));
241
+            $gi->databaseType = ord(@shmop_read($gi->shmid, $offset, 1));
242 242
             $offset++;
243 243
 
244
-            if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
244
+            if ($gi->databaseType == GEOIP_REGION_EDITION_REV0) {
245 245
                 $gi->databaseSegments = GEOIP_STATE_BEGIN_REV0;
246
-            } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){
246
+            } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) {
247 247
                 $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1;
248
-	    } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0)||
248
+	    } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0) ||
249 249
                      ($gi->databaseType == GEOIP_CITY_EDITION_REV1) 
250 250
                     || ($gi->databaseType == GEOIP_ORG_EDITION)
251 251
 		    || ($gi->databaseType == GEOIP_ISP_EDITION)
252
-		    || ($gi->databaseType == GEOIP_ASNUM_EDITION)){
252
+		    || ($gi->databaseType == GEOIP_ASNUM_EDITION)) {
253 253
                 $gi->databaseSegments = 0;
254
-                $buf = @shmop_read ($gi->shmid, $offset, SEGMENT_RECORD_LENGTH);
255
-                for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){
256
-                    $gi->databaseSegments += (ord($buf[$j]) << ($j * 8));
254
+                $buf = @shmop_read($gi->shmid, $offset, SEGMENT_RECORD_LENGTH);
255
+                for ($j = 0; $j < SEGMENT_RECORD_LENGTH; $j++) {
256
+                    $gi->databaseSegments += (ord($buf[$j]) << ($j*8));
257 257
                 }
258
-	            if (($gi->databaseType == GEOIP_ORG_EDITION)||
258
+	            if (($gi->databaseType == GEOIP_ORG_EDITION) ||
259 259
 			($gi->databaseType == GEOIP_ISP_EDITION)) {
260 260
 	                $gi->record_length = ORG_RECORD_LENGTH;
261 261
                 }
@@ -265,32 +265,32 @@  discard block
 block discarded – undo
265 265
             $offset -= 4;
266 266
         }
267 267
     }
268
-    if (($gi->databaseType == GEOIP_COUNTRY_EDITION)||
269
-        ($gi->databaseType == GEOIP_PROXY_EDITION)||
270
-        ($gi->databaseType == GEOIP_NETSPEED_EDITION)){
268
+    if (($gi->databaseType == GEOIP_COUNTRY_EDITION) ||
269
+        ($gi->databaseType == GEOIP_PROXY_EDITION) ||
270
+        ($gi->databaseType == GEOIP_NETSPEED_EDITION)) {
271 271
         $gi->databaseSegments = GEOIP_COUNTRY_BEGIN;
272 272
     }
273 273
   } else {
274 274
     $filepos = ftell($gi->filehandle);
275 275
     fseek($gi->filehandle, -3, SEEK_END);
276 276
     for ($i = 0; $i < STRUCTURE_INFO_MAX_SIZE; $i++) {
277
-        $delim = fread($gi->filehandle,3);
278
-        if ($delim == (chr(255).chr(255).chr(255))){
279
-        $gi->databaseType = ord(fread($gi->filehandle,1));
280
-        if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
277
+        $delim = fread($gi->filehandle, 3);
278
+        if ($delim == (chr(255).chr(255).chr(255))) {
279
+        $gi->databaseType = ord(fread($gi->filehandle, 1));
280
+        if ($gi->databaseType == GEOIP_REGION_EDITION_REV0) {
281 281
             $gi->databaseSegments = GEOIP_STATE_BEGIN_REV0;
282 282
         }
283
-        else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){
283
+        else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) {
284 284
 	    $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1;
285
-                }  else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0) ||
285
+                } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0) ||
286 286
                  ($gi->databaseType == GEOIP_CITY_EDITION_REV1) || 
287 287
                  ($gi->databaseType == GEOIP_ORG_EDITION) || 
288 288
 		 ($gi->databaseType == GEOIP_ISP_EDITION) || 
289
-                 ($gi->databaseType == GEOIP_ASNUM_EDITION)){
289
+                 ($gi->databaseType == GEOIP_ASNUM_EDITION)) {
290 290
             $gi->databaseSegments = 0;
291
-            $buf = fread($gi->filehandle,SEGMENT_RECORD_LENGTH);
292
-            for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){
293
-            $gi->databaseSegments += (ord($buf[$j]) << ($j * 8));
291
+            $buf = fread($gi->filehandle, SEGMENT_RECORD_LENGTH);
292
+            for ($j = 0; $j < SEGMENT_RECORD_LENGTH; $j++) {
293
+            $gi->databaseSegments += (ord($buf[$j]) << ($j*8));
294 294
             }
295 295
 	    if ($gi->databaseType == GEOIP_ORG_EDITION) {
296 296
 	    $gi->record_length = ORG_RECORD_LENGTH;
@@ -301,12 +301,12 @@  discard block
 block discarded – undo
301 301
         fseek($gi->filehandle, -4, SEEK_CUR);
302 302
         }
303 303
     }
304
-    if (($gi->databaseType == GEOIP_COUNTRY_EDITION)||
305
-        ($gi->databaseType == GEOIP_PROXY_EDITION)||
306
-        ($gi->databaseType == GEOIP_NETSPEED_EDITION)){
304
+    if (($gi->databaseType == GEOIP_COUNTRY_EDITION) ||
305
+        ($gi->databaseType == GEOIP_PROXY_EDITION) ||
306
+        ($gi->databaseType == GEOIP_NETSPEED_EDITION)) {
307 307
          $gi->databaseSegments = GEOIP_COUNTRY_BEGIN;
308 308
     }
309
-    fseek($gi->filehandle,$filepos,SEEK_SET);
309
+    fseek($gi->filehandle, $filepos, SEEK_SET);
310 310
   }
311 311
   return $gi;
312 312
 }
@@ -315,9 +315,9 @@  discard block
 block discarded – undo
315 315
   $gi = new GeoIP;
316 316
   $gi->flags = $flags;
317 317
   if ($gi->flags & GEOIP_SHARED_MEMORY) {
318
-    $gi->shmid = @shmop_open (GEOIP_SHM_KEY, "a", 0, 0);
318
+    $gi->shmid = @shmop_open(GEOIP_SHM_KEY, "a", 0, 0);
319 319
     } else {
320
-    $gi->filehandle = fopen($filename,"rb");
320
+    $gi->filehandle = fopen($filename, "rb");
321 321
     if ($gi->flags & GEOIP_MEMORY_CACHE) {
322 322
         $s_array = fstat($gi->filehandle);
323 323
         $gi->memory_buffer = fread($gi->filehandle, $s_array[size]);
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 }
346 346
 
347 347
 function geoip_country_code_by_name($gi, $name) {
348
-  $country_id = geoip_country_id_by_name($gi,$name);
348
+  $country_id = geoip_country_id_by_name($gi, $name);
349 349
   if ($country_id !== false) {
350 350
         return $gi->GEOIP_COUNTRY_CODES[$country_id];
351 351
   }
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 }
354 354
 
355 355
 function geoip_country_name_by_name($gi, $name) {
356
-  $country_id = geoip_country_id_by_name($gi,$name);
356
+  $country_id = geoip_country_id_by_name($gi, $name);
357 357
   if ($country_id !== false) {
358 358
         return $gi->GEOIP_COUNTRY_NAMES[$country_id];
359 359
   }
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 }
367 367
 
368 368
 function geoip_country_code_by_addr($gi, $addr) {
369
-  $country_id = geoip_country_id_by_addr($gi,$addr);
369
+  $country_id = geoip_country_id_by_addr($gi, $addr);
370 370
   if ($country_id !== false) {
371 371
     return $gi->GEOIP_COUNTRY_CODES[$country_id];
372 372
   }
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 }
375 375
 
376 376
 function geoip_country_name_by_addr($gi, $addr) {
377
-  $country_id = geoip_country_id_by_addr($gi,$addr);
377
+  $country_id = geoip_country_id_by_addr($gi, $addr);
378 378
   if ($country_id !== false) {
379 379
         return $gi->GEOIP_COUNTRY_NAMES[$country_id];
380 380
   }
@@ -386,21 +386,21 @@  discard block
 block discarded – undo
386 386
   for ($depth = 31; $depth >= 0; --$depth) {
387 387
     if ($gi->flags & GEOIP_MEMORY_CACHE) {
388 388
       $buf = substr($gi->memory_buffer,
389
-                            2 * $gi->record_length * $offset,
390
-                            2 * $gi->record_length);
389
+                            2*$gi->record_length*$offset,
390
+                            2*$gi->record_length);
391 391
         } elseif ($gi->flags & GEOIP_SHARED_MEMORY) {
392
-      $buf = @shmop_read ($gi->shmid, 
393
-                            2 * $gi->record_length * $offset,
394
-                            2 * $gi->record_length );
392
+      $buf = @shmop_read($gi->shmid, 
393
+                            2*$gi->record_length*$offset,
394
+                            2*$gi->record_length);
395 395
         } else {
396
-      fseek($gi->filehandle, 2 * $gi->record_length * $offset, SEEK_SET) == 0
396
+      fseek($gi->filehandle, 2*$gi->record_length*$offset, SEEK_SET) == 0
397 397
         or die("fseek failed");
398
-      $buf = fread($gi->filehandle, 2 * $gi->record_length);
398
+      $buf = fread($gi->filehandle, 2*$gi->record_length);
399 399
     }
400
-    $x = array(0,0);
400
+    $x = array(0, 0);
401 401
     for ($i = 0; $i < 2; ++$i) {
402 402
       for ($j = 0; $j < $gi->record_length; ++$j) {
403
-        $x[$i] += ord($buf[$gi->record_length * $i + $j]) << ($j * 8);
403
+        $x[$i] += ord($buf[$gi->record_length*$i + $j]) << ($j*8);
404 404
       }
405 405
     }
406 406
     if ($ipnum & (1 << $depth)) {
@@ -419,23 +419,23 @@  discard block
 block discarded – undo
419 419
   return false;
420 420
 }
421 421
 
422
-function _get_org($gi,$ipnum){
423
-  $seek_org = _geoip_seek_country($gi,$ipnum);
422
+function _get_org($gi, $ipnum) {
423
+  $seek_org = _geoip_seek_country($gi, $ipnum);
424 424
   if ($seek_org == $gi->databaseSegments) {
425 425
     return NULL;
426 426
   }
427
-  $record_pointer = $seek_org + (2 * $gi->record_length - 1) * $gi->databaseSegments;
427
+  $record_pointer = $seek_org + (2*$gi->record_length - 1)*$gi->databaseSegments;
428 428
   if ($gi->flags & GEOIP_SHARED_MEMORY) {
429
-    $org_buf = @shmop_read ($gi->shmid, $record_pointer, MAX_ORG_RECORD_LENGTH);
429
+    $org_buf = @shmop_read($gi->shmid, $record_pointer, MAX_ORG_RECORD_LENGTH);
430 430
     } else {
431 431
     fseek($gi->filehandle, $record_pointer, SEEK_SET);
432
-    $org_buf = fread($gi->filehandle,MAX_ORG_RECORD_LENGTH);
432
+    $org_buf = fread($gi->filehandle, MAX_ORG_RECORD_LENGTH);
433 433
   }
434 434
   $org_buf = substr($org_buf, 0, strpos($org_buf, 0));
435 435
   return $org_buf;
436 436
 }
437 437
 
438
-function geoip_org_by_addr ($gi,$addr) {
438
+function geoip_org_by_addr($gi, $addr) {
439 439
   if ($addr == NULL) {
440 440
     return 0;
441 441
   }
@@ -443,38 +443,38 @@  discard block
 block discarded – undo
443 443
   return _get_org($gi, $ipnum);
444 444
 }
445 445
 
446
-function _get_region($gi,$ipnum){
447
-  if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
448
-    $seek_region = _geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV0;
449
-    if ($seek_region >= 1000){
446
+function _get_region($gi, $ipnum) {
447
+  if ($gi->databaseType == GEOIP_REGION_EDITION_REV0) {
448
+    $seek_region = _geoip_seek_country($gi, $ipnum) - GEOIP_STATE_BEGIN_REV0;
449
+    if ($seek_region >= 1000) {
450 450
       $country_code = "US";
451
-      $region = chr(($seek_region - 1000)/26 + 65) . chr(($seek_region - 1000)%26 + 65);
451
+      $region = chr(($seek_region - 1000)/26 + 65).chr(($seek_region - 1000)%26 + 65);
452 452
     } else {
453 453
             $country_code = $gi->GEOIP_COUNTRY_CODES[$seek_region];
454 454
       $region = "";
455 455
     }
456
-  return array ($country_code,$region);
457
-    }  else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) {
458
-    $seek_region = _geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV1;
456
+  return array($country_code, $region);
457
+    } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) {
458
+    $seek_region = _geoip_seek_country($gi, $ipnum) - GEOIP_STATE_BEGIN_REV1;
459 459
     //print $seek_region;
460
-    if ($seek_region < US_OFFSET){
460
+    if ($seek_region < US_OFFSET) {
461 461
       $country_code = "";
462 462
       $region = "";  
463 463
         } else if ($seek_region < CANADA_OFFSET) {
464 464
       $country_code = "US";
465
-      $region = chr(($seek_region - US_OFFSET)/26 + 65) . chr(($seek_region - US_OFFSET)%26 + 65);
465
+      $region = chr(($seek_region - US_OFFSET)/26 + 65).chr(($seek_region - US_OFFSET)%26 + 65);
466 466
         } else if ($seek_region < WORLD_OFFSET) {
467 467
       $country_code = "CA";
468
-      $region = chr(($seek_region - CANADA_OFFSET)/26 + 65) . chr(($seek_region - CANADA_OFFSET)%26 + 65);
468
+      $region = chr(($seek_region - CANADA_OFFSET)/26 + 65).chr(($seek_region - CANADA_OFFSET)%26 + 65);
469 469
     } else {
470
-            $country_code = $gi->GEOIP_COUNTRY_CODES[($seek_region - WORLD_OFFSET) / FIPS_RANGE];
470
+            $country_code = $gi->GEOIP_COUNTRY_CODES[($seek_region - WORLD_OFFSET)/FIPS_RANGE];
471 471
       $region = "";
472 472
     }
473
-  return array ($country_code,$region);
473
+  return array($country_code, $region);
474 474
   }
475 475
 }
476 476
 
477
-function geoip_region_by_addr ($gi,$addr) {
477
+function geoip_region_by_addr($gi, $addr) {
478 478
   if ($addr == NULL) {
479 479
     return 0;
480 480
   }
@@ -482,12 +482,12 @@  discard block
 block discarded – undo
482 482
   return _get_region($gi, $ipnum);
483 483
 }
484 484
 
485
-function getdnsattributes ($l,$ip){
485
+function getdnsattributes($l, $ip) {
486 486
   $r = new Net_DNS_Resolver();
487 487
   $r->nameservers = array("ws1.maxmind.com");
488
-  $p = $r->search($l."." . $ip .".s.maxmind.com","TXT","IN");
489
-  $str = is_object($p->answer[0])?$p->answer[0]->string():'';
490
-  ereg("\"(.*)\"",$str,$regs);
488
+  $p = $r->search($l.".".$ip.".s.maxmind.com", "TXT", "IN");
489
+  $str = is_object($p->answer[0]) ? $p->answer[0]->string() : '';
490
+  ereg("\"(.*)\"", $str, $regs);
491 491
   $str = $regs[1];
492 492
   return $str;
493 493
 }
Please login to merge, or discard this patch.
html/inc/ReCaptcha/RequestMethod/SocketPost.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -88,18 +88,18 @@
 block discarded – undo
88 88
         $errno = 0;
89 89
         $errstr = '';
90 90
 
91
-        if (false === $this->socket->fsockopen('ssl://' . self::RECAPTCHA_HOST, 443, $errno, $errstr, 30)) {
91
+        if (false === $this->socket->fsockopen('ssl://'.self::RECAPTCHA_HOST, 443, $errno, $errstr, 30)) {
92 92
             return self::BAD_REQUEST;
93 93
         }
94 94
 
95 95
         $content = $params->toQueryString();
96 96
 
97
-        $request = "POST " . self::SITE_VERIFY_PATH . " HTTP/1.1\r\n";
98
-        $request .= "Host: " . self::RECAPTCHA_HOST . "\r\n";
97
+        $request = "POST ".self::SITE_VERIFY_PATH." HTTP/1.1\r\n";
98
+        $request .= "Host: ".self::RECAPTCHA_HOST."\r\n";
99 99
         $request .= "Content-Type: application/x-www-form-urlencoded\r\n";
100
-        $request .= "Content-length: " . strlen($content) . "\r\n";
100
+        $request .= "Content-length: ".strlen($content)."\r\n";
101 101
         $request .= "Connection: close\r\n\r\n";
102
-        $request .= $content . "\r\n\r\n";
102
+        $request .= $content."\r\n\r\n";
103 103
 
104 104
         $this->socket->fwrite($request);
105 105
         $response = '';
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -34,8 +34,7 @@  discard block
 block discarded – undo
34 34
  * instead of get_file_contents(). This is to account for people who may be on
35 35
  * servers where allow_furl_open is disabled.
36 36
  */
37
-class SocketPost implements RequestMethod
38
-{
37
+class SocketPost implements RequestMethod {
39 38
     /**
40 39
      * reCAPTCHA service host.
41 40
      * @const string
@@ -68,8 +67,7 @@  discard block
 block discarded – undo
68 67
      *
69 68
      * @param \ReCaptcha\RequestMethod\Socket $socket optional socket, injectable for testing
70 69
      */
71
-    public function __construct(Socket $socket = null)
72
-    {
70
+    public function __construct(Socket $socket = null) {
73 71
         if (!is_null($socket)) {
74 72
             $this->socket = $socket;
75 73
         } else {
@@ -83,8 +81,7 @@  discard block
 block discarded – undo
83 81
      * @param RequestParameters $params Request parameters
84 82
      * @return string Body of the reCAPTCHA response
85 83
      */
86
-    public function submit(RequestParameters $params)
87
-    {
84
+    public function submit(RequestParameters $params) {
88 85
         $errno = 0;
89 86
         $errstr = '';
90 87
 
Please login to merge, or discard this patch.