* Make some more messages '*-summary' customizeable through Special:Allmessages or...
[lhc/web/wiklou.git] / maintenance / addwiki.php
1 <?php
2
3 $wgNoDBParam = true;
4
5 require_once( "commandLine.inc" );
6 require_once( "rebuildInterwiki.inc" );
7 require_once( "languages/Names.php" );
8 if ( count( $args ) != 3 ) {
9 wfDie( "Usage: php addwiki.php <language> <site> <dbname>\n" );
10 }
11
12 addWiki( $args[0], $args[1], $args[2] );
13
14 # -----------------------------------------------------------------
15
16 function addWiki( $lang, $site, $dbName )
17 {
18 global $IP, $wgLanguageNames, $wgDefaultExternalStore;
19
20 $name = $wgLanguageNames[$lang];
21
22 $dbw =& wfGetDB( DB_WRITE );
23 $common = "/home/wikipedia/common";
24 $maintenance = "$IP/maintenance";
25
26 print "Creating database $dbName for $lang.$site\n";
27
28 # Set up the database
29 $dbw->query( "SET table_type=Innodb" );
30 $dbw->query( "CREATE DATABASE $dbName" );
31 $dbw->selectDB( $dbName );
32
33 print "Initialising tables\n";
34 dbsource( "$maintenance/tables.sql", $dbw );
35 dbsource( "$IP/extensions/OAI/update_table.sql", $dbw );
36 dbsource( "$IP/extensions/AntiSpoof/mysql/patch-antispoof.sql", $dbw );
37 $dbw->query( "INSERT INTO site_stats(ss_row_id) VALUES (1)" );
38
39 # Initialise external storage
40 if ( is_array( $wgDefaultExternalStore ) ) {
41 $stores = $wgDefaultExternalStore;
42 } elseif ( $stores ) {
43 $stores = array( $wgDefaultExternalStore );
44 } else {
45 $stores = array();
46 }
47 if ( count( $stores ) ) {
48 require_once( 'ExternalStoreDB.php' );
49 print "Initialising external storage $store...\n";
50 global $wgDBuser, $wgDBpassword, $wgExternalServers;
51 foreach ( $stores as $storeURL ) {
52 if ( !preg_match( '!^DB://(.*)$!', $storeURL, $m ) ) {
53 continue;
54 }
55
56 $cluster = $m[1];
57
58 # Hack
59 $wgExternalServers[$cluster][0]['user'] = $wgDBuser;
60 $wgExternalServers[$cluster][0]['password'] = $wgDBpassword;
61
62 $store = new ExternalStoreDB;
63 $extdb =& $store->getMaster( $cluster );
64 $extdb->query( "SET table_type=InnoDB" );
65 $extdb->query( "CREATE DATABASE $dbName" );
66 $extdb->selectDB( $dbName );
67 dbsource( "$maintenance/storage/blobs.sql", $extdb );
68 $extdb->immediateCommit();
69 }
70 }
71
72 $wgTitle = Title::newMainPage();
73 $wgArticle = new Article( $wgTitle );
74 $ucsite = ucfirst( $site );
75
76 $wgArticle->insertNewArticle( "
77 ==This subdomain is reserved for the creation of a $ucsite in '''[[:en:{$name}|{$name}]]''' language==
78
79 If you can write in this language and want to collaborate in the creation of this encyclopedia then '''you''' can make it.
80
81 Go ahead. Translate this page and start working on your encyclopedia.
82
83 For help, see '''[[m:Help:How to start a new Wikipedia|how to start a new Wikipedia]]'''.
84
85 ==Sister projects==
86 [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]
87
88 See the [http://www.wikipedia.org Wikipedia portal] for other language Wikipedias.
89
90 [[aa:]]
91 [[af:]]
92 [[als:]]
93 [[ar:]]
94 [[de:]]
95 [[en:]]
96 [[as:]]
97 [[ast:]]
98 [[ay:]]
99 [[az:]]
100 [[be:]]
101 [[bg:]]
102 [[bn:]]
103 [[bo:]]
104 [[bs:]]
105 [[cs:]]
106 [[co:]]
107 [[cs:]]
108 [[cy:]]
109 [[da:]]
110 [[el:]]
111 [[eo:]]
112 [[es:]]
113 [[et:]]
114 [[eu:]]
115 [[fa:]]
116 [[fi:]]
117 [[fr:]]
118 [[fy:]]
119 [[ga:]]
120 [[gl:]]
121 [[gn:]]
122 [[gu:]]
123 [[he:]]
124 [[hi:]]
125 [[hr:]]
126 [[hy:]]
127 [[ia:]]
128 [[id:]]
129 [[is:]]
130 [[it:]]
131 [[ja:]]
132 [[ka:]]
133 [[kk:]]
134 [[km:]]
135 [[kn:]]
136 [[ko:]]
137 [[ks:]]
138 [[ku:]]
139 [[ky:]]
140 [[la:]]
141 [[ln:]]
142 [[lo:]]
143 [[lt:]]
144 [[lv:]]
145 [[hu:]]
146 [[mi:]]
147 [[mk:]]
148 [[ml:]]
149 [[mn:]]
150 [[mr:]]
151 [[ms:]]
152 [[mt:]]
153 [[my:]]
154 [[na:]]
155 [[nah:]]
156 [[nds:]]
157 [[ne:]]
158 [[nl:]]
159 [[no:]]
160 [[oc:]]
161 [[om:]]
162 [[pa:]]
163 [[pl:]]
164 [[ps:]]
165 [[pt:]]
166 [[qu:]]
167 [[ro:]]
168 [[ru:]]
169 [[sa:]]
170 [[si:]]
171 [[sk:]]
172 [[sl:]]
173 [[sq:]]
174 [[sr:]]
175 [[sv:]]
176 [[sw:]]
177 [[ta:]]
178 [[te:]]
179 [[tg:]]
180 [[th:]]
181 [[tk:]]
182 [[tl:]]
183 [[tr:]]
184 [[tt:]]
185 [[ug:]]
186 [[uk:]]
187 [[ur:]]
188 [[uz:]]
189 [[vi:]]
190 [[vo:]]
191 [[xh:]]
192 [[yo:]]
193 [[za:]]
194 [[zh:]]
195 [[zu:]]
196 ", '', false, false );
197
198 print "Adding to dblists\n";
199
200 # Add to dblist
201 $file = fopen( "$common/all.dblist", "a" );
202 fwrite( $file, "$dbName\n" );
203 fclose( $file );
204
205 # Update the sublists
206 system("cd $common && ./refresh-dblist");
207
208 print "Constructing interwiki SQL\n";
209 # Rebuild interwiki tables
210 $sql = getRebuildInterwikiSQL();
211 $tempname = tempnam( '/tmp', 'addwiki' );
212 $file = fopen( $tempname, 'w' );
213 if ( !$file ) {
214 wfDie( "Error, unable to open temporary file $tempname\n" );
215 }
216 fwrite( $file, $sql );
217 fclose( $file );
218 print "Sourcing interwiki SQL\n";
219 dbsource( $tempname, $dbw );
220 #unlink( $tempname );
221
222 # Create the upload dir
223 global $wgUploadDirectory;
224 if( file_exists( $wgUploadDirectory ) ) {
225 echo "$wgUploadDirectory already exists.\n";
226 } else {
227 echo "Creating $wgUploadDirectory...\n";
228 mkdir( $wgUploadDirectory, 0777 );
229 chmod( $wgUploadDirectory, 0777 );
230 }
231
232 print "Script ended. You now want to run sync-common-all to publish *dblist files (check them for duplicates first)\n";
233 }
234 ?>