Ich bin leider kein richtiger php-coder, daher poste mal meine Versionen:
Listenversion:
<?php
# Kalender Script © by Nickel
defined ('main') or die ( 'no direct access' );
//-----------------------------------------------------------|
$title = $allgAr['title'].' :: Kalender';
$hmenu = 'Calendar';
$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) == '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);
}
$arr_month = array('1'=>'January','February','March','April','May','June','July','August','September','October','November','December');
$arr_day = array('Su','Mo','Tue','We','Thu','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
$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);
$alter = date('Y') - $y;
$row = array(
'title' => '<font color="#00FF00">'.$alter.'. Birthday of '.$r['name'],
'text' => 'The '.$alter.'. birthday of [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 = 'Only on '.$gday.' '.$arr_month[$month].' '.$year;
} elseif ($view == 1) {
$title_liste = 'Liste ab '.$arr_month[$month].' '.$year;
}
//Template Ausgabe
$aus['MONTH'] = $arr_month[$month];
$aus['YEAR'] = $year;
$aus['TITLE'] = ($eid) ? $data_id[$eid]['title'] : $title_liste;
$aus['TITLE_ALIGN'] = ($eid) ? '' : ' align="center"';
$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 .= '<a href="?kalender-v'.$view.'-e'.$info['id'].'">'.$info['title'].'</a>; ';
}
}
$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);
}
}
//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 .= '<a href="?kalender-v'.$view.'-e'.$info['id'].'">'.$info['title'].'</a>; ';
$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 .= '<a href="?kalender-v'.$view.'-e'.$info['id'].'">'.$info['title'].'</a>; ';
}
$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();
?>
Boxversion:
<?php
# Copyright by Manuel
# Support www.ilch.de
defined ('main') or die ( 'no direct access' );
$m = date('n');
$j = date('Y');
$where1 = mktime(0 ,0,0,$m,1,$j);
$where2 = mktime(24,0,0,$m,date('t',$where1),$j);
$data = array();
$result = db_query('SELECT *
FROM prefix_kalender
WHERE (time > '.$where1.' AND time < '.$where2.')
AND '.$_SESSION['authright'].' <= recht
ORDER BY time LIMIT 50');
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[$date][] = $row;
}
echo getCalendar($m, $j, '?kalender-v1-m{mon}-y{jahr}-d{tag}', '?kalender-v0-m{mon}-y{jahr}', $data, 1);
?>
/include/includes/func/ calender.php :
<?php
# Copyright by Manuel
# Support www.ilch.de
defined ('main') or die ( 'no direct access' );
function getCalendar($mon, $jahr, $url, $urlod, $data, $cellpadding=2) {
# lege einige variablen fest
$ak_tag = date('j');
$ak_mon = date('n');
$ak_jahr = date('Y');
$days = date('t',mktime(0,0,0,$mon,1,$jahr));
$fw = str_replace(0,7,date('w',mktime(0,0,0,$mon,1,$jahr))) -1;
$next_mon = $mon +1;
$last_mon = $mon -1;
$next_jahr = $jahr;
$last_jahr = $jahr;
if ($next_mon > 12) {
$next_jahr = $jahr +1;
$next_mon = 1;
}
if ($last_mon == 0) {
$last_jahr = $jahr -1;
$last_mon = 12;
}
# erstelle return string
$return_str = '';
$return_str .= '<table class="border" cellpadding="'.$cellpadding.'" cellspacing="1" border="0">';
$return_str .= '<tr class="Chead">';
$return_str .= '<th><a href="'.str_replace('{mon}',$last_mon, str_replace('{jahr}',$last_jahr, $urlod)).'"><b><</b></a></th>';
$return_str .= '<th colspan="5" align="center">'.$mon.'. '.$jahr.'</th>';
$return_str .= '<th><a href="'.str_replace('{mon}',$next_mon, str_replace('{jahr}',$next_jahr, $urlod)).'"><b>></b></a></th>';
$return_str .= '</tr><tr class="Cdark">';
$return_str .= '<td>Mo</td><td>Tue</td><td>We</td><td>Thu</td><td>Fr</td><td>Sa</td><td>Su</td>';
$return_str .= '</tr><tr class="Cnorm">';
$return_str .= str_repeat ('<td> </td>', $fw);
for($i=1;$i<=$days;$i++) {
if (($i+$fw-1) % 7 == 0 AND $i > 1) { $return_str .= '</tr><tr>'; }
if ($i == $ak_tag AND $mon == $ak_mon AND $jahr == $ak_jahr) { $class = 'Cmite'; } else { $class = 'Cnorm'; }
$surl = str_replace('{mon}', $mon, str_replace('{tag}',$i, str_replace('{jahr}',$jahr, $url)));
if (isset($data[mktime (0,0,0,$mon,$i,$jahr)]))
{ $out_i = '<td class="'.$class.'" align="center"><a href="'.$surl.'"><font color="#000000"><b>'.$i.'</b></font></a></td>'; }
else
{ $out_i = '<td class="'.$class.'" align="center">'.$i.'</td>'; }
$return_str .= $out_i;
}
$return_str .= str_repeat ('<td class="Cnorm"> </td>', (7-(($i+$fw-1) % 7)) % 7 );
$return_str .= '</tr></table>';
return ($return_str);
}
?>