$v) { if(strstr($v,'X-WR-CALNAME:')) { $arr = explode(':',$v); $calendar_name = trim($arr[1]); break; } } $calendar_name = isset($calendar_name) ? $calendar_name : 'default'; // 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' ); } } } // 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); } } } ?>