Passed
Branch master (7a17e1)
by Vitalii
08:27
created
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/bolt_select.inc 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
 
19 19
 function select_cmp($a, $b) {
20 20
     if ($a->value == $b->value) return 0;
21
-    return ($a->value < $b->value)?1:-1;
21
+    return ($a->value < $b->value) ? 1 : -1;
22 22
 }
23 23
 
24 24
 class BoltSelect extends BoltSet {
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/bossa_example2.inc 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -74,9 +74,9 @@
 block discarded – undo
74 74
     foreach ($insts as $inst) {
75 75
         $results[] = $inst->get_opaque_data();
76 76
     }
77
-    for ($i=0; $i<$n-1; $i++) {
77
+    for ($i = 0; $i < $n - 1; $i++) {
78 78
         $r1 = $results[$i];
79
-        for ($j=$i+1; $j<$n; $j++) {
79
+        for ($j = $i + 1; $j < $n; $j++) {
80 80
             $r2 = $results[$j];
81 81
             if (compatible($r1, $r2)) {
82 82
                 $job->set_state(BOSSA_JOB_DONE);
Please login to merge, or discard this patch.
html/inc/bossa_example3.inc 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
     // see if there's a negative consensus
123 123
     //
124 124
     $prob = 1;
125
-    for ($i=0; $i<$n; $i++) {
125
+    for ($i = 0; $i < $n; $i++) {
126 126
         $r = $results[$i];
127 127
         if ($r1->have_ellipse) continue;
128 128
         $u = $users[$i];
@@ -135,11 +135,11 @@  discard block
 block discarded – undo
135 135
 
136 136
     // see if there's a positive consensus
137 137
     //
138
-    for ($i=0; $i<$n; $i++) {
138
+    for ($i = 0; $i < $n; $i++) {
139 139
         $r1 = $results[$i];
140 140
         $u = $users[$i];
141 141
         $prob = $u->pos_error_rate;
142
-        for ($j=0; $j<$n; $j++) {
142
+        for ($j = 0; $j < $n; $j++) {
143 143
             if ($j == $i) continue;
144 144
             $r2 = $results[$j];
145 145
             if (compatible($r1, $r2)) {
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/cache.inc 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@
 block discarded – undo
99 99
                 }
100 100
             }
101 101
         }
102
-       @closedir($handle);
102
+        @closedir($handle);
103 103
     }
104 104
     chdir($start_dir);
105 105
 } 
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -32,8 +32,8 @@  discard block
 block discarded – undo
32 32
         mkdir("../cache", 0770);
33 33
         chmod("../cache", 0770);
34 34
     }
35
-    for ($i=0;$i<256;$i++) {
36
-        $j=sprintf("%02x",$i);
35
+    for ($i = 0; $i < 256; $i++) {
36
+        $j = sprintf("%02x", $i);
37 37
         if (!@filemtime("../cache/$j")) {
38 38
             mkdir("../cache/$j", 0770);
39 39
             chmod("../cache/$j", 0770);
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
     }
42 42
 }
43 43
 
44
-function get_path($params, $phpfile=null) {
44
+function get_path($params, $phpfile = null) {
45 45
     if (!@filemtime("../cache/00")) make_cache_dirs();
46 46
     if ($phpfile) {
47 47
         $z = $phpfile;
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
     }
52 52
 
53 53
     // add a layer of subdirectories for reducing file lookup time
54
-    $sz = substr(md5($z."_".urlencode($params)),1,2);
54
+    $sz = substr(md5($z."_".urlencode($params)), 1, 2);
55 55
     $path = "../cache/".$sz."/".$z;
56 56
     if ($params) {
57 57
         $path = $path."_".urlencode($params);
@@ -60,14 +60,14 @@  discard block
 block discarded – undo
60 60
 }
61 61
 
62 62
 function disk_usage($dir) {
63
-    $usage=0;
64
-    if ($handle=@opendir($dir)) {
65
-        while ($file=readdir($handle)) {
63
+    $usage = 0;
64
+    if ($handle = @opendir($dir)) {
65
+        while ($file = readdir($handle)) {
66 66
             if (($file != ".") && ($file != "..")) {
67 67
                 if (@is_dir($dir."/".$file)) {
68
-                    $usage+=disk_usage($dir."/".$file);
68
+                    $usage += disk_usage($dir."/".$file);
69 69
                 } else {
70
-                    $usage+=@filesize($dir."/".$file);
70
+                    $usage += @filesize($dir."/".$file);
71 71
                 }
72 72
             }
73 73
         }
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
     if (!chdir($dir)) {
82 82
         return;
83 83
     }
84
-    if ($handle=@opendir(".")) {
85
-        while ($file=readdir($handle)) {
84
+    if ($handle = @opendir(".")) {
85
+        while ($file = readdir($handle)) {
86 86
             if ($file == ".") continue;
87 87
             if ($file == "..") continue;
88 88
 
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
             if (@is_dir($file)) {
94 94
                 clean_cache($max_age, $file);
95 95
             } else {
96
-                if ((time()-@filemtime($file))>$max_age) {
96
+                if ((time() - @filemtime($file)) > $max_age) {
97 97
                     //echo "unlinking ".getcwd()."/$file\n";
98 98
                     @unlink($file);
99 99
                 }
@@ -107,8 +107,8 @@  discard block
 block discarded – undo
107 107
 
108 108
 // check cache size every once in a while, purge if too big
109 109
 //
110
-function cache_check_diskspace(){
111
-    if ((rand() % CACHE_SIZE_CHECK_FREQ)) return;
110
+function cache_check_diskspace() {
111
+    if ((rand()%CACHE_SIZE_CHECK_FREQ)) return;
112 112
     if (disk_usage("../cache") < MAX_CACHE_USAGE) return;
113 113
     $x = max(TEAM_PAGE_TTL, USER_PAGE_TTL, USER_HOST_TTL,
114 114
         USER_PROFILE_TTL, TOP_PAGES_TTL, INDEX_PAGE_TTL
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
     clean_cache($x, "../cache");
117 117
 }
118 118
 
119
-function cache_need_to_regenerate($path, $max_age){
119
+function cache_need_to_regenerate($path, $max_age) {
120 120
     $regenerate = false;
121 121
     $request = apache_request_headers();
122 122
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
         // and touch the cached copy so other processes
129 129
         // don't regenerate at the same time
130 130
         //
131
-        if ($lastmodified<time()-$max_age) {
131
+        if ($lastmodified < time() - $max_age) {
132 132
             $regenerate = true;
133 133
             @touch($path);
134 134
         }
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 }
140 140
 
141 141
 // Returns cached data or false if nothing was found
142
-function get_cached_data($max_age, $params=""){
142
+function get_cached_data($max_age, $params = "") {
143 143
     global $no_cache;
144 144
 
145 145
     if ($no_cache) return;
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
             }
156 156
         } else {
157 157
             cache_check_diskspace();
158
-            $regenerate=cache_need_to_regenerate($path, $max_age);
158
+            $regenerate = cache_need_to_regenerate($path, $max_age);
159 159
             if (!$regenerate) {
160 160
                 return file_get_contents($path);
161 161
             }
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 }
166 166
 
167 167
 // DEPRECATED
168
-function start_cache($max_age, $params=""){
168
+function start_cache($max_age, $params = "") {
169 169
     global $no_cache, $caching, $memcache;
170 170
 
171 171
     if ($no_cache) return;
@@ -188,15 +188,15 @@  discard block
 block discarded – undo
188 188
             $regenerate = cache_need_to_regenerate($path, $max_age);
189 189
         }
190 190
         //Is the stored version too old, do we need to regenerate it?
191
-        if ($regenerate){
191
+        if ($regenerate) {
192 192
             // If cached version is too old (or non-existent)
193 193
             // generate the page and write to cache
194 194
             //
195 195
             ob_start();
196 196
             ob_implicit_flush(0);
197
-            Header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
198
-            Header("Expires: " . gmdate("D, d M Y H:i:s",time()+$max_age) . " GMT");
199
-            Header("Cache-Control: public, max-age=" . $max_age); 
197
+            Header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
198
+            Header("Expires: ".gmdate("D, d M Y H:i:s", time() + $max_age)." GMT");
199
+            Header("Cache-Control: public, max-age=".$max_age); 
200 200
 
201 201
             // allow the calling page to see cache period
202 202
             //
@@ -208,9 +208,9 @@  discard block
 block discarded – undo
208 208
             if (strstr($params, "format=xml")) {
209 209
                 header('Content-type: text/xml');
210 210
             }
211
-            Header("Last-Modified: " . gmdate("D, d M Y H:i:s",$lastmodified) . " GMT");
212
-            Header("Expires: " . gmdate("D, d M Y H:i:s",$lastmodified+$max_age) . " GMT");
213
-            Header("Cache-Control: public, max-age=" . $max_age );
211
+            Header("Last-Modified: ".gmdate("D, d M Y H:i:s", $lastmodified)." GMT");
212
+            Header("Expires: ".gmdate("D, d M Y H:i:s", $lastmodified + $max_age)." GMT");
213
+            Header("Cache-Control: public, max-age=".$max_age);
214 214
             if ($cache && $cache->content) {
215 215
                 echo $cache->content;
216 216
                 exit;
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 
229 229
 // write output buffer both to client and to cache
230 230
 // DEPRECATED
231
-function end_cache($max_age,$params=""){
231
+function end_cache($max_age, $params = "") {
232 232
     global $no_cache;
233 233
     if ($no_cache) return;
234 234
 
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
     }
254 254
 }
255 255
 
256
-function set_cached_data($max_age, $data, $params=""){
256
+function set_cached_data($max_age, $data, $params = "") {
257 257
     // for the benefit of hackers
258 258
     if (strstr($params, "..")) {
259 259
         return "bad params";
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
             self::$instance->setOption(Memcached::OPT_PREFIX_KEY, MEMCACHE_PREFIX);
295 295
         }
296 296
         $servers = explode('|', MEMCACHE_SERVERS);
297
-        foreach($servers as &$server) {
297
+        foreach ($servers as &$server) {
298 298
             list($ip, $port) = explode(':', $server);
299 299
             if (!$port) { $port = 11211; }
300 300
             $server = array($ip, $port);
Please login to merge, or discard this patch.
Braces   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 
108 108
 // check cache size every once in a while, purge if too big
109 109
 //
110
-function cache_check_diskspace(){
110
+function cache_check_diskspace() {
111 111
     if ((rand() % CACHE_SIZE_CHECK_FREQ)) return;
112 112
     if (disk_usage("../cache") < MAX_CACHE_USAGE) return;
113 113
     $x = max(TEAM_PAGE_TTL, USER_PAGE_TTL, USER_HOST_TTL,
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
     clean_cache($x, "../cache");
117 117
 }
118 118
 
119
-function cache_need_to_regenerate($path, $max_age){
119
+function cache_need_to_regenerate($path, $max_age) {
120 120
     $regenerate = false;
121 121
     $request = apache_request_headers();
122 122
 
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 }
140 140
 
141 141
 // Returns cached data or false if nothing was found
142
-function get_cached_data($max_age, $params=""){
142
+function get_cached_data($max_age, $params="") {
143 143
     global $no_cache;
144 144
 
145 145
     if ($no_cache) return;
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 }
166 166
 
167 167
 // DEPRECATED
168
-function start_cache($max_age, $params=""){
168
+function start_cache($max_age, $params="") {
169 169
     global $no_cache, $caching, $memcache;
170 170
 
171 171
     if ($no_cache) return;
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
             $regenerate = cache_need_to_regenerate($path, $max_age);
189 189
         }
190 190
         //Is the stored version too old, do we need to regenerate it?
191
-        if ($regenerate){
191
+        if ($regenerate) {
192 192
             // If cached version is too old (or non-existent)
193 193
             // generate the page and write to cache
194 194
             //
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 
229 229
 // write output buffer both to client and to cache
230 230
 // DEPRECATED
231
-function end_cache($max_age,$params=""){
231
+function end_cache($max_age,$params="") {
232 232
     global $no_cache;
233 233
     if ($no_cache) return;
234 234
 
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
     }
254 254
 }
255 255
 
256
-function set_cached_data($max_age, $data, $params=""){
256
+function set_cached_data($max_age, $data, $params="") {
257 257
     // for the benefit of hackers
258 258
     if (strstr($params, "..")) {
259 259
         return "bad params";
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   +96 added lines, -96 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,24 +386,24 @@  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
-    if ($ipnum & (1 << $depth)) {
406
+    if ($ipnum&(1 << $depth)) {
407 407
       if ($x[1] >= $gi->databaseSegments) {
408 408
         return $x[1];
409 409
       }
@@ -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/submit_util.inc 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
         }
74 74
     }
75 75
     if ($fp_total) {
76
-        $batch->fraction_done = $fp_done / $fp_total;
76
+        $batch->fraction_done = $fp_done/$fp_total;
77 77
     }
78 78
     if ($completed && $batch->state == BATCH_STATE_IN_PROGRESS) {
79 79
         $batch->state = BATCH_STATE_COMPLETE;
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 // get the total size of output files of a batch
160 160
 //
161 161
 function batch_output_file_size($batchid) {
162
-    $batch_td_size=0;
162
+    $batch_td_size = 0;
163 163
     $wus = BoincWorkunit::enum("batch=$batchid");
164 164
     $fanout = parse_config(get_config(), "<uldl_dir_fanout>");
165 165
     $upload_dir = parse_config(get_config(), "<upload_dir>");
@@ -170,9 +170,9 @@  discard block
 block discarded – undo
170 170
         foreach ($names as $name) {
171 171
             $path = dir_hier_path($name, $upload_dir, $fanout);
172 172
             if (is_file($path)) {
173
-                $s=stat($path);
174
-                $size=$s['size'];
175
-                $batch_td_size+=$size;
173
+                $s = stat($path);
174
+                $size = $s['size'];
175
+                $batch_td_size += $size;
176 176
             }
177 177
         }
178 178
     }
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 }
192 192
 
193 193
 function boinc_get_wu_output_files_url($user, $wu_id) {
194
-    $auth_str =  md5($user->authenticator.$wu_id);
194
+    $auth_str = md5($user->authenticator.$wu_id);
195 195
     return "get_output.php?cmd=workunit_files&wu_id=$wu_id&auth_str=$auth_str";
196 196
 }
197 197
 
Please login to merge, or discard this patch.