<?php
define( 'WS_WEB', true );
require_once("common/WebInit.php");
require_once("WikiAccess.php");
#require_once("$IP/includes/GlobalFunctions.php");
function printRC($rc) {
global $wiki;
$url = $wiki->makePageLink($rc->rc_title, $rc->rc_namespace);
$name = $wiki->asPlainText($rc->rc_title);
$uurl = $wiki->makePageLink($rc->rc_user_text, NS_USER);
$uname = $wiki->asPlainText($rc->rc_user_text);
print "<li class='recentchange'>";
print "<a class='rc-page' href=\"".htmlspecialchars($url)."\">".htmlspecialchars($name)."</a>: ";
print "<i class='rc-comment'>".htmlspecialchars($rc->rc_comment)."</i> ";
print "(";
print "<a class='rc-user' href=\"".htmlspecialchars($uurl)."\">".htmlspecialchars($uname)."</a>, ";
print "<i class='rc-comment'>".htmlspecialchars(wfTimestamp(TS_DB, $rc->rc_timestamp))."</i>";
print ")";
print "</li>";
}
function httpDie($code, $msg, $text) {
header("Content-Type: text/plain",true,$code);
header("HTTP/1.0 $code $msg",true,$code);
header("Status: $code $msg",true,$code);
print "\n***************************************\n";
print "\nERROR: $code $msg\n";
print "\n$text\n";
print "\n***************************************\n";
die();
}
$domain = $wgRequest->getVal('wiki');
$num = $wgRequest->getVal('n');
$snippet = $wgRequest->getVal('snippet');
$nobot = $wgRequest->getVal('nobot');
$nominor = $wgRequest->getVal('nominor');
$noanon = $wgRequest->getVal('noanon');
$onlynew = $wgRequest->getVal('onlynew');
$ns = $wgRequest->getVal('ns');
if (!$num) $num = 5;
else $num = (int)$num;
if (!$num) $num = 5;
if ($num>100) $num = 100;
if (is_null($domain)) $go= false;
else $go= true;
header('Content-Type: text/html; charset=utf-8');
?>
<? if (!$snippet || !$go) { ?>
<html>
<head>
<title>Recent Changes</title>
</head>
<body>
<? } ?>
<?
if ($go) {
?>
<ul class="recentchanges">
<?
$wiki = WikiAccess::newInstance($domain);
if (!$wiki) httpDie(400, "Bad Request", "Unknown wiki: " . htmlspecialchars($wiki));
$cond = array(
"rc_type" => RC_EDIT,
);
if ($nobot) $cond['rc_bot'] = 0;
if ($nominor) $cond['rc_minor'] = 0;
if ($onlynew) $cond['rc_new'] = 1;
if ($noanon) $cond[] = 'rc_user != 0';
if ($ns!==NULL) $cond['rc_namespace'] = $ns;
$opt = array( "ORDER BY" => "rc_timestamp DESC", "LIMIT" => $num );
$rs = $wiki->wikiDB->select( 'recentchanges', '*', $cond, "RC", $opt );
while ($row = $wiki->wikiDB->fetchObject($rs)) {
printRC($row);
}
$wiki->wikiDB->freeResult($rs);
?>
</ul>
<?
}
else {
?>
<h1>Wiki Proxy</h1>
<form method="get" action="<?= $_SERVER['PHP_SELF']?>">
<p>Wiki: <input type='text' size='12' name='wiki' value='<?= escapeHtml($domain) ?>'/></p>
<p>Entries: <input type='text' size='6' name='num' value='<?= escapeHtml($num) ?>'/></p>
<p><input type='submit' name='go' value='Fetch'/> <input type='submit' name='meta' value='Meta'/></p>
</form>
<?
}
if (!empty($wiki)) $wiki->close();
?>
<? if (!$snippet || !$go) { ?>
</body>
</html>
<? } ?>
RC.php
application/x-php, 3157 bytes (load raw)

