Upgrade LBCAlerte to version 3.3

Add upgrade script
This commit is contained in:
Jimmy Monin
2016-11-26 19:19:16 +01:00
parent a7c054b535
commit 58ffd500e6
89 changed files with 6436 additions and 758 deletions

View File

@ -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);
}