Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1:/tmp/cvs-serv1520
Modified Files:
NEWS compat.php serendipity_admin.php
serendipity_admin_installer.inc.php serendipity_config.inc.php
serendipity_db.inc.php serendipity_lang.inc.php
Log Message:
* Fixed the problems with no translation being displayed when asked to run the installer
* Fixed problem with escaping single quotes during installation
* Fixed problem with dual-trailing slashes in paths during installation
* Save s9y version to _config_local.inc.php to be used later during upgrades
* Rewrote much of the "installer VS config.inc.php" behaviour
* We are now ready for 0.3, date is set for October 1st in NEWS..
Index: NEWS
===================================================================
RCS file: /cvsroot/php-blog/serendipity/NEWS,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- NEWS 30 Sep 2003 17:00:09 -0000 1.27
+++ NEWS 30 Sep 2003 21:21:59 -0000 1.28
@@ -1,14 +1,17 @@
# $Id$
-Version 0.3 ()
+Version 0.3 (October 1, 2003)
------------------------------------
+ * Fixed problem with escaping single quotes during installation (tomsommer)
+ * Fixed problem with dual-trailing slashes in paths during installation (tomsommer)
+ * Configuration/installation will now save the current s9y version to the config file... Thereby allowing upgrades at a later point (tomsommer)
* Include <slash:comments> in RSS-Feed. Shows amount of comments available
* Differentiate subscription mails between regular comment and trackback and adjust the mail's content corresponding to this (garvinhicking)
- * Verbose output for DB creation on installation, PostgreSQL DB-setup fixes (jtate)
+ * Added verbose output for DB creation on installation, PostgreSQL DB-setup fixes (jtate)
* Made XHTML-compatibility fix to radio buttons of the installer (garvinhicking)
- * Browse categories (on multiple pages) and have per-category RSS-feed (garvinhicking+sbergmann)
+ * Allow for browseing of categories (on multiple pages) and have per-category RSS-feed (garvinhicking+sbergmann)
* Fixed display of category in full article (garvinhicking)
- * Display all config options in installer when s9y is first installed (garvinhicking)
+ * Expand all config categories in installer when s9y is first installed (garvinhicking)
* Added select-dropdown configuration directive for the plugins (garvinhicking)
* Prepended language defines with a '@' to suppress error messages for fallback-language (garvinhicking)
* Fixed search results not displaying all content (garvinhicking)
@@ -40,7 +43,7 @@
* Restrict calendar to only browse between the dates you have comments available for (garvinhicking)
* Added external plugin to display the latest comments on a sidebar (experimental, garvinhicking)
* Add Link to extended entry in RSS-feed, if existing (garvinhicking)
- * Unified admin login functionality (tomsommer)
+ * Unified and optimized admin login functionality (tomsommer)
* Fixed trackback functionality (tomsommer)
* Send User-Agent "Serendipity/v" when trackbacking (tomsommer)
* New default theme (tomsommer)
Index: compat.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/compat.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- compat.php 18 Sep 2003 12:57:46 -0000 1.5
+++ compat.php 30 Sep 2003 21:21:59 -0000 1.6
@@ -12,6 +12,7 @@
}
}
+
if (!isset($_POST)) {
$_POST = &$HTTP_POST_VARS;
}
@@ -31,5 +32,58 @@
if (!isset($_SERVER)) {
$_SERVER = &$HTTP_SERVER_VARS;
}
+
+/*
+ * Avoid magic_quotes_gpc issues
+ * courtesy of il...@ph...
+ */
+function serendipity_strip_quotes(&$var)
+{
+ if (is_array($var)) {
+ foreach ($var as $k => $v) {
+ if (is_array($v)) {
+ array_walk($var[$k], 'serendipity_strip_quotes');
+ } else {
+ $var[$k] = stripslashes($v);
+ }
+ }
+ } else {
+ $var = stripslashes($var);
+ }
+}
+
+if (ini_get('magic_quotes_gpc')) {
+ if (@count($_GET)) {
+ array_walk($_GET, 'serendipity_strip_quotes');
+ }
+
+ if (@count($_POST)) {
+ array_walk($_POST, 'serendipity_strip_quotes');
+ }
+
+ if (@count($_COOKIES)) {
+ array_walk($_COOKIES, 'serendipity_strip_quotes');
+ }
+
+ if (@count($_FILES)) {
+ array_walk($_FILES, 'serendipity_strip_quotes');
+ }
+}
+
+// Merge get and post into the serendipity array
+$serendipity['GET'] = &$_GET['serendipity'];
+$serendipity['POST'] = &$_POST['serendipity'];
+$serendipity['COOKIE'] = &$_COOKIE['serendipity'];
+
+
+/*
+ * Some defaults for our config vars.
+ * They are likely to be overwritten later in the code
+ */
+$serendipity['templatePath'] = 'templates/';
+$serendipity['serendipityPath'] = './';
+$serendipity['indexFile'] = 'index.php';
+$serendipity['allowDateManipulation'] = true;
+
/* vim: set sts=4 ts=4 expandtab : */
?>
Index: serendipity_admin.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_admin.php,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- serendipity_admin.php 18 Sep 2003 12:58:00 -0000 1.19
+++ serendipity_admin.php 30 Sep 2003 21:21:59 -0000 1.20
@@ -1,15 +1,7 @@
<?php # $Id$
-
-ini_set('session.use_trans_sid', 1);
-session_start();
-if (file_exists('./serendipity_config_local.inc.php')) {
+ session_start();
+ define('IN_installer', true);
include('serendipity_config.inc.php');
-} else {
- // If no config file is loaded, language includes are not available.
- // Now include one. Try to auto-guess the language by looking up the HTTP_ACCEPT_LANGUAGE.
- include_once 'serendipity_lang.inc.php';
- $_SESSION['serendipityAuthedUser'] = true;
-}
?>
<html>
<head>
@@ -39,12 +31,11 @@
<table id="mainpane">
<tr id="content" valign="top">
<?php
-if (!isset($serendipity['serendipityPath']) || !file_exists($serendipity['serendipityPath'] . 'serendipity_config_local.inc.php') ) {
- // User just installed serendipity, let him go to configure mode
+if (!isset($serendipity['serendipityPath']) || IS_installed === false ) {
?>
<td class="serendipity_admin">
<div class="serendipity_date"><?php echo SERENDIPITY_INSTALLATION; ?></div>
- <p><?php include('serendipity_admin_installer.inc.php'); ?>
+ <p><?php require_once('serendipity_admin_installer.inc.php'); ?>
<?php
} elseif ( !serendipity_userLoggedIn() ) {
serendipity_printLogin();
Index: serendipity_admin_installer.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_admin_installer.inc.php,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- serendipity_admin_installer.inc.php 20 Sep 2003 03:43:56 -0000 1.42
+++ serendipity_admin_installer.inc.php 30 Sep 2003 21:21:59 -0000 1.43
@@ -2,28 +2,27 @@
umask(0000);
$umask = 0770;
-include_once('compat.php');
-
+define('IN_installer', true);
+include_once('serendipity_config.inc.php');
function serendipity_query_default($optname, $default)
{
switch ($optname) {
case 'serendipityPath':
- return dirname(__FILE__) . '/';
+ return dirname(__FILE__) .'/';
case 'serendipityHTTPPath':
- return dirname($_SERVER['PHP_SELF']) . '/';
+ return rtrim(dirname($_SERVER['PHP_SELF']), '/') .'/';
case 'baseURL':
$ssl = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on';
$port = $_SERVER['SERVER_PORT'];
- return sprintf(
- 'http%s://%s%s%s/',
-
- $ssl ? 's' : '',
- $_SERVER['HTTP_HOST'],
- (($ssl && $port != 443) || (!$ssl && $port != 80)) ? (':' . $port) : '',
- dirname($_SERVER['PHP_SELF'])
+ return sprintf('http%s://%s%s%s',
+
+ $ssl ? 's' : '',
+ $_SERVER['HTTP_HOST'],
+ (($ssl && $port != 443) || (!$ssl && $port != 80)) ? (':' . $port) : '',
+ rtrim(dirname($_SERVER['PHP_SELF']), '/') .'/'
);
case 'convert':
@@ -119,7 +118,7 @@
}
function serendipity_printConfigTemplate($t, $from = false) {
- global $serendipity, $installed;
+ global $serendipity;
?>
<script type="text/javascript" language="JavaScript">
function showConfig(id) {
@@ -175,7 +174,7 @@
<tr>
<td>
- <table width="100%" cellspacing="0" cellpadding="3" style="<?php echo ($installed ? 'display: none;' : ''); ?>" id="el<?php echo $el_count; ?>">
+ <table width="100%" cellspacing="0" cellpadding="3" style="<?php echo (IS_installed === true ? 'display: none;' : ''); ?>" id="el<?php echo $el_count; ?>">
<tr>
<td style="padding-left: 20px;" colspan="2">
<?php echo $t['descriptions'][$key] ?>
@@ -278,13 +277,11 @@
}
$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)
- serendipity_db_probe($_POST, $errs);
-
+ // (do it after the dir stuff, as we need to be able to create the sqlite database)
+ if ( @include_once($_POST['serendipityPath'] . '/serendipity_db.inc.php') ) {
+ serendipity_db_probe($_POST, $errs);
+ }
return $errs;
}
@@ -398,12 +395,13 @@
}
fwrite($configfp, "<?php\n");
- fwrite($configfp, "\t\$serendipity['dbName'] = '{$_POST['dbName']}';\n");
- fwrite($configfp, "\t\$serendipity['dbPrefix'] = '{$_POST['dbPrefix']}';\n");
- fwrite($configfp, "\t\$serendipity['dbHost'] = '{$_POST['dbHost']}';\n");
- fwrite($configfp, "\t\$serendipity['dbUser'] = '{$_POST['dbUser']}';\n");
- fwrite($configfp, "\t\$serendipity['dbPass'] = '{$_POST['dbPass']}';\n");
- fwrite($configfp, "\t\$serendipity['dbType'] = '{$_POST['dbType']}';\n");
+ fwrite($configfp, "\t\$serendipity['versionInstalled'] = '{$serendipity['version']}';\n\n");
+ fwrite($configfp, "\t\$serendipity['dbName'] = '{$_POST['dbName']}';\n");
+ fwrite($configfp, "\t\$serendipity['dbPrefix'] = '{$_POST['dbPrefix']}';\n");
+ fwrite($configfp, "\t\$serendipity['dbHost'] = '{$_POST['dbHost']}';\n");
+ fwrite($configfp, "\t\$serendipity['dbUser'] = '{$_POST['dbUser']}';\n");
+ fwrite($configfp, "\t\$serendipity['dbPass'] = '{$_POST['dbPass']}';\n");
+ fwrite($configfp, "\t\$serendipity['dbType'] = '{$_POST['dbType']}';\n");
fwrite($configfp, "?>\n");
fclose($configfp);
Index: serendipity_config.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_config.inc.php,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- serendipity_config.inc.php 18 Sep 2003 12:58:14 -0000 1.33
+++ serendipity_config.inc.php 30 Sep 2003 21:22:00 -0000 1.34
@@ -1,33 +1,37 @@
<?php # $Id$
-define('IN_serendipity', true);
+define('IS_installed', file_exists((isset($serendipity['serendipityPath']) ? $serendipity['serendipityPath'] : '') . 'serendipity_config_local.inc.php'));
+
+if ( IS_installed === true ) {
+ define('IN_serendipity', true);
+}
+
include_once('compat.php');
ini_set('session.use_trans_sid', 0);
$serendipity['version'] = '0.3';
$serendipity['production'] = 1;
$serendipity['rewrite'] = true;
-$installed = file_exists((isset($serendipity['serendipityPath']) ? $serendipity['serendipityPath'] : '') . 'serendipity_config_local.inc.php');
-
-/* Load main language file */
+/*
+ * Load main language file
+ */
include('serendipity_lang.inc.php');
-
-// We need this if people want to upgrade s9y
-if (!isset($serendipity['templatePath'])) {
- $serendipity['templatePath'] = 'templates/';
-}
-
-if (!isset($serendipity['serendipityPath'])) {
- $serendipity['serendipityPath'] = './';
-}
-
-if (!$installed) {
+/*
+ * Kill the script if we are not installed, and not inside the installer
+ */
+if ( !defined('IN_installer') && IS_installed === false ) {
die(sprintf(SERENDIPITY_NOT_INSTALLED, 'serendipity_admin.php'));
}
+if ( defined('IN_installer') && IS_installed === false) {
+ return 1;
+}
-// Load DB configuration information
+/*
+ * Load DB configuration information
+ * Load Functions
+ */
include_once("{$serendipity['serendipityPath']}serendipity_config_local.inc.php");
include_once("{$serendipity['serendipityPath']}serendipity_functions.inc.php");
@@ -35,45 +39,43 @@
die(sprintf(INCLUDE_ERROR, 'serendipity_functions.inc.php'));
}
-// Connect to database
+/*
+ * Attempt to connect to the database
+ */
if (!serendipity_db_connect()) {
die(DATABASE_ERROR);
}
-$translation = array(
- 'true' => true,
- 'false' => false
- );
+$translation = array('true' => true,
+ 'false' => false);
-// Load Configuration options from the database
+/*
+ * Load Configuration options from the database
+ */
$rows = serendipity_db_query("SELECT name,value
FROM {$serendipity['dbPrefix']}config");
foreach ($rows as $row) {
/* fixme: temp. workaround */
$serendipity['CONFIG'][$row['name']] = $row['value'];
- /* Convert 'true' and 'false' in to booleans */
+ /*
+ * Convert 'true' and 'false' into booleans
+ */
if ( isset($translation[$row['value']]) ) {
$row['value'] = $translation[$row['value']];
}
$serendipity[$row['name']] = $row['value'];
}
-
-/* Load main language file again, because now we have the preferred language */
+/*
+ * Load main language file again, because now we have the preferred language
+ */
include($serendipity['serendipityPath'] .'serendipity_lang.inc.php');
if ($serendipity['embed']) {
$serendipity['baseURL'] = 'http://' . $_SERVER['HTTP_HOST'] . $serendipity['serendipityHTTPPath'];
}
-// defaults for newly added configuration directives. Should be removed after first release.
-if (!isset($serendipity['indexFile'])) {
- $serendipity['indexFile'] = 'index.php';
-}
-
-$serendipity['allowDateManipulation'] = TRUE;
-
// A Set of emoticons to rewrite
$serendipity['smiles'] = array( ":'(" => $serendipity['serendipityHTTPPath'] . 'pixel/cry_smile.gif',
':-)' => $serendipity['serendipityHTTPPath'] . 'pixel/regular_smile.gif',
@@ -91,54 +93,6 @@
';)' => $serendipity['serendipityHTTPPath'] . 'pixel/wink_smile.gif',
':P' => $serendipity['serendipityHTTPPath'] . 'pixel/tounge_smile.gif',
);
-
-
-// Avoid magic_quotes_gpc issues
-// courtesy of il...@ph...
-function serendipity_strip_quotes(&$var)
-{
- if (is_array($var)) {
- foreach ($var as $k => $v) {
- if (is_array($v)) {
- array_walk($var[$k], 'serendipity_strip_quotes');
- } else {
- $var[$k] = stripslashes($v);
- }
- }
- } else {
- $var = stripslashes($var);
- }
-}
-
-if (ini_get('magic_quotes_gpc')) {
- if (@count($_GET)) {
- array_walk($_GET, 'serendipity_strip_quotes');
- }
-
- if (@count($_POST)) {
- array_walk($_POST, 'serendipity_strip_quotes');
- }
-
- if (@count($_COOKIES)) {
- array_walk($_COOKIES, 'serendipity_strip_quotes');
- }
-
- if (@count($_FILES)) {
- array_walk($_FILES, 'serendipity_strip_quotes');
- }
-}
-
-// Merge get and post into the serendipity array
-$serendipity['GET'] = &$_GET['serendipity'];
-$serendipity['POST'] = &$_POST['serendipity'];
-$serendipity['COOKIE'] = &$_COOKIE['serendipity'];
-
-// We want our config vars cached... will save us lots of SQL queries
-$sql = "SELECT * FROM {$serendipity['dbPrefix']}config";
-$rs = serendipity_db_query($sql);
-foreach ($rs as $var) {
- $serendipity['CONFIG'][$var['name']] = $var['value'];
-}
// We don't care who tells us what to do
if (!isset($serendipity['GET']['action'])) {
Index: serendipity_db.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_db.inc.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- serendipity_db.inc.php 21 Jul 2003 02:34:36 -0000 1.6
+++ serendipity_db.inc.php 30 Sep 2003 21:22:00 -0000 1.7
@@ -1,6 +1,6 @@
<?php # $Id$
-include_once("./serendipity_db_{$serendipity['dbType']}.inc.php");
+@include_once($serendipity['serendipityHTTPPath'] ."serendipity_db_{$serendipity['dbType']}.inc.php");
function serendipity_db_update($table, $keys, $values)
{
Index: serendipity_lang.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_lang.inc.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- serendipity_lang.inc.php 18 Sep 2003 12:58:26 -0000 1.5
+++ serendipity_lang.inc.php 30 Sep 2003 21:22:00 -0000 1.6
@@ -1,14 +1,13 @@
<?php # $Id$
if (!defined('serendipity_LANG_LOADED') || serendipity_LANG_LOADED !== true) {
- // Try and include preferred language from configurated setting
+ // Try and include preferred language from the configurated setting
if ( @include('serendipity_lang_'. $serendipity['lang'] .'.inc.php') ) {
// Only here can we truely say the language is loaded
define('serendipity_LANG_LOADED', true);
- } elseif (!isset($installed) || !$installed) { /* -- Auto-Guess -- */
-
+ } elseif ( IS_installed === false ) { /* -- Auto-Guess -- */
// If no config file is loaded, language includes are not available.
// Now include one. Try to auto-guess the language by looking up the HTTP_ACCEPT_LANGUAGE.
$supported_languages = array('en', 'de');
@@ -26,7 +25,7 @@
// Do fallback to english
- if ( defined('serendipity_LANG_LOADED') && serendipity_LANG_LOADED === true || !isset($installed)) {
+ if ( (defined('serendipity_LANG_LOADED') && serendipity_LANG_LOADED === true) || IS_installed === false) {
include_once('serendipity_lang_en.inc.php');
}
}
|