Add AbuseFilter to the installer.
[lhc/web/wiklou.git] / maintenance / addwiki.php
1 <?php
2 /**
3 * Add a new wiki
4 * Wikimedia specific!
5 *
6 * @file
7 * @ingroup Maintenance
8 */
9
10 $wgNoDBParam = true;
11
12 require_once( "commandLine.inc" );
13 require_once( "rebuildInterwiki.inc" );
14 require_once( "languages/Names.php" );
15 if ( count( $args ) != 3 ) {
16 wfDie( "Usage: php addwiki.php <language> <site> <dbname>\nThe site for Wikipedia is 'wikipedia'.\n" );
17 }
18
19 addWiki( $args[0], $args[1], $args[2] );
20
21 # -----------------------------------------------------------------
22
23 function addWiki( $lang, $site, $dbName )
24 {
25 global $IP, $wgLanguageNames, $wgDefaultExternalStore;
26
27 if ( !isset( $wgLanguageNames[$lang] ) ) {
28 print "Language $lang not found in \$wgLanguageNames\n";
29 return;
30 }
31 $name = $wgLanguageNames[$lang];
32
33 $dbw = wfGetDB( DB_MASTER );
34 $common = "/home/wikipedia/common";
35 $maintenance = "$IP/maintenance";
36
37 print "Creating database $dbName for $lang.$site ($name)\n";
38
39 # Set up the database
40 $dbw->query( "SET table_type=Innodb" );
41 $dbw->query( "CREATE DATABASE $dbName" );
42 $dbw->selectDB( $dbName );
43
44 print "Initialising tables\n";
45 dbsource( "$maintenance/tables.sql", $dbw );
46 dbsource( "$IP/extensions/OAI/update_table.sql", $dbw );
47 dbsource( "$IP/extensions/AntiSpoof/sql/patch-antispoof.mysql.sql", $dbw );
48 dbsource( "$IP/extensions/CheckUser/cu_changes.sql", $dbw );
49 dbsource( "$IP/extensions/CheckUser/cu_log.sql", $dbw );
50 dbsource( "$IP/extensions/TitleKey/titlekey.sql", $dbw );
51 dbsource( "$IP/extensions/Oversight/hidden.sql", $dbw );
52 dbsource( "$IP/extensions/GlobalBlocking/localdb_patches/setup-global_block_whitelist.sql", $dbw );
53 dbsource( "$IP/extensions/AbuseFilter/abusefilter.tables.sql", $dbw );
54
55 $dbw->query( "INSERT INTO site_stats(ss_row_id) VALUES (1)" );
56
57 # Initialise external storage
58 if ( is_array( $wgDefaultExternalStore ) ) {
59 $stores = $wgDefaultExternalStore;
60 } elseif ( $stores ) {
61 $stores = array( $wgDefaultExternalStore );
62 } else {
63 $stores = array();
64 }
65 if ( count( $stores ) ) {
66 require_once( 'ExternalStoreDB.php' );
67 global $wgDBuser, $wgDBpassword, $wgExternalServers;
68 foreach ( $stores as $storeURL ) {
69 $m = array();
70 if ( !preg_match( '!^DB://(.*)$!', $storeURL, $m ) ) {
71 continue;
72 }
73
74 $cluster = $m[1];
75 print "Initialising external storage $cluster...\n";
76
77 # Hack
78 $wgExternalServers[$cluster][0]['user'] = $wgDBuser;
79 $wgExternalServers[$cluster][0]['password'] = $wgDBpassword;
80
81 $store = new ExternalStoreDB;
82 $extdb = $store->getMaster( $cluster );
83 $extdb->query( "SET table_type=InnoDB" );
84 $extdb->query( "CREATE DATABASE $dbName" );
85 $extdb->selectDB( $dbName );
86
87 # Hack x2
88 $blobsTable = $store->getTable( $extdb );
89 $blobsFile = popen( "sed s/blobs\\\\\\>/$blobsTable/ $maintenance/storage/blobs.sql", 'r' );
90 $extdb->sourceStream( $blobsFile );
91 pclose( $blobsFile );
92 $extdb->immediateCommit();
93 }
94 }
95
96 global $wgTitle, $wgArticle;
97 $wgTitle = Title::newFromText( wfMsgWeirdKey( "mainpage/$lang" ) );
98 print "Writing main page to " . $wgTitle->getPrefixedDBkey() . "\n";
99 $wgArticle = new Article( $wgTitle );
100 $ucsite = ucfirst( $site );
101
102 $wgArticle->insertNewArticle( <<<EOT
103 ==This subdomain is reserved for the creation of a [[wikimedia:Our projects|$ucsite]] in '''[[w:en:{$name}|{$name}]]''' language==
104
105 * 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.
106
107 * 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]].
108
109 * 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]].
110
111 == Sister projects ==
112 <span class="plainlinks">
113 [http://www.wikipedia.org Wikipedia] |
114 [http://www.wiktionary.org Wiktonary] |
115 [http://www.wikibooks.org Wikibooks] |
116 [http://www.wikinews.org Wikinews] |
117 [http://www.wikiquote.org Wikiquote] |
118 [http://www.wikisource.org Wikisource]
119 [http://www.wikiversity.org Wikiversity]
120 </span>
121
122 See Wikimedia's [[m:|Meta-Wiki]] for the coordination of these projects.
123
124 [[aa:]]
125 [[af:]]
126 [[als:]]
127 [[ar:]]
128 [[de:]]
129 [[en:]]
130 [[as:]]
131 [[ast:]]
132 [[ay:]]
133 [[az:]]
134 [[bcl:]]
135 [[be:]]
136 [[bg:]]
137 [[bn:]]
138 [[bo:]]
139 [[bs:]]
140 [[cs:]]
141 [[co:]]
142 [[cs:]]
143 [[cy:]]
144 [[da:]]
145 [[el:]]
146 [[eo:]]
147 [[es:]]
148 [[et:]]
149 [[eu:]]
150 [[fa:]]
151 [[fi:]]
152 [[fr:]]
153 [[fy:]]
154 [[ga:]]
155 [[gl:]]
156 [[gn:]]
157 [[gu:]]
158 [[he:]]
159 [[hi:]]
160 [[hr:]]
161 [[hsb:]]
162 [[hy:]]
163 [[ia:]]
164 [[id:]]
165 [[is:]]
166 [[it:]]
167 [[ja:]]
168 [[ka:]]
169 [[kk:]]
170 [[km:]]
171 [[kn:]]
172 [[ko:]]
173 [[ks:]]
174 [[ku:]]
175 [[ky:]]
176 [[la:]]
177 [[ln:]]
178 [[lo:]]
179 [[lt:]]
180 [[lv:]]
181 [[hu:]]
182 [[mi:]]
183 [[mk:]]
184 [[ml:]]
185 [[mn:]]
186 [[mr:]]
187 [[ms:]]
188 [[mt:]]
189 [[my:]]
190 [[na:]]
191 [[nah:]]
192 [[nds:]]
193 [[ne:]]
194 [[nl:]]
195 [[no:]]
196 [[oc:]]
197 [[om:]]
198 [[pa:]]
199 [[pl:]]
200 [[ps:]]
201 [[pt:]]
202 [[qu:]]
203 [[ro:]]
204 [[ru:]]
205 [[sa:]]
206 [[si:]]
207 [[sk:]]
208 [[sl:]]
209 [[sq:]]
210 [[sr:]]
211 [[sv:]]
212 [[sw:]]
213 [[ta:]]
214 [[te:]]
215 [[tg:]]
216 [[th:]]
217 [[tk:]]
218 [[tl:]]
219 [[tr:]]
220 [[tt:]]
221 [[ug:]]
222 [[uk:]]
223 [[ur:]]
224 [[uz:]]
225 [[vi:]]
226 [[vo:]]
227 [[xh:]]
228 [[yo:]]
229 [[za:]]
230 [[zh:]]
231 [[zu:]]
232
233 EOT
234 , '', false, false );
235
236 print "Adding to dblists\n";
237
238 # Add to dblist
239 $file = fopen( "$common/all.dblist", "a" );
240 fwrite( $file, "$dbName\n" );
241 fclose( $file );
242
243 # Update the sublists
244 shell_exec("cd $common && ./refresh-dblist");
245
246 #print "Constructing interwiki SQL\n";
247 # Rebuild interwiki tables
248 #passthru( '/home/wikipedia/conf/interwiki/update' );
249
250 print "Script ended. You still have to:
251 * Add any required settings in InitialiseSettings.php
252 * Run sync-common-all
253 * Run /home/wikipedia/conf/interwiki/update
254 ";
255 }
256