Browse Source

started calendar iCal export

master
n0m1s 11 years ago
parent
commit
3faa820a68
8 changed files with 127 additions and 0 deletions
  1. +3
    -0
      .htaccess
  2. +0
    -0
      .htaccess~
  3. +34
    -0
      calendar.php
  4. +34
    -0
      calendar.php~
  5. +23
    -0
      getEvents.php
  6. +23
    -0
      getEvents.php~
  7. +10
    -0
      kiwi.ics~
  8. BIN
      testdb.db

+ 3
- 0
.htaccess View File

@ -0,0 +1,3 @@
RewriteEngine on
RewriteRule ^kiwi\.ics$ calendar.php [L]

+ 0
- 0
.htaccess~ View File


+ 34
- 0
calendar.php View File

@ -0,0 +1,34 @@
<?php
# if(!isset($_POST["y"]))
# {
# header("Location:.");
# exit;
# }
header('Content-type: text/calendar; charset=utf-8');
header('Content-Disposition: inline; filename=calendar.ics');
include("./getEvents.php");
$icalheader = "BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//hacksw/handcal//NONSGML v1.0//EN"
$icalfooter = "END:VCALENDAR";
#"BEGIN:VEVENT
#UID:" . md5(uniqid(mt_rand(), true)) . "@yourhost.test
#DTSTAMP:" . gmdate('Ymd').'T'. gmdate('His') . "Z
#DTSTART:19970714T170000Z
#DTEND:19970715T035959Z
#SUMMARY:Bastille Day Party"
$events = getEvents();
echo $icalheader;
foreach($events as $event)
{
echo "BEGIN:VEVENT
SUMMARY:".$event["titre"]."
"."END:VEVENT";
}
echo $icalfooter;
print_r($events);
?>

+ 34
- 0
calendar.php~ View File

@ -0,0 +1,34 @@
<?php
# if(!isset($_POST["y"]))
# {
# header("Location:.");
# exit;
# }
header('Content-type: text/calendar; charset=utf-8');
header('Content-Disposition: inline; filename=calendar.ics');
include("./getEvents.php");
$icalheader = "BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//hacksw/handcal//NONSGML v1.0//EN"
$icalfooter = "END:VCALENDAR";
#"BEGIN:VEVENT
#UID:" . md5(uniqid(mt_rand(), true)) . "@yourhost.test
#DTSTAMP:" . gmdate('Ymd').'T'. gmdate('His') . "Z
#DTSTART:19970714T170000Z
#DTEND:19970715T035959Z
SUMMARY:Bastille Day Party"
$events = getEvents();
echo $icalheader;
foreach($events as $event)
{
echo "BEGIN:VEVENT
SUMMARY:".$event["titre"]."
"."END:VEVENT";
}
echo $icalfooter;
print_r($events);
?>

+ 23
- 0
getEvents.php View File

@ -0,0 +1,23 @@
<?php
# if(!isset($_POST["y"]))
# {
# header("Location:.");
# exit;
# }
function getEvents()
{
try
{
$pdo = new PDO("sqlite:testdb.db");
}
catch(Exception $e)
{
echo("Impossible d'acceder à la base de donnée");
die();
}
$stmt = $pdo->prepare("SELECT * FROM events");
$stmt->execute();
$result = $stmt->fetchAll();
return $result;
}
?>

+ 23
- 0
getEvents.php~ View File

@ -0,0 +1,23 @@
<?php
# if(!isset($_POST["y"]))
# {
# header("Location:.");
# exit;
# }
function getEvents()
{
try
{
$pdo = new PDO("sqlite:testdb.db");
}
catch(Exception $e)
{
echo("Impossible d'acceder à la base de donnée");
die();
}
$stmt = $pdo->prepare("SELECT * FROM events");
$stmt->execute();
$result = $stmt->fetchAll();
return result;
}
?>

+ 10
- 0
kiwi.ics~ View File

@ -0,0 +1,10 @@
<?php
# if(!isset($_POST["y"]))
# {
# header("Location:.");
# exit;
# }
include("./getEvents.php");
$events = getEvents();
?>

BIN
testdb.db View File


Loading…
Cancel
Save