public function check_admin_password() { $unique = ''; $password = $_POST['admin_password']; if (Config::get('admin', 'hash') !== SecureHash::hash(Config::get('admin', 'hash_type'), $password, $unique, false)) { $this->redirect('home'); } }
public static function getInstance($cacheDriver = NULL) { if (!$cacheDriver) { $cacheDriver = Config::get('cache', 'default') ? Config::get('cache', 'default') : 'none'; } $driver = 'miranda\\cache\\drivers\\' . ucfirst($cacheDriver) . 'Driver'; if (!isset($instances[$cacheDriver])) { $instances[$cacheDriver] = new $driver(); } return $instances[$cacheDriver]; }
public static function add($key, $value, $expire = 0, $closure = NULL, $driver = NULL) { if (!$driver) { $driver = Config::get('cache', 'default') ? Config::get('cache', 'default') : 'none'; } if (!($engine = CacheFactory::getInstance($driver))) { return false; } if ($value) { return $engine->add($key, $value, $expire); } else { if (is_callable($closure)) { $engine->add($key, $value = $closure(), $expire); return $value; } } return false; }
public function form_token() { $token = SecureHash::hash('sha256', uniqid(mt_rand(10000, 99999), true), Config::get('namespace', 'base'), false); if (isset($this->session)) { $this->session->miranda_form_token = $token; } else { setcookie('miranda_form_token', $token, 0, Config::get('cookies', 'path'), Config::get('cookies', 'domain'), false, true); } return $token; }
function link_to($location, $display) { return '<a href="' . Config::get('site', 'base') . $location . '">' . $display . '</a>'; }
public function query() { $arguments = func_get_args(); $start = microtime(true); $result = call_user_func_array(array($this, 'parent::query'), $arguments); $end = microtime(true); if (Config::get('database', 'log_queries')) { SystemLogger::log_to_file('query.log', $arguments[0]); } if (!$result) { $error_information = $this->errorInfo(); SystemLogger::log_event(4, 'Query execution failed with message: ' . $error_information[2]); } $total_time = $end - $start; if (Config::get('database', 'log_slow_queries') && $total_time > (double) Config::get('database', 'slow_query_time')) { SystemLogger::log_event(5, 'Query containing: ' . $arguments[0] . ' took ' . $total_time . ' seconds to execute.'); } }
public function permanent_redirect($location) { header('Location: ' . Config::get('site', 'base') . $location, true, 301); exit; }
protected static function action($action, $params, $request, $cache = false) { list($controller, $function) = explode('#', $action); $controller = Config::get('namespace', 'controllers') . ucfirst($controller); $controller = $controller::getInstance(); $controller->controller_setup($params); if ($cache) { /** Cache the route, action and params for faster processing */ $cache = CacheFactory::getInstance(); array_unshift($params, $action); $cache->set('routes_' . md5($request->path), $params, 0); } $controller->execute_before($function); $controller->{$function}(); $controller->execute_after($function); }
public function escape() { foreach ($this->values as $key => $value) { if (is_string($value)) { $this->values[$key] = htmlentities($value, ENT_QUOTES, Config::get('site', 'charset')); } } return $this; }