31) { ++$targetMonth; if($targetMonth > 12) { ++$targetYear; $targetMonth = 1; } if(monthHas31days($targetMonth)) $targetDate = $targetDate % 31 +1; elseif(monthHas30days($targetMonth)) $targetDate = $targetDate % 30 +1; else $targetDate = $targetDate % 28 +1; } } elseif(monthHas30days($targetMonth)) { if($targetDate > 30) { ++$targetMonth; if(monthHas31days($targetMonth)) $targetDate = $targetDate % 31 +1; elseif(monthHas30days($targetMonth)) $targetDate = $targetDate % 30 +1; else $targetDate = $targetDate % 28 +1; } } else { if($targetDate > 28) { $targetMonth = 3; $targetDate = $targetDate % 31 +1; } } } return $targetYear . "-" . str_pad($targetMonth, 2, "0", STR_PAD_LEFT) . "-" . str_pad($targetDate, 2, "0", STR_PAD_LEFT); } function showCalendar() { for($offset = -7; $offset <= 20; $offset++) { if(!($offset % 7)) echo "
"; $thisTime = time() + $offset * 24 * 60 * 60; $date = date('d/m', $thisTime); echo "$date "; } echo "
"; } function showInputMode() { PHP?>
År:
Månad:
Datum:
Rubrik:
Ingress:
Text:
Länk 1:
Länk 2:
Bild 1:
Bild 2:
Bild 3:
"; $query = "select * from calendar where date='$date'"; $result = mysql_query($query); $line = @mysql_fetch_array($result); if($line != "") { echo "$line[rubrik]
$line[ingress]
$line[date]
$line[kropp]
"; $links = explode(';', $line[links]); foreach($links as $link) { if($link != '') echo "$link
\n"; } $images = explode(';', $line[images]); foreach($images as $image) { if($image != '') echo "
\n"; } } else showNoSchedule(); } else { showInputMode(); } PHP?>