Example #1
0
 function parseMail($input_file)
 {
     global $argv;
     //DBG("parseMail start");
     if (!($mp = new MailParser($input_file))) {
         $this->setError('Error In MailParser');
         //DBG("parseMail error1: ".$mp->getErrorMessage());
         return false;
     } elseif ($mp->isError()) {
         $this->setError('Error In MailParser ' . $mp->getErrorMessage());
         //DBG("parseMail error2: ".$mp->getErrorMessage());
         // even if it is an error, try to get the address of the sender so we
         // can send him back the error
         $this->FromEmail = $mp->getFromEmail();
         return false;
     }
     $this->FromEmail = $mp->getFromEmail();
     //DBG("email: ".$this->FromEmail);
     //echo ")()()()()()()".$this->FromEmail."(*(*(*(*(*";
     //
     //subjects are in this required format: '[group - Forum][123456] My Subject'
     //where 123456 is the msg_id of the forum message.
     //we parse that ID to get the forum and thread that this should post to
     //
     $subj = $mp->getSubject();
     //DBG("mp headers: ".implode("**\n",$mp->headers));
     //DBG("mp body: ".$mp->body);
     //DBG("SUBJ: ".$subj);
     //DBG("BODY: ".$mp->getBody());
     /*
     		$parent_start = (strpos($subj,'[',(strpos($subj,'[')+1))+1);
     		$parent_end = (strpos($subj,']',$parent_start)-1);
     		$this->Parent = substr($subj,$parent_start,($parent_end-$parent_start+1));
     		if (!$this->Parent || !is_numeric($this->Parent)) {
     //			$argv[1] - listname
     //			echo "No Parent ".$argv[0]."||".$argv[1];
     			$this->Parent=0;
     			$this->Subject = addslashes($subj);
     //			$this->setError('No Valid Parent ID Found in Subject Line');
     //			return false;
     		} else {
     //			echo "Parent: ".$this->Parent."||".$argv[0]."||".$argv[1];
     			$this->Subject = addslashes(substr($subj,$parent_end+3));
     		}
     */
     if (ereg('(\\[)([0-9]*)(\\])', $subj, $arr)) {
         $this->Parent = $arr[2];
         $parent_end = strpos($subj, '[' . $arr[2] . ']') + strlen('[' . $arr[2] . ']');
         $this->Subject = addslashes(substr($subj, $parent_end));
     } else {
         $this->Subject = addslashes($subj);
         $this->Parent = 0;
     }
     $this->Body =& addslashes($mp->getBody());
     //DBG( "body1:". $this->Body);
     $begin = strpos($this->Body, FORUM_MAIL_MARKER);
     if ($begin === false) {
         //do nothing
         return true;
     }
     // get the part of the message located after the marker
     $this->Body = substr($this->Body, $begin + strlen(FORUM_MAIL_MARKER));
     //DBG( "body2:". $this->Body);
     // now look for the ending marker
     $end = strpos($this->Body, FORUM_MAIL_MARKER);
     if ($end === false) {
         return true;
     }
     $message = substr($this->Body, 0, $end);
     $message = trim($message);
     // maybe the last line was "> (FORUM_MAIL_MARKER)". In that case, delete the last ">"
     $message = preg_replace('/>$/', '', $message);
     $this->Message = $message;
     return true;
 }
Example #2
0
 function parseMail($input_file)
 {
     global $argv;
     if (!($mp = new MailParser($input_file))) {
         $this->setError('Error In MailParser');
         return false;
     } elseif ($mp->isError()) {
         $this->setError('Error In MailParser ' . $mp->getErrorMessage());
         // even if it is an error, try to get the address of the sender so we
         // can send him back the error
         $this->FromEmail = $mp->getFromEmail();
         return false;
     }
     $this->FromEmail = $mp->getFromEmail();
     //
     //subjects are in this required format: '[group - tracker_name][123456] My Subject'
     //where 123456 is the artifact_id of the artifact message.
     //we parse that ID to get the artifact that this should post to
     //
     $subj = $mp->getSubject();
     if (ereg('(\\[)([0-9]*)(\\])', $subj, $arr)) {
         $this->ArtifactId = $arr[2];
         $artifactid_end = strpos($subj, '[' . $arr[2] . ']') + strlen('[' . $arr[2] . ']');
         $this->Subject = addslashes(substr($subj, $artifactid_end));
     } else {
         $this->Subject = addslashes($subj);
         $this->ArtifactId = 0;
         // Not supported at the moment
         $this->setError("ArtifactId needed at the moment. Artifact creation not supported");
         return false;
     }
     $body = addslashes($mp->getBody());
     // find first occurrence of the marker in the message
     $begin = strpos($body, ARTIFACT_MAIL_MARKER);
     if ($begin === false) {
         $this->setError("Response message wasn't found in your mail. Please verify that " . "you entered your message between the correct text markers." . "\nYour message was:" . "\n" . $mp->getBody());
         return false;
     }
     // get the part of the message located after the marker
     $body = substr($body, $begin + strlen(ARTIFACT_MAIL_MARKER));
     // now look for the ending marker
     $end = strpos($body, ARTIFACT_MAIL_MARKER);
     if ($end === false) {
         $this->setError("Response message wasn't found in your mail. Please verify that " . "you entered your message between the correct text markers." . "\nYour message was:" . "\n" . $mp->getBody());
         return false;
     }
     $message = substr($body, 0, $end);
     $message = trim($message);
     // maybe the last line was "> (ARTIFACT_MAIL_MARKER)". In that case, delete the last ">"
     $message = preg_replace('/>$/', '', $message);
     $this->Message = $message;
     return true;
 }