コード例 #1
0
 public function init()
 {
     parent::init();
     // If we've accessed the homepage as /home/, then we should redirect to /.
     if ($this->dataRecord && $this->dataRecord instanceof SiteTree && RootURLController::should_be_on_root($this->dataRecord) && (!isset($this->urlParams['Action']) || !$this->urlParams['Action']) && !$_POST && !$_FILES && !$this->redirectedTo()) {
         $getVars = $_GET;
         unset($getVars['url']);
         if ($getVars) {
             $url = "?" . http_build_query($getVars);
         } else {
             $url = "";
         }
         $this->redirect($url, 301);
         return;
     }
     if ($this->dataRecord) {
         $this->dataRecord->extend('contentcontrollerInit', $this);
     } else {
         singleton('SiteTree')->extend('contentcontrollerInit', $this);
     }
     if ($this->redirectedTo()) {
         return;
     }
     // Check page permissions
     if ($this->dataRecord && $this->URLSegment != 'Security' && !$this->dataRecord->canView()) {
         return Security::permissionFailure($this);
     }
     // Use theme from the site config
     if (($config = SiteConfig::current_site_config()) && $config->Theme) {
         Config::inst()->update('SSViewer', 'theme', $config->Theme);
     }
 }
コード例 #2
0
 public function init()
 {
     parent::init();
     // If we've accessed the homepage as /home/, then we should redirect to /.
     if ($this->dataRecord && $this->dataRecord instanceof SiteTree && RootURLController::should_be_on_root($this->dataRecord) && (!isset($this->urlParams['Action']) || !$this->urlParams['Action']) && !$_POST && !$_FILES && !$this->redirectedTo()) {
         $getVars = $_GET;
         unset($getVars['url']);
         if ($getVars) {
             $url = "?" . http_build_query($getVars);
         } else {
             $url = "";
         }
         $this->redirect($url, 301);
         return;
     }
     if ($this->dataRecord) {
         $this->dataRecord->extend('contentcontrollerInit', $this);
     } else {
         singleton('SiteTree')->extend('contentcontrollerInit', $this);
     }
     if ($this->redirectedTo()) {
         return;
     }
     // Check page permissions
     if ($this->dataRecord && $this->URLSegment != 'Security' && !$this->dataRecord->canView()) {
         return Security::permissionFailure($this);
     }
     // Draft/Archive security check - only CMS users should be able to look at stage/archived content
     if ($this->URLSegment != 'Security' && !Session::get('unsecuredDraftSite') && (Versioned::current_archived_date() || Versioned::current_stage() && Versioned::current_stage() != 'Live')) {
         if (!$this->dataRecord->canViewStage(Versioned::current_archived_date() ? 'Stage' : Versioned::current_stage())) {
             $link = $this->Link();
             $message = _t("ContentController.DRAFT_SITE_ACCESS_RESTRICTION", 'You must log in with your CMS password in order to view the draft or archived content. ' . '<a href="%s">Click here to go back to the published site.</a>');
             Session::clear('currentStage');
             Session::clear('archiveDate');
             $permissionMessage = sprintf(_t("ContentController.DRAFT_SITE_ACCESS_RESTRICTION", 'You must log in with your CMS password in order to view the draft or archived content. ' . '<a href="%s">Click here to go back to the published site.</a>'), Controller::join_links($this->Link(), "?stage=Live"));
             return Security::permissionFailure($this, $permissionMessage);
         }
     }
     // Use theme from the site config
     if (($config = SiteConfig::current_site_config()) && $config->Theme) {
         Config::inst()->update('SSViewer', 'theme', $config->Theme);
     }
 }
コード例 #3
0
 public function init()
 {
     parent::init();
     //Log page views
     Statistics::collect();
     // If we've accessed the homepage as /home/, then we should redirect to /.
     if ($this->dataRecord && $this->dataRecord instanceof SiteTree && RootURLController::should_be_on_root($this->dataRecord) && !$this->urlParams['Action'] && !$_POST && !$_FILES && !Director::redirected_to()) {
         $getVars = $_GET;
         unset($getVars['url']);
         if ($getVars) {
             $url = "?" . http_build_query($getVars);
         } else {
             $url = "";
         }
         Director::redirect($url);
         return;
     }
     if ($this->dataRecord) {
         $this->dataRecord->extend('contentcontrollerInit', $this);
     } else {
         singleton('SiteTree')->extend('contentcontrollerInit', $this);
     }
     if (Director::redirected_to()) {
         return;
     }
     Director::set_site_mode('site');
     // Check page permissions
     if ($this->dataRecord && $this->URLSegment != 'Security' && !$this->dataRecord->can('View')) {
         Security::permissionFailure($this);
     }
     // Draft/Archive security check - only CMS users should be able to look at stage/archived content
     if ($this->URLSegment != 'Security' && (Versioned::current_archived_date() || Versioned::current_stage() && Versioned::current_stage() != 'Live')) {
         if (!Permission::check('CMS_ACCESS_CMSMain')) {
             $link = $this->Link();
             $message = _t("ContentController.DRAFT_SITE_ACCESS_RESTRICTION", "You must log in with your CMS password in order to view the draft or archived content.  <a href=\"%s\">Click here to go back to the published site.</a>");
             Security::permissionFailure($this, sprintf($message, "{$link}?stage=Live"));
             return;
         }
     }
 }