Index: trunk/CHANGELOG
===================================================================
--- trunk/CHANGELOG	(revision 642)
+++ trunk/CHANGELOG	(revision 643)
@@ -12,8 +12,10 @@
 
 ------------------------------------- 2.7.0 -------------------------------------
 29-Jan-2008 Thomas Hornik
+#	strtotime()'s behavior differ in PHP4 and PHP5.
+	Had to fix some issues in admin/pages/sections and module news.
 #	Security bugfix: Text file for text-captcha was world-readable. Moved to database.
-#	Text-captcha: empty line in test file, following a question, was accepted as answer. Fixed.
+#	Text-captcha: empty line in text file, following a question, was accepted as answer. Fixed.
 28-Jan-2008 Matthias Gallas
 #	Replaced all special chars in language files with htmlentities or unicode
 +	Added some missing lines in language files
Index: trunk/wb/include/jscalendar/jscalendar-functions.php
===================================================================
--- trunk/wb/include/jscalendar/jscalendar-functions.php	(nonexistent)
+++ trunk/wb/include/jscalendar/jscalendar-functions.php	(revision 643)
@@ -0,0 +1,49 @@
+<?php
+
+// $Id$
+
+/*
+
+ Website Baker Project <http://www.websitebaker.org/>
+ Copyright (C) 2004-2008, Ryan Djurovich
+
+ Website Baker is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ Website Baker is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Website Baker; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+*/
+
+if(!defined('WB_URL')) { exit(header('Location: ../index.php')); }
+
+// convert string from jscalendar to timestamp.
+// converts dd.mm.yyyy and mm/dd/yyyy, with or without time.
+// strtotime() may fails with e.g. "dd.mm.yyyy" and PHP4
+function jscalendar_to_timestamp($str, $offset='') {
+	$str = trim($str);
+	// convert to yyyy-mm-dd
+	// "dd.mm.yyyy"?
+	if(preg_match('/^\d{1,2}\.\d{1,2}\.\d{2}(\d{2})?/', $str)) {
+		$str = preg_replace('/^(\d{1,2})\.(\d{1,2})\.(\d{2}(\d{2})?)/', '$3-$2-$1', $str);
+	}
+	// "mm/dd/yyyy"?
+	if(preg_match('#^\d{1,2}/\d{1,2}/(\d{2}(\d{2})?)#', $str)) {
+		$str = preg_replace('#^(\d{1,2})/(\d{1,2})/(\d{2}(\d{2})?)#', '$3-$1-$2', $str);
+	}
+	// use strtotime()
+	if($offset!='')
+		return(strtotime($str, $offset));
+	else
+	return(strtotime($str));
+}
+
+?>
\ No newline at end of file

Property changes on: trunk/wb/include/jscalendar/jscalendar-functions.php
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: trunk/wb/include/jscalendar/wb-setup.php
===================================================================
--- trunk/wb/include/jscalendar/wb-setup.php	(revision 642)
+++ trunk/wb/include/jscalendar/wb-setup.php	(revision 643)
@@ -1,6 +1,6 @@
 <?php
 
-// $Id:$
+// $Id$
 
 /*
 
@@ -53,6 +53,7 @@
 	if(LANGUAGE=='EN')
 		$jscal_firstday = '0'; // sunday
 	// date and time format for the text-field and for jscal's "ifFormat". We offer dd.mm.yyyy or yyyy-mm-dd or mm/dd/yyyy
+	// ATTN: strtotime() fails with "dd.mm.yyyy" and PHP4. So the string has to be converted to e.g. "yyyy-mm-dd", which will work.
 	switch(DATE_FORMAT) {
 		case 'd.m.Y':
 		case 'd M Y':
Index: trunk/wb/admin/pages/sections_save.php
===================================================================
--- trunk/wb/admin/pages/sections_save.php	(revision 642)
+++ trunk/wb/admin/pages/sections_save.php	(revision 643)
@@ -32,6 +32,8 @@
 	exit(0);
 }
 
+require_once(WB_PATH."/include/jscalendar/jscalendar-functions.php");
+
 // Get page id
 if(!isset($_GET['page_id']) OR !is_numeric($_GET['page_id'])) {
 	header("Location: index.php");
@@ -95,12 +97,12 @@
 				if(trim($_POST['start_date'.$section_id]) == '0' OR trim($_POST['start_date'.$section_id]) == '') {
 					$publ_start = 0;
 				} else {
-					$publ_start = strtotime($_POST['start_date'.$section_id]);
+					$publ_start = jscalendar_to_timestamp($_POST['start_date'.$section_id]);
 				}
 				if(trim($_POST['end_date'.$section_id]) == '0' OR trim($_POST['end_date'.$section_id]) == '') {
 					$publ_end = 0;
 				} else {
-					$publ_end = strtotime($_POST['end_date'.$section_id], $publ_start);
+					$publ_end = jscalendar_to_timestamp($_POST['end_date'.$section_id], $publ_start);
 				}
 				if($sql != '')
 					$sql .= ",";
Index: trunk/wb/admin/pages/sections.php
===================================================================
--- trunk/wb/admin/pages/sections.php	(revision 642)
+++ trunk/wb/admin/pages/sections.php	(revision 643)
@@ -140,12 +140,6 @@
 <?php // include jscalendar-setup
 	$jscal_use_time = true; // whether to use a clock, too
 	require_once(WB_PATH."/include/jscalendar/wb-setup.php");
-	// override some vars: (normally, there is no need to change this)
-	//$jscal_lang = "en"; //- calendar-language (default: wb-backend-language)
-	//$jscal_today = ""; // - date the calendar offers if the text-field is empty (default: today)
-	//$jscal_firstday = "0"; // - first-day-of-week (0-sunday, 1-monday, ...) (default: 0(EN) or 1(everything else))
-	//$jscal_format = "Y-m-d"; // - initial-format used for the text-field (default: from wb-backend-date-format)
-	//$jscal_ifformat = "%Y-%m-%d"; // - format for jscalendar (default: from wb-backend-date-format)
 ?>
 <table cellpadding="5" cellspacing="0" border="0" align="center" width="100%" height="50" style="margin-bottom: 10px;">
 <tr style="background-color: #F0F0F0;">
Index: trunk/wb/modules/news/modify_post.php
===================================================================
--- trunk/wb/modules/news/modify_post.php	(revision 642)
+++ trunk/wb/modules/news/modify_post.php	(revision 643)
@@ -52,15 +52,7 @@
 // include jscalendar-setup
 $jscal_use_time = true; // whether to use a clock, too
 require_once(WB_PATH."/include/jscalendar/wb-setup.php");
-// override some vars: (normally, there is no need to change this)
-//$jscal_lang = "en"; //- calendar-language (default: wb-backend-language)
-//$jscal_today = ""; // - date the calendar offers if the text-field is empty (default: today)
-//$jscal_firstday = "0"; // - first-day-of-week (0-sunday, 1-monday, ...) (default: 0(EN) or 1(everything else))
-//$jscal_format = "Y-m-d"; // - initial-format used for the text-field (default: from wb-backend-date-format)
-//$jscal_ifformat = "%Y-%m-%d"; // - format for jscalendar (default: from wb-backend-date-format)
-
 ?>
-
 <h2><?php echo $TEXT['ADD'].'/'.$TEXT['MODIFY'].' '.$TEXT['POST']; ?></h2>
 
 <form name="modify" action="<?php echo WB_URL; ?>/modules/news/save_post.php" method="post" style="margin: 0;">
@@ -123,7 +115,7 @@
 <tr>
 	<td><?php echo $TEXT['PUBL_START_DATE']; ?>:</td>
 	<td>
-	<input type="text" id="publishdate" name="publishdate" value="<?php if($fetch_content['published_when']==0) print date($jscal_format, time()); else print date($jscal_format, $fetch_content['published_when']);?>" style="width: 120px;" />
+	<input type="text" id="publishdate" name="publishdate" value="<?php if($fetch_content['published_when']==0) print date($jscal_format, strtotime((date('Y-m-d')))); else print date($jscal_format, $fetch_content['published_when']);?>" style="width: 120px;" />
 	<img src="<?php echo ADMIN_URL ?>/images/clock_16.png" id="publishdate_trigger" style="cursor: pointer;" title="Calendar" onmouseover="this.style.background='lightgrey';" onmouseout="this.style.background=''" />
 	<img src="<?php echo ADMIN_URL ?>/images/clock_del_16.png" style="cursor: pointer;" title="delete date" onmouseover="this.style.background='lightgrey';" onmouseout="this.style.background=''" onclick="document.modify.publishdate.value=''" />
 	</td>
Index: trunk/wb/modules/news/save_post.php
===================================================================
--- trunk/wb/modules/news/save_post.php	(revision 642)
+++ trunk/wb/modules/news/save_post.php	(revision 643)
@@ -25,6 +25,8 @@
 
 require('../../config.php');
 
+require_once(WB_PATH."/include/jscalendar/jscalendar-functions.php");
+
 // Get id
 if(!isset($_POST['post_id']) OR !is_numeric($_POST['post_id'])) {
 	header("Location: ".ADMIN_URL."/pages/index.php");
@@ -45,8 +47,6 @@
 	$title = $admin->add_slashes($admin->get_post('title'));
 	$short = $admin->add_slashes($admin->get_post('short'));
 	$long = $admin->add_slashes($admin->get_post('long'));
-	$publishedwhen = strtotime($admin->get_post('publishdate'));
-	$publisheduntil = strtotime($admin->get_post('enddate'));
 	$commenting = $admin->get_post('commenting');
 	$active = $admin->get_post('active');
 	$old_link = $admin->get_post('link');
@@ -102,6 +102,14 @@
 	change_mode($filename);
 }
 
+// get publisedwhen and publisheduntil
+$publishedwhen = jscalendar_to_timestamp($admin->get_post('publishdate'));
+if($publishedwhen == '' || $publishedwhen < 1)
+	$publishedwhen=0;
+$publisheduntil = jscalendar_to_timestamp($admin->get_post('enddate'), $publishedwhen);
+if($publisheduntil == '' || $publisheduntil < 1)
+	$publisheduntil=0;
+
 // Update row
 $database->query("UPDATE ".TABLE_PREFIX."mod_news_posts SET group_id = '$group_id', title = '$title', link = '$post_link', content_short = '$short', content_long = '$long', commenting = '$commenting', active = '$active', published_when = '$publishedwhen', published_until = '$publisheduntil', posted_when = '".mktime()."', posted_by = '".$admin->get_user_id()."' WHERE post_id = '$post_id'");
 
