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); } }
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 getValuesFromPost($sInputName) { $asValues = AnwEnv::_POST($sInputName, array()); foreach ($asValues as $i => $sValue) { $asValues[$i] = $this->cleanValueFromPost($sValue); } return $asValues; }
function run() { // load CSS $this->head($this->getCssSrcComponent(self::CSS_FILENAME)); $this->setTitle($this->t_("title")); if (!AnwEnv::_POST("exportpages")) { $this->exportForm(); } else { $this->exportProcess(AnwEnv::_POST("exportpages")); } }
function __construct($sFeedType = "", $sFeedTitle, $sFeedLink, $sFeedDescription = "") { if (in_array($sFeedType, self::getTypes())) { $this->sType = $sFeedType; } else { $this->sType = self::TYPE_DEFAULT; } $this->sTitle = $sFeedTitle; $this->sLink = $sFeedLink; $this->sUrl = AnwEnv::_SERVER('REQUEST_URI'); $this->sDescription = $sFeedDescription; }
function run() { $this->lockPageForEdition(AnwLock::TYPE_PAGEGROUP); $this->setTitle($this->t_('title', array("pagename" => $this->getPageName()))); //decide what to do if (AnwEnv::_POST("abort")) { $this->abortChangeLang(); } else { if (AnwEnv::_POST("newlang") && AnwEnv::_POST("newlang") != $this->getoPage()->getLang()) { $this->doChangeLang(AnwEnv::_POST("newlang", ""), AnwEnv::_POST("comment", "")); } else { $this->changeLangForm(AnwEnv::_POST("newlang", $this->getoPage()->getLang()), AnwEnv::_POST("comment", "")); } } }
function run() { $this->lockPageForEdition(AnwLock::TYPE_PAGEGROUP); $this->setTitle($this->t_('title', array('pagename' => $this->getPageName()))); //decide what to do if (AnwEnv::_POST("abort")) { $this->abortRename(); } else { if (AnwEnv::_POST("newname") && AnwEnv::_POST("newname") != $this->getoPage()->getName()) { $this->doRename(AnwEnv::_POST("newname", ""), AnwEnv::_POST("comment", ""), (bool) AnwEnv::_POST("updatelinks", true)); } else { $this->renameForm(AnwEnv::_POST("newname", $this->getoPage()->getName()), AnwEnv::_POST("comment", "")); } } }
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() { if (!self::globalCfgUsersRegisterEnabled()) { AnwUtils::redirect(); } $this->setTitle($this->t_('title')); $sError = false; $sLogin = ""; $sDisplayName = ""; $sEmail = ""; if (AnwEnv::_POST("submit")) { $sLogin = AnwEnv::_POST("login", ""); $sDisplayName = AnwEnv::_POST("displayname", ""); $sEmail = AnwEnv::_POST("email", ""); $sPassword = AnwEnv::_POST("password", ""); //try to register try { $this->checkCaptcha(); $sLang = AnwCurrentSession::getLang(); $nTimezone = AnwCurrentSession::getTimezone(); $oUser = AnwUsers::createUser($sLogin, $sDisplayName, $sEmail, $sLang, $nTimezone, $sPassword); AnwCurrentSession::login($sLogin, $sPassword, false); //open a public time-limited session $this->redirectInfo(false, $this->t_("t_created"), $this->t_("p_created")); } catch (AnwLoginAlreadyTakenException $e) { $sError = $this->g_("err_loginalreadytaken"); } catch (AnwBadLoginException $e) { $sError = $this->g_("err_badlogin"); } catch (AnwDisplayNameAlreadyTakenException $e) { $sError = $this->g_("err_displaynamealreadytaken"); } catch (AnwBadDisplayNameException $e) { $sError = $this->g_("err_baddisplayname"); } catch (AnwEmailAlreadyTakenException $e) { $sError = $this->g_("err_emailalreadytaken"); } catch (AnwBadEmailException $e) { $sError = $this->g_("err_bademail"); } catch (AnwBadPasswordException $e) { $sError = $this->g_("err_badpassword"); } catch (AnwBadCaptchaException $e) { $sError = $this->g_("err_badcaptcha"); } } //display register form $this->out .= $this->tpl()->registerForm(AnwUtils::alink("register"), $sLogin, $sDisplayName, $sEmail, $sError); }
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")); } } }
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; }
static function cacheSymlink($sTarget, $sSymlink, $sSafeTestRootDirectory, $bUnlinkIfExists = true) { if (AnwEnv::hasSymLink()) { // linux way AnwUtils::symlink($sTarget, $sSymlink, $sSafeTestRootDirectory, $bUnlinkIfExists); } else { // windows way // only copy files, we don't need to copy subfolders because they are only read from the cache bygroup AnwUtils::copyDirFiles($sTarget, $sSymlink, $bUnlinkIfExists); } }
private static function endLog() { //benchmark if (self::$afBenchmarksSums['GLOBAL'] == 0) { self::stopBench("GLOBAL"); } $fSum = 0; foreach (self::$afBenchmarksSums as $sName => $fElapsedTime) { $fSum += $fElapsedTime; self::log('(benchmark) SUM : ' . $sName . ' = ' . round($fElapsedTime, 3) . ' sec'); } self::log('(benchmark) SUMS TOTAL : ' . round($fSum, 3) . ' sec'); self::log('Memory Usage : ' . self::getMemoryUsage() . ' MB'); //context AnwEnv::writeDebug(); }
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); }
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(); } }
private function saveTranslation() { try { $asAvailableLangs = $this->getoPage()->getPageGroup()->getAvailableLangs(); //check permissions : translate foreach ($asAvailableLangs as $sLang) { if (AnwEnv::_POST($this->getChkName($sLang))) { $sTranslationName = AnwEnv::_POST($this->getInputName($sLang), ""); if (!AnwCurrentSession::isActionAllowed($sTranslationName, 'translate', $sLang)) { throw new AnwAclException("permission translate denied"); } } } $oPageTranslation = null; AnwStorage::transactionStart(); try { foreach ($asAvailableLangs as $sLang) { if (AnwEnv::_POST($this->getChkName($sLang))) { $sTranslationName = AnwEnv::_POST($this->getInputName($sLang), ""); //create translation $oPageTranslation = $this->getoPage()->createNewTranslation($sTranslationName, $sLang); } } AnwStorage::transactionCommit(); } catch (AnwException $e) { AnwStorage::transactionRollback(); throw $e; } if ($oPageTranslation) { // redirect to last created translation AnwUtils::redirect(AnwUtils::link($oPageTranslation)); } else { // no translation was created, show form again $this->showForm(); } } catch (AnwBadPageNameException $e) { $this->showForm($this->g_("err_badpagename")); } catch (AnwBadLangException $e) { $this->showForm($this->g_("err_badlang")); } catch (AnwPageAlreadyExistsException $e) { $this->showForm($this->g_("err_pagealreadyexists")); } catch (AnwAclException $e) { $this->showForm($this->g_("err_nopermission")); } catch (AnwLangExistsForPageGroupException $e) { $this->showForm($this->g_("err_langexistsforpagegroup")); } }
static function g_err_need_write_file($sFileName) { return AnwComponent::g_("err_need_write_file", array('filename' => $sFileName, 'processuser' => AnwEnv::getProcessUser(), 'processgroup' => AnwEnv::getProcessGroup())); }
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(); }
static function getIp() { // hardcoded IP for batch mode if (ANWIKI_MODE_BATCH) { return "127.0.0.1"; } //discover client IPs $asFoundIps = array(); //don't look at proxy fields as it can easily be spoofed /* if ($bLookForProxy) { $asFoundIps = array_reverse( explode(',', AnwEnv::_SERVER('HTTP_X_FORWARDED_FOR')) ); $asFoundIps[] = AnwEnv::_SERVER('HTTP_CLIENT_IP'); $asFoundIps[] = AnwEnv::_SERVER('HTTP_PROXY_USER'); } */ $asFoundIps[] = AnwEnv::_SERVER('REMOTE_ADDR'); //pick up the first valid IP $sValidIp = null; foreach ($asFoundIps as $sFoundIp) { $sFoundIp = trim($sFoundIp); if (self::isValidIp($sFoundIp)) { $sValidIp = $sFoundIp; } } if (!$sValidIp) { AnwDieCriticalError("Unable to determine your IP address"); } return $sValidIp; }
private function updateSettings() { //update prefs $asErrorsPrefs = array(); try { $sLang = AnwEnv::_POST("lang", ""); AnwCurrentSession::setLang($sLang); $nTimezone = AnwEnv::_POST("timezone", 0); AnwCurrentSession::setTimezone($nTimezone); } catch (AnwBadLangException $e) { $asErrorsPrefs[] = $this->g_("err_badlang"); } catch (AnwBadTimezoneException $e) { $asErrorsPrefs[] = $this->g_("err_badtimezone"); } catch (AnwException $e) { $asErrorsPrefs[] = $this->g_("err_unkn"); } $asErrorsAccount = array(); if (AnwCurrentSession::isLoggedIn() && AnwUsers::isDriverInternal()) { //update account try { //displayname change requested ? if (self::globalCfgUsersChangeDisplayname()) { $sDisplayname = AnwEnv::_POST("displayname", ""); if (AnwCurrentSession::getUser()->getDisplayName() != $sDisplayname) { AnwCurrentSession::getUser()->changeDisplayName($sDisplayname); } } //email change requested ? $sEmail = AnwEnv::_POST("email", ""); if (AnwCurrentSession::getUser()->getEmail() != $sEmail) { AnwCurrentSession::getUser()->changeEmail($sEmail); } //password change requested ? $sNewPassword = AnwEnv::_POST("newpassword"); $sNewPasswordRepeat = AnwEnv::_POST("newpassword_repeat"); $sCurrentPassword = AnwEnv::_POST("currentpassword", ""); if ($sNewPassword) { if ($sNewPassword == $sNewPasswordRepeat) { try { //authenticate with current password AnwCurrentSession::getUser()->authenticate($sCurrentPassword); //authentication ok, change the password try { AnwCurrentSession::getUser()->changePassword($sNewPassword); } catch (AnwBadPasswordException $e) { $asErrorsAccount[] = $this->t_("err_badnewpassword"); } } catch (AnwBadPasswordException $e) { $asErrorsAccount[] = $this->g_("err_incorrectpassword"); } catch (AnwAuthException $e) { $asErrorsAccount[] = $this->g_("err_incorrectpassword"); } } else { $asErrorsAccount[] = $this->g_("err_passwordsmatch"); } } } catch (AnwDisplayNameAlreadyTakenException $e) { $asErrorsAccount[] = $this->g_("err_displaynamealreadytaken"); } catch (AnwBadDisplayNameException $e) { $asErrorsAccount[] = $this->g_("err_baddisplayname"); } catch (AnwEmailAlreadyTakenException $e) { $asErrorsAccount[] = $this->g_("err_emailalreadytaken"); } catch (AnwBadEmailException $e) { $asErrorsAccount[] = $this->g_("err_bademail"); } catch (AnwException $e) { $asErrorsAccount[] = $this->g_("err_unkn"); } } if (count($asErrorsPrefs) > 0 || count($asErrorsAccount) > 0) { $this->formSettings(false, $asErrorsPrefs, $asErrorsAccount); } else { AnwUtils::redirect($this->linkMe(array("done" => 1))); } }
static function globalCfgSymlinksRelative() { if (!AnwEnv::hasSymlink()) { return false; } $amCfgSetup = self::getGlobalComponent()->cfg(AnwComponentGlobal_global::CFG_SYSTEM); $sCfgValue = $amCfgSetup[AnwISettings_globalSystem::FIELD_CACHE][AnwISettings_globalSystemCache::FIELD_SYMLINKS_RELATIVE]; return $sCfgValue; }
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); }
static function getIp() { // no IP available in batch mode // AnwEnv will return hardcoded IP 127.0.0.1 by recognizing ANWIKI_MODE_BATCH return AnwEnv::getIp(); }
protected function saveEdition($sComment, $nDraftTime) { try { //check captcha if ($this->needsCaptcha()) { $this->checkCaptcha(); } //update content from post $oEditContent = $this->getEditionForm()->updateContentFromEdition(); //save changes $this->getoPage()->saveEditAndDeploy($oEditContent, AnwChange::TYPE_PAGE_EDITION, $sComment); //delete old draft /*if ($nDraftTime) { $oDraft = $this->getoPage()->getDraft($nDraftTime); $oDraft->delete(); }*/ //unlock $this->unlockPageForEdition(); //redirect AnwUtils::redirect(AnwUtils::link($this->getoPage())); } catch (AnwStructuredContentEditionFormException $e) { $sError = $e->getMessage(); $this->editForm($sComment, AnwEnv::_POST("draft"), $sError); } catch (AnwBadCaptchaException $e) { $sError = $this->g_("err_badcaptcha"); $this->editForm($sComment, AnwEnv::_POST("draft"), $sError); } catch (AnwBadCommentException $e) { $sError = $this->g_("err_badcomment"); $this->editForm($sComment, AnwEnv::_POST("draft"), $sError); } catch (AnwUnexpectedException $e) { $sError = $this->g_("err_ex_unexpected_p"); $nErrorNumber = AnwDebug::reportError($e); if ($nErrorNumber) { $sError .= '<br/>' . $this->g_("err_ex_report", array("errornumber" => $nErrorNumber)); } $this->editForm($sComment, AnwEnv::_POST("draft"), $sError); } }
//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) {