Example #1
0
function addWiki($lang, $site, $dbName)
{
    global $IP, $wgLanguageNames, $wgDefaultExternalStore;
    $name = $wgLanguageNames[$lang];
    $dbw =& wfGetDB(DB_WRITE);
    $common = "/home/wikipedia/common";
    $maintenance = "{$IP}/maintenance";
    print "Creating database {$dbName} for {$lang}.{$site}\n";
    # Set up the database
    $dbw->query("SET table_type=Innodb");
    $dbw->query("CREATE DATABASE {$dbName}");
    $dbw->selectDB($dbName);
    print "Initialising tables\n";
    dbsource("{$maintenance}/tables.sql", $dbw);
    dbsource("{$IP}/extensions/OAI/update_table.sql", $dbw);
    $dbw->query("INSERT INTO site_stats(ss_row_id) VALUES (1)");
    # Initialise external storage
    if ($wgDefaultExternalStore && preg_match('!^DB://(.*)$!', $wgDefaultExternalStore, $m)) {
        print "Initialising external storage...\n";
        require_once 'ExternalStoreDB.php';
        global $wgDBuser, $wgDBpassword, $wgExternalServers;
        $cluster = $m[1];
        # Hack
        $wgExternalServers[$cluster][0]['user'] = $wgDBuser;
        $wgExternalServers[$cluster][0]['password'] = $wgDBpassword;
        $store = new ExternalStoreDB();
        $extdb =& $store->getMaster($cluster);
        $extdb->query("SET table_type=InnoDB");
        $extdb->query("CREATE DATABASE {$dbName}");
        $extdb->selectDB($dbName);
        dbsource("{$maintenance}/storage/blobs.sql", $extdb);
        $extdb->immediateCommit();
    }
    $wgTitle = Title::newMainPage();
    $wgArticle = new Article($wgTitle);
    $ucsite = ucfirst($site);
    $wgArticle->insertNewArticle("\n==This subdomain is reserved for the creation of a {$ucsite} in '''[[:en:{$name}|{$name}]]''' language==\n\nIf you can write in this language and want to collaborate in the creation of this encyclopedia then '''you''' can make it.\n\nGo ahead. Translate this page and start working on your encyclopedia.\n\nFor help, see '''[[m:Help:How to start a new Wikipedia|how to start a new Wikipedia]]'''.\n\n==Sister projects==\n[http://meta.wikipedia.org Meta-Wikipedia] | [http://www.wiktionary.org Wikitonary] | [http://www.wikibooks.org Wikibooks] | [http://www.wikinews.org Wikinews] | [http://www.wikiquote.org Wikiquote] | [http://www.wikisource.org Wikisource]\n\nSee the [http://www.wikipedia.org Wikipedia portal] for other language Wikipedias.\n\n[[aa:]]\n[[af:]]\n[[als:]]\n[[ar:]]\n[[de:]]\n[[en:]]\n[[as:]]\n[[ast:]]\n[[ay:]]\n[[az:]]\n[[be:]]\n[[bg:]]\n[[bn:]]\n[[bo:]]\n[[bs:]]\n[[cs:]]\n[[co:]]\n[[cs:]]\n[[cy:]]\n[[da:]]\n[[el:]]\n[[eo:]]\n[[es:]]\n[[et:]]\n[[eu:]]\n[[fa:]]\n[[fi:]]\n[[fr:]]\n[[fy:]]\n[[ga:]]\n[[gl:]]\n[[gn:]]\n[[gu:]]\n[[he:]]\n[[hi:]]\n[[hr:]]\n[[hy:]]\n[[ia:]]\n[[id:]]\n[[is:]]\n[[it:]]\n[[ja:]]\n[[ka:]]\n[[kk:]]\n[[km:]]\n[[kn:]]\n[[ko:]]\n[[ks:]]\n[[ku:]]\n[[ky:]]\n[[la:]]\n[[ln:]]\n[[lo:]]\n[[lt:]]\n[[lv:]]\n[[hu:]]\n[[mi:]]\n[[mk:]]\n[[ml:]]\n[[mn:]]\n[[mr:]]\n[[ms:]]\n[[mt:]]\n[[my:]]\n[[na:]]\n[[nah:]]\n[[nds:]]\n[[ne:]]\n[[nl:]]\n[[no:]]\n[[oc:]]\n[[om:]]\n[[pa:]]\n[[pl:]]\n[[ps:]]\n[[pt:]]\n[[qu:]]\n[[ro:]]\n[[ru:]]\n[[sa:]]\n[[si:]]\n[[sk:]]\n[[sl:]]\n[[sq:]]\n[[sr:]]\n[[sv:]]\n[[sw:]]\n[[ta:]]\n[[te:]]\n[[tg:]]\n[[th:]]\n[[tk:]]\n[[tl:]]\n[[tr:]]\n[[tt:]]\n[[ug:]]\n[[uk:]]\n[[ur:]]\n[[uz:]]\n[[vi:]]\n[[vo:]]\n[[xh:]]\n[[yo:]]\n[[za:]]\n[[zh:]]\n[[zu:]]\n", '', false, false);
    print "Adding to dblists\n";
    # Add to dblist
    $file = fopen("{$common}/all.dblist", "a");
    fwrite($file, "{$dbName}\n");
    fclose($file);
    # Update the sublists
    system("cd {$common} && ./refresh-dblist");
    print "Constructing interwiki SQL\n";
    # Rebuild interwiki tables
    $sql = getRebuildInterwikiSQL();
    $tempname = tempnam('/tmp', 'addwiki');
    $file = fopen($tempname, 'w');
    if (!$file) {
        wfDie("Error, unable to open temporary file {$tempname}\n");
    }
    fwrite($file, $sql);
    fclose($file);
    print "Sourcing interwiki SQL\n";
    dbsource($tempname, $dbw);
    unlink($tempname);
    print "Script ended. You now want to run sync-common-all to publish *dblist files (check them for duplicates first)\n";
}
    function execute($par)
    {
        global $wgUser, $wgOut, $wgLang, $wgTitle, $wgMemc, $wgDBname;
        global $wgRequest, $wgSitename, $wgLanguageCode, $IP;
        global $wgScript, $wgFilterCallback, $wgScriptPath;
        $this->setHeaders();
        require_once "{$IP}/extensions/wikihow/EditPageWrapper.php";
        require_once "{$IP}/includes/EditPage.php";
        $target = isset($par) ? $par : $wgRequest->getVal('target');
        if (!$target) {
            $wgOut->addHTML("No target specified. In order to thank a group of authors, a page must be provided.");
            return;
        }
        $title = Title::newFromDBKey($target);
        $me = Title::makeTitle(NS_SPECIAL, "ThankAuthors");
        if (!$wgRequest->getVal('token')) {
            $sk = $wgUser->getSkin();
            $talk_page = $title->getTalkPage();
            $token = $this->getToken1();
            $thanks_msg = wfMsg('thank-you-kudos', $title->getFullURL(), wfMsg('howto', $title->getText()));
            // add the form HTML
            $wgOut->addHTML(<<<EOHTML
\t\t\t\t<script type='text/javascript'>
\t\t\t\t\tfunction submitThanks () {
\t\t\t\t\t\tvar message = \$('#details').val();
\t\t\t\t\t\tif(message == "") {
\t\t\t\t\t\t\talert("Please enter a message.");
\t\t\t\t\t\t\treturn false;
\t\t\t\t\t\t}
\t\t\t\t\t\tvar url = '{$me->getFullURL()}?token=' + \$('#token')[0].value + '&target=' + \$('#target')[0].value + '&details=' + \$('#details')[0].value;
\t\t\t\t\t\tvar form = \$('#thanks_form');
\t\t\t\t\t\tform.html(\$('#thanks_response').html());
\t\t\t\t\t\t\$.get(url);
\t\t\t\t\t\treturn true;
\t\t\t\t\t}
\t\t\t\t</script>

\t\t\t\t<div id="thanks_response" style="display:none;">{$thanks_msg}</div>
\t\t\t\t<div id="thanks_form"><div class="section_text">
EOHTML
);
            $wgOut->addWikiText(wfMsg('enjoyed-reading-article', $title->getFullText(), $talk_page->getFullText()));
            $wgOut->addHTML("<input id=\"target\" type=\"hidden\" name=\"target\" value=\"{$target}\"/>\n\t\t\t\t<input id=\"token\" type=\"hidden\" name=\"{$token}\" value=\"{$token}\"/>\n\t\t\t\t");
            $wgOut->addHTML("<br />\n\t\t\t\t<textarea style='width:98%;' id=\"details\" rows=\"5\" cols=\"100\" name=\"details\"></textarea><br/>\n\t\t\t\t<br /><button onclick='submitThanks();' class='button primary'>" . wfMsg('submit') . "</button>\n\t\t\t\t</div></div>");
        } else {
            // this is a post, accept the POST data and create the
            // Request article
            wfLoadExtensionMessages('PostComment');
            $wgOut->setArticleBodyOnly(true);
            $user = $wgUser->getName();
            $real_name = User::whoIsReal($wgUser->getID());
            if ($real_name == "") {
                $real_name = $user;
            }
            $dateStr = $wgLang->timeanddate(wfTimestampNow());
            $comment = $wgRequest->getVal("details");
            $text = $title->getFullText();
            wfDebug("STA: got text...");
            // filter out links
            $preg = "/[^\\s]*\\.[a-z][a-z][a-z]?[a-z]?/i";
            $matches = array();
            if (preg_match($preg, $comment, $matches) > 0) {
                $wgOut->addHTML(wfMsg('no_urls_in_kudos', $matches[0]));
                return;
            }
            $comment = strip_tags($comment);
            $formattedComment = wfMsg('postcomment_formatted_thanks', $dateStr, $user, $real_name, $comment, $text);
            wfDebug("STA: comment {$formattedComment}\n");
            wfDebug("STA: Checking blocks...");
            $tmp = "";
            if ($wgUser->isBlocked()) {
                $this->blockedIPpage();
                return;
            }
            if (!$wgUser->getID() && $wgWhitelistEdit) {
                $this->userNotLoggedInPage();
                return;
            }
            if ($target == "Spam-Blacklist") {
                $wgOut->readOnlyPage();
                return;
            }
            wfDebug("STA: checking read only\n");
            if (wfReadOnly()) {
                $wgOut->readOnlyPage();
                return;
            }
            wfDebug("STA: checking rate limiter\n");
            if ($wgUser->pingLimiter('userkudos')) {
                $wgOut->rateLimited();
                return;
            }
            wfDebug("STA: checking blacklist\n");
            if ($wgFilterCallback && $wgFilterCallback($title, $comment, "")) {
                // Error messages or other handling should be
                // performed by the filter function
                return;
            }
            wfDebug("STA: checking tokens\n");
            $usertoken = $wgRequest->getVal('token');
            $token1 = $this->getToken1();
            $token2 = $this->getToken2();
            if ($usertoken != $token1 && $usertoken != $token2) {
                wfDebug("STA: User kudos token doesn't match user: {$usertoken} token1: {$token1} token2: {$token2}");
                return;
            }
            wfDebug("STA: going through contributors\n");
            $article = new Article($title);
            //$contributors = $article->getContributors(0, 0, true);
            $contributors = ArticleAuthors::getAuthors($article->getID());
            foreach ($contributors as $k => $v) {
                $u = User::newFromName($k);
                $id = $u->getID();
                //$id = $c->getID();
                //$u = $c;
                wfDebug("STA: going through contributors {$u} {$id}\n");
                if ($id == "0") {
                    continue;
                }
                // forget the anon users.
                //notify via the echo notification system
                if (class_exists('EchoEvent')) {
                    EchoEvent::create(array('type' => 'kudos', 'title' => $title, 'extra' => array('kudoed-user-id' => $id), 'agent' => $wgUser));
                }
                $t = Title::newFromText("User_kudos:" . $u);
                $a = new Article($t);
                $update = $t->getArticleID() > 0;
                $text = "";
                if ($update) {
                    $text = $a->getContent(true);
                    $text .= "\n\n" . $formattedComment;
                    if ($wgFilterCallback && $wgFilterCallback($t, $text, $text)) {
                        // Error messages or other handling should be
                        // performed by the filter function
                        return;
                    }
                }
                if ($update) {
                    $a->updateArticle($text, "", true, false, false, '', false);
                } else {
                    $a->insertNewArticle($text, "", true, false, false, false, false);
                }
            }
            wfDebug("STA: done\n");
            $wgOut->addHTML("Done.");
            $wgOut->redirect('');
        }
    }
 function updateMainArticle($target, $editSummary)
 {
     global $wgOut, $wgRequest;
     $title = Title::makeTitle(NS_MAIN, $target);
     $vid = Title::makeTitle(NS_VIDEO, $target);
     $r = Revision::newFromTitle($title);
     $update = true;
     if (!$r) {
         $update = false;
         $text = "";
     } else {
         $text = $r->getText();
     }
     $tag = "{{" . $vid->getFullText() . "|}}";
     if ($wgRequest->getVal('description') != '') {
         $tag = "{{" . $vid->getFullText() . "|" . $wgRequest->getVal('description') . "}}";
     }
     $newsection .= "\n\n== " . wfMsg('video') . " ==\n{$tag}\n\n";
     $a = new Article($title);
     $newtext = "";
     // Check for existing video section in the target article
     preg_match("/^==[ ]*" . wfMsg('video') . "/im", $text, $matches, PREG_OFFSET_CAPTURE);
     if (sizeof($matches) > 0) {
         // There is an existing video section, replace it
         $i = $matches[0][1];
         preg_match("/^==/im", $text, $matches, PREG_OFFSET_CAPTURE, $i + 1);
         if (sizeof($matches) > 0) {
             $j = $matches[0][1];
             // == Video == was not the last section
             $newtext = trim(substr($text, 0, $i)) . $newsection . substr($text, $j, strlen($text));
         } else {
             // == Video == was the last section append it
             $newtext = trim($text) . $newsection;
         }
         // existing section, change it.
     } else {
         // There is not an existng video section, insert it after steps
         // This section could be cleaned up to handle it if there was an existing video section too I guess
         $arr = preg_split('/(^==[^=]*?==\\s*?$)/m', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
         $found = false;
         for ($i = 0; $i < sizeof($arr); $i++) {
             if (preg_match("/^==[ ]*" . wfMsg('steps') . "/", $arr[$i])) {
                 $newtext .= $arr[$i];
                 $i++;
                 if ($i < sizeof($arr)) {
                     $newtext .= $arr[$i];
                 }
                 $newtext = trim($newtext) . $newsection;
                 $found = true;
             } else {
                 $newtext .= $arr[$i];
             }
         }
         if (!$found) {
             $arr = preg_split('/(^==[^=]*?==\\s*?$)/m', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
             $newtext = "";
             $newtext = trim($arr[0]) . $newsection;
             for ($i = 1; $i < sizeof($arr); $i++) {
                 $newtext .= $arr[$i];
             }
         }
     }
     if ($newtext == "") {
         $newtext = $newsection;
     }
     $watch = $title->userIsWatching();
     if ($update) {
         $a->updateArticle($newtext, $editSummary, false, $watch);
     } else {
         $a->insertNewArticle($newtext, $editSummary, false, $watch);
     }
     if ($wgRequest->getVal("popup") == "true") {
         $wgOut->clearHTML();
         $wgOut->disable();
         echo "<script type='text/javascript'>\n\t\t\tfunction onLoad() {\n\t\t\t\tvar e = document.getElementById('video_text');\n\t\t\t\te.value = \"" . htmlspecialchars($tag) . "\";\n\t\t\t\tpv_Preview();\n\t\t\t\tvar summary = document.getElementById('wpSummary');\n\t\t\t\tif (summary.value != '')\n\t\t\t\t\tsummary.value += ',  " . ($update ? wfMsg('importvideo_changingvideo_summary') : $editSummary) . "';\n\t\t\t\telse\n\t\t\t\t\tsummary.value = '" . ($update ? wfMsg('importvideo_changingvideo_summary') : $editSummary) . "';\n\t\t\t\tcloseModal();\n\t\t\t}\n\t\t\tonLoad();\n\t\t\t\t</script>\n\t\t\t\t";
     }
     $me = Title::makeTitle(NS_SPECIAL, "Importvideo");
     if ($wgRequest->getVal('wasnew') || $wgRequest->getVal('new')) {
         // log it, we track when someone uploads a video for a new article
         $params = array($title->getArticleID());
         $log = new LogPage('vidsfornew', false);
         $log->addEntry('added', $title, 'added');
         $wgOut->redirect($me->getFullURL() . "?new=1&skip=" . $title->getArticleID());
         return;
     } else {
         if ($wgRequest->getVal('category')) {
             // they added a video to a category, keep them in the category mode
             $wgOut->redirect($me->getFullURL() . "?category=" . urlencode($wgRequest->getVal('category')));
             return;
         }
     }
 }
Example #4
0
 function pbConfig()
 {
     global $wgUser, $wgRequest, $wgOut;
     $live = mysql_real_escape_string(strip_tags($wgRequest->getVal('live'), '<p><br><b><i>'));
     $occupation = mysql_real_escape_string(strip_tags($wgRequest->getVal('occupation'), '<p><br><b><i>'));
     $aboutme = mysql_real_escape_string(strip_tags($wgRequest->getVal('aboutme'), '<p><br><b><i>'));
     $t = Title::newFromText($wgUser->getUserPage() . '/profilebox-live');
     $article = new Article($t);
     if ($t->getArticleId() > 0) {
         $article->updateArticle($live, 'profilebox-live-update', true, $watch);
     } else {
         if ($live != '') {
             $article->insertNewArticle($live, 'profilebox-live-update', true, $watch, false, false, true);
         }
     }
     $t = Title::newFromText($wgUser->getUserPage() . '/profilebox-occupation');
     $article = new Article($t);
     if ($t->getArticleId() > 0) {
         $article->updateArticle($occupation, 'profilebox-occupation-update', true, $watch);
     } else {
         if ($occupation != '') {
             $article->insertNewArticle($occupation, 'profilebox-occupation-update', true, $watch, false, false, true);
         }
     }
     $t = Title::newFromText($wgUser->getUserPage() . '/profilebox-aboutme');
     $article = new Article($t);
     if ($t->getArticleId() > 0) {
         $article->updateArticle($aboutme, 'profilebox-aboutme-update', true, $watch);
     } else {
         if ($aboutme != '') {
             $article->insertNewArticle($aboutme, 'profilebox-aboutme-update', true, $watch, false, false, true);
         }
     }
     $userpageurl = $wgUser->getUserPage() . '';
     $t = Title::newFromText($userpageurl, NS_USER);
     $article = new Article($t);
     $userpage = " \n";
     if ($t->getArticleId() > 0) {
         /*
         $r = Revision::newFromTitle($t);
         $curtext .= $r->getText();
         
         if (!preg_match('/<!-- blank -->/',$curtext)) {
         	$userpage .= $curtext;
         	$article->updateArticle($userpage, 'profilebox-userpage-update', true, $watch);
         }
         */
     } else {
         $article->insertNewArticle($userpage, 'profilebox-userpage-update', true, $watch, false, false, true);
     }
     $wgUser->setOption('profilebox_fav1', $wgRequest->getVal('fav1'));
     $wgUser->setOption('profilebox_fav2', $wgRequest->getVal('fav2'));
     $wgUser->setOption('profilebox_fav3', $wgRequest->getVal('fav3'));
     if ($wgRequest->getVal('articleStats') == 'on') {
         $wgUser->setOption('profilebox_stats', 1);
     } else {
         $wgUser->setOption('profilebox_stats', 0);
     }
     if ($wgRequest->getVal('articleStartedEdited') == 'on') {
         $wgUser->setOption('profilebox_startedEdited', 1);
     } else {
         $wgUser->setOption('profilebox_startedEdited', 0);
     }
     /*
     		if ( ($wgRequest->getVal('articleFavs') == 'on') &&
     				($wgRequest->getVal('fav1') || $wgRequest->getVal('fav2') || $wgRequest->getVal('fav3')) )
     		{
     			$wgUser->setOption('profilebox_favs', 1);
     		} else {
     			$wgUser->setOption('profilebox_favs', 0);
     		}
     */
     $wgUser->setOption('profilebox_display', 1);
     $wgUser->saveSettings();
 }
Example #5
0
 function execute($par)
 {
     global $wgRequest, $wgTitle, $wgOut, $wgMemc, $wgUser;
     global $wgYTAS_User, $wgYTAS_Password, $wgYTAS_DeveloperId, $wgYTAS_ClientId;
     global $wgYTAS_DefaultCategory, $wgYTAS_UseClientLogin, $wgYTAS_EnableLogging, $wgYTAS_UseNamespace;
     $fname = "wfYouTubeAuthSub";
     # Check permissions
     if (!$wgUser->isAllowed('upload')) {
         if (!$wgUser->isLoggedIn()) {
             $wgOut->showErrorPage('uploadnologin', 'uploadnologintext');
         } else {
             $wgOut->permissionRequired('upload');
         }
         return;
     }
     if ($wgRequest->getVal('status') == '200' && $wgRequest->getVal('id') != null) {
         $wgOut->addHTML(wfMsg('youtubeauthsub_success', $wgRequest->getVal('id')));
         $descTitle = null;
         $desc = wfMsg('youtubeauthsub_summary');
         //TODO: can we grab the keywords and description the user has submitted?
         if ($wgYTAS_UseNamespace) {
             $descTitle = Title::makeTitle(NS_YOUTUBE, $wgRequest->getVal('id'));
             $a = new Article($descTitle);
             if ($a->getID() == 0) {
                 $title = $keywords = $description = $category = "";
                 if ($wgRequest->getVal('metaid') != null) {
                     $dbr = wfGetDB(DB_SLAVE);
                     $row = $dbr->selectRow('ytas_meta', array('ytas_title', 'ytas_description', 'ytas_keywords', 'ytas_category'), array("ytas_id={$wgRequest->getVal('metaid')}"));
                     if ($row) {
                         $title = $row->ytas_title;
                         $keywords = $row->ytas_keywords;
                         $description = $row->ytas_description;
                         $category = $row->ytas_category;
                     }
                 }
                 $content = "{{YoutubeVideo|{$wgRequest->getVal('id')}|{$title}|{$keywords}|{$description}|{$category}}}";
                 $a->insertNewArticle($content, wfMsg('youtubeauthsub_summary'), false, false);
                 $wgOut->redirect('');
             }
             $wgOut->addWikiText(wfMsg('youtubeauthsub_viewpage', $descTitle->getFullText()));
         }
         if ($wgYTAS_EnableLogging) {
             # Add the log entry
             $log = new LogPage('upload');
             $log->addEntry('upload', $descTitle, $desc);
         }
     }
     if ($wgYTAS_UseClientLogin) {
         $key = wfMemcKey('youtube', 'authsub', $wgYTAS_User);
         $token = $wgMemc->get($key);
         // regenerate the token
         if (!$token) {
             $result = $this->post("https://www.google.com/youtube/accounts/ClientLogin?", "Email={$wgYTAS_User}&Passwd={$wgYTAS_Password}&service=youtube&source=wikiHow");
             $YouTubeUser = "";
             $lines = split("\n", $result);
             foreach ($lines as $line) {
                 $params = split("=", $line);
                 switch ($params[0]) {
                     case "Auth":
                         $token = $params[1];
                         break;
                     case "YouTubeUser":
                         $YouTubeUser = $params[1];
                         break;
                 }
             }
             if (!$token) {
                 $wgOut->addHTML(wfMsg('youtubeauthsub_tokenerror'));
                 return;
             }
             $wgMemc->set($key, $token, time() + 3600);
         }
     } else {
         $token = $wgRequest->getVal('token');
         if (!$token) {
             $wgOut->addHTML(wfMsg('youtubeauthsub_authsubinstructions') . "\n\t\t\t\t\t<script type='text/javascript'>\n\t\t\t\t\t\tvar gYTAS_nokeywords = '" . wfMsg('youtubeauthsub_jserror_nokeywords') . "';\n\t\t\t\t\t\tvar gYTAS_notitle = '" . wfMsg('youtubeauthsub_jserror_notitle') . "';\n\t\t\t\t\t</script>\n\t\t\t\t\t<script type='text/javascript' src='/extensions/YouTubeAuthSub/youtubeauthsub.js'>\n\t\t\t\t\t</script>\t\n\t\t\t\t\t<form action='https://www.google.com/accounts/AuthSubRequest' method='POST' onsubmit='return checkYTASForm();' name='ytas_form'/>\n\t\t\t\t\t<input type='hidden' name='next' value='{$wgTitle->getFullURL()}'/>\n\t\t\t\t\t<input type='hidden' name='scope' value='http://gdata.youtube.com/feeds'/>\n\t\t\t\t\t<input type='hidden' name='session' value='0'/>\n\t\t\t\t\t<input type='hidden' name='secure' value='0'/>\n\t\t\t\t\t<input type='submit' value='" . wfMsg('youtubeauthsub_clickhere') . "'/>");
             return;
         }
     }
     if ($wgRequest->wasPosted()) {
         $url = "http://uploads.gdata.youtube.com/feeds/api/users/{$wgYTAS_User}/uploads";
         $url = "http://gdata.youtube.com/action/GetUploadToken";
         $data = "<?xml version='1.0'?>\n\t<entry xmlns='http://www.w3.org/2005/Atom'\n\t  xmlns:media='http://search.yahoo.com/mrss/'\n\t  xmlns:yt='http://gdata.youtube.com/schemas/2007'>\n\t  <media:group>\n\t    <media:title type='plain'>" . FeedItem::xmlEncode($wgRequest->getVal('youtube_title')) . "</media:title>\n\t    <media:description type='plain'>" . FeedItem::xmlEncode($wgRequest->getVal('youtube_description')) . "</media:description>\n\t    <media:keywords>" . FeedItem::xmlEncode($wgRequest->getVal('youtube_keywords')) . "</media:keywords>\n\t\t<media:category scheme='http://gdata.youtube.com/schemas/2007/categories.cat'>" . FeedItem::xmlEncode($wgRequest->getVal('youtube_category')) . "</media:category>\n\t  </media:group>\n\t</entry>\n\t";
         $headers = array("X-GData-Key: key={$wgYTAS_DeveloperId}", "X-GData-Client: {$wgYTAS_ClientId}", "Content-Type: application/atom+xml; charset=UTF-8", "Content-Length: " . strlen($data));
         if ($wgYTAS_UseClientLogin) {
             $headers[] = "Authorization: GoogleLogin auth={$token}";
         } else {
             $headers[] = "Authorization: AuthSub token={$token}";
         }
         $results = $this->post($url, $data, $headers);
         preg_match("/<token>.*<\\/token>/", $results, $matches);
         $token = strip_tags($matches[0]);
         preg_match("/'edit-media'[^>]*href='[^']*'>/", $results, $matches);
         preg_match("/<url>.*<\\/url>/", $results, $matches);
         $url = strip_tags($matches[0]);
         if ($url == "") {
             $wgOut->addHTML("Unable to extract URL, results where <pre>{$results}</pre>");
             return;
         }
         // CAPTURE THE META INFO AND STORE IT
         $meta_id = '';
         $dbw = wfGetDB(DB_MASTER);
         $fields = array('ytas_user' => $wgUser->getID(), 'ytas_timestamp' => $dbw->timestamp(time()), 'ytas_title' => $wgRequest->getVal('youtube_title'), 'ytas_description' => $wgRequest->getVal('youtube_description'), 'ytas_keywords' => $wgRequest->getVal('youtube_keywords'), 'ytas_category' => $wgRequest->getVal('youtube_category'));
         $dbw->insert('ytas_meta', $fields, __METHOD__, array('IGNORE'));
         if ($dbw->affectedRows()) {
             $meta_id = $dbw->insertId();
         }
         $next_url = urlencode($wgTitle->getFullURL() . "?metaid={$meta_id}");
         $wgOut->addHTML(wfMsg('youtubeauthsub_uploadhere') . "<br/><br/>\n\t\t\t\t\t <form action='{$url}?nexturl={$next_url}' METHOD='post' enctype='multipart/form-data' name='videoupload'>\n\t\t\t\t\t\t  <input type='file' name='file' size='50'/>\n\t  \t\t\t\t\t<input type='hidden' name='token' value='{$token}'/><br/>\n\t  \t\t\t\t\t<input type='submit' name='submitbtn' value='" . wfMsg('youtubeauthsub_uploadbutton') . "'/>\n\t\t\t\t\t\t</form>\n\t\t\t\t\t\t<center>\n\t\t\t\t\t\t<div id='upload_image' style='display:none;'>\n\t\t\t\t\t" . wfMsg('youtubeauthsub_uploading') . "\n\t\t\t\t\t\t\t\t\t<img src='/extensions/YouTubeAuthSub/upload.gif'>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</center>\n\t\t\t\t\t");
     } else {
         $wgOut->addHTML(wfMsg('youtubeauthsub_info') . "  <script type='text/javascript'>\n\t                    var gYTAS_nokeywords = '" . wfMsg('youtubeauthsub_jserror_nokeywords') . "';\n\t                    var gYTAS_nodesc = '" . wfMsg('youtubeauthsub_jserror_nodesc') . "';\n\t                    var gYTAS_notitle = '" . wfMsg('youtubeauthsub_jserror_notitle') . "';\n\t                </script>\n\t                <script type='text/javascript' src='/extensions/YouTubeAuthSub/youtubeauthsub.js'>\n\t                </script>\n\t\t\t\t\t<form action='{$wgTitle->getFullURL()}' method='POST' name='ytas_form' onsubmit='return checkYTASForm();'>\n\t\t\t\t\t<table cellpadding='100'>\n\t\t\t\t");
         if (!$wgYTAS_UseClientLogin) {
             $wgOut->addHTML("<input type='hidden' name='token' value='{$wgRequest->getVal('token')}'/>");
         }
         $wgOut->addHTML("\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>" . wfMsg('youtubeauthsub_title') . ":</td>\n\t\t\t\t\t\t\t<td><input type='text' name='youtube_title' size='40'/></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td valign='top'>" . wfMsg('youtubeauthsub_description') . ":</td>\n\t\t\t\t\t\t\t<td><textarea cols='100' rows='4' name='youtube_description'></textarea></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>" . wfMsg('youtubeauthsub_keywords') . ":</td>\n\t\t\t\t\t\t\t<td><input type='text' name='youtube_keywords' size='40'/></td>\n\t\t\t\t\t\t</tr>");
         if (!$wgYTAS_DefaultCategory) {
             $cats = $this->getCategories();
             $wgOut->addHTML(" \n\t\t\t\t\t\t<tr>\n\t                        <td>" . wfMsg('youtubeauthsub_category') . ":</td>\n\t                        <td><select type='text' name='youtube_category'/>{$cats}</select>\n\t\t\t\t\t\t\t</td>\n\t                    </tr>");
         } else {
             $wgOut->addHTML("<input type='hidden' name='youtube_category' value='{$wgYTAS_DefaultCategory}'/>");
         }
         $wgOut->addHTML("\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td><input type='submit' value='" . wfMsg('youtubeauthsub_submit') . "'></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>\n\t\t\t\t</form>");
     }
 }
Example #6
0
 public function execute()
 {
     global $IP, $wgDefaultExternalStore, $wgNoDBParam;
     $wgNoDBParam = true;
     $lang = $this->getArg(0);
     $site = $this->getArg(1);
     $dbName = $this->getArg(2);
     $domain = $this->getArg(3);
     $languageNames = Language::getLanguageNames();
     if (!isset($languageNames[$lang])) {
         $this->error("Language {$lang} not found in \$wgLanguageNames", true);
     }
     $name = $languageNames[$lang];
     $dbw = wfGetDB(DB_MASTER);
     $common = "/home/wikipedia/common";
     $this->output("Creating database {$dbName} for {$lang}.{$site} ({$name})\n");
     # Set up the database
     $dbw->query("SET table_type=Innodb");
     $dbw->query("CREATE DATABASE {$dbName}");
     $dbw->selectDB($dbName);
     $this->output("Initialising tables\n");
     $dbw->sourceFile($this->getDir() . '/tables.sql');
     $dbw->sourceFile("{$IP}/extensions/OAI/update_table.sql");
     $dbw->sourceFile("{$IP}/extensions/AntiSpoof/sql/patch-antispoof.mysql.sql");
     $dbw->sourceFile("{$IP}/extensions/CheckUser/cu_changes.sql");
     $dbw->sourceFile("{$IP}/extensions/CheckUser/cu_log.sql");
     $dbw->sourceFile("{$IP}/extensions/TitleKey/titlekey.sql");
     $dbw->sourceFile("{$IP}/extensions/Oversight/hidden.sql");
     $dbw->sourceFile("{$IP}/extensions/GlobalBlocking/localdb_patches/setup-global_block_whitelist.sql");
     $dbw->sourceFile("{$IP}/extensions/AbuseFilter/abusefilter.tables.sql");
     $dbw->sourceFile("{$IP}/extensions/UsabilityInitiative/PrefStats/PrefStats.sql");
     $dbw->sourceFile("{$IP}/extensions/ProofreadPage/ProofreadPage.sql");
     $dbw->sourceFile("{$IP}/extensions/UsabilityInitiative/ClickTracking/ClickTrackingEvents.sql");
     $dbw->sourceFile("{$IP}/extensions/UsabilityInitiative/ClickTracking/ClickTracking.sql");
     $dbw->sourceFile("{$IP}/extensions/UsabilityInitiative/UserDailyContribs/UserDailyContribs.sql");
     $dbw->sourceFile("{$IP}/extensions/UsabilityInitiative/OptIn/OptIn.sql");
     $dbw->query("INSERT INTO site_stats(ss_row_id) VALUES (1)");
     # Initialise external storage
     if (is_array($wgDefaultExternalStore)) {
         $stores = $wgDefaultExternalStore;
     } elseif ($wgDefaultExternalStore) {
         $stores = array($wgDefaultExternalStore);
     } else {
         $stores = array();
     }
     if (count($stores)) {
         global $wgDBuser, $wgDBpassword, $wgExternalServers;
         foreach ($stores as $storeURL) {
             $m = array();
             if (!preg_match('!^DB://(.*)$!', $storeURL, $m)) {
                 continue;
             }
             $cluster = $m[1];
             $this->output("Initialising external storage {$cluster}...\n");
             # Hack
             $wgExternalServers[$cluster][0]['user'] = $wgDBuser;
             $wgExternalServers[$cluster][0]['password'] = $wgDBpassword;
             $store = new ExternalStoreDB();
             $extdb = $store->getMaster($cluster);
             $extdb->query("SET table_type=InnoDB");
             $extdb->query("CREATE DATABASE {$dbName}");
             $extdb->selectDB($dbName);
             # Hack x2
             $blobsTable = $store->getTable($extdb);
             $sedCmd = "sed s/blobs\\\\\\>/{$blobsTable}/ " . $this->getDir() . "/storage/blobs.sql";
             $blobsFile = popen($sedCmd, 'r');
             $extdb->sourceStream($blobsFile);
             pclose($blobsFile);
             $extdb->commit();
         }
     }
     global $wgTitle, $wgArticle;
     $wgTitle = Title::newFromText(wfMsgWeirdKey("mainpage/{$lang}"));
     $this->output("Writing main page to " . $wgTitle->getPrefixedDBkey() . "\n");
     $wgArticle = new Article($wgTitle);
     $ucsite = ucfirst($site);
     $wgArticle->insertNewArticle($this->getFirstArticle($ucsite, $name), '', false, false);
     $this->output("Adding to dblists\n");
     # Add to dblist
     $file = fopen("{$common}/all.dblist", "a");
     fwrite($file, "{$dbName}\n");
     fclose($file);
     # Update the sublists
     shell_exec("cd {$common} && ./refresh-dblist");
     # print "Constructing interwiki SQL\n";
     # Rebuild interwiki tables
     # passthru( '/home/wikipedia/conf/interwiki/update' );
     $time = wfTimestamp(TS_RFC2822);
     // These arguments need to be escaped twice: once for echo and once for at
     $escDbName = wfEscapeShellArg(wfEscapeShellArg($dbName));
     $escTime = wfEscapeShellArg(wfEscapeShellArg($time));
     $escUcsite = wfEscapeShellArg(wfEscapeShellArg($ucsite));
     $escName = wfEscapeShellArg(wfEscapeShellArg($name));
     $escLang = wfEscapeShellArg(wfEscapeShellArg($lang));
     $escDomain = wfEscapeShellArg(wfEscapeShellArg($domain));
     shell_exec("echo notifyNewProjects {$escDbName} {$escTime} {$escUcsite} {$escName} {$escLang} {$escDomain} | at now + 15 minutes");
     $this->output("Script ended. You still have to:\n\t* Add any required settings in InitialiseSettings.php\n\t* Run sync-common-all\n\t* Run /home/wikipedia/conf/interwiki/update\n\t");
 }
 /**
  * Creates some predefined pages
  */
 protected function createPreDefinedPages($verbose)
 {
     global $smwgHaloContLang, $smwgContLang;
     DBHelper::reportProgress("Creating predefined pages...\n", $verbose);
     $ssp = $smwgHaloContLang->getSpecialSchemaPropertyArray();
     $propertyLabels = $smwgContLang->getPropertyLabels();
     $namespaces = $smwgContLang->getNamespaces();
     $datatypeLabels = $smwgContLang->getDatatypeLabels();
     foreach ($ssp as $key => $value) {
         $t = Title::newFromText($value, SMW_NS_PROPERTY);
         $article = new Article($t);
         if (!$t->exists()) {
             if (strtolower($ssp[SMW_SSP_HAS_DOMAIN_AND_RANGE_HINT]) == strtolower($t->getText())) {
                 $text = "\n\n[[" . $propertyLabels['_TYPE'] . "::Type:Record]]";
                 $text .= wfMsg('smw_predefined_props', $t->getText()) . "\n\n[[" . $propertyLabels['_LIST'] . "::" . $namespaces[SMW_NS_TYPE] . ":" . $datatypeLabels["_wpg"] . "; " . $namespaces[SMW_NS_TYPE] . ":" . $datatypeLabels["_wpg"] . "]]";
                 $article->insertNewArticle($text, "", false, false);
             } else {
                 if (strtolower($ssp[SMW_SSP_HAS_MAX_CARD]) == strtolower($t->getText())) {
                     // special handling for SMW_SSP_HAS_MAX_CARD.
                     $article->insertNewArticle(wfMsg('smw_predefined_props', $t->getText()) . "\n\n[[" . $propertyLabels['_TYPE'] . "::" . $namespaces[SMW_NS_TYPE] . ":" . $datatypeLabels["_num"] . "]]", "", false, false);
                 } else {
                     if (strtolower($ssp[SMW_SSP_HAS_MIN_CARD]) == strtolower($t->getText())) {
                         // special handling for SMW_SSP_HAS_MIN_CARD.
                         $article->insertNewArticle(wfMsg('smw_predefined_props', $t->getText()) . "\n\n[[" . $propertyLabels['_TYPE'] . "::" . $namespaces[SMW_NS_TYPE] . ":" . $datatypeLabels["_num"] . "]]", "", false, false);
                     } else {
                         $article->insertNewArticle(wfMsg('smw_predefined_props', $t->getText()), "", false, false);
                     }
                 }
             }
             DBHelper::reportProgress("   ... Create page " . $t->getNsText() . ":" . $t->getText() . "...\n", $verbose);
         } else {
             // save article again. Necessary when storage implementation has switched.
             $rev = Revision::newFromTitle($t);
             $article->doEdit($rev->getRawText(), $rev->getRawComment(), EDIT_UPDATE | EDIT_FORCE_BOT);
             DBHelper::reportProgress("   ... re-saved page " . $t->getNsText() . ":" . $t->getText() . ".\n", $verbose);
         }
     }
     $scs = $smwgHaloContLang->getSpecialCategoryArray();
     foreach ($scs as $key => $value) {
         $t = Title::newFromText($value, NS_CATEGORY);
         if (!$t->exists()) {
             $article = new Article($t);
             $article->insertNewArticle(wfMsg('smw_predefined_cats', $t->getText()), "", false, false);
             DBHelper::reportProgress("   ... Create page " . $t->getNsText() . ":" . $t->getText() . "...\n", $verbose);
         }
     }
     $this->createHelpAttributes($verbose);
     DBHelper::reportProgress("   ... done!\n", $verbose);
 }
 /**
  * Record an image upload in the upload log and the image table
  */
 function recordUpload($oldver, $desc, $copyStatus = '', $source = '', $watch = false)
 {
     global $wgUser, $wgLang, $wgTitle, $wgDeferredUpdateList;
     global $wgUseCopyrightUpload, $wgUseSquid, $wgPostCommitUpdateList;
     $fname = 'Image::recordUpload';
     $dbw =& wfGetDB(DB_MASTER);
     $this->checkDBSchema($dbw);
     // Delete thumbnails and refresh the metadata cache
     $this->purgeCache();
     // Fail now if the image isn't there
     if (!$this->fileExists || $this->fromSharedDirectory) {
         wfDebug("Image::recordUpload: File " . $this->imagePath . " went missing!\n");
         return false;
     }
     if ($wgUseCopyrightUpload) {
         $textdesc = '== ' . wfMsg('filedesc') . " ==\n" . $desc . "\n" . '== ' . wfMsg('filestatus') . " ==\n" . $copyStatus . "\n" . '== ' . wfMsg('filesource') . " ==\n" . $source;
     } else {
         $textdesc = $desc;
     }
     $now = $dbw->timestamp();
     #split mime type
     if (strpos($this->mime, '/') !== false) {
         list($major, $minor) = explode('/', $this->mime, 2);
     } else {
         $major = $this->mime;
         $minor = "unknown";
     }
     # Test to see if the row exists using INSERT IGNORE
     # This avoids race conditions by locking the row until the commit, and also
     # doesn't deadlock. SELECT FOR UPDATE causes a deadlock for every race condition.
     $dbw->insert('image', array('img_name' => $this->name, 'img_size' => $this->size, 'img_width' => IntVal($this->width), 'img_height' => IntVal($this->height), 'img_bits' => $this->bits, 'img_media_type' => $this->type, 'img_major_mime' => $major, 'img_minor_mime' => $minor, 'img_timestamp' => $now, 'img_description' => $desc, 'img_user' => $wgUser->getID(), 'img_user_text' => $wgUser->getName(), 'img_metadata' => $this->metadata), $fname, 'IGNORE');
     $descTitle = $this->getTitle();
     $purgeURLs = array();
     if ($dbw->affectedRows() == 0) {
         # Collision, this is an update of an image
         # Insert previous contents into oldimage
         $dbw->insertSelect('oldimage', 'image', array('oi_name' => 'img_name', 'oi_archive_name' => $dbw->addQuotes($oldver), 'oi_size' => 'img_size', 'oi_width' => 'img_width', 'oi_height' => 'img_height', 'oi_bits' => 'img_bits', 'oi_timestamp' => 'img_timestamp', 'oi_description' => 'img_description', 'oi_user' => 'img_user', 'oi_user_text' => 'img_user_text'), array('img_name' => $this->name), $fname);
         # Update the current image row
         $dbw->update('image', array('img_size' => $this->size, 'img_width' => intval($this->width), 'img_height' => intval($this->height), 'img_bits' => $this->bits, 'img_media_type' => $this->type, 'img_major_mime' => $major, 'img_minor_mime' => $minor, 'img_timestamp' => $now, 'img_description' => $desc, 'img_user' => $wgUser->getID(), 'img_user_text' => $wgUser->getName(), 'img_metadata' => $this->metadata), array('img_name' => $this->name), $fname);
     }
     $article = new Article($descTitle);
     $minor = false;
     $watch = $watch || $wgUser->isWatched($descTitle);
     $suppressRC = true;
     // There's already a log entry, so don't double the RC load
     if ($descTitle->exists()) {
         // TODO: insert a null revision into the page history for this update.
         if ($watch) {
             $wgUser->addWatch($descTitle);
         }
         # Invalidate the cache for the description page
         $descTitle->invalidateCache();
         $purgeURLs[] = $descTitle->getInternalURL();
     } else {
         // New image; create the description page.
         $article->insertNewArticle($textdesc, $desc, $minor, $watch, $suppressRC);
     }
     # Invalidate cache for all pages using this image
     $linksTo = $this->getLinksTo();
     if ($wgUseSquid) {
         $u = SquidUpdate::newFromTitles($linksTo, $purgeURLs);
         array_push($wgPostCommitUpdateList, $u);
     }
     Title::touchArray($linksTo);
     $log = new LogPage('upload');
     $log->addEntry('upload', $descTitle, $desc);
     return true;
 }
Example #9
0
function addWiki($lang, $site, $dbName)
{
    global $IP, $wgLanguageNames, $wgDefaultExternalStore;
    $name = $wgLanguageNames[$lang];
    $dbw = wfGetDB(DB_WRITE);
    $common = "/home/wikipedia/common";
    $maintenance = "{$IP}/maintenance";
    print "Creating database {$dbName} for {$lang}.{$site}\n";
    # Set up the database
    $dbw->query("SET table_type=Innodb");
    $dbw->query("CREATE DATABASE {$dbName}");
    $dbw->selectDB($dbName);
    print "Initialising tables\n";
    dbsource("{$maintenance}/tables.sql", $dbw);
    dbsource("{$IP}/extensions/OAI/update_table.sql", $dbw);
    dbsource("{$IP}/extensions/AntiSpoof/mysql/patch-antispoof.sql", $dbw);
    dbsource("{$IP}/extensions/CheckUser/cu_changes.sql", $dbw);
    $dbw->query("INSERT INTO site_stats(ss_row_id) VALUES (1)");
    # Initialise external storage
    if (is_array($wgDefaultExternalStore)) {
        $stores = $wgDefaultExternalStore;
    } elseif ($stores) {
        $stores = array($wgDefaultExternalStore);
    } else {
        $stores = array();
    }
    if (count($stores)) {
        require_once 'ExternalStoreDB.php';
        print "Initialising external storage {$store}...\n";
        global $wgDBuser, $wgDBpassword, $wgExternalServers;
        foreach ($stores as $storeURL) {
            $m = array();
            if (!preg_match('!^DB://(.*)$!', $storeURL, $m)) {
                continue;
            }
            $cluster = $m[1];
            # Hack
            $wgExternalServers[$cluster][0]['user'] = $wgDBuser;
            $wgExternalServers[$cluster][0]['password'] = $wgDBpassword;
            $store = new ExternalStoreDB();
            $extdb =& $store->getMaster($cluster);
            $extdb->query("SET table_type=InnoDB");
            $extdb->query("CREATE DATABASE {$dbName}");
            $extdb->selectDB($dbName);
            dbsource("{$maintenance}/storage/blobs.sql", $extdb);
            $extdb->immediateCommit();
        }
    }
    global $wgTitle, $wgArticle;
    $wgTitle = Title::newMainPage();
    $wgArticle = new Article($wgTitle);
    $ucsite = ucfirst($site);
    $wgArticle->insertNewArticle(<<<EOT
==This subdomain is reserved for the creation of a [[wikimedia:Our projects|{$ucsite}]] in '''[[w:en:{$name}|{$name}]]''' language==

* Please '''do not start editing''' this new site. This site has a test project on the [[incubator:|Wikimedia Incubator]] (or on the [[betawikiversity:|BetaWikiversity]] or on the [[oldwikisource:|Old Wikisource]]) and it will be imported to here.

* If you would like to help translating the interface to this language, please do not translate here, but go to [[betawiki:|Betawiki]], a special wiki for translating the interface. That way everyone can use it on every wiki using the [[mw:|same software]].

* For information about how to edit and for other general help, see [[m:Help:Contents|Help on Wikimedia's Meta-Wiki]] or [[mw:Help:Contents|Help on MediaWiki.org]].

== Sister projects ==
<span class="plainlinks">
[http://www.wikipedia.org Wikipedia] |
[http://www.wiktionary.org Wiktonary] |
[http://www.wikibooks.org Wikibooks] |
[http://www.wikinews.org Wikinews] |
[http://www.wikiquote.org Wikiquote] |
[http://www.wikisource.org Wikisource]
[http://www.wikiversity.org Wikiversity]
</span>

See Wikimedia's [[m:|Meta-Wiki]] for the coordination of these projects.

[[aa:]]
[[af:]]
[[als:]]
[[ar:]]
[[de:]]
[[en:]]
[[as:]]
[[ast:]]
[[ay:]]
[[az:]]
[[bcl:]]
[[be:]]
[[bg:]]
[[bn:]]
[[bo:]]
[[bs:]]
[[cs:]]
[[co:]]
[[cs:]]
[[cy:]]
[[da:]]
[[el:]]
[[eo:]]
[[es:]]
[[et:]]
[[eu:]]
[[fa:]]
[[fi:]]
[[fr:]]
[[fy:]]
[[ga:]]
[[gl:]]
[[gn:]]
[[gu:]]
[[he:]]
[[hi:]]
[[hr:]]
[[hsb:]]
[[hy:]]
[[ia:]]
[[id:]]
[[is:]]
[[it:]]
[[ja:]]
[[ka:]]
[[kk:]]
[[km:]]
[[kn:]]
[[ko:]]
[[ks:]]
[[ku:]]
[[ky:]]
[[la:]]
[[ln:]]
[[lo:]]
[[lt:]]
[[lv:]]
[[hu:]]
[[mi:]]
[[mk:]]
[[ml:]]
[[mn:]]
[[mr:]]
[[ms:]]
[[mt:]]
[[my:]]
[[na:]]
[[nah:]]
[[nds:]]
[[ne:]]
[[nl:]]
[[no:]]
[[oc:]]
[[om:]]
[[pa:]]
[[pl:]]
[[ps:]]
[[pt:]]
[[qu:]]
[[ro:]]
[[ru:]]
[[sa:]]
[[si:]]
[[sk:]]
[[sl:]]
[[sq:]]
[[sr:]]
[[sv:]]
[[sw:]]
[[ta:]]
[[te:]]
[[tg:]]
[[th:]]
[[tk:]]
[[tl:]]
[[tr:]]
[[tt:]]
[[ug:]]
[[uk:]]
[[ur:]]
[[uz:]]
[[vi:]]
[[vo:]]
[[xh:]]
[[yo:]]
[[za:]]
[[zh:]]
[[zu:]]

EOT
, '', false, false);
    print "Adding to dblists\n";
    # Add to dblist
    $file = fopen("{$common}/all.dblist", "a");
    fwrite($file, "{$dbName}\n");
    fclose($file);
    # Update the sublists
    system("cd {$common} && ./refresh-dblist");
    print "Constructing interwiki SQL\n";
    # Rebuild interwiki tables
    $sql = getRebuildInterwikiSQL();
    $tempname = tempnam('/tmp', 'addwiki');
    $file = fopen($tempname, 'w');
    if (!$file) {
        wfDie("Error, unable to open temporary file {$tempname}\n");
    }
    fwrite($file, $sql);
    fclose($file);
    print "Sourcing interwiki SQL\n";
    dbsource($tempname, $dbw);
    #unlink( $tempname );
    # Create the upload dir
    global $wgUploadDirectory;
    if (file_exists($wgUploadDirectory)) {
        echo "{$wgUploadDirectory} already exists.\n";
    } else {
        echo "Creating {$wgUploadDirectory}...\n";
        mkdir($wgUploadDirectory, 0777);
        chmod($wgUploadDirectory, 0777);
    }
    print "Script ended. You now want to run sync-common-all to publish *dblist files (check them for duplicates first)\n";
}
// is to "close" the non-existent connection then request another.
$db->close();
$db = wfGetDB(DB_SLAVE);
$db->ping();
// Check if any of these noembed vids have links on the site
$start = microtime(true);
foreach ($vids as $i => $vid) {
    if ($vid['noembed']) {
        $sql = "SELECT count(*) AS C\n\t\t\t\tFROM pagelinks LEFT JOIN page ON pl_from = page_id\n\t\t\t\tWHERE pl_namespace=" . NS_VIDEO . "\n\t\t\t\t\tAND pl_title=" . $db->addQuotes($vid['text']) . "\n\t\t\t\t\tAND page_namespace=0";
        $res = $db->query($sql);
        if ($row = $res->fetchObject()) {
            if ($row->C == 0) {
                echo "{$vid['full-text']} has no links...skipping\n";
                continue;
            }
        }
        $list .= "# [[{$vid['full-text']}]]\n";
    }
}
if ($list == "") {
    $list = "There are no videos at this time.";
}
$t = Title::makeTitle(NS_PROJECT, "Videos that can no longer be embedded");
$a = new Article($t);
$date = date("Y-m-d");
$text = wfMsg('no_more_embed_video') . "\n\n{$list}\nThis page was last updated {$date}\n";
if ($t->getArticleID() == 0) {
    $a->insertNewArticle($text, "list of videos that cannot be embedded", false, false);
} else {
    $a->updateArticle($text, "list of videos that cannot be embedded", false, false);
}
Example #11
0
 function execute($par)
 {
     global $wgRequest, $wgOut, $wgUser, $wgHooks;
     if (!in_array('sysop', $wgUser->getGroups()) and !in_array('newarticlepatrol', $wgUser->getRights())) {
         $wgOut->showErrorPage('nosuchspecialpage', 'nospecialpagetext');
         return;
     }
     $wgHooks['PreWikihowProcessHTML'][] = array('Misc::removePostProcessing');
     $this->setHeaders();
     $wgOut->addHTML("<div class='minor_section'>");
     $wgOut->addHTML(wfMsg('proposedredirects_info'));
     $t = Title::makeTitle(NS_PROJECT, "Proposed Redirects");
     $a = new Article($t);
     $wgOut->addHTML("<style type='text/css' media='all'>/*<![CDATA[*/ @import '" . wfGetPad('/extensions/min/f/extensions/wikihow/createpage/createpage.css?') . WH_SITEREV . "'; /*]]>*/</style> ");
     if ($wgRequest->wasPosted()) {
         // deal with collisions of loading and saving
         $changes = array();
         foreach ($wgRequest->getValues() as $key => $value) {
             if (strpos($key, "id-") === false) {
                 continue;
             }
             $id = str_replace("id-", "btn-", $key);
             $newval = $wgRequest->getVal($id);
             switch ($newval) {
                 case 'accept':
                 case 'reject':
                     $changes[$value] = $newval;
             }
         }
         foreach ($changes as $c => $v) {
             $params = split("_", $c);
             $from = Title::makeTitle(NS_MAIN, str_replace("_", " ", $params[0]));
             $to = Title::makeTitle(NS_MAIN, str_replace("_", " ", $params[1]));
             if ($v == 'accept') {
                 $a = new Article($from);
                 if ($from->getArticleID() == 0) {
                     $a->insertNewArticle("#REDIRECT [[{$to->getText()}]]\n", "Creating proposed redirect", false, false);
                     $log = new LogPage('redirects', true);
                     $log->addEntry('added', $from, 'added', array($to, $from));
                 } else {
                     $wgOut->addHTML("{$to->getText()} is an existing article, skipping<br/>");
                 }
             }
             $this->deleteProposedRedirect($from->getDBKey(), $to->getDBKey());
         }
         $wgOut->redirect('');
     }
     // regrab the text if necessary
     $r = Revision::newFromTitle($t);
     $text = "";
     if ($r) {
         $text = $r->getText();
     }
     $lines = split("\n", $text);
     $s = "";
     $dbr = wfGetDB(DB_SLAVE);
     $res = $dbr->select('proposedredirects', array('pr_from', 'pr_to', 'pr_user_text'), array(), "ProposedRedirects::execute", array("LIMIT" => 250));
     while ($row = $dbr->fetchObject($res)) {
         $u = User::newFromName($row->pr_user_text);
         $to = Title::newFromText($row->pr_to);
         $from = Title::newFromText($row->pr_from);
         $key = htmlspecialchars($from->getDBKey() . "_" . $to->getDBKey());
         if (!$u) {
             $url = "/User:{$row->pr_user_text}";
         } else {
             $url = $u->getUserPage()->getFullURL();
         }
         $id = rand(0, 10000);
         $s .= "<tr>\n\t\t\t\t\t<td>{$row->pr_user_text}</td>\n\t\t\t\t\t<td><a href='{$from->getFullURL()}' target='new'>{$from->getText()}</td>\n\t\t\t\t\t<td>\n\t\t\t\t\t\t<input type='hidden' name='id-{$id}' value=\"{$key}\"/>\n\t\t\t\t\t\t<a href='{$to->getFullURL()}' target='new'>{$to->getText()}</td>\n\t\t\t\t\t<td class='btn'><input type='radio' name='btn-{$id}' value='accept'/></td>\n\t\t\t\t\t<td class='btn'><input type='radio' name='btn-{$id}' value='skip' CHECKED/></td>\n\t\t\t\t\t<td class='btn'><input type='radio' name='btn-{$id}' value='reject'/></td>\n\t\t\t\t\t</tr>";
     }
     if ($s == "") {
         $wgOut->addHTML("There are currently no proposed redirects to show. Please check again later.");
     } else {
         $wgOut->addHTML("\n\t\t\t\t\t<script type='text/javascript'>\n\t\t\t\t\t\tfunction clearForm(){\n\t\t\t\t\t\t\tfor (i = 0; i < document.proposedform.elements.length; i++) {\n\t\t\t\t\t\t\t\tvar e = document.proposedform.elements[i];\n\t\t\t\t\t\t\t\tif (e.type=='radio') {\n\t\t\t\t\t\t\t\t\tif (e.value=='skip') {\n\t\t\t\t\t\t\t\t\t\te.checked = true;\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\te.checked = false;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfunction rejectAll(){\n\t\t\t\t\t\t\tfor (i = 0; i < document.proposedform.elements.length; i++) {\n\t\t\t\t\t\t\t\tvar e = document.proposedform.elements[i];\n\t\t\t\t\t\t\t\tif (e.type=='radio') {\n\t\t\t\t\t\t\t\t\tif (e.value=='reject') {\n\t\t\t\t\t\t\t\t\t\te.checked = true;\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\te.checked = false;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\talert('Warning! You have chosen to reject all of the proposed redirects, please use this carefully. Press Reset to Undo.');\n\t\t\t\t\t\t}\n\t\t\t\t\t</script>\n\t\t\t\t\t<form method='POST' action='/Special:ProposedRedirects' name='proposedform'>\n\t\t\t\t\t\t<table class='p_redirects'>\n\t\t\t\t\t\t<tr class='toprow'>\n\t\t\t\t\t\t\t<td>User</td><td>Title</td><td>Current Article</td><td>Accept</td><td>Skip</td><td>Reject</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t{$s}\n\t\t\t\t\t\t</table>\n\t\t\t\t\t<table width='100%'>\n\t\t\t\t\t\t<tr><td>\n\t\t\t");
         if ($wgUser->isSysop()) {
             $wgOut->addHTML("<input type='button' class='guided-button' value='Reject all' onclick='rejectAll();'>");
         }
         $wgOut->addHTML("</td><td style='text-align: right;'>\n\t\t\t\t\t\t\t\t<input type='button' class='guided-button' value='Reset' onclick='clearForm();'>\n\t\t\t\t\t\t\t\t<input type='button' class='guided-button' value='" . wfMsg('Submit') . "'onclick='document.proposedform.submit();'>\n\t\t\t\t\t\t\t</td></tr></table>\n\t\t\t\t\t\t</form>");
     }
     $wgOut->addHTML("</div><!--end minor_section-->");
 }
 private function createPage(&$title, &$data)
 {
     $article = new Article($title);
     return $article->insertNewArticle($data, '', false, false, false, false);
 }
Example #13
0
 /**
  * Create a dummy article for rendering content not associated with any title (unless it already exists)
  * - there's probably a better way to do this
  */
 function createUntitled()
 {
     $title = Title::newFromText(SIMPLEFORMS_UNTITLED);
     if (!$title->exists()) {
         $article = new Article($title);
         $article->insertNewArticle('Dummy article used by [http://www.mediawiki.org/wiki/Extension:Simple_Forms Extension:SimpleForms]', 'Dummy article created for Simple Forms extension', true, false);
     }
 }
Example #14
0
 /**
  * Record an image upload in the upload log and the image table
  */
 function recordUpload($oldver, $desc, $license = '', $copyStatus = '', $source = '', $watch = false)
 {
     global $wgUser, $wgUseCopyrightUpload;
     $dbw = wfGetDB(DB_MASTER);
     $this->checkDBSchema($dbw);
     // Delete thumbnails and refresh the metadata cache
     $this->purgeCache();
     // Fail now if the image isn't there
     if (!$this->fileExists || $this->fromSharedDirectory) {
         wfDebug("Image::recordUpload: File " . $this->imagePath . " went missing!\n");
         return false;
     }
     if ($wgUseCopyrightUpload) {
         if ($license != '') {
             $licensetxt = '== ' . wfMsgForContent('license') . " ==\n" . '{{' . $license . '}}' . "\n";
         }
         $textdesc = '== ' . wfMsg('filedesc') . " ==\n" . $desc . "\n" . '== ' . wfMsgForContent('filestatus') . " ==\n" . $copyStatus . "\n" . "{$licensetxt}" . '== ' . wfMsgForContent('filesource') . " ==\n" . $source;
     } else {
         if ($license != '') {
             $filedesc = $desc == '' ? '' : '== ' . wfMsg('filedesc') . " ==\n" . $desc . "\n";
             $textdesc = $filedesc . '== ' . wfMsgForContent('license') . " ==\n" . '{{' . $license . '}}' . "\n";
         } else {
             $textdesc = $desc;
         }
     }
     $now = $dbw->timestamp();
     #split mime type
     if (strpos($this->mime, '/') !== false) {
         list($major, $minor) = explode('/', $this->mime, 2);
     } else {
         $major = $this->mime;
         $minor = "unknown";
     }
     # Test to see if the row exists using INSERT IGNORE
     # This avoids race conditions by locking the row until the commit, and also
     # doesn't deadlock. SELECT FOR UPDATE causes a deadlock for every race condition.
     $dbw->insert('image', array('img_name' => $this->name, 'img_size' => $this->size, 'img_width' => intval($this->width), 'img_height' => intval($this->height), 'img_bits' => $this->bits, 'img_media_type' => $this->type, 'img_major_mime' => $major, 'img_minor_mime' => $minor, 'img_timestamp' => $now, 'img_description' => $desc, 'img_user' => $wgUser->getID(), 'img_user_text' => $wgUser->getName(), 'img_metadata' => $this->metadata), __METHOD__, 'IGNORE');
     if ($dbw->affectedRows() == 0) {
         # Collision, this is an update of an image
         # Insert previous contents into oldimage
         $dbw->insertSelect('oldimage', 'image', array('oi_name' => 'img_name', 'oi_archive_name' => $dbw->addQuotes($oldver), 'oi_size' => 'img_size', 'oi_width' => 'img_width', 'oi_height' => 'img_height', 'oi_bits' => 'img_bits', 'oi_timestamp' => 'img_timestamp', 'oi_description' => 'img_description', 'oi_user' => 'img_user', 'oi_user_text' => 'img_user_text'), array('img_name' => $this->name), __METHOD__);
         # Update the current image row
         $dbw->update('image', array('img_size' => $this->size, 'img_width' => intval($this->width), 'img_height' => intval($this->height), 'img_bits' => $this->bits, 'img_media_type' => $this->type, 'img_major_mime' => $major, 'img_minor_mime' => $minor, 'img_timestamp' => $now, 'img_description' => $desc, 'img_user' => $wgUser->getID(), 'img_user_text' => $wgUser->getName(), 'img_metadata' => $this->metadata), array('img_name' => $this->name), __METHOD__);
     } else {
         # This is a new image
         # Update the image count
         $site_stats = $dbw->tableName('site_stats');
         $dbw->query("UPDATE {$site_stats} SET ss_images=ss_images+1", __METHOD__);
     }
     $descTitle = $this->getTitle();
     $article = new Article($descTitle);
     $minor = false;
     $watch = $watch || $wgUser->isWatched($descTitle);
     $suppressRC = true;
     // There's already a log entry, so don't double the RC load
     if ($descTitle->exists()) {
         // TODO: insert a null revision into the page history for this update.
         if ($watch) {
             $wgUser->addWatch($descTitle);
         }
         # Invalidate the cache for the description page
         $descTitle->invalidateCache();
         $descTitle->purgeSquid();
     } else {
         // New image; create the description page.
         $article->insertNewArticle($textdesc, $desc, $minor, $watch, $suppressRC);
     }
     # Hooks, hooks, the magic of hooks...
     wfRunHooks('FileUpload', array($this));
     # Add the log entry
     $log = new LogPage('upload');
     $log->addEntry('upload', $descTitle, $desc);
     # Commit the transaction now, in case something goes wrong later
     # The most important thing is that images don't get lost, especially archives
     $dbw->immediateCommit();
     # Invalidate cache for all pages using this image
     $update = new HTMLCacheUpdate($this->getTitle(), 'imagelinks');
     $update->doUpdate();
     return true;
 }
Example #15
0
 function execute($par)
 {
     global $wgUser, $wgOut, $wgLang, $wgTitle, $wgMemc, $wgDBname;
     global $wgRequest, $wgSitename, $wgLanguageCode, $IP;
     global $wgScript, $wgParser, $wgFilterCallback, $wgScriptPath;
     $fname = "wfSpecialRequestTopic";
     $action = "";
     if ($wgUser->isBlocked()) {
         $wgOut->blockedPage();
         return;
     }
     if (!$wgRequest->wasPosted()) {
         $wgOut->addHTML("<b>" . wfMsg('lookingforhow') . "</b> <br/> " . wfMsg('requestarticleexdog') . "<br/><br/> ");
         $this->getForm();
     } else {
         // this is a post, accept the POST data and create the
         // Request article
         $topic = $wgRequest->getVal('topic');
         $details = $wgRequest->getVal('details');
         if ($wgUser->getID() == 0 && preg_match("@http://@i", $details)) {
             $wgOut->addHTML("Error: anonymous users are not allowed to include links in requests.");
             return;
         }
         if (!isset($_POST['override']) && $wgLanguageCode == 'en') {
             $l = new LSearch();
             $titles = $l->googleSearchResultTitles($topic, 0, 5);
             if (sizeof($titles) > 0) {
                 $wgOut->addHTML(wfMsg('already-related-topics') . "<br>\n\t\t\t\t\t<ul id=Things_You27ll_Need>");
                 $count = 0;
                 foreach ($titles as $t) {
                     if ($count == 10) {
                         break;
                     }
                     if ($t == null) {
                         continue;
                     }
                     $wgOut->addHTML("<li style='margin-bottom: 0px'><a href=" . $t->getFullURL() . ">How to " . $t->getText() . "</a></li>");
                     $count++;
                 }
                 $wgOut->addHTML("</ul>");
                 $wgOut->addHTML(wfMsg('no-submit-existing-topic'));
                 $this->getForm(true);
                 return;
             }
         }
         // cut off extra ?'s or whatever
         if ($wgLanguageCode == 'en') {
             while (!ereg('[a-zA-Z0-9)\\"]$', $topic)) {
                 $topic = substr($topic, 0, strlen($topic) - 1);
             }
         }
         if ($wgLanguageCode == 'en') {
             require_once 'EditPageWrapper.php';
             $topic = EditPageWrapper::formatTitle($topic);
         }
         $title = Title::newFromText($topic, NS_ARTICLE_REQUEST);
         $category = $wgRequest->getVal("category", "");
         if ($category == "") {
             $category = "Other";
         }
         $details .= "\n[[Category:{$category} Requests]]";
         // check if we can do this
         if ($wgUser->isBlocked()) {
             $wgOut->addWikiText(wfMsg('blocked-ip'));
             return;
         }
         if ($wgUser->pingLimiter()) {
             $wgOut->rateLimited();
             return;
         }
         if ($wgFilterCallback && $wgFilterCallback($title, $details, $tmp)) {
             // Error messages or other handling should be performed by
             // the filter function
             return;
         }
         // create a user
         $user = null;
         if ($wgUser->getID() == 0) {
             if ($wgRequest->getVal('email', null)) {
                 $user = WikihowUser::createTemporaryUser($wgRequest->getVal('name'), $wgRequest->getVal('email'));
                 $wgUser = $user;
             }
         }
         if ($title->getArticleID() <= 0) {
             // not yet created. good.
             $article = new Article($title);
             $ret = $article->insertNewArticle($details, "", false, false, false, $user);
             wfRunHooks('ArticleSaveComplete', array(&$article, &$user, $details, "", false, false, NULL));
             //clear the redirect that is set by insertNewArticle
             $wgOut->redirect('');
             $options = ParserOptions::newFromUser($wgUser);
             $wgParser->parse($details, $title, $options);
         } else {
             // TODO: what to do here? give error / warning? append details?
             // this question has already been asked, if you want to ask
             // a slightly different question, go here:
         }
         $wgOut->addWikiText(wfMsg('thank-you-requesting-topic'));
         $wgOut->returnToMain(false);
     }
 }
 /**
  * NAB user flagged this article as a rising star in the Action section
  * of NAB'ing an article.
  */
 private function flagRisingStar($title)
 {
     global $wgLang, $wgUser, $wgRequest;
     if ($wgRequest->getVal('cb_risingstar', null) != "on") {
         return;
     }
     $dateStr = $wgLang->timeanddate(wfTimestampNow());
     $patrollerName = $wgUser->getName();
     $patrollerRealName = User::whoIsReal($wgUser->getID());
     if (!$patrollerRealName) {
         $patrollerRealName = $patrollerName;
     }
     // post to user talk page
     $contribUsername = $wgRequest->getVal('prevuser', '');
     if ($contribUsername) {
         $this->notifyUserOfRisingStar($title, $contribUsername);
     }
     // Give user a thumbs up. Set oldId to -1 as this should be the
     // first revision
     //if (class_exists('ThumbsUp')) {
     //	ThumbsUp::thumbNAB(-1, $title->getLatestRevID(), $title->getArticleID());
     //}
     // post to article discussion page
     $wikitext = "";
     $article = "";
     $contribUser = new User();
     $contribUser->setName($contribUsername);
     $contribUserPage = $contribUser->getUserPage();
     $contribUserName = $contribUser->getName();
     $patrolUserPage = $wgUser->getUserPage();
     $patrolUserName = $wgUser->getName();
     $talkPage = $title->getTalkPage();
     $comment = '{{Rising-star-discussion-msg-2|[[' . $contribUserPage . '|' . $contribUserName . ']]|[[' . $patrolUserPage . '|' . $patrolUserName . ']]}}' . "\n";
     $formattedComment = wfMsg('postcomment_formatted_comment', $dateStr, $patrollerName, $patrollerRealName, $comment);
     wfRunHooks("MarkTitleAsRisingStar", array($title));
     if ($talkPage->getArticleId() > 0) {
         $rev = Revision::newFromTitle($talkPage);
         $wikitext = $rev->getText();
     }
     $article = new Article($talkPage);
     $wikitext = "{$comment}\n\n" . $wikitext;
     $watch = false;
     if ($wgUser->getID() > 0) {
         $watch = $wgUser->isWatched($talkPage);
     }
     if ($talkPage->getArticleId() > 0) {
         $article->updateArticle($wikitext, wfMsg('nab-rs-discussion-editsummary'), true, $watch);
     } else {
         $article->insertNewArticle($wikitext, wfMsg('nab-rs-discussion-editsummary'), true, $watch, false, false, true);
     }
     // add to fs feed page
     $wikitext = "";
     $article = "";
     $fsfeed = Title::newFromURL('wikiHow:Rising-star-feed');
     $rev = Revision::newFromTitle($fsfeed);
     $article = new Article($fsfeed);
     $wikitext = $rev->getText();
     $watch = false;
     if ($wgUser->getID() > 0) {
         $watch = $wgUser->isWatched($title->getTalkPage());
     }
     $wikitext .= "\n" . date('==Y-m-d==') . "\n" . $title->getFullURL() . "\n";
     $article->updateArticle($wikitext, wfMsg('nab-rs-feed-editsummary'), true, $watch);
 }
Example #17
0
 function reject($uid, $reason, $message)
 {
     global $wgUser, $wgOut, $wgLang;
     if ($wgUser->isBlocked()) {
         $wgOut->blockedPage();
         return;
     }
     if (!in_array('sysop', $wgUser->getGroups())) {
         $wgOut->errorpage('nosuchspecialpage', 'nospecialpagetext');
         return;
     }
     $wgOut->setArticleBodyOnly(true);
     $dbw = wfGetDB(DB_MASTER);
     //REMOVE PICTURE
     $ret = $this->removePicture($uid);
     if (preg_match('/FAILED/', $ret, $matches)) {
         wfDebug("Avatar removePicture failed: " . $ret . "\n");
     }
     //UPDATE DB RECORD
     $sql = "UPDATE avatar SET av_patrol=-1, av_patrolledBy=" . $wgUser->getID() . ", av_patrolledDate='" . wfTimestampNow() . "', av_rejectReason='" . $dbw->addQuotes($reason) . "' WHERE av_user="******"";
     $text = "";
     $article = "";
     if ($message) {
         $comment = $message . "\n";
     }
     if ($comment) {
         $formattedComment = wfMsg('postcomment_formatted_comment', $dateStr, $user, $real_name, $comment);
         if ($user_talk->getArticleId() > 0) {
             $r = Revision::newFromTitle($user_talk);
             $text = $r->getText();
         }
         $article = new Article($user_talk);
         $text .= "\n\n{$formattedComment}\n\n";
         $watch = false;
         if ($wgUser->getID() > 0) {
             $watch = $wgUser->isWatched($user_talk);
         }
         if ($user_talk->getArticleId() > 0) {
             $article->updateArticle($text, wfMsg('avatar-rejection-usertalk-editsummary'), true, $watch);
         } else {
             $article->insertNewArticle($text, wfMsg('avatar-rejection-usertalk-editsummary'), true, $watch, false, false, true);
         }
     }
     return "SUCCESS";
 }
Example #18
0
    function execute($par)
    {
        global $wgRequest, $wgUser, $wgOut, $wgLang, $wgServer;
        wfLoadExtensionMessages('UserTalkTool');
        // CHECK FOR ADMIN STATUS
        if (!in_array('sysop', $wgUser->getGroups())) {
            $wgOut->setArticleRelated(false);
            $wgOut->setRobotpolicy('noindex,nofollow');
            $wgOut->errorpage('nosuchspecialpage', 'nospecialpagetext');
            return;
        }
        // MAKE SURE USER IS NOT BLOCKED
        if ($wgUser->isBlocked()) {
            $wgOut->blockedPage();
            return;
        }
        // CHECK FOR TARGET
        $target = isset($par) ? $par : $wgRequest->getVal('target');
        if ($target == null || $target == "") {
            $wgOut->addHTML('No target specified');
            return;
        }
        $dbw = wfGetDB(DB_MASTER);
        $dbr = wfGetDB(DB_SLAVE);
        $me = Title::makeTitle(NS_SPECIAL, "UserTalkTool");
        // PROCESS FORM
        //
        //
        if ($wgRequest->wasPosted()) {
            $wgOut->setArticleBodyOnly(true);
            $utmsg = $wgRequest->getVal('utmessage');
            if ($utmsg != "") {
                #$t = Title::newFromID($aid);
                $ts = wfTimestampNow();
                $user = $wgUser->getName();
                $real_name = User::whoIsReal($wgUser->getID());
                if ($real_name == "") {
                    $real_name = $user;
                }
                //User
                //
                //
                $utitem = $wgRequest->getVal('utuser');
                wfDebug("UTT: posting user: {$utitem}\n");
                wfDebug("UTT: by admin user: "******"\n");
                if ($utitem != "") {
                    // POST USER TALK PAGE
                    //
                    //
                    $text = "";
                    $aid = "";
                    $a = "";
                    $formattedComment = "";
                    $u = new User();
                    $u->setName($utitem);
                    $user_talk = $u->getTalkPage();
                    $dateStr = $wgLang->timeanddate(wfTimestampNow());
                    $formattedComment = wfMsg('postcomment_formatted_comment', $dateStr, $user, $real_name, mysql_real_escape_string($utmsg));
                    $aid = $user_talk->getArticleId();
                    if ($aid > 0) {
                        $r = Revision::newFromTitle($user_talk);
                        $text = $r->getText();
                    }
                    $a = new Article($user_talk);
                    $text .= "\n\n{$formattedComment}\n\n";
                    if ($aid > 0) {
                        $a->updateArticle($text, "", true, false, false, '', true);
                    } else {
                        $a->insertNewArticle($text, "", true, false, true, false, false);
                    }
                    // MARK CHANGES PATROLLED
                    //
                    //
                    $res = $dbr->select('recentchanges', 'max(rc_id) as rc_id', array('rc_title=\'' . mysql_real_escape_string($utitem) . '\'', 'rc_user='******'rc_cur_id=' . $aid, 'rc_patrolled=0'));
                    while ($row = $dbr->fetchObject($res)) {
                        wfDebug("UTT: mark patroll rcid: " . $row->rc_id . " \n");
                        RecentChange::markPatrolled($row->rc_id);
                        PatrolLog::record($row->rc_id, false);
                    }
                    $dbr->freeResult($res);
                    wfDebug("UTT: done\n");
                    wfDebug("UTT: Completed posting for [" . $utitem . "]\n");
                    $wgOut->addHTML("Completed posting for - " . $utitem);
                } else {
                    wfDebug("UTT: No user\n");
                    $wgOut->addHTML("UT_MSG ERROR: No user specified. \n");
                }
            } else {
                wfDebug("UTT: No message to post\n");
                $wgOut->addHTML("UT_MSG ERROR: No message to post for - " . $utitem . "\n");
                return;
            }
            $wgOut->redirect('');
        } else {
            $sk = $wgUser->getSkin();
            $wgOut->addHTML('
<script language="javascript" src="/extensions/wikihow/common/prototype1.8.2/prototype.js"></script>
<script language="javascript" src="/extensions/wikihow/common/prototype1.8.2/effects.js"></script>
<script language="javascript" src="/extensions/wikihow/common/prototype1.8.2/controls.js"></script>
		' . "\n");
            $wgOut->addHTML("\n\t\t\t<script type='text/javascript'>\n\t\t\t\tfunction utSend () {\n\n\t\t\t\t\t\$('formdiv').style.display = 'none';\n\t\t\t\t\t\$('resultdiv').innerHTML = 'Sending...<br />';\n\n\t\t\t\t\tliArray = document.getElementById('ut_ol').childNodes;\n\t\t\t\t\ti=0;\n\t\t\t\t\twhile(liArray[i]){\n\t\t\t\t\t\tif (document.getElementById(liArray[i].id)) {\n\t\t\t\t\t\t\tif (liArray[i].getAttribute('id').match(/^ut_li_/)) {\n\n\t\t\t\t\t\t\t\tdocument.forms['utForm'].utuser.value = liArray[i].getAttribute('id').replace('ut_li_','');\n\t\t\t\t\t\t\t\t\$('utForm').request({\n\t\t\t\t\t\t\t\t\tasynchronous: false,\n\t\t\t\t\t\t\t\t\tonComplete: function(transport) {\n\t\t\t\t\t\t\t\t\t\t\$('resultdiv').innerHTML += transport.responseText+'<br />';\n\t\t\t\t\t\t\t\t\t\tif (transport.responseText.match(/Completed posting for - /)){\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\tvar u = transport.responseText.replace(/Completed posting for - /,'');\n\t\t\t\t\t\t\t\t\t\t\t//\$('resultdiv').innerHTML += 'UID: '+u+'<br />';\n\t\t\t\t\t\t\t\t\t\t\t\$('ut_li_'+u).innerHTML +=  '  <img src=\"/skins/WikiHow/light_green_check.png\" height=\"15\" width=\"15\" />';\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\tonFailure: function(transport) {\n\t\t\t\t\t\t\t\t\t\t\$('resultdiv').innerHTML += 'Sending returned error for '+liArray[i].id+' <br />';\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\t//\$('resultdiv').innerHTML += 'Sending '+liArray[i].id+'<br />';\n\t\t\t\t\t\t \t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\ti++;\n\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t</script>\n\t\t\t\n\t\t\t");
            // GET LIST OF RECIPIENTS
            //
            //
            if ($target) {
                $t = Title::newFromUrl($target);
                if ($t->getArticleId() <= 0) {
                    $wgOut->addHTML("Target not a valid article.");
                    return;
                } else {
                    $r = Revision::newFromTitle($t);
                    $text = $r->getText();
                    #$wgOut->addHTML( $text );
                    $utcount = preg_match_all('/\\[\\[User_talk:(.*?)[#\\]\\|]/', $text, $matches);
                    #print_r($matches);
                    $utlist = $matches[1];
                }
            }
            // DISPLAY COUNT OF USER TALK PAGES FOUND
            //
            //
            if (count($utlist) == 0) {
                $wgOut->addHTML(wfMsg('notalkpagesfound'));
                return;
            } else {
                $wgOut->addHTML(count($utlist) . ' ' . wfMsg('talkpagesfound') . "<br />");
            }
            // TEXTAREA and FORM
            //
            //
            $wgOut->addHTML('
<form id="utForm" method="post">
				');
            // DISPLAY LIST OF USER TALK PAGES
            //
            //
            $wgOut->addHTML('<div id="utlist" style="border: 1px grey solid;margin: 15px 0px 15px 0px;padding: 15px;height:215px;overflow:auto"><ol id="ut_ol">' . "\n");
            foreach ($utlist as $utitem) {
                $wgOut->addHTML('<li id="ut_li_' . preg_replace('/\\s/m', '-', $utitem) . '"><a href="/User_talk:' . $utitem . '">' . $utitem . '</a></li>' . "\n");
            }
            $wgOut->addHTML('</ol></div>' . "\n");
            // TEXTAREA and FORM
            //
            //
            $wgOut->addHTML('
<div id="formdiv">
' . wfMsg('sendbox') . '<br />
<textarea id="utmessage" name="utmessage" rows="6" style="margin: 5px 0px 5px 0px;"></textarea>
<input id="utuser" type="hidden" name="utuser" value="">

<input tabindex="4" type="button" value="Send" cl1ass="btn" id="postcommentbutton" style="font-size: 110%; font-weight:bold" onclick="utSend(); return false;" />


</form>
</div>
<div id="resultdiv"></div>' . "\n");
        }
    }
Example #19
0
function addWiki($lang, $site, $dbName)
{
    global $IP, $wgLanguageNames, $wgDefaultExternalStore;
    if (!isset($wgLanguageNames[$lang])) {
        print "Language {$lang} not found in \$wgLanguageNames\n";
        return;
    }
    $name = $wgLanguageNames[$lang];
    $dbw = wfGetDB(DB_MASTER);
    $common = "/home/wikipedia/common";
    $maintenance = "{$IP}/maintenance";
    print "Creating database {$dbName} for {$lang}.{$site} ({$name})\n";
    # Set up the database
    $dbw->query("SET table_type=Innodb");
    $dbw->query("CREATE DATABASE {$dbName}");
    $dbw->selectDB($dbName);
    print "Initialising tables\n";
    dbsource("{$maintenance}/tables.sql", $dbw);
    dbsource("{$IP}/extensions/OAI/update_table.sql", $dbw);
    dbsource("{$IP}/extensions/AntiSpoof/sql/patch-antispoof.mysql.sql", $dbw);
    dbsource("{$IP}/extensions/CheckUser/cu_changes.sql", $dbw);
    dbsource("{$IP}/extensions/CheckUser/cu_log.sql", $dbw);
    dbsource("{$IP}/extensions/TitleKey/titlekey.sql", $dbw);
    dbsource("{$IP}/extensions/Oversight/hidden.sql", $dbw);
    dbsource("{$IP}/extensions/GlobalBlocking/localdb_patches/setup-global_block_whitelist.sql", $dbw);
    $dbw->query("INSERT INTO site_stats(ss_row_id) VALUES (1)");
    # Initialise external storage
    if (is_array($wgDefaultExternalStore)) {
        $stores = $wgDefaultExternalStore;
    } elseif ($stores) {
        $stores = array($wgDefaultExternalStore);
    } else {
        $stores = array();
    }
    if (count($stores)) {
        require_once 'ExternalStoreDB.php';
        print "Initialising external storage {$store}...\n";
        global $wgDBuser, $wgDBpassword, $wgExternalServers;
        foreach ($stores as $storeURL) {
            $m = array();
            if (!preg_match('!^DB://(.*)$!', $storeURL, $m)) {
                continue;
            }
            $cluster = $m[1];
            # Hack
            $wgExternalServers[$cluster][0]['user'] = $wgDBuser;
            $wgExternalServers[$cluster][0]['password'] = $wgDBpassword;
            $store = new ExternalStoreDB();
            $extdb =& $store->getMaster($cluster);
            $extdb->query("SET table_type=InnoDB");
            $extdb->query("CREATE DATABASE {$dbName}");
            $extdb->selectDB($dbName);
            dbsource("{$maintenance}/storage/blobs.sql", $extdb);
            $extdb->immediateCommit();
        }
    }
    global $wgTitle, $wgArticle;
    $wgTitle = Title::newFromText(wfMsgWeirdKey("mainpage/{$lang}"));
    print "Writing main page to " . $wgTitle->getPrefixedDBkey() . "\n";
    $wgArticle = new Article($wgTitle);
    $ucsite = ucfirst($site);
    $wgArticle->insertNewArticle(<<<EOT
==This subdomain is reserved for the creation of a [[wikimedia:Our projects|{$ucsite}]] in '''[[w:en:{$name}|{$name}]]''' language==

* Please '''do not start editing''' this new site. This site has a test project on the [[incubator:|Wikimedia Incubator]] (or on the [[betawikiversity:|BetaWikiversity]] or on the [[oldwikisource:|Old Wikisource]]) and it will be imported to here.

* If you would like to help translating the interface to this language, please do not translate here, but go to [[betawiki:|Betawiki]], a special wiki for translating the interface. That way everyone can use it on every wiki using the [[mw:|same software]].

* For information about how to edit and for other general help, see [[m:Help:Contents|Help on Wikimedia's Meta-Wiki]] or [[mw:Help:Contents|Help on MediaWiki.org]].

== Sister projects ==
<span class="plainlinks">
[http://www.wikipedia.org Wikipedia] |
[http://www.wiktionary.org Wiktonary] |
[http://www.wikibooks.org Wikibooks] |
[http://www.wikinews.org Wikinews] |
[http://www.wikiquote.org Wikiquote] |
[http://www.wikisource.org Wikisource]
[http://www.wikiversity.org Wikiversity]
</span>

See Wikimedia's [[m:|Meta-Wiki]] for the coordination of these projects.

[[aa:]]
[[af:]]
[[als:]]
[[ar:]]
[[de:]]
[[en:]]
[[as:]]
[[ast:]]
[[ay:]]
[[az:]]
[[bcl:]]
[[be:]]
[[bg:]]
[[bn:]]
[[bo:]]
[[bs:]]
[[cs:]]
[[co:]]
[[cs:]]
[[cy:]]
[[da:]]
[[el:]]
[[eo:]]
[[es:]]
[[et:]]
[[eu:]]
[[fa:]]
[[fi:]]
[[fr:]]
[[fy:]]
[[ga:]]
[[gl:]]
[[gn:]]
[[gu:]]
[[he:]]
[[hi:]]
[[hr:]]
[[hsb:]]
[[hy:]]
[[ia:]]
[[id:]]
[[is:]]
[[it:]]
[[ja:]]
[[ka:]]
[[kk:]]
[[km:]]
[[kn:]]
[[ko:]]
[[ks:]]
[[ku:]]
[[ky:]]
[[la:]]
[[ln:]]
[[lo:]]
[[lt:]]
[[lv:]]
[[hu:]]
[[mi:]]
[[mk:]]
[[ml:]]
[[mn:]]
[[mr:]]
[[ms:]]
[[mt:]]
[[my:]]
[[na:]]
[[nah:]]
[[nds:]]
[[ne:]]
[[nl:]]
[[no:]]
[[oc:]]
[[om:]]
[[pa:]]
[[pl:]]
[[ps:]]
[[pt:]]
[[qu:]]
[[ro:]]
[[ru:]]
[[sa:]]
[[si:]]
[[sk:]]
[[sl:]]
[[sq:]]
[[sr:]]
[[sv:]]
[[sw:]]
[[ta:]]
[[te:]]
[[tg:]]
[[th:]]
[[tk:]]
[[tl:]]
[[tr:]]
[[tt:]]
[[ug:]]
[[uk:]]
[[ur:]]
[[uz:]]
[[vi:]]
[[vo:]]
[[xh:]]
[[yo:]]
[[za:]]
[[zh:]]
[[zu:]]

EOT
, '', false, false);
    print "Adding to dblists\n";
    # Add to dblist
    $file = fopen("{$common}/all.dblist", "a");
    fwrite($file, "{$dbName}\n");
    fclose($file);
    # Update the sublists
    shell_exec("cd {$common} && ./refresh-dblist");
    #print "Constructing interwiki SQL\n";
    # Rebuild interwiki tables
    #passthru( '/home/wikipedia/conf/interwiki/update' );
    print "Script ended. You still have to:\n* Add any required settings in InitialiseSettings.php\n* Run sync-common-all\n* Run /home/wikipedia/conf/interwiki/update\n";
}