Posted by: Anonymous Coward
on March 12, 2007 06:37 PM
Naw, I agree. Utter garbage.
First, your table declarations are old school. The widths and colors need to be moved out of the HTML and into a stylesheet.
Second, why are you using and array and epoch to figure out the date? Why go through all the overhead. The computer already knows what the date is. Let it do the math for you.
Third, where did the switch statement come from? Just count to 7 to figure out when to start a new row.
Finally, your reason for checking the value of the query string is, IMO, premature. Presumably, no matter where this is used, you will need a form and form handler to put in a database. I think the validation would be better handled there, just before insert, instead of here in the browser where it is still vulnerable.
This little note from the docs are all that you need: "mktime() is useful for doing date arithmetic and validation, as it will automatically calculate the correct value for out-of-range input." With a little creative math, you don't even need to know the actual date. Try this instead: No arrays, no switch statements, and presentation separated from content.
<tt><html><head> <style type="text/css"> <!-- a:link { color : #B22222; text-decoration: none; } a:visited { color : #B22222; text-decoration : none; } a:hover { color : #000080; text-decoration : none; }
foreach($WeekDays as $weekday) { echo "<td>$weekday</td>\n"; } echo "</tr>\n<tr>\n"; $day = 1; // offset is difference between the day displayed and number day of the week. // if the first of month is on Wed, then offset will be negative on Sun, Mon, Tues. for ($offset = $day - $firstweekdayofmonth; $day <= $lastdayofmonth; $offset++){ $picked = ($currday == $day)?"picked":""; echo "<td><span class=\"$picked\">"; $weekdaycounter++; if ($offset > 0){ echo "<a href=\"calender.php?date=".$curryear.sprintf("%02<nobr>d<wbr></nobr> ",$currmonth).sprintf("%02d",$day)."\">";
Re:Garbage. Disappointing garbage.
Posted by: Anonymous Coward on March 12, 2007 06:37 PMFirst, your table declarations are old school. The widths and colors need to be moved out of the HTML and into a stylesheet.
Second, why are you using and array and epoch to figure out the date? Why go through all the overhead. The computer already knows what the date is. Let it do the math for you.
Third, where did the switch statement come from? Just count to 7 to figure out when to start a new row.
Finally, your reason for checking the value of the query string is, IMO, premature. Presumably, no matter where this is used, you will need a form and form handler to put in a database. I think the validation would be better handled there, just before insert, instead of here in the browser where it is still vulnerable.
This little note from the docs are all that you need: "mktime() is useful for doing date arithmetic and validation, as it will automatically calculate the correct value for out-of-range input." With a little creative math, you don't even need to know the actual date. Try this instead: No arrays, no switch statements, and presentation separated from content.
#