You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

76 lines
2.1 KiB

<?php
require_once('inc/exceptions.php');
require_once('inc/config.php');
require_once('inc/database.php');
require_once('inc/rain.tpl.php');
require_once('inc/sql_types.php');
require_once('inc/mvc.php');
require_once('inc/module.php');
require_once('inc/csrf.php');
require_once('inc/parser.php');
ob_start();
/* on restaure les objets de la session */
module::load_data();
if(php_sapi_name() != 'cli') {
/* on charge la session */
ini_set('session.name', config::read_config('session', 'cookie_name'));
ini_set('session.hash_function', 1 /* SHA-1 */);
ini_set('session.cookie_httponly', 1);
session_start();
}
/* connexion à la base de données */
try {
$database = new database();
$database->connect(config::read_config('database', 'url'), config::read_config('database', 'login'), config::read_config('database', 'password'));
} catch(PDOException $e) {
die('PDOException : '.$e->getMessage());
} catch(config_section_not_found $e) {
die('config_section_not_found');
} catch(config_key_not_found $e) {
die('config_key_not_found');
} catch(Exception $e) {
die('erreur :'.$e.getMessage());
}
/* la libtpl */
$tpl = new raintpl();
raintpl::configure( 'tpl_dir', '' );
raintpl::configure( 'base_url', config::read_config('general', 'base_url').config::read_config('general', 'base_dir'));
/* on charge le module demandé */
$params = array();
$var_get;
if(php_sapi_name() != 'cli') {
$var_get = &$_GET;
$params['cli'] = false;
} else {
$var_get = getopt('', array('install', 'uninstall','action:','module:'));
$params['cli'] = true;
}
if(isset($var_get['module']))
$params['module'] = $var_get['module'];
else
die('You must specify a module');
$params['action'] = isset($var_get['action'])?$var_get['action']:null;
$params['install'] = isset($var_get['install']);
$params['uninstall'] = isset($var_get['uninstall']);
try {
module::main($params, $database, $tpl);
} catch(module_not_found $e) {
die('Module "'.$var_get['module'].'" does not exist');
}
/*
catch(Exception $e) {
die('erreur');
}
*/
if(php_sapi_name() != 'cli') {
echo '<br />Debug : <pre>';
print_r($_SESSION);
echo '</pre>';
}
ob_end_flush();