function _route() { // do for exception url self::_exception(); // check permission self::_permission(); // Restrict unwanted module if (!$this->cpModlueList()) { \lib\error::page(T_("Not found!")); } // Restrict unwanted child // if($mychild && !($mychild=='add' || $mychild=='edit' || $mychild=='delete' || $mychild=='list' || $mychild=='options')) // \lib\error::page(T_("Not found!")); $this->cpFindDisplay(); }
/** * return list of posts in custom term like cat or tag * @return [type] datarow */ public function sp_postsInTerm($_limit = null) { $url = $this->url('path'); if (substr($url, 0, 4) === 'tag/') { $url = substr($url, 4, $url); } if (substr($url, 0, 11) === 'book-index/') { preg_match("#^book-index/([^\\/]*)(.*)\$#", $url, $m); $url_raw = "book/{$m['1']}"; if ($m[2] !== '') { $qry = $this->sql()->table('posts')->where('post_status', 'publish')->order('id', 'ASC'); $qry->join('termusages')->on('termusage_id', '#posts.id')->and('termusage_foreign', '#"posts"'); $qry->join('terms')->on('id', '#termusages.term_id')->and('term_url', $url)->groupby('#posts.id'); } else { $parent_id = $this->sql()->table('posts')->where('post_url', $url_raw)->and('post_status', 'publish')->select()->assoc('id'); $qry = $this->sql()->table('posts')->where('post_parent', $parent_id)->and('post_status', 'publish')->order('id', 'ASC'); } return $qry->select()->allassoc(); } $qry = $this->sql()->table('posts')->where('post_status', 'publish')->order('id', 'DESC'); $qry->join('termusages')->on('termusage_id', '#posts.id')->and('termusage_foreign', '#"posts"')->field(false); $qry->join('terms')->on('id', '#termusages.term_id')->and('term_url', $url)->groupby('#posts.id')->field(false); // hasan :| $pagenation = []; if ($_limit) { $qryCount = clone $qry; $qryCount->field("#count(posts.id)"); $count = $qryCount->select()->num(); $pagenationPages = ceil($count / $_limit); $pagenationCurrent = \lib\router::get_storage("pagenation"); $pagenationNext = \lib\router::get_storage("pagenation") + 1; $pagenationPrev = \lib\router::get_storage("pagenation") - 1; if ($pagenationCurrent !== null and $pagenationCurrent < 1 || $pagenationCurrent > $pagenationPages) { \lib\error::page(T_("Does not exist!")); return; } $pagenation = ["num_page" => $pagenationPages, "pages" => intval($pagenationPages), "current" => $pagenationCurrent == 0 ? 1 : intval($pagenationCurrent), "next" => $pagenationNext <= $pagenationPages ? $pagenationNext : false, "prev" => $pagenationPrev >= 1 ? $pagenationPrev : false, "count_link" => 7, "current_url" => \lib\router::get_url()]; $start = \lib\router::get_storage("pagenation") ? (\lib\router::get_storage("pagenation") - 1) * $_limit : 0; $qry->limit($start, $_limit); } return ["pagenation" => $pagenation, "result" => $qry->select()->allassoc()]; }
function __call($name, $args) { $remove = array("table", "select", "update", "insert", "delete", "form", "join"); if (isset($this->subClass) && preg_grep("/^" . $name . "\$/", $remove)) { \lib\error::page("joinMaker method {$sCaller} not found"); } preg_match("/^([a-z]+)([A-Z].*)?\$/", $name, $caller); switch ($caller[1]) { case 'where': case 'if': case 'and': case 'or': case 'like': case 'orlike': case 'andlike': case 'on': $sCaller = 'conditionsCaller'; array_unshift($args, $caller[1]); break; case 'selects': $sCaller = 'selectCaller'; break; case 'update': case 'insert': case 'delete': case 'select': case 'show': $sCaller = 'syntaxCaller'; array_unshift($args, $caller[1]); break; default: $sCaller = $caller[1] . 'Caller'; break; } $sName = isset($caller[2]) ? strtolower($caller[2]) : null; if (!method_exists($this, $sCaller)) { \lib\error::page("maker method {$sCaller} not found"); } $ret = $this->{$sCaller}($sName, $args); return $ret === null ? $this : $ret; }
/** * optimize sql table, fields and value * @param [string] $table [set table name] * @param [string] $field [set field name] * @param [string] $value [set value] * @return [string] [optimize of string] * @example * oSting(users) return #users# * oSting(users, id) return #users.id# * oSting(users, id, 150) return #users.id 150# */ public function oString($table, $field = null, $value = null, $checkCondition = true) { if ($value !== null) { $cInt = false; // for insert or update multiple row if (is_array($value)) { } elseif (preg_match("/^#(.*)\$/", $value, $v)) { $value = $v[1]; $cInt = true; } elseif (substr($value, 0, 1) == '#') { $value = substr($value, 1); $cInt = true; } else { $sTable = "get" . ucfirst(dbconnection::get_db_name()); $cTable = sql\table::$sTable($table); if (isset($cTable->{$field})) { $type = $cTable->{$field}->type; $int = array("int", "tinyint", "smallint", "decimal"); preg_match("/^([^@]*)@/", $type, $tp); if (preg_grep("/^" . $tp[1] . "\$/", $int)) { $cInt = true; } if ($this->auto_validate) { $status = $this->auto_validate($field, $cTable->{$field}, $value); if (!is_bool($status)) { \lib\debug::error($status, $field, 'form'); } } } if (isset($cTable->{$field}->closure) && $checkCondition) { $gTable = $cTable->{$field}->closure; $value = preg_replace("/^\\\\#/", "#", $value); $v = new validator(array($field, $value), $gTable->validate, 'form'); $value = $v->compile(); $value = $value == '' && is_string($value) && $value === false ? "NULL" : $value; } // switch by type of field and encode data if needed // var_dump($cTable->$field->type); if (isset($cTable->{$field}->type)) { $atPos = strpos($cTable->{$field}->type, '@'); } else { // return false; \lib\error::page("Field {$field} does not exist!"); } if ($atPos !== false) { switch (substr($cTable->{$field}->type, 0, $atPos)) { // if the type of field is int do nothing case 'tinyint': case 'smallint': case 'mediumint': case 'int': case 'bigint': case 'decimal': case 'float': break; // else doing entities // else doing entities case 'tinytext': case 'text': case 'mediumtext': case 'longtext': default: // if does not contain meta doing nothing and encode value if (strpos($field, '_meta') === false) { $value = htmlentities($value, ENT_QUOTES, "UTF-8"); } break; } } // if(!$cInt) // { // $value = htmlentities($value, ENT_QUOTES, "UTF-8"); // } } if (is_array($value)) { $optimize = $value; } else { $optimize = $cInt ? "{$value}" : "'{$value}'"; } } else { $optimize = "`{$table}`"; if ($field) { if (preg_match("/^#/", $field)) { $optimize = preg_replace("/^#/", "", $field); } else { // $optimize .= $field ? ($field === "*") ? ".$field" : ".`$field`" : ""; if ($field) { if ($field === "*") { $optimize .= ".{$field}"; } else { $optimize .= ".`{$field}`"; } } else { $optimize .= ""; } } } } return $optimize; }
public function loadController() { /** * find controller; */ $url_property = router::get_url_property(-1); $myrep = router::get_repository_name(); if (!router::get_controller()) { $controller_name = '\\' . $myrep . '\\' . router::get_class() . '\\' . router::get_method() . '\\controller'; $prv_class = router::get_class(); // var_dump($controller_name); if (!class_exists($controller_name)) { if ((!isset($url_property[1]) || $url_property[1] != router::get_method()) && router::get_method() != 'home') { router::add_url_property(router::get_method()); } $prv_method = router::get_method(); router::set_method('home'); $controller_name = '\\' . $myrep . '\\' . router::get_class() . '\\' . router::get_method() . '\\controller'; // var_dump(router::get_url_property(-1)); // var_dump($controller_name); if (!class_exists($controller_name)) { router::set_class($prv_class); $controller_name = '\\' . $myrep . '\\' . router::get_class() . '\\controller'; // var_dump(router::get_url_property(-1)); // var_dump($controller_name); if (!class_exists($controller_name)) { if ((!isset($url_property[0]) || $url_property[0] != router::get_class()) && router::get_class() != 'home') { router::add_url_property(router::get_class()); } router::set_class('home'); $controller_name = '\\' . $myrep . '\\' . router::get_class() . '\\' . router::get_method() . '\\controller'; // var_dump(router::get_url_property(-1)); // var_dump($controller_name); // if (!class_exists($controller_name)) { router::set_class('home'); $controller_name = '\\' . $myrep . '\\' . router::get_class() . '\\controller'; // var_dump(router::get_url_property(-1)); // $controller_name='\account\home\controller'; // var_dump($controller_name); if (!class_exists($controller_name)) { \lib\error::page("content not found"); } } } } } } else { $controller_name = router::get_controller(); } router::set_controller($controller_name); if (!class_exists($controller_name)) { error::page($controller_name); } $controller = new $controller_name(); self::$controller = $controller; // running template base module for homepage if (\lib\router::get_storage('CMS') && $myrep == 'content' && method_exists($controller, 's_template_finder')) { $controller->s_template_finder(); } if (method_exists($controller, '_route')) { $controller->_route(); } if (router::get_controller() !== $controller_name) { $this->loadController(); return; } if (method_exists($controller, 'config')) { $controller->config(); } if (method_exists($controller, 'options')) { $controller->options(); } if (count(router::get_url_property(-1)) > 0 && $controller->route_check_true === false) { error::page('Unavailable'); } $controller->_corridor(); }
public function __call($name, $args) { if (preg_grep("/^{$name}\$/", array('get', 'post', 'put', 'delete'))) { array_unshift($args, $name); return call_user_func_array(array($this, 'check_api'), $args); } elseif (method_exists('\\lib\\router', $name)) { return call_user_func_array('\\lib\\router::' . $name, $args); } \lib\error::page(get_called_class() . "->{$name}()"); }
/** * check route of account * @return [type] [description] */ function _route() { // exit(); // \lib\debug::true("check", 'hi'); // var_dump(); $mymodule = $this->module(); $referer = \lib\router::urlParser('referer', 'domain'); $from = \lib\utility\cookie::read('from'); $from = $from ? $from : \lib\utility::get('from'); $islogin = $this->login(); // set referrer in cookie if ($referer !== Domain) { \lib\utility\cookie::write('referer', $referer, 60 * 15); } // check permission for changepass if ($mymodule === 'changepass' && $from !== 'verification' && !$islogin) { \lib\error::access(T_("you can't access to this page!")); } switch ($mymodule) { case 'home': $this->redirector()->set_url("login")->redirect(); break; case 'verification': case 'verificationsms': if ($from && $from !== 'recovery' && $from !== 'signup' && $from !== 'verification') { \lib\error::access(T_("you can't access to this page!")); } $this->model_name = '\\addons\\content_account\\' . $mymodule . '\\model'; $this->display_name = 'content_account\\' . $mymodule . '\\display.html'; $this->post($mymodule)->ALL($mymodule); $this->get()->ALL($mymodule); break; case 'signup': return; /** Fix it later, only access if posible */ /** Fix it later, only access if posible */ case 'login': case 'recovery': if ($islogin) { \lib\debug::true(T_("you are logined to system!")); $myreferer = \lib\router::urlParser('referer', 'host'); $myssid = isset($_SESSION['ssid']) ? '?ssid=' . $_SESSION['ssid'] : null; if (\lib\router::get_storage('CMS')) { $this->redirector()->set_domain()->set_sub_domain(\lib\router::get_storage('CMS'))->set_url()->redirect(); } else { $this->redirector()->set_domain()->set_url()->redirect(); } } case 'changepass': $this->model_name = '\\addons\\content_account\\' . $mymodule . '\\model'; $this->display_name = 'content_account\\' . $mymodule . '\\display.html'; $this->post($mymodule)->ALL($mymodule); $this->get()->ALL($mymodule); break; case 'smsdelivery': case 'smscallback': $uid = 201500001; if (\lib\utility::get('uid') == $uid || \lib\utility\cookie::read('uid') == $uid) { $this->model_name = '\\addons\\content_account\\sms\\model'; $this->display_name = 'content_account\\sms\\display.html'; $this->post($mymodule)->ALL($mymodule); $this->get($mymodule)->ALL($mymodule); } else { \lib\error::access("SMS"); } break; // logout user from system then redirect to ermile // logout user from system then redirect to ermile case 'logout': $this->model_name = '\\lib\\mvc\\model'; $this->model()->put_logout(); $this->redirector()->set_domain()->set_url()->redirect(); break; default: \lib\error::page(); break; } // $this->route_check_true = true; }
public function __construct($_clean_url = null) { self::$repository = repository; $path = preg_replace("/^\\.\\//", "/", '/'); $clean_url = $_clean_url !== null ? $_clean_url : $_SERVER['REQUEST_URI']; if (preg_match("#0x#", $clean_url)) { // error } $clean_url = preg_replace("#0x#Ui", "", $clean_url); $clean_url = preg_replace("#^https?://{$_SERVER['HTTP_HOST']}\\/#", '', $clean_url); $clean_url = preg_replace("#^{$path}#", '', $clean_url); $clean_url = urldecode($clean_url); preg_match("/^([^?]*)(\\?.*)?\$/", $clean_url, $url); self::$real_url_string = self::$url_string = $url[1]; self::$real_url_array = self::$url_array = preg_split("[\\/]", preg_replace("/^\\/|\\/\$/", '', $url[1]), -1, PREG_SPLIT_NO_EMPTY); // HTTP_HOST is not secure and attacker can change it $domain = $_SERVER['HTTP_HOST']; self::$domain = preg_split("[\\.]", $domain); self::$sub_domain = self::$domain; array_pop(self::$sub_domain); array_pop(self::$sub_domain); if (isset(self::$real_url_array[0]) && self::$real_url_array[0] == 'home' || isset(self::$real_url_array[1]) && self::$real_url_array[1] == 'home') { \lib\error::page("home"); } /** * user want control panel or CMS */ if (defined('CMS') && constant('CMS')) { $myCP = constant('CMS') === true ? 'cp' : constant('CMS'); router::set_storage('CMS', $myCP); } else { router::set_storage('CMS', 'cp'); } /** * before router */ if (self::$auto_repository) { // first get subdomain and if not exist get first url part as mysub $mysub = router::get_sub_domain(); if (!$mysub) { $mysub = router::get_url(0); router::$sub_is_fake = true; // router::$sub_is_fake = $mysub? true: false; // router::set_storage('language', router::get_storage('defaultLanguage') ); } if ($mysub) { // automatically set repository if folder of it exist $myaddons = array(); $mysub_real = $mysub; $myloc = null; $mysub_valid = null; // check for account with specefic name if (\lib\router::get_storage('CMS')) { $myaddons[\lib\router::get_storage('CMS')] = 'cp'; $myaddons['account'] = 'account'; } // check this sub is exist in our data or not if (array_key_exists($mysub, $myaddons)) { $mysub = $myaddons[$mysub]; $mysub_valid = true; } // set repository name $myrep = 'content_' . $mysub; // check content_aaa folder is exist in project or saloos addons folder if (is_dir(root . $myrep)) { $myloc = false; } elseif ($mysub_valid && is_dir(addons . $myrep)) { $myloc = addons; } // if folder exist if (!is_null($myloc)) { // if url is fake, show it like subdomain and remove from url if (router::$sub_is_fake) { router::remove_url($mysub_real); router::set_sub_domain($mysub_real); } // set repository to this folder $myparam = array($myrep); if ($myloc) { array_push($myparam, $myloc); } // call function and pass param value to it router::set_repository(...$myparam); } } } if (self::$auto_api) { // automatically allow api, if you wan't to desable it, only set a value $route = new router\route("/^api([^\\/]*)/", function ($reg) { router::remove_url($reg->url); router::set_storage('api', true); }); } if (class_exists('\\cls\\route')) { $router = new \cls\route(); $router->main = $this; if (method_exists($router, "_before")) { $router->_before(); } } // like dev or com or ir or ... if (!defined('Tld')) { define('Tld', router::get_root_domain('tld')); } $this->check_router(); /** * after router */ if (class_exists('\\cls\\route')) { if (method_exists($router, "_after")) { $router->_after(); } } // Define Project Constants ******************************************************************* // declate some constant variable for better use in all part of app // like .dev or .com if (!defined('MainTld')) { // if enabling multi domain and set default tld define main tld if (\lib\utility\option::get('config', 'meta', 'multiDomain') && ($defaultTld = \lib\utility\option::get('config', 'meta', 'defaultTld'))) { define('MainTld', '.' . $defaultTld); } else { define('MainTld', Tld === 'dev' ? '.dev' : '.com'); } } // like ermile if (!defined('Domain')) { define('Domain', router::get_root_domain('domain')); } // like account if (!defined('SubDomain')) { define('SubDomain', router::get_sub_domain()); } // like 127.0.0.1 if (!defined('ClientIP')) { define('ClientIP', router::get_clientIP()); } // like ermile.com if (!defined('Service')) { define('Service', Domain . '.' . Tld); } // like test if (!defined('Module')) { define('Module', router::get_url(0)); } // like https://ermile.com router::set_storage('url_site', Protocol . '://' . Domain . '.' . Tld . '/'); // set MyAccount for use in all part of services if (!defined('AccountService')) { // if user want main account and set main account name if (\lib\utility\option::get('config', 'meta', 'useMainAccount') && \lib\utility\option::get('config', 'meta', 'mainAccount') === constant('MainService')) { define('AccountService', constant('MainService')); } else { define('AccountService', Domain); } } // check for account with specefic name if (!defined('MyAccount') && \lib\router::get_storage('CMS')) { // set MyAccount for use in all part of services define('MyAccount', 'account'); } router::$base = Protocol . '://'; if (router::$sub_is_fake) { router::$base .= Service . (SubDomain ? '/' . SubDomain : null); } else { router::$base .= SubDomain . '.' . Service; } if (count(explode('.', SubDomain)) > 1) { die("<p>Saloos only support one subdomain!</p>"); } elseif (SubDomain === 'www') { header('Location: ' . router::get_storage('url_site'), true, 301); } }
function s_template_finder() { // if lang exist in module or subdomain remove it and continue $currentLang = substr(router::get_storage('language'), 0, 2); $defaultLang = substr(router::get_storage('defaultLanguage'), 0, 2); if ($currentLang === SubDomain && $currentLang !== $defaultLang) { \lib\router::set_sub_domain(null); } // elseif($currentLang === $this->module() && $currentLang !== $defaultLang) // \lib\router::remove_url($currentLang); // continue find best template for this condition $mymodule = $this->module(); if ($mymodule == 'home') { // if home template exist show it if (is_file(root . 'content/template/home.html')) { $this->display_name = 'content\\template\\home.html'; } $this->get()->ALL(); return 0; } elseif ($mymodule == 'search') { if (is_file(root . 'content/template/search.html')) { $this->display_name = 'content\\template\\search.html'; } $this->get()->ALL(); return; } elseif ($mymodule == 'feed') { $site_title = $this->view()->data->site['title']; $site_desc = $this->view()->data->site['desc']; $site_protocol = $this->url('MainProtocol') . '://'; $site_url = $this->url('MainSite'); $rss = new \lib\utility\RSS($site_protocol, $site_url, $site_title, $site_desc); // add posts foreach ($this->model()->get_feeds() as $row) { $rss->addItem($row['link'], $row['title'], $row['desc'], $row['date']); } $rss->create(); // \lib\utility\RSS::create(); exit; return; } if (!empty(db_name)) { $myurl = $this->model()->s_template_finder(); } else { $myurl = null; } // if url does not exist show 404 error if (!$myurl) { // var_dump($mymodule); // var_dump(\lib\router::get_storage('language')); // if user entered url contain one of our site language $currentPath = $this->url('path', '_'); // if custom template exist show this template if (is_file(root . 'content/template/static_' . $currentPath . '.html')) { $this->display_name = 'content\\template\\static_' . $currentPath . '.html'; } elseif (is_file(root . 'content/template/404.html')) { header("HTTP/1.1 404 NOT FOUND"); $this->display_name = 'content\\template\\404.html'; } else { \lib\error::page(T_("Does not exist!")); return; } } elseif (is_file(root . 'content/template/' . $myurl['type'] . '-' . $myurl['slug'] . '.html')) { $this->display_name = 'content\\template\\' . $myurl['type'] . '-' . $myurl['slug'] . '.html'; } elseif (is_file(root . 'content/template/' . $myurl['type'] . '.html')) { $this->display_name = 'content\\template\\' . $myurl['type'] . '.html'; } elseif (is_file(root . 'content/template/' . $myurl['table'] . '.html')) { $this->display_name = 'content\\template\\' . $myurl['table'] . '.html'; } elseif (is_file(root . 'content/template/dafault.html')) { $this->display_name = 'content\\template\\dafault.html'; } $this->route_check_true = true; $this->get(null, $myurl['table'])->ALL(); // $this->get()->ALL(); }
function config() { // Restrict unwanted module if (!$this->cpModlueList()) { \lib\error::page(T_("Not found!")); } $mymodule = $this->cpModule('table'); $cpModule = $this->cpModule('raw'); $mychild = $this->child(); $mypath = $this->url('path', '_'); // Restrict unwanted child // if($mychild && !($mychild=='add' || $mychild=='edit' || $mychild=='delete' || $mychild=='list' || $mychild=='options')) // \lib\error::page(T_("Not found!")); if (is_file(addons . 'content_cp/' . $cpModule . '/model.php')) { $this->model_name = 'content_cp\\' . $cpModule . '\\model'; } elseif (is_file(addons . 'content_cp/' . $mymodule . '/model.php')) { $this->model_name = 'content_cp\\' . $mymodule . '\\model'; } switch ($cpModule) { case 'home': break; case 'profile': // Check permission and if user can do this operation // allow to do it, else show related message in notify center $this->access('cp', 'profile', 'edit', 'notify'); //allow put on profile $this->display_name = 'content_cp/templates/module_profile.html'; $this->get(null, 'datatable')->ALL('/^[^\\/]*$/'); $this->put('profile')->ALL(); break; case 'options': //allow put on profile // $this->display_name = 'content_cp/templates/module_options.html'; $this->get(null, 'datatable')->ALL('/^[^\\/]*$/'); $this->put('options')->ALL(); break; // case 'permissions': // $this->display_name = 'content_cp/templates/module_permissions.html'; // $this->get(null, 'datatable')->ALL('/^[^\/]*$/'); // $this->put('permissions')->ALL(); // break; // case 'permissions': // $this->display_name = 'content_cp/templates/module_permissions.html'; // $this->get(null, 'datatable')->ALL('/^[^\/]*$/'); // $this->put('permissions')->ALL(); // break; case 'logout': $mydomain = AccountService ? AccountService . MainTld : null; $this->redirector(null, false)->set_domain($mydomain)->set_url('logout')->redirect(); break; default: if (is_file(addons . 'content_cp/templates/module_' . $mymodule . '.html')) { $this->display_name = 'content_cp/templates/module_' . $mymodule . '.html'; } else { $this->display_name = 'content_cp/templates/module_display.html'; } $this->get(null, 'datatable')->ALL('/^[^\\/]*$/'); // on each module except home and some special module with child like /post/add if ($mychild) { if (is_file(addons . 'content_cp/templates/child_' . $mymodule . '.html')) { $this->display_name = 'content_cp/templates/child_' . $mymodule . '.html'; } else { $this->display_name = 'content_cp/templates/child_display.html'; } //all("edit=.*") $this->route_check_true = true; switch ($mychild) { case 'delete': $this->redirector()->set_url($this->cpModule('raw')); //->redirect(); // $this->delete($mychild)->ALL('/^[^\/]*\/[^\/]*$/'); $this->post($mychild)->ALL('/^[^\\/]*\\/[^\\/]*$/'); $this->get($mychild)->ALL('/^[^\\/]*\\/[^\\/]*$/'); // @hasan: regular? // $this->display_name = null; // $this->redirector()->set_url($cpModule);//->redirect(); return; break; case 'edit': // var_dump($this->model()->datarow()); $this->get(null, 'child')->ALL('/^[^\\/]*\\/[^\\/]*$/'); $this->put($mychild)->ALL('/^[^\\/]*\\/[^\\/]*$/'); break; case 'add': $this->get(null, 'child')->ALL('/^[^\\/]*\\/[^\\/]*$/'); $this->post($mychild)->ALL('/^[^\\/]*\\/[^\\/]*$/'); break; case 'list': $this->route_check_true = false; $this->get($mychild)->ALL(); $this->post($mychild)->ALL(); break; case 'options': $this->route_check_true = false; $this->get($mychild)->ALL(); $this->post($mychild)->ALL(); break; default: break; } } break; } if (is_file(addons . 'content_cp/templates/static_' . $mypath . '.html')) { $this->display_name = 'content_cp/templates/static_' . $mypath . '.html'; } }
/** * [__call description] * @param [type] $_name [description] * @param [type] $_args [description] * @return [type] [description] */ public function __call($_name, $_args) { if (preg_grep("/^{$_name}\$/", array('get', 'post', 'put', 'delete'))) { array_unshift($_args, $_name); return call_user_func_array(array($this, 'check_api'), $_args); } elseif (method_exists('\\lib\\router', $_name)) { return call_user_func_array('\\lib\\router::' . $_name, $_args); } elseif (preg_match("#^inject_((after_|before_)?.+)\$#Ui", $_name, $inject)) { return $this->inject($inject[1], $_args); } elseif (preg_match("#^i(.*)\$#Ui", $_name, $icall)) { return $this->mvc_inject_finder($_name, $_args, $icall[1]); } \lib\error::page(get_called_class() . "->{$_name}()"); }