From e5185eb3c6d744cf228f6852ef5dcfbf359966a3 Mon Sep 17 00:00:00 2001 From: Albin Date: Sun, 7 Jan 2024 19:16:38 +0100 Subject: [PATCH] #1416 divers --- configs/application/config-test.php | 2 - configs/application/config.php.dist | 2 - configs/application/config.php.dist-docker | 2 - htdocs/include/prepend.inc.php | 57 ------------------- htdocs/pages/administration/configuration.php | 7 --- sources/Afup/Bootstrap/Http.php | 12 ++-- sources/Afup/Bootstrap/_Common.php | 9 +-- sources/Afup/Utils/SymfonyKernel.php | 4 +- 8 files changed, 11 insertions(+), 84 deletions(-) delete mode 100644 htdocs/include/prepend.inc.php diff --git a/configs/application/config-test.php b/configs/application/config-test.php index ca509720e..54b0ce7d5 100644 --- a/configs/application/config-test.php +++ b/configs/application/config-test.php @@ -5,8 +5,6 @@ $configuration['bdd']['mot_de_passe']='afup'; $configuration['web']['path']='/'; -$configuration['divers']['niveau_erreur']='32767'; -$configuration['divers']['afficher_erreurs']='1'; $configuration['mails']['serveur_smtp']='mailcatcher'; $configuration['mails']['email_expediteur']='bureau@afup.org'; $configuration['mails']['nom_expediteur']='Bureau AFUP'; diff --git a/configs/application/config.php.dist b/configs/application/config.php.dist index 6501fcb48..3ad132ac5 100644 --- a/configs/application/config.php.dist +++ b/configs/application/config.php.dist @@ -5,8 +5,6 @@ $configuration['bdd']['utilisateur']='afup_dev'; $configuration['bdd']['mot_de_passe']='p455w0rd'; $configuration['web']['path']='http://.dev/'; -$configuration['divers']['niveau_erreur']='6143'; -$configuration['divers']['afficher_erreurs']='1'; $configuration['mails']['serveur_smtp']=''; $configuration['mails']['email_expediteur']='bureau@afup.org'; $configuration['mails']['nom_expediteur']='Bureau AFUP'; diff --git a/configs/application/config.php.dist-docker b/configs/application/config.php.dist-docker index e95ac91fa..adb86be52 100644 --- a/configs/application/config.php.dist-docker +++ b/configs/application/config.php.dist-docker @@ -5,8 +5,6 @@ $configuration['bdd']['utilisateur']='afup'; $configuration['bdd']['mot_de_passe']='afup'; $configuration['web']['path']='/'; -$configuration['divers']['niveau_erreur']='6143'; -$configuration['divers']['afficher_erreurs']='1'; $configuration['mails']['serveur_smtp']='mailcatcher'; $configuration['mails']['email_expediteur']='bureau@afup.org'; $configuration['mails']['nom_expediteur']='Bureau AFUP'; diff --git a/htdocs/include/prepend.inc.php b/htdocs/include/prepend.inc.php deleted file mode 100644 index ef8c2170a..000000000 --- a/htdocs/include/prepend.inc.php +++ /dev/null @@ -1,57 +0,0 @@ -obtenir('divers|niveau_erreur')); -ini_set('display_errors', $conf->obtenir('divers|afficher_erreurs')); -ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . dirname(__FILE__).'/../../dependencies/PEAR/' . PATH_SEPARATOR . dirname(__FILE__).'/../../dependencies/'); -header('Content-type: text/html; charset=UTF-8'); - -// On détermine sur quel sous-site on est -$serveur = ""; -$url = $_SERVER['REQUEST_URI']; -if (strrpos($url, '?') !== false) { - $position = strrpos($url, '?'); - $url = substr($url, 0, $position); -} -$position = strrpos($url, '/'); -$url = substr($_SERVER['REQUEST_URI'], 0, $position); -$parties = explode('/', $url); -$sous_site = array_pop($parties); -if (empty($sous_site) and strpos($_SERVER['HTTP_HOST'], "planete") !== false) { - $sous_site = "planete"; - $serveur = "https://afup.org"; -} - -// Initialisation de Smarty -$smarty = new Smarty; -$smarty->template_dir = array(dirname(__FILE__).'/../../htdocs/templates/' . $sous_site . '/', - dirname(__FILE__).'/../../htdocs/templates/commun/'); -$smarty->compile_dir = dirname(__FILE__).'/../../htdocs/cache/templates'; -$smarty->compile_id = $sous_site; -$smarty->use_sub_dirs = true; -$smarty->compile_check = true; -$smarty->php_handling = SMARTY_PHP_ALLOW; -$smarty->assign('url_base', 'http://' . $_SERVER['HTTP_HOST'] . '/'); -$smarty->assign('chemin_template', $serveur.$conf->obtenir('web|path').'templates/' . $sous_site . '/'); -$smarty->assign('chemin_javascript', $serveur.$conf->obtenir('web|path').'javascript/'); - -// Initialisation de la couche d'abstraction de la base de données -$bdd = new \Afup\Site\Utils\Base_De_Donnees($conf->obtenir('bdd|hote'), - $conf->obtenir('bdd|base'), - $conf->obtenir('bdd|utilisateur'), - $conf->obtenir('bdd|mot_de_passe')); -$bdd->executer("SET NAMES 'utf8'"); - -require_once(dirname(__FILE__) . '/../../sources/Afup/Bootstrap/commonStart.php'); diff --git a/htdocs/pages/administration/configuration.php b/htdocs/pages/administration/configuration.php index d42d5cce3..a1488c4c0 100644 --- a/htdocs/pages/administration/configuration.php +++ b/htdocs/pages/administration/configuration.php @@ -45,13 +45,6 @@ $formulaire->addElement('header' , '' , 'Planète PHP FR'); $formulaire->addElement('textarea', 'planete|pertinence' , 'Critère de pertinence', array('cols' => 42, 'rows' => 7)); -$formulaire->addElement('header' , '' , 'Divers'); -$formulaire->addElement('select' , 'divers|niveau_erreur' , 'Niveau erreur' , array(E_ALL => 'Toutes', - E_NOTICE => 'Informations', - E_WARNING => 'Avertissements', - 0 => 'Aucune')); -$formulaire->addElement('advcheckbox', 'divers|afficher_erreurs', 'Afficher erreurs', null, null, array(0, 1)); - $formulaire->addElement('header', 'boutons' , ''); $formulaire->addElement('submit', 'soumettre', 'Enregistrer'); diff --git a/sources/Afup/Bootstrap/Http.php b/sources/Afup/Bootstrap/Http.php index 696d3fc03..7f7b961ef 100644 --- a/sources/Afup/Bootstrap/Http.php +++ b/sources/Afup/Bootstrap/Http.php @@ -30,10 +30,14 @@ session_start(); } -// mise à jour des paramètrage PHP en fonction de la configuration - -ini_set('error_reporting', $GLOBALS['AFUP_CONF']->obtenir('divers|niveau_erreur')); -ini_set('display_errors', $GLOBALS['AFUP_CONF']->obtenir('divers|afficher_erreurs')); +// mise à jour des paramétrages PHP en fonction de la configuration +if ($_ENV['SYMFONY_ENV'] === 'dev') { + ini_set('error_reporting', E_ALL); + ini_set('display_errors', 1); +} else { + ini_set('error_reporting', E_ALL ^ E_WARNING); + ini_set('display_errors', 0); +} ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . dirname(__FILE__).'/../../../dependencies/PEAR/'); header('Content-type: text/html; charset=UTF-8'); diff --git a/sources/Afup/Bootstrap/_Common.php b/sources/Afup/Bootstrap/_Common.php index 3e9c15255..42d6926c7 100644 --- a/sources/Afup/Bootstrap/_Common.php +++ b/sources/Afup/Bootstrap/_Common.php @@ -18,7 +18,7 @@ // racine de l'application (pas du document root !) -use Afup\Site\Utils\Base_De_Donnees; +use Afup\Site\Corporate\_Site_Base_De_Donnees; use Afup\Site\Utils\Configuration; $root = realpath(dirname(__FILE__) . '/../../..'); @@ -67,12 +67,7 @@ // initialisation de la couche d'abstraction de la base de données -$bdd = new Base_De_Donnees( - $conf->obtenir('bdd|hote'), - $conf->obtenir('bdd|base'), - $conf->obtenir('bdd|utilisateur'), - $conf->obtenir('bdd|mot_de_passe') -); +$bdd = new _Site_Base_De_Donnees(); // mets la connexion db dans une 'clé de registre' accessible à tout moment diff --git a/sources/Afup/Utils/SymfonyKernel.php b/sources/Afup/Utils/SymfonyKernel.php index ef958771d..20e8f5352 100644 --- a/sources/Afup/Utils/SymfonyKernel.php +++ b/sources/Afup/Utils/SymfonyKernel.php @@ -21,9 +21,7 @@ public function __construct(Request $request = null) $env = 'prod'; $debug = false; - $configuration = $this->getLegacyConfig(); - - if ($configuration['divers']['afficher_erreurs']) { + if ($_ENV['SYMFONY_ENV'] === 'dev') { Debug::enable(E_WARNING); $debug = true; $env = 'dev';