private function __construct() { // Secure system folder if in production mode. if (DEV_MODE) { file_put_contents(ROOT_DIR . 'system/.htaccess', ''); } else { file_put_contents(ROOT_DIR . 'system/.htaccess', 'Deny from all'); } // Add instance model base class for retrieving settings, users. self::$model = new Model(); // Set session for helper if loaded. $session_name = Pep::get_setting('session_name'); if (!empty($session_name)) { session_name($session_name); session_start(); } // Set defaults. $controller = self::get_setting('default_controller'); $action = 'index'; $url = ''; // Get request and scripts urls. $request_url = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''; $script_url = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : ''; if ($request_url != $script_url) { // Trim url path of its slash. $url = trim(preg_replace('/' . str_replace('/', '\\/', str_replace('index.php', '', $script_url)) . '/', '', $request_url, 1), '/'); } // Remove string after possible question mark if (stripos($url, '?') > 0) { $url = substr($url, 0, stripos($url, '?')); } // Get url segments. $segments = explode('/', $url); // Attempt to get controller and action segments. if (isset($segments[0]) && $segments[0] != '') { $controller = $segments[0]; } if (isset($segments[1]) && $segments[1] != '') { $action = $segments[1]; } // Get controller. $path = APP_DIR . 'controllers/' . $controller . '.php'; if (file_exists($path)) { require_once $path; } else { $controller = self::get_setting('error_controller'); require_once APP_DIR . 'controllers/' . $controller . '.php'; } // Check for action. if (!method_exists($controller, $action)) { $controller = self::get_setting('error_controller'); require_once APP_DIR . 'controllers/' . $controller . '.php'; $action = 'index'; } // Create controller and call page. $obj = new $controller(); die(call_user_func_array(array($obj, $action), array_slice($segments, 2))); }
public function __construct() { parent::__construct(); // Load helpers in the constructor. $this->session = $this->load->helper('session'); $this->validate = $this->load->helper('validate'); $this->string = $this->load->helper('string'); // Load language. $this->lang = $this->load->lang(Pep::get_setting('language')); }
public function __construct() { $this->expires = time() + 60 * 60 * 24 * floatval(Pep::get_setting('cookie_expiration')); $this->key = Pep::get_setting('cookie_key'); $this->cookie_name = Pep::get_setting('cookie_name'); if (!isset($_COOKIE[$this->cookie_name])) { setcookie($this->cookie_name, $this->encrypt(array()), $this->expires, '/', '', false, true); } else { $saved = $_COOKIE[$this->cookie_name]; setcookie($this->cookie_name, $saved, $this->expires, '/', '', false, true); } $this->check_login(); }
private function render_view($data = null) { $language = Pep::get_setting('language'); if (!empty($language)) { $file = APP_DIR . 'languages/' . strtolower($language) . '.php'; if (file_exists($file)) { include $file; } else { Pep::show_error(sprintf('The language file %s.php does not exist.', $language)); } } if ($data) { extract($data); } if (file_exists($this->template)) { $minified = Pep::get_setting('minify'); $minified ? ob_start(array($this, 'minify')) : ob_start(); require $this->template; ob_end_flush(); } else { // No view exists at all. Pep::show_error(sprintf('The view file %s.php does not exist.', $this->view)); } }
<!DOCTYPE html> <html> <head> <title><?php echo $title; ?> </title> <meta name="description" content="<?php echo Pep::get_setting('site_description'); ?> " /> <meta name="keywords" content="<?php echo Pep::get_setting('site_keywords'); ?> " /> </head> <body> <?php if (DEV_MODE) { ?> <p>Dev mode is on.</p><?php } ?>