bug fix
[lhc/web/wiklou.git] / install-utils.inc
index 55e712c..040c34d 100644 (file)
@@ -1,6 +1,9 @@
 <?php
 
 function install_version_checks() {
+       # Turn off output buffering if it's on
+       @ob_end_flush();
+       
        if( !function_exists( "version_compare" ) ) {
                # version_compare was introduced in 4.1.0
                die( "Your PHP version is much too old; 4.0.x will _not_ work. 4.3.2 or higher is recommended. ABORTING.\n" );
@@ -52,14 +55,18 @@ function copydirectory( $source, $dest ) {
        }
 }
 
-function readconsole() {
-       $fp = fopen( "php://stdin", "r" );
-       $resp = trim( fgets( $fp, 1024 ) );
-       fclose( $fp );
-       return $resp;
+function readconsole( $prompt = "" ) {
+       if ( function_exists( "readline" ) ) {
+               return readline( $prompt );
+       } else {
+               print $prompt;
+               $fp = fopen( "php://stdin", "r" );
+               $resp = trim( fgets( $fp, 1024 ) );
+               fclose( $fp );
+               return $resp;
+       }
 }
 
-
 function replacevars( $ins ) {
        $varnames = array(
                "wgDBserver", "wgDBname", "wgDBintlname", "wgDBuser",
@@ -110,7 +117,8 @@ function dbsource( $fname, $database = false ) {
                                $res = mysql_query( $cmd );
 
                        if ( false === $res ) {
-                               print "Query \"{$cmd}\" failed.\n";
+                               $err = mysql_error();
+                               print "Query \"{$cmd}\" failed with error code \"$err\".\n";
                                exit();
                        }