* @date 2008-04-24 * @version 1.0 * @license MIT * @website http://blog.ubrio.us */ /** * Your website -- leave off the http:// * Ex: "example.com" */ define('DAV_BASE_URL', 'your_site_here.com'); /** * where your password protected directory is - relative to the site root * Ex: "private_calendars" */ define('DAV_PRIVATED_CALENDAR_DIR', 'your_password_protected_directory'); /** * the username and password specified in .htaccess for your folder */ define('DAV_USERNAME', 'your_htaccess_username'); define('DAV_PASSWORD', 'your_htpasswd_password'); /** * which calendar to use if not specified in _GET[c] * Ex: "personal" maps to DAV_BASE_URL/DAV_PRIVATED_CALENDAR_DIR/personal.ics */ define('DEFAULT_CALENDAR', 'your_default_calendar'); /** * authentication to pass in through _GET[u] and _GET[p] * (below would map to the following when entered in google:) * this_script.php?u=your_silly_google_username&p=your_silly_google_password */ define('GCAL_USERNAME', 'your_silly_google_username'); define('GCAL_PASSWORD', 'your_silly_google_password'); /** * processing - will check the _GET[u] && _GET[p] to see if they match the appropriate * GCAL_* definition -- if so, will use cURL to get the private calendar and return it * as its own text/calendar * * GET VARIABLES REFERENCED * u => username * p => password * c => *calendar -- optional, defaults to DEFAULT_CALENDAR */ if($_GET['u'] == GCAL_USERNAME && $_GET['p'] == GCAL_PASSWORD) { $_cal_name = isset($_GET['c']) ? $_GET['c'] : DEFAULT_CALENDAR; $_ical_url = sprintf( 'http://%s:%s@%s/%s/%s.ics', DAV_USERNAME, DAV_PASSWORD, DAV_BASE_URL, DAV_PRIVATED_CALENDAR_DIR, $_cal_name ); $_curl = curl_init(); curl_setopt($_curl, CURLOPT_URL, $_ical_url); curl_setopt($_curl, CURLOPT_HEADER, 0); ob_start(); curl_exec($_curl); $ics_data = ob_get_clean(); curl_close($_curl); header('Content-Type:text/calendar'); print $ics_data; /** * the forbidden zone */ }else{ header('HTTP/1.1 403 Forbidden'); print "
Sorry. This directory is not your buddy, friend.
"; } ?>