aboutsummaryrefslogtreecommitdiffstats
path: root/calendars
diff options
context:
space:
mode:
authorChad Little <clittle@users.sourceforge.net>2003-11-23 22:55:22 +0000
committerChad Little <clittle@users.sourceforge.net>2003-11-23 22:55:22 +0000
commit2d2a0f5bc3b8ec9b756412da4228128afdf5d9da (patch)
treea4e4d340ca80cb3849ac586eb50bf83597445d77 /calendars
parent4755bf8f506fda3b64b8267c10d06b6b747f8321 (diff)
downloadphpicalendar-2d2a0f5bc3b8ec9b756412da4228128afdf5d9da.tar.gz
phpicalendar-2d2a0f5bc3b8ec9b756412da4228128afdf5d9da.tar.bz2
phpicalendar-2d2a0f5bc3b8ec9b756412da4228128afdf5d9da.zip
Updated.
Diffstat (limited to 'calendars')
-rw-r--r--calendars/publish.php119
1 files changed, 67 insertions, 52 deletions
diff --git a/calendars/publish.php b/calendars/publish.php
index 9a75e99..68856bd 100644
--- a/calendars/publish.php
+++ b/calendars/publish.php
@@ -19,8 +19,9 @@ Installation:
2. configure path to PHP iCalendar config file (below)
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:
+Usage (Apple iCal):
1. Open iCal, select a calendar for publishing
2. Select "Publish" from the "Calendar" menu
3. Configure to your liking, and set the URL to (eg): http://localhost/~dietricha/calendar/calendars/publish.php
@@ -46,76 +47,90 @@ include('../config.inc.php');
// set calendar path, or just use current directory
$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', 0 );
+define( 'PHPICALENDAR_LOG_PUBLISHING', 1 );
-// viewing
+/* force GET requests to main calendar view
if($_SERVER['REQUEST_METHOD'] == 'GET')
{
header('Location: '.$default_path);
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')
+*/
+// only allow publishing if explicitly enabled
+if(PHPICALENDAR_PUBLISHING == 1)
{
- // get calendar data
- $fp = fopen('php://input','r');
-
- while(!feof($fp))
+ // unpublishing
+ if($_SERVER['REQUEST_METHOD'] == 'DELETE')
{
- $data .= fgets($fp,4096);
+ // 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;
}
- fclose($fp);
-
- if(isset($data))
+ // publishing
+ if($_SERVER['REQUEST_METHOD'] == 'PUT')
{
-
- // get calendar name
- $cal_arr = explode("\n",$data);
-
- foreach($cal_arr as $k => $v)
+ // get calendar data
+ if($fp = fopen('php://input','r'))
{
- if(strstr($v,'X-WR-CALNAME:'))
+ while(!@feof($fp))
{
- $arr = explode(':',$v);
- $calendar_name = trim($arr[1]);
- break;
+ $data .= fgets($fp,4096);
}
+
+ @fclose($fp);
}
-
- $calendar_name = isset($calendar_name) ? $calendar_name : 'default';
-
- // write to file
- if($fp = fopen($calendar_path.$calendar_name.'.ics','w+'))
+ else
{
- fputs($fp, $data, strlen($data) );
- fclose($fp);
+ logmsg('unable to read input data');
}
- else
+
+ if(isset($data))
{
- logmsg( 'couldnt open file '.$calendar_path.$calendar_name.'.ics' );
+
+ // 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' );
+ }
}
}
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy