}
}
-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",
$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();
}