Initial revision
[lhc/web/wiklou.git] / update.php
1 <?
2
3 # Update already-installed software
4 #
5
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";
10 exit();
11 }
12
13 $DP = "./includes";
14 include_once( "./LocalSettings.php" );
15 include_once( "./AdminSettings.php" );
16
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";
20 exit();
21 }
22
23 umask( 000 );
24 set_time_limit( 0 );
25
26 #
27 # Copy files into installation directories
28 #
29 print "Copying files...\n";
30
31 copyfile( ".", "wiki.phtml", $IP );
32 copyfile( ".", "redirect.phtml", $IP );
33 copyfile( ".", "texvc.phtml", $IP );
34
35 $handle = opendir( "./includes" );
36 while ( false !== ( $f = readdir( $handle ) ) ) {
37 if ( "." == $f{0} ) continue;
38 copyfile( "./includes", $f, $IP );
39 }
40
41 $handle = opendir( "./stylesheets" );
42 while ( false !== ( $f = readdir( $handle ) ) ) {
43 if ( "." == $f{0} ) continue;
44 copyfile( "./stylesheets", $f, $wgStyleSheetDirectory );
45 }
46
47 copyfile( "./images", "wiki.png", $wgUploadDirectory );
48 copyfile( "./languages", "Language.php", $IP );
49 copyfile( "./languages", "Language" . ucfirst( $wgLanguageCode ) . ".php", $IP );
50
51 $fp = fopen( $wgDebugLogFile, "w" );
52 if ( false === $fp ) {
53 print "Could not create log file \"{$wgDebugLogFile}\".\n";
54 exit();
55 }
56 $d = date( "Y-m-d H:i:s" );
57 fwrite( $fp, "Wiki debug log file created {$d}\n\n" );
58 fclose( $fp );
59
60 if ( $wgUseTeX ) {
61 copyfile( "./math", "texvc", "{$IP}/math", 0775 );
62 copyfile( "./math", "texvc_test", "{$IP}/math", 0775 );
63 copyfile( "./math", "texvc_tex", "{$IP}/math", 0775 );
64 }
65
66 print "Done.\nIf any database changes are necessary, you may have to run\n" .
67 "one or more \"patch\" files from the maintenance directory.\n";
68 exit();
69
70 function copyfile( $sdir, $name, $ddir, $perms = 0644 ) {
71 global $installOwner, $installGroup;
72
73 $d = "{$ddir}/{$name}";
74 if ( copy( "{$sdir}/{$name}", $d ) ) {
75 if ( isset( $installOwner ) ) { chown( $d, $installOwner ); }
76 if ( isset( $installGroup ) ) { chgrp( $d, $installGroup ); }
77 chmod( $d, $perms );
78 # print "Copied \"{$name}\" to \"{$ddir}\".\n";
79 } else {
80 print "Failed to copy file \"{$name}\" to \"{$ddir}\".\n";
81 exit();
82 }
83 }
84
85 ?>