<?php
define("WS_ADMIN",true);
require_once( "../common/WSInit.php" );
require_once( "WikiAccess.php" );
if (!isset($args[2])) {
print "USAGE: MakePage.php <wiki> <template> <config> \n";
print " MakePage.php --post=<page> [post-options] <wiki> <template> <config> [summary]\n";
die();
}
$lang= $args[0];
$tmpl= $args[1];
$conf= $args[2];
$wiki= WikiAccess::newInstance( $lang );
$wiki->initTranslations();
ob_start();
require($conf);
require($tmpl);
$txt= ob_get_contents();
ob_end_clean();
if (@$options['post']) {
$page= $options['post'];
$summary= @$args[3];
if (!$summary) $summary= preg_replace('/\..*$/','',basename($tmpl));
$u= @$options['user'];
if (!$u) {
$u= wsfGetWikiUsers($wiki->domain);
if ($u) $u= $u[0];
}
if (!$u) die("no user found for {$wiki->domain}\n");
$userpage= $wiki->getNsText(NS_USER) . ':' . $u;
$talkpage= $wiki->getNsText(NS_USER_TALK) . ':' . $u;
$page= str_replace('{userpage}', $userpage, $page);
$page= str_replace('{usertalk}', $talkpage, $page);
foreach ($config as $k => $v) {
$page= str_replace('{'.$k.'}', $v, $page);
}
wsfLog("posting to $page: $summary", LL_INFO);
require_once('WikiBot.php');
$bot= new WikiBot($wiki);
$bot->user= @$options['user'];
$bot->password= @$options['password'];
$bot->edit( $page, $txt, $summary,
@$options['insert-before'], @$options['insert-after'], @$options['insert-replace'],
@$options['separator'] );
}
else {
print $txt;
}
$wiki->close();
?>
MakePage.php
application/x-php, 1640 bytes (load raw)

