Update of /cvsroot/php-blog/serendipity/include
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5405/include
Modified Files:
functions_installer.inc.php
Log Message:
allow user-defined variables in serendipity_config_local.inc.php
Index: functions_installer.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/include/functions_installer.inc.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- functions_installer.inc.php 20 Nov 2004 12:21:40 -0000 1.3
+++ functions_installer.inc.php 20 Nov 2004 14:09:10 -0000 1.4
@@ -5,7 +5,9 @@
if (is_null($path)) {
$path = $serendipity['serendipityPath'];
}
- $configfp = fopen($path . $file, 'w');
+
+ $oldconfig = @file_get_contents($path . $file);
+ $configfp = fopen($path . $file, 'w');
if (!is_resource($configfp)) {
$errs[] = sprintf(FILE_WRITE_ERROR, $file);
@@ -20,10 +22,21 @@
$dbName = $_POST['sqlitedbName'];
}
- fwrite($configfp, "<?php\n");
+ $file_start = "<?php\n"
+ . "\t/*\n"
+ . "\t Serendipity configuration file\n";
+ $file_mark = "\n\t// End of Serendipity configuration file"
+ . "\n\t// You can place your own special variables after here:\n";
+ $file_end = "\n?>\n";
+ $file_personal = '';
+
+ preg_match('@' . preg_quote($file_start) . '.*' . preg_quote($file_mark) . '(.+)' . preg_quote($file_end) . '@imsU', $oldconfig, $match);
+ if (!empty($match[1])) {
+ $file_personal = $match[1];
+ }
+
+ fwrite($configfp, $file_start);
- fwrite($configfp, "\t/*\n");
- fwrite($configfp, "\t Serendipity configuration file\n");
fwrite($configfp, "\t Written on ". date('r') ."\n");
fwrite($configfp, "\t*/\n\n");
@@ -41,7 +54,7 @@
}
}
- fwrite($configfp, "?>\n");
+ fwrite($configfp, $file_mark . $file_personal . $file_end);
fclose($configfp);
@@ -144,7 +157,7 @@
}
function serendipity_parseTemplate($n, $raw = false, $prepend_var = null, $get_defaults = true) {
- global $serendipity;
+ global $serendipity;
if (is_array($prepend_var)) {
$config = $configRaw = &$prepend_var;
@@ -159,13 +172,13 @@
$maxt = count($t);
for ($x=0; $x<$maxt; $x++) {
- $l = $t[$x];
+ $l = $t[$x];
$l = trim($l);
if ($l != '') {
- switch ($l[0]) {
+ switch ($l[0]) {
- // New Configure section
+ // New Configure section
case '/':
if ($l[1] == '/') {
$current = @constant(trim(substr($l, 2)));
@@ -179,7 +192,7 @@
// A configure option
case '$':
- // Grep out the name, type and default
+ // Grep out the name, type and default
preg_match('#\{([^|]+\|[^|]+\|([^}]+)?)\}[^/]+/{2}(.+)#msi', $l, $match);
// Make vars containing the elements in the | list
|