mirror of
https://github.com/ZeJMaN/LBCAlerte_ynh.git
synced 2025-07-26 05:10:49 +02:00
Upgrade LBCAlerte to version 3.3
Add upgrade script
This commit is contained in:
@ -10,6 +10,10 @@ defined("APPLICATION_ENV")
|
||||
// Define application environment
|
||||
define("APPLICATION_VERSION", require DOCUMENT_ROOT."/version.php");
|
||||
|
||||
// Constante utilisée pour forcer le navigateur à télécharger
|
||||
// les fichiers statiques (js, css, html, etc)
|
||||
define("STATIC_REV", 10);
|
||||
|
||||
set_include_path(
|
||||
__DIR__."/lib".PATH_SEPARATOR.get_include_path()
|
||||
);
|
||||
@ -62,7 +66,7 @@ class Bootstrap
|
||||
{
|
||||
Logger::configure(array(
|
||||
"rootLogger" => array(
|
||||
"appenders" => array("default"),
|
||||
"appenders" => array("default", "error"),
|
||||
"level" => APPLICATION_ENV == "development"?"debug":"info"
|
||||
),
|
||||
"appenders" => array(
|
||||
@ -76,9 +80,26 @@ class Bootstrap
|
||||
),
|
||||
"params" => array(
|
||||
"file" => DOCUMENT_ROOT."/var/log/info.log",
|
||||
"maxFileSize" => APPLICATION_ENV == "development"?"20MB":"3MB",
|
||||
"maxBackupIndex" => 5,
|
||||
"append" => true,
|
||||
"threshold" => "all",
|
||||
)
|
||||
),
|
||||
"error" => array(
|
||||
"class" => "LoggerAppenderRollingFile",
|
||||
"layout" => array(
|
||||
"class" => "LoggerLayoutPattern",
|
||||
"params" => array(
|
||||
"conversionPattern" => "%date %-5level %msg%n"
|
||||
)
|
||||
),
|
||||
"params" => array(
|
||||
"file" => DOCUMENT_ROOT."/var/log/error.log",
|
||||
"maxFileSize" => "3MB",
|
||||
"maxBackupIndex" => 5,
|
||||
"append" => true
|
||||
"append" => true,
|
||||
"threshold" => "error",
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -152,6 +173,11 @@ class Bootstrap
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
set_exception_handler(array($this, "_exceptionHandler"));
|
||||
set_error_handler(
|
||||
array($this, "_errorHandler"),
|
||||
E_ERROR | E_WARNING | E_USER_ERROR | E_USER_WARNING
|
||||
);
|
||||
}
|
||||
|
||||
public function bootstrap(Config_Lite $config)
|
||||
@ -163,6 +189,62 @@ class Bootstrap
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function _exceptionHandler($e)
|
||||
{
|
||||
Logger::getLogger("main")->error(
|
||||
get_class($e)." : #".
|
||||
$e->getCode()." ".
|
||||
$e->getMessage()." (".$e->getFile().":".$e->getLine().")"
|
||||
);
|
||||
|
||||
if ("development" == APPLICATION_ENV) {
|
||||
var_dump($e);
|
||||
return;
|
||||
}
|
||||
|
||||
die("Un problème est survenu lors de l'exécution du programme.\n");
|
||||
}
|
||||
|
||||
public function _errorHandler($errno, $errstr, $errfile, $errline)
|
||||
{
|
||||
$display_errors = ini_get("display_errors");
|
||||
if ($display_errors || "development" == APPLICATION_ENV) {
|
||||
var_dump($display_errors,$errno, $errstr, $errfile, $errline);
|
||||
return false;
|
||||
}
|
||||
|
||||
switch ($errno) {
|
||||
case E_NOTICE:
|
||||
$errno_const = "E_NOTICE";
|
||||
break;
|
||||
case E_ERROR:
|
||||
$errno_const = "E_ERROR";
|
||||
break;
|
||||
case E_USER_ERROR:
|
||||
$errno_const = "E_USER_ERROR";
|
||||
break;
|
||||
case E_WARNING:
|
||||
$errno_const = "E_WARNING";
|
||||
break;
|
||||
case E_USER_WARNING:
|
||||
$errno_const = "E_USER_WARNING";
|
||||
break;
|
||||
default:
|
||||
$errno_const = $errno;
|
||||
}
|
||||
|
||||
Logger::getLogger("main")->error(
|
||||
$errno_const." ".$errstr." (".$errfile.":".$errline.")"
|
||||
);
|
||||
|
||||
// Pour les ERROR, on stoppe l'exécution du script
|
||||
if ($errno == E_ERROR || $errno == E_USER_ERROR) {
|
||||
die("Un problème est survenu lors de l'exécution du programme.\n");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
$config = new Config_Lite(DOCUMENT_ROOT."/var/config.ini");
|
||||
@ -182,7 +264,22 @@ if ("db" == $config->get("storage", "type", "files")) {
|
||||
"password" => "",
|
||||
"dbname" => ""
|
||||
), $config->get("storage", "options"));
|
||||
$dbConnection = new mysqli($options["host"], $options["user"],
|
||||
$options["password"], $options["dbname"]);
|
||||
$dbConnection = new mysqli(
|
||||
$options["host"],
|
||||
$options["user"],
|
||||
$options["password"],
|
||||
$options["dbname"]
|
||||
);
|
||||
if ($dbConnection->connect_error) {
|
||||
Logger::getLogger("main")->error(
|
||||
"Connexion à la base de données échouée : ".
|
||||
$dbConnection->connect_error
|
||||
);
|
||||
echo "Un problème est survenu lors de la génération de la page.";
|
||||
exit;
|
||||
}
|
||||
$driver = new mysqli_driver();
|
||||
$driver->report_mode = MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT;
|
||||
$dbConnection->set_charset("utf8");
|
||||
unset($options);
|
||||
}
|
||||
|
Reference in New Issue
Block a user