Exemplo n.º 1
0
 function debugHtml()
 {
     $sHtml = "<li>AnwDiffKept : ";
     $sHtml .= htmlentities(AnwUtils::xmlDumpNode($this->getNode()));
     $sHtml .= "</li>";
     return $sHtml;
 }
Exemplo n.º 2
0
 private function showLoginForm($sLogin, $sUrlRedirect, $bRememberMe, $sError = false)
 {
     //display login form
     $sFormAction = AnwUtils::alink("login");
     $this->out .= $this->tpl()->loginForm($sFormAction, $sLogin, $sUrlRedirect, $bRememberMe, AnwSessions::isResumeEnabled(), $sError);
     $this->headJsOnload($this->tpl()->loginFormJs());
 }
Exemplo n.º 3
0
 function availableTranslationsRow($oPage)
 {
     $sName = $oPage->getName();
     $sUrl = AnwUtils::link($oPage);
     $sStyle = "background:url('" . Anwi18n::srcFlag($oPage->getLang()) . "') no-repeat left;";
     $HTML = "<a href=\"" . $this->xQuote($sUrl) . "\" style=\"{$sStyle}\">" . $this->xText($sName) . "</a>";
     return $HTML;
 }
Exemplo n.º 4
0
 function run()
 {
     $sDirToDelete = $this->getActionInstall()->getMyComponentPathDefault();
     $sLinkHome = AnwUtils::link(AnwComponent::globalCfgHomePage());
     $sLinkEditConfig = AnwUtils::alink('editconfig');
     $sWebsite = '<a href="' . ANWIKI_WEBSITE . '" target="_blank">' . ANWIKI_WEBSITE . '</a>';
     $this->out .= $this->tpl()->showFinished($sDirToDelete, $sLinkHome, $sLinkEditConfig, $sWebsite);
     //lock install
     $asInstallInfo = array('install_timehuman' => date("Y-m-d H:i:s"), 'install_time' => time(), 'install_version_id' => ANWIKI_VERSION_ID, 'install_version_name' => ANWIKI_VERSION_NAME);
     AnwUtils::putFileSerializedObject(ANWIKI_INSTALL_LOCK, $asInstallInfo);
 }
Exemplo n.º 5
0
 function debugHtml()
 {
     $sHtml = "<li>AnwDiffMoved : ";
     if ($this->getMovedNode()) {
         $sHtml .= htmlentities(AnwUtils::xmlDumpNode($this->getMovedNode()));
     } else {
         $sHtml .= "***NOT SET***";
     }
     $sHtml .= "(was " . htmlentities(AnwUtils::xmlDumpNode($this->getDiffDeleted()->getNode())) . ")";
     $sHtml .= "</li>";
     return $sHtml;
 }
Exemplo n.º 6
0
    function showStart($sLinkContinue, $sWebsite)
    {
        $sStartLabel = AnwUtils::xQuote($this->t_("start_go"));
        $HTML = <<<EOF

<div class="explain">
\t{$this->t_("start_explain_p1")}<br/>
\t{$this->t_("start_explain_p2")}<br/><br/>
\t{$this->t_("start_explain_p3", array('website' => $sWebsite))}<br/><br/>
\t<input type="button" class="insubmit inbuttonbig" value="{$sStartLabel} &gt;&gt;" onclick="window.location.href='{$this->escapeQuoteApostrophe($sLinkContinue)}'"/>  
</div>
EOF;
        return $HTML;
    }
Exemplo n.º 7
0
    function editConfigLayout($sLinkRefresh, $aaConfigurableComponents, $sHtmlContent)
    {
        $HTML = <<<EOF

\t<div id="listconfigurables">
\t\t<div id="refreshcomponentslist"><a href="{$this->xQuote($sLinkRefresh)}">{$this->t_("refreshcomponents_redirect_link")}</a></div>
\t\t
\t\t<ul>
EOF;
        foreach ($aaConfigurableComponents as $mComponentType => $asComponents) {
            $HTML .= <<<EOF
\t\t<li><label>{$this->xText($mComponentType)}</label>
\t\t\t<ul>
EOF;
            $asComponentsEnabled = array();
            $asComponentsDisabled = array();
            foreach ($asComponents as $sComponent) {
                if (AnwComponent::isComponentEnabled($sComponent, $mComponentType)) {
                    $asComponentsEnabled[] = $sComponent;
                } else {
                    $asComponentsDisabled[] = $sComponent;
                }
            }
            foreach ($asComponentsEnabled as $sComponent) {
                $sLink = AnwUtils::aLink("editconfig", array("c" => $sComponent, "t" => $mComponentType));
                $HTML .= <<<EOF
\t\t\t<li class="active"><a href="{$this->xQuote($sLink)}">{$this->xText($sComponent)}</a></li>
EOF;
            }
            foreach ($asComponentsDisabled as $sComponent) {
                $sLink = AnwUtils::aLink("editconfig", array("c" => $sComponent, "t" => $mComponentType));
                $HTML .= <<<EOF
\t\t\t<li class="inactive"><a href="{$this->xQuote($sLink)}">{$this->xText($sComponent)}</a></li>
EOF;
            }
            $HTML .= <<<EOF
\t\t\t</ul>
EOF;
        }
        $HTML .= <<<EOF
\t
\t\t</ul>
\t</div>
\t<div id="editconfigurable">
\t\t{$sHtmlContent}
\t</div>
EOF;
        return $HTML;
    }
Exemplo n.º 8
0
 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();
 }
Exemplo n.º 9
0
 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);
 }
Exemplo n.º 10
0
    function alreadyInstalled($sLinkHome, $sLinkForce, $sFileLock, $sFileStatus)
    {
        $sGoHomeLabel = AnwUtils::xQuote($this->t_("alreadyinstalled_go_home"));
        $sGoForceLabel = AnwUtils::xQuote($this->t_("alreadyinstalled_go_force"));
        $HTML = <<<EOF

<h1>{$this->t_('alreadyinstalled_t')}</h1>
<div class="explain">
\t{$this->t_('alreadyinstalled_explain_p1')}<br/><br/>
\t{$this->t_('alreadyinstalled_explain_p2')}<br/>
\t<ul>
\t\t<li>{$sFileLock}</li>
\t</ul>
\t<br/>
\t{$this->t_('alreadyinstalled_explain_p3')}<br/><br/>
\t<input type="button" class="inabort inbuttonbig" value="&lt;&lt; {$sGoHomeLabel}" onclick="window.location.href='{$this->escapeQuoteApostrophe($sLinkHome)}'"/>
\t<input type="button" class="insubmit inbuttonbig" value="{$sGoForceLabel} &gt;&gt;" onclick="window.location.href='{$this->escapeQuoteApostrophe($sLinkForce)}'"/>
</div>
EOF;
        return $HTML;
    }
Exemplo n.º 11
0
    function pingInfo($sTarget)
    {
        $sPingYesLabel = AnwUtils::xQuote($this->t_("ping_yes_go"));
        $sPingNoLabel = AnwUtils::xQuote($this->t_("ping_no_go"));
        $HTML = <<<EOF

<div class="explain">
\t{$this->t_("ping_explain")}<br/>
</div>

<table style="width:100%">
<tr>
<td style="width:50%; padding:2em; vertical-align:top;">
<h2>{$this->t_("ping_yes_t")}</h2>
\t<form method="post" action="{$sTarget}">
\t\t<div style="text-align:center">
\t\t\t<input type="hidden" name="ping" value="yes"/>
\t\t\t<input type="checkbox" name="countincr" value="1" id="countincr" checked="checked" disabled="disabled"/><label for="countincr">{$this->t_("ping_yes_countincr_checkbox")} <span style="font-size:0.8em">({$this->t_("ping_yes_countincr_checkbox_info")})</span></label><br/>
\t\t\t<input type="checkbox" name="addindirectory" value="1" id="addindirectory"/><label for="addindirectory">{$this->t_("ping_yes_directory_checkbox")} <span style="font-size:0.8em">({$this->t_("ping_yes_directory_checkbox_info")})</span></label><br/>
\t\t\t<input type="submit" class="insubmit inbuttonbig" value="{$sPingYesLabel} &gt;&gt;"/>
\t\t</div>
\t</form>
</td>

<td style="width:50%; padding:1em; vertical-align:top;">
<h2>{$this->t_("ping_no_t")}</h2>
\t<form method="post" action="{$sTarget}">
\t\t<div style="text-align:center">
\t\t\t<input type="hidden" name="ping" value="no"/>
\t\t\t<input type="submit" class="inbutton inbuttonbig" value="{$sPingNoLabel} &gt;&gt;"/>
\t\t</div>
\t</form>
</td>
</tr>
</table>
EOF;
        return $HTML;
    }
Exemplo n.º 12
0
    function managementHome($aoManagementNavEntries)
    {
        $HTML = <<<EOF

\t<h1>{$this->t_('title')}</h1>
\t<div class="explain">
\t\t{$this->t_('explain')}
\t</div>
EOF;
        foreach ($aoManagementNavEntries as $oEntry) {
            $sLink = $oEntry->getLink();
            $sTitle = $oEntry->getTitle();
            $sDescription = $oEntry->getDescription();
            $sImg = $oEntry->getImg() ? '<img src="' . AnwUtils::xQuote($sImg) . '"/>' : '';
            $HTML .= <<<EOF

\t<div style="float:left;width:45%; margin:2%;">
\t\t<h2><a href="{$this->xQuote($sLink)}" style="color:#000; text-decoration:none;">{$sImg}{$this->xText($sTitle)}</a></h2>
\t\t<p>{$this->xText($sDescription)}</p>
\t</div>
EOF;
        }
        return $HTML;
    }
Exemplo n.º 13
0
 private function doRevert($oPageGroup, $aaRevertPlan)
 {
     $nTime = time();
     // simulation
     $aoAllFutureContents = array();
     foreach ($aaRevertPlan['REVERT'] as $aoRevertPages) {
         $oPageCurrent = $aoRevertPages[0];
         $oPageForRevert = $aoRevertPages[1];
         if (isset($aoAllFutureContents[$oPageForRevert->getLang()])) {
             throw new AnwUnexpectedException("already have a content for this lang");
         }
         $aoAllFutureContents[$oPageForRevert->getLang()] = $oPageForRevert->getContent();
     }
     foreach ($aaRevertPlan['RESTORE'] as $oPageForRestore) {
         if (isset($aoAllFutureContents[$oPageForRestore->getLang()])) {
             throw new AnwUnexpectedException("already have a content for this lang");
         }
         $aoAllFutureContents[$oPageForRestore->getLang()] = $oPageForRestore->getContent();
     }
     foreach ($aaRevertPlan['KEEP'] as $oPageKept) {
         if (isset($aoAllFutureContents[$oPageKept->getLang()])) {
             throw new AnwUnexpectedException("already have a content for this lang");
         }
         $aoAllFutureContents[$oPageKept->getLang()] = $oPageKept->getContent();
     }
     // make sure that everything is in order... (or throws an exception)
     AnwPage::checkSimilarContents($aoAllFutureContents);
     // now, apply changes
     AnwStorage::transactionStart();
     try {
         //important, firstly delete pages which needs it, to avoid conflicts when reverting or creating pages
         foreach ($aaRevertPlan['DELETE'] as $oPageForDelete) {
             $sChangeComment = "delete for revert";
             $oPageForDelete->delete($nTime, $sChangeComment);
         }
         foreach ($aaRevertPlan['REVERT'] as $aoRevertPages) {
             $oPageCurrent = $aoRevertPages[0];
             $oPageForRevert = $aoRevertPages[1];
             $sChangeComment = "revert to old revision";
             $oPageCurrent->revertToRevision($oPageForRevert, $nTime, $sChangeComment);
         }
         foreach ($aaRevertPlan['RESTORE'] as $oPageForRestore) {
             $sChangeComment = "restore for revert";
             $oPageForRestore->restoreArchive($nTime, $sChangeComment);
         }
         AnwStorage::transactionCommit();
     } catch (AnwException $e) {
         AnwStorage::transactionRollback();
         throw $e;
     }
     // redirect to reverted page if possible
     $oPageGroup->refresh();
     if (count($oPageGroup->getPages()) > 0) {
         $oPageRedirect = $oPageGroup->getPreferedPage();
         AnwUtils::redirect(AnwUtils::link($oPageRedirect));
     } else {
         // no page available, go home
         AnwUtils::redirect();
     }
 }
Exemplo n.º 14
0
 static function reportError($oException, $nErrorNumber = null)
 {
     if (AnwComponent::globalCfgReportFileEnabled() || AnwComponent::globalCfgReportMailEnabled()) {
         if (!$nErrorNumber) {
             $nErrorNumber = time();
         }
         $sExceptionName = get_class($oException);
         $sExceptionMessage = $oException->getMessage();
         self::log("=== exception " . $sExceptionName . " - logged as error #" . $nErrorNumber . " : " . $sExceptionMessage);
         self::endLog();
         $sLoggedStr = "\n\n";
         $sLoggedStr .= "********* BEGIN ERROR LOG #" . $nErrorNumber . "*********\n";
         $sLoggedStr .= "Date : " . date("Y-m-d H:i:s") . "\n";
         $sLoggedStr .= "Exception : " . $sExceptionName . "\n";
         $sLoggedStr .= "Message : " . $sExceptionMessage . "\n";
         $sLoggedStr .= "Stack trace below :\n";
         $sLoggedStr .= " * File " . $oException->getFile() . ", line " . $oException->getLine() . "\n";
         $asTrace = $oException->getTrace();
         foreach ($asTrace as $sTrace) {
             $sLoggedStr .= ' * ';
             if (isset($sTrace['class'])) {
                 $sLoggedStr .= $sTrace['class'];
             }
             if (isset($sTrace['type'])) {
                 $sLoggedStr .= $sTrace['type'];
             }
             $sLoggedStr .= $sTrace['function'];
             //hide args for security reasons
             if (is_array(@$sTrace['args'])) {
                 foreach ($sTrace['args'] as $i => $sArg) {
                     $sTrace['args'][$i] = 'p' . ($i + 1);
                     //$sTrace['args'][$i] = serialize($sArg);
                 }
                 $sLoggedStr .= '(' . implode($sTrace['args'], ", ") . ') - ';
             }
             $sLoggedStr .= 'File ' . @$sTrace['file'] . ', line ' . @$sTrace['line'];
             $sLoggedStr .= "\n";
         }
         $sLoggedStr .= "Execution log below :\n\n";
         $sLoggedStr .= implode("\n", self::$log) . "\n";
         $sLoggedStr .= "********* END ERROR LOG #" . $nErrorNumber . " *********\n";
         if (AnwComponent::globalCfgReportFileEnabled()) {
             try {
                 AnwUtils::file_put_contents(ANWPATH_ERRORLOG, $sLoggedStr, LOCK_EX | FILE_APPEND);
             } catch (AnwException $e) {
             }
         }
         if (AnwComponent::globalCfgReportMailEnabled()) {
             $sSubject = AnwComponent::g_("err_mailreport_subject", array("errornumber" => $nErrorNumber));
             $sBody = AnwComponent::g_("err_mailreport_body", array("website" => AnwComponent::globalCfgWebsiteName()));
             $sBody .= "\n\n" . $sLoggedStr;
             $asEmail = AnwComponent::globalCfgReportMailAddresses();
             foreach ($asEmail as $sEmail) {
                 AnwUtils::mail($sEmail, $sSubject, $sBody);
             }
         }
         return $nErrorNumber;
     }
     return false;
 }
Exemplo n.º 15
0
 static function getCachedActionsMapping()
 {
     $sCacheFile = self::filenameCachedActionsMapping();
     if (!file_exists($sCacheFile)) {
         throw new AnwCacheNotFoundException();
     }
     //mapping must be newer than enabled-plugins-settings
     try {
         if (filemtime($sCacheFile) < filemtime(AnwUtils::getFileOverride("global.cfg.php", AnwComponent::getGlobalComponentFullDir()))) {
             self::debug("cachedActionsMapping obsoleted by settings");
             throw new AnwCacheNotFoundException();
         }
     } catch (AnwFileNotFoundException $e) {
     }
     //no override config
     //mapping must be newer than each available action
     $asEnabledActions = AnwComponent::getAvailableComponents(AnwComponent::TYPE_ACTION);
     foreach ($asEnabledActions as $sEnabledAction) {
         $asActionsFilesLocations = array();
         $sActionFile = 'action_' . $sEnabledAction . '.php';
         $sActionDir = AnwAction::getComponentDir($sEnabledAction);
         list($sFileActionDefault, $null) = AnwUtils::getFileDefault($sActionFile, $sActionDir);
         $asActionsFilesLocations[] = $sFileActionDefault;
         try {
             $sFileActionOverride = AnwUtils::getFileOverride($sActionDir, $sActionDir);
             $asActionsFilesLocations[] = $sFileActionOverride;
         } catch (AnwFileNotFoundException $e) {
         }
         //no override config
         foreach ($asActionsFilesLocations as $sActionFileLocation) {
             if (file_exists($sActionFileLocation) && filemtime($sCacheFile) < filemtime($sActionFileLocation)) {
                 self::debug("cachedActionsMapping obsoleted by action : " . $sEnabledAction);
                 throw new AnwCacheNotFoundException();
             }
         }
     }
     //load it from cache
     $oObject = (array) self::getCachedObject($sCacheFile);
     if (!is_array($oObject)) {
         self::debug("cachedActionsMapping invalid : " . $sCacheFile);
         throw new AnwCacheNotFoundException();
     } else {
         self::debug("cachedActionsMapping found : " . $sCacheFile);
     }
     return $oObject;
 }
Exemplo n.º 16
0
 function output()
 {
     $sOut = "";
     switch ($this->getType()) {
         case self::TYPE_RSS1:
             $sOut .= '<?xml version="1.0"?>' . "\n";
             $sOut .= '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:co="http://purl.org/rss/1.0/modules/company/" xmlns:ti="http://purl.org/rss/1.0/modules/textinput/" xmlns="http://purl.org/rss/1.0/"> ' . "\n";
             $sOut .= '<channel rdf:about="<![CDATA[' . $this->sUrl . ']]>">' . "\n";
             $sOut .= "<title><![CDATA[" . $this->sTitle . "]]></title>\n";
             $sOut .= "<link><![CDATA[" . $this->sLink . "]]></link>\n";
             $sOut .= "<description><![CDATA[" . $this->sDescription . "]]></description>\n";
             $sOut .= "</channel>\n";
             $sOut .= "<items>\n";
             $sOut .= "<rdf:Seq>\n";
             foreach ($this->aoItems as $oItem) {
                 $sOut .= '<rdf:li resource="' . $oItem->getLink() . '" />' . "\n";
             }
             $sOut .= "</rdf:Seq>\n";
             $sOut .= "</items>\n";
             foreach ($this->aoItems as $oItem) {
                 $sOut .= "<item>\n";
                 $sOut .= "<title><![CDATA[" . $oItem->getTitle() . "]]></title>\n";
                 $sOut .= "<link><![CDATA[" . $oItem->getLink() . "]]></link>\n";
                 $sOut .= "<dc:description><![CDATA[" . $oItem->getDescription() . "]]></dc:description>\n";
                 if ($oItem->getDate()) {
                     $sOut .= "<dc:date>" . date("Y-m-d\\TH:i:sP", $oItem->getDate()) . "</dc:date>\n";
                 }
                 $sOut .= "</item>\n";
             }
             $sOut .= "</rdf:RDF>";
             break;
         case self::TYPE_RSS2:
             $sOut .= '<?xml version="1.0"?>' . "\n";
             $sOut .= '<rss version="2.0">' . "\n";
             $sOut .= "<channel>\n";
             $sOut .= "<title><![CDATA[" . $this->sTitle . "]]></title>\n";
             $sOut .= "<link><![CDATA[" . $this->sLink . "]]></link>\n";
             $sOut .= "<description><![CDATA[" . $this->sDescription . "]]></description>\n";
             foreach ($this->aoItems as $oItem) {
                 $sOut .= "<item>\n";
                 $sOut .= "<title><![CDATA[" . $oItem->getTitle() . "]]></title>\n";
                 $sOut .= "<link><![CDATA[" . $oItem->getLink() . "]]></link>\n";
                 $sOut .= "<author><![CDATA[" . $oItem->getAuthor() . "]]></author>\n";
                 $sOut .= "<description><![CDATA[" . $oItem->getDescription() . "]]></description>\n";
                 if ($oItem->getDate()) {
                     $sOut .= "<pubDate>" . date("D, d M Y H:i:s e", $oItem->getDate()) . "</pubDate>\n";
                 }
                 $sOut .= "</item>\n";
             }
             $sOut .= "</channel>\n";
             $sOut .= "</rss>";
             break;
     }
     $sOut = AnwUtils::stripUntr($sOut);
     //do output
     header("Content-type: application/rss+xml; charset=UTF-8");
     print $sOut;
     exit;
 }
Exemplo n.º 17
0
 static function getNewSessionId()
 {
     //generate a session ID hard to predict
     return AnwUtils::genStrongRandMd5();
 }
Exemplo n.º 18
0
 static function clearCache()
 {
     $sCacheFile = self::filenameCachedComponentsMapping();
     AnwUtils::unlink($sCacheFile, ANWPATH_CACHESYSTEM);
 }
Exemplo n.º 19
0
 private function exportData($aaExportPageGroups)
 {
     $oDoc = new DOMDocument("1.0", "UTF-8");
     //put information as comment
     $sComment = "";
     $sComment .= $this->t_("xmlcomment_info") . "\n";
     $sComment .= ANWIKI_WEBSITE . "\n\n";
     $sComment .= $this->t_("xmlcomment_time", array("time" => Anwi18n::dateTime(time()))) . "\n";
     $sComment .= $this->t_("xmlcomment_version", array("version" => ANWIKI_VERSION_NAME)) . "\n";
     $sComment .= $this->t_("xmlcomment_user", array("user" => AnwCurrentSession::getUser()->getLogin())) . "\n";
     $sComment .= $this->t_("xmlcomment_from", array("url" => self::globalCfgUrlRoot())) . "\n\n";
     $sComment .= $this->t_("xmlcomment_contents") . "\n";
     //list exported contents as comment
     foreach ($aaExportPageGroups as $amPageGroup) {
         foreach ($amPageGroup['PAGES'] as $oPage) {
             $sPageTime = Anwi18n::dateTime($oPage->getTime());
             $sComment .= ' * ' . $oPage->getName() . " (" . $oPage->getLang() . ") (" . $sPageTime . ")\n";
         }
     }
     $sCommentSeparator = "\n**************************************************\n";
     $sComment = " " . $sCommentSeparator . $sComment . $sCommentSeparator . " ";
     $oCommentNode = $oDoc->createComment($sComment);
     $oDoc->appendChild($oCommentNode);
     //end comment
     //<anwexport time="" origin="">
     $oRootNode = $oDoc->createElement(self::XMLTAG_ROOT);
     $oRootNode->setAttribute("time", time());
     $oRootNode->setAttribute("from", AnwXml::xmlFileAttributeEncode(self::globalCfgUrlRoot()));
     $oRootNode->setAttribute("version_id", ANWIKI_VERSION_ID);
     $oRootNode->setAttribute("version_name", AnwXml::xmlFileAttributeEncode(ANWIKI_VERSION_NAME));
     $oDoc->appendChild($oRootNode);
     foreach ($aaExportPageGroups as $amPageGroup) {
         $oPageGroup = $amPageGroup['GROUP'];
         $sContentClassName = $oPageGroup->getContentClass()->getName();
         //<anwpagegroup>
         $oPageGroupNode = $oDoc->createElement(self::XMLTAG_PAGEGROUP);
         $oPageGroupNode->setAttribute("contentclass", AnwXml::xmlFileAttributeEncode($sContentClassName));
         foreach ($amPageGroup['PAGES'] as $oPage) {
             //add comment
             $sPageTime = Anwi18n::dateTime($oPage->getTime());
             $sComment = $oPage->getName() . " (" . $oPage->getLang() . ") (" . $sPageTime . ") (" . $oPageGroup->getContentClass()->getLabel() . "/" . $sContentClassName . ")";
             //$sComment = " \n*\n* ".$sComment."\n*\n ";
             $sCommentSeparator = "\n**************************************************\n";
             $sComment = " \n\n" . $sCommentSeparator . $sComment . $sCommentSeparator . " ";
             $oCommentNode = $oDoc->createComment($sComment);
             $oPageGroupNode->appendChild($oCommentNode);
             //end comment
             //using a CDATA node to preserve source breaklines :-)
             //$sPageContent = $oPage->getContent()->toXml();
             //$oPageContentNode = $oDoc->createCDATASection($sPageContent);
             $oContentNodeDoc = $oPage->getContent()->toXml()->documentElement;
             //here we got a <doc> node
             $oPageContentNodeDoc = $oDoc->importNode($oContentNodeDoc, true);
             //<anwpage name="" lang="" time="">
             $oPageNode = $oDoc->createElement(self::XMLTAG_PAGE);
             $oPageNode->setAttribute("name", AnwXml::xmlFileAttributeEncode($oPage->getName()));
             $oPageNode->setAttribute("lang", AnwXml::xmlFileAttributeEncode($oPage->getLang()));
             $oPageNode->setAttribute("time", $oPage->getTime());
             //we need to do this to squeeze the unwanted <doc> node in
             //WARNING - special loop ! childs are getting modified...
             while ($oChildNode = $oPageContentNodeDoc->childNodes->item(0)) {
                 $oPageNode->appendChild($oChildNode);
             }
             $oPageGroupNode->appendChild($oPageNode);
         }
         $oRootNode->appendChild($oPageGroupNode);
     }
     $sReturn = AnwUtils::xmlDumpNode($oRootNode);
     // even if final XML structure may be broken due to undeclared namespaces used in content,
     // we let raw content as it is for better compatibility in later versions.
     // $sReturn = AnwXml::prepareXmlValueToXml($sReturn);
     return $sReturn;
 }
Exemplo n.º 20
0
 protected function saveEditionForm()
 {
     try {
         //save changes
         $this->getEditionForm()->saveEdition();
         //update step status
         $this->getActionInstall()->updateStepStatusNext();
         //redirect
         AnwUtils::redirect($this->linkStepNext());
     } catch (AnwStructuredContentEditionFormException $e) {
         $sError = $e->getMessage();
         $this->showEditionForm($sError);
     }
 }
Exemplo n.º 21
0
 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);
     }
 }
Exemplo n.º 22
0
 private static function cleanPost($sReturn, $bSkipTrim = false)
 {
     if (get_magic_quotes_gpc()) {
         $sReturn = stripslashes($sReturn);
     }
     if (!$bSkipTrim) {
         $sReturn = trim($sReturn);
     }
     $sReturn = AnwUtils::standardizeCRLF($sReturn);
     return $sReturn;
 }
Exemplo n.º 23
0
 private static function cbk_vhook_outputhtml_clean_body_html($asMatches)
 {
     $sHtmlOnly = $asMatches[1];
     $sHtmlOnly = self::cleanBodyHtmlRenderTranslatableAttributes($sHtmlOnly);
     $sHtmlOnly = self::cleanHtmlCloseEndTags($sHtmlOnly);
     $sHtmlOnly = AnwUtils::renderUntr($sHtmlOnly);
     $sHtmlOnly = AnwPlugins::vhook('outputhtml_clean_body_html', $sHtmlOnly);
     $sHtmlOnly = '?>' . $sHtmlOnly . '<?';
     return $sHtmlOnly;
 }
Exemplo n.º 24
0
 function renderAdditionalEditInput($sSuffix, $oContentParent)
 {
     AnwUtils::checkFriendAccess("AnwStructuredContent");
     if (!$this->isMultiple()) {
         throw new AnwUnexpectedException("JS_AddMultipleContentField on non multiple field");
     }
     //temporary disable collapsing
     self::setDoCollapsing(false);
     $nNewSuffixNumber = AnwUtils::genUniqueIdNumeric();
     $sDefaultValue = null;
     if ($this instanceof AnwStructuredContentField_composed) {
         $sNewSuffix = $this->updateSuffix($sSuffix, $nNewSuffixNumber);
         $oSubContent = $oContentParent->newContent($this);
         $sSubRender = $oSubContent->renderEditHtmlForm(false, "", $sNewSuffix);
         $sDefaultValue = array(AnwStructuredContent::IDX_SUBCONTENT => $oSubContent, AnwStructuredContent::IDX_RENDERED => $sSubRender);
     } else {
         $aoValuesTmp = $this->getDefaultValues();
         // in two lines for avoiding php warning
         $sDefaultValue = array_pop($aoValuesTmp);
         //TODO ??
     }
     $sHtmlRender = $this->renderEditInputN($sSuffix, $sDefaultValue, $nNewSuffixNumber);
     //enable collapsing again
     self::setDoCollapsing(true);
     return $sHtmlRender;
 }
Exemplo n.º 25
0
 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)));
     }
 }
Exemplo n.º 26
0
 * @package Anwiki
 * @version $Id: index.php 350 2010-12-12 22:12:07Z anw $
 * @copyright 2007-2009 Antoine Walter
 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License 3
 */
try {
    //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");
    }
    /**
     * Render all instances of a multiple contentfield.
     */
    function doRenderEditInputs($oContentField, $amValues, $sSuffix)
    {
        //special case for _renderedAsMultiple
        if ($oContentField instanceof AnwStructuredContentField_renderedAsMultiple) {
            //same code as multiplicity_single
            if ($oContentField instanceof AnwStructuredContentField_composed) {
                $sSuffix = $oContentField->updateSuffix($sSuffix);
                //update suffix
            }
            $HTML = $oContentField->getRenderedEditInput($amValues, $sSuffix, 0);
            return $HTML;
        }
        $sDivId = "instance_" . $oContentField->getInputName($sSuffix);
        $sContentFieldName = $oContentField->getName();
        $sInstancesClass = "instance_" . $oContentField->getInputName($sSuffix);
        $sIsSortable = $this->isSortable() ? 'true' : 'false';
        $JS = <<<EOF

new AnwContentFieldMultiple('{$sInstancesClass}', {$this->nMin}, {$this->nMax}, \$('{$sDivId}'), '{$sSuffix}', '{$sContentFieldName}', {$sIsSortable});
EOF;
        $sHtmlRenderedInstances = "";
        foreach ($amValues as $i => $sValue) {
            $sHtmlRenderedInstances .= $oContentField->renderEditInputN($sSuffix, $sValue, $i);
        }
        $HTML = "";
        if (!$oContentField->isCollapsedChild()) {
            $sFieldName = AnwUtils::escapeApostrophe($oContentField->getName());
            $sTranslationAddButton = AnwComponent::g_editcontent("contentmultiplicity_multiple_contentfield_add", array('fieldname' => $oContentField->getFieldLabelSingle()));
            $HTML .= <<<EOF

<div class="contentfield_multiple">
\t<div id="{$sDivId}" class="contentfield_multiple_instances">
\t\t{$sHtmlRenderedInstances}
\t</div>
\t<a class="contentmultiplicity_add" href="#" onclick="AnwContentFieldMultiple.get('{$sInstancesClass}').addInstance(); return false;">{$sTranslationAddButton}</a>
</div> <!-- end contentfield_multiple -->
<script type="text/javascript">{$JS}</script>
EOF;
        } else {
            $HTML = $sHtmlRenderedInstances;
        }
        return $HTML;
    }
Exemplo n.º 28
0
 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"));
     }
 }
Exemplo n.º 29
0
 protected function getEditionForm()
 {
     if (!$this->oEditionForm) {
         $sTarget = AnwUtils::link($this->getoPage(), $this->getName());
         $this->oEditionForm = new AnwStructuredContentEditionFormPage($this->getoPage()->getContent(), $sTarget);
     }
     return $this->oEditionForm;
 }
Exemplo n.º 30
0
 function debugHtml()
 {
     $sHtml = "<li>AnwDiffDeleted : ";
     if ($this->getMovedDiff()) {
         $sHtml .= "[MOVED]";
     }
     if ($this->hasSubMovedDiff()) {
         $sHtml .= "(*) ";
     }
     $sHtml .= htmlentities(AnwUtils::xmlDumpNode($this->getNode()));
     if ($this->hasSubDeletedDiffs()) {
         $sHtml .= '<ul>Subdeleted:';
         $aoSubDiffs = $this->getSubDeletedDiffs();
         foreach ($aoSubDiffs as $oSubDiff) {
             $sHtml .= $oSubDiff->debugHtml();
         }
         $sHtml .= '</ul>';
     }
     $sHtml .= "</li>";
     return $sHtml;
 }