|
From: <cl...@us...> - 2004-05-19 05:50:19
|
Update of /cvsroot/phpicalendar/phpicalendar/functions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16323/functions Modified Files: ical_parser.php template.php Log Message: Replaced ereg_replace with str_replace for speed. Index: ical_parser.php =================================================================== RCS file: /cvsroot/phpicalendar/phpicalendar/functions/ical_parser.php,v retrieving revision 1.159 retrieving revision 1.160 diff -C2 -d -r1.159 -r1.160 *** ical_parser.php 16 May 2004 20:30:19 -0000 1.159 --- ical_parser.php 19 May 2004 05:50:09 -0000 1.160 *************** *** 347,352 **** break; case 'UNTIL': ! $until = ereg_replace('T', '', $val); ! $until = ereg_replace('Z', '', $until); if (strlen($until) == 8) $until = $until.'235959'; $abs_until = $until; --- 347,352 ---- break; case 'UNTIL': ! $until = str_replace('T', '', $val); ! $until = str_replace('Z', '', $until); if (strlen($until) == 8) $until = $until.'235959'; $abs_until = $until; *************** *** 722,727 **** $zulu_time = false; if (substr($data,-1) == 'Z') $zulu_time = true; ! $data = ereg_replace('T', '', $data); ! $data = ereg_replace('Z', '', $data); if (preg_match("/^DUE;VALUE=DATE/i", $field)) { $allday_start = $data; --- 722,727 ---- $zulu_time = false; if (substr($data,-1) == 'Z') $zulu_time = true; ! $data = str_replace('T', '', $data); ! $data = str_replace('Z', '', $data); if (preg_match("/^DUE;VALUE=DATE/i", $field)) { $allday_start = $data; *************** *** 771,776 **** $zulu_time = false; if (substr($data,-1) == 'Z') $zulu_time = true; ! $data = ereg_replace('T', '', $data); ! $data = ereg_replace('Z', '', $data); if (preg_match("/^COMPLETED;VALUE=DATE/i", $field)) { $allday_start = $data; --- 771,776 ---- $zulu_time = false; if (substr($data,-1) == 'Z') $zulu_time = true; ! $data = str_replace('T', '', $data); ! $data = str_replace('Z', '', $data); if (preg_match("/^COMPLETED;VALUE=DATE/i", $field)) { $allday_start = $data; *************** *** 836,842 **** $zulu_time = false; if (substr($data,-1) == 'Z') $zulu_time = true; ! $data = ereg_replace('T', '', $data); ! $data = ereg_replace('Z', '', $data); ! $field = ereg_replace(';VALUE=DATE-TIME', '', $field); if ((preg_match("/^DTSTART;VALUE=DATE/i", $field)) || (ereg ('^([0-9]{4})([0-9]{2})([0-9]{2})$', $data))) { ereg ('([0-9]{4})([0-9]{2})([0-9]{2})', $data, $dtstart_check); --- 836,842 ---- $zulu_time = false; if (substr($data,-1) == 'Z') $zulu_time = true; ! $data = str_replace('T', '', $data); ! $data = str_replace('Z', '', $data); ! $field = str_replace(';VALUE=DATE-TIME', '', $field); if ((preg_match("/^DTSTART;VALUE=DATE/i", $field)) || (ereg ('^([0-9]{4})([0-9]{2})([0-9]{2})$', $data))) { ereg ('([0-9]{4})([0-9]{2})([0-9]{2})', $data, $dtstart_check); *************** *** 889,895 **** $zulu_time = false; if (substr($data,-1) == 'Z') $zulu_time = true; ! $data = ereg_replace('T', '', $data); ! $data = ereg_replace('Z', '', $data); ! $field = ereg_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); --- 889,895 ---- $zulu_time = false; if (substr($data,-1) == 'Z') $zulu_time = true; ! $data = str_replace('T', '', $data); ! $data = str_replace('Z', '', $data); ! $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); *************** *** 932,937 **** $data = split(",", $data); foreach ($data as $exdata) { ! $exdata = ereg_replace('T', '', $exdata); ! $exdata = ereg_replace('Z', '', $exdata); ereg ('([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})', $exdata, $regs); $except_dates[] = $regs[1] . $regs[2] . $regs[3]; --- 932,937 ---- $data = split(",", $data); foreach ($data as $exdata) { ! $exdata = str_replace('T', '', $exdata); ! $exdata = str_replace('Z', '', $exdata); ereg ('([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})', $exdata, $regs); $except_dates[] = $regs[1] . $regs[2] . $regs[3]; *************** *** 980,985 **** unset($parts, $part, $eachval); ! $data = ereg_replace('T', '', $data); ! $data = ereg_replace('Z', '', $data); ereg ('([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})', $data, $regs); $recurrence_id['date'] = $regs[1] . $regs[2] . $regs[3]; --- 980,985 ---- unset($parts, $part, $eachval); ! $data = str_replace('T', '', $data); ! $data = str_replace('Z', '', $data); ereg ('([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})', $data, $regs); $recurrence_id['date'] = $regs[1] . $regs[2] . $regs[3]; *************** *** 1020,1028 **** if (($first_duration == TRUE) && (!stristr($field, '=DURATION'))) { ereg ('^P([0-9]{1,2}[W])?([0-9]{1,2}[D])?([T]{0,1})?([0-9]{1,2}[H])?([0-9]{1,2}[M])?([0-9]{1,2}[S])?', $data, $duration); ! $weeks = ereg_replace('W', '', $duration[1]); ! $days = ereg_replace('D', '', $duration[2]); ! $hours = ereg_replace('H', '', $duration[4]); ! $minutes = ereg_replace('M', '', $duration[5]); ! $seconds = ereg_replace('S', '', $duration[6]); $the_duration = ($weeks * 60 * 60 * 24 * 7) + ($days * 60 * 60 * 24) + ($hours * 60 * 60) + ($minutes * 60) + ($seconds); $first_duration = FALSE; --- 1020,1028 ---- if (($first_duration == TRUE) && (!stristr($field, '=DURATION'))) { ereg ('^P([0-9]{1,2}[W])?([0-9]{1,2}[D])?([T]{0,1})?([0-9]{1,2}[H])?([0-9]{1,2}[M])?([0-9]{1,2}[S])?', $data, $duration); ! $weeks = str_replace('W', '', $duration[1]); ! $days = str_replace('D', '', $duration[2]); ! $hours = str_replace('H', '', $duration[4]); ! $minutes = str_replace('M', '', $duration[5]); ! $seconds = str_replace('S', '', $duration[6]); $the_duration = ($weeks * 60 * 60 * 24 * 7) + ($days * 60 * 60 * 24) + ($hours * 60 * 60) + ($minutes * 60) + ($seconds); $first_duration = FALSE; *************** *** 1030,1034 **** break; case 'RRULE': ! $data = ereg_replace ('RRULE:', '', $data); $rrule = split (';', $data); foreach ($rrule as $recur) { --- 1030,1034 ---- break; case 'RRULE': ! $data = str_replace ('RRULE:', '', $data); $rrule = split (';', $data); foreach ($rrule as $recur) { *************** *** 1038,1048 **** break; case 'ATTENDEE': ! $field = ereg_replace("ATTENDEE;CN=", "", $field); ! $data = ereg_replace ("mailto:", "", $data); $attendee[] = array ('name' => $field, 'email' => $data); break; case 'ORGANIZER': ! $field = ereg_replace("ORGANIZER;CN=", "", $field); ! $data = ereg_replace ("mailto:", "", $data); $organizer[] = array ('name' => $field, 'email' => $data); break; --- 1038,1048 ---- break; case 'ATTENDEE': ! $field = str_replace("ATTENDEE;CN=", "", $field); ! $data = str_replace ("mailto:", "", $data); $attendee[] = array ('name' => $field, 'email' => $data); break; case 'ORGANIZER': ! $field = str_replace("ORGANIZER;CN=", "", $field); ! $data = str_replace ("mailto:", "", $data); $organizer[] = array ('name' => $field, 'email' => $data); break; Index: template.php =================================================================== RCS file: /cvsroot/phpicalendar/phpicalendar/functions/template.php,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** template.php 19 May 2004 03:45:09 -0000 1.43 --- template.php 19 May 2004 05:50:09 -0000 1.44 *************** *** 7,12 **** function draw_subscribe($template_p) { global $template, $getdate, $cal, $ALL_CALENDARS_COMBINED, $subscribe_path, $download_filename; - preg_match("!<\!-- switch display_download on -->(.*)<\!-- switch display_download off -->!is", $this->page, $match1); - $subscribe = trim($match2[1]); if ($cal != $ALL_CALENDARS_COMBINED && $subscribe_path != '' && $download_filename != '') { $this->page = str_replace('{SUBSCRIBE_PATH}', $subscribe_path, $this->page); --- 7,10 ---- |