@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | require 'stuff.php'; |
| 3 | 3 | $config = parse_ini_file($argv[1]); |
| 4 | -if (! $config) { |
|
| 4 | +if (!$config) { |
|
| 5 | 5 | echo "Couldn't parse the config file."; |
| 6 | 6 | exit(1); |
| 7 | 7 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | if ($ceps) { |
| 24 | 24 | if (is_numeric($ceps['codigoMunIBGE'])) { |
| 25 | 25 | if ($ceps['codigoMunIBGE'] === 0) { |
| 26 | - if (!$stm3->execute(array('BR-'.$ceps['state'],$ceps['infoAdicional']))) { |
|
| 26 | + if (!$stm3->execute(array('BR-'.$ceps['state'], $ceps['infoAdicional']))) { |
|
| 27 | 27 | print_r($pdo->errorInfo()); |
| 28 | 28 | return false; |
| 29 | 29 | } |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | print_r('dunno'); |
| 50 | 50 | return false; |
| 51 | 51 | } |
| 52 | - } elseif (is_numeric($person['city_id']) && $person['city_id'] == 0) { |
|
| 52 | + } elseif (is_numeric($person['city_id']) && $person['city_id'] == 0) { |
|
| 53 | 53 | if (!$stm1->execute(array(null, null, null, null, $person['id']))) { |
| 54 | 54 | print_r($pdo->errorInfo()); |
| 55 | 55 | return false; |
@@ -12,27 +12,27 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | $this->createDir($directory); |
| 14 | 14 | |
| 15 | - $copySource = 'zip://' . $this->filename . '#'; |
|
| 16 | - for ($i = 0; $i < $this->numFiles; $i ++) { |
|
| 15 | + $copySource = 'zip://'.$this->filename.'#'; |
|
| 16 | + for ($i = 0; $i < $this->numFiles; $i++) { |
|
| 17 | 17 | $entry = $this->getNameIndex($i); |
| 18 | 18 | $filename = basename($entry); |
| 19 | 19 | |
| 20 | 20 | if ($this->matchFileToFilter($filename, $filters)) { |
| 21 | 21 | $base = dirname($entry); |
| 22 | - $newPath = $directory . DIRECTORY_SEPARATOR . $base . DIRECTORY_SEPARATOR; |
|
| 22 | + $newPath = $directory.DIRECTORY_SEPARATOR.$base.DIRECTORY_SEPARATOR; |
|
| 23 | 23 | $this->createDir($newPath); |
| 24 | 24 | |
| 25 | 25 | // extract file |
| 26 | - copy($copySource . $entry, $newPath . $filename); |
|
| 26 | + copy($copySource.$entry, $newPath.$filename); |
|
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | protected function createDir($path) |
| 32 | 32 | { |
| 33 | - if (! is_dir($path)) { |
|
| 34 | - if (! mkdir($path, self::CHMOD, true)) { |
|
| 35 | - throw new Exception('unable to create path ' . $path); |
|
| 33 | + if (!is_dir($path)) { |
|
| 34 | + if (!mkdir($path, self::CHMOD, true)) { |
|
| 35 | + throw new Exception('unable to create path '.$path); |
|
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | } |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | foreach ($filters as $i => $filter) { |
| 49 | 49 | |
| 50 | - if (! ctype_alnum($filter[0]) && preg_match($filter, $filename)) { |
|
| 50 | + if (!ctype_alnum($filter[0]) && preg_match($filter, $filename)) { |
|
| 51 | 51 | return true; |
| 52 | 52 | } |
| 53 | 53 | } |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | $ch = curl_init(); |
| 72 | 72 | // curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
| 73 | 73 | $f = fopen($file, 'wb'); |
| 74 | - if (! $f) { |
|
| 74 | + if (!$f) { |
|
| 75 | 75 | return false; |
| 76 | 76 | } |
| 77 | 77 | curl_setopt($ch, CURLOPT_FILE, $f); |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | } |
| 85 | 85 | $result = curl_exec($ch); |
| 86 | 86 | if (!$result) { |
| 87 | - echo curl_error ($ch ); |
|
| 87 | + echo curl_error($ch); |
|
| 88 | 88 | } |
| 89 | 89 | curl_close($ch); |
| 90 | 90 | fclose($f); |
@@ -119,9 +119,9 @@ discard block |
||
| 119 | 119 | foreach ($in as $key => $value) { |
| 120 | 120 | $out[utf8_encode_recursivo($key)] = utf8_encode_recursivo($value); |
| 121 | 121 | } |
| 122 | - } elseif(is_string($in)) { |
|
| 123 | - if(!mb_check_encoding($in, 'UTF-8') |
|
| 124 | - OR !($in === mb_convert_encoding(mb_convert_encoding($in, 'UTF-32', 'UTF-8' ), 'UTF-8', 'UTF-32'))) { |
|
| 122 | + } elseif (is_string($in)) { |
|
| 123 | + if (!mb_check_encoding($in, 'UTF-8') |
|
| 124 | + OR !($in === mb_convert_encoding(mb_convert_encoding($in, 'UTF-32', 'UTF-8'), 'UTF-8', 'UTF-32'))) { |
|
| 125 | 125 | $in = mb_convert_encoding($in, 'UTF-8'); |
| 126 | 126 | } |
| 127 | 127 | return $in; |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | ); |
| 182 | 182 | $headApp = array_merge($headApp, $header); |
| 183 | 183 | curl_setopt($this->ch, CURLOPT_HTTPHEADER, $headApp); |
| 184 | - if (! $this->cookie) { |
|
| 184 | + if (!$this->cookie) { |
|
| 185 | 185 | $tmp = getenv('TMPDIR'); |
| 186 | 186 | if ($tmp && @is_writable($tmp)) { |
| 187 | 187 | $tmpDir = $tmp; |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | 'key' => $this->key, |
| 203 | 203 | 'cep' => $var |
| 204 | 204 | )); |
| 205 | - $url = $this->url . '?' . $data; |
|
| 205 | + $url = $this->url.'?'.$data; |
|
| 206 | 206 | curl_setopt($this->ch, CURLOPT_URL, $url); |
| 207 | 207 | $result = curl_exec($this->ch); |
| 208 | 208 | curl_close($this->ch); |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | 'action' => 'pesquisa', |
| 223 | 223 | 'key' => $this->key |
| 224 | 224 | )); |
| 225 | - curl_setopt($this->ch, CURLOPT_URL, $this->url . '?' . $dataGet); |
|
| 225 | + curl_setopt($this->ch, CURLOPT_URL, $this->url.'?'.$dataGet); |
|
| 226 | 226 | curl_setopt($this->ch, CURLOPT_POST, 1); |
| 227 | 227 | curl_setopt($this->ch, CURLOPT_POSTFIELDS, $data); |
| 228 | 228 | $result = curl_exec($this->ch); |
@@ -235,11 +235,11 @@ discard block |
||
| 235 | 235 | return false; |
| 236 | 236 | } |
| 237 | 237 | $dom = new \DOMDocument(); |
| 238 | - if (! @$dom->loadXML($result)) { |
|
| 238 | + if (!@$dom->loadXML($result)) { |
|
| 239 | 239 | return false; |
| 240 | 240 | } |
| 241 | 241 | $node = $dom->getElementsByTagName('valor'); |
| 242 | - if (! $node) { |
|
| 242 | + if (!$node) { |
|
| 243 | 243 | return false; |
| 244 | 244 | } |
| 245 | 245 | return json_decode($node->item(0)->nodeValue, true); |