Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1:/tmp/cvs-serv9578
Modified Files:
index.php serendipity_functions.inc.php
Log Message:
Adjusted mktime() start/end timestamps to correctly return dates for a whole
dayspan. Fixes a bug that the last day of a month was not taken into
account of the archives.
Index: index.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/index.php,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- index.php 9 Jul 2003 17:52:00 -0000 1.21
+++ index.php 9 Jul 2003 18:55:36 -0000 1.22
@@ -15,11 +15,11 @@
if (strlen($range) == 6) {
- $date = date('m/Y', mktime(0,0,0, substr($range, 4, 6), 2, substr($range, 0, 4)));
+ $date = date('m/Y', mktime(0, 0, 0, substr($range, 4, 6), 2, substr($range, 0, 4)));
} else {
$date = date('d/m/Y', strtotime($range));
}
-
+
$serendipity['blogSubTitle'] = sprintf(ENTRIES_FOR, $date);
ob_start();
include_once('serendipity_genpage.inc.php');
Index: serendipity_functions.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_functions.inc.php,v
retrieving revision 1.102
retrieving revision 1.103
diff -u -d -r1.102 -r1.103
--- serendipity_functions.inc.php 9 Jul 2003 17:52:00 -0000 1.102
+++ serendipity_functions.inc.php 9 Jul 2003 18:55:36 -0000 1.103
@@ -206,7 +206,7 @@
$nextYear = $year+1;
}
- $endts = mktime(0, 0, 0, $month + 1, 1, $year);
+ $endts = mktime(23, 59, 59, $month + 1, 1, $year);
// Find out about diary entries
$querystring = "SELECT timestamp from $serendipity[dbPrefix]entries WHERE timestamp >= $ts and timestamp <= $endts";
@@ -341,15 +341,15 @@
$year = (int)substr($range, 0, 4);
$month = (int)substr($range, 4, 2);
$day = (int)substr($range, 6, 2);
-
- $startts = mktime(0, 0, 0, $month, $day, $year);
+
+ $startts = mktime(0, 0, 0, $month, ($day == 0 ? 1 : $day), $year);
if ( $day == 0 ) {
$month++;
} else {
$day++;
}
- $endts = mktime(0, 0, 0, $month, $day, $year);
-
+ $endts = mktime(0, 0, 0, $month, ($day == 0 ? 1 : $day), $year);
+
$and = " WHERE timestamp >= $startts AND timestamp <= $endts ";
} else {
$and = "";
@@ -376,6 +376,7 @@
ORDER BY
timestamp DESC
$limit";
+
$ret = serendipity_db_query($query);
if (is_string($ret)) {
die("Query failed: $ret");
@@ -1832,10 +1833,11 @@
function serendipity_postAmount($year, $month) {
global $serendipity;
- $s = mktime(0,0,0, $month, 1, $year);
- $e = mktime(23,59,59, $month, date("t",$s) , $year);
- $querystring = "SELECT count(id) FROM {$serendipity['dbPrefix']}entries WHERE timestamp>$s AND timestamp<$e";
+ $s = mktime(0, 0, 0, $month, 1, $year);
+ $e = mktime(23, 59, 59, $month, date('t', $s), $year);
+ $querystring = "SELECT count(id) FROM {$serendipity['dbPrefix']}entries WHERE timestamp >= $s AND timestamp <= $e";
$query = serendipity_db_query($querystring);
+
return $query[0][0];
}
@@ -1857,7 +1859,7 @@
// echo "<h2>$currYear</h2><div class='serendipity_entry'>";
for($x=1; $x<13; $x++) {
$entries = serendipity_postAmount($currYear, $x);
- if ($entries>0) {
+ if ($entries > 0) {
$a = "<a href='{$serendipity['serendipityHTTPPath']}archives/$currYear" . sprintf('%02s', $x) . '.html\'>';
$b = '</a>';
$c = "<a href='{$serendipity['serendipityHTTPPath']}archives/$currYear" . sprintf('%02s', $x) . '_short.html\'>';
@@ -1867,7 +1869,7 @@
$b = $d = '</span>';
}
- if ($x<=date("m") || $currYear < date('Y')) {
+ if ($x <= date('m') || $currYear < date('Y')) {
$out[$currYear][$x] = array($entries, $a, $b, $c, $d);
}
|