| <?php |
| |
| require_once($_SERVER['DOCUMENT_ROOT'] . "/projects/stats/utils.php"); |
| |
| class Post { |
| var $_date; |
| var $_time; |
| var $_subject; |
| var $_author; |
| var $_messageid; |
| var $_reference; |
| |
| function Post($post_head){ |
| while(count($post_head)){ # Extract Date |
| $line = array_pop($post_head); |
| $tpos = 0; |
| if (substr($line,0,17) == "NNTP-Posting-Date"){ |
| $tpos = strpos($line,","); |
| if (!$tpos){ |
| $tpos = strpos($line," ") + 1; |
| }else |
| $tpos += 2; # Pass whitespaces, some posts are not conventional |
| $tstr = substr($line,$tpos); |
| # Get date |
| $data = explode(" ",$tstr,4); |
| $this->_date = convertNewsDate($data[0]." ".$data[1]." ".$data[2]); |
| # Get time |
| $tpos = strpos($line,":") + 1; |
| $tpos = strpos($line,":",$tpos) - 2; |
| $this->_time = substr($line,$tpos,8); |
| } else if (substr($line,0,7) == "Subject"){ # Extract Subject |
| $this->_subject = substr($line,9); |
| } else if (substr($line,0,4) == "From"){ # Extract Author |
| $data = explode(" ",$line); |
| $rstr = array("<",">"); |
| while(count($data)){ |
| $tmp = array_pop($data); |
| $tmp = str_replace($rstr,"",$tmp); |
| if (strpos($tmp,"@")) |
| break; |
| } |
| $this->_author = $tmp; |
| } else if (substr($line,0,10) == "References"){ # Extract References |
| $tpos = strrpos($line,"<") + 1; |
| $end = strrpos($line,"@"); |
| $this->_reference = substr($line,$tpos,$end-$tpos); |
| } else if (substr($line,0,10) == "Message-ID"){ # Extract Message-ID |
| $tpos = strpos($line,"<") + 1; |
| $end = strpos($line,"@"); |
| $this->_messageid = substr($line,$tpos,$end-$tpos); |
| } |
| } |
| } |
| |
| function getDate(){ |
| return $this->_date; |
| } |
| |
| function getTime(){ |
| return $this->_time; |
| } |
| |
| function getSubject(){ |
| return $this->_subject; |
| } |
| |
| function getAuthor(){ |
| return $this->_author; |
| } |
| |
| function getReference(){ |
| return $this->_reference; |
| } |
| |
| function getMessageID(){ |
| return $this->_messageid; |
| } |
| } |
| |
| ?> |