Exemple #1
0
Opl_Loader::loadPaths($config);
Opl_Loader::setCheckFileExists(false);
Opl_Loader::register();
Opl_Registry::setState('opl_extended_errors', true);
if (!file_exists('./config.php')) {
    die('Please create the config.php file from config.sample.php!');
}
require './config.php';
require './includes/forms.php';
require './components/base.php';
require './components/input.php';
require './components/textarea.php';
try {
    $tpl = new Opt_Class();
    // Load the configuration
    $tpl->loadConfig($config['opt']);
    // Register the components
    $tpl->register(Opt_Class::OPT_COMPONENT, 'opt:input', 'InputComponent');
    $tpl->register(Opt_Class::OPT_COMPONENT, 'opt:textarea', 'TextareaComponent');
    $tpl->setup();
    Opt_View::assignGlobal('baseHref', $config['script']['baseHref']);
    // Connect to the database.
    $pdo = new PDO($config['db']['dsn'], $config['db']['user'], $config['db']['password']);
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $pdo->query('SET NAMES `' . $config['db']['charset'] . '`');
    // Load and execute the action.
    $action = 'list';
    if (isset($_GET['action']) && ctype_alpha($_GET['action'])) {
        $action = $_GET['action'];
    }
    require './actions/' . $action . '.php';