public function forURL() { session_start(); /* first we find which site we're working with */ $site = $this->siteManager->get('pasted.at'); /* placeholder */ $GLOBALS['currentSite'] = $site; /* get the page name from the post data */ $pageName = $_GET['page']; $extra = false; if (strpos($pageName, '/') !== false) { $explode = explode('/', $pageName); $extra = $explode[1]; $pageName = $explode[0]; } /* if no pagename is supplied then it is presumed we want the index */ if (!isset($pageName) || empty($pageName)) { $pageName = 'index'; } if ($this->isCustomRoute($pageName, $extra)) { return; } /* if the page name starts with plugin/ then we are accessing something from the plugin dir */ if (strpos($pageName, 'plugin/') === 0) { require $pageName . '.php'; return; } /* get the page object from the page name */ $page = $site->getPage($pageName); /* if no page exists for the page name we re-direct to the 404 page */ /* otherwise we show the page that was requested */ if (isset($page) && $page !== false) { if (!$page->canView()) { return; } $GLOBALS['currentPage'] = $page; View::publishForPage(); } else { $this->throwError(404); } }