So hat etwas gedauert, aber hier meine Umsetzung.
Kalender | Termine Monat | Termine Jahr
Einfach den Inhalt der Dateien mit folgendem Code vollständig ersetzen.
<?php
# Kalender Script © by Nickel
defined ('main') or die ( 'no direct access' );
//-----------------------------------------------------------|
$title = $allgAr['title'].' :: Kalender';
$hmenu = 'Kalender';
$design = new design ( $title , $hmenu );
$design->header();
$tpl = new tpl ( 'kalender.htm' );
//-----------------------------------------------------------|
//Daten
$month = date('n');
$year = date('Y');
$gday = 0;
$view = 0;
$eid = 0;
if ($menu->getA(1) == 'v' AND is_numeric($menu->getE(1))) {
$view = $menu->getE(1);
}
if ($menu->getA(2) == 'y' AND is_numeric($menu->getE(2)) AND $menu->getE(2) > 2000 AND $menu->getE(2) < date('Y', (time()+pow(8,9)))) {
$year = $menu->getE(2);
}
if ($menu->getA(2) == 'm' AND is_numeric($menu->getE(2)) AND $menu->getE(2) > 0 AND $menu->getE(2) < 13) {
$month = $menu->getE(2);
}
if ($menu->getA(4) == 'd' AND is_numeric($menu->getE(4)) AND $menu->getE(4) > 0 AND $menu->getE(4) < 32) {
$gday = $menu->getE(4);
}
if ($menu->getA(3) == 'y' AND is_numeric($menu->getE(3)) AND $menu->getE(3) > 2000 AND $menu->getE(3) < date('Y', (time()+pow(8,9)))) {
$year = $menu->getE(3);
}
if ($menu->getA(2) == 'e' AND is_numeric($menu->getE(1))) {
$eid = $menu->getE(2);
}
//-----------------------------------------------------------|
$next_mon = $month +1;
$last_mon = $month -1;
$next_jahr = $year;
$last_jahr = $year;
if ($next_mon > 12) {
$next_jahr = $year +1;
$next_mon = 1;
}
if ($last_mon == 0) {
$last_jahr = $year -1;
$last_mon = 12;
}
//-----------------------------------------------------------|
$arr_month = array('1' => 'Januar','Februar','März','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember');
$arr_day = array('So','Mo','Di','Mi','Do','Fr','Sa');
$days = date('t',mktime(0,0,0,$month,1,$year));
$start_col = date('w',mktime(0,0,0,$month,1,$year))-1;
$rows = ceil($days/7);
$day = 1;
$data = array ();
$data_id = array ();
$aus = array();
//Daten aus der MySQL
if ($view == 2) {
$where1 = mktime(0 ,0,0,1,1,$year);
$where2 = mktime(24,0,0,12,31,$year);
} else {
$where1 = mktime(0 ,0,0,$month,1,$year);
$where2 = mktime(24,0,0,$month,date('t',$where1),$year);
}
$result = db_query("SELECT *
FROM prefix_kalender
WHERE ((time >= ".$where1." AND time < ".$where2.") OR id = ".$eid.")
AND ".$_SESSION['authright']." <= recht
ORDER BY time LIMIT 200");
while ($row = db_fetch_assoc($result)) {
$t_id = $row['id'];
$t_d = date('j', $row['time']);
$t_m = date('n', $row['time']);
$t_y = date('Y', $row['time']);
$date = mktime(0,0,0,$t_m,$t_d,$t_y);
$data_id[$t_id] = $row;
$data[$date][] = $row;
}
$ueid = 0;
if (substr($eid, 0, 3) == 999) {
$ueid = substr ($eid, 3);
}
$result = db_query("SELECT name, gebdatum, id
FROM prefix_user
WHERE MONTH(gebdatum) = ".$month."
OR id = ".$ueid."
ORDER BY MONTH(gebdatum), DAYOFMONTH(gebdatum) LIMIT 200");
while ($r = db_fetch_assoc($result)) {
list($y,$m,$d) = explode('-',$r['gebdatum']);
$date = mktime(0,0,0,$m,$d,date('Y'));
$dateA = mktime(0,0,0,$m,$d,$y);
$jetzt = time();
$alter = $jetzt - $dateA;
if ($date > $jetzt) {
$alter = date("Y",$alter) - 1970 +1;
} else {
$alter = date("Y",$alter) - 1970;
}
$row = array(
'title' => $alter.'. Geburtstag von '.$r['name'],
'text' => 'Der '.$alter.'. Geburtstag von [url=http://'.($_SERVER["HTTP_HOST"].$_SERVER["SCRIPT_NAME"]).'?user-details-'.$r['id'].'][b]'.$r['name'].'[/b][/url]',
'time' => $date + 99,
'id' => '999'.$r['id']
);
$data_id['999'.$r['id']] = $row;
$data[$date][] = $row;
}
if ($view == 0) {
$title_liste = $arr_month[$month].' '.$year;
} elseif ($view == 1 && !empty($gday)) {
$title_liste = 'Nur am '.$gday.' '.$arr_month[$month].' '.$year;
} elseif ($view == 1) {
$title_liste = 'Termine vom '.$arr_month[$month].' '.$year;
} elseif ($view == 2) {
$title_liste = 'Termine von '.$year;
}
//Template Ausgabe
if ($eid) {
$aus['MONTH'] = $arr_month[$month];
$aus['YEAR'] = $year;
$aus['TITLE'] = $data_id[$eid]['title'];
$aus['TITLE_ALIGN'] = ' align="center"';
$aus['NEXTM'] = '';
$aus['LASTM'] = '';
$tpl->set_ar_out($aus,0);
unset($aus);
} elseif ($view == 0 OR $view == 1) {
$aus['MONTH'] = $arr_month[$month];
$aus['YEAR'] = $year;
$aus['TITLE'] = $title_liste;
$aus['TITLE_ALIGN'] = ' align="center"';
$aus['NEXTM'] = '<a href="index.php?kalender-v'.$view.'-m'.$next_mon.'-y'.$next_jahr.'" title="Nächster Monat"><span class="smalspan">'.$arr_month[$next_mon].' </span>»</a>';
$aus['LASTM'] = '<a href="index.php?kalender-v'.$view.'-m'.$last_mon.'-y'.$last_jahr.'" title="Letzter Monat">«<span class="smalspan"> '.$arr_month[$last_mon].'</span></a>';
$tpl->set_ar_out($aus,0);
unset($aus);
} elseif ($view == 2) {
$aus['MONTH'] = $arr_month[$month];
$aus['YEAR'] = $year;
$aus['TITLE'] = $title_liste;
$aus['TITLE_ALIGN'] = ' align="center"';
$nyear = $year +1; $lyear = $year -1;
$aus['NEXTM'] = '<a href="index.php?kalender-v2-y'.$nyear.'" title="Nächstes Jahr"><span class="smalspan">'.$nyear.' </span>»</a>';
$aus['LASTM'] = '<a href="index.php?kalender-v2-y'.$lyear.'" title="Letztes Jahr">«<span class="smalspan"> '.$lyear.'</span></a>';
$tpl->set_ar_out($aus,0);
unset($aus);
}
//Deatilansicht
if ($eid) {
$aus['DEATIL_DATE'] = date('d.m.Y',$data_id[$eid]['time']);
$aus['DEATIL_TIME'] = date('H:i',$data_id[$eid]['time']);
$aus['DEATIL_TEXT'] = BBcode($data_id[$eid]['text']);
$tpl->set_ar_out($aus,2);
unset($aus);
}
//Liste der Tage (Monats-Ansicht)
elseif ($view == 0) {
for($i=0;$i<$days;$i++) {
$date = mktime(0,0,0,$month,$i+1,$year);
$text = '';
if (isset($data[$date])) {
foreach($data[$date] as $info) {
$text .= '<table style="width:100%;border:0px;" cellspacing="0" cellpadding="0"><tr><td style="width:15px;vertical-align:top;"><b>•</b></td><td><a href="?kalender-v'.$view.'-e'.$info['id'].'">'.$info['title'].'</a></td></tr></table>';
}
}
$aus['LIST_I'] = $i+1;
$aus['LIST_D'] = $arr_day[date('w',mktime(0,0,0,$month,$i+1,$year))];
$aus['LIST_T'] = $text;
$class = ($i % 2) ? 'Cnorm' : 'Cmite' ;
$aus['LIST_CLASS'] = ($i+1 == date('j') && $month == date('n') && $year == date('Y')) ? 'Cdark' : $class;
$tpl->set_ar_out($aus,1);
unset($aus);
}
}
// Ganzes Jahr
elseif ($view == 2) {
$i = 1;
foreach($data as $date => $data1) {
$text = '';
foreach($data1 as $info) {
$text .= '<table style="width:100%;border:0px;" cellspacing="0" cellpadding="0"><tr><td style="width:15px;vertical-align:top;"><b>•</b></td><td><a href="?kalender-v'.$view.'-e'.$info['id'].'">'.$info['title'].'</a></td></tr></table>';
}
$aus['LIST_I'] = date('d.m.Y',$date);
$aus['LIST_D'] = $arr_day[date('w',$date)];
$aus['LIST_T'] = $text;
$aus['LIST_CLASS'] = ($i % 2) ? 'Cnorm' : 'Cmite' ;
$tpl->set_ar_out($aus,1);
unset($aus);
$i++;
}
}
//Liste der Tage (Listenansicht)
elseif ($view == 1) {
//Nur ein Tag
if (isset($data) && !empty($gday)) {
$date = mktime(0,0,0,$month,$gday,$year);
$i = 1;
if (isset($data[$date])) {
foreach($data[$date] as $info) {
$text = '';
$text .= '<table style="width:100%;border:0px;" cellspacing="0" cellpadding="0"><tr><td style="width:15px;vertical-align:top;"><b>•</b></td><td><a href="?kalender-v'.$view.'-e'.$info['id'].'">'.$info['title'].'</a></td></tr></table>';
$aus['LIST_I'] = $arr_day[date('w',$date)];
$aus['LIST_D'] = date('H:i',$info['time']);
$aus['LIST_T'] = $text;
$class = ($i % 2) ? 'Cnorm' : 'Cmite';
$aus['LIST_CLASS'] = ($i+1 == date('j') && $month == date('n') && $year == date('Y')) ? 'Cdark' : $class;
$tpl->set_ar_out($aus,1);
unset($aus);
$i++;
}
}
//Ganze Liste
} elseif (isset($data)) {
$i = 1;
foreach($data as $date => $data1) {
$text = '';
foreach($data1 as $info) {
$text .= '<table style="width:100%;border:0px;" cellspacing="0" cellpadding="0"><tr><td style="width:15px;vertical-align:top;"><b>•</b></td><td><a href="?kalender-v'.$view.'-e'.$info['id'].'">'.$info['title'].'</a></td></tr></table>';
}
$aus['LIST_I'] = date('d.m.Y',$date);
$aus['LIST_D'] = $arr_day[date('w',$date)];
$aus['LIST_T'] = $text;
$class = ($i % 2) ? 'Cnorm' : 'Cmite' ;
$aus['LIST_CLASS'] = ($i+1 == date('j') && $month == date('n') && $year == date('Y')) ? 'Cdark' : $class;
$tpl->set_ar_out($aus,1);
unset($aus);
$i++;
}
} else {
$aus['LIST_I'] = '-';
$aus['LIST_D'] = '-';
$aus['LIST_T'] = '-';
$aus['LIST_CLASS'] = 'Cnorm';
$tpl->set_ar_out($aus,1);
unset($aus);
}
}
# kalender
$tpl->set('calender', getCalendar($month,$year, 'index.php?kalender-v1-m{mon}-y{jahr}-d{tag}', 'index.php?kalender-v'.$view.'-m{mon}-y{jahr}', $data));
$tpl->out(3);
$design->footer();
?>
<table align="center" border="0" cellpadding="3" cellspacing="0" width="100%">
<tr>
<td width="100%" valign="top" nowrap="nowrap" align="center" id="menubox">
<a href="index.php?kalender-v0">Kalender</a> | <a href="index.php?kalender-v1">Termine des Monats</a> | <a href="index.php?kalender-v2">Termine vom Jahr</a>
</td>
</tr>
</table>
<table width="100%" cellpadding="0" border="0" cellspacing="0">
<tr>
<td width="100%" valign="top">
<table width="100%" cellpadding="4" cellspacing="0" border="0">
<tr>
<td align="center" valign="middle" colspan="3"><b>{LASTM} {TITLE} {NEXTM}</b></td>
</tr>
{EXPLODE}
<tr class="{LIST_CLASS}">
<td align="center" valign="top" width="25" nowrap="nowrap">{LIST_I}</td>
<td align="center" valign="top" width="25" nowrap="nowrap">{LIST_D}</td>
<td width="100%">{LIST_T}</td>
</tr>
{EXPLODE}
<tr class="Cdark">
<td colspan="3">{DEATIL_DATE} - {DEATIL_TIME} Uhr</td>
</tr>
<tr class="Cnorm">
<td colspan="3">{DEATIL_TEXT}</td>
</tr>
<tr class="Cmite">
<td colspan="3" align="center"><a href="javascript:history.back()">{_lang_back}</a></td>
</tr>
{EXPLODE}
</table>
</td>
</tr>
</table>