2013-09-16 17:41:31 +02:00
|
|
|
<?php
|
|
|
|
// Define path to application directory
|
|
|
|
defined('APPLICATION_PATH')
|
2014-03-14 11:42:09 +01:00
|
|
|
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../application'));
|
2013-09-16 17:41:31 +02:00
|
|
|
|
|
|
|
// Define application environment
|
|
|
|
defined('APPLICATION_ENV')
|
2014-03-14 11:42:09 +01:00
|
|
|
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
|
2013-09-16 17:41:31 +02:00
|
|
|
|
|
|
|
// Ensure library/ is on include_path
|
|
|
|
set_include_path(implode(PATH_SEPARATOR, array(
|
2014-03-14 11:42:09 +01:00
|
|
|
realpath(APPLICATION_PATH . '/../library'),
|
|
|
|
get_include_path(),
|
2013-09-16 17:41:31 +02:00
|
|
|
)));
|
|
|
|
|
2014-03-14 11:42:09 +01:00
|
|
|
//Use classmap autoloader - useful with opcode and realpath cache
|
|
|
|
require_once 'Zend/Loader/AutoloaderFactory.php';
|
|
|
|
require_once 'Zend/Loader/ClassMapAutoloader.php';
|
|
|
|
Zend_Loader_AutoloaderFactory::factory(array(
|
|
|
|
'Zend_Loader_ClassMapAutoloader' => array(
|
|
|
|
__DIR__ . '/../../library/Zend/autoload_classmap.php',
|
|
|
|
__DIR__ . '/../../library/Application/autoload_classmap.php',
|
|
|
|
__DIR__ . '/../../library/Scores/autoload_classmap.php',
|
|
|
|
__DIR__ . '/../../application/autoload_classmap.php',
|
|
|
|
),
|
|
|
|
'Zend_Loader_StandardAutoloader' => array(
|
|
|
|
'prefixes' => array(
|
|
|
|
'Zend' => __DIR__ . '/../../library/Zend',
|
|
|
|
'Application' => __DIR__ . '/../../library/Application',
|
|
|
|
'Scores' => __DIR__ . '/../../library/Scores',
|
|
|
|
'Metier' => __DIR__ . '/../../library/Metier',
|
|
|
|
),
|
|
|
|
'fallback_autoloader' => true
|
|
|
|
)
|
|
|
|
));
|
|
|
|
|
|
|
|
// Zend_Application - Use it if you don't have autoloaders
|
|
|
|
//require_once 'Zend/Application.php';
|
2013-09-16 17:41:31 +02:00
|
|
|
|
|
|
|
// Create application, bootstrap, and run
|
|
|
|
$application = new Zend_Application(
|
2014-03-14 11:42:09 +01:00
|
|
|
APPLICATION_ENV,
|
|
|
|
APPLICATION_PATH . '/configs/application.ini'
|
2013-09-16 17:41:31 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
try {
|
|
|
|
$opts = new Zend_Console_Getopt(
|
2014-03-14 11:42:09 +01:00
|
|
|
//Options
|
|
|
|
array(
|
|
|
|
'help|?' => "Affiche l'aide.",
|
|
|
|
'cron' => "Mandatory for automatic mode",
|
|
|
|
'get=s' => "Relance la commande pour un login",
|
|
|
|
)
|
2013-09-16 17:41:31 +02:00
|
|
|
);
|
|
|
|
$opts->parse();
|
|
|
|
} catch (Zend_Console_Getopt_Exception $e) {
|
|
|
|
echo $e->getUsageMessage();
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Usage
|
|
|
|
if(count($opts->getOptions())==0 || isset($opts->help))
|
|
|
|
{
|
|
|
|
echo "Demande et télécharge le portefeuille au format csv pour le client";
|
|
|
|
echo "\n\n";
|
|
|
|
echo $opts->getUsageMessage();
|
|
|
|
echo "\n";
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
$c = new Zend_Config($application->getOptions());
|
|
|
|
Zend_Registry::set('config', $c);
|
|
|
|
|
|
|
|
//Liste des logins avec leur hash
|
|
|
|
$logins = array(
|
|
|
|
'kpun1' => 'd21346ccbcf24c6a69ed01f82e04cc39',
|
|
|
|
'olymp2' => 'a1b7d26be20e7bc7ee5daa05bafda09c',
|
|
|
|
'groupmsurv' => '7405a5afba5a1e5f27982eb22d2bf542',
|
|
|
|
'initialadm' => '041c15646e425682859e396734ec2240',
|
2013-10-04 14:41:24 +02:00
|
|
|
'paprec1' => '582a6470d2fb8a44c8c7ad6387f56bd4',
|
2013-09-16 17:41:31 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
if ( $opts->get ) {
|
|
|
|
|
|
|
|
if ( in_array($opts->get, array(array_keys($logins))) ) {
|
|
|
|
$logins = array($opts->get => $logins[$opts->get]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
require_once 'Scores/WsScores.php';
|
|
|
|
|
|
|
|
foreach ($logins as $login => $hash ) {
|
|
|
|
|
|
|
|
echo date('Y-m-dTH:i:s') . " - Login : " . $login;
|
|
|
|
|
|
|
|
$ws = new WsScores($login, $hash);
|
|
|
|
|
|
|
|
//Faire la demande du protefeuille en CSV,
|
|
|
|
$response = $ws->getPortefeuilleCsv($login);
|
|
|
|
|
|
|
|
if ( $response !== false ) {
|
|
|
|
|
|
|
|
//Wait for the file
|
|
|
|
sleep(10);
|
|
|
|
|
|
|
|
$url = $response->result->Url;
|
|
|
|
|
|
|
|
echo " URL = " . $url;
|
|
|
|
|
|
|
|
$file = basename($url);
|
|
|
|
$path = $c->profil->path->files;
|
|
|
|
|
|
|
|
//Télécharger le fichier
|
|
|
|
try {
|
|
|
|
$client = new Zend_Http_Client($url);
|
|
|
|
$client->setStream();
|
|
|
|
$response = $client->request('GET');
|
|
|
|
if ( copy($response->getStreamName(), $path . DIRECTORY_SEPARATOR . $file) ) {
|
|
|
|
echo " - Fichier créer.";
|
|
|
|
}
|
|
|
|
} catch (Zend_Http_Client_Exception $e) {
|
|
|
|
echo " - Erreur ".$e->getMessage();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
echo PHP_EOL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|