From: <cl...@us...> - 2004-08-08 01:47:26
|
Update of /cvsroot/phpicalendar/phpicalendar/functions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30765/functions Modified Files: ical_parser.php Log Message: Added webcal caching. Index: ical_parser.php =================================================================== RCS file: /cvsroot/phpicalendar/phpicalendar/functions/ical_parser.php,v retrieving revision 1.174 retrieving revision 1.175 diff -C2 -d -r1.174 -r1.175 *** ical_parser.php 7 Aug 2004 06:36:49 -0000 1.174 --- ical_parser.php 8 Aug 2004 01:47:17 -0000 1.175 *************** *** 34,38 **** // reading the file if it's allowed $parse_file = true; ! if (($is_webcal == false) && ($save_parsed_cals == 'yes')) { if (sizeof ($cal_filelist) > 1) { $parsedcal = $tmp_dir.'/parsedcal-'.$cal_filename.'-'.$this_year; --- 34,38 ---- // reading the file if it's allowed $parse_file = true; ! if ($save_parsed_cals == 'yes') { if (sizeof ($cal_filelist) > 1) { $parsedcal = $tmp_dir.'/parsedcal-'.$cal_filename.'-'.$this_year; *************** *** 48,53 **** $mtime = $master_array['-4'][$z]['mtime']; $fname = $master_array['-4'][$z]['filename']; $realcal_mtime = filemtime($fname); ! if ($mtime == $realcal_mtime) { $y++; } --- 48,58 ---- $mtime = $master_array['-4'][$z]['mtime']; $fname = $master_array['-4'][$z]['filename']; + $wcalc = $master_array['-4'][$z]['webcal']; $realcal_mtime = filemtime($fname); ! $webcal_mtime = strtotime("now -$webcal_hours hours"); ! if (($mtime == $realcal_mtime) && ($wcalc == 'no')) { ! $y++; ! } elseif (($wcalc == 'yes') && ($mtime > $webcal_mtime)) { ! //echo date('H:i',$mtime). ' > '. date('H:i',$webcal_mtime); $y++; } *************** *** 100,103 **** --- 105,123 ---- if ($parse_file) { + // Let's see if we're doing a webcal + $is_webcal == FALSE; + if (substr($filename, 0, 7) == 'http://' || substr($filename, 0, 8) == 'https://' || substr($filename, 0, 9) == 'webcal://') { + $is_webcal == TRUE; + $cal_webcalPrefix = str_replace('http://','webcal://',$filename); + $cal_httpPrefix = str_replace('webcal://','http://',$filename); + $cal_httpsPrefix = str_replace('webcal://','https://',$filename); + $cal_httpsPrefix = str_replace('http://','https://',$cal_httpsPrefix); + $filename = $cal_httpPrefix; + $master_array['-4'][$calnumber]['webcal'] = 'yes'; + $actual_mtime = time(); + } else { + $actual_mtime = filemtime($filename); + } + $ifile = @fopen($filename, "r"); if ($ifile == FALSE) exit(error($lang['l_error_cantopen'], $filename)); *************** *** 105,113 **** if (trim($nextline) != 'BEGIN:VCALENDAR') exit(error($lang['l_error_invalidcal'], $filename)); - //Mod time - if ($is_webcal == false) { - $actual_mtime = filemtime($filename); - } - // Set a value so we can check to make sure $master_array contains valid data $master_array['-1'] = 'valid cal file'; --- 125,128 ---- *************** *** 161,164 **** --- 176,180 ---- if (!isset($master_array['-4'][$calnumber]['mtime'])) $master_array['-4'][$calnumber]['mtime'] = $actual_mtime; if (!isset($master_array['-4'][$calnumber]['filename'])) $master_array['-4'][$calnumber]['filename'] = $filename; + if (!isset($master_array['-4'][$calnumber]['webcal'])) $master_array['-4'][$calnumber]['webcal'] = 'no'; if (!isset($url)) $url = ''; if (!isset($type)) $type = ''; *************** *** 1136,1140 **** // write the new master array to the file ! if (isset($master_array) && is_array($master_array) && $save_parsed_cals == 'yes' && $is_webcal == FALSE) { $write_me = serialize($master_array); $fd = fopen($parsedcal, 'w'); --- 1152,1156 ---- // write the new master array to the file ! if (isset($master_array) && is_array($master_array) && $save_parsed_cals == 'yes') { $write_me = serialize($master_array); $fd = fopen($parsedcal, 'w'); *************** *** 1142,1145 **** --- 1158,1162 ---- fclose($fd); touch($parsedcal, $realcal_mtime); + //echo 'writing file'; } } |