Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5019
Modified Files:
NEWS serendipity_functions_installer.inc.php
Log Message:
* Detect support for php_value directives when changing htaccess files. If not supported, the .cgi version of the htaccess template is used.
* Suppress errors from fsockopen()
* Move fopen() call down a bit
Index: NEWS
===================================================================
RCS file: /cvsroot/php-blog/serendipity/NEWS,v
retrieving revision 1.195
retrieving revision 1.196
diff -u -d -r1.195 -r1.196
--- NEWS 5 Aug 2004 12:32:12 -0000 1.195
+++ NEWS 5 Aug 2004 22:31:10 -0000 1.196
@@ -3,6 +3,9 @@
Version 0.7 ()
------------------------------------------------------------------------
+ * Add detection for support of php_value directives in .htaccess
+ files (tomsommer)
+
* Installation will report an error, if the needed db-extension for
a specific database-type are not available within PHP
(garvinhicking)
Index: serendipity_functions_installer.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_functions_installer.inc.php,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- serendipity_functions_installer.inc.php 28 Jul 2004 16:39:47 -0000 1.27
+++ serendipity_functions_installer.inc.php 5 Aug 2004 22:31:10 -0000 1.28
@@ -281,12 +281,13 @@
fclose($fp);
// Do a request on a nonexistant file to see, if our htaccess allows ErrorDocument
- $sock = fsockopen($serendipity_host, $_SERVER['SERVER_PORT'], $errorno, $errorstring, 10);
+ $sock = @fsockopen($serendipity_host, $_SERVER['SERVER_PORT'], $errorno, $errorstring, 10);
$response = '';
if ($sock) {
fputs($sock, "GET {$_SERVER['PHP_SELF']}nonexistant HTTP/1.0\r\n");
fputs($sock, "Host: $serendipity_host\r\n");
+ fputs($sock, "User-Agent: Serendipity/{$serendipity['version']}\r\n");
fputs($sock, "Connection: close\r\n\r\n");
while (!feof($sock) && strlen($response) < 4096) {
@@ -599,6 +600,50 @@
$htaccess_cgi = '';
}
+
+ /* Detect comptability with php_value */
+ if ( $htaccess_cgi == '' ) {
+ $serendipity_root = str_replace(basename($_SERVER['PHP_SELF']), '', $_SERVER['PHP_SELF']);
+ $serendipity_host = preg_replace('@^([^:]+):?.*$@', '\1', $_SERVER['HTTP_HOST']);
+
+ $old_htaccess = @file_get_contents($serendipity['serendipityPath'] . '.htaccess');
+ $fp = @fopen($serendipity['serendipityPath'] . '.htaccess', 'w');
+ if ($fp) {
+ fwrite($fp, 'php_value register_globals off'. "\n" .'php_value session.use_trans_sid 0');
+ fclose($fp);
+
+ // Do a request on a nonexistant file to see, if our htaccess allows ErrorDocument
+ $sock = @fsockopen($serendipity_host, $_SERVER['SERVER_PORT'], $errorno, $errorstring, 10);
+ $response = '';
+
+ if ($sock) {
+ fputs($sock, "GET {$serendipity['serendipityHTTPPath']} HTTP/1.0\r\n");
+ fputs($sock, "Host: $serendipity_host\r\n");
+ fputs($sock, "User-Agent: Serendipity/{$serendipity['version']}\r\n");
+ fputs($sock, "Connection: close\r\n\r\n");
+
+ while (!feof($sock) && strlen($response) < 4096) {
+ $response .= fgets($sock, 400);
+ }
+ fclose($sock);
+ }
+
+ /* 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';
+ }
+
+ if (!empty($old_htacces)) {
+ $fp = @fopen($serendipity['serendipityPath'] . '.htaccess', 'w');
+ fwrite($fp, $old_htaccess);
+ fclose($fp);
+ } else {
+ @unlink($serendipity['serendipityPath'] . '.htaccess');
+ }
+ }
+ }
+
+
if ($rewrite == 'rewrite') {
$template = 'htaccess' . $htaccess_cgi . '.rewrite.tpl';
} elseif ($rewrite == 'errordocs') {
@@ -611,8 +656,6 @@
$err[] = ERROR_TEMPLATE_FILE;
}
- $fp = @fopen($serendipity['serendipityPath'] . '.htaccess', 'w');
-
$content = str_replace(
array(
'{PREFIX}',
@@ -651,6 +694,7 @@
implode('', $a)
);
+ $fp = @fopen($serendipity['serendipityPath'] . '.htaccess', 'w');
if (!$fp) {
$errs[] = sprintf(FILE_WRITE_ERROR, $serendipity['serendipityPath'] . '.htaccess') . ' ' . FILE_CREATE_YOURSELF;
$errs[] = sprintf(COPY_CODE_BELOW , $serendipity['serendipityPath'] . '.htaccess', 'serendipity', htmlspecialchars($content));
|