Passed
Pull Request — master (#6441)
by
unknown
09:23
created
html/user/submit_test.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
     $f->mode = "local_staged";
42 42
     $f->source = "input";
43 43
 
44
-    for ($i=10; $i<20; $i++) {
44
+    for ($i = 10; $i < 20; $i++) {
45 45
         $job = new StdClass;
46 46
         $job->input_files = array($f);
47 47
         $job->rsc_fpops_est = $i*1e9;
Please login to merge, or discard this patch.
html/inc/language_names.inc 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -63,13 +63,13 @@  discard block
 block discarded – undo
63 63
     global $language_names;
64 64
     $supported_languages = get_supported_languages();
65 65
     $supported_languages[] = "en";
66
-    $sel = $cur_lang_name?"":"selected";
66
+    $sel = $cur_lang_name ? "" : "selected";
67 67
     echo "
68 68
         <option $sel value=auto>Language: default
69 69
     ";
70 70
     foreach ($language_names as $lang) {
71 71
         if (!in_array($lang[0], $supported_languages)) continue;
72
-        $sel = ($cur_lang_name == $lang[0])?"selected":"";
72
+        $sel = ($cur_lang_name == $lang[0]) ? "selected" : "";
73 73
         if ($lang[0] == "en") {
74 74
             echo "<option $sel value=".$lang[0].">".$lang[1];
75 75
         } else {
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 
82 82
 // show a menu of supported languages
83 83
 //
84
-function language_form($cur_lang_name=null) {
84
+function language_form($cur_lang_name = null) {
85 85
     echo '
86 86
         <form name="language" method="get" action="set_language.php">
87 87
         <select class="selectbox form-control" name="lang" onchange="javascript: submit()">
Please login to merge, or discard this patch.
html/user/openid.php 1 patch
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -69,13 +69,13 @@  discard block
 block discarded – undo
69 69
 
70 70
     function __construct()
71 71
     {
72
-        $this->trustRoot = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'];
72
+        $this->trustRoot = (!empty($_SERVER['HTTPS']) ? 'https' : 'http').'://'.$_SERVER['HTTP_HOST'];
73 73
         $uri = rtrim(preg_replace('#((?<=\?)|&)openid\.[^&]+#', '', $_SERVER['REQUEST_URI']), '?');
74
-        $this->returnUrl = $this->trustRoot . $uri;
74
+        $this->returnUrl = $this->trustRoot.$uri;
75 75
 
76 76
         $this->data = $_POST + $_GET; # OPs may send data as POST or GET.
77 77
 
78
-        if(!function_exists('curl_init') && !in_array('https', stream_get_wrappers())) {
78
+        if (!function_exists('curl_init') && !in_array('https', stream_get_wrappers())) {
79 79
             throw new ErrorException('You must have either https wrappers or curl enabled.');
80 80
         }
81 81
     }
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     {
85 85
         switch ($name) {
86 86
         case 'identity':
87
-            if (strlen($value = trim((String) $value))) {
87
+            if (strlen($value = trim((String)$value))) {
88 88
                 if (preg_match('#^xri:/*#i', $value, $m)) {
89 89
                     $value = substr($value, strlen($m[0]));
90 90
                 } elseif (!preg_match('/^(?:[=@+\$!\(]|https?:)/i', $value)) {
@@ -139,23 +139,23 @@  discard block
 block discarded – undo
139 139
         return !!gethostbynamel($server);
140 140
     }
141 141
 
142
-    protected function request_curl($url, $method='GET', $params=array())
142
+    protected function request_curl($url, $method = 'GET', $params = array())
143 143
     {
144 144
         $params = http_build_query($params, '', '&');
145
-        $curl = curl_init($url . ($method == 'GET' && $params ? '?' . $params : ''));
145
+        $curl = curl_init($url.($method == 'GET' && $params ? '?'.$params : ''));
146 146
         curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
147 147
         curl_setopt($curl, CURLOPT_HEADER, false);
148 148
         curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
149 149
         curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
150 150
         curl_setopt($curl, CURLOPT_HTTPHEADER, array('Accept: application/xrds+xml, */*'));
151 151
 
152
-        if($this->verify_peer !== null) {
152
+        if ($this->verify_peer !== null) {
153 153
             curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, $this->verify_peer);
154
-            if($this->capath) {
154
+            if ($this->capath) {
155 155
                 curl_setopt($curl, CURLOPT_CAPATH, $this->capath);
156 156
             }
157 157
 
158
-            if($this->cainfo) {
158
+            if ($this->cainfo) {
159 159
                 curl_setopt($curl, CURLOPT_CAINFO, $this->cainfo);
160 160
             }
161 161
         }
@@ -171,17 +171,17 @@  discard block
 block discarded – undo
171 171
         }
172 172
         $response = curl_exec($curl);
173 173
 
174
-        if($method == 'HEAD') {
174
+        if ($method == 'HEAD') {
175 175
             $headers = array();
176
-            foreach(explode("\n", $response) as $header) {
177
-                $pos = strpos($header,':');
176
+            foreach (explode("\n", $response) as $header) {
177
+                $pos = strpos($header, ':');
178 178
                 $name = strtolower(trim(substr($header, 0, $pos)));
179
-                $headers[$name] = trim(substr($header, $pos+1));
179
+                $headers[$name] = trim(substr($header, $pos + 1));
180 180
             }
181 181
 
182 182
             # Updating claimed_id in case of redirections.
183 183
             $effective_url = curl_getinfo($curl, CURLINFO_EFFECTIVE_URL);
184
-            if($effective_url != $url) {
184
+            if ($effective_url != $url) {
185 185
                 $this->identity = $this->claimed_id = $effective_url;
186 186
             }
187 187
 
@@ -195,14 +195,14 @@  discard block
 block discarded – undo
195 195
         return $response;
196 196
     }
197 197
 
198
-    protected function request_streams($url, $method='GET', $params=array())
198
+    protected function request_streams($url, $method = 'GET', $params = array())
199 199
     {
200
-        if(!$this->hostExists($url)) {
200
+        if (!$this->hostExists($url)) {
201 201
             throw new ErrorException('Invalid request.');
202 202
         }
203 203
 
204 204
         $params = http_build_query($params, '', '&');
205
-        switch($method) {
205
+        switch ($method) {
206 206
         case 'GET':
207 207
             $opts = array(
208 208
                 'http' => array(
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
                     'ignore_errors' => true,
212 212
                 )
213 213
             );
214
-            $url = $url . ($params ? '?' . $params : '');
214
+            $url = $url.($params ? '?'.$params : '');
215 215
             break;
216 216
         case 'POST':
217 217
             $opts = array(
@@ -236,31 +236,31 @@  discard block
 block discarded – undo
236 236
                 ))
237 237
             );
238 238
 
239
-            $url = $url . ($params ? '?' . $params : '');
240
-            $headers_tmp = get_headers ($url);
241
-            if(!$headers_tmp) {
239
+            $url = $url.($params ? '?'.$params : '');
240
+            $headers_tmp = get_headers($url);
241
+            if (!$headers_tmp) {
242 242
                 return array();
243 243
             }
244 244
 
245 245
             # Parsing headers.
246 246
             $headers = array();
247
-            foreach($headers_tmp as $header) {
248
-                $pos = strpos($header,':');
247
+            foreach ($headers_tmp as $header) {
248
+                $pos = strpos($header, ':');
249 249
                 $name = strtolower(trim(substr($header, 0, $pos)));
250
-                $headers[$name] = trim(substr($header, $pos+1));
250
+                $headers[$name] = trim(substr($header, $pos + 1));
251 251
 
252 252
                 # Following possible redirections. The point is just to have
253 253
                 # claimed_id change with them, because get_headers() will
254 254
                 # follow redirections automatically.
255 255
                 # We ignore redirections with relative paths.
256 256
                 # If any known provider uses them, file a bug report.
257
-                if($name == 'location') {
258
-                    if(strpos($headers[$name], 'http') === 0) {
257
+                if ($name == 'location') {
258
+                    if (strpos($headers[$name], 'http') === 0) {
259 259
                         $this->identity = $this->claimed_id = $headers[$name];
260
-                    } elseif($headers[$name][0] == '/') {
260
+                    } elseif ($headers[$name][0] == '/') {
261 261
                         $parsed_url = parse_url($this->claimed_id);
262 262
                         $this->identity =
263
-                        $this->claimed_id = $parsed_url['scheme'] . '://'
263
+                        $this->claimed_id = $parsed_url['scheme'].'://'
264 264
                                           . $parsed_url['host']
265 265
                                           . $headers[$name];
266 266
                     }
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
             return $headers;
273 273
         }
274 274
 
275
-        if($this->verify_peer) {
275
+        if ($this->verify_peer) {
276 276
             $opts += array('ssl' => array(
277 277
                 'verify_peer' => true,
278 278
                 'capath'      => $this->capath,
@@ -280,14 +280,14 @@  discard block
 block discarded – undo
280 280
             ));
281 281
         }
282 282
 
283
-        $context = stream_context_create ($opts);
283
+        $context = stream_context_create($opts);
284 284
 
285 285
         return file_get_contents($url, false, $context);
286 286
     }
287 287
 
288
-    protected function request($url, $method='GET', $params=array())
288
+    protected function request($url, $method = 'GET', $params = array())
289 289
     {
290
-        if(function_exists('curl_init') && !ini_get('safe_mode') && !ini_get('open_basedir')) {
290
+        if (function_exists('curl_init') && !ini_get('safe_mode') && !ini_get('open_basedir')) {
291 291
             return $this->request_curl($url, $method, $params);
292 292
         }
293 293
         return $this->request_streams($url, $method, $params);
@@ -296,19 +296,19 @@  discard block
 block discarded – undo
296 296
     protected function build_url($url, $parts)
297 297
     {
298 298
         if (isset($url['query'], $parts['query'])) {
299
-            $parts['query'] = $url['query'] . '&' . $parts['query'];
299
+            $parts['query'] = $url['query'].'&'.$parts['query'];
300 300
         }
301 301
 
302 302
         $url = $parts + $url;
303
-        $url = $url['scheme'] . '://'
304
-             . (empty($url['username'])?''
305
-                 :(empty($url['password'])? "{$url['username']}@"
303
+        $url = $url['scheme'].'://'
304
+             . (empty($url['username']) ? ''
305
+                 :(empty($url['password']) ? "{$url['username']}@"
306 306
                  :"{$url['username']}:{$url['password']}@"))
307 307
              . $url['host']
308
-             . (empty($url['port'])?'':":{$url['port']}")
309
-             . (empty($url['path'])?'':$url['path'])
310
-             . (empty($url['query'])?'':"?{$url['query']}")
311
-             . (empty($url['fragment'])?'':"#{$url['fragment']}");
308
+             . (empty($url['port']) ? '' : ":{$url['port']}")
309
+             . (empty($url['path']) ? '' : $url['path'])
310
+             . (empty($url['query']) ? '' : "?{$url['query']}")
311
+             . (empty($url['fragment']) ? '' : "#{$url['fragment']}");
312 312
         return $url;
313 313
     }
314 314
 
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
         preg_match_all("#<{$tag}[^>]*$valueName=['\"](.+?)['\"][^>]*$attrName=['\"].*?$attrValue.*?['\"][^>]*/?>#i", $content, $matches2);
323 323
 
324 324
         $result = array_merge($matches1[1], $matches2[1]);
325
-        return empty($result)?false:$result[0];
325
+        return empty($result) ?false:$result[0];
326 326
     }
327 327
 
328 328
     /**
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
         $yadis = true;
349 349
 
350 350
         # We'll jump a maximum of 5 times, to avoid endless redirections.
351
-        for ($i = 0; $i < 5; $i ++) {
351
+        for ($i = 0; $i < 5; $i++) {
352 352
             if ($yadis) {
353 353
                 $headers = $this->request($url, 'HEAD');
354 354
 
@@ -370,12 +370,12 @@  discard block
 block discarded – undo
370 370
                     $content = $this->request($url, 'GET');
371 371
 
372 372
                     preg_match_all('#<Service.*?>(.*?)</Service>#s', $content, $m);
373
-                    foreach($m[1] as $content) {
374
-                        $content = ' ' . $content; # The space is added, so that strpos doesn't return 0.
373
+                    foreach ($m[1] as $content) {
374
+                        $content = ' '.$content; # The space is added, so that strpos doesn't return 0.
375 375
 
376 376
                         # OpenID 2
377 377
                         $ns = preg_quote('http://specs.openid.net/auth/2.0/');
378
-                        if(preg_match('#<Type>\s*'.$ns.'(server|signon)\s*</Type>#s', $content, $type)) {
378
+                        if (preg_match('#<Type>\s*'.$ns.'(server|signon)\s*</Type>#s', $content, $type)) {
379 379
                             if ($type[1] == 'server') $this->identifier_select = true;
380 380
 
381 381
                             preg_match('#<URI.*?>(.*)</URI>#', $content, $server);
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
                                 return false;
385 385
                             }
386 386
                             # Does the server advertise support for either AX or SREG?
387
-                            $this->ax   = (bool) strpos($content, '<Type>http://openid.net/srv/ax/1.0</Type>');
387
+                            $this->ax   = (bool)strpos($content, '<Type>http://openid.net/srv/ax/1.0</Type>');
388 388
                             $this->sreg = strpos($content, '<Type>http://openid.net/sreg/1.0</Type>')
389 389
                                        || strpos($content, '<Type>http://openid.net/extensions/sreg/1.1</Type>');
390 390
 
@@ -498,33 +498,33 @@  discard block
 block discarded – undo
498 498
         if ($this->required || $this->optional) {
499 499
             $params['openid.ns.ax'] = 'http://openid.net/srv/ax/1.0';
500 500
             $params['openid.ax.mode'] = 'fetch_request';
501
-            $this->aliases  = array();
501
+            $this->aliases = array();
502 502
             $counts   = array();
503 503
             $required = array();
504 504
             $optional = array();
505
-            foreach (array('required','optional') as $type) {
505
+            foreach (array('required', 'optional') as $type) {
506 506
                 foreach ($this->$type as $alias => $field) {
507 507
                     if (is_int($alias)) $alias = strtr($field, '/', '_');
508
-                    $this->aliases[$alias] = 'http://axschema.org/' . $field;
508
+                    $this->aliases[$alias] = 'http://axschema.org/'.$field;
509 509
                     if (empty($counts[$alias])) $counts[$alias] = 0;
510 510
                     $counts[$alias] += 1;
511 511
                     ${$type}[] = $alias;
512 512
                 }
513 513
             }
514 514
             foreach ($this->aliases as $alias => $ns) {
515
-                $params['openid.ax.type.' . $alias] = $ns;
515
+                $params['openid.ax.type.'.$alias] = $ns;
516 516
             }
517 517
             foreach ($counts as $alias => $count) {
518 518
                 if ($count == 1) continue;
519
-                $params['openid.ax.count.' . $alias] = $count;
519
+                $params['openid.ax.count.'.$alias] = $count;
520 520
             }
521 521
 
522 522
             # Don't send empty ax.requied and ax.if_available.
523 523
             # Google and possibly other providers refuse to support ax when one of these is empty.
524
-            if($required) {
524
+            if ($required) {
525 525
                 $params['openid.ax.required'] = implode(',', $required);
526 526
             }
527
-            if($optional) {
527
+            if ($optional) {
528 528
                 $params['openid.ax.if_available'] = implode(',', $optional);
529 529
             }
530 530
         }
@@ -537,8 +537,8 @@  discard block
 block discarded – undo
537 537
         # If we have an openid.delegate that is different from our claimed id,
538 538
         # we need to somehow preserve the claimed id between requests.
539 539
         # The simplest way is to just send it along with the return_to url.
540
-        if($this->identity != $this->claimed_id) {
541
-            $returnUrl .= (strpos($returnUrl, '?') ? '&' : '?') . 'openid.claimed_id=' . $this->claimed_id;
540
+        if ($this->identity != $this->claimed_id) {
541
+            $returnUrl .= (strpos($returnUrl, '?') ? '&' : '?').'openid.claimed_id='.$this->claimed_id;
542 542
         }
543 543
 
544 544
         $params = array(
@@ -612,15 +612,15 @@  discard block
 block discarded – undo
612 612
         # by presenting user_setup_url (for 1.1) or reporting
613 613
         # mode 'setup_needed' (for 2.0). Also catching all modes other than
614 614
         # id_res, in order to avoid throwing errors.
615
-        if(isset($this->data['openid_user_setup_url'])) {
615
+        if (isset($this->data['openid_user_setup_url'])) {
616 616
             $this->setup_url = $this->data['openid_user_setup_url'];
617 617
             return false;
618 618
         }
619
-        if($this->mode != 'id_res') {
619
+        if ($this->mode != 'id_res') {
620 620
             return false;
621 621
         }
622 622
 
623
-        $this->claimed_id = isset($this->data['openid_claimed_id'])?$this->data['openid_claimed_id']:$this->data['openid_identity'];
623
+        $this->claimed_id = isset($this->data['openid_claimed_id']) ? $this->data['openid_claimed_id'] : $this->data['openid_identity'];
624 624
         $params = array(
625 625
             'openid.assoc_handle' => $this->data['openid_assoc_handle'],
626 626
             'openid.signed'       => $this->data['openid_signed'],
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
             # If it's an OpenID 1 provider, and we've got claimed_id,
639 639
             # we have to append it to the returnUrl, like authUrl_v1 does.
640 640
             $this->returnUrl .= (strpos($this->returnUrl, '?') ? '&' : '?')
641
-                             .  'openid.claimed_id=' . $this->claimed_id;
641
+                             .  'openid.claimed_id='.$this->claimed_id;
642 642
         }
643 643
 
644 644
         if ($this->data['openid_return_to'] != $this->returnUrl) {
@@ -656,8 +656,8 @@  discard block
 block discarded – undo
656 656
             # In such case, validation would fail, since we'd send different data than OP
657 657
             # wants to verify. stripslashes() should solve that problem, but we can't
658 658
             # use it when magic_quotes is off.
659
-            $value = $this->data['openid_' . str_replace('.','_',$item)];
660
-            $params['openid.' . $item] = (version_compare(PHP_VERSION, '5.4.0') < 0 && get_magic_quotes_gpc()) ? stripslashes($value) : $value;
659
+            $value = $this->data['openid_'.str_replace('.', '_', $item)];
660
+            $params['openid.'.$item] = (version_compare(PHP_VERSION, '5.4.0') < 0 && get_magic_quotes_gpc()) ? stripslashes($value) : $value;
661 661
 
662 662
         }
663 663
 
@@ -695,18 +695,18 @@  discard block
 block discarded – undo
695 695
 
696 696
         $attributes = array();
697 697
         foreach ($this->data as $key => $value) {
698
-            $keyMatch = 'openid_' . $alias . '_value_';
698
+            $keyMatch = 'openid_'.$alias.'_value_';
699 699
             if (substr($key, 0, strlen($keyMatch)) != $keyMatch) {
700 700
                 continue;
701 701
             }
702 702
             $key = substr($key, strlen($keyMatch));
703
-            if (!isset($this->data['openid_' . $alias . '_type_' . $key])) {
703
+            if (!isset($this->data['openid_'.$alias.'_type_'.$key])) {
704 704
                 # OP is breaking the spec by returning a field without
705 705
                 # associated ns. This shouldn't happen, but it's better
706 706
                 # to check, than cause an E_NOTICE.
707 707
                 continue;
708 708
             }
709
-            $key = substr($this->data['openid_' . $alias . '_type_' . $key],
709
+            $key = substr($this->data['openid_'.$alias.'_type_'.$key],
710 710
                           strlen('http://axschema.org/'));
711 711
             $attributes[$key] = $value;
712 712
         }
Please login to merge, or discard this patch.
html/inc/web_rpc_api.inc 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
     // Adapt to your web site. The following assumes Bootstrap.
137 137
     //
138 138
     function show_download_button($info, $is_vbox) {
139
-        $desc = $is_vbox?$info->boinc_vbox:$info->boinc;
139
+        $desc = $is_vbox ? $info->boinc_vbox : $info->boinc;
140 140
         echo sprintf('
141 141
 <form action="https://boinc.berkeley.edu/concierge.php" method="post">
142 142
     <input type=hidden name=project_id value="%d">
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
             (string)$info->token,
151 151
             (int)$info->user_id,
152 152
             (string)$desc->filename,
153
-            $is_vbox?" + VirtualBox":"",
153
+            $is_vbox ? " + VirtualBox" : "",
154 154
             (string)$info->platform,
155 155
             (string)$desc->size_mb
156 156
         );
Please login to merge, or discard this patch.
html/inc/rss.inc 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@
 block discarded – undo
55 55
 // You can pass a function $filter;
56 56
 // if $filter(item) returns true, don't show it.
57 57
 //
58
-function show_rss_items($items, $n=0, $filter=null) {
58
+function show_rss_items($items, $n = 0, $filter = null) {
59 59
     $i = 0;
60 60
     foreach ($items as $item) {
61 61
         if ($filter && $filter($item)) {
Please login to merge, or discard this patch.
html/inc/random_compat/random_bytes_dev_urandom.inc 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -141,7 +141,7 @@
 block discarded – undo
141 141
                 /**
142 142
                  * @var string|bool
143 143
                  */
144
-                $buf = $buf . $read;
144
+                $buf = $buf.$read;
145 145
             } while ($remaining > 0);
146 146
 
147 147
             /**
Please login to merge, or discard this patch.
html/inc/random_compat/byte_safe_strings.inc 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
                 );
52 52
             }
53 53
 
54
-            return (int) mb_strlen($binary_string, '8bit');
54
+            return (int)mb_strlen($binary_string, '8bit');
55 55
         }
56 56
 
57 57
     } else {
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
                     'RandomCompat_strlen() expects a string'
74 74
                 );
75 75
             }
76
-            return (int) strlen($binary_string);
76
+            return (int)strlen($binary_string);
77 77
         }
78 78
     }
79 79
 }
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
                 return '';
134 134
             }
135 135
 
136
-            return (string) mb_substr($binary_string, $start, $length, '8bit');
136
+            return (string)mb_substr($binary_string, $start, $length, '8bit');
137 137
         }
138 138
 
139 139
     } else {
@@ -172,10 +172,10 @@  discard block
 block discarded – undo
172 172
                     );
173 173
                 }
174 174
 
175
-                return (string) substr($binary_string, $start, $length);
175
+                return (string)substr($binary_string, $start, $length);
176 176
             }
177 177
 
178
-            return (string) substr($binary_string, $start);
178
+            return (string)substr($binary_string, $start);
179 179
         }
180 180
     }
181 181
 }
Please login to merge, or discard this patch.
html/inc/geoip.inc 1 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.
drupal/sites/all/themes/zen/template.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
  */
23 23
 function zen_theme(&$existing, $type, $theme, $path) {
24 24
   // When #341140 is fixed, replace _zen_path() with drupal_get_path().
25
-  include_once './' . _zen_path() . '/zen-internals/template.theme-registry.inc';
25
+  include_once './'._zen_path().'/zen-internals/template.theme-registry.inc';
26 26
   return _zen_theme($existing, $type, $theme, $path);
27 27
 }
28 28
 
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
       elseif (theme_get_setting('zen_breadcrumb_trailing')) {
58 58
         $trailing_separator = $breadcrumb_separator;
59 59
       }
60
-      return '<div class="breadcrumb">' . implode($breadcrumb_separator, $breadcrumb) . "$trailing_separator$title</div>";
60
+      return '<div class="breadcrumb">'.implode($breadcrumb_separator, $breadcrumb)."$trailing_separator$title</div>";
61 61
     }
62 62
   }
63 63
   // Otherwise, return an empty string.
@@ -106,14 +106,14 @@  discard block
 block discarded – undo
106 106
           'level' => 'h2',
107 107
         );
108 108
       }
109
-      $output .= '<' . $heading['level'];
109
+      $output .= '<'.$heading['level'];
110 110
       if (!empty($heading['class'])) {
111 111
         $output .= drupal_attributes(array('class' => $heading['class']));
112 112
       }
113
-      $output .= '>' . check_plain($heading['text']) . '</' . $heading['level'] . '>';
113
+      $output .= '>'.check_plain($heading['text']).'</'.$heading['level'].'>';
114 114
     }
115 115
 
116
-    $output .= '<ul'. drupal_attributes($attributes) .'>';
116
+    $output .= '<ul'.drupal_attributes($attributes).'>';
117 117
 
118 118
     $num_links = count($links);
119 119
     $i = 1;
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
           && (empty($link['language']) || $link['language']->language == $language->language)) {
133 133
         $class .= ' active';
134 134
       }
135
-      $output .= '<li'. drupal_attributes(array('class' => $class)) .'>';
135
+      $output .= '<li'.drupal_attributes(array('class' => $class)).'>';
136 136
 
137 137
       if (isset($link['href'])) {
138 138
         // Pass in $link as $options, they share the same keys.
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
         if (isset($link['attributes'])) {
148 148
           $span_attributes = drupal_attributes($link['attributes']);
149 149
         }
150
-        $output .= '<span'. $span_attributes .'>'. $link['title'] .'</span>';
150
+        $output .= '<span'.$span_attributes.'>'.$link['title'].'</span>';
151 151
       }
152 152
 
153 153
       $i++;
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 
171 171
   // If an item is a LOCAL TASK, render it as a tab
172 172
   if ($link['type'] & MENU_IS_LOCAL_TASK) {
173
-    $link['title'] = '<span class="tab">' . check_plain($link['title']) . '</span>';
173
+    $link['title'] = '<span class="tab">'.check_plain($link['title']).'</span>';
174 174
     $link['localized_options']['html'] = TRUE;
175 175
   }
176 176
 
@@ -195,10 +195,10 @@  discard block
 block discarded – undo
195 195
   }
196 196
 
197 197
   if ($primary) {
198
-    $output .= '<ul class="tabs primary clearfix">' . $primary . '</ul>';
198
+    $output .= '<ul class="tabs primary clearfix">'.$primary.'</ul>';
199 199
   }
200 200
   if ($secondary) {
201
-    $output .= '<ul class="tabs secondary clearfix">' . $secondary . '</ul>';
201
+    $output .= '<ul class="tabs secondary clearfix">'.$secondary.'</ul>';
202 202
   }
203 203
 
204 204
   return $output;
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
     $elements['#region'] = $region;
254 254
 
255 255
     // Set the theme hook suggestions.
256
-    $hook = array('region_' . $region);
256
+    $hook = array('region_'.$region);
257 257
     if (strpos($region, 'sidebar_') === 0) {
258 258
       $hook[] = 'region_sidebar';
259 259
     }
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
     // Views (and possibly other modules) have templates with a $classes
296 296
     // variable that isn't a string, so we leave those variables alone.
297 297
     if (is_string($vars[$key])) {
298
-      $vars['classes_array'] = explode(' ', $hook . ' ' . $vars[$key]);
298
+      $vars['classes_array'] = explode(' ', $hook.' '.$vars[$key]);
299 299
       unset($vars[$key]);
300 300
     }
301 301
   }
@@ -319,37 +319,37 @@  discard block
 block discarded – undo
319 319
 function zen_preprocess_page(&$vars, $hook) {
320 320
   // If the user is silly and enables Zen as the theme, add some styles.
321 321
   if ($GLOBALS['theme'] == 'zen') {
322
-    include_once './' . _zen_path() . '/zen-internals/template.zen.inc';
322
+    include_once './'._zen_path().'/zen-internals/template.zen.inc';
323 323
     _zen_preprocess_page($vars, $hook);
324 324
   }
325 325
   // Add conditional stylesheets.
326 326
   elseif (!module_exists('conditional_styles')) {
327 327
     $language = $GLOBALS['language']->direction == LANGUAGE_RTL ? '_rtl' : '';
328
-    $vars['conditional_styles'] = variable_get('conditional_styles_' . $GLOBALS['theme'] . $language, '');
328
+    $vars['conditional_styles'] = variable_get('conditional_styles_'.$GLOBALS['theme'].$language, '');
329 329
     $vars['styles'] .= $vars['conditional_styles'];
330 330
   }
331 331
 
332 332
   // Classes for body element. Allows advanced theming based on context
333 333
   // (home page, node of certain type, etc.)
334 334
   // Remove the mostly useless page-ARG0 class.
335
-  if ($index = array_search(preg_replace('![^abcdefghijklmnopqrstuvwxyz0-9-_]+!s', '', 'page-'. drupal_strtolower(arg(0))), $vars['classes_array'])) {
335
+  if ($index = array_search(preg_replace('![^abcdefghijklmnopqrstuvwxyz0-9-_]+!s', '', 'page-'.drupal_strtolower(arg(0))), $vars['classes_array'])) {
336 336
     unset($vars['classes_array'][$index]);
337 337
   }
338 338
   if (!$vars['is_front']) {
339 339
     // Add unique class for each page.
340 340
     $path = drupal_get_path_alias($_GET['q']);
341
-    $vars['classes_array'][] = drupal_html_class('page-' . $path);
341
+    $vars['classes_array'][] = drupal_html_class('page-'.$path);
342 342
     // Add unique class for each website section.
343
-    list($section, ) = explode('/', $path, 2);
343
+    list($section,) = explode('/', $path, 2);
344 344
     if (arg(0) == 'node') {
345 345
       if (arg(1) == 'add') {
346 346
         $section = 'node-add';
347 347
       }
348 348
       elseif (is_numeric(arg(1)) && (arg(2) == 'edit' || arg(2) == 'delete')) {
349
-        $section = 'node-' . arg(2);
349
+        $section = 'node-'.arg(2);
350 350
       }
351 351
     }
352
-    $vars['classes_array'][] = drupal_html_class('section-' . $section);
352
+    $vars['classes_array'][] = drupal_html_class('section-'.$section);
353 353
   }
354 354
   if (theme_get_setting('zen_wireframes')) {
355 355
     $vars['classes_array'][] = 'with-wireframes'; // Optionally add the wireframes style.
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
     }
377 377
     else {
378 378
       $vars['classes_array'][] = 'one-sidebar';
379
-      $vars['classes_array'][] = 'sidebar-' . $vars['layout'];
379
+      $vars['classes_array'][] = 'sidebar-'.$vars['layout'];
380 380
     }
381 381
   }
382 382
   // Store the menu item since it has some useful information.
@@ -406,13 +406,13 @@  discard block
 block discarded – undo
406 406
 function zen_preprocess_maintenance_page(&$vars, $hook) {
407 407
   // If Zen is the maintenance theme, add some styles.
408 408
   if ($GLOBALS['theme'] == 'zen') {
409
-    include_once './' . _zen_path() . '/zen-internals/template.zen.inc';
409
+    include_once './'._zen_path().'/zen-internals/template.zen.inc';
410 410
     _zen_preprocess_page($vars, $hook);
411 411
   }
412 412
   // Add conditional stylesheets.
413 413
   elseif (!module_exists('conditional_styles')) {
414 414
     $language = $GLOBALS['language']->direction == LANGUAGE_RTL ? '_rtl' : '';
415
-    $vars['conditional_styles'] = variable_get('conditional_styles_' . $GLOBALS['theme'] . $language, '');
415
+    $vars['conditional_styles'] = variable_get('conditional_styles_'.$GLOBALS['theme'].$language, '');
416 416
     $vars['styles'] .= $vars['conditional_styles'];
417 417
   }
418 418
 }
@@ -459,11 +459,11 @@  discard block
 block discarded – undo
459 459
   $vars['user_picture'] = $vars['picture'];
460 460
 
461 461
   // Create the Drupal 7 $display_submitted variable.
462
-  $vars['display_submitted'] = theme_get_setting('toggle_node_info_' . $vars['node']->type);
462
+  $vars['display_submitted'] = theme_get_setting('toggle_node_info_'.$vars['node']->type);
463 463
 
464 464
   // Special classes for nodes.
465 465
   // Class for node type: "node-type-page", "node-type-story", "node-type-my-custom-type", etc.
466
-  $vars['classes_array'][] = drupal_html_class('node-type-' . $vars['type']);
466
+  $vars['classes_array'][] = drupal_html_class('node-type-'.$vars['type']);
467 467
   if ($vars['promote']) {
468 468
     $vars['classes_array'][] = 'node-promoted';
469 469
   }
@@ -486,7 +486,7 @@  discard block
 block discarded – undo
486 486
   if (isset($vars['preview'])) {
487 487
     $vars['classes_array'][] = 'node-preview';
488 488
   }
489
-  $vars['classes_array'][] = 'build-mode-' . $vars['build_mode'] ;
489
+  $vars['classes_array'][] = 'build-mode-'.$vars['build_mode'];
490 490
 }
491 491
 
492 492
 /**
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
  *   The name of the template being rendered ("comment" in this case.)
499 499
  */
500 500
 function zen_preprocess_comment(&$vars, $hook) {
501
-  include_once './' . _zen_path() . '/zen-internals/template.comment.inc';
501
+  include_once './'._zen_path().'/zen-internals/template.comment.inc';
502 502
   _zen_preprocess_comment($vars, $hook);
503 503
 }
504 504
 
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
   $vars['region'] = $vars['elements']['#region'];
517 517
 
518 518
   // Setup the default classes.
519
-  $vars['classes_array'] = array('region', 'region-' . str_replace('_', '-', $vars['region']));
519
+  $vars['classes_array'] = array('region', 'region-'.str_replace('_', '-', $vars['region']));
520 520
 
521 521
   // Sidebar regions get a couple extra classes.
522 522
   if (strpos($vars['region'], 'sidebar_') === 0) {
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
   $vars['title'] = $block->subject;
543 543
 
544 544
   // Special classes for blocks.
545
-  $vars['classes_array'][] = 'block-' . $block->module;
545
+  $vars['classes_array'][] = 'block-'.$block->module;
546 546
   // Classes describing the position of the block within the region.
547 547
   if ($vars['block_id'] == 1) {
548 548
     $vars['classes_array'][] = 'first';
@@ -550,17 +550,17 @@  discard block
 block discarded – undo
550 550
   if (!function_exists('context_blocks') && count(block_list($vars['block']->region)) == $vars['block_id']) {
551 551
     $vars['classes_array'][] = 'last';
552 552
   }
553
-  $vars['classes_array'][] = 'region-' . $vars['block_zebra'];
553
+  $vars['classes_array'][] = 'region-'.$vars['block_zebra'];
554 554
   $vars['classes_array'][] = $vars['zebra'];
555
-  $vars['classes_array'][] = 'region-count-' . $vars['block_id'];
556
-  $vars['classes_array'][] = 'count-' . $vars['id'];
555
+  $vars['classes_array'][] = 'region-count-'.$vars['block_id'];
556
+  $vars['classes_array'][] = 'count-'.$vars['id'];
557 557
 
558 558
   // Create the block ID.
559
-  $vars['block_html_id'] = 'block-' . $block->module . '-' . $block->delta;
559
+  $vars['block_html_id'] = 'block-'.$block->module.'-'.$block->delta;
560 560
 
561 561
   $vars['edit_links_array'] = array();
562 562
   if (theme_get_setting('zen_block_editing') && user_access('administer blocks')) {
563
-    include_once './' . _zen_path() . '/zen-internals/template.block-editing.inc';
563
+    include_once './'._zen_path().'/zen-internals/template.block-editing.inc';
564 564
     zen_preprocess_block_editing($vars, $hook);
565 565
     $vars['classes_array'][] = 'with-block-editing';
566 566
   }
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
  *   The name of the template being rendered ("block" in this case.)
591 591
  */
592 592
 function zen_process_block(&$vars, $hook) {
593
-  $vars['edit_links'] = !empty($vars['edit_links_array']) ? '<div class="edit">' . implode(' ', $vars['edit_links_array']) . '</div>' : '';
593
+  $vars['edit_links'] = !empty($vars['edit_links_array']) ? '<div class="edit">'.implode(' ', $vars['edit_links_array']).'</div>' : '';
594 594
 }
595 595
 
596 596
 if (!function_exists('drupal_html_class')) {
Please login to merge, or discard this patch.