$v) { if(strstr($v,'X-WR-CALNAME:')) { $arr = explode(':',$v); $calendar_name = trim($arr[1]); break; } } $calendar_name = isset($calendar_name) ? $calendar_name : 'default'; if (isset($_SERVER['PATH_INFO'])) { preg_match("/\/([ A-Za-z0-9.]*).ics/i",$_SERVER['PATH_INFO'],$matches); $calendar_name = $matches[1]; } // write to file if($fp = fopen($calendar_path.$calendar_name.'.ics','w+')) { fputs($fp, $data, strlen($data) ); @fclose($fp); } else { logmsg( 'couldnt open file '.$calendar_path.$calendar_name.'.ics' ); } } } if ($_SERVER['REQUEST_METHOD'] == 'GET') { if (isset($_SERVER['PATH_INFO'])) { preg_match("/\/([ A-Za-z0-9._]*).ics/i",$_SERVER['PATH_INFO'],$matches); $icsfile = $matches[1]; // get calendar data if (file_exists($calendar_path . $icsfile . '.ics') && is_readable($calendar_path . $icsfile . '.ics') && is_file($calendar_path . $icsfile . '.ics') ) { echo file_get_contents($calendar_path . $icsfile . '.ics'); } else { } } } } } // for logging function logmsg($str){ if(defined('PHPICALENDAR_LOG_PUBLISHING') && PHPICALENDAR_LOG_PUBLISHING == 1) { if($fp = fopen('publish_log.txt','a+')) { $str .= "\n"; fputs($fp, $str, strlen($str) ); fclose($fp); } } } ?>