#!/usr/bin/php -q "Affiche l'aide.", 'all' => "Charge tout les éléments", 'one' => "Charge un élément", ) ); $opts->parse(); } catch (Zend_Console_Getopt_Exception $e) { echo $e->getUsageMessage(); exit; } //Usage if(count($opts->getOptions())==0 || isset($opts->help)) { echo "Charge les données nécessaire à l'applicatioon à partir du webservice."; echo "\n\n"; echo $opts->getUsageMessage(); echo "\n"; exit; } //Utilisateur webservice define('LOGIN', ''); define('PASSWORD', ''); $args = $opts->getRemainingArgs(); $elements = array('naf'); if ($opts->all || $opts->one){ require_once 'Scores/WsScores.php'; $ws = new WsScores(LOGIN, PASSWORD); } if ($opts->all) { foreach($elements as $element) { $reponse = $ws->getDataCSV($element); } } elseif ($opts->one) { //Vérification $element = $args[0]; if (!in_array($args[0], $elements)){ echo 'Element inconnu !'; } $reponse = $ws->getDataCSV($element); } //Méthodes interne function getFichier($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($ch, CURLOPT_COOKIEFILE,TRUE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); $output = curl_exec($ch); curl_close($ch); return $output; } function saveToDatabase($key, $filename) { //Vider la table $sql = "TRUNCATE $key"; //Sauvegarder toutes les lignes $cmd = "mysqlimport --ignore-lines=1 --fields-enclosed-by=\\\" --fields-terminated-by=, --user=USERNAME --password=PASSWORD ciblage $filename"; exec($command); } ?>