From: Waitman C. G. <wa...@em...> - 2002-10-16 02:29:55
|
hello! please review the following unfolding code. according to rfc 2445, each line in the ics file must be 75 octets or less in length. each line is to terminated by CRLF. if the data portion causes the particular line to exceed 75 octets, then the line is to broken, with the excess placed on the following line(s) and preceded by a single space (ascii 32) or htab (ascii 9). (sheesh, i bet that made the unix and mac ppl happy, but hey look... a guy at microsoft co-authored the rfc... now can someone tell me why outlook doesn't do this right?) anyhow, i think this unfolding business is the reason that the existing phpicalendar scripts wouldn't read the mozilla files. i posted a quick-fix on the forum but i bet it wouldn't read multiple-multiple lines, ie if the particular line was long enough to exceed two lines. i tested it on a mozilla ics and an apple ics i found at apple.com if somebody has a really good one with lots of text in the descriptions, that would be super-cool. <?php //$ical_file="/53073H4/calenders/kristi.ics"; $ical_file="/53073H4/calenders/Premieres32Pacific.ics"; //need file name in $ical_file $errstr=""; if (!@file_exists($ical_file)) { $errstr="The file does not exist."; } else { //unfold file $folded=@file($ical_file); $unfolded = array(); $buffer = ""; for ($jj=0;$jj<count($folded);$jj++) { if (strlen($folded[$jj])>0) { if ( (ord(substr($folded[$jj],0,1))==32) || (ord(substr($folded[$jj],0,1))==9) ) { $buffer .= substr($folded[$jj],1,strlen($folded[$jj])-1); } else { if (strlen($buffer)>0) { $unfolded[]=$buffer; } $buffer=$folded[$jj]; } } } } //remove linefeeds and carriage returns for ($jj=0;$jj<count($unfolded);$jj++) { $unfolded[$jj] = @ereg_replace("\n","",$unfolded[$jj]); $unfolded[$jj] = @ereg_replace("\r","",$unfolded[$jj]); } print_r($unfolded); ?> thanks waitman |