|
From: <cl...@us...> - 2004-05-20 05:46:33
|
Update of /cvsroot/phpicalendar/phpicalendar/functions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25095/functions Modified Files: ical_parser.php Log Message: Optimizations: Moved more eregs to preg_match, changed if statements to case and switch. Seems ok on my calendars. Index: ical_parser.php =================================================================== RCS file: /cvsroot/phpicalendar/phpicalendar/functions/ical_parser.php,v retrieving revision 1.163 retrieving revision 1.164 diff -C2 -d -r1.163 -r1.164 *** ical_parser.php 20 May 2004 04:15:19 -0000 1.163 --- ical_parser.php 20 May 2004 05:46:23 -0000 1.164 *************** *** 14,18 **** while ($fillTime < $day_end) { array_push ($day_array, $fillTime); ! ereg ('([0-9]{2})([0-9]{2})', $fillTime, $dTime); $fill_h = $dTime[1]; $fill_min = $dTime[2]; --- 14,18 ---- while ($fillTime < $day_end) { array_push ($day_array, $fillTime); ! preg_match ('/([0-9]{2})([0-9]{2})/', $fillTime, $dTime); $fill_h = $dTime[1]; $fill_min = $dTime[2]; *************** *** 27,31 **** // what date we want to get data for (for day calendar) if (!isset($getdate) || $getdate == '') $getdate = date('Ymd'); ! ereg ('([0-9]{4})([0-9]{2})([0-9]{2})', $getdate, $day_array2); $this_day = $day_array2[3]; $this_month = $day_array2[2]; --- 27,31 ---- // what date we want to get data for (for day calendar) if (!isset($getdate) || $getdate == '') $getdate = date('Ymd'); ! preg_match ("/([0-9]{4})([0-9]{2})([0-9]{2})/", $getdate, $day_array2); $this_day = $day_array2[3]; $this_month = $day_array2[2]; *************** *** 84,95 **** $line = $nextline; $nextline = fgets($ifile, 1024); ! $nextline = ereg_replace("[\r\n]", "", $nextline); while (substr($nextline, 0, 1) == " ") { $line = $line . substr($nextline, 1); $nextline = fgets($ifile, 1024); ! $nextline = ereg_replace("[\r\n]", "", $nextline); } $line = trim($line); ! if ($line == 'BEGIN:VEVENT') { // each of these vars were being set to an empty string unset ( --- 84,97 ---- $line = $nextline; $nextline = fgets($ifile, 1024); ! $nextline = str_replace("\r\n", "", $nextline); while (substr($nextline, 0, 1) == " ") { $line = $line . substr($nextline, 1); $nextline = fgets($ifile, 1024); ! $nextline = str_replace("\r\n", "", $nextline); } $line = trim($line); ! ! switch ($line) { ! case 'BEGIN:VEVENT': // each of these vars were being set to an empty string unset ( *************** *** 98,102 **** $beginning, $rrule_array, $start_of_vevent, $description, $bd, $url, $valarm_description, $start_unixtime, $end_unixtime, $display_end_tmp, $end_time_tmp1, ! $recurrence_id, $uid, $class, $location, $rrule, $abs_until, $until_check ); --- 100,107 ---- $beginning, $rrule_array, $start_of_vevent, $description, $bd, $url, $valarm_description, $start_unixtime, $end_unixtime, $display_end_tmp, $end_time_tmp1, ! $recurrence_id, $uid, $class, $location, $rrule, $abs_until, $until_check, ! $until, $bymonth, $byday, $bymonthday, $byweek, $byweekno, ! $byminute, $byhour, $bysecond, $byyearday, $bysetpos, $wkst, ! $interval, $number ); *************** *** 111,121 **** $organizer = array(); ! unset( ! $until, $bymonth, $byday, $bymonthday, $byweek, $byweekno, ! $byminute, $byhour, $bysecond, $byyearday, $bysetpos, $wkst, ! $interval, $number ! ); ! ! } elseif ($line == 'END:VEVENT') { if (!isset($master_array[-3][$calnumber])) $master_array[-3][$calnumber] = $actual_calname; --- 116,122 ---- $organizer = array(); ! break; ! ! case 'END:VEVENT': if (!isset($master_array[-3][$calnumber])) $master_array[-3][$calnumber] = $actual_calname; *************** *** 203,208 **** } if (isset($start_time) && $start_time != '') { ! ereg ('([0-9]{2})([0-9]{2})', $start_time, $time); ! ereg ('([0-9]{2})([0-9]{2})', $end_time, $time2); if (isset($start_unixtime) && isset($end_unixtime)) { $length = $end_unixtime - $start_unixtime; --- 204,209 ---- } if (isset($start_time) && $start_time != '') { ! preg_match ('/([0-9]{2})([0-9]{2})/', $start_time, $time); ! preg_match ('([0-9]{2})([0-9]{2})', $end_time, $time2); if (isset($start_unixtime) && isset($end_unixtime)) { $length = $end_unixtime - $start_unixtime; *************** *** 692,698 **** unset($start_time, $start_time_tmp, $end_time, $end_time_tmp, $start_unixtime, $start_unixtime_tmp, $end_unixtime, $end_unixtime_tmp, $summary, $length, $nbrOfOverlaps, $description, $status, $class, $location, $organizer, $attendee); ! ! // Begin VTODO Support ! } elseif ($line == 'END:VTODO') { if ((!$vtodo_priority) && ($status == 'COMPLETED')) { $vtodo_sort = 11; --- 693,698 ---- unset($start_time, $start_time_tmp, $end_time, $end_time_tmp, $start_unixtime, $start_unixtime_tmp, $end_unixtime, $end_unixtime_tmp, $summary, $length, $nbrOfOverlaps, $description, $status, $class, $location, $organizer, $attendee); ! break; ! case 'END:VTODO': if ((!$vtodo_priority) && ($status == 'COMPLETED')) { $vtodo_sort = 11; *************** *** 705,715 **** unset ($start_date, $start_time, $due_date, $due_time, $completed_date, $completed_time, $vtodo_priority, $status, $class, $vtodo_categories, $summary, $description); $vtodo_set = FALSE; ! } elseif ($line == 'BEGIN:VTODO') { $vtodo_set = TRUE; ! } elseif ($line == 'BEGIN:VALARM') { $valarm_set = TRUE; ! } elseif ($line == 'END:VALARM') { $valarm_set = FALSE; ! } else { unset ($field, $data, $prop_pos, $property); --- 705,722 ---- unset ($start_date, $start_time, $due_date, $due_time, $completed_date, $completed_time, $vtodo_priority, $status, $class, $vtodo_categories, $summary, $description); $vtodo_set = FALSE; ! ! break; ! ! case 'BEGIN:VTODO': $vtodo_set = TRUE; ! break; ! case 'BEGIN:VALARM': $valarm_set = TRUE; ! break; ! case 'END:VALARM': $valarm_set = FALSE; ! break; ! ! default: unset ($field, $data, $prop_pos, $property); *************** *** 865,869 **** } ! ereg ('([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})', $data, $regs); $start_date = $regs[1] . $regs[2] . $regs[3]; $start_time = $regs[4] . $regs[5]; --- 872,876 ---- } ! preg_match ('/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})/', $data, $regs); $start_date = $regs[1] . $regs[2] . $regs[3]; $start_time = $regs[4] . $regs[5]; *************** *** 902,906 **** $field = str_replace(';VALUE=DATE-TIME', '', $field); if (preg_match("/^DTEND;VALUE=DATE/i", $field)) { ! ereg ('([0-9]{4})([0-9]{2})([0-9]{2})', $data, $dtend_check); if ($dtend_check[1] < 1970) { $data = '1971'.$dtend_check[2].$dtend_check[3]; --- 909,913 ---- $field = str_replace(';VALUE=DATE-TIME', '', $field); if (preg_match("/^DTEND;VALUE=DATE/i", $field)) { ! preg_match ('/([0-9]{4})([0-9]{2})([0-9]{2})/', $data, $dtend_check); if ($dtend_check[1] < 1970) { $data = '1971'.$dtend_check[2].$dtend_check[3]; *************** *** 916,920 **** } ! ereg ('([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})', $data, $regs); $end_date = $regs[1] . $regs[2] . $regs[3]; $end_time = $regs[4] . $regs[5]; --- 923,927 ---- } ! preg_match ('/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})/', $data, $regs); $end_date = $regs[1] . $regs[2] . $regs[3]; $end_time = $regs[4] . $regs[5]; |