From baa34f6a341df3fddc2a6ecd85391c548de8cc37 Mon Sep 17 00:00:00 2001 From: donncha Date: Mon, 25 Jul 2005 19:46:45 +0000 Subject: Add a lot more error checking and reporting. git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@78 7be80a69-a1ef-0310-a953-fb0f7c49ff36 --- index.php | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 63 insertions(+), 11 deletions(-) (limited to 'index.php') diff --git a/index.php b/index.php index 1276e0f..3c8ed4a 100644 --- a/index.php +++ b/index.php @@ -86,6 +86,37 @@ function check_writeable_dir( $dir, $ret ) } } +function filestats( $err ) { + print "

Server Summary

"; + print "

If you post a message to the MU support forum at http://mu.wordpress.org/forums/ then copy and paste the following information into your message:

"; + + print "
"; + print "
ERROR: $err
"; + clearstatcache(); + $files = array( "htaccess.dist", ".htaccess" ); + while( list( $key, $val ) = each( $files ) ) { + $stats = @stat( $val ); + if( $stats ) { + print "

$val

"; + print "    uid/gid: " . $stats[ 'uid' ] . "/" . $stats[ 'gid' ] . "
\n"; + print "    size: " . $stats[ 'size' ] . "
"; + print "    perms: " . substr( sprintf('%o', fileperms( $val ) ), -4 ) . "
"; + print "    readable: "; + print is_readable( $val ) == true ? "yes" : "no"; + print "
"; + print "    writeable: "; + print is_writeable( $val ) == true ? "yes" : "no"; + print "
"; + + } elseif( file_exists( $val ) == false ) { + print "

$val

"; + print "    FILE NOT FOUND: $val
"; + } + } + print "
"; + +} + function do_htaccess( $oldfilename, $newfilename, $realpath, $base, $url ) { // remove ending slash from $base and $url @@ -97,11 +128,10 @@ function do_htaccess( $oldfilename, $newfilename, $realpath, $base, $url ) if( substr($url, -1 ) == '/') { $url = substr($url, 0, -1); } - if( is_file( $oldfilename ) ) - { + $err = ''; + if( is_file( $oldfilename ) ) { $fp = @fopen( $oldfilename, "r" ); - if( $fp ) - { + if( $fp ) { while( !feof( $fp ) ) { $htaccess .= fgets( $fp, 4096 ); @@ -111,16 +141,39 @@ function do_htaccess( $oldfilename, $newfilename, $realpath, $base, $url ) $htaccess = str_replace( "BASE", $base, $htaccess ); $htaccess = str_replace( "HOST", $url, $htaccess ); $fp = fopen( $newfilename, "w" ); - fwrite( $fp, $htaccess ); - fclose( $fp ); + if( $fp ) { + fwrite( $fp, $htaccess ); + fclose( $fp ); + } else { + $err = "could not open $newfilename for writing"; + } } else { - print "

There was a problem creating the .htaccess file in $realpath. Please ensure that the webserver can write to this directory.

"; + $err = "could not open $oldfilename for reading"; + } + } else { + $err = "$oldfilename not found"; + } + + if( $err != '' ) { + print "

Warning!

"; + print "

There was a problem creating the .htaccess file in $realpath.

"; + print "

Error: "; + if( $err == "could not open $newfilename for writing" ) { + print "Could Not Write To $newfilename."; + } elseif( $err == "could not open $oldfilename for reading" ) { + print "I could not read from $oldfilename. "; + } elseif( $err == "$oldfilename not found" ) { + print "The file, $oldfilename, is missing."; + } + print "

"; + filestats( $err ); + + print "

Please ensure that the webserver can write to this directory.

"; print "

If all else fails then you'll have to create it by hand:"; print "