Ein Kalender, wenn ihr das Copyright drinlasst dürft ihr ihn auch benutzen :D
Ich weiß das ist nicht die beste Methode, aber es ist eben in 5min aus LW und ner Tastatur entstanden :D
Hat sogar noch ne kleine Notizfunktion ohne DB abbekommen :)
Ich lass es unkommentiert, wenn ihr es erklärt wollt, schickt mir ne PN.
Sollte aber mit ein bisschen PHP-Erfahrung verständlich sein.
Der Teil zur Anzeige ist eben etwas... naja, unverständlich XD
PHP
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<title>Kalender</title>
</head>
<body>
<?php
if (!is_dir("./notices/")) {
mkdir("./notices/");
}
setlocale(LC_TIME, 'de_DE');
$date = (isset($_REQUEST['d']) && $_REQUEST['d'] <= 2000000000 && $_REQUEST['d'] >= 0) ? $_REQUEST['d'] : time();
$linkOn = '?today';
if (isset($_REQUEST['d']) && $_REQUEST['d'] <= 2000000000 && $_REQUEST['d'] >= 0) {
$linkOn = '?d='.$_REQUEST['d'];
}
$fileDate = mktime(0, 0, 0, date('n', $date), date('j', $date), date('Y', $date));
$time = time();
$compDate = mktime(0, 0, 0, date('n', $time), date('j', $time), date('Y', $time));
$compDate2 = mktime(0, 0, 0, date('n', $date), date('j', $date), date('Y', $date));
if (isset($_POST['noticeText'], $_GET['notices'])) {
file_put_contents('./notices/'.$fileDate.'.txt', $_POST['noticeText']);
if (isset($_POST['kill'])) {
if ($dh = opendir("./notices/")) {
while (($file = readdir($dh)) !== false) {
if ($file != '.' && $file != '..') @unlink("./notices/".$file);
}
closedir($dh);
}
}
}
$monthDays = date('t', $date);
$calendarStart = mktime(0, 0, 0, date('n', $date), 1, date('Y', $date));
$calendarStartDay = date('N', $calendarStart);
$calendarEndDay = date('N', mktime(0, 0, 0, date('n', $date), $monthDays, date('Y', $date)));
$month = date('M', $date);
$switch = date('L', $date);
switch ($month) {
case('Jan'):
$month = 'Januar';
$days = 31;
$season = 'Winter';
break;
case('Feb'):
$month = 'Februar';
$days = ($switch) ? 29 : 28;
$season = 'Winter';
break;
case('Mar'):
$month = 'März';
$days = 31;
$season = 'Frühling';
break;
case('Apr'):
$month = 'April';
$days = 30;
$season = 'Frühling';
break;
case('May'):
$month = 'Mai';
$days = 31;
$season = 'Frühling';
break;
case('Jun'):
$month = 'Juni';
$days = 30;
$season = 'Sommer';
break;
case('Jul'):
$month = 'Juli';
$days = 31;
$season = 'Sommer';
break;
case('Aug'):
$month = 'August';
$days = 31;
$season = 'Sommer';
break;
case('Sep'):
$month = 'September';
$days = 30;
$season = 'Herbst';
break;
case('Oct'):
$month = 'Oktober';
$days = 31;
$season = 'Herbst';
break;
case('Nov'):
$month = 'November';
$days = 30;
$season = 'Herbst';
break;
case('Dec'):
$month = 'Dezember';
$days = 31;
$season = 'Winter';
break;
}
echo 'Es ist: '.date('H:i:s', time()).' Uhr!<br><br>';
?>
<table border="1" style="text-align:center;font-size:14px" cellpadding="10">
<caption>
<a style="text-decoration:none;color:black;" href="?d=<?php echo mktime(0, 0, 0, date('n', $date), date('j', $date), date('Y', $date) - 1); ?>">
«
</a>
<a style="text-decoration:none;color:black;" href="?d=<?php echo mktime(0, 0, 0, date('n', $date) - 1, date('j', $date), date('Y', $date)); ?>">
<
</a>
<?php if ($compDate2 > $compDate) {echo ' <a href="?today" style="text-decoration:none;color:black;">•</a>';} ?>
<?php echo $season.' '.strftime('%Y', $date).', '.$month; ?>
<?php if ($compDate2 < $compDate) {echo '<a href="?today" style="text-decoration:none;color:black;">•</a> ';} ?>
<a style="text-decoration:none;color:black;" href="?d=<?php echo mktime(0, 0, 0, date('n', $date) + 1, date('j', $date), date('Y', $date)); ?>">
>
</a>
<a style="text-decoration:none;color:black;" href="?d=<?php echo mktime(0, 0, 0, date('n', $date), date('j', $date), date('Y', $date) + 1); ?>">
»
</a>
</caption>
<thead>
<tr>
<th> KW </th>
<th> Mo </th>
<th> Di </th>
<th> Mi </th>
<th> Do </th>
<th> Fr </th>
<th> Sa </th>
<th> So </th>
</tr>
</thead>
<tbody>
<tr>
<?php
$calendarShowing = 1 - $calendarStartDay;
echo '<td><i>KW '.(date('W', strtotime($calendarShowing.' day', $calendarStart))).'</i></td>';
for($i = 1; $i <= 42; $i++) {
$calendarShowing = $i - $calendarStartDay;
$calendarToday = strtotime($calendarShowing.' day', $calendarStart);
$calendarTodayDay = date('j', $calendarToday);
if(date('dmY', $date) == date('dmY', $calendarToday))
echo '<td><b>'.$calendarTodayDay.'</b></td>';
elseif($calendarShowing >= 0 && $calendarShowing < $monthDays)
echo '<td><a style="text-decoration:none;color:black;" href="?d='.$calendarToday.'">'.$calendarTodayDay.'</a></td>';
else
echo '<td><a style="text-decoration:none;color:gray;" href="?d='.$calendarToday.'">'.$calendarTodayDay.'</a></td>';
if(date('N', $calendarToday) == 7 && $i != 42) {
echo '</tr><tr><td><i>KW '.(date('W', $calendarToday + 86400)).'</i></td>';
}
}
?>
</tbody>
</table>
<br>
Notizen zu diesem Datum:<br>
<form action="<?php echo $linkOn; ?>¬ices=1" method="post">
<textarea cols="60" rows="9" name="noticeText"><?php
if (file_exists('./notices/'.$fileDate.'.txt')) {
echo htmlentities(file_get_contents('./notices/'.$fileDate.'.txt'));
}
?></textarea>
<br>
<input type="submit" value="Notizen für diesen Tag aktualisieren">
<br>
<input type="checkbox" id="killConf"><input type="submit" onclick="if (!document.getElementById('killConf').checked) return false;if (!confirm('Moechtest du wirklich alle Notizen loeschen?')) return false;if (!confirm('Wirklich? Es erfolgt keine weitere Sicherheitsabfrage!')) return false;" name="kill" value="Alle Notizen entfernen">
</form>
<br><hr>
© 2011 mewking
</body>
</html>
Alles anzeigen
@Edit1: Die KW 0 und KW 53 gibt es nun nichtmehr.
@Edit2: Hab mal die Mini-Navigation in der Caption verbessert, sodass die Sprünge genauer werden
Ich empfange nur konstruktive Kritik :P