-function readconsole() {
- $fp = fopen( "php://stdin", "r" );
- $resp = trim( fgets( $fp, 1024 ) );
- fclose( $fp );
- return $resp;
-}
-
-
-function replacevars( $ins ) {
- $varnames = array(
- "wgDBserver", "wgDBname", "wgDBintlname", "wgDBuser",
- "wgDBpassword", "wgDBsqluser", "wgDBsqlpassword",
- "wgDBadminuser", "wgDBadminpassword"
- );
-
- foreach ( $varnames as $var ) {
- global $$var;
- $ins = str_replace( '{$' . $var . '}', $$var, $ins );
- }
- return $ins;
-}
-
-#
-# Read and execute SQL commands from a file
-#
-function dbsource( $fname, $database = false ) {
- $fp = fopen( $fname, "r" );
- if ( false === $fp ) {
- print "Could not open \"{$fname}\".\n";
- exit();
+function readconsole( $prompt = '' ) {
+ static $isatty = null;
+ if ( is_null( $isatty ) ) {
+ if ( !function_exists( 'posix_isatty' ) || posix_isatty( 0 /*STDIN*/ ) ) {
+ $isatty = true;
+ } else {
+ $isatty = false;
+ }