Skip to content
Extraits de code Groupes Projets
Valider 2fa8059c rédigé par Animation des soirees's avatar Animation des soirees
Parcourir les fichiers

iCalendar

parent 5c54e227
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
<?php
header("Content-Type: text/calendar");
header('Content-Disposition: inline; filename=calendar.ics');
// the iCal date format. Note the Z on the end indicates a UTC timestamp.
define('DATE_ICAL', 'Ymd\THis');
$bdd = new PDO('mysql:host=mysql.iiens.net;dbname=assoce_nightiies', 'assoce_nightiies', 'VwuQREP5JwJQTF5h', array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING));
// max line length is 75 chars. New line is \\n
$output = "BEGIN:VCALENDAR
VERSION:2.0
METHOD:PUBLISH
PRODID:-//Sam events//NONSGML//EN
X-WR-CALNAME:Sam events
BEGIN:VTIMEZONE
TZID:UTC
BEGIN:STANDARD
TZOFFSETFROM:+0000
TZOFFSETTO:+0000
DTSTART:".gmdate(DATE_ICAL)."
END:STANDARD
END:VTIMEZONE\n\n";
// get events
$events = $bdd->prepare('SELECT id, title, date, place, description
FROM sam
ORDER BY date');
$events->execute();
// loop over events
while ($event = $events->fetch()) {
$output .=
"BEGIN:VTIMEZONE
TZID:Europe/Paris
BEGIN:STANDARD
TZOFFSETFROM:+0100
TZOFFSETTO:+0100
DTSTART;TZID=UTC:".gmdate(DATE_ICAL)."
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
UID:".$event[0]."
DTSTAMP;TZID=Europe/Paris:".gmdate(DATE_ICAL)."
DTSTART;TZID=UTC;TZID=Europe/Paris:" . date(DATE_ICAL, $event[2]) . "
DTEND;TZID=UTC;TZID=Europe/Paris:" . date(DATE_ICAL, $event[2] + 5*3600) . "
SUMMARY:".str_replace(',', '\\,', $event[1])."
DESCRIPTION:".str_replace(',', '\\,', $event[4])."
LOCATION:".$event[3]."
END:VEVENT\n\n";
}
// close calendar
$output .= "END:VCALENDAR";
echo str_replace("\n", "\r\n", $output);
?>
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter