Re: POP3 access class

From: Date: Sat, 19 Jan 2002 14:12:47 +0000
Subject: Re: POP3 access class
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-4001@lists.php.net to get a copy of this message
<richard@phpguru.org> wrote : > Since I recently had to write a pop3 class for someone who didn't have > access to the imap extension, I was wondering if anyone had any thoughts on > me adding it to pear? I have had a look at it and it seems quite good. I would like to see it in PEAR. Maybe, instead of returning false in some cases you could return a PEAR ERROR. You might also want to add utility functions like this one taken from Horde : /** * Decodes special characters in mail headers * @param string $string String to decode * @return string decoded string */ function _mimeHeaderDecode($string) { $pos = strpos($string, '=?'); if ($pos === false) { return $string; } // take out any spaces between multiple encoded words $string = preg_replace('|\?=\s=\?|', '?==?', $string); $preceding = substr($string, 0, $pos); // save any preceding text $search = substr($string, $pos + 2, 75); // the mime header spec says this is the longest a single encoded word can be $d1 = strpos($search, '?'); if (!is_int($d1)) { return $string; } $charset = substr($string, $pos + 2, $d1); $search = substr($search, $d1 + 1); $d2 = strpos($search, '?'); if (!is_int($d2)) { return $string; } $encoding = substr($search, 0, $d2); $search = substr($search, $d2+1); $end = strpos($search, '?='); if (!is_int($end)) { return $string; } $encoded_text = substr($search, 0, $end); $rest = substr($string, (strlen($preceding . $charset . $encoding . $encoded_text) + 6)); switch ($encoding) { case 'Q': case 'q': $encoded_text = str_replace('_', '%20', $encoded_text); $encoded_text = str_replace('=', '%', $encoded_text); $decoded = urldecode($encoded_text); break; case 'B': case 'b': $decoded = urldecode(base64_decode($encoded_text)); break; default: $decoded = '=?' . $charset . '?' . $encoding . '?' . $encoded_text . '?='; break; } return $preceding . $decoded . $this->_mimeHeaderDecode($rest); } // end function _mimeHeaderDecode

« previous php.pear.dev (#4001) next »