示例#1
0
<?php

define('SQL_DSN', 'mysql:host=127.0.0.1;dbname=lord_agenda;charset=utf8');
define('SQL_USERNAME', 'root');
define('SQL_PASSWORD', '');
require_once 'global/utils.php';
require_once 'models/base.php';
$db = new PDO(SQL_DSN, SQL_USERNAME, SQL_PASSWORD);
Model_Base::set_db($db);
session_set_cookie_params(6000, '/', '', false, true);
session_start();
date_default_timezone_set('Europe/Paris');
define('BASEURL', dirname($_SERVER['SCRIPT_NAME']));
define('DIR', base_url());
ob_start();
if (isset($_SERVER['PATH_INFO'])) {
    $args = explode('/', $_SERVER['PATH_INFO']);
    $found = false;
    if (count($args) >= 3) {
        $controller = $args[1];
        $method = $args[2];
        $params = array();
        for ($i = 3; $i < count($args); $i++) {
            $params[] = $args[$i];
        }
        $controller_file = dirname(__FILE__) . '/controllers/' . $controller . '.php';
        if (is_file($controller_file)) {
            require_once $controller_file;
            $controller_name = 'Controller_' . ucfirst($controller);
            if (class_exists($controller_name)) {
                $c = new $controller_name();