public function display(Template $oTemplate, $bIsPreview = false)
 {
     $sValue = $this->oPage->getPagePropertyValue('redirect-location', '');
     if (is_numeric($sValue)) {
         $this->oPage = PageQuery::create()->findPk($sValue);
         LinkUtil::redirect(LinkUtil::link($this->oPage->getFullPathArray()), null, 'default', false);
     } else {
         if (!$sValue) {
             throw new Exception('Error in RedirectPageTypeModule->display(): no redirect location set');
         }
     }
     LinkUtil::redirect($sValue, false);
 }
示例#2
0
 protected function initLanguage()
 {
     $this->sOldSessionLanguage = Session::language();
     if (isset($_REQUEST[AdminManager::CONTENT_LANGUAGE_SESSION_KEY]) && LanguageQuery::languageExists($_REQUEST[AdminManager::CONTENT_LANGUAGE_SESSION_KEY])) {
         AdminManager::setContentLanguage($_REQUEST[AdminManager::CONTENT_LANGUAGE_SESSION_KEY]);
         unset($_REQUEST[AdminManager::CONTENT_LANGUAGE_SESSION_KEY]);
         LinkUtil::redirect(LinkUtil::link(Manager::getRequestedPath(), get_class()));
     } else {
         if (!LanguageQuery::languageExists(AdminManager::getContentLanguage())) {
             AdminManager::setContentLanguage($this->sOldSessionLanguage);
         }
         if (!LanguageQuery::languageExists(AdminManager::getContentLanguage())) {
             LinkUtil::redirectToManager('', "AdminManager");
         }
     }
     Session::getSession()->setLanguage(AdminManager::getContentLanguage());
 }
 public function __construct($aRequestPath)
 {
     parent::__construct($aRequestPath);
     if (!isset($this->aPath[0])) {
         // Exceptions thrown in a file module’s constructor yield a UserError but that’s OK.
         throw new Exception("Error in DisplayDocumentFileModule->__construct: no key given");
     }
     $this->oSession = Session::close();
     $this->oDocument = DocumentQuery::create()->findPk(intval($this->aPath[0]));
     if ($this->oDocument === null || $this->oDocument->getIsProtected() && !$this->isAuthenticated()) {
         $oErrorPage = PageQuery::create()->findOneByName(Settings::getSetting('error_pages', 'not_found', 'error_404'));
         if ($oErrorPage) {
             LinkUtil::redirect(LinkUtil::link($oErrorPage->getLinkArray(), "FrontendManager"));
         } else {
             print "Not found";
             exit;
         }
     }
     Session::close();
 }
示例#4
0
 public function renderFile()
 {
     $aCurrentValues = $this->oFormStorage->saveCurrentValuesToSession();
     $oFlash = Flash::getFlash();
     $oFlash->setArrayToCheck($aCurrentValues);
     $bHasCaptcha = false;
     foreach ($this->oFormStorage->getFormObjects() as $oFormObject) {
         if ($oFormObject instanceof CaptchaObject) {
             $bHasCaptcha = true;
         }
         if ($oFormObject->shouldExcludeFromReport()) {
             continue;
         }
         if ($oFormObject->isRequired()) {
             $oFlash->checkForValue($oFormObject->getName());
         }
         $oEmailItemTemplateInstance = clone $this->oEmailItemTemplate;
         $oEmailItemTemplateInstance->replaceIdentifier('name', $oFormObject->getName());
         $oEmailItemTemplateInstance->replaceIdentifier('label', $oFormObject->getLabel());
         $oEmailItemTemplateInstance->replaceIdentifier('value', $oFormObject->getCurrentValue());
         $this->oEmailTemplate->replaceIdentifierMultiple('form_content', $oEmailItemTemplateInstance);
     }
     if ($bHasCaptcha && !FormFrontendModule::validateRecaptchaInput()) {
         $oFlash->addMessage('captcha_code_required');
     }
     $oFlash->finishReporting();
     if (Flash::noErrors()) {
         $oEmail = new EMail(TranslationPeer::getString('wns.form_module.email_subject', null, null, array('page' => $this->sPageName)), $this->oEmailTemplate);
         $oEmail->addRecipient($this->sEmailAddress);
         $oEmail->send();
         $this->oFormStorage->deleteCurrentValuesFromSession();
         LinkUtil::redirect($_REQUEST['origin'] . '?form_success=true');
     } else {
         $oFlash->stick();
         LinkUtil::redirect($_REQUEST['origin']);
     }
 }
示例#5
0
 public function renderAdmin(Template $oTemplate = null)
 {
     if ($this->sModuleName === null) {
         $this->sModuleName = self::DEFAULT_MODULE;
     }
     try {
         $this->oModule = AdminModule::getModuleInstance($this->sModuleName);
     } catch (Exception $e) {
         LinkUtil::redirect(LinkUtil::link(array(self::DEFAULT_MODULE, 'module_not_found', $this->sModuleName)));
     }
     if (!Module::isModuleAllowed('admin', $this->sModuleName, Session::getSession()->getUser())) {
         LinkUtil::redirect(LinkUtil::link(array(self::DEFAULT_MODULE, 'module_denied', $this->sModuleName)));
     }
     $this->doAdmin($oTemplate);
 }
示例#6
0
 /**
  * GET method handler for directories
  *
  * This is a very simple mod_index lookalike.
  * See RFC 2518, Section 8.4 on GET/HEAD for collections
  *
  * @param	 string	 directory path
  * @return void	 function has to handle HTTP response itself
  */
 private function getDir($sFullPath, &$aOptions)
 {
     if (!StringUtil::endsWith(Manager::getOriginalPath(), '/')) {
         LinkUtil::redirect($this->_slashify(LinkUtil::link($aOptions["path"])));
     }
     // fixed width directory column format
     $format = "%15s\t %-19s\t%-s\n";
     $handle = @opendir($sFullPath);
     if (!$handle) {
         return false;
     }
     echo "<html><head><title>Index of " . htmlspecialchars($aOptions['path']) . "</title></head>\n";
     echo "<h1>Index of " . htmlspecialchars($aOptions['path']) . "</h1>\n";
     echo "<pre>";
     printf($format, "Size", "Last modified", "Filename");
     echo "<hr>";
     while ($filename = readdir($handle)) {
         if ($filename === '.') {
             continue;
         }
         if (!$this->hasReadAccess($aOptions["path"] . '/' . $filename)) {
             continue;
         }
         //Add the file
         $sSubPath = $sFullPath . "/" . $filename;
         $name = htmlspecialchars($filename);
         $name_href = htmlspecialchars(rawurlencode($filename));
         printf($format, number_format(filesize($sSubPath)), strftime("%Y-%m-%d %H:%M:%S", filemtime($sSubPath)), "<a href='{$name_href}'>{$name}</a>");
     }
     echo "</pre>";
     closedir($handle);
     echo "</html>\n";
     exit;
 }
示例#7
0
 /**
  * __construct()
  */
 public function __construct()
 {
     parent::__construct();
     $this->aPathRequestParams = array();
     $this->bIsNotFound = false;
     $this->initLanguage();
     // Find requested page
     $oRootPage = PagePeer::getRootPage();
     if ($oRootPage === null) {
         throw new Exception("No root node exists in the database. Use the admin tool to create one.");
     }
     $this->oRootNavigationItem = PageNavigationItem::navigationItemForPage($oRootPage);
     $oMatchingNavigationItem = $this->oRootNavigationItem;
     while (self::hasNextPathItem()) {
         $oNextNavigationItem = $oMatchingNavigationItem->namedChild(self::usePath(), Session::language(), false, true);
         if ($oNextNavigationItem !== null) {
             $oMatchingNavigationItem = $oNextNavigationItem;
         } else {
             self::unusePath();
             break;
         }
     }
     self::$CURRENT_NAVIGATION_ITEM = $oMatchingNavigationItem;
     $oParent = $oMatchingNavigationItem;
     while (!$oParent instanceof PageNavigationItem) {
         $oParent = $oParent->getParent();
     }
     if ($oParent !== $oMatchingNavigationItem) {
         $oParent->setCurrent(false);
     }
     self::$CURRENT_PAGE = $oParent->getMe();
     // See if the filter(s) changed anything
     FilterModule::getFilters()->handleNavigationPathFound($this->oRootNavigationItem, $oMatchingNavigationItem);
     // There may now be new, virtual navigation items. Follow them.
     while (self::hasNextPathItem()) {
         $oNextNavigationItem = $oMatchingNavigationItem->namedChild(self::usePath(), Session::language(), false, true);
         if ($oNextNavigationItem !== null) {
             $oMatchingNavigationItem = $oNextNavigationItem;
         } else {
             self::unusePath();
             break;
         }
     }
     // See if anything has changed
     if (self::$CURRENT_NAVIGATION_ITEM !== $oMatchingNavigationItem && self::$CURRENT_NAVIGATION_ITEM instanceof PageNavigationItem) {
         self::$CURRENT_NAVIGATION_ITEM->setCurrent(false);
         //It is, however, still active
     }
     self::$CURRENT_NAVIGATION_ITEM = $oMatchingNavigationItem;
     $iTimesUsed = 0;
     while (self::hasNextPathItem()) {
         $sKey = self::usePath();
         $iTimesUsed++;
         $sValue = null;
         if (self::hasNextPathItem()) {
             $sValue = self::usePath();
             $iTimesUsed++;
         }
         $this->aPathRequestParams[] = $sKey;
         if (!isset($_REQUEST[$sKey]) && $sValue !== null) {
             $_REQUEST[$sKey] = $sValue;
         }
     }
     for ($i = 1; $i <= $iTimesUsed; $i++) {
         self::unusePath();
     }
     if ($oMatchingNavigationItem->isFolder()) {
         $oFirstChild = $oMatchingNavigationItem->getFirstChild(Session::language(), false, true);
         if ($oFirstChild !== null) {
             $aAdditionalPathItems = array();
             $aRequestParams = LinkUtil::getRequestedParameters();
             foreach (self::getRequestPath() as $iKey => $sPathItem) {
                 if ($iKey % 2 === 0 && isset($aRequestParams[$sPathItem])) {
                     unset($aRequestParams[$sPathItem]);
                 }
                 $aAdditionalPathItems[] = $sPathItem;
             }
             LinkUtil::redirectToManager(array_merge($oFirstChild->getLink(), $aAdditionalPathItems), null, $aRequestParams);
         } else {
             $this->bIsNotFound = true;
         }
     }
     if ($oMatchingNavigationItem->isProtected()) {
         if (!$oMatchingNavigationItem->isAccessible()) {
             $oLoginPage = self::$CURRENT_PAGE->getLoginPage();
             if ($oLoginPage !== self::$CURRENT_PAGE) {
                 Session::getSession()->setAttribute('login_referrer_page', self::$CURRENT_PAGE);
                 Session::getSession()->setAttribute('login_referrer', LinkUtil::link($oMatchingNavigationItem->getLink(), "FrontendManager"));
             }
             if ($oLoginPage === null) {
                 LinkUtil::redirect(LinkUtil::link('', "LoginManager"));
             }
             self::$CURRENT_PAGE = $oLoginPage;
         }
     }
     FilterModule::getFilters()->handlePageHasBeenSet(self::$CURRENT_PAGE, $this->bIsNotFound, self::$CURRENT_NAVIGATION_ITEM);
 }
 private function displayEntry($oTemplate)
 {
     if ($this->oEntry === null) {
         LinkUtil::redirect(LinkUtil::link($this->oPage->getLinkArray()));
     }
     $oEntryTemplate = $this->constructTemplate('full_entry');
     if ($aLink = Session::getSession()->getAttribute(self::SESSION_LAST_OVERVIEW_ITEM_LINK)) {
         $sOverviewHref = LinkUtil::link($aLink);
     } else {
         $sOverviewHref = LinkUtil::link($this->oPage->getLink());
     }
     $oEntryTemplate->replaceIdentifier('return_to_list_view', TagWriter::quickTag('a', array('class' => 'back_to_overview', 'href' => $sOverviewHref, 'title' => TranslationPeer::getString('journal.back_to_list_view')), TranslationPeer::getString('journal.back_to_list_view')));
     $oTemplate->replaceIdentifier('container', $this->renderEntry($this->oEntry, $oEntryTemplate), $this->sContainer);
 }
 public function delete()
 {
     $aDirPermissionsGroups = DirectoryPermissionPeer::getPermissionsByFileName($this->sFilePath);
     foreach ($aDirPermissionsGroups as $oDirPermGroup) {
         $oDirPermGroup->delete();
     }
     ResourceFinder::recursiveUnlink("{$this->sWebdavBaseDirPath}/{$this->sFilePath}");
     LinkUtil::redirect($this->link());
 }
示例#10
0
 public static function login($sUserName = null, $sPassword = null, $sReferrer = '')
 {
     if ($sUserName === null) {
         $sUserName = $_POST[self::USER_NAME];
     }
     if ($sPassword === null) {
         $sPassword = $_POST[self::LOGIN_PASSWORD];
     }
     $oFlash = Flash::getFlash();
     if ($sUserName === '' || $sPassword === '') {
         $oFlash->addMessage('login.empty_fields');
         return;
     }
     $iAdminTest = Session::getSession()->login($sUserName, $sPassword);
     //User is valid
     if (($iAdminTest & Session::USER_IS_VALID) === Session::USER_IS_VALID) {
         if (isset($_REQUEST['origin'])) {
             $sReferrer = $_REQUEST['origin'];
         } else {
             if (Session::getSession()->hasAttribute('login_referrer')) {
                 $sReferrer = Session::getSession()->getAttribute('login_referrer');
                 Session::getSession()->resetAttribute('login_referrer');
             } else {
                 if (!$sReferrer) {
                     $sReferrer = LinkUtil::link(array(), 'AdminManager');
                 }
             }
         }
         if (($iAdminTest & Session::USER_IS_DEFAULT_USER) === Session::USER_IS_DEFAULT_USER) {
             Session::getSession()->setAttribute('change_password', 1);
             $sReferrer = LinkUtil::link(array('users', Session::getSession()->getUserId()), 'AdminManager');
         }
         LinkUtil::redirect($sReferrer);
     }
     //User is inactive
     if (($iAdminTest & Session::USER_IS_INACTIVE) === Session::USER_IS_INACTIVE) {
         $oFlash->addMessage('login_user_inactive');
         return;
     }
     //User is unknown
     $oFlash->addMessage('login_check_params');
     $sUsernameDefault = $sUserName;
     $sPasswordDefault = $sPassword;
     if (AdminManager::initializeFirstUserIfEmpty($sUsernameDefault, $sPasswordDefault)) {
         $oFlash->removeMessage('login_check_params');
         $oFlash->addMessage('login_welcome');
         $oFlash->addMessage('login_welcome2', array('username' => $sUsernameDefault, 'password' => $sPasswordDefault));
     }
 }
 private function handleNewJournalComment($oPage, $oEntry)
 {
     $oFlash = Flash::getFlash();
     // Validate form and create new comment and
     $oComment = new JournalComment();
     $oComment->setUsername($_POST['comment_name']);
     $oFlash->checkForValue('comment_name', 'comment_name_required');
     $oComment->setEmail($_POST['comment_email']);
     $oFlash->checkForEmail('comment_email', 'comment_email_required');
     if ($oEntry->getJournal()->getUseCaptcha() && !Session::getSession()->isAuthenticated() && !FormFrontendModule::validateRecaptchaInput() && !isset($_POST['preview'])) {
         $oFlash->addMessage('captcha_required');
     }
     $oPurifierConfig = HTMLPurifier_Config::createDefault();
     $oPurifierConfig->set('Cache.SerializerPath', MAIN_DIR . '/' . DIRNAME_GENERATED . '/' . DIRNAME_CACHES . '/purifier');
     $oPurifierConfig->set('HTML.Doctype', 'XHTML 1.0 Transitional');
     $oPurifierConfig->set('AutoFormat.AutoParagraph', true);
     $oPurifier = new HTMLPurifier($oPurifierConfig);
     $_POST['comment_text'] = $oPurifier->purify($_POST['comment_text']);
     $oComment->setText($_POST['comment_text']);
     $oFlash->checkForValue('comment_text', 'comment_required');
     $oFlash->finishReporting();
     if (isset($_POST['preview'])) {
         $oComment->setCreatedAt(date('c'));
         $_POST['preview'] = $oComment;
     } else {
         if (Flash::noErrors()) {
             $oEntry->addJournalComment($oComment);
             // Post is considered as spam
             $bIsProblablySpam = isset($_POST['important_note']) && $_POST['important_note'] != null;
             $sCommentNotificationTemplate = 'e_mail_comment_notified';
             // Prevent publication if comments are not enabled or post is spam
             if (!$oEntry->getJournal()->getEnableComments() || $bIsProblablySpam) {
                 if (!Session::getSession()->isAuthenticated()) {
                     $oComment->setIsPublished(false);
                     $sCommentNotificationTemplate = 'e_mail_comment_moderated';
                 }
             }
             $oComment->save();
             // Notify new comment
             if ($oEntry->getJournal()->getNotifyComments()) {
                 $oEmailContent = JournalPageTypeModule::templateConstruct($sCommentNotificationTemplate, $oPage->getPagePropertyValue('journal:template_set', 'default'));
                 $oEmailContent->replaceIdentifier('email', $oComment->getEmail());
                 $oEmailContent->replaceIdentifier('user', $oComment->getUsername());
                 if ($bIsProblablySpam) {
                     $oEmailContent->replaceIdentifier('this_comment_is_spam_note', TranslationPeer::getString('journal.this_comment_is_spam_note', null, null, array('important_note_content' => $_POST['important_note'])));
                 }
                 $oEmailContent->replaceIdentifier('comment', $oComment->getText());
                 $oEmailContent->replaceIdentifier('entry', $oEntry->getTitle());
                 $oEmailContent->replaceIdentifier('journal', $oEntry->getJournal()->getName());
                 $oEmailContent->replaceIdentifier('entry_link', LinkUtil::absoluteLink(LinkUtil::link($oEntry->getLink($oPage))));
                 $oEmailContent->replaceIdentifier('deactivation_link', LinkUtil::absoluteLink(LinkUtil::link(array('journal_comment_moderation', $oComment->getActivationHash(), 'deactivate'), 'FileManager'), null, LinkUtil::isSSL()));
                 $oEmailContent->replaceIdentifier('activation_link', LinkUtil::absoluteLink(LinkUtil::link(array('journal_comment_moderation', $oComment->getActivationHash(), 'activate'), 'FileManager'), null, LinkUtil::isSSL()));
                 $oEmailContent->replaceIdentifier('deletion_link', LinkUtil::absoluteLink(LinkUtil::link(array('journal_comment_moderation', $oComment->getActivationHash(), 'delete'), 'FileManager'), null, LinkUtil::isSSL()));
                 $sSubject = TranslationPeer::getString('journal.notification_subject', null, null, array('entry' => $oEntry->getTitle()));
                 $oEmail = new EMail($sSubject, $oEmailContent);
                 $oSender = $oEntry->getUserRelatedByCreatedBy();
                 $oEmail->addRecipient($oSender->getEmail(), $oSender->getFullName());
                 $oEmail->send();
             }
             $oSession = Session::getSession();
             Flash::getFlash()->unfinishReporting()->addMessage('journal.has_new_comment', array(), "journal_entry.new_comment_thank_you" . ($oEntry->getJournal()->getEnableComments() || $oSession->isAuthenticated() ? '' : '.moderated'), 'new_comment_thank_you_message', 'p')->stick();
             LinkUtil::redirect(LinkUtil::link($oEntry->getLink($oPage)) . "#comments");
         }
     }
 }