// Filters an iCalendar feed, removing events over a certain duration. // Written specifically because I was tired of multi-day Facebook events // crowding out other events on my iCal. // Install the script on a web server that supports PHP with the cURL extension. // To filter a Facebook feed, add the 'uid' and 'key' parameters to the URL // (e.g., icalproxy.php?uid=X&key=Y). To filter another feed, specifiy an 'url' // parameter instead (e.g., icalproxy.php?url=http:%2f%2fexample.com%2fical). // By default, all events longer than 12 hours are removed from the calendar. // If you'd like, you can change this number with the 'maxhrs' parameter. // Copyright (c) 2009 Benjamin Ragheb // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. define('SCRIPT_VERSION', '1.0'); define('DEFAULT_MAX_HOURS', 12); // Allow the script to serve a download of itself. if (isset($_REQUEST['getsrc'])) { header('Content-type: text/plain'); readfile(__FILE__); exit; } // Figure out the iCalendar URL. if (isset($_REQUEST['url'])) { $iCalendarURL = $_REQUEST['url']; } elseif (isset($_REQUEST['uid']) && isset($_REQUEST['key'])) { $uid = $_REQUEST['uid']; $key = $_REQUEST['key']; $iCalendarURL = 'http://www.facebook.com/ical/u.php?uid=' . $uid . '&key=' . $key; } // The maximum allowed event duration in hours, 12 by default. if (is_numeric($_REQUEST['maxhrs'])) { $eventMaxHours = $_REQUEST['maxhrs']; } else { $eventMaxHours = DEFAULT_MAX_HOURS; } if (preg_match('_^http(s?)://_', $iCalendarURL)) { $ch = curl_init($iCalendarURL); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $inputRaw = curl_exec($ch); curl_close($ch); } else { header('Content-type: text/html'); ?> icalproxy

A script, in PHP, to remove events from an iCalendar if they exceed a specified duration.

Learn More

View PHP Source (version )

written by Benjamin Ragheb