Example #1
0
    $db = new PDO("{$registry->db_type}:host={$registry->db_host};dbname={$registry->db_db}", $registry->db_user, $registry->db_pass);
} catch (Exception $e) {
    die("Could not connect to mysql database.\n<br />Error: " . $e->getMessage());
}
$registry->db = $db;
/**
 *  Load template/view object
 */
$template = new Template($registry);
$registry->template = $template;
$registry->template->overwrite = true;
/**
 *  Load smarty object
 */
require $registry->smarty_path;
$smarty = new Smarty();
$smarty->template_dir = site_path . 'v';
$smarty->compile_dir = site_path . 'v' . DIRSEP . 'smarty' . DIRSEP . 'compile';
$smarty->cache_dir = site_path . 'v' . DIRSEP . 'smarty' . DIRSEP . 'cache';
$smarty->config_dir = site_path . 'v' . DIRSEP . 'smarty' . DIRSEP . 'configs';
$registry->smarty = $smarty;
/**
 *  Load router
 */
$router = new Router($registry);
$registry->router = $router;
$router->setPath(site_path . 'c');
/**
 *  Launch the page 
 */
$router->delegate();
Example #2
0
define('SMARTY_PATH', LIBRARY_PATH . "smarty/libs/");
define('BASE_URL', dirname($_SERVER["SCRIPT_NAME"]));
define('LOGS_PATH', site_path . "logs" . DIRSEP);
$template_name = "poreklamim-2012";
$LIBRARY_PATH = LIBRARY_PATH;
$LOGS_PATH = LOGS_PATH;
$LOGS_SEVERITY = Logger::DEBUG;
require_once SMARTY_PATH . "SmartyBC.class.php";
$_SESSION['start_time'] = $start_time;
$log = new Logger(__FILE__);
$log->info("Log initialized.");
$registry = new Registry();
$router = new Router($registry);
$registry['router'] = $router;
$registry['log'] = $log;
$router->setPath(site_path . 'controllers');
class My_Security_Policy extends Smarty_Security
{
    // disable all PHP functions
    public $php_functions = array();
    // remove PHP tags
    public $php_handling = Smarty::PHP_REMOVE;
    // allow everthing as modifier
    public $modifiers = array();
    public $trusted_dir = array();
    public $allow_php_tag = true;
    public function __construct($smarty)
    {
        parent::__construct($smarty);
        $this->secure_dir[] = dirname(__FILE__);
    }
Example #3
0
<?php

date_default_timezone_set('Europe/Kiev');
//error_reporting (E_ALL);
//ini_set("display_startup_errors", "1");
//ini_set("display_errors", "1");
ini_set("always_populate_raw_post_data", "-1");
if (version_compare(phpversion(), '5.6.0', '<') == true) {
    exit('PHP5.6 or above');
}
// Константы:
define('DS', DIRECTORY_SEPARATOR);
// Узнаём путь до файлов сайта
define('SITEPATH', realpath(dirname(__FILE__) . DS . '..' . DS) . DS);
require_once SITEPATH . 'app' . DS . 'startup.php';
$router = new Router();
$router->setPath(SITEPATH . 'controllers');
$router->delegate();
Example #4
0
<?php

error_reporting(E_ALL);
include 'config.php';
$db = new PDO('pgsql:host=' . DB_HOST . ';port=' . DB_PORT . ';dbname=' . DB_NAME . ';user='******';password='******'core' . DS . 'core.php';
include SITE_PATH . DS . 'classes/dao' . DS . 'dao.inc.php';
Dao::setPdo($db);
$router = new Router();
$router->setPath(SITE_PATH . DS . 'controllers');
$router->start();
Example #5
0
    $path = explode('_', $className);
    $className = end($path);
    $countPath = count($path);
    if ($countPath == 1) {
        $file = SITE_PATH . 'System' . DS . $className . '.php';
    } elseif ($countPath == 2) {
        if ($path[0] == 'Db') {
            $file = SITE_PATH . 'System' . DS . 'Db' . DS . $className . '.php';
        } elseif ($path[0] == 'Model') {
            $file = SITE_PATH . 'Model' . DS . $className . '.php';
        }
    } elseif ($countPath == 4) {
        $file = SITE_PATH . 'Model' . DS . 'Db' . DS . 'Table' . DS . $className . '.php';
    }
    if (file_exists($file) == false) {
        return false;
    }
    include $file;
}
try {
    Registry::set('db', $db);
} catch (Exception $e) {
    echo $e->getMessage();
}
$router = new Router();
try {
    $router->setPath($site_path . 'Controller');
    $router->start();
} catch (Exception $e) {
    echo $e->getMessage();
}
Example #6
0
    define('DEVINFO', "<b>Development:</b> revision v" . VERSION);
}
// register class autoloader function
spl_autoload_register("ClassAutoloader");
// purge expired chart cache images
$cachedir = dir(CHART_CACHE);
while (($img = $cachedir->read()) !== false) {
    if ($img != "." && $img != ".." && substr($img, -4, 4) == ".png") {
        if (filemtime(CHART_CACHE . "/{$img}") < time() - CHART_CACHE_EXPIRE) {
            unlink(CHART_CACHE . "/{$img}");
        }
    }
}
// create router and run requested controller
$router = new Router();
$router->setPath(APP_PATH . "/controllers");
$router->loader();
/**
 * Class autoloader function saves having to manually include each class and model file.
 * 
 * @param string $class		- class or model
 * 
 * @return void
 */
function ClassAutoloader($class)
{
    foreach (array("classes", "models") as $dir) {
        if (file_exists(APP_PATH . "/{$dir}/{$class}.php")) {
            require_once APP_PATH . "/{$dir}/{$class}.php";
        }
    }
Example #7
0
$sitePath = realpath(dirname(__FILE__));
define('__SITE_PATH', $sitePath);
if (strpos(dirname(__FILE__), "/") === false) {
    $parts = explode("\\", dirname(__FILE__));
} else {
    $parts = explode("/", dirname(__FILE__));
}
define("__PROJECT_NAME", $parts[count($parts) - 1]);
require_once 'application/BaseController.php';
require_once 'application/BaseDataAccess.php';
require_once 'application/Config.php';
require_once 'application/Router.php';
require_once 'application/Template.php';
/**
 * __autoload
 * @param $className
 */
function __autoload($className)
{
    $filename = $className . '.php';
    $file = 'models/' . $filename;
    if (file_exists($file)) {
        include_once $file;
    }
}
// Database causing errors, we're going front end only from this point on
//$db = DB::getInstance();
$router = new Router(new Template());
$router->setPath('controllers');
$router->loader();