Exemple #1
0
    public function result()
    {
        return $this->result;
    }
}
ini_set("display_errors", 1);
error_reporting(E_ALL ^ E_NOTICE);
$botuser = '******';
require_once 'botclasses.php';
require_once 'new_mediawiki.php';
require_once 'harejpass.php';
echo "Logging in...";
$wiki = new mediawiki($botuser, $botpass);
echo " done.\n";
echo "Retrieving MFD contents... ";
$page = $wiki->page("Wikipedia:Miscellany for deletion");
$mfdpage = $page->content();
preg_match_all("/\\{\\{(Wikipedia:Miscellany for deletion\\/(?!Front matter)(.*?)*)\\}\\}/i", $mfdpage, $m);
$container = new mfd_container();
// Loop through each MFD
foreach ($m[1] as $title) {
    $mfd = new mfd($title);
    $container->add($mfd);
    if ($mfd->isArchive()) {
        $origmonth = $mfd->starttime("F");
        $origyear = $mfd->starttime("Y");
        $archive = $wiki->page("Wikipedia:Miscellany for deletion/Archived debates/" . $origmonth . " " . $origyear);
        if (!$archive->exists()) {
            // Create the archive page
            $archivecontents = "";
            $days_in_month = date("t", $mfd->starttime());
Exemple #2
0
echo "Connecting to replica\n";
$replica_mycnf = parse_ini_file("/data/project/legobot/replica.my.cnf");
$replica_username = $replica_mycnf['user'];
$replica_password = $replica_mycnf['password'];
$enwikidb = new mysqli('enwiki.labsdb', $replica_username, $replica_password, 'enwiki_p');
if (mysqli_connect_errno()) {
    echo "Connection Failed: " . mysqli_connect_errno();
    die;
}
$rfcid_list = array();
// Step 1: Check for transclusions
$transclusions = $wiki->getTransclusions("Template:Rfc");
foreach ($transclusions as $page) {
    $rfcid = null;
    // Get the page content
    $page = $wiki->page($page);
    $content = $page->content();
    if (!$page->exists()) {
        $deleteId = $rfcdb->prepare("DELETE FROM `rfc` WHERE `rfc_page`=?;");
        $deleteId->bind_param("s", $page);
        $deleteId->execute();
        $deleteId->close();
        continue;
    }
    // Syntax Correction. RFC templates with common errors are corrected and then saved on the wiki.
    preg_match_all("/(\\{{2}\\s?Rfc(tag)?\\s?[^}]*\\}{2}(\n|,| )*){2,}/i", $content, $fixes);
    foreach ($fixes[0] as $fix) {
        preg_match_all("/(?=\\{{2}\\s?Rfc(tag)?\\s?\\|\\s?)[^}]*/i", $fix, $parts);
        $newtag = "";
        foreach ($parts[0] as $part) {
            $newtag .= $part . "|";
Exemple #3
0
            $frsquery4->close();
            $rfc_pool[$rfc_id]['page'] = $rfc_page;
            $rfc_pool[$rfc_id]['time'] = $timestamp;
        }
        $rfctouse = null;
        foreach ($rfc_pool as $a => $b) {
            if ($rfctouse == null) {
                $rfctouse = $a;
            } elseif ($rfc_pool[$rfctouse]['time'] > $b['time']) {
                $rfctouse = $a;
            }
        }
        echo "User:{$frs_username} RFC: " . $rfc_pool[$rfctouse]['page'] . "\n";
        if (empty($rfc_pool[$rfctouse]['page'])) {
            continue;
        }
        $frsinsert = $rfcdb->stmt_init();
        $frsinsert->prepare("INSERT INTO frs_contacts (frsc_userid,frsc_rfcid,frsc_timestamp) VALUES (?,?,?);");
        $newtime = time();
        $frsinsert->bind_param("isi", $frs_userid, $rfctouse, $newtime);
        $frsinsert->execute();
        $frsinsert->close();
        $randomuser_talkpage = $wiki->page("User talk:" . $frs_username);
        $randomuser_talkpage->resolveRedirects();
        if (substr($randomuser_talkpage, 0, strlen("User talk")) != "User talk") {
            continue;
        }
        $randomuser_talkpage->addSection("Please comment on [[" . $rfc_pool[$rfctouse]['page'] . "#rfc_" . $rfctouse . "|" . $rfc_pool[$rfctouse]['page'] . "]]", "{{subst:FRS message|title=" . $rfc_pool[$rfctouse]['page'] . "|rfcid=" . $rfctouse . "}} <!-- FRS id " . $rfcdb->insert_id . " --> ~~~~");
        sleep(5);
    }
}
Exemple #4
0
 $reviewpage_content = $wiki->getpage($reviewpage);
 if (preg_match("/'''Reviewer:''' .*?(\\[\\[User:([^|]+)\\|[^\\]]+\\]\\]).*?\\(UTC\\)/", $reviewpage_content, $reviewer)) {
     $currentNom->setReviewer($reviewer[2], str_replace("'''Reviewer:''' ", '', $reviewer[0]));
     if ($currentNom->getVar('status') == 'new') {
         $currentNom->setStatus('on review');
         $old_contents = $contents;
         // TODO: There should be a better way of doing this (i.e. once the page parser is completely written)
         $contents = str_replace("status=|", "status=onreview|", $contents);
         if (!preg_match('/\\{\\{' . preg_quote($reviewpage, '/') . '\\}\\}/i', $contents)) {
             $contents .= "\n\n{{{$reviewpage}}}";
         }
         if ($contents != $old_contents && $wiki->nobots($article, 'GA bot', $contents) == true) {
             $wiki->edit($article, $contents, "Transcluding GA review", true, true);
         }
         // Notify the nom that the page is now on review
         $noms_talk_page = $wiki2->page("User talk:" . $currentNom->getVar('nominator_plain'));
         $noms_talk_page->resolveRedirects();
         if (substr($noms_talk_page, 0, strlen("User talk")) == "User talk" && !preg_match('/\\[\\[' . preg_quote($currentNom, '/') . '\\]\\].+?' . preg_quote('<!-- Template:GANotice -->', '/') . '/', $noms_talk_page->content()) && !in_array($currentNom->getVar('reviewer'), $dontNotify)) {
             $sig = $currentNom->getVar('reviewer');
             $sig2 = "-- {{subst:user0|User={$sig}}} ~~~~~";
             $msg = "{{subst:GANotice|article={$currentNom}|days=7}} <small>Message delivered by [[User:{$botuser}|{$botuser}]], on behalf of [[User:{$sig}|{$sig}]]</small> {$sig2}";
             if ($wiki->nobots($noms_talk_page, 'GA bot', $noms_talk_page->content())) {
                 $noms_talk_page->edit($noms_talk_page->content() . "\n\n{$msg}", "/* Your [[WP:GA|GA]] nomination of [[" . $currentNom . "]] */ new section");
             }
         }
         unset($old_contents);
         // TODO: This is a lazy way of doing things, improve it
         $deleteQuery_title = $title;
         $deleteQuery->execute();
         // in case it is already defined in the db
         $insertQuery_title = $title;