From: <cl...@us...> - 2003-11-23 22:55:26
|
Update of /cvsroot/phpicalendar/phpicalendar/calendars In directory sc8-pr-cvs1:/tmp/cvs-serv14011/calendars Modified Files: publish.php Log Message: Updated. Index: publish.php =================================================================== RCS file: /cvsroot/phpicalendar/phpicalendar/calendars/publish.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** publish.php 19 Nov 2003 22:17:24 -0000 1.2 --- publish.php 23 Nov 2003 22:55:22 -0000 1.3 *************** *** 20,25 **** 3. make sure that PHP has write access to the calendars directory (or whatever you set $calendar_path to) 4. set up directory security on your calendars directory ! Usage: 1. Open iCal, select a calendar for publishing 2. Select "Publish" from the "Calendar" menu --- 20,26 ---- 3. make sure that PHP has write access to the calendars directory (or whatever you set $calendar_path to) 4. set up directory security on your calendars directory + 5. turn on publishing in your PHP iCalendar config file by setting $phpicalendar_publishing to 1. ! Usage (Apple iCal): 1. Open iCal, select a calendar for publishing 2. Select "Publish" from the "Calendar" menu *************** *** 47,54 **** $calendar_path = (isset($calendar_path) && $calendar_path != '') ? $calendar_path : ''; // toggle logging ! define( 'PHPICALENDAR_LOG_PUBLISHING', 0 ); ! // viewing if($_SERVER['REQUEST_METHOD'] == 'GET') { --- 48,60 ---- $calendar_path = (isset($calendar_path) && $calendar_path != '') ? $calendar_path : ''; + // allow/disallow publishing + + $phpicalendar_publishing = isset($phpicalendar_publishing) ? $phpicalendar_publishing : 0; + define( 'PHPICALENDAR_PUBLISHING', $phpicalendar_publishing ); + // toggle logging ! define( 'PHPICALENDAR_LOG_PUBLISHING', 1 ); ! /* force GET requests to main calendar view if($_SERVER['REQUEST_METHOD'] == 'GET') { *************** *** 56,120 **** return; } ! ! // unpublishing ! if($_SERVER['REQUEST_METHOD'] == 'DELETE') ! { ! // get calendar filename ! $calendar_file = $calendar_path.substr($_SERVER['REQUEST_URI'] , ( strrpos($_SERVER['REQUEST_URI'], '/') + 1) ) ; ! ! logmsg('received request to delete '.$calendar_file); ! ! // remove calendar file ! if(!unlink($calendar_file)) ! { ! logmsg('unable to delete the calendar file'); ! } ! else ! { ! logmsg('deleted'); ! } ! return; ! } ! ! // publishing ! if($_SERVER['REQUEST_METHOD'] == 'PUT') { ! // get calendar data ! $fp = fopen('php://input','r'); ! ! while(!feof($fp)) { ! $data .= fgets($fp,4096); } ! fclose($fp); ! ! if(isset($data)) { ! ! // get calendar name ! $cal_arr = explode("\n",$data); ! ! foreach($cal_arr as $k => $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' ); } } --- 62,135 ---- return; } ! */ ! // only allow publishing if explicitly enabled ! if(PHPICALENDAR_PUBLISHING == 1) { ! // unpublishing ! if($_SERVER['REQUEST_METHOD'] == 'DELETE') { ! // get calendar filename ! $calendar_file = $calendar_path.substr($_SERVER['REQUEST_URI'] , ( strrpos($_SERVER['REQUEST_URI'], '/') + 1) ) ; ! ! logmsg('received request to delete '.$calendar_file); ! ! // remove calendar file ! if(!unlink($calendar_file)) ! { ! logmsg('unable to delete the calendar file'); ! } ! else ! { ! logmsg('deleted'); ! } ! return; } ! // publishing ! if($_SERVER['REQUEST_METHOD'] == 'PUT') { ! // get calendar data ! if($fp = fopen('php://input','r')) { ! while(!@feof($fp)) { ! $data .= fgets($fp,4096); } + + @fclose($fp); } ! else { ! logmsg('unable to read input data'); } ! ! if(isset($data)) { ! ! // get calendar name ! $cal_arr = explode("\n",$data); ! ! foreach($cal_arr as $k => $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' ); ! } } } |