Beispiel #1
0
<?php

require_once '../../includes/siteAdmin.php';
$fileInfo = array('title' => 'Admin Tools', 'fileName' => 'admin/index.php');
$debug->newFile($fileInfo['fileName']);
$buildPage = new Adrlist_BuildPage();
$buildPage->addIncludes('adminToolsMethods.php');
$buildPage->addJs(array('adminTools.js', 'jquery/jquery.datetimepicker.js'));
$buildPage->addCss(array('jquery/jquery.datetimepicker.css'));
echo $buildPage->output(), '
<div>
	', debugSwitch(), '
</div>
<div>
	', maintSwitch(), '
</div>
<div id="listMaintHolder">
	', buildListMaint(), '
</div>
', $buildPage->buildFooter();
Beispiel #2
0
function renderXML($input, $argv, $parser)
{
    // parameters
    $feedURL = $argv["feed"];
    $escapedFeedURL = urlencode($argv["feed"]);
    $maxItems = (int) $argv["maxitems"];
    $addLineFeed = $argv["linefeed"];
    // retrieve the xml source from the cache before trying to fetch it
    // limits possible stress on other people's servers, reduces chance of DOS attacks
    global $wgMemc;
    $cachedSource = false;
    if (debugSwitch("forceload")) {
        $wgMemc->get($escapedFeedURL);
    }
    if (!$cachedSource) {
        // Uses Http::get which is the prefered method to make requests from MediaWiki since it handles going through proxies, etc.
        $timeout = 5;
        // set to zero for no timeout
        $source = Http::get($feedURL, $timeout, array(CURLOPT_FOLLOWLOCATION => 1));
        if (!$source) {
            return wfMsgExt("xml-feedfailed", array('parseinline'));
        }
        // only cache newly fetched sources
        $wgMemc->set($escapedFeedURL, $source, strtotime("+2 hour"));
    } else {
        $source = $cachedSource;
    }
    if (debugSwitch("source")) {
        echo $source . "\n";
    }
    // parse
    $feed = new XmlDocument();
    if (!$feed->parse($source)) {
        return wfMsg("xml-parseerror", $feed->getError());
    }
    // fill in the template with the fields from the xml file
    preg_match_all("#<item path=\"(.*?)\">(.*?)</item>#", filter($input), $matches);
    $result = "";
    foreach ($matches[0] as $i => $text) {
        $path = $matches[1][$i];
        $template = filter(trim(unfilter($matches[2][$i])));
        $items = $feed->getItem($path);
        $count = min(count($items), $maxItems);
        if (!$items) {
            $result .= wfMsg("xml-pathnotfound", $path);
        }
        for ($i = 0; $i < $count; ++$i) {
            $item = $items[$i];
            // fill in the template (use standard template parameter format)
            $text = $template;
            if (preg_match_all("/{{{([a-zA-Z:]*)}}}/", $text, $fields)) {
                foreach (array_unique($fields[1]) as $field) {
                    // SWC 20061113 - Broke the accessing into two lines so that it parses
                    $tempArray = $item[strtoupper($field)];
                    $currValue = implode("", $tempArray[0]);
                    $text = str_replace("{{{{$field}}}}", $currValue, $text);
                }
            }
            // conditially add a line feed to the end of each item
            if ($addLineFeed) {
                $result .= $text . "\n";
            } else {
                $result .= $text;
            }
        }
    }
    return sandboxParse($result);
}