Exemplo n.º 1
0
 public function cleanupOldFiles()
 {
     $_SESSION['DB_DONE'] = true;
     $cleanupList = array_merge($this->pluginFinder->getDummyPlugins(), $this->filesFinder->getCleanupFiles());
     $this->cleanupMedia();
     if (count($cleanupList) == 0) {
         $_SESSION['CLEANUP_DONE'] = true;
         $this->response->redirect($this->app->urlFor('done'));
     }
     if ($this->request->isPost()) {
         $result = [];
         foreach ($cleanupList as $path) {
             $result = array_merge($result, Utils::cleanPath($path));
         }
         if (count($result) == 0) {
             $_SESSION['CLEANUP_DONE'] = true;
             $this->response->redirect($this->app->urlFor('done'));
         } else {
             $result = array_map(function ($path) {
                 return substr($path, strlen(SW_PATH) + 1);
             }, $result);
             $this->app->render('cleanup.php', ['cleanupList' => $result, 'error' => true]);
         }
     } else {
         $cleanupList = array_map(function ($path) {
             return substr($path, strlen(SW_PATH) + 1);
         }, $cleanupList);
         $this->app->render('cleanup.php', ['cleanupList' => $cleanupList, 'error' => false]);
     }
 }
Exemplo n.º 2
0
 /**
  * Call
  *
  * This method finds and iterates all route objects that match the current request URI.
  */
 public function call()
 {
     try {
         if (isset($this->environment['slim.flash'])) {
             $this->view()->setData('flash', $this->environment['slim.flash']);
         }
         $this->applyHook('slim.before');
         ob_start();
         $this->applyHook('slim.before.router');
         $dispatched = false;
         $httpMethodsAllowed = array();
         $this->router->setResourceUri($this->request->getResourceUri());
         $this->router->getMatchedRoutes();
         foreach ($this->router as $route) {
             if ($route->supportsHttpMethod($this->environment['REQUEST_METHOD'])) {
                 try {
                     $this->applyHook('slim.before.dispatch');
                     $dispatched = $this->router->dispatch($route);
                     $this->applyHook('slim.after.dispatch');
                     if ($dispatched) {
                         break;
                     }
                 } catch (\Slim\Exception\Pass $e) {
                     continue;
                 }
             } else {
                 $httpMethodsAllowed = array_merge($httpMethodsAllowed, $route->getHttpMethods());
             }
         }
         if (!$dispatched) {
             if ($httpMethodsAllowed) {
                 $this->response['Allow'] = implode(' ', $httpMethodsAllowed);
                 $this->halt(405, 'HTTP method not allowed for the requested resource. Use one of these instead: ' . implode(', ', $httpMethodsAllowed));
             } else {
                 $this->notFound();
             }
         }
         $this->applyHook('slim.after.router');
         $this->stop();
     } catch (\Slim\Exception\Stop $e) {
         $this->response()->write(ob_get_clean());
         $this->applyHook('slim.after');
     } catch (\Slim\Exception\RequestSlash $e) {
         $this->response->redirect($this->request->getPath() . '/', 301);
     } catch (\Exception $e) {
         if ($this->config('debug')) {
             throw $e;
         } else {
             try {
                 $this->error($e);
             } catch (\Slim\Exception\Stop $e) {
                 // Do nothing
             }
         }
     }
 }
 /**
  * Redirect
  *
  * This method immediately redirects to a new URL. By default,
  * this issues a 302 Found response; this is considered the default
  * generic redirect response. You may also specify another valid
  * 3xx status code if you want. This method will automatically set the
  * HTTP Location header for you using the URL parameter.
  *
  * @param  string   $url        The destination URL
  * @param  int      $status     The HTTP redirect status code (optional)
  */
 public function redirect($url, $status = 302)
 {
     $this->response->redirect($url, $status);
     $this->halt($status);
 }
Exemplo n.º 4
0
 /**
  * [redirect description]
  *
  * @param string  $url    [description]
  * @param integer $status [description]
  *
  * @return [type] [description]
  */
 public function redirect($url = ':self', $status = 302)
 {
     $scheme = parse_url($url, PHP_URL_SCHEME);
     if (isset($scheme)) {
         return parent::redirect($url, $status);
     }
     if ($url === ':self') {
         $app = \Slim\Slim::getInstance();
         $url = $app->request->getResourceUri();
     }
     $url = \Bono\Helper\URL::site($url);
     return parent::redirect($url, $status);
 }