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";
}
Example #2
0
 function setup_database()
 {
     global $wgVersion, $wgDBmwschema, $wgDBts2schema, $wgDBport, $wgDBuser;
     // Make sure that we can write to the correct schema
     // If not, Postgres will happily and silently go to the next search_path item
     $ctest = "mediawiki_test_table";
     $safeschema = $this->quote_ident($wgDBmwschema);
     if ($this->tableExists($ctest, $wgDBmwschema)) {
         $this->doQuery("DROP TABLE {$safeschema}.{$ctest}");
     }
     $SQL = "CREATE TABLE {$safeschema}.{$ctest}(a int)";
     $olde = error_reporting(0);
     $res = $this->doQuery($SQL);
     error_reporting($olde);
     if (!$res) {
         print "<b>FAILED</b>. Make sure that the user \"" . htmlspecialchars($wgDBuser) . "\" can write to the schema \"" . htmlspecialchars($wgDBmwschema) . "\"</li>\n";
         dieout("</ul>");
     }
     $this->doQuery("DROP TABLE {$safeschema}.{$ctest}");
     $res = dbsource("../maintenance/postgres/tables.sql", $this);
     ## Update version information
     $mwv = $this->addQuotes($wgVersion);
     $pgv = $this->addQuotes($this->getServerVersion());
     $pgu = $this->addQuotes($this->mUser);
     $mws = $this->addQuotes($wgDBmwschema);
     $tss = $this->addQuotes($wgDBts2schema);
     $pgp = $this->addQuotes($wgDBport);
     $dbn = $this->addQuotes($this->mDBname);
     $ctype = $this->addQuotes(pg_fetch_result($this->doQuery("SHOW lc_ctype"), 0, 0));
     $SQL = "UPDATE mediawiki_version SET mw_version={$mwv}, pg_version={$pgv}, pg_user={$pgu}, " . "mw_schema = {$mws}, ts2_schema = {$tss}, pg_port={$pgp}, pg_dbname={$dbn}, " . "ctype = {$ctype} " . "WHERE type = 'Creation'";
     $this->query($SQL);
     ## Avoid the non-standard "REPLACE INTO" syntax
     $f = fopen("../maintenance/interwiki.sql", 'r');
     if ($f == false) {
         dieout("<li>Could not find the interwiki.sql file");
     }
     ## We simply assume it is already empty as we have just created it
     $SQL = "INSERT INTO interwiki(iw_prefix,iw_url,iw_local) VALUES ";
     while (!feof($f)) {
         $line = fgets($f, 1024);
         $matches = array();
         if (!preg_match('/^\\s*(\\(.+?),(\\d)\\)/', $line, $matches)) {
             continue;
         }
         $this->query("{$SQL} {$matches['1']},{$matches['2']})");
     }
     print " (table interwiki successfully populated)...\n";
     $this->doQuery("COMMIT");
 }
Example #3
0
 function setup_database()
 {
     global $wgVersion, $wgDBmwschema, $wgDBts2schema, $wgDBport;
     dbsource("../maintenance/postgres/tables.sql", $this);
     ## Update version information
     $mwv = $this->addQuotes($wgVersion);
     $pgv = $this->addQuotes($this->getServerVersion());
     $pgu = $this->addQuotes($this->mUser);
     $mws = $this->addQuotes($wgDBmwschema);
     $tss = $this->addQuotes($wgDBts2schema);
     $pgp = $this->addQuotes($wgDBport);
     $dbn = $this->addQuotes($this->mDBname);
     $ctype = pg_fetch_result($this->doQuery("SHOW lc_ctype"), 0, 0);
     $SQL = "UPDATE mediawiki_version SET mw_version={$mwv}, pg_version={$pgv}, pg_user={$pgu}, " . "mw_schema = {$mws}, ts2_schema = {$tss}, pg_port={$pgp}, pg_dbname={$dbn}, " . "ctype = '{$ctype}' " . "WHERE type = 'Creation'";
     $this->query($SQL);
     ## Avoid the non-standard "REPLACE INTO" syntax
     $f = fopen("../maintenance/interwiki.sql", 'r');
     if ($f == false) {
         dieout("<li>Could not find the interwiki.sql file");
     }
     ## We simply assume it is already empty as we have just created it
     $SQL = "INSERT INTO interwiki(iw_prefix,iw_url,iw_local) VALUES ";
     while (!feof($f)) {
         $line = fgets($f, 1024);
         $matches = array();
         if (!preg_match('/^\\s*(\\(.+?),(\\d)\\)/', $line, $matches)) {
             continue;
         }
         $this->query("{$SQL} {$matches['1']},{$matches['2']})");
     }
     print " (table interwiki successfully populated)...\n";
 }
    public function execute($par = null)
    {
        global $IP, $mvgIP;
        require_once $IP . '/includes/SpecialPage.php';
        require_once $IP . '/includes/Title.php';
        global $wgOut, $wgRequest;
        global $wgServer;
        // "http://www.yourserver.org"
        // (should be equal to 'http://'.$_SERVER['SERVER_NAME'])
        global $wgScript;
        // "/subdirectory/of/wiki/index.php"
        global $wgUser;
        if (!$wgUser->isAllowed('delete')) {
            $wgOut->permissionRequired('delete');
            return;
        }
        $wgOut->setPageTitle(wfMsg('mvadmin'));
        /**** Execute actions if any ****/
        $action = $wgRequest->getText('action');
        if ($action == 'updatetables') {
            $sure = $wgRequest->getText('udsure');
            if ($sure == 'yes') {
                $wgOut->disable();
                // raw output
                ob_start();
                print "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"  \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\" dir=\"ltr\">\n<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><title>Setting up Storage for Metavid Wiki</title></head><body>";
                header("Content-type: text/html; charset=UTF-8");
                global $botUserName, $valid_attributes, $states_ary;
                require_once "{$mvgIP}/maintenance/metavid2mvWiki.inc.php";
                require_once "{$mvgIP}/maintenance/maintenance_util.inc.php";
                require_once "{$mvgIP}/maintenance/metavid_gov_templates.php";
                require_once "{$IP}/install-utils.inc";
                print '<p><b>Creating database tables</b><p><pre>';
                dbsource("extensions/MetavidWiki/maintenance/mv_tables.sql");
                print '</p><p><b>Creating templates</b><pre>';
                upTemplates(false);
                print '</pre></p>';
                print '<p><b>Please check there were no errors</b></p>';
                $returntitle = Title::newFromText('Special:MVAdmin');
                print '<p> Return to <a href="' . htmlspecialchars($returntitle->getFullURL()) . '">Special:MVAdmin</a></p>';
                print '</body></html>';
                ob_flush();
                flush();
                return;
            }
        }
        /**** Normal output ****/
        $html = '<p>This special page helps you during installation and upgrade of 
					<a href="http://metavid.ucsc.edu/wiki/index.php/MetaVidWiki">MetaVidWiki</a>. Remember to backup valuable data before 
					executing administrative functions.</p>' . "\n";
        // creating tables and converting contents from older versions
        $html .= '<form name="buildtables" action="" method="POST">' . "\n" . '<input type="hidden" name="action" value="updatetables" />' . "\n";
        $html .= '<h2>Preparing database for  MetaVidWiki</h2>' . "\n" . '<p>MetaVidWiki requires some minor extensions to the MediaWiki database in 
				order to store the video data. The below function ensures that your database is
				set up properly. The changes made in this step do not affect the rest of the 
				MediaWiki database, and can easily be undone if desired. This setup function
				can be executed multiple times without doing any harm, but it is needed only once on
				installation or upgrade.<p/>' . "\n";
        $html .= '<p>If the operation fails with obscure SQL errors, the database user employed 
				by your wiki (check your LocalSettings.php) probably does not have sufficient 
				permissions. Either grant this user additional persmissions to create and delete 
				tables, or temporarily enter the login of your database root in LocalSettings.php.<p/>' . "\n" . '<input type="hidden" name="udsure" value="yes"/>' . '<input type="submit" value="Initialise or upgrade tables"/></form>' . "\n";
        $wgOut->addHTML($html);
        return true;
    }
Example #5
0
 }
 print " done.</li>\n";
 print "<li>Initializing data...</li>\n";
 $wgDatabase->insert('site_stats', array('ss_row_id' => 1, 'ss_total_views' => 0, 'ss_total_edits' => 0, 'ss_good_articles' => 0));
 # Set up the "regular user" account *if we can, and if we need to*
 if ($conf->Root and $conf->DBtype == 'mysql') {
     # See if we need to
     $wgDatabase2 = $dbc->newFromParams($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1);
     if ($wgDatabase2->isOpen()) {
         # Nope, just close the test connection and continue
         $wgDatabase2->close();
         echo "<li>User {$wgDBuser} exists. Skipping grants.</li>\n";
     } else {
         # Yes, so run the grants
         echo "<li>Granting user permissions to {$wgDBuser} on {$wgDBname}...";
         dbsource("../maintenance/users.sql", $wgDatabase);
         echo "success.</li>\n";
     }
 }
 if ($conf->SysopName) {
     $u = User::newFromName($conf->getSysopName());
     if (!$u) {
         print "<li><strong class=\"error\">Warning:</strong> Skipped sysop account creation - invalid username!</li>\n";
     } else {
         if (0 == $u->idForName()) {
             $u->addToDatabase();
             $u->setPassword($conf->getSysopPass());
             $u->saveSettings();
             $u->addGroup("sysop");
             $u->addGroup("bureaucrat");
             print "<li>Created sysop account <tt>" . htmlspecialchars($conf->SysopName) . "</tt>.</li>\n";
Example #6
0
<?php

/**
 * Makes the required changes for the AbuseFilter extension
 */
require_once getenv('MW_INSTALL_PATH') !== false ? getenv('MW_INSTALL_PATH') . "/maintenance/commandLine.inc" : dirname(__FILE__) . '/../../maintenance/commandLine.inc';
$sqlfile = '/abusefilter.tables.sql';
if ($wgDBtype == 'postgres') {
    $sqlfile = '/abusefilter.tables.pg.sql';
}
dbsource(dirname(__FILE__) . $sqlfile);
// Create the Abuse Filter user.
wfLoadExtensionMessages('AbuseFilter');
$user = User::newFromName(wfMsgForContent('abusefilter-blocker'));
if (!$user->getId()) {
    $user->addToDatabase();
    $user->saveSettings();
    # Increment site_stats.ss_users
    $ssu = new SiteStatsUpdate(0, 0, 0, 0, 1);
    $ssu->doUpdate();
} else {
    // Sorry dude, we need this account.
    $user->setPassword(null);
    $user->setEmail(null);
    $user->saveSettings();
}
# Promote user so it doesn't look too crazy.
$user->addGroup('sysop');
Example #7
0
 /**
  * Create tables, stored procedures, and so on
  */
 public function setup_database()
 {
     // Timeout was being changed earlier due to mysterious crashes
     // Changing it now may cause more problems than not changing it
     //set_time_limit(240);
     try {
         // TODO: switch to root login if available
         // Switch into the correct namespace
         $this->applySchema();
         $this->begin();
         $res = dbsource("../maintenance/ibm_db2/tables.sql", $this);
         $res = null;
         // TODO: update mediawiki_version table
         // TODO: populate interwiki links
         $this->commit();
     } catch (MWException $mwe) {
         print "<br><pre>{$mwe}</pre><br>";
     }
 }
Example #8
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";
}
Example #9
0
if (is_array($wgDefaultExternalStore)) {
    $stores = $wgDefaultExternalStore;
} elseif ($wgDefaultExternalStore) {
    $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 {$to}");
        $extdb->query("ALTER TABLE {$from}.blobs RENAME TO {$to}.blobs");
        $extdb->selectDB($from);
        dbsource("{$maintenance}/storage/blobs.sql", $extdb);
        $extdb->immediateCommit();
    }
}
echo "done.\n";
Example #10
0
<?php

/**
 * Manually run an SQL patch outside of the general updaters.
 * This ensures that the DB options (charset, prefix, engine) are correctly set.
 *
 * @file
 * @ingroup Maintenance
 */
require_once 'commandLine.inc';
require_once "{$IP}/maintenance/updaters.inc";
if ($args) {
    foreach ($args as $arg) {
        $files = array($arg, archive($arg), archive("patch-{$arg}.sql"));
        foreach ($files as $file) {
            if (file_exists($file)) {
                echo "{$file} ...\n";
                dbsource($file);
                continue 2;
            }
        }
        echo "Could not find {$arg}\n";
    }
    echo "done.\n";
} else {
    echo "Run an SQL file into the DB, replacing prefix and charset vars.\n";
    echo "Usage:\n";
    echo "  php maintenance/patchSql.php file1.sql file2.sql ...\n";
    echo "\n";
    echo "Paths in maintenance/archive are automatically expanded if a local file isn't found.\n";
}
Example #11
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";
}