echo $str . PHP_EOL; } } function csv_line($str) { if (!$GLOBALS["isVerbose"]) { echo $str . PHP_EOL; } } if ($argc < 2 && $argc > 4) { die_usage(); } $filePtr = file($argv[1]); $GLOBALS["isVerbose"] = $argv[2] == "--verbose" ? true : false; if (!$filePtr) { die_usage("Error : file not found."); } $csv = array_map('str_getcsv', $filePtr); $total = 0; $success = 0; foreach ($csv as $key => $row) { $address = trim($row[0]); $address = str_replace(';', ' ', $address); $address = preg_replace('!\\s+!', ' ', $address); verbose("Looking for : {$address}"); $geo = file_get_contents('http://maps.googleapis.com/maps/api/geocode/json?address=' . urlencode($address) . '&sensor=false'); $geo = json_decode($geo, true); if ($geo['status'] = 'OK') { $success++; verbose("Found !"); $latitude = $geo['results'][0]['geometry']['location']['lat'];
foreach ($options as $key => $value) { switch ($key) { case 't': case 'token': $vault_token = $value; break; case 'a': case 'addr': $vault_addr = $value; break; case 'k': case 'key': $vault_key = $value; break; default: die_usage(); } } if (is_null($vault_addr) or is_null($vault_token) or is_null($vault_key)) { die_usage(); } $vaultURI = new VaultURI($vault_addr); $vaultAuthToken = new VaultAuthToken($vault_token); $vault = new Vault($vaultURI, $vaultAuthToken); $value = $vault->read($vault_key); $env = $value->get(); if (is_array($env)) { foreach ($env as $key => $value) { echo 'export ' . $key . '=' . escapeshellarg($value) . PHP_EOL; } }