| @@ -1,21 +1,64 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | if(isset($_GET['t']) && isset($_GET['sd']) && isset($_GET['ed']) && isset($_GET['d']) && isset($_GET['a']) && isset($_GET['u'])){ |
| 3 | - date_default_timezone_set('Europe/Paris') ; | |
| 4 | - header("content-type:text/x-vcalendar"); | |
| 3 | + header("content-type:text/".(isset($mime)?$mime:'x-icalendar')); | |
| 5 | 4 | header("Pragma: public"); |
| 6 | 5 | header("Expires: 0"); |
| 7 | 6 | header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); |
| 8 | 7 | header("Cache-Control: public"); |
| 9 | - header("Content-Disposition: attachment; filename=".$_GET['u'].".ics;" ); | |
| 10 | - echo"BEGIN:VCALENDAR\r\nVERSION:2.0\r\n"; | |
| 11 | - $sta = array('ACCEPTED','COMPLETED'); | |
| 12 | - $mt = strtotime($_GET['sd']); | |
| 13 | - $vdat = date("Ymd",$mt).'T'.date("His",$mt).'Z'; | |
| 8 | + header("Content-Disposition: attachment; filename=".$_GET['u'].'.'.(isset($format)?$format:'ics').';' ); | |
| 9 | + | |
| 10 | + $date_start = $_GET['sd']; | |
| 14 | 11 | $vtz = $_GET['tz']; |
| 15 | - $mte = strtotime($_GET['ed']); | |
| 16 | - $vdate = date("Ymd",$mte).'T'.date("His",$mte).'Z'; | |
| 17 | - //str_replace('-','',$m_date).'T'.str_replace(':','',$m_heure).'Z'; | |
| 18 | - echo"BEGIN:VEVENT\r\nPRODID:agenda_eelv\r\nSUMMARY:".stripslashes($_GET['t'])."\r\nUID:".$_GET['u']."\r\nLOCATION:".stripslashes($_GET['a'])."\r\nDTEND$vtz:$vdate\r\nDTSTART$vtz:$vdat\r\nDESCRIPTION:".stripslashes($_GET['d'])."\r\nEND:VEVENT\r\n"; | |
| 19 | - echo"END:VCALENDAR\r\n"; | |
| 12 | + $gmt = $_GET['gmt']; | |
| 13 | + $date_end = $_GET['ed']; | |
| 14 | + | |
| 15 | + $separator = "\n"; | |
| 16 | + | |
| 17 | + $props = array(); | |
| 18 | + | |
| 19 | + // General | |
| 20 | + $props[] = 'BEGIN:VCALENDAR'; | |
| 21 | + $props[] = 'PRODID://WordPress//Event-Post V'. file_get_contents(('../VERSION')).'//EN'; | |
| 22 | + $props[] = 'VERSION:2.0'; | |
| 23 | + | |
| 24 | + // Timezone | |
| 25 | + if(!empty($vtz)){ | |
| 26 | + array_push($props, | |
| 27 | + 'BEGIN:VTIMEZONE', | |
| 28 | + 'TZID:'.$vtz, | |
| 29 | + 'BEGIN:DAYLIGHT', | |
| 30 | + 'TZOFFSETFROM:+0100', | |
| 31 | + 'TZOFFSETTO:'.($gmt).'00', | |
| 32 | + //'TZNAME:CEST', | |
| 33 | + 'DTSTART:19700329T020000', | |
| 34 | + 'RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3', | |
| 35 | + 'END:DAYLIGHT', | |
| 36 | + 'BEGIN:STANDARD', | |
| 37 | + 'TZOFFSETFROM:'.($gmt).'00', | |
| 38 | + 'TZOFFSETTO:+0100', | |
| 39 | + 'TZNAME:CET', | |
| 40 | + 'DTSTART:19701025T030000', | |
| 41 | + 'RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10', | |
| 42 | + 'END:STANDARD', | |
| 43 | + 'END:VTIMEZONE' | |
| 44 | + ); | |
| 45 | + } | |
| 46 | + | |
| 47 | + // Event | |
| 48 | + array_push($props, | |
| 49 | + 'BEGIN:VEVENT', | |
| 50 | + 'SUMMARY:'.stripslashes($_GET['t']), | |
| 51 | + 'UID:'.$_GET['u'], | |
| 52 | + 'LOCATION:'.stripslashes($_GET['a']), | |
| 53 | + 'DTSTART'.(!empty($vtz)?';TZID='.$vtz:'').':'.$date_start.(!empty($vtz)?'':'Z'), | |
| 54 | + 'DTEND'.(!empty($vtz)?';TZID='.$vtz:'').':'.$date_end.(!empty($vtz)?'':'Z'), | |
| 55 | + 'DESCRIPTION:'.stripslashes($_GET['d']), | |
| 56 | + 'END:VEVENT' | |
| 57 | + ); | |
| 58 | + | |
| 59 | + // End | |
| 60 | + $props[] = 'END:VCALENDAR'; | |
| 61 | + | |
| 62 | + echo implode($separator, $props); | |
| 20 | 63 | } |
| 21 | 64 | ?> |