0f63e53619f3861d5d0f96c5d4c32b3be7d0af11
3 # Update already-installed software
6 if ( ! ( is_readable( "./LocalSettings.php" )
7 && is_readable( "./AdminSettings.php" ) ) ) {
8 print "A copy of your installation's LocalSettings.php\n" .
9 "and AdminSettings.php must exist in this source directory.\n";
14 include_once( "./LocalSettings.php" );
15 include_once( "./AdminSettings.php" );
17 if ( $wgUseTeX && ( ! is_executable( "./math/texvc" ) ) ) {
18 print "To use math functions, you must first compile texvc by\n" .
19 "running \"make\" in the math directory.\n";
26 include_once( "{$IP}/Version.php" );
27 include_once( "{$IP}/Setup.php" );
28 $wgTitle = Title
::newFromText( "Update script" );
29 $wgCommandLineMode = true;
31 do_revision_updates();
34 # Copy files into installation directories
36 print "Copying files...\n";
38 copyfile( ".", "wiki.phtml", $IP );
39 copyfile( ".", "redirect.phtml", $IP );
40 copyfile( ".", "texvc.phtml", $IP );
42 copydirectory( "./includes", $IP );
43 copydirectory( "./stylesheets", $wgStyleSheetDirectory );
45 copyfile( "./images", "wiki.png", $wgUploadDirectory );
46 copyfile( "./languages", "Language.php", $IP );
47 copyfile( "./languages", "Language" . ucfirst( $wgLanguageCode ) . ".php", $IP );
49 $fp = fopen( $wgDebugLogFile, "w" );
50 if ( false === $fp ) {
51 print "Could not create log file \"{$wgDebugLogFile}\".\n";
54 $d = date( "Y-m-d H:i:s" );
55 fwrite( $fp, "Wiki debug log file created {$d}\n\n" );
59 copyfile( "./math", "texvc", "{$IP}/math", 0775 );
60 copyfile( "./math", "texvc_test", "{$IP}/math", 0775 );
61 copyfile( "./math", "texvc_tex", "{$IP}/math", 0775 );
64 copyfile( ".", "Version.php", $IP );
73 function copyfile( $sdir, $name, $ddir, $perms = 0664 ) {
74 global $wgInstallOwner, $wgInstallGroup;
76 $d = "{$ddir}/{$name}";
77 if ( copy( "{$sdir}/{$name}", $d ) ) {
78 if ( isset( $wgInstallOwner ) ) { chown( $d, $wgInstallOwner ); }
79 if ( isset( $wgInstallGroup ) ) { chgrp( $d, $wgInstallGroup ); }
81 # print "Copied \"{$name}\" to \"{$ddir}\".\n";
83 print "Failed to copy file \"{$name}\" to \"{$ddir}\".\n";
88 function copydirectory( $source, $dest ) {
89 $handle = opendir( $source );
90 while ( false !== ( $f = readdir( $handle ) ) ) {
91 if ( "." == $f{0} ) continue;
92 if ( "CVS" == $f ) continue;
93 copyfile( $source, $f, $dest );
97 function do_revision_updates() {
98 global $wgSoftwareRevision;
100 if ( $wgSoftwareRevision < 1001 ) { update_passwords(); }
103 function update_passwords() {
104 $fname = "Update scripte: update_passwords()";
105 print "Updating passwords...\n";
107 $sql = "SELECT user_id,user_password FROM user";
108 $source = wfQuery( $sql, fname
);
110 while ( $row = mysql_fetch_object( $source ) ) {
112 $oldpass = $row->user_password
;
113 $newpass = md5( $oldpass . $id );
115 $sql = "UPDATE user SET user_password='{$newpass}' " .
116 "WHERE user_id={$id}";
117 wfQuery( $sql, $fname );