Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1:/tmp/cvs-serv29659
Modified Files:
serendipity_admin_installer.inc.php
serendipity_db_postgres.inc.php serendipity_functions.inc.php
Added Files:
serendipity_functions_config.inc.php
Log Message:
This fixes installation issues with s9y for people desiring postgresql database backends. I tested installation on a system with mysql and I don't think I broke anything.
I made use of the abstracted functions serendipity_set_config_var and serendipity_get_config_var to set the values from the installation script.
To make use of these functions, I broke them out into serendipity_functions_config.inc.php. I also changed the installer so that it included serendipity_db.inc.php instead of the sub-database script. To make this work, I temporarily set $serendipity['dbType'].
Someone really needs to commit the schema for the css table! Just add it to the db.sql file and commit.
--- NEW FILE: serendipity_functions_config.inc.php ---
<?php # $Id: serendipity_functions_config.inc.php,v 1.1 2003/06/29 02:40:48 jtate Exp $
function serendipity_set_config_var($name, $val) {
global $serendipity;
serendipity_db_query("DELETE FROM $serendipity[dbPrefix]config where name='" . serendipity_db_escape_string($name) . "'");
$r = serendipity_db_insert("config", array("name"=>$name, "value"=>$val));
if (is_string($r)) {
echo $r;
}
}
function serendipity_get_config_var($name, $defval = false) {
global $serendipity;
if ( isset($serendipity['CONFIG'][$name]) ) {
return $serendipity['CONFIG'][$name];
} else {
return $defval;
}
}
?>
Index: serendipity_admin_installer.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_admin_installer.inc.php,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- serendipity_admin_installer.inc.php 22 Jun 2003 19:52:18 -0000 1.14
+++ serendipity_admin_installer.inc.php 29 Jun 2003 02:40:48 -0000 1.15
@@ -202,7 +202,8 @@
$serendipity[$k] = $v;
}
}
- include_once $_POST['serendipityPath'] . '/serendipity_db_' . $_POST['dbType'] . '.inc.php';
+ $serendipity['dbType'] = $_POST['dbType'];
+ include_once $_POST['serendipityPath'] . '/serendipity_db.inc.php';
// Probe database (do it after the dir stuff, as we need to be able to create the
// sqlite database)
@@ -239,7 +240,8 @@
'$_POST[email]',
$mail_comments) ";
serendipity_db_query($query);
- $query = "INSERT INTO $_POST[dbPrefix]config set name='template', value='default'";
+ include_once $_POST['serendipityPath'] . '/serendipity_functions_config.inc.php';
+ serendipity_set_config_var('template', 'default');
serendipity_db_query($query);
$text = serendipity_db_escape_string(file_get_contents('./serendipity.css'));
$query = "INSERT into $_POST[dbPrefix]css (name, data) values ('default', '$text')";
@@ -269,15 +271,11 @@
// Save all basic config variables to the database
$p = serendipity_parseTemplate("./serendipity_config_local.tpl");
- foreach($p as $key=>$value) {
- foreach ($value as $entry) {
- $query = "REPLACE INTO {$_POST['dbPrefix']}config (name, value) ";
- $query .= "VALUES ('" . serendipity_db_escape_string($entry['name']) . "', '";
- $query .= serendipity_db_escape_string($_POST[$entry['name']]) . "');";
-
- serendipity_db_query($query);
- }
- }
+ foreach($p as $key=>$value) {
+ foreach ($value as $entry) {
+ serendipity_set_config_var($entry['name'], $_POST[$entry['name']]);
+ }
+ }
// Create a basic configuration file which gives enough information to open
// the database and get information from the database tables
Index: serendipity_db_postgres.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_db_postgres.inc.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- serendipity_db_postgres.inc.php 3 Apr 2003 21:02:41 -0000 1.3
+++ serendipity_db_postgres.inc.php 29 Jun 2003 02:40:48 -0000 1.4
@@ -50,6 +50,7 @@
if (function_exists("debug_backtrace")) {
highlight_string(var_export(debug_backtrace(), 1));
}
+ print "<br><code>$sql</code>\n";
}
return false;
}
Index: serendipity_functions.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_functions.inc.php,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -d -r1.84 -r1.85
--- serendipity_functions.inc.php 28 Jun 2003 18:47:14 -0000 1.84
+++ serendipity_functions.inc.php 29 Jun 2003 02:40:48 -0000 1.85
@@ -1,6 +1,8 @@
<?php
include_once("./serendipity_db.inc.php");
include_once("./compat.php");
+include_once("./serendipity_functions_config.inc.php");
+
function serendipity_getTemplateFile($file) {
global $serendipity;
if ( file_exists($serendipity['templatePath'] . $serendipity['CONFIG']['template'] . '/'. $file) ) {
@@ -1661,25 +1663,6 @@
}
}
echo "</span>";
-}
-
-function serendipity_set_config_var($name, $val) {
- global $serendipity;
-
- serendipity_db_query("DELETE FROM $serendipity[dbPrefix]config where name='" . serendipity_db_escape_string($name) . "'");
- $r = serendipity_db_insert("config", array("name"=>$name, "value"=>$val));
- if (is_string($r)) {
- echo $r;
- }
-}
-
-function serendipity_get_config_var($name, $defval = false) {
- global $serendipity;
- if ( isset($serendipity['CONFIG'][$name]) ) {
- return $serendipity['CONFIG'][$name];
- } else {
- return $defval;
- }
}
function serendipity_emit_htmlarea_code($item)
|