Example of PHP5 + ICS | Mail ICS | Download ICS | Source | Parent directory
<?php
function censorEmails($str, $censor = true) {
return $censor ? preg_replace('/[a-z_\d\.]+@[a-z_\d\.]+/i', 'censored@dev.null', $str): $str;
}
$loggedIn = ( md5($_REQUEST['pwd']) == '7a324f9caea77c896b6e20c72f45096f' );
if($_REQUEST['output'] != 'dl') {
echo 'Example of PHP5 + ICS | <a href="?output=mail&pwd='.$_REQUEST['pwd'].'">Mail ICS</a> | <a href="?output=dl&pwd='
.$_REQUEST['pwd'].'">Download ICS</a> | <a href="?output=src&pwd='.$_REQUEST['pwd'].'">Source</a> | <a href="./">Parent directory</a><hr/>';
}
if( !$loggedIn && $_REQUEST['output'] == 'mail') { echo 'Pwd?'; exit; }
if( $_REQUEST['output'] == 'src') {
try {
echo '<pre>'.htmlspecialchars(censorEmails(file_get_contents(__FILE__),!$loggedIn)).'</pre>';
} catch (Exception $e) { echo $e->getMessage(); }
exit;
}
$senderhost = 'ucm.energia.ee';
$sendingtime = date('Ymd\THi');
$uid='ID_120620';
$i = array(
'to' => 'censored@dev.null',
'subject' => 'Notes TODO #'.$uid.' @ '.$sendingtime,
'xtraheaders' => 'From: censored@dev.null
Content-type: text/calendar',
'message' => 'BEGIN:VCALENDAR
CALSCALE:GREGORIAN
PRODID:-//CGI Eesti//UCM2Notes v20130605//EN
VERSION:1.0
METHOD:REQUEST
BEGIN:VEVENT
ORGANIZER;CN="UCM":mailto:censored@dev.null
ATTENDEE;RSVP=YES;EXPECT=REQUEST:mailto:censored@dev.null
CREATED:20130605T093006Z
DTSTART;VALUE=DATE-TIME:20130615T150000Z
SUMMARY;CHARSET=UTF-8:Nõustumine dokumendiga '.$uid.'
DESCRIPTION;CHARSET=UTF-8:Kui olete nõus dokumendiga
http://ucm-dev1/rc/idcplg?IdcService=DOC_INFO_BY_NAME&RevisionSelectionMethod=Latest&dDocName='.$uid.' ,
vajutage [Accept], vastasel juhul [Decline].
UID:UCM2Notes!!'.$uid.'!'.mt_rand().'@ucm.energia.ee
TRANSP:1
STATUS:NEEDS ACTION
CATEGORIES:UCM
END:VEVENT
END:VCALENDAR
'
);
if($_REQUEST['output'] == 'dl') {
header('Content-type: text/calendar; charset=UTF-8');
header("Content-Disposition: attachment; filename=notestest_".date('YmdHis').".ics");
echo censorEmails($i['message'], !$loggedIn);
exit;
}
if($_REQUEST['output'] != 'mail') { exit; }
echo '<pre>';
var_export($i);
echo '</pre><hr/>';
$result = mail($i['to'],$i['subject'],$i['message'],$i['xtraheaders']);
echo 'Mail was sent: ';
var_export($result);