Index: trunk/phase3/testsuite/src/com/piclab/wikitest/UploadTest.java |
— | — | @@ -24,6 +24,61 @@ |
25 | 25 | } |
26 | 26 | |
27 | 27 | 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 | + |
28 | 83 | return 0; |
29 | 84 | } |
30 | 85 | |
Index: trunk/phase3/LocalSettings.sample |
— | — | @@ -15,8 +15,6 @@ |
16 | 16 | |
17 | 17 | $IP = "/usr/local/apache/htdocs/wiki"; |
18 | 18 | |
19 | | -# This workaround is for the maintenance scripts: |
20 | | -# |
21 | 19 | if ( ! isset( $DP ) ) { $DP = $IP; } |
22 | 20 | include_once( "$DP/DefaultSettings.php" ); |
23 | 21 | |
— | — | @@ -31,10 +29,10 @@ |
32 | 30 | |
33 | 31 | # MySQL settings |
34 | 32 | # |
35 | | -$wgDBserver = "127.0.0.1"; |
| 33 | +$wgDBserver = "localhost"; |
36 | 34 | $wgDBname = "wikidb"; |
37 | 35 | $wgDBpassword = "userpass"; |
38 | | -#wgDBsqlpassword = "sqlpass"; |
| 36 | +$wgDBsqlpassword = "sqlpass"; |
39 | 37 | $wgDBminWordLen = 3; # Match this to your MySQL fulltext |
40 | 38 | $wgDBtransactions = false; # Set to true if using InnoDB tables |
41 | 39 | |
Index: trunk/phase3/install.php |
— | — | @@ -10,17 +10,28 @@ |
11 | 11 | "source directory before running this install script.\n"; |
12 | 12 | exit(); |
13 | 13 | } |
| 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 | +} |
14 | 19 | |
15 | 20 | $DP = "./includes"; |
16 | 21 | include_once( "./LocalSettings.php" ); |
17 | 22 | include_once( "./AdminSettings.php" ); |
18 | 23 | |
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(); } |
23 | 33 | } |
24 | 34 | |
| 35 | +$wgCommandLineMode = true; |
25 | 36 | umask( 000 ); |
26 | 37 | set_time_limit( 0 ); |
27 | 38 | |
— | — | @@ -36,22 +47,14 @@ |
37 | 48 | print "Copying files...\n"; |
38 | 49 | |
39 | 50 | copyfile( ".", "LocalSettings.php", $IP ); |
| 51 | +copyfile( ".", "Version.php", $IP ); |
40 | 52 | copyfile( ".", "wiki.phtml", $IP ); |
41 | 53 | copyfile( ".", "redirect.phtml", $IP ); |
42 | 54 | copyfile( ".", "texvc.phtml", $IP ); |
43 | 55 | |
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 ); |
49 | 58 | |
50 | | -$handle = opendir( "./stylesheets" ); |
51 | | -while ( false !== ( $f = readdir( $handle ) ) ) { |
52 | | - if ( "." == $f{0} ) continue; |
53 | | - copyfile( "./stylesheets", $f, $wgStyleSheetDirectory ); |
54 | | -} |
55 | | - |
56 | 59 | copyfile( "./images", "wiki.png", $wgUploadDirectory ); |
57 | 60 | copyfile( "./languages", "Language.php", $IP ); |
58 | 61 | copyfile( "./languages", "Language" . ucfirst( $wgLanguageCode ) . ".php", $IP ); |
— | — | @@ -114,6 +117,8 @@ |
115 | 118 | print "Adding indexes...\n"; |
116 | 119 | dbsource( $rconn, "./maintenance/indexes.sql" ); |
117 | 120 | |
| 121 | +copyfile( ".", "Version.php", $IP ); |
| 122 | + |
118 | 123 | print "Done.\nBrowse \"{$wgServer}{$wgScript}\" to test,\n" . |
119 | 124 | "or \"run WikiSuite -b -o\" in test suite.\n"; |
120 | 125 | exit(); |
— | — | @@ -122,14 +127,14 @@ |
123 | 128 | # Functions used above: |
124 | 129 | # |
125 | 130 | function makedirectory( $d ) { |
126 | | - global $installOwner, $installGroup; |
| 131 | + global $wgInstallOwner, $wgInstallGroup; |
127 | 132 | |
128 | 133 | if ( is_dir( $d ) ) { |
129 | 134 | print "Directory \"{$d}\" exists.\n"; |
130 | 135 | } else { |
131 | 136 | 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 ); } |
134 | 139 | print "Directory \"{$d}\" created.\n"; |
135 | 140 | } else { |
136 | 141 | print "Could not create directory \"{$d}\".\n"; |
— | — | @@ -138,13 +143,13 @@ |
139 | 144 | } |
140 | 145 | } |
141 | 146 | |
142 | | -function copyfile( $sdir, $name, $ddir, $perms = 0644 ) { |
143 | | - global $installOwner, $installGroup; |
| 147 | +function copyfile( $sdir, $name, $ddir, $perms = 0664 ) { |
| 148 | + global $wgInstallOwner, $wgInstallGroup; |
144 | 149 | |
145 | 150 | $d = "{$ddir}/{$name}"; |
146 | 151 | 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 ); } |
149 | 154 | chmod( $d, $perms ); |
150 | 155 | # print "Copied \"{$name}\" to \"{$ddir}\".\n"; |
151 | 156 | } else { |
— | — | @@ -153,6 +158,15 @@ |
154 | 159 | } |
155 | 160 | } |
156 | 161 | |
| 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 | + |
157 | 171 | function readconsole() { |
158 | 172 | $fp = fopen( "php://stdin", "r" ); |
159 | 173 | $resp = trim( fgets( $fp ) ); |
— | — | @@ -254,6 +268,11 @@ |
255 | 269 | "cur_restrictions) VALUES ({$wns},'{$dlp}','" . |
256 | 270 | wfStrencode( wfMsg( "dellogpagetext" ) ) . "','sysop')"; |
257 | 271 | 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 ); |
258 | 277 | } |
259 | 278 | |
260 | 279 | ?> |
Index: trunk/phase3/includes/User.php |
— | — | @@ -8,6 +8,7 @@ |
9 | 9 | /* private */ var $mSkin; |
10 | 10 | /* private */ var $mBlockedby, $mBlockreason; |
11 | 11 | /* private */ var $mTouched; |
| 12 | + /* private */ var $mCookiePassword; |
12 | 13 | |
13 | 14 | function User() |
14 | 15 | { |
— | — | @@ -45,15 +46,15 @@ |
46 | 47 | return $s->user_id; |
47 | 48 | } |
48 | 49 | } |
49 | | - |
| 50 | + |
50 | 51 | # does the string match an anonymous user IP address? |
51 | 52 | /* static */ function isIP( $name ) { |
52 | 53 | return preg_match("/^\d{1,3}\.\d{1,3}.\d{1,3}\.\d{1,3}$/",$name); |
53 | | - |
| 54 | + |
54 | 55 | } |
55 | | - |
56 | | - |
57 | 56 | |
| 57 | + |
| 58 | + |
58 | 59 | /* static */ function randomPassword() |
59 | 60 | { |
60 | 61 | $pwchars = "ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz"; |
— | — | @@ -84,6 +85,7 @@ |
85 | 86 | $this->mDataLoaded = false; |
86 | 87 | $this->mBlockedby = -1; # Unset |
87 | 88 | $this->mTouched = '0'; # Allow any pages to be cached |
| 89 | + $this->cookiePassword = ""; |
88 | 90 | } |
89 | 91 | |
90 | 92 | /* private */ function getBlockedStatus() |
— | — | @@ -152,21 +154,23 @@ |
153 | 155 | $this->mId = 0; |
154 | 156 | return; |
155 | 157 | } |
| 158 | + |
| 159 | + $passwordCorrect = FALSE; |
| 160 | + $this->mId = $sId; |
| 161 | + $this->loadFromDatabase(); |
| 162 | + |
156 | 163 | if ( isset( $wsUserPassword ) ) { |
157 | | - $sPass = $wsUserPassword; |
| 164 | + $passwordCorrect = $wsUserPassword == $this->mPassword; |
158 | 165 | } 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; |
161 | 169 | } else { |
162 | 170 | $this->mId = 0; |
163 | 171 | return; |
164 | 172 | } |
165 | | - $this->mId = $sId; |
166 | | - $this->loadFromDatabase(); |
167 | 173 | |
168 | | - if ( ( $sName == $this->mName ) && |
169 | | - ( ( $sPass == $this->mPassword ) || |
170 | | - ( $sPass == $this->mNewpassword ) ) ) { |
| 174 | + if ( ( $sName == $this->mName ) && $passwordCorrect ) { |
171 | 175 | return; |
172 | 176 | } |
173 | 177 | $this->loadDefaults(); # Can't log in from session |
— | — | @@ -174,22 +178,22 @@ |
175 | 179 | |
176 | 180 | function loadFromDatabase() |
177 | 181 | { |
178 | | - if ( $this->mDataLoaded ) { return; } |
| 182 | + if ( $this->mDataLoaded ) { return; } |
179 | 183 | # check in separate table if there are changes to the talk page |
180 | 184 | $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}"; |
183 | 187 | $res = wfQuery ($sql, "User::loadFromDatabase" ); |
184 | 188 | |
185 | | - if (wfNumRows($res)>0) { |
| 189 | + if (wfNumRows($res)>0) { |
186 | 190 | $this->mNewtalk= 1; |
187 | 191 | } |
188 | 192 | wfFreeResult( $res ); |
189 | 193 | } 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}'"; |
191 | 195 | $res = wfQuery ($sql, "User::loadFromDatabase" ); |
192 | | - |
193 | | - if (wfNumRows($res)>0) { |
| 196 | + |
| 197 | + if (wfNumRows($res)>0) { |
194 | 198 | $this->mNewtalk= 1; |
195 | 199 | } |
196 | 200 | wfFreeResult( $res ); |
— | — | @@ -198,7 +202,7 @@ |
199 | 203 | $this->mDataLoaded = true; |
200 | 204 | return; |
201 | 205 | } # the following stuff is for non-anonymous users only |
202 | | - |
| 206 | + |
203 | 207 | $sql = "SELECT user_name,user_password,user_newpassword,user_email," . |
204 | 208 | "user_options,user_rights,user_touched FROM user WHERE user_id=" . |
205 | 209 | "{$this->mId}"; |
— | — | @@ -213,8 +217,8 @@ |
214 | 218 | $this->decodeOptions( $s->user_options ); |
215 | 219 | $this->mRights = explode( ",", strtolower( $s->user_rights ) ); |
216 | 220 | $this->mTouched = $s->user_touched; |
217 | | - } |
218 | | - |
| 221 | + } |
| 222 | + |
219 | 223 | wfFreeResult( $res ); |
220 | 224 | $this->mDataLoaded = true; |
221 | 225 | } |
— | — | @@ -248,19 +252,19 @@ |
249 | 253 | $this->mNewtalk = $val; |
250 | 254 | $this->invalidateCache(); |
251 | 255 | } |
252 | | - |
| 256 | + |
253 | 257 | function invalidateCache() { |
254 | 258 | $this->loadFromDatabase(); |
255 | 259 | $this->mTouched = wfTimestampNow(); |
256 | 260 | # Don't forget to save the options after this or |
257 | 261 | # it won't take effect! |
258 | 262 | } |
259 | | - |
| 263 | + |
260 | 264 | function validateCache( $timestamp ) { |
261 | 265 | $this->loadFromDatabase(); |
262 | 266 | return ($timestamp >= $this->mTouched); |
263 | 267 | } |
264 | | - |
| 268 | + |
265 | 269 | function getPassword() |
266 | 270 | { |
267 | 271 | $this->loadFromDatabase(); |
— | — | @@ -273,23 +277,34 @@ |
274 | 278 | return $this->mNewpassword; |
275 | 279 | } |
276 | 280 | |
277 | | - /* static */ function encryptPassword( $p ) |
| 281 | + function addSalt( $p ) |
278 | 282 | { |
279 | | - $np = md5( $p ); |
280 | | - return $np; |
| 283 | + return md5( "wikipedia{$this->mId}-{$p}" ); |
281 | 284 | } |
282 | 285 | |
| 286 | + function encryptPassword( $p ) |
| 287 | + { |
| 288 | + return $this->addSalt( md5( $p ) ); |
| 289 | + } |
| 290 | + |
283 | 291 | function setPassword( $str ) |
284 | 292 | { |
285 | 293 | $this->loadFromDatabase(); |
286 | | - $this->mPassword = User::encryptPassword( $str ); |
| 294 | + $this->setCookiePassword( $str ); |
| 295 | + $this->mPassword = $this->encryptPassword( $str ); |
287 | 296 | $this->mNewpassword = ""; |
288 | 297 | } |
289 | 298 | |
| 299 | + function setCookiePassword( $str ) |
| 300 | + { |
| 301 | + $this->loadFromDatabase(); |
| 302 | + $this->mCookiePassword = md5( $str ); |
| 303 | + } |
| 304 | + |
290 | 305 | function setNewpassword( $str ) |
291 | 306 | { |
292 | 307 | $this->loadFromDatabase(); |
293 | | - $this->mNewpassword = User::encryptPassword( $str ); |
| 308 | + $this->mNewpassword = $this->encryptPassword( $str ); |
294 | 309 | } |
295 | 310 | |
296 | 311 | function getEmail() |
— | — | @@ -342,15 +357,15 @@ |
343 | 358 | |
344 | 359 | return in_array( "developer", $this->mRights ); |
345 | 360 | } |
346 | | - |
| 361 | + |
347 | 362 | function isBot() |
348 | 363 | { |
349 | 364 | $this->loadFromDatabase(); |
350 | 365 | if ( 0 == $this->mId ) { return false; } |
351 | | - |
| 366 | + |
352 | 367 | return in_array( "bot", $this->mRights ); |
353 | 368 | } |
354 | | - |
| 369 | + |
355 | 370 | function &getSkin() |
356 | 371 | { |
357 | 372 | if ( ! isset( $this->mSkin ) ) { |
— | — | @@ -443,7 +458,7 @@ |
444 | 459 | |
445 | 460 | $wsUserPassword = $this->mPassword; |
446 | 461 | if ( 1 == $this->getOption( "rememberpassword" ) ) { |
447 | | - setcookie( "wcUserPassword", $this->mPassword, $exp, "/" ); |
| 462 | + setcookie( "wcUserPassword", $this->mCookiePassword, $exp, "/" ); |
448 | 463 | } else { |
449 | 464 | setcookie( "wcUserPassword", "", time() - 3600 ); |
450 | 465 | } |
— | — | @@ -463,22 +478,22 @@ |
464 | 479 | function saveSettings() |
465 | 480 | { |
466 | 481 | global $wgUser; |
467 | | - |
| 482 | + |
468 | 483 | if(!$this->mNewtalk) { |
469 | | - |
| 484 | + |
470 | 485 | if($this->mId) { |
471 | 486 | $sql="DELETE FROM user_newtalk WHERE user_id={$this->mId}"; |
472 | 487 | wfQuery ($sql,"User::saveSettings"); |
473 | 488 | } else { |
474 | | - |
475 | | - |
| 489 | + |
| 490 | + |
476 | 491 | $sql="DELETE FROM user_newtalk WHERE user_ip='{$this->mName}'"; |
477 | 492 | wfQuery ($sql,"User::saveSettings"); |
478 | | - |
| 493 | + |
479 | 494 | } |
480 | 495 | } |
481 | 496 | |
482 | | - if ( 0 == $this->mId ) { return; } |
| 497 | + if ( 0 == $this->mId ) { return; } |
483 | 498 | |
484 | 499 | $sql = "UPDATE user SET " . |
485 | 500 | "user_name= '" . wfStrencode( $this->mName ) . "', " . |
— | — | @@ -486,7 +501,8 @@ |
487 | 502 | "user_newpassword= '" . wfStrencode( $this->mNewpassword ) . "', " . |
488 | 503 | "user_email= '" . wfStrencode( $this->mEmail ) . "', " . |
489 | 504 | "user_options= '" . $this->encodeOptions() . "', " . |
490 | | - "user_rights= '" . wfStrencode( implode( ",", $this->mRights ) ) . "', " . |
| 505 | + "user_rights= '" . wfStrencode( implode( ",", $this->mRights ) ) . "', " |
| 506 | +. |
491 | 507 | "user_touched= '" . wfStrencode( $this->mTouched ) . |
492 | 508 | "' WHERE user_id={$this->mId}"; |
493 | 509 | wfQuery( $sql, "User::saveSettings" ); |
— | — | @@ -527,4 +543,5 @@ |
528 | 544 | $this->mId = $this->idForName(); |
529 | 545 | } |
530 | 546 | } |
| 547 | + |
531 | 548 | ?> |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | |
21 | 21 | # MySQL settings |
22 | 22 | # |
23 | | -$wgDBserver = "127.0.0.1"; |
| 23 | +$wgDBserver = "localhost"; |
24 | 24 | $wgDBname = "wikidb"; |
25 | 25 | $wgDBintlname = "intl"; |
26 | 26 | $wgDBconnection = ""; |
Index: trunk/phase3/includes/SpecialUserlogin.php |
— | — | @@ -31,7 +31,8 @@ |
32 | 32 | } |
33 | 33 | $wpName = trim( $wpName ); |
34 | 34 | 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 | +{ |
36 | 37 | mainLoginForm( wfMsg( "noname" ) ); |
37 | 38 | return; |
38 | 39 | } |
— | — | @@ -75,17 +76,22 @@ |
76 | 77 | } |
77 | 78 | $u->setId( $id ); |
78 | 79 | $u->loadFromDatabase(); |
79 | | - $ep = User::encryptPassword( $wpPassword ); |
| 80 | + $ep = $u->encryptPassword( $wpPassword ); |
80 | 81 | if ( 0 != strcmp( $ep, $u->getPassword() ) ) { |
81 | 82 | if ( 0 != strcmp( $ep, $u->getNewpassword() ) ) { |
82 | 83 | mainLoginForm( wfMsg( "wrongpassword" ) ); |
83 | 84 | return; |
84 | 85 | } |
85 | 86 | } |
| 87 | + |
86 | 88 | # We've verified now, update the real record |
87 | 89 | # |
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 | + } |
90 | 96 | $u->setOption( "rememberpassword", $r ); |
91 | 97 | |
92 | 98 | $wgUser = $u; |
— | — | @@ -118,6 +124,7 @@ |
119 | 125 | } |
120 | 126 | $np = User::randomPassword(); |
121 | 127 | $u->setNewpassword( $np ); |
| 128 | + |
122 | 129 | setcookie( "wcUserPassword", "", time() - 3600 ); |
123 | 130 | $u->saveSettings(); |
124 | 131 | |
— | — | @@ -191,7 +198,8 @@ |
192 | 199 | if ( "" == $err ) { |
193 | 200 | $wgOut->addHTML( "<h2>$li:</h2>\n" ); |
194 | 201 | } 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" ); |
196 | 204 | } |
197 | 205 | if ( 1 == $wgUser->getOption( "rememberpassword" ) ) { |
198 | 206 | $checked = " checked"; |
— | — | @@ -208,39 +216,40 @@ |
209 | 217 | $wpEmail = wfEscapeHTML( $wpEmail ); |
210 | 218 | |
211 | 219 | $wgOut->addHTML( " |
212 | | -<form id=\"userlogin\" method=\"post\" action=\"{$action}\"> |
| 220 | +<form name='userlogin' method=post action=\"{$action}\"> |
213 | 221 | <table border=0><tr> |
214 | 222 | <td align=right>$yn:</td> |
215 | 223 | <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> |
217 | 225 | </td></tr><tr> |
218 | 226 | <td align=right>$yp:</td> |
219 | 227 | <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> |
221 | 229 | </td> |
222 | 230 | <td align=left> |
223 | | -<input tabindex=3 type=submit name=\"wpLoginattempt\" value=\"{$li}\"> |
| 231 | +<input tabindex=3 type=submit name='wpLoginattempt' value=\"{$li}\"> |
224 | 232 | </td></tr> |
225 | 233 | <tr><td colspan=3> </td></tr><tr> |
226 | 234 | <td align=right>$ypa:</td> |
227 | 235 | <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> |
229 | 238 | </td><td>$nuo</td></tr> |
230 | 239 | <tr> |
231 | 240 | <td align=right>$ye:</td> |
232 | 241 | <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> |
234 | 243 | </td><td align=left> |
235 | | -<input tabindex=6 type=submit name=\"wpCreateaccount\" value=\"{$ca}\"> |
| 244 | +<input tabindex=6 type=submit name='wpCreateaccount' value=\"{$ca}\"> |
236 | 245 | </td></tr> |
237 | 246 | <tr> |
238 | 247 | <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 |
240 | 249 | </td></tr> |
241 | 250 | <tr><td colspan=3> </td></tr><tr> |
242 | 251 | <td colspan=3 align=left> |
243 | 252 | <p>$efl<br> |
244 | | -<input tabindex=8 type=submit name=\"wpMailmypassword\" value=\"{$mmp}\"> |
| 253 | +<input tabindex=8 type=submit name='wpMailmypassword' value=\"{$mmp}\"> |
245 | 254 | </td></tr></table> |
246 | 255 | </form>\n" ); |
247 | 256 | } |
Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -531,17 +531,26 @@ |
532 | 532 | |
533 | 533 | function databaseError( $fname ) |
534 | 534 | { |
535 | | - global $wgUser; |
| 535 | + global $wgUser, $wgCommandLineMode; |
536 | 536 | |
537 | 537 | $this->setPageTitle( wfMsg( "databaseerror" ) ); |
538 | 538 | $this->setRobotpolicy( "noindex,nofollow" ); |
539 | 539 | $this->setArticleFlag( false ); |
540 | 540 | |
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 ); |
542 | 547 | $msg = str_replace( "$2", htmlspecialchars( $fname ), $msg ); |
543 | 548 | $msg = str_replace( "$3", wfLastErrno(), $msg ); |
544 | 549 | $msg = str_replace( "$4", htmlspecialchars( wfLastError() ), $msg ); |
545 | 550 | |
| 551 | + if ( $wgCommandLineMode ) { |
| 552 | + print $msg; |
| 553 | + exit(); |
| 554 | + } |
546 | 555 | $sk = $wgUser->getSkin(); |
547 | 556 | $shlink = $sk->makeKnownLink( wfMsg( "searchhelppage" ), |
548 | 557 | wfMsg( "searchingwikipedia" ) ); |
Index: trunk/phase3/languages/Language.php |
— | — | @@ -280,6 +280,7 @@ |
281 | 281 | # |
282 | 282 | "linktrail" => "/^([a-z]+)(.*)\$/sD", |
283 | 283 | "mainpage" => "Main Page", |
| 284 | +"mainpagetext" => "Wiki software successfully installed.", |
284 | 285 | "about" => "About", |
285 | 286 | "aboutwikipedia" => "About Wikipedia", |
286 | 287 | "aboutpage" => "Wikipedia:About", |
— | — | @@ -368,6 +369,11 @@ |
369 | 370 | <blockquote><tt>$1</tt></blockquote> |
370 | 371 | from within function \"<tt>$2</tt>\". |
371 | 372 | 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", |
372 | 378 | "noconnect" => "Could not connect to DB on $1", |
373 | 379 | "nodb" => "Could not select database $1", |
374 | 380 | "readonly" => "Database locked", |
Index: trunk/phase3/update.php |
— | — | @@ -23,6 +23,13 @@ |
24 | 24 | umask( 000 ); |
25 | 25 | set_time_limit( 0 ); |
26 | 26 | |
| 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 | + |
27 | 34 | # |
28 | 35 | # Copy files into installation directories |
29 | 36 | # |
— | — | @@ -32,18 +39,9 @@ |
33 | 40 | copyfile( ".", "redirect.phtml", $IP ); |
34 | 41 | copyfile( ".", "texvc.phtml", $IP ); |
35 | 42 | |
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 ); |
41 | 45 | |
42 | | -$handle = opendir( "./stylesheets" ); |
43 | | -while ( false !== ( $f = readdir( $handle ) ) ) { |
44 | | - if ( "." == $f{0} ) continue; |
45 | | - copyfile( "./stylesheets", $f, $wgStyleSheetDirectory ); |
46 | | -} |
47 | | - |
48 | 46 | copyfile( "./images", "wiki.png", $wgUploadDirectory ); |
49 | 47 | copyfile( "./languages", "Language.php", $IP ); |
50 | 48 | copyfile( "./languages", "Language" . ucfirst( $wgLanguageCode ) . ".php", $IP ); |
— | — | @@ -63,17 +61,22 @@ |
64 | 62 | copyfile( "./math", "texvc_tex", "{$IP}/math", 0775 ); |
65 | 63 | } |
66 | 64 | |
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"; |
69 | 68 | exit(); |
70 | 69 | |
71 | | -function copyfile( $sdir, $name, $ddir, $perms = 0644 ) { |
72 | | - global $installOwner, $installGroup; |
| 70 | +# |
| 71 | +# |
| 72 | +# |
73 | 73 | |
| 74 | +function copyfile( $sdir, $name, $ddir, $perms = 0664 ) { |
| 75 | + global $wgInstallOwner, $wgInstallGroup; |
| 76 | + |
74 | 77 | $d = "{$ddir}/{$name}"; |
75 | 78 | 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 ); } |
78 | 81 | chmod( $d, $perms ); |
79 | 82 | # print "Copied \"{$name}\" to \"{$ddir}\".\n"; |
80 | 83 | } else { |
— | — | @@ -82,4 +85,37 @@ |
83 | 86 | } |
84 | 87 | } |
85 | 88 | |
| 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 | + |
86 | 122 | ?> |
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 |
1 | 14 | + native |
Name: svn:keywords |
2 | 15 | + Author Date Id Revision |