public static function run() { $route_found = false; foreach (self::$routes as $route) { if (app\config::get('basepath')) { $route['expression'] = rtrim(app\config::get('basepath') . DIRECTORY_SEPARATOR . $route['expression'], '/'); } //Add 'find string start' automatically $route['expression'] = '^' . $route['expression']; //Add 'find string end' automatically $route['expression'] = $route['expression'] . '$'; //check match if (preg_match('#' . $route['expression'] . '#', self::$path, $matches)) { array_shift($matches); //Always remove first element. This contains the whole string call_user_func_array($route['function'], $matches); $route_found = true; } //echo $route['expression'].'<br />'; } if (!$route_found) { foreach (self::$routes404 as $route404) { call_user_func_array($route404, array(self::$path)); } } }
public function getCells($table) { $query = 'SELECT COLUMN_NAME '; $query .= 'FROM INFORMATION_SCHEMA.COLUMNS '; $query .= 'WHERE TABLE_SCHEMA=\'' . app\config::get('dbname') . '\' '; $query .= 'AND TABLE_NAME=\'' . $table . '\';'; return $this->sql_getVals($query); }
function loadClass($classname) { $classname = str_replace('\\', DIRECTORY_SEPARATOR, $classname); if (file_exists(__DIR__ . config::get('classroot') . $classname . '.php')) { include __DIR__ . config::get('classroot') . $classname . '.php'; } else { echo __DIR__ . config::get('classroot') . $classname . '.php'; throw new Exception('Can\'t find file to include. /index.php/loadClass(\'' . $classname . '\')'); } }
public static function start_session() { $secure = config::get('environment') === 'deveop' ? FALSE : TRUE; $httponly = config::get('environment') === 'deveop' ? FALSE : TRUE; if (ini_set('session.use_only_cookies', 1) === FALSE) { header("Location: ../login?message=cookies"); exit; } $cookieParams = session_get_cookie_params(); session_set_cookie_params($cookieParams["lifetime"], $cookieParams["path"], $cookieParams["domain"], $secure, $httponly); session_name(config::get('session_name')); session_start(); // Startet die PHP-Sitzung session_regenerate_id(); }
/** * */ private function setFromPost() { //$this->uid = app\config::getPostVal('user_name') == null ? $this->uid : app\config::getPostVal('user_name'); $this->uname = app\config::getPostVal('user_name') == null ? $this->uname : app\config::getPostVal('user_name'); $this->umail = app\config::getPostVal('user_email') == null ? $his->umail : app\config::getPostVal('user_email'); $this->upw = app\config::getPostVal('user_password') == null ? $this->upw : app\config::getPostVal('user_password'); }
<?php namespace snowcms; use snowcms; config::set('basepath', 'snowcms'); config::set('classroot', '/src/'); config::set('ctrlroot', '/src/ctrl/'); config::set('viewroot', '/src/views/'); // Database-Parameters config::set('dbtype', 'mysql'); config::set('dbhost', 'localhost'); config::set('dbport', 3306); //not implemented... config::set('dbname', 'snowcms'); config::set('dbuser', ''); config::set('dbpw', ''); // Session-Config config::set('session_name', 'snowcms'); config::set('authtype', 'db'); config::set('environment', 'develop'); config::set('page_base', 'Location: ../ index.php');