Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28865
Modified Files:
serendipity_admin_installer.inc.php
serendipity_functions.inc.php
serendipity_functions_installer.inc.php
Log Message:
finally fixed that damn shared install .htaccess updating problem for good.
let's release 0.7-beta1 :)
Index: serendipity_admin_installer.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_admin_installer.inc.php,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -d -r1.73 -r1.74
--- serendipity_admin_installer.inc.php 28 Jul 2004 17:27:14 -0000 1.73
+++ serendipity_admin_installer.inc.php 9 Aug 2004 09:49:54 -0000 1.74
@@ -11,6 +11,18 @@
$_POST['installAction'] = '';
}
+/* Check where to deploy .htaccess files. For shared installation, first guess is submitted directory name.
+ If that is not existant we autodetect using current directory. */
+if (IS_installed !== true) {
+ if (!empty($_POST['serendipityPath'])) {
+ $serendipity_core = $_POST['serendipityPath'];
+ } else {
+ $serendipity_core = $_SERVER['DOCUMENT_ROOT'] . dirname($_SERVER['PHP_SELF']) . '/';
+ }
+} else {
+ $serendipity_core = $serendipity['serendipityPath'];
+}
+
switch ($_POST['installAction']) {
case 'check':
/* If we already have serendipity installed, all we need to do is write the configuration again */
@@ -37,8 +49,8 @@
}
/* Next are the files, .htaccess */
- printf(ATTEMPT_WRITE_FILE, $serendipity['serendipityPath'] . '.htaccess');
- $res = serendipity_installFiles();
+ printf(ATTEMPT_WRITE_FILE, $serendipity_core . '.htaccess');
+ $res = serendipity_installFiles($serendipity_core);
if (is_array($res)) {
echo '<span class="serendipity_msg_important">- ' . implode('<br />', $res) . '</span><br /><br />';
die();
@@ -86,8 +98,8 @@
} else {
/* If we have new rewrite rules, then install them */
if (isset($_POST['rewrite']) && $serendipity['serendipityUserlevel'] >= USERLEVEL_ADMIN && $oldRewrite != $_POST['rewrite']) {
- printf(ATTEMPT_WRITE_FILE, $serendipity['serendipityPath'] . '.htaccess');
- $res = serendipity_installFiles();
+ printf(ATTEMPT_WRITE_FILE, $serendipity_core . '.htaccess');
+ $res = serendipity_installFiles($serendipity_core);
if (is_array($res)) {
echo implode('<br />'. $res);
} else {
@@ -124,5 +136,4 @@
}
/* vim: set sts=4 ts=4 expandtab : */
-?>
-
+?>
\ No newline at end of file
Index: serendipity_functions.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_functions.inc.php,v
retrieving revision 1.389
retrieving revision 1.390
diff -u -d -r1.389 -r1.390
--- serendipity_functions.inc.php 8 Aug 2004 22:39:58 -0000 1.389
+++ serendipity_functions.inc.php 9 Aug 2004 09:49:54 -0000 1.390
@@ -521,16 +521,16 @@
}
if ($y == 6) {
$cellProps[] = 'LastInRow';
- }
+ }
if ($x == $nrOfRows-1) {
$cellProps[] = 'LastRow';
- }
+ }
// If it's not a blank day, we print the day
if (($x > 0 || $y >= $firstDayWeekDay) && $currDay <= $nrOfDays) {
$printDay = $currDay;
-
+
if ($today_year == $year && $today_month == $month && $today_day == $currDay) {
$cellProps[] = 'Today';
}
@@ -1761,7 +1761,7 @@
$row = serendipity_db_query($query, true); // Get info on author/entry
// Send mail to the author if he chose to receive these mails, or if the comment is awaiting moderation
- if (serendipity_db_bool($ca['moderate_comments'])
+ if (serendipity_db_bool($ca['moderate_comments'])
|| ($type == 'NORMAL' && serendipity_db_bool($row['mail_comments']))
|| ($type == 'TRACKBACK' && serendipity_db_bool($row['mail_trackbacks']))) {
serendipity_sendComment($cid, $row['email'], $name, $email, $url, $id, $row['title'], $comments, $type, serendipity_db_bool($row['moderate_comments']));
@@ -1950,7 +1950,7 @@
static $r = array(
'&\1',
'&',
- '<\1r\2 />'
+ '<\1\2 />'
);
return preg_replace($p, $r, $html);
Index: serendipity_functions_installer.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_functions_installer.inc.php,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- serendipity_functions_installer.inc.php 5 Aug 2004 22:37:05 -0000 1.29
+++ serendipity_functions_installer.inc.php 9 Aug 2004 09:49:54 -0000 1.30
@@ -266,9 +266,10 @@
// If not yet installed, do some magic:
$abort = false;
if (IS_installed !== true && $_abort !== true) {
- $old_htaccess = @file_get_contents($serendipity['serendipityPath'] . '.htaccess');
- $fp = @fopen($serendipity['serendipityPath'] . '.htaccess', 'w');
- $serendipity_root = str_replace(basename($_SERVER['PHP_SELF']), '', $_SERVER['PHP_SELF']);
+ $serendipity_root = dirname($_SERVER['PHP_SELF']) . '/';
+ $serendipity_core = $_SERVER['DOCUMENT_ROOT'] . $serendipity_root;
+ $old_htaccess = @file_get_contents($serendipity_core . '.htaccess');
+ $fp = @fopen($serendipity_core . '.htaccess', 'w');
$serendipity_host = preg_replace('@^([^:]+):?.*$@', '\1', $_SERVER['HTTP_HOST']);
if (!$fp) {
@@ -302,12 +303,12 @@
$serendipity['rewrite_default'] = 'none';
}
- if (!empty($old_htacces)) {
- $fp = @fopen($serendipity['serendipityPath'] . '.htaccess', 'w');
+ if (!empty($old_htaccess)) {
+ $fp = @fopen($serendipity_core . '.htaccess', 'w');
fwrite($fp, $old_htaccess);
fclose($fp);
} else {
- @unlink($serendipity['serendipityPath'] . '.htaccess');
+ @unlink($serendipity_core . '.htaccess');
}
}
}
@@ -579,10 +580,16 @@
return true;
}
-function serendipity_installFiles() {
+function serendipity_installFiles($serendipity_core = '') {
global $serendipity;
- $htaccess = @file_get_contents($serendipity['serendipityPath'] . '.htaccess');
+ // This variable is transmitted from serendipity_admin_installer. If an empty variable is used,
+ // this means that serendipity_installFiles() was called from the auto-updater facility.
+ if (empty($serendipity_core)) {
+ $serendipity_core = $serendipity['serendipityPath'];
+ }
+
+ $htaccess = @file_get_contents($serendipity_core . '.htaccess');
// Let this function be callable outside installation and let it use existing settings.
$import = array('rewrite', 'serendipityHTTPPath', 'indexFile');
@@ -594,21 +601,21 @@
}
}
- if(php_sapi_name() == 'cgi' || php_sapi_name() == 'cgi-fcgi') {
- $htaccess_cgi = '.cgi';
+ if (php_sapi_name() == 'cgi' || php_sapi_name() == 'cgi-fcgi') {
+ $htaccess_cgi = '.cgi';
} else {
- $htaccess_cgi = '';
+ $htaccess_cgi = '';
}
/* Detect comptability with php_value directives */
- if ( $htaccess_cgi == '' ) {
+ if ($htaccess_cgi == '') {
$response = '';
- $serendipity_root = str_replace(basename($_SERVER['PHP_SELF']), '', $_SERVER['PHP_SELF']);
+ $serendipity_root = dirname($_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');
+ $old_htaccess = @file_get_contents($serendipity_core . '.htaccess');
+ $fp = @fopen($serendipity_core . '.htaccess', 'w');
if ($fp) {
fwrite($fp, 'php_value register_globals off'. "\n" .'php_value session.use_trans_sid 0');
fclose($fp);
@@ -631,12 +638,12 @@
$htaccess_cgi = '.cgi';
}
- if (!empty($old_htacces)) {
- $fp = @fopen($serendipity['serendipityPath'] . '.htaccess', 'w');
+ if (!empty($old_htaccess)) {
+ $fp = @fopen($serendipity_core . '.htaccess', 'w');
fwrite($fp, $old_htaccess);
fclose($fp);
} else {
- @unlink($serendipity['serendipityPath'] . '.htaccess');
+ @unlink($serendipity_core . '.htaccess');
}
}
}
@@ -692,10 +699,10 @@
implode('', $a)
);
- $fp = @fopen($serendipity['serendipityPath'] . '.htaccess', 'w');
+ $fp = @fopen($serendipity_core . '.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));
+ $errs[] = sprintf(FILE_WRITE_ERROR, $serendipity_core . '.htaccess') . ' ' . FILE_CREATE_YOURSELF;
+ $errs[] = sprintf(COPY_CODE_BELOW , $serendipity_core . '.htaccess', 'serendipity', htmlspecialchars($content));
return $errs;
} else {
// Check if an old htaccess file existed and try to preserve its contents. Otherwise completely wipe the file.
@@ -751,4 +758,4 @@
return true;
}
}
-?>
+?>
\ No newline at end of file
|