From: Brion Vibber
Date: Sun, 7 Mar 2004 01:31:08 +0000 (+0000)
Subject: Avoid failing on pre-4.3.2 due to lack of 'x' create-only option on fopen
X-Git-Tag: 1.3.0beta1~848
X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22articles%22%2C%22id_article=%24ze_article%22%29%20.%20%22?a=commitdiff_plain;h=3e97b1dd6f486878d2216e6ff72a8b554e6098d7;p=lhc%2Fweb%2Fwiklou.git
Avoid failing on pre-4.3.2 due to lack of 'x' create-only option on fopen
---
diff --git a/config/index.php b/config/index.php
index cc22169f1e..a8e0ce3d10 100644
--- a/config/index.php
+++ b/config/index.php
@@ -424,7 +424,14 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) {
/* Write out the config file now that all is well */
print "Creating LocalSettings.php...
\n\n";
$localSettings = "<" . "?php\n$local\n?" . ">";
- $f = fopen( "LocalSettings.php", "xt" );
+
+ if( version_compare( phpversion(), "4.3.2" ) >= 0 ) {
+ $xt = "xt"; # Refuse to overwrite an existing file
+ } else {
+ $xt = "wt"; # 'x' is not available prior to PHP 4.3.2. We did check above, but race conditions blah blah
+ }
+ $f = fopen( "LocalSettings.php", $xt );
+
if( $f == false ) {
dieout( "Couldn't write out LocalSettings.php. Check that the directory permissions are correct and that there isn't already a file of that name here...
\n" .
"Here's the file that would have been written, try to paste it into place manually:
\n" .