diff options
author | Ludovic Pouzenc <ludovic@pouzenc.fr> | 2018-06-30 10:03:15 +0200 |
---|---|---|
committer | Ludovic Pouzenc <ludovic@pouzenc.fr> | 2018-06-30 10:03:15 +0200 |
commit | 756f0fa75c7d8e18188dffdfbdd4416651dca9fe (patch) | |
tree | 18b6bae18a08982d5e707954eebde04d05f3d632 /maquette_old/ical.php | |
parent | 30238f5847b418645983a4efddb13f087c99e585 (diff) | |
download | 2007-AWOR-756f0fa75c7d8e18188dffdfbdd4416651dca9fe.tar.gz 2007-AWOR-756f0fa75c7d8e18188dffdfbdd4416651dca9fe.tar.bz2 2007-AWOR-756f0fa75c7d8e18188dffdfbdd4416651dca9fe.zip |
Première maquette 2007-02-03+09:05:40 - 2007-02-03+22:31:43
Diffstat (limited to 'maquette_old/ical.php')
-rw-r--r-- | maquette_old/ical.php | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/maquette_old/ical.php b/maquette_old/ical.php new file mode 100644 index 0000000..7dc43e3 --- /dev/null +++ b/maquette_old/ical.php @@ -0,0 +1,60 @@ +<?php
+include ('connect.inc.php');
+function generationIcal ($identifiant)
+{
+ $result = mysql_query("SELECT DISTINCT R.idR,R.objetR,P.courrielP,C.dateHeure,C.duree,R.lieuR,R.ordreJourR,L.idL FROM Liste L,Reunion R,Appartenir A,Creneau C,Personne P WHERE ((A.idP = $identifiant AND A.idL = L.idL) OR R.idP_Orga = $identifiant) AND R.idL = L.idL AND C.idC = R.idC_Fixe AND P.idP = R.idP_Orga");
+ if (mysql_num_rows($result)>0)
+ {
+ $nameiCal = "iCal" . $identifiant . ".ics";
+ $textiCal = "BEGIN:VCALENDAR\r\n" . "VERSION:2.0\r\n";
+ for($i=0;$i<mysql_num_rows($result);$i++)
+ {
+ $row = mysql_fetch_array($result);
+ $textiCal .= "BEGIN:VEVENT\r\n" . "UID:$identifiant." . $row["idR"] . "\r\n";
+ $textiCal .= "SUMMARY:" . $row["objetR"] . " (" . $row["courrielP"] . ")" ."\r\n";
+ list($date,$time) = explode(" ",$row["dateHeure"]);
+ list($year,$month,$day) = explode("-",$date);
+ list($hour,$minute,$seconde) = explode(":",$time);
+ $textiCal .= "DTSTART:$year$month$day"."T"."$hour$minute$seconde"."\r\n";
+ $endDate = date("Ymd", mktime((int)$hour, (int)((int)$minute+(int)$row["duree"]), (int)$seconde,(int)$month, (int)$day, (int)$year));
+ $endTime = date("His", mktime((int)$hour, (int)((int)$minute+(int)$row["duree"]), (int)$seconde,(int)$month, (int)$day, (int)$year));
+ $textiCal .= "DTEND:$endDate"."T"."$endTime"."\r\n" ;
+ $textiCal .= "LOCATION:".$row["lieuR"]."\r\n";
+ $textiCal .= "DESCRIPTION:".$row["ordreJourR"]."\r\n";
+ $result_p = mysql_query("SELECT P.courrielP FROM Appartenir A,Personne P WHERE A.idP = P.idP AND A.idL = " . $row['idL']);
+ for($j=0;$j<mysql_num_rows($result_p);$j++)
+ {
+ $row_p = mysql_fetch_array($result_p);
+ $textiCal .= "ATTENDEE:mailto:" . $row_p['courrielP'] . "\r\n";
+ }
+ $textiCal .= "URL:http://awor.free.fr/\r\n";
+ $textiCal .= "END:VEVENT\r\n";
+ }
+ $textiCal .= "END:VCALENDAR\r\n";
+ if ($f=fopen("iCal/".$nameiCal,"wb")) if (fputs($f, $textiCal) == true) {fclose($f); return($nameiCal);}
+ fclose($f);
+ return ("erreur");
+ }
+ else
+ {
+ return ("none");
+ }
+}
+
+if (isset($_GET["id"])) //a remplacer par isset($_SESSION["id"])
+{
+ $res = generationIcal($id);
+ if ($res != "none" && res != "erreur")
+ {
+ header("Content-disposition: attachment; filename=$res");
+ header("Content-Type: application/force-download");
+ header("Content-Transfer-Encoding: text/ics\n"); // Surtout ne pas enlever le \n
+ header("Content-Length: ".filesize("iCal/".$res));
+ header("Pragma: no-cache");
+ header("Cache-Control: must-revalidate, post-check=0, pre-check=0, public");
+ header("Expires: 0");
+ readfile("iCal/".$res);
+ }
+}
+
+?>
|