public function run($app = '', $ac = '') { $c = sha1(url()); $S = !empty($_SESSION['pe_s'][$c]) ? $_SESSION['pe_s'][$c] : ''; for ($i = 1; $i <= 9; ++$i) { if (isset($_REQUEST['pe_try' . $i]) && !empty($_REQUEST['pe_s']) && $_REQUEST['pe_s'] == $S) { $this->try = $i; $this->form = !empty($_REQUEST['pe_f']) ? trim($_REQUEST['pe_f']) : ''; $_SESSION['pe_s'][$c] = 0; break; } } if (empty($_SESSION['pe_s'][$c])) { $_SESSION['pe_s'][$c] = sha1(uniqid() . 'PHPPE' . VERSION); } if (!empty($_SESSION['pe_v'])) { self::$v = $_SESSION['pe_v']; } View::init(); if (empty($this->maintenance)) { list($app, $ac, $args) = HTTP::urlMatch($app, $ac, $this->url); list($app, $ac) = self::event('route', [$app, $ac]); $c = $app . '_' . $ac; if (strpos($c, '..') !== false || strpos($c, '/') !== false || substr($app, -4) == '.php' || substr($ac, -4) == '.php') { $app = $this->template = '403'; } else { $this->template = self::$w ? $app . '_' . $ac : ''; } $appCls = $app; foreach (['PHPPE\\Ctrl\\' . $app . ucfirst($ac), 'PHPPE\\Ctrl\\' . $app, 'PHPPE\\' . $app, $app] as $a) { if (ClassMap::has($a)) { $appCls = $a; if ($a[0] == "\\") { $a = substr($a, 1); } $p = dirname(ClassMap::$map[strtolower($a)]); if (basename($p) == "ctrl" || basename($p) == "libs") { $p = dirname($p); } self::$paths[strtolower($app)] = $p; break; } } if (!ClassMap::has($appCls)) { if (!self::$w) { die($this->app == 'cron' ? self::event('cron' . ucfirst($this->action), 0) : 'PHPPE-C: ' . L($this->app . '_' . $this->action . ' not found!') . "\n"); } $appCls = 'PHPPE\\Content'; $ac = 'action'; } $appObj = new $appCls(); View::setPath(self::$paths[strtolower($app)]); View::assign('app', $appObj); self::log('D', $this->url . " ->{$app}::{$ac} " . $this->template, 'routes'); $N = 'p_' . sha1($this->base . $this->url . '/' . self::$user->id . '/' . self::$client->lang); if (empty($this->nocache) && !self::isTry()) { $T = View::fromCache($N); } if (empty($T)) { Content::getDDS($appObj); self::event('ctrl', [$app, $ac]); if (!method_exists($appObj, $ac)) { $ac = 'action'; } if (method_exists($appObj, $ac)) { !empty($args) ? call_user_func_array([$appObj, $ac], $args) : $appObj->{$ac}($this->item); } $T = View::generate($this->template, $N); } } else { session_destroy(); $T = View::template('maintenance'); if (empty($T)) { $T = L('Site is temporarily down for maintenance'); } } if ((@in_array('--dump', $_SERVER['argv']) || isset($_REQUEST['--dump'])) && $this->runlevel > 0) { View::dump(); } DS::close(); $T = self::event('view', $T); View::output($T); session_write_close(); }