Zurück zur iCal-Seite

<?php
/**
  * iCal function
  * @param array $addrs: Array of arrays with indices
  * "Vorname", "Name", "Mail"
  * @param int $year Year the calendar should be created for
  */
  
function iCal($addrs$year="") {
    
$thisyear date("Y");
    if ((int) 
$year < (int) $thisyear$year $thisyear;

    
// (prodid, method (Publish), download directory)
    
$iCal = new iCal('-//Privat//NONSGML Adressbuch//EN'1'');

    
// einheitliche Daten
    
$where '';
    
$transp 1// transparent: only takes time if one attends the party
    
$category = array('Geburtstag');
    
$class 1// 0: private, 1: public, 2: confidential
    
$lang "de";
    
$priority 5// average
    
$freq 7// yearly
    
$recend ''// recurs forever
    
$interval 1// every year
    
$days = array(0,1,2,3,4,5,6); // birthday can be any day (0=Sunday)
    
$startday 1// week starts on Monday
    
$exception ''// exclude no dates
    
$alarm 12 60// alarm x minutes before event
    
$status 0// tentative
    
$url '';

    
$self "Jens Hatlak";
    
$selfmail "jh@junetz.de";

    foreach (
$addrs as $addr) {
      if (
$addr["Gebtag"]!='') {
        
$name $addr["Vorname"]." ".$addr["Name"];

        
$mail sprintf("mailto:%s"$addr["Mail"]);
        
// start (mktime): h,i,s,m,d,Y
        
$date explode('.'$addr["Gebtag"]);

        
$start mktime(0,0,0,$date[1],$date[0],$year);
        
$end   $start + (24 3600)-1;
        
$desc  $name." hat Geburtstag";
        
$title "* ".$name;
        
// Attendees: person celebrating birthday (0=chair) and self (2=opt)
        
$attendees = array($name => $addr["Mail"].",0",
                           
$self => $selfmail.",2");
        
$iCal->addEvent($mail$start$end$where$transp,
                        
$category$desc$title$class$attendees,
                        
$priority$freq$recend$interval$days$startday,
                        
$exception$alarm$status$url$lang);
      }
    }

    
header('Content-Type: text/Calendar; name=Geburtstage.ics');
    
header('Content-Disposition: attachment; filename=Geburtstage.ics');
    echo 
$iCal->getOutput();
    exit;
  }
?>