示例#1
0
 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 showHtml($aoPages, $asAllLangs, $asDisplayLangs, $asAllClasses, $asDisplayClasses)
 {
     $this->out .= $this->tpl()->begin();
     $this->out .= $this->tpl()->filterStart($this->linkMe()) . $this->tpl()->filterLangs($asAllLangs, $asDisplayLangs) . $this->tpl()->filterClass($asAllClasses, $asDisplayClasses) . $this->tpl()->filterEnd();
     //rss link
     $sRssLink = AnwEnv::_SERVER('REQUEST_URI') . '&feed=rss2';
     $this->head($this->tpl()->headRss($sRssLink));
     $this->out .= $this->tpl()->nav($sRssLink);
     //pages list
     $this->out .= $this->tpl()->openTable();
     foreach ($aoPages as $oPage) {
         $this->out .= $this->tpl()->untranslatedPageLine($oPage);
     }
     $this->out .= $this->tpl()->closeTable();
 }
示例#3
0
/**
 * Anwiki main script.
 * @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) {
示例#4
0
 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;
 }
示例#5
0
    function showHtml($aoChanges, $amAllChangeTypes, $amDisplayChangeTypes, $asAllLangs, $asDisplayLangs, $asAllClasses, $asDisplayClasses, $nStartPrev, $nStartNext, $sTitle, $bGrouped, $oPage, $oPageGroup)
    {
        $this->out .= $this->tpl()->lastchangesHeader($sTitle);
        $sUrl = AnwEnv::_SERVER('REQUEST_URI');
        $sUrl = preg_replace("/&s=([0-9]*)/", "", $sUrl);
        //rss link
        $sRssLink = $sUrl;
        $sRssLink .= '&feed=rss2';
        //without start
        $this->head($this->tpl()->headRss($sRssLink));
        $this->out .= $this->tpl()->filterBefore($this->linkMe());
        $nPageId = $oPage ? $oPage->getId() : null;
        $nPageGroupId = $oPageGroup ? $oPageGroup->getId() : null;
        $bShowHistoryColumn = $oPage ? false : true;
        //disable filters if a page is selected
        if (!$nPageId) {
            //filter lang
            $this->out .= $this->tpl()->filterLangs($asAllLangs, $asDisplayLangs);
        }
        if (!$nPageId && !$nPageGroupId) {
            //filter contentclass
            $this->out .= $this->tpl()->filterClass($asAllClasses, $asDisplayClasses);
        }
        //filter changes types
        $this->out .= $this->tpl()->filterChangeTypes($amAllChangeTypes, $amDisplayChangeTypes);
        //display mode
        $sHistoryPageGroupLink = false;
        if ($oPage && AnwCurrentSession::isActionGlobalAllowed($this->getName())) {
            $sHistoryPageGroupLink = AnwEnv::_SERVER('REQUEST_URI');
            $sHistoryPageGroupLink = preg_replace("\$&page=([0-9]*)\$", "", $sHistoryPageGroupLink);
            $sHistoryPageGroupLink = preg_replace("\$&pagegroup=([0-9]*)\$", "", $sHistoryPageGroupLink);
            $sHistoryPageGroupLink .= '&pagegroup=' . $oPage->getPageGroup()->getId();
        }
        $this->out .= $this->tpl()->filterAfter($bGrouped, $nPageId, $nPageGroupId, $sRssLink, $sHistoryPageGroupLink);
        //nav
        $sLatestLink = "";
        $sPrevLink = "";
        if ($nStartPrev >= 0) {
            $sPrevLink = $sUrl . '&s=' . $nStartPrev;
            if ($nStartPrev > 0) {
                $sLatestLink = $sUrl . '&s=0';
            }
        }
        $sNextLink = $sUrl . '&s=' . $nStartNext;
        $this->out .= $this->tpl()->nav($sLatestLink, $sPrevLink, $sNextLink, $bShowHistoryColumn);
        foreach ($aoChanges as $i => $oChange) {
            $sType = AnwChange::changeTypei18n($oChange->getType());
            //links
            $sLnkPage = '<span class="pageid">#' . $oChange->getPageId() . '</span>';
            $sLnkDiff = '-';
            if ($oChange->activePageExists()) {
                $sLnkPage = $oChange->getActivePage()->link();
                //active link, if it exists
            }
            //diffs link
            if ($oChange->isGlobalAndViewActionAllowed('diff')) {
                if ($oChange->isDiffAvailable()) {
                    $sImgDiff = AnwUtils::xQuote(AnwUtils::pathImg("diff.gif"));
                    $sAltDiff = AnwUtils::xQuote(self::g_("change_diff_link"));
                    $sLnkDiff = AnwUtils::xQuote(AnwUtils::alink("diff", array("page" => $oChange->getPageId(), "revto" => $oChange->getChangeId())));
                    $sLnkDiff = <<<EOF
<a href="{$sLnkDiff}" title="{$sAltDiff}"><img src="{$sImgDiff}" alt="{$sAltDiff}"/></a>
EOF;
                }
            }
            //history link
            $sLnkHistory = false;
            if ($bShowHistoryColumn) {
                $sLnkHistory = " - ";
                if ($oChange->isActionAllowed('history')) {
                    $sImgHistory = AnwUtils::xQuote(AnwUtils::pathImg("history.gif"));
                    $sAltHistory = AnwUtils::xQuote($this->t_("change_history_link"));
                    $sLnkHistory = AnwUtils::xQuote(AnwUtils::alink("lastchanges", array("page" => $oChange->getPageId())));
                    $sLnkHistory = <<<EOF
<a href="{$sLnkHistory}" title="{$sAltHistory}"><img src="{$sImgHistory}" alt="{$sAltHistory}"/></a>
EOF;
                }
            }
            //revert link
            $sLnkRevert = " - ";
            if ($oChange->isGlobalAndViewActionAllowed('revert')) {
                if ($oChange->isRevertAvailable()) {
                    $sImgRevert = AnwUtils::xQuote(AnwUtils::pathImg("revert.gif"));
                    $sAltRevert = AnwUtils::xQuote(self::t_("change_revert_link"));
                    $sLnkRevert = AnwUtils::xQuote(AnwUtils::alink("revert", array("page" => $oChange->getPageId(), "revto" => $oChange->getChangeId())));
                    //we pass pageid instead of pagegroupid for better performances...
                    $sLnkRevert = <<<EOF
<a href="{$sLnkRevert}" title="{$sAltRevert}"><img src="{$sImgRevert}" alt="{$sAltRevert}"/></a>
EOF;
                }
            }
            //output
            $this->out .= $this->tpl()->lastchangesLine(Anwi18n::dateTime($oChange->getTime()), $sType, $oChange->getComment(), $oChange->getInfo(), $oChange->getUser()->getDisplayName(), $sLnkPage, $sLnkDiff, $sLnkHistory, $sLnkRevert, $oChange->getPageName(), $oChange->getPageLang());
        }
        $this->out .= $this->tpl()->lastchangesFooter();
    }
示例#6
0
<?php

//only enable a few languages for default setups
$cfg['setup']['i18n']['langs'] = array('en', 'fr');
//auto-detect setup location
$cfg['setup']['location']['urlroot'] = "http://" . AnwEnv::_SERVER("HTTP_HOST") . dirname(AnwEnv::_SERVER("PHP_SELF")) . "/";
示例#7
0
 static function detectPreferredLang()
 {
     $asAllowedLangs = AnwComponent::globalCfgLangs();
     if (AnwEnv::_SERVER("HTTP_ACCEPT_LANGUAGE")) {
         $asAcceptedLangs = explode(",", AnwEnv::_SERVER("HTTP_ACCEPT_LANGUAGE"));
         foreach ($asAcceptedLangs as $sLangItem) {
             $asLangItem = explode(';', $sLangItem);
             $sAcceptedLang = strtolower($asLangItem[0]);
             if (in_array($sAcceptedLang, $asAllowedLangs)) {
                 return $sAcceptedLang;
             }
         }
     }
     throw new AnwUnexpectedException("No preferred lang is supported");
 }