From d8cd599d24dd58675b92f753d5db3454fda1b9ca Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Mon, 28 Jan 2013 17:31:29 +0000 Subject: [PATCH] delete config file configuration.ini --- application/Bootstrap.php | 13 ++++-- application/configs/application.ini | 15 +++++++ application/controllers/DoublonController.php | 10 ++--- application/controllers/EnvoiController.php | 10 ++--- batch/cron.php | 8 ++-- batch/enrichissement.php | 13 +++--- config/configure.php | 16 ++++--- config/local/application.ini | 42 +++++++++++++++++++ config/local/configuration.ini | 22 ---------- config/sdsrvdev01/application.ini | 42 +++++++++++++++++++ config/sdsrvdev01/configuration.ini | 22 ---------- 11 files changed, 140 insertions(+), 73 deletions(-) create mode 100644 config/local/application.ini delete mode 100644 config/local/configuration.ini create mode 100644 config/sdsrvdev01/application.ini delete mode 100644 config/sdsrvdev01/configuration.ini diff --git a/application/Bootstrap.php b/application/Bootstrap.php index 775de906..ec979abf 100644 --- a/application/Bootstrap.php +++ b/application/Bootstrap.php @@ -1,7 +1,14 @@ getOptions()); + Zend_Registry::set('config', $config); + return $config; + } + + //Initialisation global des paramètres de vue protected function _initViewSettings() { $this->bootstrap('view'); @@ -30,9 +37,9 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap protected function _initDb() { - $dbConfig = new Zend_Config_Ini(APPLICATION_PATH . '/configs/configuration.ini', 'databases'); + $c = Zend_Registry::get('config'); try { - $db = Zend_Db::factory($dbConfig->db); + $db = Zend_Db::factory($c->profil->db); Zend_Db_Table::setDefaultAdapter ($db); } catch ( Exception $e ) { exit ( $e->getMessage() ); diff --git a/application/configs/application.ini b/application/configs/application.ini index 12d812c0..78655e23 100644 --- a/application/configs/application.ini +++ b/application/configs/application.ini @@ -12,6 +12,21 @@ resources.layout.layout = "main" resources.layout.layoutPath = APPLICATION_PATH "/views" resources.view.basePath = APPLICATION_PATH "/views" +; Scores configuration +profil.server.name = sdsrvdev01 +profil.webservice.location = local +profil.mail.method = smtp +profil.mail.smtp_host = smtp.free.fr +profil.mail.email.support = support@scores-decisions.com +profil.mail.email.supportdev = supportdev@scores-decisions.com +profil.path.data = "C:\Users\mricois\www\dataenrichissement" +profil.db.adapter=mysqli +profil.db.params.host=127.0.0.1 +profil.db.params.username=root +profil.db.params.password=bj10sx +profil.db.params.dbname=enrichissement +profil.db.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8" + [staging : production] resources.frontController.params.displayExceptions = 0 phpSettings.soap.wsdl_cache_enabled = 0 diff --git a/application/controllers/DoublonController.php b/application/controllers/DoublonController.php index a7ba46cc..dfd93aa9 100644 --- a/application/controllers/DoublonController.php +++ b/application/controllers/DoublonController.php @@ -20,8 +20,8 @@ class DoublonController extends Zend_Controller_Action $this->_helper->viewRenderer->setNoRender(true); $request = $this->getRequest(); - $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/configuration.ini', 'path'); - $path = realpath($config->data).'/doublon'; + $c = Zend_Registry::get('config'); + $path = realpath($c->profil->path->data).'/doublon'; if(!file_exists($path)) mkdir($path); if ( isset($_FILES) && count($_FILES)==1 ){ @@ -71,10 +71,10 @@ class DoublonController extends Zend_Controller_Action $request = $this->getRequest(); $file = $request->getParam('file'); - $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/configuration.ini', 'path'); + $c = Zend_Registry::get('config'); - $pathIn = $config->data.'/doublon'; - $pathOut = $config->data.'/doublon'; + $pathIn = $c->profil->path->data.'/doublon'; + $pathOut = $c->profil->path->data.'/doublon'; if(!file_exists($pathOut)) mkdir($pathOut); //Vérifier le format du fichier diff --git a/application/controllers/EnvoiController.php b/application/controllers/EnvoiController.php index c3399b40..84dcd65e 100644 --- a/application/controllers/EnvoiController.php +++ b/application/controllers/EnvoiController.php @@ -52,8 +52,8 @@ class EnvoiController extends Zend_Controller_Action } else { - $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/configuration.ini', 'path'); - $path = realpath($config->data).'/validation'; + $c = Zend_Registry::get('config'); + $path = realpath($c->profil->path->data).'/validation'; if(!file_exists($path)) mkdir($path); if ( isset($_FILES) && count($_FILES)==1 ){ @@ -104,10 +104,10 @@ class EnvoiController extends Zend_Controller_Action $request = $this->getRequest(); $file = $request->getParam('file'); - $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/configuration.ini', 'path'); + $c = Zend_Registry::get('config'); - $pathIn = $config->data.'/validation'; - $pathOut = $config->data.'/clients'; + $pathIn =$c->profil->path->data.'/validation'; + $pathOut = $c->profil->path->data.'/clients'; if(!file_exists($pathOut)) mkdir($pathOut); //Vérifier le format du fichier diff --git a/batch/cron.php b/batch/cron.php index 2b88da7e..1aedcf96 100644 --- a/batch/cron.php +++ b/batch/cron.php @@ -43,9 +43,9 @@ if(isset($opts->help)) exit; } -$dbConfig = new Zend_Config_Ini(APPLICATION_PATH . '/configs/configuration.ini', 'databases'); -$db = Zend_Db::factory($dbConfig->db); +$c = new Zend_Config($application->getOptions()); +$db = Zend_Db::factory($c->profil->db); $commandesM = new Application_Model_Commandes($db); $sql = $commandesM->select() @@ -55,7 +55,7 @@ $sql = $commandesM->select() $result = $commandesM->fetchAll($sql); if ( count($result)>0 ) { - + } else { @@ -71,5 +71,5 @@ if ( count($result)>0 ) { echo "Lancement enrichissement $info->id\n"; exec(realpath(dirname(__FILE__))."/enrichissement.php --id ".$info->id." &"); } - + } \ No newline at end of file diff --git a/batch/enrichissement.php b/batch/enrichissement.php index 911b4936..531647c0 100644 --- a/batch/enrichissement.php +++ b/batch/enrichissement.php @@ -242,9 +242,9 @@ $cache = Zend_Cache::factory('Core','Apc', $frontendOptions, $backendOptions); Zend_Db_Table_Abstract::setDefaultMetadataCache($cache); //Définition bdd local -$dbConfig = new Zend_Config_Ini(APPLICATION_PATH . '/configs/configuration.ini', 'databases'); +$c = new Zend_Config($application->getOptions()); try { - $db = Zend_Db::factory($dbConfig->db); + $db = Zend_Db::factory($c->profil->db); } catch ( Exception $e ) { exit ( $e->getMessage() ); } @@ -259,8 +259,7 @@ if ($opts->id) { $extension = strrchr($file,'.'); $file = str_replace($extension, '', $file); -$path = new Zend_Config_Ini(APPLICATION_PATH . '/configs/configuration.ini', 'path'); -if (!file_exists($path->data.'/export')) mkdir($path->data.'/export'); +if (!file_exists($c->profil->path->data.'/export')) mkdir($c->profil->path->data.'/export'); if ($opts->id) { $profilM = new Application_Model_Profil($db); @@ -307,7 +306,7 @@ $tabData = array(); $posKeySiren = $posKeySiret = $posKeyNic = false; //Fichier de définition -$inFile = $path->data.'/clients/'.$file.'.csv'; +$inFile = $c->profil->path->data.'/clients/'.$file.'.csv'; //Lire le fichier csv $row = 0; @@ -464,7 +463,7 @@ if (count($tabEntete)>0){ //Définition du fichier de sortie if ( $opts->reprise ) { - $outFile = $path->data.'/export/'.$commande->fichierOut; + $outFile = $c->profil->path->data.'/export/'.$commande->fichierOut; $rowReprise = 0; $fp = fopen($outFile, 'r+'); @@ -473,7 +472,7 @@ if ( $opts->reprise ) { } } else { - $outFile = $path->data.'/export/'.$file.'-'.date('YmdHis').'.csv'; + $outFile = $c->profil->path->data.'/export/'.$file.'-'.date('YmdHis').'.csv'; //Ecriture de l'entete du fichier $fp = fopen($outFile, 'w'); diff --git a/config/configure.php b/config/configure.php index 9732597a..41386801 100644 --- a/config/configure.php +++ b/config/configure.php @@ -58,18 +58,24 @@ function writeConfig() { global $hostname; + //Copie de la configuration + $configDir = realpath(dirname(__FILE__)).'/config'; + $appconfigDir = '../application/configs'; + $hostname = exec('echo $(hostname)'); + + passthru('cp -fv '. + $configDir.'/'.$hostname.'/application.ini' . ' ' . + $appconfigDir.'/application.ini'); + $arrayConfig = array( - 'mysql.php', - 'stockage.php', + 'mysql.php', + 'stockage.php', ); foreach($arrayConfig as $config) { passthru('cp -v '. realpath(dirname(__FILE__)).'/'.$hostname.'/'.$config.' ' . realpath(dirname(__FILE__)).'/'.$config); } - passthru('cp -v '. - realpath(dirname(__FILE__)).'/'.$hostname.'/configuration.ini'.' '. - realpath(dirname(__FILE__)).'/../application/configs/configuration.ini'); } diff --git a/config/local/application.ini b/config/local/application.ini new file mode 100644 index 00000000..e3422f87 --- /dev/null +++ b/config/local/application.ini @@ -0,0 +1,42 @@ +[production] +phpSettings.date.timezone = "Europe/Paris" +phpSettings.display_startup_errors = 0 +phpSettings.display_errors = 0 +bootstrap.path = APPLICATION_PATH "/Bootstrap.php" +bootstrap.class = "Bootstrap" +appnamespace = "Application" +resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" +resources.frontController.params.displayExceptions = 0 +autoloaderNamespaces[] = "Application_" +resources.layout.layout = "main" +resources.layout.layoutPath = APPLICATION_PATH "/views" +resources.view.basePath = APPLICATION_PATH "/views" + +; Scores configuration +profil.server.name = local +profil.webservice.location = local +profil.mail.method = smtp +profil.mail.smtp_host = smtp.free.fr +profil.mail.email.support = support@scores-decisions.com +profil.mail.email.supportdev = supportdev@scores-decisions.com +profil.path.data = "C:\Users\mricois\www\dataenrichissement" +profil.db.adapter=mysqli +profil.db.params.host=127.0.0.1 +profil.db.params.username=root +profil.db.params.password=password +profil.db.params.dbname=enrichissement +profil.db.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8" + +[staging : production] +resources.frontController.params.displayExceptions = 0 +phpSettings.soap.wsdl_cache_enabled = 0 + +[development : production] +phpSettings.display_startup_errors = 1 +phpSettings.display_errors = 1 +phpSettings.soap.wsdl_cache_enabled = 0 +resources.frontController.params.displayExceptions = 1 + +[testing : production] +phpSettings.display_startup_errors = 1 +phpSettings.display_errors = 1 \ No newline at end of file diff --git a/config/local/configuration.ini b/config/local/configuration.ini deleted file mode 100644 index f9a96336..00000000 --- a/config/local/configuration.ini +++ /dev/null @@ -1,22 +0,0 @@ -[server] -name = sdsrvdev01 - -[databases] -db.adapter=mysqli -db.params.host=127.0.0.1 -db.params.username=root -db.params.password=password -db.params.dbname=enrichissement -db.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8" - -[mail] -method = smtp -smpt_port = -smtp_host = smtp.free.fr -support = mricois@scores-decisions.com -supportdev = mricois@scores-decisions.com -contact = mricois@scores-decisions.com -production = mricois@scores-decisions.com - -[path] -data = "d:\www\dataenrichissement" diff --git a/config/sdsrvdev01/application.ini b/config/sdsrvdev01/application.ini new file mode 100644 index 00000000..335f0c1c --- /dev/null +++ b/config/sdsrvdev01/application.ini @@ -0,0 +1,42 @@ +[production] +phpSettings.date.timezone = "Europe/Paris" +phpSettings.display_startup_errors = 0 +phpSettings.display_errors = 0 +bootstrap.path = APPLICATION_PATH "/Bootstrap.php" +bootstrap.class = "Bootstrap" +appnamespace = "Application" +resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" +resources.frontController.params.displayExceptions = 0 +autoloaderNamespaces[] = "Application_" +resources.layout.layout = "main" +resources.layout.layoutPath = APPLICATION_PATH "/views" +resources.view.basePath = APPLICATION_PATH "/views" + +; Scores configuration +profil.server.name = sdsrvdev01 +profil.webservice.location = local +profil.mail.method = smtp +profil.mail.smtp_host = smtp.free.fr +profil.mail.email.support = support@scores-decisions.com +profil.mail.email.supportdev = supportdev@scores-decisions.com +profil.path.data = "/sites/dataenrichissement" +profil.db.adapter=mysqli +profil.db.params.host=127.0.0.1 +profil.db.params.username=enrichissement +profil.db.params.password=aY5EWvtMmXrqKwK8 +profil.db.params.dbname=enrichissement +profil.db.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8" + +[staging : production] +resources.frontController.params.displayExceptions = 0 +phpSettings.soap.wsdl_cache_enabled = 0 + +[development : production] +phpSettings.display_startup_errors = 1 +phpSettings.display_errors = 1 +phpSettings.soap.wsdl_cache_enabled = 0 +resources.frontController.params.displayExceptions = 1 + +[testing : production] +phpSettings.display_startup_errors = 1 +phpSettings.display_errors = 1 \ No newline at end of file diff --git a/config/sdsrvdev01/configuration.ini b/config/sdsrvdev01/configuration.ini deleted file mode 100644 index 21b28fcc..00000000 --- a/config/sdsrvdev01/configuration.ini +++ /dev/null @@ -1,22 +0,0 @@ -[server] -name = sdsrvdev01 - -[databases] -db.adapter=mysqli -db.params.host=127.0.0.1 -db.params.username=enrichissement -db.params.password=aY5EWvtMmXrqKwK8 -db.params.dbname=enrichissement -db.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8" - -[mail] -method = smtp -smpt_port = -smtp_host = smtp.free.fr -support = mricois@scores-decisions.com -supportdev = mricois@scores-decisions.com -contact = mricois@scores-decisions.com -production = mricois@scores-decisions.com - -[path] -data = "/sites/dataenrichissement"