]> git.mjollnir.org Git - s9y.git/commitdiff
Improve installation on hosts where fsockopen() is disabled
authorgarvinhicking <garvinhicking>
Mon, 26 Feb 2007 14:42:04 +0000 (14:42 +0000)
committergarvinhicking <garvinhicking>
Mon, 26 Feb 2007 14:42:04 +0000 (14:42 +0000)
docs/NEWS
include/functions_installer.inc.php

index 87fea68fb8ec1f2b9f7dcc6e72a0a37f57dc87d1..3f2167d1556e6f9f01e3e7489bbc7a9111335f31 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -3,6 +3,9 @@
 Version 1.2 ()
 ------------------------------------------------------------------------
 
+    * Improve installation on hosts where fsockopen() is disabled
+      (garvinhicking)
+      
     * Improve memory usage of WordPress importer, add debug output
       (garvinhicking)
       
index c90d1d68cd21cd73ea4d60b444bbf9e3752c1d65..08be1ba1cbc83498f1e2f3789293d174ee4447f5 100644 (file)
@@ -780,6 +780,11 @@ function serendipity_installFiles($serendipity_core = '') {
         $htaccess_cgi = '';
     }
 
+    /* If this file exists, a previous install failed painfully. We must consider the safer alternative now */
+    if (file_exists($serendipity_core . '.installer_detection_failsafe')) {
+        $htaccess_cgi = '_cgi';
+        @unlink($serendipity_core . '.htaccess');
+    }
 
     /* Detect comptability with php_value directives */
     if ($htaccess_cgi == '') {
@@ -792,8 +797,10 @@ function serendipity_installFiles($serendipity_core = '') {
         if ($fp) {
             fwrite($fp, 'php_value register_globals off'. "\n" .'php_value session.use_trans_sid 0');
             fclose($fp);
-
-            $sock = @fsockopen($serendipity_host, $_SERVER['SERVER_PORT'], $errorno, $errorstring, 10);
+            
+            $safeFP = @fopen($serendipity_core . '.installer_detection_failsafe', 'w');
+            fclose($safeFP);
+            $sock = fsockopen($serendipity_host, $_SERVER['SERVER_PORT'], $errorno, $errorstring, 10);
             if ($sock) {
                 fputs($sock, "GET {$serendipityHTTPPath} HTTP/1.0\r\n");
                 fputs($sock, "Host: $serendipity_host\r\n");
@@ -806,7 +813,7 @@ function serendipity_installFiles($serendipity_core = '') {
                 fclose($sock);
             }
 
-            /* If we get HTTP 500 Internal Server Error, we have to use the .cgi template */
+            # If we get HTTP 500 Internal Server Error, we have to use the .cgi template
             if (preg_match('@^HTTP/\d\.\d 500@', $response)) {
                 $htaccess_cgi = '_cgi';
             }
@@ -818,6 +825,8 @@ function serendipity_installFiles($serendipity_core = '') {
             } else {
                 @unlink($serendipity_core . '.htaccess');
             }
+
+            @unlink($serendipity_core . '.installer_detection_failsafe');
         }
     }