diff options
author | Ludovic Pouzenc <ludovic@pouzenc.fr> | 2018-06-30 11:22:30 +0200 |
---|---|---|
committer | Ludovic Pouzenc <ludovic@pouzenc.fr> | 2018-06-30 11:22:30 +0200 |
commit | 50b0ff7533657a8edb7a0d9645699559c50ea712 (patch) | |
tree | 54fb5d7b6efc44d26aef24a6fa055e97b65f74b6 /maquette/ical.php | |
parent | f55d097d97c3c81382c441f612b0ce2881e63334 (diff) | |
download | 2007-AWOR-50b0ff7533657a8edb7a0d9645699559c50ea712.tar.gz 2007-AWOR-50b0ff7533657a8edb7a0d9645699559c50ea712.tar.bz2 2007-AWOR-50b0ff7533657a8edb7a0d9645699559c50ea712.zip |
Strip retours chariot Windows pour diff propre
Diffstat (limited to 'maquette/ical.php')
-rw-r--r-- | maquette/ical.php | 120 |
1 files changed, 60 insertions, 60 deletions
diff --git a/maquette/ical.php b/maquette/ical.php index 7dc43e3..1a1e44e 100644 --- a/maquette/ical.php +++ b/maquette/ical.php @@ -1,60 +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);
- }
-}
-
-?>
+<?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); + } +} + +?> |