示例#1
0
 public function shouldLogQueries(Request $request)
 {
     $th = Core::make('helper/text');
     foreach ($this->excludedPaths as $path) {
         if ($th->fnmatch($path, $request->getPath())) {
             return false;
         }
     }
     return true;
 }
 /**
  * If we haven't installed and we're not looking at the install directory, redirect.
  *
  * @param Application $app
  * @param Request $request
  *
  * @return null|Response
  */
 private function checkInstall(Application $app, Request $request)
 {
     if (!$app->isInstalled()) {
         if (!$request->matches('/install/*') && $request->getPath() != '/install' && !$request->matches('/ccm/assets/localization/*')) {
             $manager = $app->make('Concrete\\Core\\Url\\Resolver\\Manager\\ResolverManager');
             $response = new RedirectResponse($manager->resolve(array('install')));
             return $response;
         }
     }
 }
示例#3
0
 public function setupRequestActionAndParameters(Request $request)
 {
     $requestPath = $this->getCustomRequestPath();
     if ($requestPath === null) {
         $requestPath = $request->getPath();
     }
     $task = substr($requestPath, strlen($this->c->getCollectionPath()) + 1);
     $task = str_replace('-/', '', $task);
     $taskparts = explode('/', $task);
     if (isset($taskparts[0]) && $taskparts[0] !== '') {
         $method = $taskparts[0];
     } elseif (is_object($this->c) && is_callable(array($this, $this->c->getCollectionHandle()))) {
         $method = $this->c->getCollectionHandle();
     } else {
         $method = 'view';
     }
     $foundTask = false;
     $restrictedControllers = array('Concrete\\Core\\Controller\\Controller', 'Concrete\\Core\\Controller\\AbstractController', 'Concrete\\Core\\Page\\Controller\\PageController');
     try {
         $r = new \ReflectionMethod(get_class($this), $method);
         $cl = $r->getDeclaringClass();
         if (is_object($cl)) {
             if (!in_array($cl->getName(), $restrictedControllers) && strpos($method, 'on_') !== 0 && strpos($method, '__') !== 0 && $r->isPublic() && !$r->isConstructor() && (is_array($this->restrictedMethods) && !in_array($method, $this->restrictedMethods))) {
                 $foundTask = true;
             }
         }
     } catch (\Exception $e) {
     }
     if ($foundTask) {
         $this->action = $method;
         if (isset($taskparts[1])) {
             array_shift($taskparts);
             $this->parameters = $taskparts;
         }
     } else {
         $this->action = 'view';
         if ($taskparts[0] !== '') {
             $this->parameters = $taskparts;
         }
     }
 }
 private function collectionNotFound(Collection $collection, Request $request, array $headers)
 {
     // if we don't have a path and we're doing cID, then this automatically fires a 404.
     if (!$request->getPath() && $request->get('cID')) {
         return $this->notFound('', Response::HTTP_NOT_FOUND, $headers);
     }
     // let's test to see if this is, in fact, the home page,
     // and we're routing arguments onto it (which is screwing up the path.)
     $home = Page::getByID(HOME_CID);
     $request->setCurrentPage($home);
     $homeController = $home->getPageController();
     $homeController->setupRequestActionAndParameters($request);
     $response = $homeController->validateRequest();
     if ($response instanceof \Symfony\Component\HttpFoundation\Response) {
         return $response;
     } elseif ($response === true) {
         return $this->controller($homeController);
     } else {
         return $this->notFound('', Response::HTTP_NOT_FOUND, $headers);
     }
 }
示例#5
0
 /**
  * Returns the full path for a request.
  *
  * @return string
  */
 public function getPath()
 {
     return parent::getPath();
 }