changeset 857 | f3a5a276208c |
parent 851 | b98798f6572d |
child 875 | 0c3dd4c166c0 |
856:0b7ff06aad13 | 857:f3a5a276208c |
---|---|
5031 } |
5031 } |
5032 } |
5032 } |
5033 return false; |
5033 return false; |
5034 } |
5034 } |
5035 |
5035 |
5036 ?> |
5036 /** |
5037 * Properly test a file or directory for writability. Used in various places around installer. |
|
5038 * @param string File or directory to test |
|
5039 * @return bool |
|
5040 */ |
|
5041 |
|
5042 function write_test($filename) |
|
5043 { |
|
5044 // We need to actually _open_ the file to make sure it can be written, because sometimes this fails even when is_writable() returns |
|
5045 // true on Windows/IIS servers. Don't ask me why. |
|
5046 |
|
5047 $file = ENANO_ROOT . '/' . $filename; |
|
5048 if ( is_dir($file) ) |
|
5049 { |
|
5050 $file = rtrim($file, '/') . '/' . 'enanoinstalltest.txt'; |
|
5051 if ( file_exists($file) ) |
|
5052 { |
|
5053 $fp = @fopen($file, 'a+'); |
|
5054 if ( !$fp ) |
|
5055 return false; |
|
5056 fclose($fp); |
|
5057 unlink($file); |
|
5058 return true; |
|
5059 } |
|
5060 else |
|
5061 { |
|
5062 $fp = @fopen($file, 'w'); |
|
5063 if ( !$fp ) |
|
5064 return false; |
|
5065 fclose($fp); |
|
5066 unlink($file); |
|
5067 return true; |
|
5068 } |
|
5069 } |
|
5070 else |
|
5071 { |
|
5072 if ( file_exists($file) ) |
|
5073 { |
|
5074 $fp = @fopen($file, 'a+'); |
|
5075 if ( !$fp ) |
|
5076 return false; |
|
5077 fclose($fp); |
|
5078 return true; |
|
5079 } |
|
5080 else |
|
5081 { |
|
5082 $fp = @fopen($file, 'w'); |
|
5083 if ( !$fp ) |
|
5084 return false; |
|
5085 fclose($fp); |
|
5086 return true; |
|
5087 } |
|
5088 } |
|
5089 } |
|
5090 |