', $pcont)[0]); if (sizeof($pbits) > 1) { $postpbits=explode("/" . "/ ", explode("/" . "/ " . (1 + $_GET['msg']) . " ", $pbits[-1 + sizeof($pbits)])[0]); $msg=""; $okay=true; for ($i=0; $i Calendar *.ics file creation - RJM Programming - November, 2016

" . $msg . "

"; } else { echo ""; } } else if (!isset($_POST['id'])) { date_default_timezone_set('Australia/Perth'); $qbits=@file_get_contents("ics_attachment.php"); $msgno=1; while (strpos($qbits, "/" . "/ " . $msgno . " ") !== false) { $msgno++; } echo " Calendar *.ics file creation - RJM Programming - November, 2016

Create Calendar iCal File

RJM Programming

November, 2016

Thanks to https://gist.github.com/vtedesco/5671155



Title:

Address:

Description:

Start Date (YYYYmmdd:HH24MISS) Local Time:

End Date (YYYYmmdd:HH24MISS) Local Time:

Subtitle:

Event
Recall
Text:

"; } else { if (isset($_POST['eventwords']) && isset($_POST['id'])) { $ptmsg=explode(" ", "/" . "/ " . $_POST['id'] . " " . urldecode($_POST['eventwords'])); //echo sizeof($ptmsg); if (sizeof($ptmsg) > 3) { if ($ptmsg[2] != "") { //echo "here"; //exit; file_put_contents("ics_attachment.php", explode('?' . '>', file_get_contents("ics_attachment.php"))[0] . "\n/" . "/ " . $_POST['id'] . " " . str_replace("\n", "\n/" . "/ ", str_replace('?' . '>', '', urldecode($_POST['eventwords']))) . "\n" . "?" . ">"); } else { $x=""; } } else { $x=""; } } // Fetch vars $event = array( 'id' => $_POST['id'], 'title' => urldecode($_POST['title']), 'address' => urldecode($_POST['address']), 'description' => urldecode($_POST['description']), 'datestart' => $_POST['datestart'], 'dateend' => $_POST['dateend'], 'address' => urldecode($_POST['stage']) ); // iCal date format: yyyymmddThhiissZ // PHP equiv format: Ymd\This // The Function function dateToCal($time) { date_default_timezone_set('UTC'); //echo "\n" . date('Ymd\This', $time) . 'Z'; return date('Ymd\This', $time) . 'Z'; } function tzbit($ts) { $outts=$ts; if (isset($_POST['tz'])) { if ($_POST['tz'] != "") { $di="PT" . str_replace("-","",urldecode($_POST['tz'])) . "H"; $parsed_date = DateTime::createFromFormat('Ymd:His', $ts); if (strpos(urldecode($_POST['tz']), "-") !== false) { $parsed_date->sub(new DateInterval($di)); } else { $parsed_date->add(new DateInterval($di)); } $outts = $parsed_date->format('Ymd:His'); //echo $outts . " " . $di . " "; } } return $outts; } // Build the ics file $ical = 'BEGIN:VCALENDAR VERSION:2.0 PRODID:-//hacksw/handcal//NONSGML v1.0//EN CALSCALE:GREGORIAN BEGIN:VEVENT DTEND:' . str_replace(':','T',tzbit($event['dateend'])) . 'Z UID:' . md5($event['title']) . ' DTSTAMP:' . time() . ' LOCATION:' . addslashes($event['address']) . ' DESCRIPTION:' . addslashes($event['description']) . ' URL;VALUE=URI:http://www.rjmprogramming.com.au/PHP/ics_attachment.php?msg=' . $event['id'] . ' SUMMARY:' . addslashes($event['title']) . ' DTSTART:' . str_replace(':','T',tzbit($event['datestart'])) . 'Z END:VEVENT END:VCALENDAR'; //echo $ical; //exit; //set correct content-type-header if ($event['id']) { header('Content-type: text/calendar; charset=utf-8'); header('Content-Disposition: attachment; filename=rjmprogramming-event.ics'); echo $ical; } else { // If $id isn't set, then kick the user back to home. Do not pass go, and do not collect $200. header('Location: /'); } } // -1 No message // 999999999 No message ?>