* @package MCMS\System */ class Runner extends RunnerBase implements \MCMS\Interfaces\iRunner { /** * * @var \MCMS\Request request instance */ protected $request; /** * * @var \MCMS\Response respone instance */ protected $response; /** * * @var \MCMS\Context call context */ protected $context; /** * * @var array the plugins used by the script */ protected $plugins; public function __construct() { Logger::getInstance(__CLASS__)->traceStart(); } public function doLoadConfig() { Logger::getInstance(__CLASS__)->traceStart(); if(!defined('_CFGPATH_')) throw new IllegalStateException('_CFGPATH_ undefined'); $this->_loadConfigFromDir(new File(_CFGPATH_)); $syskey = System::getInstance()->getConfig('syskey'); if(empty($syskey)) throw new \UnexpectedValueException('$cfg[\'syskey\'] needs to be defined for security purpurse'); Logger::getInstance(__CLASS__)->traceEnd(); } public function doInit() { Logger::getInstance(__CLASS__)->traceStart(); $system = System::getInstance(); defined('PROFILE') && Profiler::start(__METHOD__ . '::initDB'); $this->doInitDb($system); $db = $system->getDB(); defined('PROFILE') && Profiler::stop(__METHOD__ . '::initDB'); defined('PROFILE') && Profiler::start(__METHOD__ . '::checkDBver'); $this->doInitCheckDBVersion($db); defined('PROFILE') && Profiler::stop(__METHOD__ . '::checkDBver'); // init the cache defined('PROFILE') && Profiler::start(__METHOD__ . '::initCache'); $this->doInitCache($system); defined('PROFILE') && Profiler::stop(__METHOD__ . '::initCache'); // init the session object defined('PROFILE') && Profiler::start(__METHOD__ . '::initSession'); if (!$system->isContextSet(iSystem::CTX_SESSION)) $this->doInitSession($system); defined('PROFILE') && Profiler::stop(__METHOD__ . '::initSession'); // init the plugin system $this->plugins['cache'] = array($cache = System::getContext(iSystem::CTX_CACHE)); // load the weaving $weaving = $this->getWeaving(); $this->plugins['content'] = array(); foreach ($weaving['common']['content'] as $piName) { $this->plugins['content'][] = new $piName(); } if(defined('_ADMIN_')) { if (!class_exists($weaving['backend']['router'])) throw new \Exception("Router class '{$weaving['backend']['router']}' not found"); $this->plugins['router'] = new $weaving['backend']['router'](); foreach ($weaving['backend']['content'] as $piName) { $this->plugins['content'][] = new $piName(); } } else { if (!class_exists($weaving['frontend']['router'])) throw new \Exception("Router class '{$weaving['frontend']['router']}' not found"); $this->plugins['router'] = new $weaving['frontend']['router'](); foreach ($weaving['frontend']['content'] as $piName) { $this->plugins['content'][] = new $piName(); } } // var_dump($this->plugins); // die(); // adding user plugins // $installedPlugins = $cache->get(array('sys','-1','sys.info','installedPlugins')); // if(!is_array($installedPlugins)) { $q = $db->select()->from('installinfos')->where(array('type' => 'plugin')); $installedPlugins = $db->getObjectList($q); // $cache->set(array('sys','-1','sys.info','installedPlugins'), $installedPlugins, 60); // } // foreach($installedPlugins as $plugin) { // list($type, $name) = explode(':', $plugin->key, 2); // $this->plugins[$type][] = $name; // } // if(defined('_ADMIN_')) { // $this->usedPlugins = $this->plugins; // $this->plugins = $system->getBaseAdminPlugins(); // // foreach($this->plugins as $cat=>$list) { // // $this->usedPlugins[$cat] = array_merge($this->usedPlugins[$cat], $this->plugins[$cat]); // // } // } // initialize the user service $authcfg = $system->getConfig('auth'); $authclass = isset($weaving['common']['auth']) ? $weaving['common']['auth'] : \MCMS\_\Plugin\Auth\MCMS\DefaultAuth\DefaultAuth::clazz(); if (!class_exists($authclass)) throw new \Exception("Authentication class '{$authclass}' not found"); if(empty($authcfg)) $authcfg = array(); defined('PROFILE') && Profiler::start(__METHOD__ . '::initUserSvc'); // $class = loadPlugin('auth', $authcfg['type']); // add the plugin to the list of used plugins on admin calls // if(defined('_ADMIN_')) // $this->usedPlugins['auth'][0] = $authcfg['type']; $system->initUserSvc($authclass, $authcfg); // register the auth plugin in the system $this->plugins['auth'][0] = $system->getUserSvc(); defined('PROFILE') && Profiler::stop(__METHOD__ . '::initUserSvc'); $this->request = $system->getRequest(); $this->context = new Context(); $this->response = new Response(); // setting the default system timezone $timezone = $system->getConfig('timezone'); if(empty($timezone)) $timezone = 'UTC'; date_default_timezone_set($timezone); $defaultlocale = $system->getConfig('defaultlocale'); if(empty($defaultlocale)) $defaultlocale = 'en'; $this->context->setDefaultLocale($defaultlocale); unset($timezone, $defaultlocale); // foreach($this->plugins as $cat=>$plugins) { // foreach($plugins as $id=>$plugin) // // ignore already initialized plugins // if (!is_object($this->plugins[$cat][$id])) // $this->plugins[$cat][$id] = $system->loadPlugin($cat, $plugin); // } Logger::getInstance(__CLASS__)->traceEnd(); } protected function doInitDb(iSystem &$system) { Logger::getInstance(__CLASS__)->traceStart(); $dbcfg = $system->getConfig('db'); if(!isset($dbcfg['option'])) $dbcfg['option'] = array(); $system->initDB($dbcfg['dsn'], $dbcfg['user'], $dbcfg['passwd'], $dbcfg['option']); $dbcfg = $system->getConfig('dbx'); if(!empty($dbcfg) && is_array($dbcfg)) { foreach($dbcfg as $name=>$dbc) { Logger::getInstance(__CLASS__)->trace('initDBx:'.$name); if(!isset($dbc['option'])) $dbc['option'] = array(); $system->addDB($name, $dbc['dsn'], $dbc['user'], $dbc['passwd'], $dbc['option']); } unset($dbc); } unset($dbcfg); Logger::getInstance(__CLASS__)->traceEnd(); } protected function doInitCache(iSystem &$system) { Logger::getInstance(__CLASS__)->traceStart(); $system = System::getInstance(); $weaving = $system->getWeaving(); if(defined('_CLI_')) // CLI mod has no real caching $weaving['common']['cache'] = \MCMS\_\Plugin\Cache\MCMS\NullCache\NullCache::clazz(); if (!class_exists($weaving['common']['cache'])) throw new \Exception("Unknown cache class '{$weaving['common']['cache']}' set in weaving config"); $class = $weaving['common']['cache']; $cache = new $class(); if (!($cache instanceof iPlugInCache)) throw new \Exception('Invalid cache class set in weaving config'); $system->initContext(iSystem::CTX_CACHE, $cache); Logger::getInstance(__CLASS__)->traceEnd(); } protected function doInitCheckDBVersion(DB &$db) { Logger::getInstance(__CLASS__)->traceStart(); $q = $db->select()->columns(array('version'))->from('installinfos')->where(array('type' => 'system','key' => 'mcmsdb'))->limit(1); if(($dbv = $db->getObject($q)->version) != MCMS_DB) throw new \ErrorException('CRITICAL: DB-VERSION ' . $dbv . '!=' . MCMS_DB . ' NEEDED BY SYSTEM'); Logger::getInstance(__CLASS__)->traceEnd(); } protected function doInitSession(iSystem &$system) { Logger::getInstance(__CLASS__)->traceStart(); if (defined('_CLI_')) { Logger::getInstance(__CLASS__)->trace("CLI mode, using dummy session"); $system->initContext(iSystem::CTX_SESSION, new \MCMS\_\Plugin\Session\MCMS\CLISession\CLISession()); Logger::getInstance(__CLASS__)->traceEnd(); return; } $system = System::getInstance(); $weaving = $system->getWeaving(); if (!class_exists($weaving['common']['session'])) throw new \Exception('Unknown session class set in weaving config'); $class = $weaving['common']['session']; $session = new $class(); if (!($session instanceof iPlugInSession)) throw new \Exception('Invalid session class set in weaving config'); if (method_exists($session, 'setPrefix')) { $prefix = sha1(_BASEPATH_); $session->setPrefix(substr($prefix,0,6)); } $system->initContext(iSystem::CTX_SESSION, $session); Logger::getInstance(__CLASS__)->traceEnd(); } protected function loadWebpageSettings($id, $asParent = false) { Logger::getInstance(__CLASS__)->traceStart(); if(!is_int($id)) throw new \InvalidArgumentException('$id needs to be an integer'); $system = System::getInstance(); $cache = System::getContext(iSystem::CTX_CACHE); $cachekey = implode('@',array('sys',$id,'site','real_id')); if ($cache->keyExists($cachekey)) { // TODO: Srsly? $sysId = $cache->get($cachekey); $system->setSiteId($sysId); return; } $db = $system->getDB(); $sql = $db->select()->from('websites')->where(array('id' => new Parameter())); $maindata = $db->getObjectP($sql, array($id)); $system->setSiteId($maindata->id); if(!empty($maindata->parent_id)) $this->loadWebpageSettings((int) $maindata->parent_id, true); $cache->set($cachekey,$system->getSiteId(),10); Logger::getInstance(__CLASS__)->traceEnd(); } public function doRoute() { Logger::getInstance(__CLASS__)->traceStart(); if(defined('_CRON_')) return; $system = System::getInstance(); $db = $system->getDB(); $profilerClass = defined('PROFILE'); if (!class_exists($profilerClass)) $profilerClass = \Mammut\Profiler\Profiler::clazz(); $this->doRouteFindSite(); $profilerClass && call_user_func([$profilerClass,'start'],'run::doRoute::route'); $info = $this->plugins['router']->doRoute(); $siteId = $system->getSiteId(); $profilerClass && call_user_func([$profilerClass,'stop'],'run::doRoute::route'); $profilerClass && call_user_func([$profilerClass,'start'],'run::doRoute::acl'); if ((!empty($info->visible)) && ($info->visible != 'all') && !defined('_ADMIN_')) { $allowed = false; $userSvc = System::getInstance()->getUserSvc(); $user = $userSvc->getUser(); // All access methods need a valid user if (empty($user)) throw new AccessDeniedException('Missing privileges'); if ($userSvc->userHasPriv($user)) $allowed = true; switch ($info->visible) { case 'user': $allowed = true; break; case 'acl': $allowed = $allowed || ACLSvc::hasUserAccess($user, $siteId, $info->instance); break; } if (!$allowed) throw new AccessDeniedException('Missing privileges'); } $profilerClass && call_user_func([$profilerClass,'stop'],'run::doRoute::acl'); if (isset($info->module)) $this->request->setModule($info->module); Logger::getInstance(__CLASS__)->traceEnd(); } protected function doRouteFindSite() { Logger::getInstance(__CLASS__)->traceStart(); $system = System::getInstance(); $db = $system->getDB(); // $table = $db->escapeTableName('websites'); // $efn_domain = $db->escapeColumnName('domain'); // if(defined('SINGLESITE')) { // single site tuning $sql = $db->select()->from('websites')->where(['domain' => '*'])->limit(1); $row = $db->getObject($sql); $this->loadWebpageSettings((int) $row->id); // } // else { // // find page // $domain = $_SERVER['HTTP_HOST']; // if(empty($domain)) // $domain = $_SERVER['SERVER_NAME']; // $subdomain = substr($domain, strpos($domain, '.')); // // echo "

seaching for ".$domain." or *.".$subdomain."

"; // $subdomain = $db->escapeString($subdomain); // $domain = $db->escapeString($domain); // $result = $db->query("SELECT * FROM {$table} WHERE {$efn_domain}='{$domain}'"); // if($result->getRowCount() > 0) { // // echo '

found main-domain

'; // $this->loadWebpageSettings((int) $result->fetchObject()->id); // $result->close(); // } // else { // $result->close(); // $result = $db->query("SELECT * FROM {$table} WHERE {$efn_domain} LIKE '%.{$subdomain}'"); // if($result->getRowCount() > 0) { // // echo '

found sub-domain-catchall

'; // $this->loadWebpageSettings((int) $result->fetchObject()->id); // $result->close(); // } // else { // $result->close(); // $result = $db->query("SELECT * FROM {$table} WHERE {$efn_domain} LIKE '*'"); // if($result->getRowCount() > 0) { // // echo '

found catchall

'; // $this->loadWebpageSettings((int) $result->fetchObject()->id); // $result->close(); // } // else { // // echo 'no pagedef has been found'; // $result->close(); // } // } // } // } // foreach($this->plugins['route'] as $router) // $router->doRoute($this->context); Logger::getInstance(__CLASS__)->traceEnd(); } public function doBeforeRun() { Logger::getInstance(__CLASS__)->traceStart(); // if(defined('_ADMIN_')) // $this->plugins['content'][0]->setUsedPlugins($this->usedPlugins); // foreach($this->plugins['content'] as $plugin) { // defined('PROFILE') && Profiler::start(__METHOD__ . '::runPlugin::' . get_class($plugin)); // $plugin->run($this->response, iPlugInContent::STEP_BEFORE_RUN, $this->context); // defined('PROFILE') && Profiler::stop(__METHOD__ . '::runPlugin::' . get_class($plugin)); // } $cfg = System::getInstance()->getConfig('cron'); if(empty($cfg)) $cfg = array('mode' => 'cli'); if(defined('_CRON_') && $cfg['mode'] != 'emulate') throw new \ErrorException("cron can only be called from a shell", 500); foreach($this->plugins['content'] as $pi) { $pi->run($this->request, $this->response, iPlugInContent::STEP_BEFORE_RUN, $this->context); } Logger::getInstance(__CLASS__)->traceEnd(); } public function doRun() { Logger::getInstance(__CLASS__)->traceStart(); if(defined('_CRON_')) return; $system = System::getInstance(); if ($system->getTarget('instance') == '*') { switch($system->getTarget(iSystem::TARGET_PLUGIN)) { case 'mm': $weaving = $this->getWeaving(); $cls = $weaving['common']['mediamanager']; $mm = new $cls(); $mm->handleRequest($this->request, $this->response, $this->context); unset($mm); break; } } else { foreach($this->plugins['content'] as $pi) { $pi->run($this->request, $this->response, iPlugInContent::STEP_RUN, $this->context); } } Logger::getInstance(__CLASS__)->traceEnd(); return; // ----------------------------------------------------- try { if($system->getTarget(iSystem::TARGET_INSTANCE) == '*') { $target = $system->getTarget(iSystem::TARGET_VIEW); if(isset($this->plugins['misc'][$target])) $this->plugins['misc'][$target]->handleRequest($system->getRequest(), $this->response, $this->context); else $this->response->setContent('invalid request: ' . $target); } else { // foreach($this->plugins['content'] as $plugin) { // defined('PROFILE') && Profiler::start(__METHOD__ . '::runPlugin::' . get_class($plugin)); // $plugin->run($this->response, iPlugInContent::STEP_RUN, $this->context); // defined('PROFILE') && Profiler::stop(__METHOD__ . '::runPlugin::' . get_class($plugin)); // } } } catch(\MCMS\Exception\AccessDeniedException $e) { $this->response->addError(403, 'Access denied'); } catch(\Mammut\Exception\IllegalStateException $e) { if (defined('DEBUG')) $this->response->addError($e->getCode(), 'Internal error: '.$e->getMessage(),'run',$e); else $this->response->addError(500, 'Internal error','run'); } $this->response->setContent('TestContent'); } public function doRunAdmin() { Logger::getInstance(__CLASS__)->traceStart(); if(defined('_CRON_')) return; if(!defined('_ADMIN_')) throw new \InvalidArgumentException('Admin call in non-admin context'); $system = System::getInstance(); $userSvc = $system->getUserSvc(); $profilerClass = defined('PROFILE'); if (!class_exists($profilerClass)) $profilerClass = \Mammut\Profiler\Profiler::clazz(); $allowed = false; if (defined('_ADMIN_')) { $user = $userSvc->getUser(); if (!empty($user) && $userSvc->userHasAdminPriv($user)) $allowed = true; } if ($allowed) { foreach($this->plugins['content'] as $pi) { if (!($pi instanceof \MCMS\Plugin\iAdminPlugIn )) throw new IllegalStateException(get_class($pi).' does not implement iAdminPlugIn'); $profilerClass && call_user_func([$profilerClass,'start'],'runner::doRunAdmin::run('.get_class($pi).')'); $pi->run($this->request, $this->response, iPlugInContent::STEP_RUN, $this->context); $profilerClass && call_user_func([$profilerClass,'stop'],'runner::doRunAdmin::run('.get_class($pi).')'); } } else { $param = $system->getRequest()->getParam(); // TODO: improve if (isset($param['login']) && isset($param['password'])) { $userSvc->loginUser($param['login'], $param['password']); $this->response->setRedirectURL(_SELF_BACKEND_); } elseif ($system->getTarget(iSystem::TARGET_VIEW) == 'logout') { $userSvc->logoutUser(); $this->response->setRedirectURL(_SELF_BACKEND_); } } Logger::getInstance(__CLASS__)->traceEnd(); } public function doRunCLI() { Logger::getInstance(__CLASS__)->traceStart(); if(defined('_CRON_')) $this->runCronJobs(); Logger::getInstance(__CLASS__)->traceEnd(); } protected function runCronJobs() { Logger::getInstance(__CLASS__)->traceStart(); $LOG = Logger::getInstance(__CLASS__); $system = System::getInstance(); $time = time(); $lastrun = (int) $system->getSiteParam(NULL, 'cron', 'lastrun', -1); $cronrun = false; $cronparam = array('time' => $time); $minDelay = defined('MIN_CRONTIME') ? constant('MIN_CRONTIME') : 60; if($lastrun <= 0 || $time - $lastrun >= $minDelay) { $LOG->info("Running cron"); $cronrun = true; $lastrun = $system->setSiteParam(NULL, 'cron', 'lastrun', $time); } if(!$cronrun) return; foreach($this->plugins as $plugingroup) { foreach($plugingroup as $plugin) { if($plugin instanceof \MCMS\Interfaces\iCronClient) { $LOG->info("Running cron tasks [{$time}:{$lastrun}] in ".get_class($plugin)); $plugin->executeCronRun($cronparam); } } } $LOG->info("Cronrun done"); Logger::getInstance(__CLASS__)->traceEnd(); } public function doAfterRun() { if(defined('_CRON_')) return; Logger::getInstance(__CLASS__)->traceStart(); foreach($this->plugins['content'] as $pi) { $pi->run($this->request, $this->response, iPlugInContent::STEP_AFTER_RUN, $this->context); } // var_dump($this); // add layout if ($this->response->getAddLayout() && $this->response->getMime() && !defined('_SERVICE_')) { $mime = $this->response->getMime(); $weaving = System::getInstance()->getWeaving(); $weavingCtx = defined('_ADMIN_') ? $weaving['backend']['layout'] : $weaving['frontend']['layout'] ; /** * @var \MCMS\Plugin\iPlugInLayout */ $layoutPi = NULL; if (isset($weavingCtx[$mime])) { if (!class_exists($weavingCtx[$mime])) throw new ConfigException("Invalid layout class for type '{$mime}' defined: {$weavingCtx[$mime]}"); $layoutPi = new $weavingCtx[$mime](); } if ($layoutPi) { $system = System::getInstance(); $siteId = $system->getSiteId(); if (defined('_ADMIN_')) { $layoutPi->load('default'); } else { $layout = $system->getSiteParam($siteId, '', 'layout', 'default'); $layoutPi->load($layout); } // fill in the generated content foreach ($this->response->getAllFragments() as $name => $content) { $layoutPi->setRegionContent($name, $content); } foreach ($weaving['common']['layout']['addon'] as $addon) { $addonPi = new $addon(); $addonPi->processLayout($layoutPi); unset($addonPi); } foreach ($weavingCtx['addon'] as $addon) { $addonPi = new $addon(); $addonPi->processLayout($layoutPi, $this->response); unset($addonPi); } $this->response->setContent($layoutPi->getDocument()); // $content = $this->response->getFragment('CONTENT'); // $this->response->setFragment('CONTENT', NULL); // $layoutPi = new \MCMS\_\Plugin\Layout\MCMS\Layout\Layout(); // $layoutPi->setRegionContent('CONTENT', $content); // unset($content); // $this->response->appendContent($layoutPi->getDocument()); // $content = $this->response->getFragment('CONTENT'); // $this->response->setFragment('CONTENT', NULL); // $layoutPi = false; // if (defined('_ADMIN_')) { // $weaving = System::getInstance()->getWeaving(); // if (isset($weaving['backend']['layout']['text/html'])) // $class = $weaving['backend']['layout']['text/html']; // else // $class = \MCMS\_\Plugin\Layout\MCMS\AdminLayout\AdminLayout::clazz(); // $layoutPi = new $class(); // $layoutPi->load('default'); // // TODO: fix // if (isset($weaving['backend']['menu'])) // $class = $weaving['backend']['menu']; // else // $class = \MCMS\_\Plugin\Content\MCMS\AdminMenu\AdminMenu::clazz(); // $menu = new $class(); // $response = new Response(); // $menu->run($response, iPlugInContent::STEP_BEFORE_RUN, NULL); // $layoutPi->setRegionContent('MENU1',$response->getFragment('MENU1')); // $layoutPi->setRegionContent('MENU2',$response->getFragment('MENU2')); // } // else { // $weaving = System::getInstance()->getWeaving(); // if (isset($weaving['frontend']['layout']['text/html'])) // $class = $weaving['frontend']['layout']['text/html']; // else // $class = \MCMS\_\Plugin\Layout\MCMS\Layout\Layout::clazz(); // $layoutPi = new $class(); // $layout = $system->getSiteParam($siteId, '', 'layout', 'default'); // $layoutPi->load($layout); // // TODO: fix // if (isset($weaving['frontend']['menu'])) // $class = $weaving['frontend']['menu']; // else // $class = \MCMS\_\Plugin\Content\MCMS\MainMenu\MainMenu::clazz(); // $menu = new $class(); // $response = new Response(); // $menu->run($response, iPlugInContent::STEP_BEFORE_RUN, NULL); // $layoutPi->setRegionContent('MENU1',$response->getFragment('MENU1')); // } // $layoutPi->setRegionContent('HEAD', $this->buildHTMLHeadArea()); // $layoutPi->setRegionContent('CONTENT', $content); // unset($content); // $this->response->appendContent($layoutPi->getDocument()); } else { $content = $this->response->getFragment('CONTENT'); // $type = $this->response->getType(); // if (empty($type)) // $content = ''.$content.''; $this->response->setContent($content); } } else { // TODO: check this $content = $this->response->getContent(); if (empty($content)) $content = $this->response->getFragment('CONTENT'); // $type = $this->response->getType(); // if (empty($type)) // $content = ''.$content.''; $this->response->setContent($content); } Logger::getInstance(__CLASS__)->traceEnd(); } protected function buildHTMLHeadArea() { return 'DemoSite'; } public function doOutput() { Logger::getInstance(__CLASS__)->traceStart(); if(defined('_CRON_')) return; $system = System::getInstance(); $errors = $this->response->getErrors(); if(count($errors) > 0) { $https = array(); // errors with http codes foreach($errors as $error) { if($error['type'] == 'http') $https[] = $error; } if(count($https) > 0) { $msg = \Mammut\Protocol\HTTP\Status::getMessage($https[0]['code']); header('HTTP/1.0 ' . $https[0]['code'] . ' ' . $msg); echo '' . $https[0]['code'] . ': ' . $msg . ''; echo $https[0]['message']; if(!empty($https[0]['exception']) && defined('DEBUG')) { echo '

Debug info:

' . htmlentities($https[0]['exception']->getTraceAsString()) . '
'; } unset($https[0]); if(count($https) > 0) { echo "
"; echo "Additional errors while processing the page:
"; foreach($https as $error) echo "Code {$error['code']} (" . \Mammut\Protocol\HTTP\Status::getMessage($error['code']) . "): {$error['message']}
\n"; } echo ''; } else { if($this->response->getType()) header('Content-Type: ' . $this->response->getType()); if(!defined('_SERVICE_')) { $layout = $this->plugins['layout'][0]; $layout->setRegionContent('TITLE', $system->getSiteParam($system->getSiteId(), '', 'title', 'Unnamed Page')); $errortext = ''; $layout->setRegionContent('ERROR', $errortext); echo $layout->getDocument('error'); } else echo $this->response->getContent(); } return; } if ($red = $this->response->getRedirect()) { if (empty($red['url'])) { $url = _SELF_DEFAULT_.'?mod='.urlencode($red['instance']); if (!empty($red['view'])) $url .= '&view='.urlencode($red['view']); if (!empty($red['param'])) { foreach($red['param'] as $k => $p) $url .= '&'.urlencode($k).'='.urlencode($p); } header('Location: '.$url); } else header('Location: '.$red['url']); return; } if ($this->response->getMime()) header('Content-type: '.$this->response->getMime()); $content = $this->response->getContent(); if ($content instanceof iOutput) { ob_end_flush(); if ($this->response->getFilename()) { header('Content-disposition: attachment; filename='.$this->response->getFilename()); if (($size = $content->getSize()) > 0) header('Content-Length: ' . $size); } while (!$content->isEOF()) echo $content->read(65565); } else { if ($this->response->getFilename()) { header('Content-disposition: attachment; filename='.$this->response->getFilename()); header('Content-Length: ' . strlen($this->response->getContent())); } echo $content; } Logger::getInstance(__CLASS__)->traceEnd(); return; } public function doCleanup() { Logger::getInstance(__CLASS__)->traceStart(); parent::doCleanup(); Logger::getInstance(__CLASS__)->traceEnd(); } public function __destruct() { Logger::getInstance(__CLASS__)->traceStart(); // System::shutdown(); Logger::getInstance(__CLASS__)->traceEnd(); } }