Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31998
Modified Files:
NEWS README compat.php index.php rss.php serendipity.css.php
serendipity_admin.php serendipity_admin_entries.inc.php
serendipity_admin_images.inc.php
serendipity_admin_installer.inc.php
serendipity_admin_interop.inc.php
serendipity_admin_plugins.inc.php
serendipity_admin_upgrader.inc.php serendipity_config.inc.php
serendipity_db.inc.php serendipity_entries.php
serendipity_functions.inc.php
serendipity_functions_images.inc.php
serendipity_functions_installer.inc.php
serendipity_genpage.inc.php serendipity_lang.inc.php
serendipity_layout.inc.php serendipity_layout_table.inc.php
serendipity_plugin_api.php
Log Message:
s9y as shared library.
plus some small bugfixes/code guideline issues which were too hard to seperate from this commit
Index: serendipity_admin_installer.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_admin_installer.inc.php,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- serendipity_admin_installer.inc.php 21 Mar 2004 16:26:56 -0000 1.58
+++ serendipity_admin_installer.inc.php 21 Mar 2004 16:35:31 -0000 1.59
@@ -1,16 +1,17 @@
<?php # $Id$
umask(0000);
-$umask = 0770;
-define('IN_installer', true);
+$umask = 0775;
+@define('IN_installer', true);
-require_once('serendipity_config.inc.php');
-require_once('serendipity_functions_installer.inc.php');
+require_once($serendipity['serendipityPath'] . 'serendipity_config.inc.php');
+require_once(S9Y_INCLUDE_PATH . 'serendipity_functions_installer.inc.php');
+define('S9Y_CONFIG_TEMPLATE', S9Y_INCLUDE_PATH . 'serendipity_config_local.tpl');
function serendipity_query_default($optname, $default) {
switch ($optname) {
case 'serendipityPath':
- return dirname(__FILE__) .'/';
+ return $_SERVER['DOCUMENT_ROOT'] . rtrim(dirname($_SERVER['PHP_SELF']), '/') . '/';
case 'serendipityHTTPPath':
return rtrim(dirname($_SERVER['PHP_SELF']), '/') .'/';
@@ -22,7 +23,7 @@
return sprintf('http%s://%s%s%s',
$ssl ? 's' : '',
- $_SERVER['HTTP_HOST'],
+ preg_replace('@^([^:]+):?.*$@', '\1', $_SERVER['HTTP_HOST']),
(($ssl && $port != 443) || (!$ssl && $port != 80)) ? (':' . $port) : '',
rtrim(dirname($_SERVER['PHP_SELF']), '/') .'/'
);
@@ -40,7 +41,7 @@
$path[] = '/usr/bin';
foreach ($path as $dir) {
- if (function_exists('is_executable') && is_executable($dir . '/convert') || is_file($dir . '/convert')) {
+ if (function_exists('is_executable') && @is_executable($dir . '/convert') || @is_file($dir . '/convert')) {
return $dir . '/convert';
}
}
@@ -55,7 +56,7 @@
global $serendipity;
$config = array();
- $t = file($n);
+ $t = file($n, 1);
for ($x=0; $x<count($t); $x++) {
$l = $t[$x];
$l = trim($l);
@@ -140,6 +141,10 @@
function serendipity_printConfigTemplate($t, $from = false) {
global $serendipity;
+ if (!isset($serendipity['XHTML11'])) {
+ $serendipity['XHTML11'] = FALSE;
+ }
+
// If not yet installed, do some magic:
$abort = false;
if (IS_installed !== true) {
@@ -157,13 +162,16 @@
fclose($fp);
// Do a request on a nonexistant file to see, if our htaccess allows ErrorDocument
- $sock = fsockopen($_SERVER['HTTP_HOST'], $_SERVER['SERVER_PORT'], $errorno, $errorstring, 10);
- fputs($sock, "GET {$_SERVER['REQUEST_URI']}nonexistant HTTP/1.0\n\n");
+ $sock = fsockopen(preg_replace('@^([^:]+):?.*$@', '\1', $_SERVER['HTTP_HOST']), $_SERVER['SERVER_PORT'], $errorno, $errorstring, 10);
$response = '';
- while (!feof($sock) && strlen($response) < 4096) {
- $response .= fgets($sock, 400);
+
+ if ($sock) {
+ fputs($sock, "GET {$_SERVER['REQUEST_URI']}nonexistant HTTP/1.0\n\n");
+ while (!feof($sock) && strlen($response) < 4096) {
+ $response .= fgets($sock, 400);
+ }
+ fclose($sock);
}
- fclose($sock);
if (preg_match('@^HTTP/\d\.\d 200@', $response)) {
$serendipity['rewrite_default'] = 'errordocs';
@@ -171,7 +179,7 @@
$serendipity['rewrite_default'] = 'none';
}
- if ($old_htacces != '') {
+ if (!empty($old_htacces)) {
$fp = @fopen('./.htaccess', 'w');
fwrite($fp, $old_htaccess);
fclose($fp);
@@ -288,51 +296,55 @@
$in_table = 0;
$queries = array();
- $fp = fopen($filename, 'r');
- while (!@feof($fp)) {
- $line = trim(fgets($fp, 4096));
- if ($in_table) {
- $def .= $line;
- if (preg_match('/^\)\s*(type\=\S+)?\s*\;$/i', $line)) {
- $in_table = 0;
- array_push($queries, $def);
- }
- } else {
- if (preg_match('#^create table \{PREFIX\}\S+\s*\(#i', $line)) {
- $in_table = 1;
- $def = $line;
- }
-
- if (preg_match('#^create\s*(\{fulltext\}|unique)\s*index#i', $line)) {
- array_push($queries, $line);
+ $fp = fopen($filename, 'r', 1);
+ if ($fp) {
+ while (!@feof($fp)) {
+ $line = trim(fgets($fp, 4096));
+ if ($in_table) {
+ $def .= $line;
+ if (preg_match('/^\)\s*(type\=\S+)?\s*\;$/i', $line)) {
+ $in_table = 0;
+ array_push($queries, $def);
+ }
+ } else {
+ if (preg_match('#^create table \{PREFIX\}\S+\s*\(#i', $line)) {
+ $in_table = 1;
+ $def = $line;
+ }
+
+ if (preg_match('#^create\s*(\{fulltext\}|unique)\s*index#i', $line)) {
+ array_push($queries, $line);
+ }
}
}
+ fclose($fp);
}
- fclose($fp);
-
+
return $queries;
}
function serendipity_checkInstallation() {
global $serendipity, $umask;
+ $errs = array();
+
// Check dirs
- if ( !is_dir($_POST['serendipityPath']) ) {
+ if (!is_dir($_POST['serendipityPath'])) {
$errs[] = sprintf(DIRECTORY_NON_EXISTANT, $_POST['serendipityPath']);
}
- elseif ( !is_writable($_POST['serendipityPath']) ) {
+ elseif (!is_writable($_POST['serendipityPath']) ) {
$errs[] = sprintf(DIRECTORY_WRITE_ERROR, $_POST['serendipityPath']);
}
- elseif ( !is_dir($_POST['serendipityPath'] . $_POST['uploadPath'] ) && @mkdir($_POST['serendipityPath'] . $_POST['uploadPath'], $umask) !== true) {
+ elseif (!is_dir($_POST['serendipityPath'] . $_POST['uploadPath'] ) && @mkdir($_POST['serendipityPath'] . $_POST['uploadPath'], $umask) !== true) {
$errs[] = sprintf(DIRECTORY_CREATE_ERROR, $_POST['serendipityPath'] . $_POST['uploadPath']);
}
- elseif ( !is_writable($_POST['serendipityPath'] . $_POST['uploadPath']) ) {
+ elseif (!is_writable($_POST['serendipityPath'] . $_POST['uploadPath'])) {
$errs[] = sprintf(DIRECTORY_WRITE_ERROR, $_POST['serendipityPath'] . $_POST['uploadPath']);
$errs[] = sprintf(DIRECTORY_RUN_CMD , 'chmod go+rws', $_POST['serendipityPath'] . $_POST['uploadPath']);
}
// Attempt to create the archives directory
- if ( !is_dir($_POST['serendipityPath'] . PATH_ARCHIVES) && @mkdir($_POST['serendipityPath'] . PATH_ARCHIVES, $umask) !== true ) {
+ if (!is_dir($_POST['serendipityPath'] . PATH_ARCHIVES) && @mkdir($_POST['serendipityPath'] . PATH_ARCHIVES, $umask) !== true) {
$errs[] = sprintf(DIRECTORY_CREATE_ERROR, $_POST['serendipityPath'] . PATH_ARCHIVES);
$errs[] = sprintf(DIRECTORY_RUN_CMD , 'mkdir' , $_POST['serendipityPath'] . PATH_ARCHIVES);
$errs[] = sprintf(DIRECTORY_RUN_CMD , 'chmod go+rwx', $_POST['serendipityPath'] . PATH_ARCHIVES);
@@ -341,17 +353,22 @@
// plugins directory now part of basic CVS
// Check imagick
- if ($_POST['magick'] == 'true' && !is_executable($_POST['convert'])) {
+ if ($_POST['magick'] == 'true' && !@is_executable($_POST['convert'])) {
$errs[] = sprintf(CANT_EXECUTE_BINARY, 'convert imagemagick');
}
$serendipity['dbType'] = $_POST['dbType'];
// Probe database
// (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') ) {
+ @include_once($_POST['serendipityPath'] . 'serendipity_db.inc.php');
+ // For shared installations, probe the file on include path
+ @include_once(S9Y_INCLUDE_PATH . 'serendipity_db.inc.php');
+
+ if (S9Y_DB_INCLUDED) {
serendipity_db_probe($_POST, $errs);
}
- return $errs;
+
+ return (count($errs) > 0 ? $errs : '');
}
function serendipity_installDatabase() {
@@ -362,20 +379,21 @@
echo CHECK_DATABASE_EXISTS;
$t = serendipity_db_query("SELECT * FROM {$_POST['dbPrefix']}authors");
echo ' ' . DONE . '<br />';
+
if (is_array($t)) {
return false;
}
echo CREATE_DATABASE;
// Create tables
- $queries = serendipity_parse_sql_tables('./sql/db.sql');
+ $queries = serendipity_parse_sql_tables($serendipity['serendipityPath'] . 'sql/db.sql');
$queries = str_replace('{PREFIX}', $_POST['dbPrefix'], $queries);
foreach ($queries as $query) {
serendipity_db_schema_import($query);
}
- if($_POST['want_mail'] == true) {
+ if ($_POST['want_mail'] == true) {
$mail_comments = 1;
} else {
$mail_comments = 0;
@@ -400,17 +418,19 @@
)";
serendipity_db_query($query);
- include_once $_POST['serendipityPath'] . '/serendipity_functions_config.inc.php';
+ include_once S9Y_INCLUDE_PATH . 'serendipity_functions_config.inc.php';
$serendipity['dbPrefix'] = $_POST['dbPrefix'];
serendipity_set_config_var('template', 'default');
- $text = serendipity_db_escape_string(file_get_contents('./serendipity.css'));
+ $text = serendipity_db_escape_string(file_get_contents(S9Y_INCLUDE_PATH . 'serendipity.css'));
$query = "INSERT into {$_POST['dbPrefix']}css (name, data) values ('default', '$text')";
return serendipity_db_query($query);
}
function serendipity_installFiles() {
+ global $serendipity;
+
$htaccess = @file_get_contents('./.htaccess');
if ($_POST['rewrite'] == 'rewrite') {
@@ -421,7 +441,7 @@
$template = 'htaccess.normal.tpl';
}
- if (!($a = file('./'. $template))) {
+ if (!($a = file($serendipity['serendipityPath'] . $template, 1))) {
$err[] = ERROR_TEMPLATE_FILE;
}
@@ -481,7 +501,7 @@
global $serendipity, $umask;
// Save all basic config variables to the database
- $p = serendipity_parseTemplate("./serendipity_config_local.tpl", true);
+ $p = serendipity_parseTemplate(S9Y_CONFIG_TEMPLATE, true);
foreach($p as $key => $entry) {
serendipity_set_config_var($entry['name'], $_POST[$entry['name']]);
@@ -510,7 +530,7 @@
if (is_array($res)) {
echo DIAGNOSTIC_ERROR . '<br /><br />';
echo '<span style="color: #FF0000">- ' . implode('<br />', $res) . '</span><br /><br />';
- serendipity_printConfigTemplate(serendipity_parseTemplate('./serendipity_config_local.tpl'), $_POST);
+ serendipity_printConfigTemplate(serendipity_parseTemplate(S9Y_CONFIG_TEMPLATE), $_POST);
die();
}
@@ -519,7 +539,8 @@
/* We are good to go, lets install databases etc. */
echo ATTEMPT_SETUP_DATABASE . "<br />";
$res = serendipity_installDatabase();
- if ( $res !== false ) {
+
+ if ($res !== false) {
echo ' ' . DATABASE_DONE . '<br />';
} else {
echo '<span style="color: #FF0000">- ' . DATABASE_ALREADY_INSTALLED . '</span><br />';
@@ -528,7 +549,7 @@
/* Next are the files, .htaccess */
printf(ATTEMPT_WRITE_FILE, '.htaccess');
$res = serendipity_installFiles();
- if ( is_array($res) ) {
+ if (is_array($res)) {
echo '<span style="color: #FF0000">- ' . implode('<br />', $res) . '</span><br /><br />';
die();
} else {
@@ -541,8 +562,12 @@
/* register default plugins */
$GLOBALS['serendipity']['dbPrefix'] = $_POST['dbPrefix'];
$GLOBALS['serendipity']['dbName'] = $_POST['dbName'];
+ $GLOBALS['serendipity']['serendipityHTTPPath'] = $_POST['serendipityHTTPPath'];
+ if (!isset($serendipity['lang'])) {
+ $serendipity['lang'] = 'en';
+ }
- include_once 'serendipity_plugin_api.php';
+ include_once S9Y_INCLUDE_PATH . 'serendipity_plugin_api.php';
serendipity_plugin_api::register_default_plugins();
printf(
@@ -564,15 +589,15 @@
}
$res = serendipity_updateConfiguration();
- if ( is_array($res) ) {
+ if (is_array($res)) {
echo DIAGNOSTIC_ERROR;
echo '<span style="color: #FF0000">- ' . implode('<br />', $res) . '</span><br /><br />';
} else {
/* If we have new rewrite rules, then install them */
- if ( $serendipity['rewrite'] != $_POST['rewrite'] ) {
+ if ($serendipity['rewrite'] != $_POST['rewrite']) {
printf(ATTEMPT_WRITE_FILE, '.htaccess');
$res = serendipity_installFiles();
- if ( is_array($res) ) {
+ if (is_array($res)) {
echo implode('<br />'. $res);
} else {
echo DONE .'<br />';
@@ -585,19 +610,19 @@
default:
/* Is serendipity already installed= */
- if ( file_exists('./serendipity_config_local.inc.php') ) {
+ if (file_exists('./serendipity_config_local.inc.php')) {
$from = &$serendipity;
} else {
define('VERSION_REQUIRED', '4.2.1');
/* Do check for required PHP version */
- if ( version_compare(PHP_VERSION, VERSION_REQUIRED) == -1 ) {
+ if (version_compare(PHP_VERSION, VERSION_REQUIRED) == -1) {
echo '<br /><font color="#FF0000">WARNING!<br />You are using PHP version '. PHP_VERSION .'! Serendipity requires version '. VERSION_REQUIRED .'</font>';
}
$from = false;
}
- serendipity_printConfigTemplate(serendipity_parseTemplate('./serendipity_config_local.tpl'), $from);
+ serendipity_printConfigTemplate(serendipity_parseTemplate(S9Y_CONFIG_TEMPLATE), $from);
}
/* vim: set sts=4 ts=4 expandtab : */
Index: serendipity_lang.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_lang.inc.php,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- serendipity_lang.inc.php 15 Mar 2004 10:12:47 -0000 1.9
+++ serendipity_lang.inc.php 21 Mar 2004 16:35:32 -0000 1.10
@@ -2,19 +2,19 @@
if (!defined('serendipity_LANG_LOADED') || serendipity_LANG_LOADED !== true) {
// Try and include preferred language from the configurated setting
- if ( @include($serendipity['serendipityPath'] .'lang/serendipity_lang_'. $serendipity['lang'] .'.inc.php') ) {
+ if (@include(S9Y_INCLUDE_PATH .'lang/serendipity_lang_'. $serendipity['lang'] .'.inc.php') ) {
// Only here can we truely say the language is loaded
define('serendipity_LANG_LOADED', true);
- } elseif ( IS_installed === false || IS_up2date === false ) { /* -- Auto-Guess -- */
+ } elseif (IS_installed === false || (defined('IS_up2date') && IS_up2date === 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', 'da', 'de', 'es');
- $possible_languages = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
+ $possible_languages = explode(',', (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : ''));
if (is_array($possible_languages)) {
foreach($possible_languages as $index => $lang) {
$preferred_language = preg_replace('@^([^\-_;]*)_?.*$@', '\1', $lang);
if (in_array($preferred_language, $supported_languages)) {
- @include_once($serendipity['serendipityPath'] . 'lang/serendipity_lang_' . $preferred_language . '.inc.php');
+ @include_once(S9Y_INCLUDE_PATH . 'lang/serendipity_lang_' . $preferred_language . '.inc.php');
break;
} // endif
} // endforeach
@@ -22,8 +22,8 @@
} //endif
// Do fallback to english
- if ( (defined('serendipity_LANG_LOADED') && serendipity_LANG_LOADED === true) || IS_installed === false || IS_up2date === false) {
- @include_once($serendipity['serendipityPath'] .'lang/serendipity_lang_en.inc.php');
+ if ((defined('serendipity_LANG_LOADED') && serendipity_LANG_LOADED === true) || IS_installed === false || (defined('IS_up2date') && IS_up2date === false)) {
+ @include_once(S9Y_INCLUDE_PATH .'lang/serendipity_lang_en.inc.php');
}
}
Index: serendipity_genpage.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_genpage.inc.php,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- serendipity_genpage.inc.php 29 Jan 2004 12:08:28 -0000 1.24
+++ serendipity_genpage.inc.php 21 Mar 2004 16:35:32 -0000 1.25
@@ -34,8 +34,8 @@
} // end if (is serendipity embedded?)
include_once('serendipity_config.inc.php');
-include_once('serendipity_plugin_api.php');
-include_once('serendipity_sidebar_items.php');
+include_once(S9Y_INCLUDE_PATH . 'serendipity_plugin_api.php');
+include_once(S9Y_INCLUDE_PATH . 'serendipity_sidebar_items.php');
if (file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] . serendipity_get_config_var('template', 'default') . '/layout.php')) {
include $serendipity['serendipityPath'] . $serendipity['templatePath'] . serendipity_get_config_var('template', 'default') . '/layout.php';
Index: serendipity_layout_table.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_layout_table.inc.php,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- serendipity_layout_table.inc.php 8 Jul 2003 09:13:27 -0000 1.9
+++ serendipity_layout_table.inc.php 21 Mar 2004 16:35:32 -0000 1.10
@@ -8,9 +8,9 @@
# http://www.jannis.to/programming/serendipity.html #
# #
##########################################################################
-include_once("serendipity_config.inc.php");
-include_once("serendipity_plugin_api.php");
-include_once("serendipity_sidebar_items.php");
+include_once('serendipity_config.inc.php");
+include_once(S9Y_INCLUDE_PATH . 'serendipity_plugin_api.php');
+include_once(S9Y_INCLUDE_PATH . 'serendipity_sidebar_items.php');
?>
<div id="serendipity_banner">
Index: rss.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/rss.php,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- rss.php 18 Mar 2004 14:45:20 -0000 1.21
+++ rss.php 21 Mar 2004 16:35:31 -0000 1.22
@@ -79,7 +79,7 @@
$title = utf8_encode($title);
$description = utf8_encode($description);
-include_once('serendipity_plugin_api.php');
+include_once(S9Y_INCLUDE_PATH . 'serendipity_plugin_api.php');
$plugins = serendipity_plugin_api::enum_plugins();
if (is_array($plugins)) {
Index: serendipity_config.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_config.inc.php,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- serendipity_config.inc.php 21 Mar 2004 16:26:56 -0000 1.58
+++ serendipity_config.inc.php 21 Mar 2004 16:35:32 -0000 1.59
@@ -2,13 +2,17 @@
# Copyright (c) 2003-2004, Jannis Hermanns
# All rights reserved. See LICENSE file for licensing details
+if (!defined('S9Y_INCLUDE_PATH')) {
+ define('S9Y_INCLUDE_PATH', dirname(__FILE__) . '/');
+}
+
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');
+include_once(S9Y_INCLUDE_PATH . 'compat.php');
ini_set('session.use_trans_sid', 0);
$serendipity['version'] = '0.6-CVS';
@@ -16,7 +20,7 @@
$serendipity['rewrite'] = 'none';
$serendipity['messagestack'] = array();
-if ( $serendipity['production'] == 1 ) {
+if ($serendipity['production'] == 1) {
error_reporting(E_ALL & ~E_NOTICE);
} else {
error_reporting(E_ALL);
@@ -32,7 +36,7 @@
/*
* Load main language file
*/
-include('serendipity_lang.inc.php');
+include($serendipity['serendipityPath'] . 'serendipity_lang.inc.php');
/* URI paths
* These could be defined in the language headers, except that would break
@@ -74,13 +78,15 @@
/*
* Load DB configuration information
* Load Functions
+ * Make sure that the file included is in the current directory and not any possible
+ * include path
*/
-include_once("{$serendipity['serendipityPath']}serendipity_config_local.inc.php");
+include_once($_SERVER['DOCUMENT_ROOT'] . dirname($_SERVER['PHP_SELF']) . '/serendipity_config_local.inc.php');
/*
* Include main functions
*/
-include_once("{$serendipity['serendipityPath']}serendipity_functions.inc.php");
+include_once(S9Y_INCLUDE_PATH . 'serendipity_functions.inc.php');
if (serendipity_FUNCTIONS_LOADED!== true) {
die(sprintf(INCLUDE_ERROR, 'serendipity_functions.inc.php'));
@@ -114,7 +120,7 @@
/*
* Load main language file again, because now we have the preferred language
*/
-include($serendipity['serendipityPath'] .'serendipity_lang.inc.php');
+include(S9Y_INCLUDE_PATH .'serendipity_lang.inc.php');
/*
* Set current locale, if any has been defined
@@ -163,7 +169,7 @@
}
$old_include = @ini_get('include_path');
-@ini_set('include_path', $serendipity['serendipityPath'] . 'bundled-libs/:' . $old_include);
+@ini_set('include_path', $serendipity['serendipityPath'] . ':' . $serendipity['serendipityPath'] . 'bundled-libs/:' . $old_include);
$serendipity['user'] = isset($_SESSION['serendipityUser']) ? $_SESSION['serendipityUser'] : '';
$serendipity['email'] = isset($_SESSION['serendipityEmail']) ? $_SESSION['serendipityEmail'] : '';
Index: serendipity_admin_plugins.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_admin_plugins.inc.php,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- serendipity_admin_plugins.inc.php 19 Mar 2004 10:18:39 -0000 1.19
+++ serendipity_admin_plugins.inc.php 21 Mar 2004 16:35:31 -0000 1.20
@@ -5,8 +5,8 @@
}
session_start();
-include_once 'serendipity_plugin_api.php';
-include_once 'serendipity_sidebar_items.php';
+include_once S9Y_INCLUDE_PATH . 'serendipity_plugin_api.php';
+include_once S9Y_INCLUDE_PATH . 'serendipity_sidebar_items.php';
function show_plugins($event_only = false)
{
Index: serendipity_db.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_db.inc.php,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- serendipity_db.inc.php 2 Feb 2004 10:19:08 -0000 1.9
+++ serendipity_db.inc.php 21 Mar 2004 16:35:32 -0000 1.10
@@ -1,8 +1,9 @@
<?php # $Id$
# Copyright (c) 2003-2004, Jannis Hermanns
# All rights reserved. See LICENSE file for licensing details
+@define('S9Y_DB_INCLUDED', TRUE);
-include_once("serendipity_db_{$serendipity['dbType']}.inc.php");
+include_once(S9Y_INCLUDE_PATH . "serendipity_db_{$serendipity['dbType']}.inc.php");
function serendipity_db_update($table, $keys, $values)
{
Index: serendipity_plugin_api.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_plugin_api.php,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- serendipity_plugin_api.php 3 Mar 2004 08:17:59 -0000 1.13
+++ serendipity_plugin_api.php 21 Mar 2004 16:35:32 -0000 1.14
@@ -4,7 +4,7 @@
die ('Don\'t hack!');
}
-include_once 'serendipity_functions.inc.php';
+include_once S9Y_INCLUDE_PATH . 'serendipity_functions.inc.php';
/* This file defines the plugin API for serendipity.
* By extending these classes, you can add your own code
@@ -136,32 +136,66 @@
}
}
- /* third-party classes next */
- $ppath = (isset($serendipity['serendipityPath']) ? $serendipity['serendipityPath'] : '') . 'plugins';
+ /* GLOBAL third-party classes next */
+ $ppath = dirname(__FILE__) . '/plugins';
$d = opendir($ppath);
- while (($f = readdir($d)) !== false) {
- if ($f{0} == '.' || $f == 'CVS') {
- continue;
- }
-
- if ($event_only && strncmp($f, 'serendipity_event_', 18) != 0) {
- continue;
- }
-
- if (!$event_only && strncmp($f, 'serendipity_event_', 18) == 0) {
- continue;
- }
-
- $existing = array_search('@' . $f, $classes);
- if ($existing !== null && $existing !== false) {
- // If an external plugin/event already exists as internal, remove the internal reference because its redundant
- unset($classes[$existing]);
+ if ($d) {
+ while (($f = readdir($d)) !== false) {
+ if ($f{0} == '.' || $f == 'CVS') {
+ continue;
+ }
+
+ if ($event_only && strncmp($f, 'serendipity_event_', 18) != 0) {
+ continue;
+ }
+
+ if (!$event_only && strncmp($f, 'serendipity_event_', 18) == 0) {
+ continue;
+ }
+
+ $existing = array_search('@' . $f, $classes);
+ if ($existing !== null && $existing !== false) {
+ // If an external plugin/event already exists as internal, remove the internal reference because its redundant
+ unset($classes[$existing]);
+ }
+
+ if (file_exists($ppath . '/' . $f . '/' . $f . '.php')) {
+ $classes[] = $f;
+ }
}
-
- if (file_exists($ppath . '/' . $f . '/' . $f . '.php')) {
- $classes[] = $f;
+ }
+
+ /* LOCAL third-party classes next */
+ $local_ppath = $serendipity['serendipityPath'] . 'plugins';
+ if ($ppath != $local_ppath) {
+ $d = @opendir($local_ppath);
+ if ($d) {
+ while (($f = readdir($d)) !== false) {
+ if ($f{0} == '.' || $f == 'CVS') {
+ continue;
+ }
+
+ if ($event_only && strncmp($f, 'serendipity_event_', 18) != 0) {
+ continue;
+ }
+
+ if (!$event_only && strncmp($f, 'serendipity_event_', 18) == 0) {
+ continue;
+ }
+
+ $existing = array_search('@' . $f, $classes);
+ if ($existing !== null && $existing !== false) {
+ // If an external plugin/event already exists as internal, remove the internal reference because its redundant
+ unset($classes[$existing]);
+ }
+
+ if (file_exists($local_ppath . '/' . $f . '/' . $f . '.php')) {
+ $classes[] = $f;
+ }
+ }
}
}
+
return $classes;
}
@@ -190,15 +224,20 @@
{
global $serendipity;
- list($name, $uniq) = explode(':', $instance_id);
+ $instance = explode(':', $instance_id);
+ $name = $instance[0];
if ($name{0} == '@') {
$class_name = substr($name, 1);
} else {
/* plugin from the plugins/ dir */
if (!class_exists($name)) {
-
- include $serendipity['serendipityPath'] . 'plugins/' . $name . '/' . $name . '.php';
+ // First try the local path, and then (if existing) a shared library repository ...
+ if (file_exists($serendipity['serendipityPath'] . 'plugins/' . $name . '/' . $name . '.php')) {
+ include $serendipity['serendipityPath'] . 'plugins/' . $name . '/' . $name . '.php';
+ } elseif (file_exists(S9Y_INCLUDE_PATH . 'plugins/' . $name . '/' . $name . '.php')) {
+ include S9Y_INCLUDE_PATH . 'plugins/' . $name . '/' . $name . '.php';
+ }
if (!class_exists($name)) {
return false;
@@ -264,7 +303,7 @@
// Generate plugin output. Make sure that by probing the plugin, no events are actually called. After that,
// restore setting of 'no_events'.
- $ne = ($serendipity['no_events'] ? TRUE : FALSE);
+ $ne = (isset($serendipity['no_events']) && $serendipity['no_events'] ? TRUE : FALSE);
$serendipity['no_events'] = TRUE;
ob_start();
$plugin->generate_content($title);
@@ -285,7 +324,7 @@
function &get_event_plugins($instance = false) {
global $serendipity;
- if (!is_array($serendipity['event_plugins'])) {
+ if (!isset($serendipity['event_plugins']) || !is_array($serendipity['event_plugins'])) {
$plugins = serendipity_plugin_api::enum_plugins('event');
$serendipity['event_plugins'] = array();
@@ -319,7 +358,7 @@
// Can be bypassed globally
// $serendipity['no_events'] = TRUE;
- if (!$serendipity['no_events']) {
+ if (!isset($serendipity['no_events']) || !$serendipity['no_events']) {
$plugins = &serendipity_plugin_api::get_event_plugins();
if (is_array($plugins)) {
@@ -483,7 +522,7 @@
{
global $serendipity;
- if (is_array($this->dependencies)) {
+ if (isset($this->dependencies) && is_array($this->dependencies)) {
if ($remove) {
$dependencies = @explode(';', $this->get_config('dependencies'));
@@ -549,7 +588,7 @@
}
}
-include_once 'serendipity_sidebar_items.php';
+include_once S9Y_INCLUDE_PATH . 'serendipity_sidebar_items.php';
/* vim: set sts=4 ts=4 expandtab : */
?>
Index: NEWS
===================================================================
RCS file: /cvsroot/php-blog/serendipity/NEWS,v
retrieving revision 1.91
retrieving revision 1.92
diff -u -d -r1.91 -r1.92
--- NEWS 21 Mar 2004 16:26:56 -0000 1.91
+++ NEWS 21 Mar 2004 16:35:31 -0000 1.92
@@ -3,6 +3,15 @@
Version 0.6 ()
------------------------------------------------------------------------
+ * Serendipity can now be used in shared environments and act as a
+ library for VirtualHost'ed Blogs. See README. (garvinhicking)
+
+ * Fixed installer on hosts with non-standard (80) HTTP ports
+ (garvinhicking)
+
+ * Relaxed umask/chmod file and directory creation
+ (garvinhicking)
+
* Abstract archives/URL locations and regex-patterns in a central
place for easier maintenance (zem)
Index: serendipity_admin.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_admin.php,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- serendipity_admin.php 21 Mar 2004 16:26:56 -0000 1.33
+++ serendipity_admin.php 21 Mar 2004 16:35:31 -0000 1.34
@@ -5,10 +5,10 @@
define('IN_upgrader', true);
include('serendipity_config.inc.php');
-if ($serendipity['GET']['adminModule'] == 'logout'){
+if (isset($serendipity['GET']['adminModule']) && $serendipity['GET']['adminModule'] == 'logout'){
serendipity_logout();
} else {
- if ( IS_installed === true ) {
+ if (IS_installed === true) {
serendipity_login();
}
}
@@ -42,7 +42,7 @@
<tr valign="top">
<?php
if (!isset($serendipity['serendipityPath']) || IS_installed === false || IS_up2date === false ) {
- if ( IS_installed === false ) {
+ if (IS_installed === false) {
$file = 'serendipity_admin_installer.inc.php';
} elseif ( IS_up2date === false ) {
$file = 'serendipity_admin_upgrader.inc.php';
@@ -54,7 +54,7 @@
?>
<td class="serendipity_admin">
<div class="serendipity_date"><?php echo SERENDIPITY_INSTALLATION; ?></div>
- <p><?php require_once($file); ?>
+ <p><?php require_once(S9Y_INCLUDE_PATH . $file); ?>
<?php
} elseif ( !serendipity_userLoggedIn() ) {
serendipity_printLogin();
@@ -95,23 +95,23 @@
switch($serendipity['GET']['adminModule']) {
case 'installer':
- include './serendipity_admin_installer.inc.php';
+ include S9Y_INCLUDE_PATH . 'serendipity_admin_installer.inc.php';
break;
case 'images':
- include 'serendipity_admin_images.inc.php';
+ include S9Y_INCLUDE_PATH . 'serendipity_admin_images.inc.php';
break;
case 'templates':
- include 'serendipity_admin_templates.inc.php';
+ include S9Y_INCLUDE_PATH . 'serendipity_admin_templates.inc.php';
break;
case 'plugins':
- include 'serendipity_admin_plugins.inc.php';
+ include S9Y_INCLUDE_PATH . 'serendipity_admin_plugins.inc.php';
break;
case 'interop':
- include 'serendipity_admin_interop.inc.php';
+ include S9Y_INCLUDE_PATH . 'serendipity_admin_interop.inc.php';
break;
case 'logout':
@@ -119,7 +119,7 @@
break;
default:
- include 'serendipity_admin_overview.inc.php';
+ include S9Y_INCLUDE_PATH . 'serendipity_admin_overview.inc.php';
}
}
?>
Index: serendipity_entries.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_entries.php,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- serendipity_entries.php 3 Mar 2004 09:07:00 -0000 1.24
+++ serendipity_entries.php 21 Mar 2004 16:35:32 -0000 1.25
@@ -9,7 +9,8 @@
} else {
$_SESSION['serendipityAuthedUser'] = true;
}
-if ($serendipity['GET']['adminModule'] == 'logout'){
+
+if (isset($serendipity['GET']['adminModule']) && $serendipity['GET']['adminModule'] == 'logout'){
serendipity_logout();
} else {
serendipity_login();
@@ -95,15 +96,15 @@
switch($serendipity['GET']['adminModule']) {
case 'entries':
- include 'serendipity_admin_entries.inc.php';
+ include S9Y_INCLUDE_PATH . 'serendipity_admin_entries.inc.php';
break;
case 'images':
- include 'serendipity_admin_images.inc.php';
+ include S9Y_INCLUDE_PATH . 'serendipity_admin_images.inc.php';
break;
case 'category':
- include 'serendipity_admin_category.inc.php';
+ include S9Y_INCLUDE_PATH . 'serendipity_admin_category.inc.php';
break;
case 'logout':
@@ -111,7 +112,7 @@
break;
default:
- include 'serendipity_entries_overview.inc.php';
+ include S9Y_INCLUDE_PATH . 'serendipity_entries_overview.inc.php';
}
}
?>
Index: serendipity_admin_entries.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_admin_entries.inc.php,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- serendipity_admin_entries.inc.php 18 Feb 2004 11:48:23 -0000 1.18
+++ serendipity_admin_entries.inc.php 21 Mar 2004 16:35:31 -0000 1.19
@@ -18,7 +18,7 @@
global $serendipity;
// Prepare variables
- if (!is_numeric($serendipity['GET']['offset'])) {
+ if (empty($serendipity['GET']['offset']) || !is_numeric($serendipity['GET']['offset'])) {
$serendipity['GET']['offset'] = 0;
}
@@ -179,9 +179,9 @@
} else {
// Only display the preview
if (!is_numeric($entry['timestamp'])) $entry['timestamp'] = time();
- if (!$entry['trackbacks']) $entry['trackbacks'] = 0;
- if (!$entry['comments']) $entry['comments'] = 0;
- if (!$entry['username']) $entry['username'] = $serendipity['serendipityUser'];
+ if (!isset($entry['trackbacks']) || !$entry['trackbacks']) $entry['trackbacks'] = 0;
+ if (!isset($entry['comments']) || !$entry['comments']) $entry['comments'] = 0;
+ if (!isset($entry['username']) || !$entry['username']) $entry['username'] = $serendipity['serendipityUser'];
echo '<strong>' . PREVIEW . '</strong>';
echo '<div style="border:1px solid #000000; padding: 15px;">';
Index: serendipity_admin_images.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_admin_images.inc.php,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- serendipity_admin_images.inc.php 17 Feb 2004 12:10:04 -0000 1.15
+++ serendipity_admin_images.inc.php 21 Mar 2004 16:35:31 -0000 1.16
@@ -59,13 +59,13 @@
$file = serendipity_fetchImageFromDatabase($serendipity['GET']['fid']);
$newfile = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $serendipity['GET']['newname'] . '.' . $file['extension'];
$oldfile = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $file['name'] . '.'. $file['extension'];
- if ( $serendipity['GET']['newname']!= '' && file_exists($oldfile) && !file_exists($newfile) ) {
+ if ($serendipity['GET']['newname'] != '' && file_exists($oldfile) && !file_exists($newfile)) {
// Rename file
rename($oldfile, $newfile);
// Rename thumbnail
- rename( $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $file['name'] . '.' . $file['thumbnail_name'] . '.' . $file['extension'],
- $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $serendipity['GET']['newname'] . '.' . $serendipity['thumbSuffix'] . '.' . $file['extension']);
+ rename($serendipity['serendipityPath'] . $serendipity['uploadPath'] . $file['name'] . '.' . $file['thumbnail_name'] . '.' . $file['extension'],
+ $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $serendipity['GET']['newname'] . '.' . $serendipity['thumbSuffix'] . '.' . $file['extension']);
serendipity_updateImageInDatabase(array('thumbnail_name' => $serendipity['thumbSuffix'], 'name' => $serendipity['GET']['newname']), $serendipity['GET']['fid']);
// Forward user to overview (we don't want the user's back button to rename things again)
@@ -123,6 +123,8 @@
// Accept file
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $_FILES['userfile']['name'])) {
printf(FILE_UPLOADED . '<br />', $_FILES['userfile']['name']);
+ @umask(0000);
+ @chmod($serendipity['serendipityPath'] . $serendipity['uploadPath'] . $_FILES['userfile']['name'], 0664);
// Create thumbnail
serendipity_makeThumbnail($_FILES['userfile']['name']);
Index: serendipity_functions.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_functions.inc.php,v
retrieving revision 1.230
retrieving revision 1.231
diff -u -d -r1.230 -r1.231
--- serendipity_functions.inc.php 21 Mar 2004 16:26:56 -0000 1.230
+++ serendipity_functions.inc.php 21 Mar 2004 16:35:32 -0000 1.231
@@ -3,13 +3,13 @@
# All rights reserved. See LICENSE file for licensing details
$serendipity['imageList'] = array();
-include_once("${serendipity['serendipityPath']}serendipity_db.inc.php");
-include_once("${serendipity['serendipityPath']}compat.php");
-include_once("${serendipity['serendipityPath']}serendipity_functions_config.inc.php");
-include_once("${serendipity['serendipityPath']}bundled-libs/XML/RPC.php");
-include_once("${serendipity['serendipityPath']}serendipity_plugin_api.php");
-include_once("${serendipity['serendipityPath']}serendipity_functions_images.inc.php");
-include_once("${serendipity['serendipityPath']}serendipity_functions_installer.inc.php");
+include_once(S9Y_INCLUDE_PATH . "serendipity_db.inc.php");
+include_once(S9Y_INCLUDE_PATH . "compat.php");
+include_once(S9Y_INCLUDE_PATH . "serendipity_functions_config.inc.php");
+include_once(S9Y_INCLUDE_PATH . "bundled-libs/XML/RPC.php");
+include_once(S9Y_INCLUDE_PATH . "serendipity_plugin_api.php");
+include_once(S9Y_INCLUDE_PATH . "serendipity_functions_images.inc.php");
+include_once(S9Y_INCLUDE_PATH . "serendipity_functions_installer.inc.php");
function serendipity_logout() {
$_SESSION['serendipityAuthedUser'] = false;
@@ -98,7 +98,7 @@
global $serendipity;
$directories = array(
- $serendipity['CONFIG']['template'] . '/',
+ (isset($serendipity['CONFIG']) ? $serendipity['CONFIG']['template'] . '/' : ''),
'default/'
);
@@ -158,7 +158,7 @@
<?php
foreach ($themelist as $theme) {
$info = serendipity_fetchTemplateInfo($theme);
- if ( file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] . $theme . '/preview.png') ) {
+ if (file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] . $theme . '/preview.png')) {
$preview = '<img src="templates/' . $theme . '/preview.png" width="100" style="border: 1px #000000 solid" />';
} else {
$preview = ' ';
@@ -210,35 +210,35 @@
<table border="0" width="100%" cellpadding="3">
<tr>
<td class="serendipity_commentsLabel"><?php echo NAME; ?></td>
- <td class="serendipity_commentsValue"><input type="text" name="serendipity[name]" value="<?php echo ($serendipity['POST']['name'] ? $serendipity['POST']['name'] : $serendipity['COOKIE']['name']); ?>" size="30" /></td>
+ <td class="serendipity_commentsValue"><input type="text" name="serendipity[name]" value="<?php echo (isset($serendipity['POST']['name']) ? $serendipity['POST']['name'] : isset($serendipity['COOKIE']['name']) ? $serendipity['COOKIE']['name'] : ''); ?>" size="30" /></td>
</tr>
<tr>
<td class="serendipity_commentsLabel"><?php echo EMAIL; ?></td>
- <td class="serendipity_commentsValue"><input type="text" name="serendipity[email]" value="<?php echo ($serendipity['POST']['email'] ? $serendipity['POST']['email'] : $serendipity['COOKIE']['email']); ?>" /></td>
+ <td class="serendipity_commentsValue"><input type="text" name="serendipity[email]" value="<?php echo (isset($serendipity['POST']['email']) ? $serendipity['POST']['email'] : isset($serendipity['COOKIE']['email']) ? $serendipity['COOKIE']['email'] : ''); ?>" /></td>
</tr>
<tr>
<td class="serendipity_commentsLabel"><?php echo HOMEPAGE; ?></td>
- <td class="serendipity_commentsValue"><input type="text" name="serendipity[url]" value="<?php echo ($serendipity['POST']['url'] ? $serendipity['POST']['url'] : $serendipity['COOKIE']['url']); ?>" /></td>
+ <td class="serendipity_commentsValue"><input type="text" name="serendipity[url]" value="<?php echo (isset($serendipity['POST']['url']) ? $serendipity['POST']['url'] : isset($serendipity['COOKIE']['url']) ? $serendipity['COOKIE']['url'] : ''); ?>" /></td>
</tr>
<tr>
<td class="serendipity_commentsLabel"><?php echo COMMENT; ?></td>
<td class="serendipity_commentsValue">
- <textarea rows="10" cols="40" name="serendipity[comment]"><?php echo $serendipity['POST']['comment']; ?></textarea><br />
+ <textarea rows="10" cols="40" name="serendipity[comment]"><?php echo (isset($serendipity['POST']['comment']) ? $serendipity['POST']['comment'] : ''); ?></textarea><br />
<?php serendipity_plugin_api::hook_event('frontend_comment', $nullParam); ?>
</td>
</tr>
<tr>
<td> </td>
<td class="serendipity_commentsLabel">
- <input id="checkbox_remember" type="checkbox" name="serendipity[remember]" <?php echo ($serendipity['POST']['remember'] ? 'checked="checked"' : $serendipity['COOKIE']['remember']) ; ?> /><label for="checkbox_remember"> <?php echo REMEMBER_INFO; ?></label>
+ <input id="checkbox_remember" type="checkbox" name="serendipity[remember]" <?php echo (isset($serendipity['POST']['remember']) ? 'checked="checked"' : isset($serendipity['COOKIE']['remember']) ? $serendipity['COOKIE']['remember'] : '') ; ?> /><label for="checkbox_remember"> <?php echo REMEMBER_INFO; ?></label>
<?php
if ($serendipity['allowSubscriptions']) {
?>
<br />
- <input id="checkbox_subscribe" type="checkbox" name="serendipity[subscribe]" <?php echo ($serendipity['POST']['subscribe'] ? 'checked="checked"' : ''); ?> /><label for="checkbox_subscribe"> <?php echo SUBSCRIBE_TO_THIS_ENTRY; ?></label>
+ <input id="checkbox_subscribe" type="checkbox" name="serendipity[subscribe]" <?php echo (isset($serendipity['POST']['subscribe']) ? 'checked="checked"' : ''); ?> /><label for="checkbox_subscribe"> <?php echo SUBSCRIBE_TO_THIS_ENTRY; ?></label>
<?php
}
?>
@@ -516,6 +516,8 @@
function serendipity_fetchEntries($range = null, $full = true, $limit = '', $fetchDrafts = false, $modified_since = false, $orderby = 'timestamp') {
global $serendipity;
+ $and = '';
+
if ($full === true) {
$body = ', e.body, e.extended';
} else {
@@ -561,7 +563,7 @@
}
}
- if ($drafts) {
+ if (!empty($drafts)) {
if (!empty($and)) {
$and .= " AND $drafts";
} else {
@@ -770,7 +772,7 @@
$query = serendipity_db_query($querystring);
$totalEntries = $query[0][0];
- $totalPages = ceil($totalEntries / ($serendipity['fetchLimit'] ? $serendipity['fetchLimit'] : 15));
+ $totalPages = ceil($totalEntries / (!empty($serendipity['fetchLimit']) ? $serendipity['fetchLimit'] : 15));
if (!isset($serendipity['GET']['page'])) {
$serendipity['GET']['page'] = 1;
@@ -833,7 +835,7 @@
$html_extended .= $entry['extended'];
}
- if ($entry['exflag'] && !$extended) {
+ if (isset($entry['exflag']) && $entry['exflag'] && !$extended) {
$html_extended = '<br /><a href="' . $entryLink . '#extended">' . VIEW_EXTENDED_ENTRY . '</a><br />';
}
@@ -847,7 +849,7 @@
<div class='serendipity_entryFooter'>
<?php
- echo ' ' . POSTED_BY . ' ' . htmlentities($entry['username']) . ($entry['category_name'] ? ' ' . IN . ' <a href="' . $serendipity['serendipityHTTPPath'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . 'categories/' . $entry['categoryid'] . '_' . serendipity_makeFilename($entry['category_name']) . '">' . $entry['category_name'] . '</a> ' : ' ') . AT . ' <a href="' . $entryLink . '">' . date('H:i', $entry['timestamp']) . '</a>'. "\n";
+ echo ' ' . POSTED_BY . ' ' . htmlentities($entry['username']) . (!empty($entry['category_name']) ? ' ' . IN . ' <a href="' . $serendipity['serendipityHTTPPath'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . 'categories/' . $entry['categoryid'] . '_' . serendipity_makeFilename($entry['category_name']) . '">' . $entry['category_name'] . '</a> ' : ' ') . AT . ' <a href="' . $entryLink . '">' . date('H:i', $entry['timestamp']) . '</a>'. "\n";
if (serendipity_db_bool($entry['allow_comments']) || !isset($entry['allow_comments']) || $entry['comments'] > 0) {
if (!isset($serendipity['GET']['id'])) {
@@ -920,7 +922,7 @@
<?php
}
- if ($serendipity['GET']['csuccess'] == 'true') {
+ if (isset($serendipity['GET']['csuccess']) && $serendipity['GET']['csuccess'] == 'true') {
?>
<br />
<div class="serendipity_commentsTitle"><?php echo COMMENT_ADDED; ?></div>
@@ -952,7 +954,7 @@
if (!isset($serendipity['GET']['id']) &&
(!isset($serendipity['GET']['hidefooter']) || $serendipity['GET']['hidefooter'] == false) &&
- count($entries) <= ($serendipity['fetchLimit'] ? $serendipity['fetchLimit'] : 15)) {
+ count($entries) <= (!empty($serendipity['fetchLimit']) ? $serendipity['fetchLimit'] : 15)) {
serendipity_printEntryFooter();
}
} else { // else short mode
@@ -1098,7 +1100,7 @@
}
/* Link to the user's website, if the URL is valid */
- if ($comment['type'] != 'trackback' && !empty($comment['url']) && $comment['url'] != 'http://' && eregi('^http://', $comment['url'])) {
+ if ((!isset($comment['type']) || $comment['type'] != 'trackback') && !empty($comment['url']) && $comment['url'] != 'http://' && eregi('^http://', $comment['url'])) {
echo ' (<a href="' . str_replace('"', '"', $comment['url']) . '" ' . serendipity_xhtml_target('_blank') . ' title="' . htmlentities($comment['url']) . '">Link</a>)';
}
@@ -1117,6 +1119,10 @@
}
if ($show_admin && $_SESSION['serendipityAuthedUser'] === true) {
+ if (!isset($comment)) {
+ $comment = array('entry_id' => $serendipity['GET']['id']);
+ }
+
if (serendipity_db_bool($allow_comments)) {
echo '<div class="serendipity_comment_source">(<a href="' . $serendipity['baseURL'] . 'comment.php?serendipity[switch]=disable&serendipity[entry]=' . $comment['entry_id'] . '">' . COMMENTS_DISABLE . '</a>)</div>';
} else {
@@ -1178,7 +1184,7 @@
$ca = serendipity_db_query($query, true);
if (serendipity_db_bool($ca['allow_comments']) || !is_array($ca)) {
- $title = serendipity_db_escape_string($commentInfo['title']);
+ $title = serendipity_db_escape_string(isset($commentInfo['title']) ? $commentInfo['title'] : '');
$comments = $commentInfo['comment'];
$commentsFixed = serendipity_db_escape_string($commentInfo['comment']);
$name = serendipity_db_escape_string($commentInfo['name']);
@@ -1228,10 +1234,12 @@
$entryURI = serendipity_archiveURL($entry_id, $title);
$subject = '[' . $serendipity['blogTitle'] . '] ' . sprintf(NEW_COMMENT_TO_SUBSCRIBED_ENTRY, $title);
+ $pgsql_insert = '';
+ $mysql_insert = '';
if (strtolower($serendipity['dbType']) == 'postgres') {
- $pgsql_insert = "DISTINCT ON (email)";
+ $pgsql_insert = 'DISTINCT ON (email)';
} else {
- $mysql_insert = "GROUP BY email";
+ $mysql_insert = 'GROUP BY email';
}
$sql = "SELECT $pgsql_insert author, email, type
@@ -1306,7 +1314,7 @@
. "\n" . strip_tags($comment);
} else {
$subject = '[' . $serendipity['blogTitle'] . '] ' . NEW_COMMENT_TO . ' ' . $title;
- $text = sprintf(A_NEW_COMMENT_BLAHBLAH, $serendipity[blogTitle], $title)
+ $text = sprintf(A_NEW_COMMENT_BLAHBLAH, $serendipity['blogTitle'], $title)
. "\n" . LINK_TO_ENTRY . ': ' . $entryURI
. "\n"
. "\n" . USER . ' ' . IP_ADDRESS . ': ' . $_SERVER['REMOTE_ADDR']
@@ -1532,9 +1540,9 @@
}
function serendipity_pingback_autodiscover($loc, $body) {
- if($_SERVER['X-PINGBACK']) {
+ if (!empty($_SERVER['X-PINGBACK'])) {
$pingback = $_SERVER['X-PINGBACK'];
- } else if(preg_match('@<link rel="pingback" href="([^"]+)" ?/?>@i', $body, $matches)) {
+ } elseif (preg_match('@<link rel="pingback" href="([^"]+)" ?/?>@i', $body, $matches)) {
$pingback = $matches[1];
} else {
return;
@@ -1617,7 +1625,7 @@
function serendipity_reference_autodiscover($loc, $url, $author, $title, $text) {
$res = @file_get_contents($loc);
- if ( strlen($res) != 0 ) {
+ if (strlen($res) != 0) {
serendipity_trackback_autodiscover($res, $loc, $url, $author, $title, $text);
serendipity_pingback_autodiscover($loc, $res);
}
@@ -1767,7 +1775,7 @@
if ($row[0] > 0) {
continue;
}
- if (!$serendipity['noautodiscovery']) {
+ if (!isset($serendipity['noautodiscovery']) || !$serendipity['noautodiscovery']) {
serendipity_reference_autodiscover($locations[$i], $url, $author, $title, serendipity_trackback_excerpt($text));
}
}
@@ -1910,7 +1918,7 @@
if (isset($entry['allow_comments']) && (serendipity_db_bool($entry['allow_comments']))) {
$allow_comments = ' checked="checked"';
- } elseif ($entry['allow_comments'] !== 'false' && ($serendipity['allowCommentsDefault'] == 'true' || $serendipity['allowCommentsDefault'] === true)) {
+ } elseif ((!isset($entry['allow_comments']) || $entry['allow_comments'] !== 'false') && ($serendipity['allowCommentsDefault'] == 'true' || $serendipity['allowCommentsDefault'] === true)) {
// This is the default on creation of a new entry and depends on the "allowCommentsDefault" variable of the configuration.
$allow_comments = ' checked="checked"';
} else {
@@ -2308,19 +2316,11 @@
function serendipity_updateEntryCategories($postid, $categories) {
global $serendipity;
- if(!$postid || !$categories) {
+ if (!$postid || !$categories) {
return;
}
$query = "UPDATE $serendipity[dbPrefix]entries set categoryid = $categories[0] where id = $postid";
$err = serendipity_db_query($query);
-
- /* TODO: nuke this */
- $fp = fopen('/tmp/a', 'w');
- fwrite($fp,$query);
- if(is_string($err)) {
- fwrite($fp, $err);
- }
- fclose($fp);
}
/*
Index: index.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/index.php,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- index.php 21 Mar 2004 16:26:56 -0000 1.36
+++ index.php 21 Mar 2004 16:35:31 -0000 1.37
@@ -33,7 +33,7 @@
$serendipity['blogSubTitle'] = sprintf(ENTRIES_FOR, $date);
ob_start();
- include_once('serendipity_genpage.inc.php');
+ include_once(S9Y_INCLUDE_PATH . 'serendipity_genpage.inc.php');
$data = ob_get_contents();
ob_end_clean();
@@ -59,7 +59,7 @@
$serendipity['blogSubTitle'] = sprintf(ENTRIES_FOR, $date);
ob_start();
- include_once('serendipity_genpage.inc.php');
+ include_once(S9Y_INCLUDE_PATH . 'serendipity_genpage.inc.php');
$data = ob_get_contents();
ob_end_clean();
@@ -108,7 +108,7 @@
$serendipity['blogTitle'] = $title;
ob_start();
- include_once('serendipity_genpage.inc.php');
+ include_once(S9Y_INCLUDE_PATH . 'serendipity_genpage.inc.php');
$data = ob_get_contents();
ob_end_clean();
@@ -124,7 +124,7 @@
$_GET['version'] = serendipity_discover_rss($matches[1], $matches[2]);
ob_start();
- include_once('rss.php');
+ include_once(S9Y_INCLUDE_PATH . 'rss.php');
$data = ob_get_contents();
ob_end_clean();
@@ -148,7 +148,7 @@
} else if (preg_match(PAT_ARCHIVE, $uri)) {
header('Content-Type: text/html; charset='. LANG_CHARSET);
$serendipity['GET']['action'] = 'archives';
- include_once('serendipity_genpage.inc.php');
+ include_once(S9Y_INCLUDE_PATH . 'serendipity_genpage.inc.php');
} else if (preg_match(PAT_CATEGORIES, $uri, $matches) ||
preg_match('@/(index\.(php|html))?@', $uri) ||
preg_match('@/(' . preg_quote($serendipity['indexFile']) . ')?@', $uri)) {
@@ -161,7 +161,7 @@
}
ob_start();
- include_once('serendipity_genpage.inc.php');
+ include_once(S9Y_INCLUDE_PATH . 'serendipity_genpage.inc.php');
$data = ob_get_contents();
ob_end_clean();
if (isset($serendipity['pregenerate']) && $serendipity['pregenerate']) {
@@ -179,7 +179,7 @@
$serendipity['GET']['action'] = 'read';
$serendipity['GET']['range'] = $serendipity['GET']['calendarZoom'];
}
- include_once('serendipity_genpage.inc.php');
+ include_once(S9Y_INCLUDE_PATH . 'serendipity_genpage.inc.php');
}
} else {
printf(DOCUMENT_NOT_FOUND, $uri);
Index: serendipity_admin_upgrader.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_admin_upgrader.inc.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- serendipity_admin_upgrader.inc.php 17 Mar 2004 08:46:33 -0000 1.4
+++ serendipity_admin_upgrader.inc.php 21 Mar 2004 16:35:32 -0000 1.5
@@ -1,5 +1,5 @@
<?php
-require_once('serendipity_functions_installer.inc.php');
+require_once(S9Y_INCLUDE_PATH . 'serendipity_functions_installer.inc.php');
$abortLoc = $serendipity['serendipityHTTPPath'] . 'serendipity_admin.php?serendipity[action]=ignore';
$upgradeLoc = $serendipity['serendipityHTTPPath'] . 'serendipity_admin.php?serendipity[action]=upgrade';
@@ -9,7 +9,7 @@
/* Fetch SQL files which needs to be run */
-$dir = opendir($serendipity['serendipityPath'] .'sql/');
+$dir = opendir(S9Y_INCLUDE_PATH . 'sql/');
while (($file = readdir($dir)) !== false ) {
if (preg_match('@db_update_(.*)_(.*)_'. $serendipity['dbType'] .'.sql@', $file, $res)) {
if (version_compare($res[1], serendipity_version($serendipity['versionInstalled'])) >= 0) {
@@ -25,7 +25,7 @@
/* Install SQL files */
foreach ($sqlfiles as $sqlfile) {
- $sql = file_get_contents($serendipity['serendipityPath'] .'sql/'. $sqlfile);
+ $sql = file_get_contents(S9Y_INCLUDE_PATH .'sql/'. $sqlfile);
$sql = str_replace('{PREFIX}', $serendipity['dbPrefix'], $sql);
preg_match_all("@(.*);@iUs", $sql, $res);
foreach ($res[0] as $sql) {
Index: serendipity.css.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity.css.php,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- serendipity.css.php 3 Mar 2004 08:17:59 -0000 1.24
+++ serendipity.css.php 21 Mar 2004 16:35:31 -0000 1.25
@@ -1,7 +1,6 @@
<?php # $Id$
session_start();
-include_once('compat.php');
/* This is a small hack to allow CSS display during installations and upgr...
[truncated message content] |