3 function install_version_checks() {
4 # We dare not turn output buffer _off_ since this will break completely
5 # if PHP is globally configured to run through a gzip filter.
6 @ob_implicit_flush( true );
8 if( !function_exists( 'version_compare' ) ) {
9 # version_compare was introduced in 4.1.0
10 echo "Your PHP version is much too old; 4.0.x will _not_ work. 4.3.2 or higher is required. ABORTING.\n";
13 if( version_compare( phpversion(), '4.3.2' ) < 0 ) {
14 echo "PHP 4.3.2 or higher is required. ABORTING.\n";
19 ## XXX We should quiet the warnings thrown here
20 if (extension_loaded('mysql') or @dl('mysql.so')) {
21 $gotdatabase = 'mysql';
23 else if (extension_loaded('pgsql') or @dl('pgsql.so')) {
27 global $wgCommandLineMode;
29 $error ="Could not load the MySQL or the PostgreSQL driver! Please compile ".
30 "php with either --with-mysql or --with-pgsql, or install the mysql.so or pg.so module.<br/>\n".
31 " If the database extension is installed (eg php-mysql), make sure it is enabled in your php.ini.\n";
32 if( $wgCommandLineMode ) { print $error; }
33 else { outputFooter($error); }
37 global $wgCommandLineMode;
38 $wgCommandLineMode = true;
43 function copyfile( $sdir, $name, $ddir, $perms = 0664 ) {
44 copyfileto( $sdir, $name, $ddir, $name, $perms );
47 function copyfileto( $sdir, $sname, $ddir, $dname, $perms = 0664 ) {
48 global $wgInstallOwner, $wgInstallGroup;
50 $d = "{$ddir}/{$dname}";
51 if ( copy( "{$sdir}/{$sname}", $d ) ) {
52 if ( isset( $wgInstallOwner ) ) { chown( $d, $wgInstallOwner ); }
53 if ( isset( $wgInstallGroup ) ) { chgrp( $d, $wgInstallGroup ); }
55 # print "Copied \"{$sname}\" to \"{$d}\".\n";
57 print "Failed to copy file \"{$sname}\" to \"{$ddir}/{$dname}\".\n";
62 function copydirectory( $source, $dest ) {
63 $handle = opendir( $source );
64 while ( false !== ( $f = readdir( $handle ) ) ) {
65 $fullname = "$source/$f";
66 if ( $f{0} != '.' && is_file( $fullname ) ) {
67 copyfile( $source, $f, $dest );
72 function readconsole( $prompt = '' ) {
73 static $isatty = null, $fp = null;
74 if ( is_null( $fp ) ) {
75 $fp = fopen( 'php://stdin', 'r' );
77 if ( is_null( $isatty ) ) {
78 if ( !function_exists( 'posix_isatty' ) || posix_isatty( $fp ) ) {
85 if ( $isatty && function_exists( 'readline' ) ) {
86 return readline( $prompt );
94 $st = fgets($fp, 1024);
95 if ($st === false) return false;
102 # Read and execute SQL commands from a file
104 function dbsource( $fname, $db = false ) {
106 // Try $wgDatabase, which is used in the install and update scripts
108 if ( isset( $wgDatabase ) ) {
111 // No? Well, we must be outside of those scripts, so use the standard method
112 $db =& wfGetDB( DB_MASTER );
115 $error = $db->sourceFile( $fname );
116 if ( $error !== true ) {
122 # Obsolete, use Database::fieldExists()
123 function field_exists( $table, $field ) {
124 $fname = 'Update script: field_exists';
125 $db =& wfGetDB( DB_SLAVE );
126 $res = $db->query( "DESCRIBE $table", $fname );
129 while ( $row = $db->fetchObject( $res ) ) {
130 if ( $row->Field == $field ) {
138 # Obsolete Database::tableExists()
139 function table_exists( $db ) {
141 $res = mysql_list_tables( $wgDBname );
143 echo "** " . mysql_error() . "\n";
146 for( $i = mysql_num_rows( $res ) - 1; $i--; $i > 0 ) {
147 if( mysql_tablename( $res, $i ) == $db ) return true;
152 # Obsolete, use Database:fieldInfo()
153 function field_info( $table, $field ) {
154 $res = mysql_query( "SELECT * FROM $table LIMIT 1" );
155 $n = mysql_num_fields( $res );
156 for( $i = 0; $i < $n; $i++ ) {
157 $meta = mysql_fetch_field( $res, $i );
158 if( $field == $meta->name ) {
166 * Used to end the HTML stream when we die out
168 function outputFooter( $text ) {
174 <div id="column-one">
175 <div class="portlet" id="p-logo">
176 <a style="background-image: url(../skins/common/images/mediawiki.png);"
177 href="http://www.mediawiki.org/"
178 title="Main Page"></a>
180 <script type="text/javascript"> if (window.isMSIE55) fixalpha(); </script>
181 <div class='portlet'><div class='pBody'>
183 <li><strong><a href="http://www.mediawiki.org/">MediaWiki home</a></strong></li>
184 <li><a href="../README">Readme</a></li>
185 <li><a href="../RELEASE-NOTES">Release notes</a></li>
186 <li><a href="../docs/">Documentation</a></li>
187 <li><a href="http://meta.wikipedia.org/wiki/MediaWiki_User's_Guide">User's Guide</a></li>
188 <li><a href="http://meta.wikimedia.org/wiki/MediaWiki_FAQ">FAQ</a></li>
190 <p style="font-size:90%;margin-top:1em">MediaWiki is Copyright © 2001-2006 by Magnus Manske, Brion Vibber, Lee Daniel Crocker, Tim Starling, Erik Möller, Gabriel Wicke and others.</p>