Exemplo n.º 1
0
 protected function loadData()
 {
     $manager = UpdateManager::instance();
     $this->vars['canUpdate'] = BackendAuth::getUser()->hasAccess('system.manage_updates');
     $this->vars['updates'] = $manager->check();
     $this->vars['warnings'] = $this->getSystemWarnings();
     $this->vars['coreBuild'] = Parameter::get('system::core.build');
     $this->vars['eventLog'] = EventLog::count();
     $this->vars['requestLog'] = RequestLog::count();
     $this->vars['appBirthday'] = PluginVersion::orderBy('created_at')->pluck('created_at');
 }
Exemplo n.º 2
0
 public function index_onDelete()
 {
     if (($checkedIds = post('checked')) && is_array($checkedIds) && count($checkedIds)) {
         foreach ($checkedIds as $recordId) {
             if (!($record = RequestLog::find($recordId))) {
                 continue;
             }
             $record->delete();
         }
         Flash::success(Lang::get('backend::lang.list.delete_selected_success'));
     } else {
         Flash::error(Lang::get('backend::lang.list.delete_selected_empty'));
     }
     return $this->listRefresh();
 }
Exemplo n.º 3
0
 /**
  * Finds and serves the requested page.
  * If the page cannot be found, returns the page with the URL /404.
  * If the /404 page doesn't exist, returns the system 404 page.
  * @param string $url Specifies the requested page URL.
  * If the parameter is omitted, the current URL used.
  * @return string Returns the processed page content.
  */
 public function run($url = '/')
 {
     if ($url === null) {
         $url = Request::path();
     }
     if (!strlen($url)) {
         $url = '/';
     }
     /*
      * Hidden page
      */
     $page = $this->router->findByUrl($url);
     if ($page && $page->is_hidden) {
         if (!BackendAuth::getUser()) {
             $page = null;
         }
     }
     /*
      * Maintenance mode
      */
     if (MaintenanceSettings::isConfigured() && MaintenanceSettings::get('is_enabled', false) && !BackendAuth::getUser()) {
         $page = Page::loadCached($this->theme, MaintenanceSettings::get('cms_page'));
     }
     /*
      * Extensibility
      */
     if (($event = $this->fireEvent('page.beforeDisplay', [$url, $page], true)) || ($event = Event::fire('cms.page.beforeDisplay', [$this, $url, $page], true))) {
         if ($event instanceof Page) {
             $page = $event;
         } else {
             return $event;
         }
     }
     /*
      * If the page was not found, render the 404 page - either provided by the theme or the built-in one.
      */
     if (!$page) {
         $this->setStatusCode(404);
         // Log the 404 request
         if (!App::runningUnitTests()) {
             RequestLog::add();
         }
         if (!($page = $this->router->findByUrl('/404'))) {
             return Response::make(View::make('cms::404'), $this->statusCode);
         }
     }
     /*
      * Run the page
      */
     $result = $this->runPage($page);
     /*
      * Post-processing
      */
     $result = $this->postProcessResult($page, $url, $result);
     /*
      * Extensibility
      */
     if (($event = $this->fireEvent('page.display', [$url, $page, $result], true)) || ($event = Event::fire('cms.page.display', [$this, $url, $page, $result], true))) {
         return $event;
     }
     if (!is_string($result)) {
         return $result;
     }
     return Response::make($result, $this->statusCode);
 }
Exemplo n.º 4
0
 /**
  * Finds and serves the requested page.
  * If the page cannot be found, returns the page with the URL /404.
  * If the /404 page doesn't exist, returns the system 404 page.
  * @param string $url Specifies the requested page URL.
  * If the parameter is omitted, the current URL used.
  * @return string Returns the processed page content.
  */
 public function run($url = '/')
 {
     if ($url === null) {
         $url = Request::path();
     }
     if (!strlen($url)) {
         $url = '/';
     }
     /*
      * Handle hidden pages
      */
     $page = $this->router->findByUrl($url);
     if ($page && $page->hidden) {
         if (!BackendAuth::getUser()) {
             $page = null;
         }
     }
     /*
      * Extensibility
      */
     if ($event = $this->fireEvent('page.beforeDisplay', [$url, $page], true)) {
         return $event;
     }
     if ($event = Event::fire('cms.page.beforeDisplay', [$this, $url, $page], true)) {
         return $event;
     }
     /*
      * If the page was not found, render the 404 page - either provided by the theme or the built-in one.
      */
     if (!$page) {
         $this->setStatusCode(404);
         // Log the 404 request
         RequestLog::add();
         if (!($page = $this->router->findByUrl('/404'))) {
             return Response::make(View::make('cms::404'), $this->statusCode);
         }
     }
     $this->page = $page;
     /*
      * If the page doesn't refer any layout, create the fallback layout.
      * Otherwise load the layout specified in the page.
      */
     if (!$page->layout) {
         $layout = Layout::initFallback($this->theme);
     } elseif (($layout = Layout::loadCached($this->theme, $page->layout)) === null) {
         throw new CmsException(Lang::get('cms::lang.layout.not_found', ['name' => $page->layout]));
     }
     $this->layout = $layout;
     /*
      * The 'this' variable is reserved for default variables.
      */
     $this->vars['this'] = ['controller' => $this, 'layout' => $this->layout, 'page' => $this->page, 'param' => $this->router->getParameters(), 'environment' => App::environment()];
     /*
      * Handle AJAX requests and execute the life cycle functions
      */
     $this->initCustomObjects();
     $this->initComponents();
     /*
      * Give the layout and page an opportunity to participate
      * after components are initialized and before AJAX is handled.
      */
     if ($this->layoutObj) {
         CmsException::mask($this->layout, 300);
         $this->layoutObj->onInit();
         CmsException::unmask();
     }
     CmsException::mask($this->page, 300);
     $this->pageObj->onInit();
     CmsException::unmask();
     /*
      * Extensibility
      */
     if ($event = $this->fireEvent('page.init', [$url, $page], true)) {
         return $event;
     }
     if ($event = Event::fire('cms.page.init', [$this, $url, $page], true)) {
         return $event;
     }
     /*
      * Execute AJAX event
      */
     if ($ajaxResponse = $this->execAjaxHandlers()) {
         return $ajaxResponse;
     }
     /*
      * Execute postback handler
      */
     if (($handler = post('_handler')) && ($handlerResponse = $this->runAjaxHandler($handler)) && $handlerResponse !== true) {
         return $handlerResponse;
     }
     /*
      * Execute page lifecycle
      */
     if ($cycleResponse = $this->execPageCycle()) {
         return $cycleResponse;
     }
     /*
      * Render the page
      */
     CmsException::mask($this->page, 400);
     $this->loader->setObject($this->page);
     $template = $this->twig->loadTemplate($this->page->getFullPath());
     $this->pageContents = $template->render($this->vars);
     CmsException::unmask();
     /*
      * Render the layout
      */
     CmsException::mask($this->layout, 400);
     $this->loader->setObject($this->layout);
     $template = $this->twig->loadTemplate($this->layout->getFullPath());
     $result = $template->render($this->vars);
     CmsException::unmask();
     /*
      * Extensibility
      */
     if ($event = $this->fireEvent('page.display', [$url, $page], true)) {
         return $event;
     }
     if ($event = Event::fire('cms.page.display', [$this, $url, $page], true)) {
         return $event;
     }
     if (!is_string($result)) {
         return $result;
     }
     return Response::make($result, $this->statusCode);
 }
Exemplo n.º 5
0
 public function onEmptyLog()
 {
     RequestLog::truncate();
     Flash::success(Lang::get('system::lang.request_log.empty_success'));
     return $this->listRefresh();
 }
Exemplo n.º 6
0
 /**
  * Create Redirects from Request Log items
  *
  * @return array
  */
 public function onCreateRedirectFromRequestLogItems()
 {
     $checkedIds = $this->getCheckedIds();
     $redirectsCreated = 0;
     foreach ($checkedIds as $checkedId) {
         /** @var RequestLog $requestLog */
         $requestLog = RequestLog::find($checkedId);
         $path = parse_url($requestLog->getAttribute('url'), PHP_URL_PATH);
         if ($path === false || $path === '/' || $path === '') {
             continue;
         }
         Redirect::create(['match_type' => Redirect::TYPE_EXACT, 'target_type' => Redirect::TARGET_TYPE_PATH_URL, 'from_url' => $path, 'to_url' => '/', 'status_code' => 301, 'is_enabled' => false]);
         $redirectsCreated++;
     }
     if ((bool) Request::get('andDelete', false)) {
         RequestLog::destroy($checkedIds);
     }
     if ($redirectsCreated > 0) {
         Event::fire('redirects.changed');
         Flash::success(Lang::get('adrenth.redirect::lang.flash.success_created_redirects', ['count' => $redirectsCreated]));
     }
     return $this->listRefresh();
 }