r1292 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r1291‎ | r1292 | r1293 >
Date:07:30, 16 April 2003
Author:lcrocker
Status:old
Tags:
Comment:
New update script, Version.php, new salted passwords, minor fixes.
Modified paths:
  • /trunk/phase3/LocalSettings.sample (modified) (history)
  • /trunk/phase3/Version.php (added) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/OutputPage.php (modified) (history)
  • /trunk/phase3/includes/SpecialUserlogin.php (modified) (history)
  • /trunk/phase3/includes/User.php (modified) (history)
  • /trunk/phase3/install.php (modified) (history)
  • /trunk/phase3/languages/Language.php (modified) (history)
  • /trunk/phase3/testsuite/src/com/piclab/wikitest/UploadTest.java (modified) (history)
  • /trunk/phase3/update.php (modified) (history)

Diff [purge]

Index: trunk/phase3/testsuite/src/com/piclab/wikitest/UploadTest.java
@@ -24,6 +24,61 @@
2525 }
2626
2727 private int part1() throws Exception {
 28+ WebResponse wr = getResponse( viewUrl( "Special:Upload" ) );
 29+ String text = getArticle( wr );
 30+
 31+ String[] goodpats = { "<h1[^>]*>Not logged in</h1>" };
 32+ int c = 0;
 33+
 34+ if ( 0 != ( c = checkGoodPatterns( text, goodpats ) ) ) {
 35+ return 100 + c;
 36+ }
 37+ wr = loginAs( "Fred", "Fred" );
 38+ wr = viewPage( "Special:Upload" );
 39+ text = getArticle( wr );
 40+
 41+ String[] goodpats2 = {
 42+ "<h1[^>]*>Upload file</h1>", ">image use policy<", ">upload log<"
 43+ };
 44+ if ( 0 != ( c = checkGoodPatterns( text, goodpats2 ) ) ) {
 45+ return 110 + c;
 46+ }
 47+
 48+ WebForm wf = getFormByName( wr, "upload" );
 49+ WebRequest req = wf.getRequest( "wpUpload" );
 50+
 51+ req.selectFile( "wpUploadFile", new java.io.File( "./data/startrek.png" ) );
 52+ req.setParameter( "wpUploadDescription", "Upload test" );
 53+
 54+ wr = getResponse( req );
 55+ text = getArticle( wr );
 56+
 57+ String[] goodpats3 = {
 58+ "<h1[^>]*>Upload error</h1>", "You must affirm"
 59+ };
 60+ if ( 0 != ( c = checkGoodPatterns( text, goodpats2 ) ) ) {
 61+ return 120 + c;
 62+ }
 63+
 64+ wr = viewPage( "Special:Upload" );
 65+ text = getArticle( wr );
 66+
 67+ wf = getFormByName( wr, "upload" );
 68+ req = wf.getRequest( "wpUpload" );
 69+ req.selectFile( "wpUploadFile", new java.io.File( "./data/startrek.png" ) );
 70+ req.setParameter( "wpUploadDescription", "Upload test" );
 71+ req.setParameter( "wpUploadAffirm", "1" );
 72+
 73+ wr = getResponse( req );
 74+ text = getArticle( wr );
 75+
 76+ String[] goodpats4 = {
 77+ "uploaded successfully", "description page"
 78+ };
 79+ if ( 0 != ( c = checkGoodPatterns( text, goodpats4 ) ) ) {
 80+ return 130 + c;
 81+ }
 82+
2883 return 0;
2984 }
3085
Index: trunk/phase3/LocalSettings.sample
@@ -15,8 +15,6 @@
1616
1717 $IP = "/usr/local/apache/htdocs/wiki";
1818
19 -# This workaround is for the maintenance scripts:
20 -#
2119 if ( ! isset( $DP ) ) { $DP = $IP; }
2220 include_once( "$DP/DefaultSettings.php" );
2321
@@ -31,10 +29,10 @@
3230
3331 # MySQL settings
3432 #
35 -$wgDBserver = "127.0.0.1";
 33+$wgDBserver = "localhost";
3634 $wgDBname = "wikidb";
3735 $wgDBpassword = "userpass";
38 -#wgDBsqlpassword = "sqlpass";
 36+$wgDBsqlpassword = "sqlpass";
3937 $wgDBminWordLen = 3; # Match this to your MySQL fulltext
4038 $wgDBtransactions = false; # Set to true if using InnoDB tables
4139
Index: trunk/phase3/install.php
@@ -10,17 +10,28 @@
1111 "source directory before running this install script.\n";
1212 exit();
1313 }
 14+if ( $wgUseTeX && ( ! is_executable( "./math/texvc" ) ) ) {
 15+ print "To use math functions, you must first compile texvc by\n" .
 16+ "running \"make\" in the math directory.\n";
 17+ exit();
 18+}
1419
1520 $DP = "./includes";
1621 include_once( "./LocalSettings.php" );
1722 include_once( "./AdminSettings.php" );
1823
19 -if ( $wgUseTeX && ( ! is_executable( "./math/texvc" ) ) ) {
20 - print "To use math functions, you must first compile texvc by\n" .
21 - "running \"make\" in the math directory.\n";
22 - exit();
 24+if ( is_file( "{$IP}/Version.php" ) ) {
 25+ print "There appears to be an installation of the software\n" .
 26+ "already present on \"{$IP}\". You may want to run the update\n" .
 27+ "script instead. If you continue with this installation script,\n" .
 28+ "that software and all of its data will be overwritten.\n" .
 29+ "Are you sure you want to do this? (yes/no) ";
 30+
 31+ $response = readconsole();
 32+ if ( ! ( "Y" == $response{0} || "y" == $response{0} ) ) { exit(); }
2333 }
2434
 35+$wgCommandLineMode = true;
2536 umask( 000 );
2637 set_time_limit( 0 );
2738
@@ -36,22 +47,14 @@
3748 print "Copying files...\n";
3849
3950 copyfile( ".", "LocalSettings.php", $IP );
 51+copyfile( ".", "Version.php", $IP );
4052 copyfile( ".", "wiki.phtml", $IP );
4153 copyfile( ".", "redirect.phtml", $IP );
4254 copyfile( ".", "texvc.phtml", $IP );
4355
44 -$handle = opendir( "./includes" );
45 -while ( false !== ( $f = readdir( $handle ) ) ) {
46 - if ( "." == $f{0} ) continue;
47 - copyfile( "./includes", $f, $IP );
48 -}
 56+copydirectory( "./includes", $IP );
 57+copydirectory( "./stylesheets", $wgStyleSheetsDirectory );
4958
50 -$handle = opendir( "./stylesheets" );
51 -while ( false !== ( $f = readdir( $handle ) ) ) {
52 - if ( "." == $f{0} ) continue;
53 - copyfile( "./stylesheets", $f, $wgStyleSheetDirectory );
54 -}
55 -
5659 copyfile( "./images", "wiki.png", $wgUploadDirectory );
5760 copyfile( "./languages", "Language.php", $IP );
5861 copyfile( "./languages", "Language" . ucfirst( $wgLanguageCode ) . ".php", $IP );
@@ -114,6 +117,8 @@
115118 print "Adding indexes...\n";
116119 dbsource( $rconn, "./maintenance/indexes.sql" );
117120
 121+copyfile( ".", "Version.php", $IP );
 122+
118123 print "Done.\nBrowse \"{$wgServer}{$wgScript}\" to test,\n" .
119124 "or \"run WikiSuite -b -o\" in test suite.\n";
120125 exit();
@@ -122,14 +127,14 @@
123128 # Functions used above:
124129 #
125130 function makedirectory( $d ) {
126 - global $installOwner, $installGroup;
 131+ global $wgInstallOwner, $wgInstallGroup;
127132
128133 if ( is_dir( $d ) ) {
129134 print "Directory \"{$d}\" exists.\n";
130135 } else {
131136 if ( mkdir( $d, 0777 ) ) {
132 - if ( isset( $installOwner ) ) { chown( $d, $installOwner ); }
133 - if ( isset( $installGroup ) ) { chgrp( $d, $installGroup ); }
 137+ if ( isset( $wgInstallOwner ) ) { chown( $d, $wgInstallOwner ); }
 138+ if ( isset( $wgInstallGroup ) ) { chgrp( $d, $wgInstallGroup ); }
134139 print "Directory \"{$d}\" created.\n";
135140 } else {
136141 print "Could not create directory \"{$d}\".\n";
@@ -138,13 +143,13 @@
139144 }
140145 }
141146
142 -function copyfile( $sdir, $name, $ddir, $perms = 0644 ) {
143 - global $installOwner, $installGroup;
 147+function copyfile( $sdir, $name, $ddir, $perms = 0664 ) {
 148+ global $wgInstallOwner, $wgInstallGroup;
144149
145150 $d = "{$ddir}/{$name}";
146151 if ( copy( "{$sdir}/{$name}", $d ) ) {
147 - if ( isset( $installOwner ) ) { chown( $d, $installOwner ); }
148 - if ( isset( $installGroup ) ) { chgrp( $d, $installGroup ); }
 152+ if ( isset( $wgInstallOwner ) ) { chown( $d, $wgInstallOwner ); }
 153+ if ( isset( $wgInstallGroup ) ) { chgrp( $d, $wgInstallGroup ); }
149154 chmod( $d, $perms );
150155 # print "Copied \"{$name}\" to \"{$ddir}\".\n";
151156 } else {
@@ -153,6 +158,15 @@
154159 }
155160 }
156161
 162+function copydirectory( $source, $dest ) {
 163+ $handle = opendir( $source );
 164+ while ( false !== ( $f = readdir( $handle ) ) ) {
 165+ if ( "." == $f{0} ) continue;
 166+ if ( "CVS" == $f ) continue;
 167+ copyfile( $source, $f, $dest );
 168+ }
 169+}
 170+
157171 function readconsole() {
158172 $fp = fopen( "php://stdin", "r" );
159173 $resp = trim( fgets( $fp ) );
@@ -254,6 +268,11 @@
255269 "cur_restrictions) VALUES ({$wns},'{$dlp}','" .
256270 wfStrencode( wfMsg( "dellogpagetext" ) ) . "','sysop')";
257271 wfQuery( $sql );
 272+
 273+ $sql = "INSERT INTO cur (cur_namespace,cur_title,cur_text) " .
 274+ "VALUES (0,'" . wfStrencode( wfMsg( "mainpage" ) ) . "','" .
 275+ wfStrencode( wfMsg( "mainpagetext" ) ) . "')";
 276+ wfQuery( $sql );
258277 }
259278
260279 ?>
Index: trunk/phase3/includes/User.php
@@ -8,6 +8,7 @@
99 /* private */ var $mSkin;
1010 /* private */ var $mBlockedby, $mBlockreason;
1111 /* private */ var $mTouched;
 12+ /* private */ var $mCookiePassword;
1213
1314 function User()
1415 {
@@ -45,15 +46,15 @@
4647 return $s->user_id;
4748 }
4849 }
49 -
 50+
5051 # does the string match an anonymous user IP address?
5152 /* static */ function isIP( $name ) {
5253 return preg_match("/^\d{1,3}\.\d{1,3}.\d{1,3}\.\d{1,3}$/",$name);
53 -
 54+
5455 }
55 -
56 -
5756
 57+
 58+
5859 /* static */ function randomPassword()
5960 {
6061 $pwchars = "ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz";
@@ -84,6 +85,7 @@
8586 $this->mDataLoaded = false;
8687 $this->mBlockedby = -1; # Unset
8788 $this->mTouched = '0'; # Allow any pages to be cached
 89+ $this->cookiePassword = "";
8890 }
8991
9092 /* private */ function getBlockedStatus()
@@ -152,21 +154,23 @@
153155 $this->mId = 0;
154156 return;
155157 }
 158+
 159+ $passwordCorrect = FALSE;
 160+ $this->mId = $sId;
 161+ $this->loadFromDatabase();
 162+
156163 if ( isset( $wsUserPassword ) ) {
157 - $sPass = $wsUserPassword;
 164+ $passwordCorrect = $wsUserPassword == $this->mPassword;
158165 } else if ( isset( $HTTP_COOKIE_VARS["wcUserPassword"] ) ) {
159 - $sPass = $HTTP_COOKIE_VARS["wcUserPassword"];
160 - $wsUserPassword = $sPass;
 166+ $this->mCookiePassword = $HTTP_COOKIE_VARS["wcUserPassword"];
 167+ $wsUserPassword = $this->addSalt($this->mCookiePassword);
 168+ $passwordCorrect = $wsUserPassword == $this->mPassword;
161169 } else {
162170 $this->mId = 0;
163171 return;
164172 }
165 - $this->mId = $sId;
166 - $this->loadFromDatabase();
167173
168 - if ( ( $sName == $this->mName ) &&
169 - ( ( $sPass == $this->mPassword ) ||
170 - ( $sPass == $this->mNewpassword ) ) ) {
 174+ if ( ( $sName == $this->mName ) && $passwordCorrect ) {
171175 return;
172176 }
173177 $this->loadDefaults(); # Can't log in from session
@@ -174,22 +178,22 @@
175179
176180 function loadFromDatabase()
177181 {
178 - if ( $this->mDataLoaded ) { return; }
 182+ if ( $this->mDataLoaded ) { return; }
179183 # check in separate table if there are changes to the talk page
180184 $this->mNewtalk=0; # reset talk page status
181 - if($this->mId) {
182 - $sql = "SELECT 1 FROM user_newtalk WHERE user_id={$this->mId}";
 185+ if($this->mId) {
 186+ $sql = "SELECT 1 FROM user_newtalk WHERE user_id={$this->mId}";
183187 $res = wfQuery ($sql, "User::loadFromDatabase" );
184188
185 - if (wfNumRows($res)>0) {
 189+ if (wfNumRows($res)>0) {
186190 $this->mNewtalk= 1;
187191 }
188192 wfFreeResult( $res );
189193 } else {
190 - $sql = "SELECT 1 FROM user_newtalk WHERE user_ip='{$this->mName}'";
 194+ $sql = "SELECT 1 FROM user_newtalk WHERE user_ip='{$this->mName}'";
191195 $res = wfQuery ($sql, "User::loadFromDatabase" );
192 -
193 - if (wfNumRows($res)>0) {
 196+
 197+ if (wfNumRows($res)>0) {
194198 $this->mNewtalk= 1;
195199 }
196200 wfFreeResult( $res );
@@ -198,7 +202,7 @@
199203 $this->mDataLoaded = true;
200204 return;
201205 } # the following stuff is for non-anonymous users only
202 -
 206+
203207 $sql = "SELECT user_name,user_password,user_newpassword,user_email," .
204208 "user_options,user_rights,user_touched FROM user WHERE user_id=" .
205209 "{$this->mId}";
@@ -213,8 +217,8 @@
214218 $this->decodeOptions( $s->user_options );
215219 $this->mRights = explode( ",", strtolower( $s->user_rights ) );
216220 $this->mTouched = $s->user_touched;
217 - }
218 -
 221+ }
 222+
219223 wfFreeResult( $res );
220224 $this->mDataLoaded = true;
221225 }
@@ -248,19 +252,19 @@
249253 $this->mNewtalk = $val;
250254 $this->invalidateCache();
251255 }
252 -
 256+
253257 function invalidateCache() {
254258 $this->loadFromDatabase();
255259 $this->mTouched = wfTimestampNow();
256260 # Don't forget to save the options after this or
257261 # it won't take effect!
258262 }
259 -
 263+
260264 function validateCache( $timestamp ) {
261265 $this->loadFromDatabase();
262266 return ($timestamp >= $this->mTouched);
263267 }
264 -
 268+
265269 function getPassword()
266270 {
267271 $this->loadFromDatabase();
@@ -273,23 +277,34 @@
274278 return $this->mNewpassword;
275279 }
276280
277 - /* static */ function encryptPassword( $p )
 281+ function addSalt( $p )
278282 {
279 - $np = md5( $p );
280 - return $np;
 283+ return md5( "wikipedia{$this->mId}-{$p}" );
281284 }
282285
 286+ function encryptPassword( $p )
 287+ {
 288+ return $this->addSalt( md5( $p ) );
 289+ }
 290+
283291 function setPassword( $str )
284292 {
285293 $this->loadFromDatabase();
286 - $this->mPassword = User::encryptPassword( $str );
 294+ $this->setCookiePassword( $str );
 295+ $this->mPassword = $this->encryptPassword( $str );
287296 $this->mNewpassword = "";
288297 }
289298
 299+ function setCookiePassword( $str )
 300+ {
 301+ $this->loadFromDatabase();
 302+ $this->mCookiePassword = md5( $str );
 303+ }
 304+
290305 function setNewpassword( $str )
291306 {
292307 $this->loadFromDatabase();
293 - $this->mNewpassword = User::encryptPassword( $str );
 308+ $this->mNewpassword = $this->encryptPassword( $str );
294309 }
295310
296311 function getEmail()
@@ -342,15 +357,15 @@
343358
344359 return in_array( "developer", $this->mRights );
345360 }
346 -
 361+
347362 function isBot()
348363 {
349364 $this->loadFromDatabase();
350365 if ( 0 == $this->mId ) { return false; }
351 -
 366+
352367 return in_array( "bot", $this->mRights );
353368 }
354 -
 369+
355370 function &getSkin()
356371 {
357372 if ( ! isset( $this->mSkin ) ) {
@@ -443,7 +458,7 @@
444459
445460 $wsUserPassword = $this->mPassword;
446461 if ( 1 == $this->getOption( "rememberpassword" ) ) {
447 - setcookie( "wcUserPassword", $this->mPassword, $exp, "/" );
 462+ setcookie( "wcUserPassword", $this->mCookiePassword, $exp, "/" );
448463 } else {
449464 setcookie( "wcUserPassword", "", time() - 3600 );
450465 }
@@ -463,22 +478,22 @@
464479 function saveSettings()
465480 {
466481 global $wgUser;
467 -
 482+
468483 if(!$this->mNewtalk) {
469 -
 484+
470485 if($this->mId) {
471486 $sql="DELETE FROM user_newtalk WHERE user_id={$this->mId}";
472487 wfQuery ($sql,"User::saveSettings");
473488 } else {
474 -
475 -
 489+
 490+
476491 $sql="DELETE FROM user_newtalk WHERE user_ip='{$this->mName}'";
477492 wfQuery ($sql,"User::saveSettings");
478 -
 493+
479494 }
480495 }
481496
482 - if ( 0 == $this->mId ) { return; }
 497+ if ( 0 == $this->mId ) { return; }
483498
484499 $sql = "UPDATE user SET " .
485500 "user_name= '" . wfStrencode( $this->mName ) . "', " .
@@ -486,7 +501,8 @@
487502 "user_newpassword= '" . wfStrencode( $this->mNewpassword ) . "', " .
488503 "user_email= '" . wfStrencode( $this->mEmail ) . "', " .
489504 "user_options= '" . $this->encodeOptions() . "', " .
490 - "user_rights= '" . wfStrencode( implode( ",", $this->mRights ) ) . "', " .
 505+ "user_rights= '" . wfStrencode( implode( ",", $this->mRights ) ) . "', "
 506+.
491507 "user_touched= '" . wfStrencode( $this->mTouched ) .
492508 "' WHERE user_id={$this->mId}";
493509 wfQuery( $sql, "User::saveSettings" );
@@ -527,4 +543,5 @@
528544 $this->mId = $this->idForName();
529545 }
530546 }
 547+
531548 ?>
Index: trunk/phase3/includes/DefaultSettings.php
@@ -19,7 +19,7 @@
2020
2121 # MySQL settings
2222 #
23 -$wgDBserver = "127.0.0.1";
 23+$wgDBserver = "localhost";
2424 $wgDBname = "wikidb";
2525 $wgDBintlname = "intl";
2626 $wgDBconnection = "";
Index: trunk/phase3/includes/SpecialUserlogin.php
@@ -31,7 +31,8 @@
3232 }
3333 $wpName = trim( $wpName );
3434 if ( ( "" == $wpName ) ||
35 - preg_match( "/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/", $wpName ) ) {
 35+ preg_match( "/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/", $wpName ) )
 36+{
3637 mainLoginForm( wfMsg( "noname" ) );
3738 return;
3839 }
@@ -75,17 +76,22 @@
7677 }
7778 $u->setId( $id );
7879 $u->loadFromDatabase();
79 - $ep = User::encryptPassword( $wpPassword );
 80+ $ep = $u->encryptPassword( $wpPassword );
8081 if ( 0 != strcmp( $ep, $u->getPassword() ) ) {
8182 if ( 0 != strcmp( $ep, $u->getNewpassword() ) ) {
8283 mainLoginForm( wfMsg( "wrongpassword" ) );
8384 return;
8485 }
8586 }
 87+
8688 # We've verified now, update the real record
8789 #
88 - if ( 1 == $wpRemember ) { $r = 1; }
89 - else { $r = 0; }
 90+ if ( 1 == $wpRemember ) {
 91+ $r = 1;
 92+ $u->setCookiePassword( $wpPassword );
 93+ } else {
 94+ $r = 0;
 95+ }
9096 $u->setOption( "rememberpassword", $r );
9197
9298 $wgUser = $u;
@@ -118,6 +124,7 @@
119125 }
120126 $np = User::randomPassword();
121127 $u->setNewpassword( $np );
 128+
122129 setcookie( "wcUserPassword", "", time() - 3600 );
123130 $u->saveSettings();
124131
@@ -191,7 +198,8 @@
192199 if ( "" == $err ) {
193200 $wgOut->addHTML( "<h2>$li:</h2>\n" );
194201 } else {
195 - $wgOut->addHTML( "<h2>$le:</h2>\n<font size='+1' color='red'>$err</font>\n" );
 202+ $wgOut->addHTML( "<h2>$le:</h2>\n<font size='+1'
 203+color='red'>$err</font>\n" );
196204 }
197205 if ( 1 == $wgUser->getOption( "rememberpassword" ) ) {
198206 $checked = " checked";
@@ -208,39 +216,40 @@
209217 $wpEmail = wfEscapeHTML( $wpEmail );
210218
211219 $wgOut->addHTML( "
212 -<form id=\"userlogin\" method=\"post\" action=\"{$action}\">
 220+<form name='userlogin' method=post action=\"{$action}\">
213221 <table border=0><tr>
214222 <td align=right>$yn:</td>
215223 <td colspan=2 align=left>
216 -<input tabindex=1 type=text name=\"wpName\" value=\"{$name}\" size=20>
 224+<input tabindex=1 type=text name='wpName' value=\"{$name}\" size=20>
217225 </td></tr><tr>
218226 <td align=right>$yp:</td>
219227 <td align=left>
220 -<input tabindex=2 type=password name=\"wpPassword\" value=\"{$pwd}\" size=20>
 228+<input tabindex=2 type=password name='wpPassword' value=\"{$pwd}\" size=20>
221229 </td>
222230 <td align=left>
223 -<input tabindex=3 type=submit name=\"wpLoginattempt\" value=\"{$li}\">
 231+<input tabindex=3 type=submit name='wpLoginattempt' value=\"{$li}\">
224232 </td></tr>
225233 <tr><td colspan=3>&nbsp;</td></tr><tr>
226234 <td align=right>$ypa:</td>
227235 <td align=left>
228 -<input tabindex=4 type=password name=\"wpRetype\" value=\"{$wpRetype}\" size=20>
 236+<input tabindex=4 type=password name='wpRetype' value=\"{$wpRetype}\"
 237+size=20>
229238 </td><td>$nuo</td></tr>
230239 <tr>
231240 <td align=right>$ye:</td>
232241 <td align=left>
233 -<input tabindex=5 type=text name=\"wpEmail\" value=\"{$wpEmail}\" size=20>
 242+<input tabindex=5 type=text name='wpEmail' value=\"{$wpEmail}\" size=20>
234243 </td><td align=left>
235 -<input tabindex=6 type=submit name=\"wpCreateaccount\" value=\"{$ca}\">
 244+<input tabindex=6 type=submit name='wpCreateaccount' value=\"{$ca}\">
236245 </td></tr>
237246 <tr>
238247 <td colspan=3 align=left>
239 -<input tabindex=7 type=checkbox name=\"wpRemember\" value=\"1\"$checked>$rmp
 248+<input tabindex=7 type=checkbox name='wpRemember' value='1'$checked>$rmp
240249 </td></tr>
241250 <tr><td colspan=3>&nbsp;</td></tr><tr>
242251 <td colspan=3 align=left>
243252 <p>$efl<br>
244 -<input tabindex=8 type=submit name=\"wpMailmypassword\" value=\"{$mmp}\">
 253+<input tabindex=8 type=submit name='wpMailmypassword' value=\"{$mmp}\">
245254 </td></tr></table>
246255 </form>\n" );
247256 }
Index: trunk/phase3/includes/OutputPage.php
@@ -531,17 +531,26 @@
532532
533533 function databaseError( $fname )
534534 {
535 - global $wgUser;
 535+ global $wgUser, $wgCommandLineMode;
536536
537537 $this->setPageTitle( wfMsg( "databaseerror" ) );
538538 $this->setRobotpolicy( "noindex,nofollow" );
539539 $this->setArticleFlag( false );
540540
541 - $msg = str_replace( "$1", htmlspecialchars( wfLastDBquery() ), wfMsg( "dberrortext" ) );
 541+ if ( $wgCommandLineMode ) {
 542+ $msg = wfMsg( "dberrortextcl" );
 543+ } else {
 544+ $msg = wfMsg( "dberrortextcl" );
 545+ }
 546+ $msg = str_replace( "$1", htmlspecialchars( wfLastDBquery() ), $msg );
542547 $msg = str_replace( "$2", htmlspecialchars( $fname ), $msg );
543548 $msg = str_replace( "$3", wfLastErrno(), $msg );
544549 $msg = str_replace( "$4", htmlspecialchars( wfLastError() ), $msg );
545550
 551+ if ( $wgCommandLineMode ) {
 552+ print $msg;
 553+ exit();
 554+ }
546555 $sk = $wgUser->getSkin();
547556 $shlink = $sk->makeKnownLink( wfMsg( "searchhelppage" ),
548557 wfMsg( "searchingwikipedia" ) );
Index: trunk/phase3/languages/Language.php
@@ -280,6 +280,7 @@
281281 #
282282 "linktrail" => "/^([a-z]+)(.*)\$/sD",
283283 "mainpage" => "Main Page",
 284+"mainpagetext" => "Wiki software successfully installed.",
284285 "about" => "About",
285286 "aboutwikipedia" => "About Wikipedia",
286287 "aboutpage" => "Wikipedia:About",
@@ -368,6 +369,11 @@
369370 <blockquote><tt>$1</tt></blockquote>
370371 from within function \"<tt>$2</tt>\".
371372 MySQL returned error \"<tt>$3: $4</tt>\".",
 373+"dberrortextcl" => "A database query syntax error has occurred.
 374+The last attempted database query was:
 375+\"$1\"
 376+from within function \"$2\".
 377+MySQL returned error \"$3: $4\".\n",
372378 "noconnect" => "Could not connect to DB on $1",
373379 "nodb" => "Could not select database $1",
374380 "readonly" => "Database locked",
Index: trunk/phase3/update.php
@@ -23,6 +23,13 @@
2424 umask( 000 );
2525 set_time_limit( 0 );
2626
 27+include_once( "{$IP}/Version.php" );
 28+include_once( "{$IP}/Setup.php" );
 29+$wgTitle = Title::newFromText( "Update script" );
 30+$wgCommandLineMode = true;
 31+
 32+do_revision_updates();
 33+
2734 #
2835 # Copy files into installation directories
2936 #
@@ -32,18 +39,9 @@
3340 copyfile( ".", "redirect.phtml", $IP );
3441 copyfile( ".", "texvc.phtml", $IP );
3542
36 -$handle = opendir( "./includes" );
37 -while ( false !== ( $f = readdir( $handle ) ) ) {
38 - if ( "." == $f{0} ) continue;
39 - copyfile( "./includes", $f, $IP );
40 -}
 43+copydirectory( "./includes", $IP );
 44+copydirectory( "./stylesheets", $wgStyleSheetDirectory );
4145
42 -$handle = opendir( "./stylesheets" );
43 -while ( false !== ( $f = readdir( $handle ) ) ) {
44 - if ( "." == $f{0} ) continue;
45 - copyfile( "./stylesheets", $f, $wgStyleSheetDirectory );
46 -}
47 -
4846 copyfile( "./images", "wiki.png", $wgUploadDirectory );
4947 copyfile( "./languages", "Language.php", $IP );
5048 copyfile( "./languages", "Language" . ucfirst( $wgLanguageCode ) . ".php", $IP );
@@ -63,17 +61,22 @@
6462 copyfile( "./math", "texvc_tex", "{$IP}/math", 0775 );
6563 }
6664
67 -print "Done.\nIf any database changes are necessary, you may have to run\n" .
68 - "one or more \"patch\" files from the maintenance directory.\n";
 65+copyfile( ".", "Version.php", $IP );
 66+
 67+print "Done.\n";
6968 exit();
7069
71 -function copyfile( $sdir, $name, $ddir, $perms = 0644 ) {
72 - global $installOwner, $installGroup;
 70+#
 71+#
 72+#
7373
 74+function copyfile( $sdir, $name, $ddir, $perms = 0664 ) {
 75+ global $wgInstallOwner, $wgInstallGroup;
 76+
7477 $d = "{$ddir}/{$name}";
7578 if ( copy( "{$sdir}/{$name}", $d ) ) {
76 - if ( isset( $installOwner ) ) { chown( $d, $installOwner ); }
77 - if ( isset( $installGroup ) ) { chgrp( $d, $installGroup ); }
 79+ if ( isset( $wgInstallOwner ) ) { chown( $d, $wgInstallOwner ); }
 80+ if ( isset( $wgInstallGroup ) ) { chgrp( $d, $wgInstallGroup ); }
7881 chmod( $d, $perms );
7982 # print "Copied \"{$name}\" to \"{$ddir}\".\n";
8083 } else {
@@ -82,4 +85,37 @@
8386 }
8487 }
8588
 89+function copydirectory( $source, $dest ) {
 90+ $handle = opendir( $source );
 91+ while ( false !== ( $f = readdir( $handle ) ) ) {
 92+ if ( "." == $f{0} ) continue;
 93+ if ( "CVS" == $f ) continue;
 94+ copyfile( $source, $f, $dest );
 95+ }
 96+}
 97+
 98+function do_revision_updates() {
 99+ global $wgSoftwareRevision;
 100+
 101+ if ( $wgSoftwareRevision < 1001 ) { update_passwords(); }
 102+}
 103+
 104+function update_passwords() {
 105+ $fname = "Update scripte: update_passwords()";
 106+ print "Updating passwords...\n";
 107+
 108+ $sql = "SELECT user_id,user_password FROM user";
 109+ $source = wfQuery( $sql, fname );
 110+
 111+ while ( $row = mysql_fetch_object( $source ) ) {
 112+ $id = $row->user_id;
 113+ $oldpass = $row->user_password;
 114+ $newpass = md5( $oldpass . $id );
 115+
 116+ $sql = "UPDATE user SET user_password='{$newpass}' " .
 117+ "WHERE user_id={$id}";
 118+ wfQuery( $sql, $fname );
 119+ }
 120+}
 121+
86122 ?>
Index: trunk/phase3/Version.php
@@ -0,0 +1,12 @@
 2+# This file is copied to the install directory so that
 3+# later update scripts will be able to use it to determine
 4+# what they need to update. The version number here must
 5+# be updated any time you make a change that requires
 6+# the update to do anything other than copy the new files
 7+# over, such as changing the database layout. If you
 8+# change this version number, you should also update the
 9+# update.php script.
 10+#
 11+
 12+$wgSoftwareRevision = 1001;
 13+
Property changes on: trunk/phase3/Version.php
___________________________________________________________________
Name: svn:eol-style
114 + native
Name: svn:keywords
215 + Author Date Id Revision

Status & tagging log