Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1:/tmp/cvs-serv16672
Modified Files:
serendipity_admin.php serendipity_admin_category.inc.php
serendipity_admin_entries.inc.php
serendipity_admin_installer.inc.php
Log Message:
Commited patch as proposed on the mailinglist
(Part 2/5)
Index: serendipity_admin.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_admin.php,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- serendipity_admin.php 10 Aug 2003 17:56:10 -0000 1.18
+++ serendipity_admin.php 18 Sep 2003 12:58:00 -0000 1.19
@@ -14,9 +14,9 @@
<html>
<head>
<title><?php echo SERENDIPITY_ADMIN_SUITE; ?></title>
- <link rel="stylesheet" type="text/css" href="<?php echo $serendipity['serendipityHTTPPath']; ?>serendipity.css.php" />
+ <link rel="stylesheet" type="text/css" href="<?php echo (isset($serendipity['serendipityHTTPPath']) ? $serendipity['serendipityHTTPPath'] : ''); ?>serendipity.css.php" />
<?php
-if (strtolower($serendipity['extCSS'])!='none') {
+if (isset($serendipity['extCSS']) && strtolower($serendipity['extCSS']) != 'none') {
?>
<link rel="stylesheet" type="text/css" href="<?php echo $serendipity['extCSS']; ?>" />
<?php
@@ -26,9 +26,9 @@
<body>
<div id="serendipity_banner">
- <h1><?php echo $serendipity['blogTitle'] ; ?></h1>
+ <h1><?php echo (isset($serendipity['blogTitle']) ? $serendipity['blogTitle'] : ''); ?></h1>
<?php
-$sub = isset($serendipity['blogSubTitle']) ? $serendipity['blogSubTitle'] : $serendipity['blogDescription'];
+$sub = isset($serendipity['blogSubTitle']) ? $serendipity['blogSubTitle'] : (isset($serendipity['blogDescription']) ? $serendipity['blogDescription'] : '');
if (strlen($sub)) {
?>
<h2><?php echo $sub ; ?></h2>
@@ -39,7 +39,7 @@
<table id="mainpane">
<tr id="content" valign="top">
<?php
-if ( !file_exists($serendipity['serendipityPath'] . 'serendipity_config_local.inc.php') ) {
+if (!isset($serendipity['serendipityPath']) || !file_exists($serendipity['serendipityPath'] . 'serendipity_config_local.inc.php') ) {
// User just installed serendipity, let him go to configure mode
?>
<td class="serendipity_admin">
@@ -78,10 +78,10 @@
<td class="serendipity_admin">
<div class="serendipity_admin_title"><?php echo SERENDIPITY_ADMIN_SUITE; ?></div>
<?php
- if (!$serendipity['GET']['adminModule']) {
- $serendipity['GET']['adminModule'] = $serendipity['POST']['adminModule'];
+ if (!isset($serendipity['GET']['adminModule'])) {
+ $serendipity['GET']['adminModule'] = (isset($serendipity['POST']['adminModule']) ? $serendipity['POST']['adminModule'] : '');
}
-
+
switch($serendipity['GET']['adminModule']) {
case 'installer':
include './serendipity_admin_installer.inc.php';
Index: serendipity_admin_category.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_admin_category.inc.php,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- serendipity_admin_category.inc.php 13 Aug 2003 16:16:11 -0000 1.7
+++ serendipity_admin_category.inc.php 18 Sep 2003 12:58:00 -0000 1.8
@@ -6,7 +6,7 @@
session_start();
-$cat_to_edit = (int)$_GET['serendipity']['cat']['catid'];
+$cat_to_edit = (isset($_GET['serendipity']['cat']['catid']) ? (int)$_GET['serendipity']['cat']['catid'] : 0);
$msg = '';
if (isset($_POST['SAVE'])) {
@@ -17,7 +17,7 @@
} else {
$query = "UPDATE {$serendipity['dbPrefix']}category SET category_name='$name', category_description='$desc' where categoryid=$cat_to_edit";
}
-
+
$r = serendipity_db_query($query);
if (is_string($r)) {
$msg = $r;
@@ -33,7 +33,7 @@
} else {
$msg = INVALID_CATEGORY;
}
-
+
$cat_to_edit = 0;
}
@@ -42,14 +42,14 @@
$existing_cats_table = '';
$existing_cats_dropdown = '<select name="serendipity[cat][remaining_catid]">' . "\n";
$existing_cats_dropdown .= '<option value="0">- '. NO_CATEGORY .' -</option>' . "\n";
-if (count($cats)) {
+if (isset($cats) && is_array($cats) && count($cats)) {
foreach ($cats as $cat_data) {
if ($cat_to_edit > 0 && $cat_data['categoryid'] == $cat_to_edit && !isset($this_cat)) {
$this_cat = $cat_data;
} elseif ($cat_to_edit > 0) {
$existing_cats_dropdown .= '<option value="' . $cat_data['categoryid'] . '">' . htmlentities($cat_data['category_name']) . '</option>' . "\n";
}
-
+
$name = htmlentities($cat_data['category_name']);
$desc = htmlentities($cat_data['category_description']);
$existing_cats_table .= <<<CAT
@@ -83,12 +83,12 @@
<table cellpadding="5">
<tr>
<th><?php echo NAME; ?></th>
- <td><input type="text" name="serendipity[cat][name]" value="<?php echo htmlentities($this_cat['category_name']); ?>" /></td>
+ <td><input type="text" name="serendipity[cat][name]" value="<?php echo isset($this_cat['category_name']) ? htmlentities($this_cat['category_name']) : ''; ?>" /></td>
</tr>
<tr>
<th><?php echo DESCRIPTION; ?></th>
- <td><input type="text" name="serendipity[cat][description]" value="<?php echo htmlentities($this_cat['category_description']); ?>" /></td>
+ <td><input type="text" name="serendipity[cat][description]" value="<?php echo isset($this_cat['category_description']) ? htmlentities($this_cat['category_description']) : ''; ?>" /></td>
</tr>
</table>
Index: serendipity_admin_entries.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_admin_entries.inc.php,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- serendipity_admin_entries.inc.php 31 Aug 2003 21:41:49 -0000 1.11
+++ serendipity_admin_entries.inc.php 18 Sep 2003 12:58:00 -0000 1.12
@@ -78,7 +78,7 @@
<td class="serendipity_admin_list_item">
<?php echo date('d.m.y, H:i', $entries[$x]['timestamp']) . ': '; ?>
<br />
- <?php if ($entries[$x]['isdraft'] == 'true') echo DRAFT . ':'; ?>
+ <?php if ($entries[$x]['isdraft'] == 'true') echo DRAFT . ':'; ?>
<a href="?serendipity[action]=admin&serendipity[adminModule]=entries&serendipity[adminAction]=<?php echo $action; ?>&serendipity[id]=<?php echo $entries[$x]['id']; ?>">
<?php echo htmlentities(substr(empty($entries[$x]['title']) ? $entries[$x]['body'] : $entries[$x]['title'], 0, 40)); ?>
</a>
@@ -128,7 +128,20 @@
'categoryid' => $serendipity['POST']['categoryid'],
'isdraft' => $serendipity['POST']['isdraft']
);
-
+
+
+ // Check if the user changed the timestamp.
+ if (isset($serendipity['allowDateManipulation']) && $serendipity['allowDateManipulation'] && isset($serendipity['POST']['new_timestamp']) && $serendipity['POST']['new_timestamp'] != date(DATE_FORMAT_2, $serendipity['POST']['chk_timestamp'])) {
+ // The user changed the timestamp, now set the DB-timestamp to the user's date
+ $entry['timestamp'] = strtotime($serendipity['POST']['new_timestamp']);
+
+ if ($entry['timestamp'] == -1) {
+ echo DATE_INVALID . '<br />';
+ // The date given by the user is not convertable. Reset the timestamp.
+ $entry['timestamp'] = $serendipity['POST']['timestamp'];
+ }
+ }
+
// Save the entry, or just display a preview
if ($serendipity['POST']['preview'] != 'true') {
$res = serendipity_updertEntry($entry);
@@ -151,7 +164,7 @@
if (!$entry['trackbacks']) $entry['trackbacks'] = 0;
if (!$entry['comments']) $entry['comments'] = 0;
if (!$entry['username']) $entry['username'] = $serendipity['serendipityUser'];
-
+
echo '<strong>' . PREVIEW . '</strong>';
echo '<div style="border:1px solid #000000; padding: 15px;">';
serendipity_printEntries(array($entry), ($entry['extended'] != '' ? 1 : 0));
@@ -207,7 +220,7 @@
'serendipity[adminModule]' => 'entries',
'serendipity[adminAction]' => 'save'
),
- $entry
+ (isset($entry) ? $entry : array())
);
}
/* 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.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- serendipity_admin_installer.inc.php 7 Sep 2003 22:16:00 -0000 1.39
+++ serendipity_admin_installer.inc.php 18 Sep 2003 12:58:00 -0000 1.40
@@ -14,7 +14,7 @@
return dirname($_SERVER['PHP_SELF']) . '/';
case 'baseURL':
- $ssl = $_SERVER['HTTPS'] == 'on';
+ $ssl = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on';
$port = $_SERVER['SERVER_PORT'];
return sprintf(
@@ -27,14 +27,18 @@
);
case 'convert':
- $path = explode(':', $_ENV['PATH']);
+ if (isset($_EVN['PATH'])) {
+ $path = explode(':', $_ENV['PATH']);
+ } else {
+ $path = '';
+ }
/* add some other possible locations to the path while we are at it,
* as these are not always included in the apache path */
$path[] = '/usr/X11R6/bin';
foreach ($path as $dir) {
- if (@is_executable($dir . '/convert')) {
+ if (function_exists('is_executable') && is_executable($dir . '/convert') || is_file($dir . '/convert')) {
return $dir . '/convert';
}
}
@@ -45,7 +49,7 @@
}
}
-function serendipity_parseTemplate($n, $raw=false) {
+function serendipity_parseTemplate($n, $raw = false) {
global $serendipity;
$config = array();
@@ -54,37 +58,41 @@
$l = $t[$x];
$l = trim($l);
- switch ($l[0]) {
+ if ($l != '') {
+ switch ($l[0]) {
- // New Configure section
- case '/':
- if ($l[1] == '/') {
- $current = trim(substr($l, 2));
- $config['categories'][$current] = array();
- }
+ // New Configure section
+ case '/':
+ if ($l[1] == '/') {
+ $current = trim(substr($l, 2));
+ $config['categories'][$current] = array();
+ }
+ break;
- break;
- case '#':
+ case '#':
$config['descriptions'][$current] = trim(substr($l, 1));
- break;
- // A configure option
- case '$':
- // Grep out the name, type and default
- preg_match('#\{([^|]+\|[^|]+\|([^}]+)?)\}[^/]+/{2}(.+)#msi', $l, $match);
- $c = explode('|', $match[1]);
- $config['categories'][$current][] = $configRaw[] = array(
- 'longname' => $c[0],
- 'name' => $c[1],
- 'type' => $c[2],
- 'default' => serendipity_query_default($c[1], $c[3]),
- 'distdefault' => $c[3],
- 'desc' => $match[3]
- );
-
- break;
+ break;
+
+ // A configure option
+ case '$':
+ // Grep out the name, type and default
+ preg_match('#\{([^|]+\|[^|]+\|([^}]+)?)\}[^/]+/{2}(.+)#msi', $l, $match);
+ $c = explode('|', $match[1]);
+ $cdef = serendipity_query_default($c[1], $c[3]);
+ $config['categories'][$current][] = $configRaw[] = array(
+ 'longname' => $c[0],
+ 'name' => $c[1],
+ 'type' => $c[2],
+ 'default' => $cdef,
+ 'distdefault' => $c[3],
+ 'desc' => $match[3]
+ );
+ break;
+ }
}
}
- if ( $raw ) {
+
+ if ($raw) {
return $configRaw;
} else {
return $config;
@@ -92,13 +100,12 @@
}
function serendipity_guessInput($type, $name, $value='', $default='') {
-
switch ($type) {
case 'bool' :
echo '<input type="radio" name="' . $name . '" value="true" ';
- echo (($default == true) ? 'CHECKED' : ''). ' /> ' . YES;
+ echo (($default == true) ? 'checked="checked"' : ''). ' /> ' . YES . ' ';
echo '<input type="radio" name="' . $name . '" value="false" ';
- echo (($default == true) ? '' : 'CHECKED'). ' /> ' . NO;
+ echo (($default == true) ? '' : 'checked="checked"'). ' /> ' . NO;
break;
case 'protected' :
@@ -112,7 +119,7 @@
}
function serendipity_printConfigTemplate($t, $from = false) {
- global $serendipity;
+ global $serendipity, $installed;
?>
<script type="text/javascript" language="JavaScript">
function showConfig(id) {
@@ -168,7 +175,7 @@
<tr>
<td>
- <table width="100%" cellspacing="0" cellpadding="3" style="display: none;" id="el<?php echo $el_count; ?>">
+ <table width="100%" cellspacing="0" cellpadding="3" style="<?php echo ($installed ? 'display: none;' : ''); ?>" id="el<?php echo $el_count; ?>">
<tr>
<td style="padding-left: 20px;" colspan="2">
<?php echo $t['descriptions'][$key] ?>
@@ -183,14 +190,14 @@
}
?>
<tr>
- <td style="border-bottom: 1px #000000 solid" align="left" valign="top">
+ <td style="border-bottom: 1px #000000 solid" align="left" valign="top" width="75%">
<strong><?php echo $value[$x]['longname']; ?></strong>
<br />
<span style="color: #5E7A94; font-size: 8pt;"><?php echo '(' . $value[$x]['type'] . ') ' . $value[$x]['desc']; ?></span>
</td>
- <td style="border-bottom: 1px #000000 solid; font-size: 8pt" align="left" valign="middle" width="1">
- <?php echo serendipity_guessInput($value[$x]['type'], $value[$x]['name'], $from[$value[$x]['name']], $value[$x]['default']); ?>
+ <td style="border-bottom: 1px #000000 solid; font-size: 8pt" align="right" valign="middle" width="25%">
+ <nobr><?php echo serendipity_guessInput($value[$x]['type'], $value[$x]['name'], $from[$value[$x]['name']], $value[$x]['default']); ?></nobr>
</td>
</tr>
<?php
@@ -283,7 +290,7 @@
function serendipity_installDatabase() {
global $serendipity;
-
+
/* Try and check if the database/tables are already installed,
if they are... exit the function */
$t = serendipity_db_query("SELECT * FROM {$_POST['dbPrefix']}authors");
@@ -291,7 +298,7 @@
return false;
}
-
+
// Create tables
$queries = serendipity_parse_sql_tables('./db.sql');
$queries = str_replace('{PREFIX}', $_POST['dbPrefix'], $queries);
@@ -369,7 +376,7 @@
// Save all basic config variables to the database
$p = serendipity_parseTemplate("./serendipity_config_local.tpl", true);
-
+
foreach($p as $key => $entry) {
serendipity_set_config_var($entry['name'], $_POST[$entry['name']]);
}
@@ -403,10 +410,14 @@
}
+if (!isset($_POST['installAction'])) {
+ $_POST['installAction'] = '';
+}
+
switch ($_POST['installAction']) {
case 'check':
/* If we already have serendipity installed, all we need to do is write the configuration again */
- if (IN_serendipity !== true) {
+ if (!defined('IN_serendipity') || IN_serendipity !== true) {
$res = serendipity_checkInstallation();
if (is_array($res)) {
@@ -426,7 +437,7 @@
} else {
echo '<span style="color: #FF0000">- ' . DATABASE_ALREADY_INSTALLED . '</span><br />';
}
-
+
/* Next are the files, .htaccess */
printf(ATTEMPT_WRITE_FILE, '.htaccess');
$res = serendipity_installFiles();
@@ -462,9 +473,9 @@
);
session_destroy();
-
+
}
-
+
$res = serendipity_updateConfiguration();
if ( is_array($res) ) {
echo DIAGNOSTIC_ERROR;
@@ -472,7 +483,7 @@
} else {
echo WRITTEN_N_SAVED;
}
-
+
break;
default:
@@ -484,9 +495,9 @@
if ( !eregi('apache', $_SERVER['SERVER_SOFTWARE']) ) {
echo '<br /><font color="#FF000">WARNING!<br />You are about to attempt to install Serendipity on a non-apache webserver.<br />Serendipity requires the Apache Werbserver to function correctly!</font>';
}
-
+
define('VERSION_REQUIRED', '4.3.0');
-
+
/* Do check for required PHP version */
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>';
|