Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1:/tmp/cvs-serv4080
Modified Files:
serendipity_lang_de.inc.php serendipity_lang_en.inc.php
serendipity_admin_installer.inc.php htaccess.rewrite.tpl
htaccess.normal.tpl htaccess.errordocs.tpl NEWS
Log Message:
* Added rewrite rules to htaccess.rewrite.tpl
* Used language string for new htaccess saving method
* Updated NEWS-file
* Introduced '# BEGIN s9y' and '# END s9y' tags for use in .htaccess file -
this way a user can tweak a .htaccess file by adding code outside this block
which will be preserved when s9y updates the .htaccess file
Index: serendipity_lang_de.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_lang_de.inc.php,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- serendipity_lang_de.inc.php 20 Jan 2004 09:14:58 -0000 1.39
+++ serendipity_lang_de.inc.php 20 Jan 2004 11:12:37 -0000 1.40
@@ -315,6 +315,7 @@
@define('GENERAL_PLUGIN_DATEFORMAT_BLAHBLAH', 'Das Datumsformat des Eintrages, mithilfe von PHPs strftime() Variablen. (Standard: "%s")');
@define('GENERAL_PLUGIN_LANGUAGE', 'Anzeigesprache');
@define('GENERAL_PLUGIN_LANGUAGE_BLAHBLAH', 'In welcher Sprache soll das Datum formatiert werden? ("en|de", Standard "en")');
+@define('ERROR_TEMPLATE_FILE', 'Die Templatedatei konnte nicht geöffnet werden, bitte die serendipity-Version aktualisieren!');
/* vim: set sts=4 ts=4 expandtab : */
?>
Index: serendipity_lang_en.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_lang_en.inc.php,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -d -r1.50 -r1.51
--- serendipity_lang_en.inc.php 20 Jan 2004 09:14:58 -0000 1.50
+++ serendipity_lang_en.inc.php 20 Jan 2004 11:12:37 -0000 1.51
@@ -315,6 +315,7 @@
@define('GENERAL_PLUGIN_DATEFORMAT_BLAHBLAH', 'The format of the entry\'s actual date, using PHPs strftime() variables. (Default: "%s")');
@define('GENERAL_PLUGIN_LANGUAGE', 'Output language');
@define('GENERAL_PLUGIN_LANGUAGE_BLAHBLAH', 'What is your output language used for date and text formatting? ("en|de", default "en")');
+@define('ERROR_TEMPLATE_FILE', 'Unable to open template file, please update serendipity!');
/* vim: set sts=4 ts=4 expandtab : */
?>
Index: serendipity_admin_installer.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_admin_installer.inc.php,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- serendipity_admin_installer.inc.php 7 Jan 2004 17:45:46 -0000 1.47
+++ serendipity_admin_installer.inc.php 20 Jan 2004 11:12:37 -0000 1.48
@@ -352,16 +352,20 @@
}
function serendipity_installFiles() {
- if ( $_POST['rewrite'] == 'rewrite') {
+ $htaccess = @file_get_contents('./.htaccess');
+
+ if ($_POST['rewrite'] == 'rewrite') {
$template = 'htaccess.rewrite.tpl';
- } elseif ( $_POST['rewrite'] == 'errordocs' ) {
+ } elseif ($_POST['rewrite'] == 'errordocs') {
$template = 'htaccess.errordocs.tpl';
} else {
$template = 'htaccess.normal.tpl';
}
- if ( !($a = file('./'. $template)) ) {
- $err[] = 'Unable to open template file, please update serendipity!';
+
+ if (!($a = file('./'. $template))) {
+ $err[] = ERROR_TEMPLATE_FILE;
}
+
$fp = @fopen('./.htaccess', 'w');
$content = str_replace(
@@ -378,12 +382,18 @@
implode('', $a)
);
- if ( !$fp ) {
+ if (!$fp) {
$errs[] = sprintf(FILE_WRITE_ERROR, '.htaccess') . ' ' . FILE_CREATE_YOURSELF;
$errs[] = sprintf(COPY_CODE_BELOW , '.htaccess', 'serendipity', $content);
return $errs;
} else {
- fwrite($fp, $content);
+ // Check if an old htaccess file existed and try to preserve its contents. Otherwise completely wipe the file.
+ if ($htaccess != '' && preg_match('@^(.*)#\s+BEGIN\s+s9y.*#\s+END\s+s9y(.*)$@isU', $htaccess, $match)) {
+ // Code outside from s9y-code was found.
+ fwrite($fp, $match[1] . $content . $match[2]);
+ } else {
+ fwrite($fp, $content);
+ }
fclose($fp);
return true;
}
Index: htaccess.rewrite.tpl
===================================================================
RCS file: /cvsroot/php-blog/serendipity/htaccess.rewrite.tpl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- htaccess.rewrite.tpl 7 Jan 2004 17:45:44 -0000 1.1
+++ htaccess.rewrite.tpl 20 Jan 2004 11:12:37 -0000 1.2
@@ -1,6 +1,21 @@
+# BEGIN s9y
ErrorDocument 404 {PREFIX}{indexFile}
DirectoryIndex {PREFIX}{indexFile}
+RewriteEngine On
+RewriteRule ^archives/([0-9]+)\.html {indexFile}?url=/archives/$1.html [L,QSA]
+RewriteRule ^archives/([0-9]+)_short*\.html {indexFile}?url=/archives/$1_short.html [L,NC,QSA]
+RewriteRule ^([0-9]+)_[0-9a-z_]*\.html {indexFile}?url=$1_article.html [L,NC,QSA]
+RewriteRule ^feeds/(.*) {indexFile}?url=/feeds/$1 [L,QSA]
+RewriteRule ^unsubscribe/(.*)/([0-9]+) {indexFile}?url=/unsubscribe/$1/$2 [L,QSA]
+RewriteRule ^admin serendipity_admin.php [L,QSA]
+RewriteRule ^entries serendipity_entries.php [L,QSA]
+RewriteRule ^archive {indexFile}?url=/archive [L,QSA]
+RewriteRule ^categories/(.*) {indexFile}?url=categories/$1 [L,QSA]
+RewriteRule ^(index|rss|b2rss|b2rdf)\.(rss|xml|rdf) rss.php?version=2.0
+RewriteRule ^index\.(html?|php.?) {indexFile}?url=index.html
+RewriteRule (.*\.html?) {indexFile}?url=/$1
+
<Files *.tpl>
deny from all
</Files>
@@ -16,3 +31,4 @@
<Files sqlite.db>
deny from all
</Files>
+# END s9y
\ No newline at end of file
Index: htaccess.normal.tpl
===================================================================
RCS file: /cvsroot/php-blog/serendipity/htaccess.normal.tpl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- htaccess.normal.tpl 7 Jan 2004 17:45:44 -0000 1.1
+++ htaccess.normal.tpl 20 Jan 2004 11:12:37 -0000 1.2
@@ -1,3 +1,4 @@
+# BEGIN s9y
DirectoryIndex {PREFIX}{indexFile}
<Files *.tpl>
@@ -15,3 +16,4 @@
<Files sqlite.db>
deny from all
</Files>
+# END s9y
\ No newline at end of file
Index: htaccess.errordocs.tpl
===================================================================
RCS file: /cvsroot/php-blog/serendipity/htaccess.errordocs.tpl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- htaccess.errordocs.tpl 7 Jan 2004 17:45:44 -0000 1.1
+++ htaccess.errordocs.tpl 20 Jan 2004 11:12:37 -0000 1.2
@@ -1,3 +1,4 @@
+# BEGIN s9y
ErrorDocument 404 {PREFIX}{indexFile}
DirectoryIndex {PREFIX}{indexFile}
@@ -16,3 +17,4 @@
<Files sqlite.db>
deny from all
</Files>
+# END s9y
\ No newline at end of file
Index: NEWS
===================================================================
RCS file: /cvsroot/php-blog/serendipity/NEWS,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- NEWS 20 Jan 2004 09:14:05 -0000 1.41
+++ NEWS 20 Jan 2004 11:12:37 -0000 1.42
@@ -3,7 +3,7 @@
Version 0.5 ()
------------------------------------
* Added support for pinging weblogs.com, blo.gs, blogrolling.com and technorati.com to announce new entries. (jimwinstead, sebastianbergmann)
- * Used patch from Craig O'Shannessy (modified and expanded to all occurences) to allow usage of s9y without mod_rewrite/ErrorDocument Handlers. Set $serendipity['rewrite'] to FALSE to do so. (garvinhicking)
+ * Used patch from Craig O'Shannessy (modified and expanded to all occurences) to allow usage of s9y without mod_rewrite/ErrorDocument Handlers. Configurable with installer. (garvinhicking,tomsommer)
* Created a clickable label for the autologin, german translation (garvinhicking)
* Allow Autologin, saving login information in a cookie (tomsommer)
* HTML-Nugget can now be configured to preserve textformatting. Default is 'apply textformatting' to stay backwards-compatible. (garvinhicking)
|