[geeklog-devel] Solution for Bug 0000853

Stan Palatnik yankees26an at gmail.com
Sat Apr 11 13:42:29 EDT 2009


Hello,
My name is Stanislav Palatnik. I've applied for gsoc 2009. I've looked over
some bugs and have a proposal to solve bug 0000853
Basically it doesn't check if the date was valid.
Current line: search.class.php

if (!empty($this->_dateStart) AND !empty($this->_dateEnd)) {


It works fine if the date format is valid. Even if you enter 1921-33-44 to
2034-22-33 it will still return the results. However, if the format is
different IE 192-133-44 then you(well me at least) will get a rather
pointless error message "Unfortunately, an error has occurred rendering this
page. Please try again later."
The simplest fix is including checkdate() in both the start and end dates

fixed line:

         if (!empty($this->_dateStart) && !empty($this->_dateEnd) &&
checkdate($DE[1],$DE[2],$DE[0]) && checkdate($DS[1],$DS[2],$DS[0])) {

Another faster solution would be just to check if mkdate returns false

                    $startdate = mktime(0,0,0,$DS[1],$DS[2],$DS[0]);
                    $enddate = mktime(23,59,59,$DE[1],$DE[2],$DE[0]);
                    if($startdate!=false && $enddate!=false)  $sql .= "AND
(UNIX_TIMESTAMP({$_TABLES['comments']}.date) BETWEEN '$startdate' AND
'$enddate') ";

For even faster peformance, explicity put !=false to make PHP use less
guessing

--
Warmly,

Stanislav
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist8.pair.net/pipermail/geeklog-devel/attachments/20090411/6a0ada89/attachment.html>


More information about the geeklog-devel mailing list