101 lines
3.2 KiB
PHP
101 lines
3.2 KiB
PHP
<?php
|
|
// Define path to application directory
|
|
defined('APPLICATION_PATH')
|
|
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../application'));
|
|
|
|
// Define application environment
|
|
defined('APPLICATION_ENV')
|
|
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
|
|
|
|
// Ensure library/ is on include_path
|
|
set_include_path(implode(PATH_SEPARATOR, array(
|
|
realpath(APPLICATION_PATH . '/../library'),
|
|
get_include_path(),
|
|
)));
|
|
|
|
//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',
|
|
'SdMetier' => __DIR__ . '/../../library/SdMetier',
|
|
'Metier' => __DIR__ . '/../../library/Metier',
|
|
),
|
|
'fallback_autoloader' => true
|
|
)
|
|
));
|
|
|
|
// Zend_Application - Use it if you don't have autoloaders
|
|
//require_once 'Zend/Application.php';
|
|
|
|
// Create application, bootstrap, and run
|
|
$application = new Zend_Application(
|
|
APPLICATION_ENV,
|
|
APPLICATION_PATH . '/configs/application.ini'
|
|
);
|
|
|
|
try {
|
|
$opts = new Zend_Console_Getopt(
|
|
//Options
|
|
array(
|
|
'help|?' => 'Displays usage information.',
|
|
)
|
|
);
|
|
$opts->parse();
|
|
} catch (Zend_Console_Getopt_Exception $e) {
|
|
echo $e->getUsageMessage();
|
|
exit;
|
|
}
|
|
|
|
$c = new Zend_Config($application->getOptions());
|
|
Zend_Registry::set('config', $c);
|
|
|
|
require_once 'WsScore/Configure.php';
|
|
$oldconfig = new Configure();
|
|
|
|
//Usage
|
|
if(isset($opts->help))
|
|
{
|
|
echo "\n";
|
|
echo $opts->getUsageMessage();
|
|
echo basename($argv[0]). " BASE FICHIER.SQL FICHIER.CSV\n";
|
|
echo "Génération d'un fichier CSV à partir d'un fichier SQL sur la BASE en paramètre.";
|
|
echo "\n";
|
|
exit;
|
|
}
|
|
elseif (count($opts)==1 && $argc==4)
|
|
{
|
|
require_once 'framework/fwk.php';
|
|
require_once 'framework/common/chiffres.php';
|
|
require_once 'framework/common/dates.php';
|
|
require_once 'framework/mail/sendMail.php';
|
|
require_once 'Metier/insee/classMInsee.php';
|
|
require_once 'Metier/partenaires/classMGreffes.php';
|
|
require_once 'Metier/partenaires/classMBilans.php';
|
|
|
|
$base = $argv[1];
|
|
$sql = $argv[2];
|
|
$csv = $argv[3];
|
|
|
|
$heureDemande = date('Hi');
|
|
|
|
$iDb = new WDB($base, '195.154.170.169:53336', 'root', 'scores');
|
|
$nbLignes = $iDb->exportCSV(file_get_contents($sql), $csv.'.tmp');
|
|
$fp = fopen(LOG_PATH.'/csv2sql.log', 'a');
|
|
fwrite($fp, date('Y-m-d H:i:s')." - $base $sql $csv : $nbLignes lignes extraites".EOL);
|
|
fclose($fp);
|
|
move($csv.'.tmp', $csv);
|
|
} else {
|
|
echo "Erreur !\n";
|
|
}
|