From: Lee Daniel Crocker Date: Wed, 16 Apr 2003 07:30:52 +0000 (+0000) Subject: New update script, Version.php, new salted passwords, minor fixes. X-Git-Tag: 1.1.0~584 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=a96bcaf80d3fb8e1480b7ce1fbd27ca52dbfc9da;p=lhc%2Fweb%2Fwiklou.git New update script, Version.php, new salted passwords, minor fixes. --- diff --git a/LocalSettings.sample b/LocalSettings.sample index f0ac8e48a8..e5a82e96ae 100644 --- a/LocalSettings.sample +++ b/LocalSettings.sample @@ -15,8 +15,6 @@ $IP = "/usr/local/apache/htdocs/wiki"; -# This workaround is for the maintenance scripts: -# if ( ! isset( $DP ) ) { $DP = $IP; } include_once( "$DP/DefaultSettings.php" ); @@ -31,10 +29,10 @@ $wgEmergencyContact = "wikiadmin@myhost.com"; # MySQL settings # -$wgDBserver = "127.0.0.1"; +$wgDBserver = "localhost"; $wgDBname = "wikidb"; $wgDBpassword = "userpass"; -#wgDBsqlpassword = "sqlpass"; +$wgDBsqlpassword = "sqlpass"; $wgDBminWordLen = 3; # Match this to your MySQL fulltext $wgDBtransactions = false; # Set to true if using InnoDB tables diff --git a/Version.php b/Version.php new file mode 100644 index 0000000000..cdbf6e376f --- /dev/null +++ b/Version.php @@ -0,0 +1,12 @@ +# This file is copied to the install directory so that +# later update scripts will be able to use it to determine +# what they need to update. The version number here must +# be updated any time you make a change that requires +# the update to do anything other than copy the new files +# over, such as changing the database layout. If you +# change this version number, you should also update the +# update.php script. +# + +$wgSoftwareRevision = 1001; + diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 77be904f3a..6b9746ca17 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -19,7 +19,7 @@ $wgEmergencyContact = "wikiadmin@" . getenv( "SERVER_NAME" ); # MySQL settings # -$wgDBserver = "127.0.0.1"; +$wgDBserver = "localhost"; $wgDBname = "wikidb"; $wgDBintlname = "intl"; $wgDBconnection = ""; diff --git a/includes/OutputPage.php b/includes/OutputPage.php index b1c97a1f81..8869627d43 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -531,17 +531,26 @@ class OutputPage { function databaseError( $fname ) { - global $wgUser; + global $wgUser, $wgCommandLineMode; $this->setPageTitle( wfMsg( "databaseerror" ) ); $this->setRobotpolicy( "noindex,nofollow" ); $this->setArticleFlag( false ); - $msg = str_replace( "$1", htmlspecialchars( wfLastDBquery() ), wfMsg( "dberrortext" ) ); + if ( $wgCommandLineMode ) { + $msg = wfMsg( "dberrortextcl" ); + } else { + $msg = wfMsg( "dberrortextcl" ); + } + $msg = str_replace( "$1", htmlspecialchars( wfLastDBquery() ), $msg ); $msg = str_replace( "$2", htmlspecialchars( $fname ), $msg ); $msg = str_replace( "$3", wfLastErrno(), $msg ); $msg = str_replace( "$4", htmlspecialchars( wfLastError() ), $msg ); + if ( $wgCommandLineMode ) { + print $msg; + exit(); + } $sk = $wgUser->getSkin(); $shlink = $sk->makeKnownLink( wfMsg( "searchhelppage" ), wfMsg( "searchingwikipedia" ) ); diff --git a/includes/SpecialUserlogin.php b/includes/SpecialUserlogin.php index ed16443dd7..803cafd3cc 100644 --- a/includes/SpecialUserlogin.php +++ b/includes/SpecialUserlogin.php @@ -31,7 +31,8 @@ function wfSpecialUserlogin() } $wpName = trim( $wpName ); if ( ( "" == $wpName ) || - preg_match( "/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/", $wpName ) ) { + preg_match( "/^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/", $wpName ) ) +{ mainLoginForm( wfMsg( "noname" ) ); return; } @@ -75,17 +76,22 @@ function wfSpecialUserlogin() } $u->setId( $id ); $u->loadFromDatabase(); - $ep = User::encryptPassword( $wpPassword ); + $ep = $u->encryptPassword( $wpPassword ); if ( 0 != strcmp( $ep, $u->getPassword() ) ) { if ( 0 != strcmp( $ep, $u->getNewpassword() ) ) { mainLoginForm( wfMsg( "wrongpassword" ) ); return; } } + # We've verified now, update the real record # - if ( 1 == $wpRemember ) { $r = 1; } - else { $r = 0; } + if ( 1 == $wpRemember ) { + $r = 1; + $u->setCookiePassword( $wpPassword ); + } else { + $r = 0; + } $u->setOption( "rememberpassword", $r ); $wgUser = $u; @@ -118,6 +124,7 @@ function wfSpecialUserlogin() } $np = User::randomPassword(); $u->setNewpassword( $np ); + setcookie( "wcUserPassword", "", time() - 3600 ); $u->saveSettings(); @@ -191,7 +198,8 @@ function wfSpecialUserlogin() if ( "" == $err ) { $wgOut->addHTML( "

$li:

\n" ); } else { - $wgOut->addHTML( "

$le:

\n$err\n" ); + $wgOut->addHTML( "

$le:

\n$err\n" ); } if ( 1 == $wgUser->getOption( "rememberpassword" ) ) { $checked = " checked"; @@ -208,39 +216,40 @@ function wfSpecialUserlogin() $wpEmail = wfEscapeHTML( $wpEmail ); $wgOut->addHTML( " -
+
$yn: - +
$yp: - + - +
 
$ypa: - + $nuo
$ye: - + - +
-$rmp +$rmp
 

$efl
- +

\n" ); } diff --git a/includes/User.php b/includes/User.php index 127fe34eac..45c60a2cc2 100644 --- a/includes/User.php +++ b/includes/User.php @@ -8,6 +8,7 @@ class User { /* private */ var $mSkin; /* private */ var $mBlockedby, $mBlockreason; /* private */ var $mTouched; + /* private */ var $mCookiePassword; function User() { @@ -45,14 +46,14 @@ class User { return $s->user_id; } } - + # does the string match an anonymous user IP address? /* static */ function isIP( $name ) { return preg_match("/^\d{1,3}\.\d{1,3}.\d{1,3}\.\d{1,3}$/",$name); - + } - - + + /* static */ function randomPassword() { @@ -84,6 +85,7 @@ class User { $this->mDataLoaded = false; $this->mBlockedby = -1; # Unset $this->mTouched = '0'; # Allow any pages to be cached + $this->cookiePassword = ""; } /* private */ function getBlockedStatus() @@ -152,21 +154,23 @@ class User { $this->mId = 0; return; } + + $passwordCorrect = FALSE; + $this->mId = $sId; + $this->loadFromDatabase(); + if ( isset( $wsUserPassword ) ) { - $sPass = $wsUserPassword; + $passwordCorrect = $wsUserPassword == $this->mPassword; } else if ( isset( $HTTP_COOKIE_VARS["wcUserPassword"] ) ) { - $sPass = $HTTP_COOKIE_VARS["wcUserPassword"]; - $wsUserPassword = $sPass; + $this->mCookiePassword = $HTTP_COOKIE_VARS["wcUserPassword"]; + $wsUserPassword = $this->addSalt($this->mCookiePassword); + $passwordCorrect = $wsUserPassword == $this->mPassword; } else { $this->mId = 0; return; } - $this->mId = $sId; - $this->loadFromDatabase(); - if ( ( $sName == $this->mName ) && - ( ( $sPass == $this->mPassword ) || - ( $sPass == $this->mNewpassword ) ) ) { + if ( ( $sName == $this->mName ) && $passwordCorrect ) { return; } $this->loadDefaults(); # Can't log in from session @@ -174,22 +178,22 @@ class User { function loadFromDatabase() { - if ( $this->mDataLoaded ) { return; } + if ( $this->mDataLoaded ) { return; } # check in separate table if there are changes to the talk page $this->mNewtalk=0; # reset talk page status - if($this->mId) { - $sql = "SELECT 1 FROM user_newtalk WHERE user_id={$this->mId}"; + if($this->mId) { + $sql = "SELECT 1 FROM user_newtalk WHERE user_id={$this->mId}"; $res = wfQuery ($sql, "User::loadFromDatabase" ); - if (wfNumRows($res)>0) { + if (wfNumRows($res)>0) { $this->mNewtalk= 1; } wfFreeResult( $res ); } else { - $sql = "SELECT 1 FROM user_newtalk WHERE user_ip='{$this->mName}'"; + $sql = "SELECT 1 FROM user_newtalk WHERE user_ip='{$this->mName}'"; $res = wfQuery ($sql, "User::loadFromDatabase" ); - - if (wfNumRows($res)>0) { + + if (wfNumRows($res)>0) { $this->mNewtalk= 1; } wfFreeResult( $res ); @@ -198,7 +202,7 @@ class User { $this->mDataLoaded = true; return; } # the following stuff is for non-anonymous users only - + $sql = "SELECT user_name,user_password,user_newpassword,user_email," . "user_options,user_rights,user_touched FROM user WHERE user_id=" . "{$this->mId}"; @@ -213,8 +217,8 @@ class User { $this->decodeOptions( $s->user_options ); $this->mRights = explode( ",", strtolower( $s->user_rights ) ); $this->mTouched = $s->user_touched; - } - + } + wfFreeResult( $res ); $this->mDataLoaded = true; } @@ -248,19 +252,19 @@ class User { $this->mNewtalk = $val; $this->invalidateCache(); } - + function invalidateCache() { $this->loadFromDatabase(); $this->mTouched = wfTimestampNow(); # Don't forget to save the options after this or # it won't take effect! } - + function validateCache( $timestamp ) { $this->loadFromDatabase(); return ($timestamp >= $this->mTouched); } - + function getPassword() { $this->loadFromDatabase(); @@ -273,23 +277,34 @@ class User { return $this->mNewpassword; } - /* static */ function encryptPassword( $p ) + function addSalt( $p ) { - $np = md5( $p ); - return $np; + return md5( "wikipedia{$this->mId}-{$p}" ); + } + + function encryptPassword( $p ) + { + return $this->addSalt( md5( $p ) ); } function setPassword( $str ) { $this->loadFromDatabase(); - $this->mPassword = User::encryptPassword( $str ); + $this->setCookiePassword( $str ); + $this->mPassword = $this->encryptPassword( $str ); $this->mNewpassword = ""; } + function setCookiePassword( $str ) + { + $this->loadFromDatabase(); + $this->mCookiePassword = md5( $str ); + } + function setNewpassword( $str ) { $this->loadFromDatabase(); - $this->mNewpassword = User::encryptPassword( $str ); + $this->mNewpassword = $this->encryptPassword( $str ); } function getEmail() @@ -342,15 +357,15 @@ class User { return in_array( "developer", $this->mRights ); } - + function isBot() { $this->loadFromDatabase(); if ( 0 == $this->mId ) { return false; } - + return in_array( "bot", $this->mRights ); } - + function &getSkin() { if ( ! isset( $this->mSkin ) ) { @@ -443,7 +458,7 @@ class User { $wsUserPassword = $this->mPassword; if ( 1 == $this->getOption( "rememberpassword" ) ) { - setcookie( "wcUserPassword", $this->mPassword, $exp, "/" ); + setcookie( "wcUserPassword", $this->mCookiePassword, $exp, "/" ); } else { setcookie( "wcUserPassword", "", time() - 3600 ); } @@ -463,22 +478,22 @@ class User { function saveSettings() { global $wgUser; - + if(!$this->mNewtalk) { - + if($this->mId) { $sql="DELETE FROM user_newtalk WHERE user_id={$this->mId}"; wfQuery ($sql,"User::saveSettings"); } else { - - + + $sql="DELETE FROM user_newtalk WHERE user_ip='{$this->mName}'"; wfQuery ($sql,"User::saveSettings"); - + } } - if ( 0 == $this->mId ) { return; } + if ( 0 == $this->mId ) { return; } $sql = "UPDATE user SET " . "user_name= '" . wfStrencode( $this->mName ) . "', " . @@ -486,7 +501,8 @@ class User { "user_newpassword= '" . wfStrencode( $this->mNewpassword ) . "', " . "user_email= '" . wfStrencode( $this->mEmail ) . "', " . "user_options= '" . $this->encodeOptions() . "', " . - "user_rights= '" . wfStrencode( implode( ",", $this->mRights ) ) . "', " . + "user_rights= '" . wfStrencode( implode( ",", $this->mRights ) ) . "', " +. "user_touched= '" . wfStrencode( $this->mTouched ) . "' WHERE user_id={$this->mId}"; wfQuery( $sql, "User::saveSettings" ); @@ -527,4 +543,5 @@ class User { $this->mId = $this->idForName(); } } + ?> diff --git a/install.php b/install.php index e4f5a6039e..37775cada7 100644 --- a/install.php +++ b/install.php @@ -10,17 +10,28 @@ if ( ! ( is_readable( "./LocalSettings.php" ) "source directory before running this install script.\n"; exit(); } +if ( $wgUseTeX && ( ! is_executable( "./math/texvc" ) ) ) { + print "To use math functions, you must first compile texvc by\n" . + "running \"make\" in the math directory.\n"; + exit(); +} $DP = "./includes"; include_once( "./LocalSettings.php" ); include_once( "./AdminSettings.php" ); -if ( $wgUseTeX && ( ! is_executable( "./math/texvc" ) ) ) { - print "To use math functions, you must first compile texvc by\n" . - "running \"make\" in the math directory.\n"; - exit(); +if ( is_file( "{$IP}/Version.php" ) ) { + print "There appears to be an installation of the software\n" . + "already present on \"{$IP}\". You may want to run the update\n" . + "script instead. If you continue with this installation script,\n" . + "that software and all of its data will be overwritten.\n" . + "Are you sure you want to do this? (yes/no) "; + + $response = readconsole(); + if ( ! ( "Y" == $response{0} || "y" == $response{0} ) ) { exit(); } } +$wgCommandLineMode = true; umask( 000 ); set_time_limit( 0 ); @@ -36,21 +47,13 @@ foreach ( $dirs as $d ) { makedirectory( $d ); } print "Copying files...\n"; copyfile( ".", "LocalSettings.php", $IP ); +copyfile( ".", "Version.php", $IP ); copyfile( ".", "wiki.phtml", $IP ); copyfile( ".", "redirect.phtml", $IP ); copyfile( ".", "texvc.phtml", $IP ); -$handle = opendir( "./includes" ); -while ( false !== ( $f = readdir( $handle ) ) ) { - if ( "." == $f{0} ) continue; - copyfile( "./includes", $f, $IP ); -} - -$handle = opendir( "./stylesheets" ); -while ( false !== ( $f = readdir( $handle ) ) ) { - if ( "." == $f{0} ) continue; - copyfile( "./stylesheets", $f, $wgStyleSheetDirectory ); -} +copydirectory( "./includes", $IP ); +copydirectory( "./stylesheets", $wgStyleSheetsDirectory ); copyfile( "./images", "wiki.png", $wgUploadDirectory ); copyfile( "./languages", "Language.php", $IP ); @@ -114,6 +117,8 @@ populatedata(); # Needs internationalized messages print "Adding indexes...\n"; dbsource( $rconn, "./maintenance/indexes.sql" ); +copyfile( ".", "Version.php", $IP ); + print "Done.\nBrowse \"{$wgServer}{$wgScript}\" to test,\n" . "or \"run WikiSuite -b -o\" in test suite.\n"; exit(); @@ -122,14 +127,14 @@ exit(); # Functions used above: # function makedirectory( $d ) { - global $installOwner, $installGroup; + global $wgInstallOwner, $wgInstallGroup; if ( is_dir( $d ) ) { print "Directory \"{$d}\" exists.\n"; } else { if ( mkdir( $d, 0777 ) ) { - if ( isset( $installOwner ) ) { chown( $d, $installOwner ); } - if ( isset( $installGroup ) ) { chgrp( $d, $installGroup ); } + if ( isset( $wgInstallOwner ) ) { chown( $d, $wgInstallOwner ); } + if ( isset( $wgInstallGroup ) ) { chgrp( $d, $wgInstallGroup ); } print "Directory \"{$d}\" created.\n"; } else { print "Could not create directory \"{$d}\".\n"; @@ -138,13 +143,13 @@ function makedirectory( $d ) { } } -function copyfile( $sdir, $name, $ddir, $perms = 0644 ) { - global $installOwner, $installGroup; +function copyfile( $sdir, $name, $ddir, $perms = 0664 ) { + global $wgInstallOwner, $wgInstallGroup; $d = "{$ddir}/{$name}"; if ( copy( "{$sdir}/{$name}", $d ) ) { - if ( isset( $installOwner ) ) { chown( $d, $installOwner ); } - if ( isset( $installGroup ) ) { chgrp( $d, $installGroup ); } + if ( isset( $wgInstallOwner ) ) { chown( $d, $wgInstallOwner ); } + if ( isset( $wgInstallGroup ) ) { chgrp( $d, $wgInstallGroup ); } chmod( $d, $perms ); # print "Copied \"{$name}\" to \"{$ddir}\".\n"; } else { @@ -153,6 +158,15 @@ function copyfile( $sdir, $name, $ddir, $perms = 0644 ) { } } +function copydirectory( $source, $dest ) { + $handle = opendir( $source ); + while ( false !== ( $f = readdir( $handle ) ) ) { + if ( "." == $f{0} ) continue; + if ( "CVS" == $f ) continue; + copyfile( $source, $f, $dest ); + } +} + function readconsole() { $fp = fopen( "php://stdin", "r" ); $resp = trim( fgets( $fp ) ); @@ -254,6 +268,11 @@ function populatedata() { "cur_restrictions) VALUES ({$wns},'{$dlp}','" . wfStrencode( wfMsg( "dellogpagetext" ) ) . "','sysop')"; wfQuery( $sql ); + + $sql = "INSERT INTO cur (cur_namespace,cur_title,cur_text) " . + "VALUES (0,'" . wfStrencode( wfMsg( "mainpage" ) ) . "','" . + wfStrencode( wfMsg( "mainpagetext" ) ) . "')"; + wfQuery( $sql ); } ?> diff --git a/languages/Language.php b/languages/Language.php index 92312c1d07..6a99ed7516 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -280,6 +280,7 @@ this (alternative: like this?).", # "linktrail" => "/^([a-z]+)(.*)\$/sD", "mainpage" => "Main Page", +"mainpagetext" => "Wiki software successfully installed.", "about" => "About", "aboutwikipedia" => "About Wikipedia", "aboutpage" => "Wikipedia:About", @@ -368,6 +369,11 @@ The last attempted database query was:
$1
from within function \"$2\". MySQL returned error \"$3: $4\".", +"dberrortextcl" => "A database query syntax error has occurred. +The last attempted database query was: +\"$1\" +from within function \"$2\". +MySQL returned error \"$3: $4\".\n", "noconnect" => "Could not connect to DB on $1", "nodb" => "Could not select database $1", "readonly" => "Database locked", diff --git a/testsuite/src/com/piclab/wikitest/UploadTest.java b/testsuite/src/com/piclab/wikitest/UploadTest.java index bdf0dc506e..9c7bb724a2 100644 --- a/testsuite/src/com/piclab/wikitest/UploadTest.java +++ b/testsuite/src/com/piclab/wikitest/UploadTest.java @@ -24,6 +24,61 @@ protected int runTest() throws Exception { } private int part1() throws Exception { + WebResponse wr = getResponse( viewUrl( "Special:Upload" ) ); + String text = getArticle( wr ); + + String[] goodpats = { "]*>Not logged in" }; + int c = 0; + + if ( 0 != ( c = checkGoodPatterns( text, goodpats ) ) ) { + return 100 + c; + } + wr = loginAs( "Fred", "Fred" ); + wr = viewPage( "Special:Upload" ); + text = getArticle( wr ); + + String[] goodpats2 = { + "]*>Upload file", ">image use policy<", ">upload log<" + }; + if ( 0 != ( c = checkGoodPatterns( text, goodpats2 ) ) ) { + return 110 + c; + } + + WebForm wf = getFormByName( wr, "upload" ); + WebRequest req = wf.getRequest( "wpUpload" ); + + req.selectFile( "wpUploadFile", new java.io.File( "./data/startrek.png" ) ); + req.setParameter( "wpUploadDescription", "Upload test" ); + + wr = getResponse( req ); + text = getArticle( wr ); + + String[] goodpats3 = { + "]*>Upload error", "You must affirm" + }; + if ( 0 != ( c = checkGoodPatterns( text, goodpats2 ) ) ) { + return 120 + c; + } + + wr = viewPage( "Special:Upload" ); + text = getArticle( wr ); + + wf = getFormByName( wr, "upload" ); + req = wf.getRequest( "wpUpload" ); + req.selectFile( "wpUploadFile", new java.io.File( "./data/startrek.png" ) ); + req.setParameter( "wpUploadDescription", "Upload test" ); + req.setParameter( "wpUploadAffirm", "1" ); + + wr = getResponse( req ); + text = getArticle( wr ); + + String[] goodpats4 = { + "uploaded successfully", "description page" + }; + if ( 0 != ( c = checkGoodPatterns( text, goodpats4 ) ) ) { + return 130 + c; + } + return 0; } diff --git a/update.php b/update.php index 3d812884fa..0f63e53619 100644 --- a/update.php +++ b/update.php @@ -23,6 +23,13 @@ if ( $wgUseTeX && ( ! is_executable( "./math/texvc" ) ) ) { umask( 000 ); set_time_limit( 0 ); +include_once( "{$IP}/Version.php" ); +include_once( "{$IP}/Setup.php" ); +$wgTitle = Title::newFromText( "Update script" ); +$wgCommandLineMode = true; + +do_revision_updates(); + # # Copy files into installation directories # @@ -32,17 +39,8 @@ copyfile( ".", "wiki.phtml", $IP ); copyfile( ".", "redirect.phtml", $IP ); copyfile( ".", "texvc.phtml", $IP ); -$handle = opendir( "./includes" ); -while ( false !== ( $f = readdir( $handle ) ) ) { - if ( "." == $f{0} ) continue; - copyfile( "./includes", $f, $IP ); -} - -$handle = opendir( "./stylesheets" ); -while ( false !== ( $f = readdir( $handle ) ) ) { - if ( "." == $f{0} ) continue; - copyfile( "./stylesheets", $f, $wgStyleSheetDirectory ); -} +copydirectory( "./includes", $IP ); +copydirectory( "./stylesheets", $wgStyleSheetDirectory ); copyfile( "./images", "wiki.png", $wgUploadDirectory ); copyfile( "./languages", "Language.php", $IP ); @@ -63,17 +61,22 @@ if ( $wgUseTeX ) { copyfile( "./math", "texvc_tex", "{$IP}/math", 0775 ); } -print "Done.\nIf any database changes are necessary, you may have to run\n" . - "one or more \"patch\" files from the maintenance directory.\n"; +copyfile( ".", "Version.php", $IP ); + +print "Done.\n"; exit(); -function copyfile( $sdir, $name, $ddir, $perms = 0644 ) { - global $installOwner, $installGroup; +# +# +# + +function copyfile( $sdir, $name, $ddir, $perms = 0664 ) { + global $wgInstallOwner, $wgInstallGroup; $d = "{$ddir}/{$name}"; if ( copy( "{$sdir}/{$name}", $d ) ) { - if ( isset( $installOwner ) ) { chown( $d, $installOwner ); } - if ( isset( $installGroup ) ) { chgrp( $d, $installGroup ); } + if ( isset( $wgInstallOwner ) ) { chown( $d, $wgInstallOwner ); } + if ( isset( $wgInstallGroup ) ) { chgrp( $d, $wgInstallGroup ); } chmod( $d, $perms ); # print "Copied \"{$name}\" to \"{$ddir}\".\n"; } else { @@ -82,4 +85,37 @@ function copyfile( $sdir, $name, $ddir, $perms = 0644 ) { } } +function copydirectory( $source, $dest ) { + $handle = opendir( $source ); + while ( false !== ( $f = readdir( $handle ) ) ) { + if ( "." == $f{0} ) continue; + if ( "CVS" == $f ) continue; + copyfile( $source, $f, $dest ); + } +} + +function do_revision_updates() { + global $wgSoftwareRevision; + + if ( $wgSoftwareRevision < 1001 ) { update_passwords(); } +} + +function update_passwords() { + $fname = "Update scripte: update_passwords()"; + print "Updating passwords...\n"; + + $sql = "SELECT user_id,user_password FROM user"; + $source = wfQuery( $sql, fname ); + + while ( $row = mysql_fetch_object( $source ) ) { + $id = $row->user_id; + $oldpass = $row->user_password; + $newpass = md5( $oldpass . $id ); + + $sql = "UPDATE user SET user_password='{$newpass}' " . + "WHERE user_id={$id}"; + wfQuery( $sql, $fname ); + } +} + ?>