private function getOutput() { if (!AnwEnv::_GET("outputname") || !AnwEnv::_GET("outputlang")) { return self::ERR_BADCALL; } $sOutput = ""; try { //fake current page $_GET[AnwActionPage::GET_PAGENAME] = AnwEnv::_GET("outputcurrent"); $sPageName = AnwEnv::_GET("outputname"); if (substr($sPageName, 0, 1) == '/') { $sPageName = substr($sPageName, 1); } $sPageLang = AnwEnv::_GET("outputlang"); //additionnal permissions check if (!AnwCurrentSession::isActionAllowed($sPageName, 'output', $sPageLang)) { return self::ERR_ACLS; } //get page execution result $bAutoLoadTranslatedPage = true; $bUseCache = false; //TODO? $sCacheKey = ""; //"currentpage-".AnwActionPage::getCurrentPageName(); $sOutput = AnWiki::includePage($sPageName, $sPageLang, $bAutoLoadTranslatedPage, $bUseCache, $sCacheKey); } catch (AnwPageNotFoundException $e) { $sOutput = self::ERR_NOTFOUND; } catch (AnwAclException $e) { $sOutput = self::ERR_ACLS; } catch (AnwException $e) { $sOutput = self::ERR_UNKNOWN; } return $sOutput; }
function run() { $sError = false; $this->setTitle($this->t_('title')); if (AnwEnv::_POST("submit")) { $sLogin = AnwEnv::_POST("login", ""); $sPassword = AnwEnv::_POST("password", ""); $bRememberMe = AnwSessions::isResumeEnabled() && AnwEnv::_POST("remember") ? true : false; $sUrlRedirect = AnwEnv::_POST("redirect", ""); try { //try to authenticate and open the session AnwCurrentSession::login($sLogin, $sPassword, $bRememberMe); $this->redirectInfo($sUrlRedirect, $this->t_("t_loggedin"), $this->t_("p_loggedin")); } catch (AnwAuthException $e) { $sError = $this->g_("err_auth"); } catch (AnwBadLoginException $e) { $sError = $this->g_("err_badlogin"); } catch (AnwBadPasswordException $e) { $sError = $this->g_("err_badpassword"); } //error occurred, display again the login form $this->showLoginForm($sLogin, $sUrlRedirect, $bRememberMe, $sError); } else { //arriving on the form $this->showLoginForm("", AnwEnv::_GET("redirect", ""), false); } }
function run() { $this->setTitle($this->t_('title')); if (AnwEnv::_POST("addlang")) { $this->saveTranslations(AnwEnv::_POST("addlang")); } else { $this->showForm(AnwEnv::_GET("addlang", "")); } }
function run() { $this->setTitle($this->t_("title")); if (AnwEnv::_POST("submit")) { $this->updateSettings(); } else { $this->formSettings(AnwEnv::_GET("done")); } }
function run() { if ($this->getoPage()->exists()) { AnwUtils::redirect(AnwUtils::link($this->getoPage())); } if (AnwEnv::_POST("lang") && AnwEnv::_POST("contentclass")) { $this->createPageProcess(AnwEnv::_POST("lang"), AnwEnv::_POST("contentclass")); } else { $this->createForm(AnwEnv::_GET("lang")); } }
function run() { loadApp($this->getMyComponentPathDefault() . 'class_stepinstall.php'); //make sure it's not already installed if (file_exists(ANWIKI_INSTALL_LOCK)) { $sLinkHome = AnwUtils::link(AnwComponent::globalCfgHomePage()); $sLinkForce = AnwStepInstall::linkStep(AnwStepInstall::getStepDefault()); $this->out .= $this->tpl()->alreadyInstalled($sLinkHome, $sLinkForce, ANWIKI_INSTALL_LOCK, ANWIKI_INSTALL_STATUS); return; } //make sure writable dir is writable if (!file_exists(ANWIKI_INSTALL_STATUS)) { @touch(ANWIKI_INSTALL_STATUS); } if (!is_writable(ANWPATH_WRITABLE) || !is_writable(ANWIKI_INSTALL_STATUS)) { $this->out .= $this->tpl()->error($this->t_("err_notwritable_directory_explain", array('directory' => '<br/>' . ANWPATH_WRITABLE)), $this->t_("err_notwritable_t")); return; } //security define('ANWIKI_IN_INSTALL', true); //read next step $nCurrentStepStatus = self::getCurrentStepStatus(); self::debug("current step status: " . $nCurrentStepStatus); //find step to execute $nStepOrder = (int) AnwEnv::_GET("step", AnwEnv::_POST("step", $nCurrentStepStatus)); //do not go to next steps if previous steps were not completed if ($nStepOrder > $nCurrentStepStatus) { $nStepOrder = $nCurrentStepStatus; } //make sure step exists try { $sStepName = AnwStepInstall::getStepForOrder($nStepOrder); } catch (AnwException $e) { $nStepOrder = $nCurrentStepStatus; $sStepName = AnwStepInstall::getStepForOrder($nStepOrder); } //load the step $this->oStepInstall = AnwStepInstall::loadComponent($sStepName); AnwStepInstall::setActionInstall($this); $nCountSteps = count(AnwStepInstall::getAllSteps()); $sLinkPrevious = $this->oStepInstall->linkStepPrevious(); $sLinkNext = $this->oStepInstall->linkStepNext(); $sTitleStep = $this->oStepInstall->getStepTitle(); $this->out .= $this->tpl()->headerInstall($sTitleStep, $nStepOrder, $nCountSteps, $sLinkPrevious, $sLinkNext); //run the step $this->out .= $this->oStepInstall->runStepInstall(); $this->out .= $this->tpl()->footerInstall($sTitleStep, $nStepOrder, $nCountSteps, $sLinkPrevious, $sLinkNext); }
function showFeed($aoPages) { $sFeedTitle = $this->t_("title") . " - " . self::globalCfgWebsiteName(); $oFeed = new AnwFeed(AnwEnv::_GET("feed"), $sFeedTitle, AnwUtils::aLinkAbsolute("untranslated")); foreach ($aoPages as $oPage) { //add to feed $sUserDisplayName = ""; $sItemTitle = '[' . $oPage->getLang() . '] ' . $oPage->getName() . ' (' . $oPage->getTranslatedPercent() . '%) - ' . Anwi18n::dateTime($oPage->getTime()); $sPageLink = AnwUtils::linkAbsolute($oPage); $oFeedItem = new AnwFeedItem($sItemTitle, $sPageLink); $oFeedItem->setDate($oPage->getTime()); $oFeedItem->setAuthor($sUserDisplayName); $oFeed->addItem($oFeedItem); } $oFeed->output(); }
function run() { if (AnwEnv::_POST("ping")) { if (AnwEnv::_POST("ping") == "yes") { $bAddInDirectory = AnwEnv::_POST("addindirectory") ? true : false; $this->doPing($bAddInDirectory); } else { $this->skipPing(); } } else { if (AnwEnv::_GET("pingdone")) { $this->pingDone(); } else { $this->showPingInfo(); } } }
function run() { //find TO revision try { //retrieve pagegroup $nPageGroupId = (int) AnwEnv::_GET("pagegroup", AnwEnv::_POST("pagegroup")); if (!$nPageGroupId) { //special case: we may have passed a pageid (ie: from lastchanges, for better performances avoiding loading pagegroup info) $nPageId = (int) AnwEnv::_GET("page"); if ($nPageId) { $oExistingPageTmp = AnwPage::getLastPageRevision($nPageId); //high queries consuming, not 100% cached... if ($oExistingPageTmp->exists()) { $nPageGroupId = $oExistingPageTmp->getPageGroup()->getId(); } unset($oExistingPageTmp); } if (!$nPageGroupId) { throw new AnwBadCallException(); } } $oPageGroup = new AnwPageGroup($nPageGroupId); if (!$oPageGroup->exists()) { throw new AnwBadCallException("pagegroup not found for revert"); } //get valid changeid $aoPageGroupChangesById = AnwStorage::getLastChanges(false, 0, null, null, null, null, $oPageGroup); $nRevToChangeId = (int) AnwEnv::_GET("revto", AnwEnv::_POST("revto")); //may be null when coming from action_revertpage if (!$nRevToChangeId || !array_key_exists($nRevToChangeId, $aoPageGroupChangesById)) { //get last changeid from this pagegroup $oChangeReference = reset($aoPageGroupChangesById); $nRevToChangeId = $oChangeReference->getChangeId(); } } catch (AnwException $e) { throw new AnwBadCallException(); } $this->setTitle($this->t_("title")); $aaRevertPlan = $this->generateRevertPlan($oPageGroup, $nRevToChangeId); if (AnwEnv::_POST("submit") && $nRevToChangeId > 0) { $this->doRevert($oPageGroup, $aaRevertPlan); } else { $this->showFormRevert($oPageGroup, $aaRevertPlan, $nRevToChangeId); } }
function run() { // load CSS $this->head($this->getCssSrcComponent(self::CSS_FILENAME)); $this->lockPageForEdition(AnwLock::TYPE_PAGEONLY); $this->getoPage()->checkPageGroupSynchronized(); //determine the Reference Page $oPageRef = $this->choosePageRef(urldecode(AnwEnv::_GET("ref"))); if (AnwEnv::_POST("save") && AnwEnv::_POST("rev")) { $this->saveTranslation(AnwEnv::_POST("rev")); } else { if (AnwEnv::_GET("abort")) { $this->abortTranslation(); } else { $this->translateForm($oPageRef); } } }
function run() { $this->setTitle($this->t_('title')); $sDeleteType = AnwEnv::_GET("t"); if (!$sDeleteType) { $this->selectDeletionType(); } else { if ($sDeleteType == self::$DELETE_PAGE) { $this->deletePage(); } else { if ($sDeleteType == self::$DELETE_GROUP) { $this->deleteGroup(); } else { $this->error($this->g_("err_badcall")); } } } }
function run() { if (AnwAcls::isDriverReadWrite()) { if (AnwEnv::_POST("submit_create") && AnwUsers::isDriverInternal()) { $this->createAndGrant(AnwEnv::_POST("login"), AnwEnv::_POST("displayname"), AnwEnv::_POST("email"), AnwEnv::_POST("password")); } else { if (AnwEnv::_POST("submit_existing")) { $this->chooseAndGrant(AnwEnv::_POST("login"), AnwEnv::_POST("password")); } else { if (AnwEnv::_GET("skipgrant")) { $this->skipGrant(); } else { $this->showChooseGrant(); } } } } else { $this->showGrantNotSupported(); } }
function run() { // load CSS $this->head($this->getCssSrcComponent(self::CSS_FILENAME)); //decide what to do if (AnwEnv::_GET("refresh")) { $this->refreshComponentsList(); } else { try { $this->oComponent = null; $this->sComponentName = strtolower(AnwEnv::_GET("c", AnwEnv::_POST("c"))); $this->sComponentType = strtolower(AnwEnv::_GET("t", AnwEnv::_POST("t"))); if ($this->sComponentName && $this->sComponentType) { try { $this->oComponent = AnwComponent::loadComponentGeneric($this->sComponentName, $this->sComponentType); } catch (AnwException $e) { } } if (!$this->oComponent) { $this->oComponent = AnwComponent::loadComponentGeneric('global', 'global'); } if (AnwEnv::_POST("publish")) { $this->saveEdition(); } else { if (AnwEnv::_GET("js") == "addmultiplecontentfield") { $sFieldName = AnwEnv::_GET("fieldname"); $sSuffix = AnwEnv::_GET("suffix"); $this->JS_AddMultipleContentField($sFieldName, $sSuffix); } else { $this->editForm(); } } } catch (AnwInvalidContentException $e) { $this->editForm($this->g_("err_contentinvalid")); } } }
function run() { // load CSS $this->head($this->getCssSrcComponent(self::CSS_FILENAME)); $this->setTitle($this->t_("title")); if (AnwEnv::_POST(self::IN_FILENAME) && AnwEnv::_POST(self::IN_PAGENAMES)) { //4) do import $bContinueOnErrors = AnwEnv::_POST(self::IN_CONTINUE_ON_ERRORS) == 'true' ? true : false; $this->doImport(AnwEnv::_POST(self::IN_FILENAME), AnwEnv::_POST(self::IN_PAGENAMES), $bContinueOnErrors); } else { if (AnwEnv::_GET(self::IN_FILENAME)) { //3) form: select pages to import $this->importSelectionForm(AnwEnv::_GET(self::IN_FILENAME), AnwEnv::_GET(self::IN_PREFIX, "")); } else { if (AnwEnv::_FILES(self::IN_UPLOAD)) { //2) do upload of an export file $this->doUpload(AnwEnv::_FILES(self::IN_UPLOAD), AnwEnv::_POST(self::IN_PREFIX, "")); } else { //1) form: upload an export file $this->uploadForm(); } } } }
protected function previewForm() { try { //check captcha if ($this->needsCaptcha()) { $this->checkCaptcha(); } //update content from post $oEditContent = $this->getEditionForm()->updateContentFromEdition(); //show again edit form on the top $this->editForm(AnwEnv::_POST("comment"), AnwEnv::_GET("draft")); //render preview try { $oHtml = $oEditContent->toHtml($this->getoPage()); $oHtml->disableCaching(); $sPreview = $oHtml->runHead() . $oHtml->runBody(); $this->out .= $this->tpl()->preview($sPreview, AnwUtils::cssViewContent($this->getoPage())); $this->headJsOnload($this->tpl()->preview_jsOnload()); } catch (AnwException $e) { $this->out .= 'error'; } } catch (AnwStructuredContentEditionFormException $e) { $sError = $e->getMessage(); $this->editForm(AnwEnv::_POST("comment"), AnwEnv::_POST("draft"), $sError); } catch (AnwBadCaptchaException $e) { $sError = $this->g_("err_badcaptcha"); $this->editForm(AnwEnv::_POST("comment"), AnwEnv::_POST("draft"), $sError); } }
function run() { try { $nPageId = (int) AnwEnv::_GET("page"); if ($nPageId <= 0) { throw new AnwBadCallException(); } //find TO revision $nRevToChangeId = (int) AnwEnv::_GET("revto"); if ($nRevToChangeId <= 0) { throw new AnwBadCallException(); } else { $oPageRevTo = AnwPage::getPageByChangeId($nPageId, $nRevToChangeId); } //find FROM revision $nRevFromChangeId = (int) AnwEnv::_GET("revfrom"); if ($nRevFromChangeId <= 0) { try { $oPageRevFrom = $oPageRevTo->getPreviousArchive(); } catch (AnwArchiveNotFoundException $e) { //if TO revision is already the last... $oPageRevFrom = $oPageRevTo; } } else { $oPageRevFrom = AnwPage::getPageByChangeId($nPageId, $nRevFromChangeId); } if (!$oPageRevTo) { throw new AnwBadCallException("page revision TO not found :" . $nRevToChangeId); } if (!$oPageRevTo->getContent() instanceof AnwContentPage) { throw new AnwUnexpectedException("error getcontent for page revision TO :" . $nRevToChangeId); } if (!$oPageRevFrom) { throw new AnwBadCallException("page revision FROM not found :" . $nRevFromChangeId); } if (!$oPageRevFrom->getContent() instanceof AnwContentPage) { throw new AnwUnexpectedException("error getcontent for page revision FROM :" . $nRevFromChangeId); } // check permissions $oPageRevFrom->checkGlobalAndViewActionAllowed($this->getName()); $oPageRevTo->checkGlobalAndViewActionAllowed($this->getName()); $oContentXmlFrom = $oPageRevFrom->getContent()->toXml(); $oContentXmlTo = $oPageRevTo->getContent()->toXml(); } catch (AnwBadPageNameException $e) { $this->error($this->g_("err_badcall")); } catch (AnwBadCallException $e) { $this->error($this->g_("err_badcall")); } catch (AnwPageNotFoundException $e) { $this->error($this->g_("err_badcall")); } catch (AnwArchiveNotFoundException $e) { $this->error($this->g_("err_badcall")); } $this->setTitle($this->t_("title", array("pagename" => $oPageRevTo->getName()))); $oDiffs = new AnwDiffs($oContentXmlFrom, $oContentXmlTo); if (!AnwCurrentSession::getUser()->isPhpEditionAllowed()) { $oDiffs->hidePhpCode(); } else { $oDiffs->showPhpCode(); } $this->out .= $this->tpl()->beforeDiffs($this->linkMe(), $oPageRevFrom, $oPageRevTo, $oPageRevTo->getActivePage()); if ($oPageRevFrom->getChangeId() == $oPageRevTo->getChangeId()) { $this->out .= $this->tpl()->drawNotice($this->t_("notice_same")); } if ($oPageRevFrom->getChangeId() > $oPageRevTo->getChangeId()) { $this->out .= $this->tpl()->drawNotice($this->t_("notice_reverse")); } $this->renderDiffs($oDiffs); }
function getCachedOutputKeyDynamic() { $sCacheKey = ""; //we need this in order to get the dynamic link "?feed=rss2" working... if (AnwEnv::_GET(self::GET_FEED) == AnwFeed::TYPE_RSS2) { $sCacheKey .= AnwFeed::TYPE_RSS2; //rss links are absolute and may be in HTTP or HTTPS, depending on protocol currently in use $sCacheKey .= "|" . (AnwEnv::isHttps() ? "HTTPS" : "HTTP"); } return $sCacheKey; }
static function testCaptcha() { //retrieve typed number $nTestedNumber = AnwEnv::_POST("captcha"); if (!$nTestedNumber) { $nTestedNumber = AnwEnv::_GET("captcha", 0); } $nTestedNumber = "{$nTestedNumber}"; //compare $bTest = AnwEnv::_SESSION(self::SESSION_CAPTCHA) && AnwEnv::_SESSION(self::SESSION_CAPTCHA) == md5($nTestedNumber); AnwEnv::unsetSession(self::SESSION_CAPTCHA); return $bTest; }
protected function filterContentClasses($asRequiredActionsAcls = array()) { $asAllClasses = self::globalCfgModulesContentClasses(); $asDisplayClasses = array(); foreach ($asAllClasses as $sClass) { if (AnwEnv::_GET("cc_" . $sClass)) { $asDisplayClasses[] = $sClass; } } return array($asAllClasses, $asDisplayClasses); }
//should we load minimal mode? if (in_array(@$_GET['a'], array('install')) || isset($_GET['anwiki_mode_minimal'])) { define('ANWIKI_MODE_MINIMAL', true); } require_once "engine.inc.php"; //install redirect if (!file_exists(ANWIKI_INSTALL_LOCK) && AnwEnv::_GET('a') != 'install') { $sUrlInstall = AnwEnv::_SERVER('SCRIPT_URI') . '?a=install'; header("Location: " . $sUrlInstall); print '<a href="' . AnwUtils::xQuote($sUrlInstall) . '">' . AnwUtils::xQuote($sUrlInstall) . '</a>'; exit; } AnwDebug::startbench("preparing action", true); //load action code try { $sAction = strtolower(AnwEnv::_GET(AnwAction::GET_ACTIONNAME, "view")); $oAction = AnwAction::loadComponent($sAction); } catch (AnwException $e) { $sAction = "view"; $oAction = AnwAction::loadComponent($sAction); } //security check if (ANWIKI_MODE_MINIMAL && !$oAction instanceof AnwActionMinimal) { AnwDieCriticalError("Unauthorized mode / bad URL"); } $oAction->setAsCurrentAction(); AnwDebug::log("Action : " . $sAction); AnwDebug::stopbench("preparing action"); //run $oAction->runAndOutput(); } catch (AnwException $e) {
function run() { if ($this->getComponentToInitialize() instanceof AnwInitializable) { if ($this->getComponentToInitialize()->isComponentInitialized()) { $this->showAlreadyInitialized(); } else { if (AnwEnv::_GET("runinit")) { $this->runInitialization(); } else { $this->showInitializationConfirm(); } } } else { //no need to configure anything $this->showNoInitializationNeeded(); } }
function showFeed($aoChanges) { $sFeedTitle = $this->t_("title") . " - " . self::globalCfgWebsiteName(); $oFeed = new AnwFeed(AnwEnv::_GET("feed"), $sFeedTitle, AnwUtils::aLinkAbsolute("lastchanges")); foreach ($aoChanges as $oChange) { $sType = AnwChange::changeTypei18n($oChange->getType()); $sPageLink = ""; if ($oChange->activePageExists()) { $oActivePage = $oChange->getActivePage(); $sPageLink = AnwUtils::linkAbsolute($oActivePage); //active link, if it exists $sPageTitle = $oActivePage->getName() . ' (' . $oActivePage->getLang() . ')'; //show old name from the change } else { $sPageTitle = '(DEL)' . $oChange->getPageName() . ' (' . $oChange->getPageLang() . ')'; } //add to feed $sUserDisplayName = $oChange->getUser()->getDisplayName(); $sItemTitle = $sPageTitle . ' - ' . $sType . ' - ' . $sUserDisplayName; $oFeedItem = new AnwFeedItem($sItemTitle, $sPageLink); $oFeedItem->setDate($oChange->getTime()); $oFeedItem->setAuthor($sUserDisplayName); $oFeed->addItem($oFeedItem); } $oFeed->output(); }
function run() { AnwCurrentSession::logout(); $sUrlRedirect = AnwEnv::_GET("redirect", false); $this->redirectInfo($sUrlRedirect, $this->t_("t_loggedout"), $this->t_("p_loggedout")); }
protected function getoPage() { if (!self::$oPage) { if (AnwEnv::_GET(self::GET_PAGENAME)) { //read pagename from env $sPageName = self::getCurrentPageName(); if (AnwPage::isValidPageName(self::getCurrentPageName())) { self::$oPage = new AnwPageByName($sPageName); } else { //warning, doing error404() here may lead to infinite recursion in some very special cases... that's why $oPage is set to the homepage here, to prevent loop. self::$oPage = new AnwPageByName(self::globalCfgHomePage()); self::error404(); } } else { //load homepage $sPageName = self::globalCfgHomePage(); self::$oPage = new AnwPageByName($sPageName); //make sure to load homepage in the session language, if available try { $sWantedLang = AnwCurrentSession::getLang(); if (self::$oPage->exists() && self::$oPage->getLang() != $sWantedLang) { $aoPages = self::$oPage->getPageGroup()->getPages(); if (isset($aoPages[$sWantedLang])) { self::$oPage = $aoPages[$sWantedLang]; self::debug("Homepage found in current session lang"); } else { self::debug("Homepage NOT found in current session lang"); } } } catch (AnwException $e) { } } } return self::$oPage; }