function decode_ical_file($filename) { $parsed_data = parse_ical($filename); if (isset($parsed_data[0]['tzoffsetfrom'])){ $tz_diff = ($parsed_data[0]['tzoffsetfrom'] / 100); }else $tz_diff = logged_user()->getTimezone(); unset($parsed_data[0]); $events_data = CalFormatUtilities::build_events_data($parsed_data, $tz_diff); return $events_data; }
function import_edt($file) { global $count_con, $count_suc, $error_num, $numDeleted, $ALLOW_CONFLICT, $message; //if ( $file['size'] > 0 ) { $data = array(); $doOverwrite = 'true'; $data = parse_ical("/tmp/arch_agend/" . $file); $type = 'ical'; if (!empty($data)) { $message .= date("H:i:s") . " - <b>Traitement du fichier " . $file . "</b><br/>"; ecrit_fichier(); lcs_import_data($data, true, $type); $message .= ' ' . translate('Events successfully imported') . ': ' . $count_suc . '<br /><br /> '; } ecrit_fichier(); }
case 'PALMDESKTOP': include "import_palmdesktop.php"; if (delete_palm_events($login) != 1) { $errormsg = "Error deleting palm events from webcalendar."; } $data = parse_palmdesktop($file['tmp_name'], $exc_private); $type = 'palm'; break; case 'VCAL': include "import_vcal.php"; $data = parse_vcal($file['tmp_name']); $type = 'vcal'; break; case 'ICAL': include "import_ical.php"; $data = parse_ical($file['tmp_name']); $type = 'ical'; break; } $count_con = $count_suc = $error_num = 0; if (!empty($data) && empty($errormsg)) { import_data($data, $doOverwrite, $type); echo "<p>" . translate("Import Results") . "</p>\n<br /><br />\n" . translate("Events successfully imported") . ": {$count_suc}<br />\n"; echo translate("Events from prior import marked as deleted") . ": {$numDeleted}<br />\n"; if (empty($allow_conflicts)) { echo translate("Conflicting events") . ": " . $count_con . "<br />\n"; } echo translate("Errors") . ": {$error_num}<br><br>\n"; } elseif ($errormsg) { echo "<br /><br />\n<b>" . translate("Error") . ":</b> {$errormsg}<br />\n"; } else {
/** * Import to the ATutor DB * @param string $input - Depends on mode * @param int $mode - Mode of operation of import [ 0 | 1 ] * * mode 0 - accepts the dates to be imported as a string * * mode 1 - accepts the name of the file containing the dates to be imported * @param string $format - Import Format DEFAULT 'ical' * @return void * @author Anurup Raveendran * */ function cal_import($input, $mode, $format = 'ical') { $ics_file_name = ""; include 'classes/parser_' . $format . '.class.php'; // include the format-based parser if (!$mode) { // string input | rare case but good for code re-use $ics_file_name = AT_CONTENT_DIR . uniqid() . 'ics'; $fhandle = @fopen($ics_file_name, 'w'); fwrite($fhandle, $input); fseek($fhandle, 0); fclose($fhandle); } else { if ($mode) { // filename input $ics_file_name = $input; } } $cal = parse_ical($ics_file_name); //parse $cal }
function dump_globals() { foreach ($GLOBALS as $K => $V) { do_debug("GLOBALS[{$K}] => " . (strlen($V) < 70 ? $V : '(too long)')); } foreach ($GLOBALS['HTTP_POST_VARS'] as $K => $V) { do_debug("GLOBALS[{$_POST[$K]}] => " . (strlen($V) < 70 ? $V : '(too long)')); } } switch ($_SERVER['REQUEST_METHOD']) { case 'PUT': // do_debug ( "Importing updated remote calendar" ); $calUser = $login; $overwrite = true; $type = 'icalclient'; $data = parse_ical('', $type); import_data($data, $overwrite, $type); break; case 'GET': // do_debug ( "Exporting updated remote calendar" ); header('Content-Type: text/calendar'); header('Content-Disposition: attachment; filename="' . $login . '.ics"'); $use_all_dates = true; echo export_ical(); break; case 'OPTIONS': header('Allow: GET, PUT, OPTIONS'); break; default: header('Allow: GET, PUT, OPTIONS'); header('HTTP/1.0 405 Method Not Allowed');
<?php include 'parse_ics.php'; $ical = parse_ical('http://movement.meetup.com/72/calendar/ical/Bay+Area+Seasteading+Socials'); ?> <pre> <?php print_r($ical); ?> </pre> <hr /> <?php foreach ($ical as $event) { echo $event['summary']; ?> : <?php echo date('d-m-Y @ g:i a', $event['start_unix'] - 25200); ?> <br /> <?php }
// First delete any record for this user/nuc combo. dbi_execute('DELETE FROM webcal_access_user WHERE cal_login = ? AND cal_other_user = ?', array($nadmin, $nid)); if (!dbi_execute('INSERT INTO webcal_access_user ( cal_login, cal_other_user, cal_can_view, cal_can_edit, cal_can_approve, cal_can_invite, cal_can_email, cal_see_time_only ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ? )', array($nadmin, $nid, 511, 511, 511, 'Y', 'Y', 'N'))) { die_miserable_death(translate('Database error') . ': ' . dbi_error()); } } if (!empty($reload)) { $data = array(); $calUser = $nid; $overwrite = true; $type = 'remoteics'; // We will check ics first. $data = parse_ical($nurl, $type); // TODO it may be a vcs file. // if ( count ( $data ) == 0 ) { // $data = parse_vcal ( $nurl ); // } // We may be processing an hCalendar. // $data sometimes has a count of 1 but is not a valid array. if ((count($data) == 0 || !isset($data[0])) && function_exists('simplexml_load_string')) { $h = new hKit(); $h->tidy_mode = 'proxy'; $result = $h->getByURL('hcal', $nurl); $type = 'hcal'; $data = parse_hcal($result, $type); } $errorStr = '<br /><br /> <b>' . translate('Error') . ':</b> ';
echo "<br />\n" . translate('Include Path') . ' =' . ini_get('include_path') . "<br />\n"; } if ($REMOTES_ENABLED == 'Y') { $res = dbi_execute('SELECT cal_login, cal_url, cal_admin FROM webcal_nonuser_cals WHERE cal_url IS NOT NULL'); $cnt = 0; if ($res) { while ($row = dbi_fetch_row($res)) { $data = array(); $cnt++; $calUser = $row[0]; $cal_url = $row[1]; $login = $row[2]; $overwrite = true; $type = 'remoteics'; $data = parse_ical($cal_url, $type); // TODO it may be a vcs file // if ( count ( $data ) == 0 ) { // $data = parse_vcal ( $cal_url ); // } // we may be processing an hCalendar if (count($data) == 0 && function_exists('simplexml_load_string')) { $h = new hKit(); $h->tidy_mode = 'proxy'; $result = $h->getByURL('hcal', $cal_url); $type = 'hcal'; $data = parse_hcal($result, $type); } if (count($data) && empty($errormsg)) { // delete existing events if ($debug) {