011
08.11.2004, 19:50 Uhr
FloSoft
Medialer Over-Flow (Administrator)
|
ich hab das mal so gemacht, auch wenn noch nicht alles erfasst wird:
PHP 4: |
function Parse_MultiPart($mail,$x,$body,$parts,$m) { if($m['boundary'] != "") { $mail2 = explode("--".$m['boundary'],$mail[$x]); for($z = 1; $z < count($mail2); $z++) { if($mail2[$z] != "--" && $mail2[$z] != "") { $m2 = array(); $head2 = substr($mail2[$z],0,strpos($mail2[$z],"\r\n\r\n")); $head2 = explode("\n",$head2); for($y = 0; $y < count($head2); $y++) { if(Parse_Check($head2[$y],"Content-Type:")) $m2 = Parse_ContentType($head2[$y],$m2,$head2,$z); if(Parse_Check($head2[$y],"Content-Transfer-Encoding:")) $m2 = Parse_ContentTransferEncoding($head2[$y],$m2); if(Parse_Check($head2[$y],"Content-Disposition:")) $m2 = Parse_ContentDisposition($head2[$y],$m2); if(Parse_Check($head2[$y],"Content-ID:")) $m2 = Parse_ContentID($head2[$y],$m2); } if(count($m2) > 0) { $body[$parts] = $m2; $body[$parts]['text'] = substr($mail2[$z],strpos($mail2[$z],"\r\n\r\n")+4); debug_out(3,$body[$parts]); $parts++; } } } } return(array($body,$parts)); }
function Parse_Body($header, $string) { global $config; if(intval(str_replace(".","",$header['mime_version'])) > 0) { switch($header['content_type']) { default: case "text/plain": { $body['parts'] = 1; $body[0]['content_type'] = ($header['content_type'] ? $header['content_type'] : "text/plain"); $body[0]['text'] = Decode_Body($header,$string); } break; case "multipart/mixed": case "multipart/alternative": case "multipart/related": { if($header['boundary'] != "") { $mail = explode("--".$header['boundary'],$string); $parts = 0; for($x = 0; $x < count($mail); $x++) { if($mail[$x] != "--" && $mail[$x] != "") { $m = array(); $head = substr($mail[$x],0,strpos($mail[$x],"\r\n\r\n")); $head = explode("\n",$head); for($y = 0; $y < count($head); $y++) { if(Parse_Check($head[$y],"Content-Type:")) $m = Parse_ContentType($head[$y],$m,$head,$y); if(Parse_Check($head[$y],"Content-Transfer-Encoding:")) $m = Parse_ContentTransferEncoding($head[$y],$m); if(Parse_Check($head[$y],"Content-Disposition:")) $m = Parse_ContentDisposition($head[$y],$m); if(Parse_Check($head[$y],"Content-ID:")) $m = Parse_ContentID($head[$y],$m); } switch($m['content_type']) { case "multipart/alternative": case "multipart/appledouble": { $a = Parse_MultiPart($mail,$x,$body,$parts,$m); $body = $a[0]; $parts = $a[1]; } break; default: { $body[$parts] = $m; $body[$parts]['text'] = substr($mail[$x],strpos($mail[$x],"\r\n\r\n")+4); $parts++; } break; } } } $body['parts'] = $parts; } else { } } break; } } else { $body['parts'] = 1; $body[0]['content_type'] = ($header['content_type'] ? $header['content_type'] : "text/plain"); $body[0]['text'] = Mail_MIME_Decode($string); } return $body; }
function Parse_Check($h,$string,$case = 1) { $string = strtolower($string); $h = strtolower($h); return (substr($h,0,strlen($string)) == $string); }
function Parse_ContentType($h,$mail,$header,$x) { $mail['content_type'] = Parse_GetString($h,"Content-type:"); $ct = $mail['content_type'];
$b = strstr($ct,"boundary="); if($b != FALSE) { $mail['boundary'] = Parse_GetString($b,"boundary"); $mail['content_type'] = trim(substr($ct,0,strpos($ct,$b))); $ct = $mail['content_type']; } else { $h = $header[$x+1]; $b = strstr($h,"boundary="); if($b != FALSE) $mail['boundary'] = Parse_GetString($b,"boundary"); } if(preg_match_all("/"(.*)"/U",$mail['boundary'], $out, PREG_SET_ORDER)) $mail['boundary'] = $out[0][1]; if(preg_match_all("/\"(.*)\"/U",$mail['boundary'], $out, PREG_SET_ORDER)) $mail['boundary'] = $out[0][1]; $c = strstr($ct,"charset="); if($c != FALSE) { $mail['charset'] = Parse_GetString($c,"charset"); $mail['content_type'] = trim(substr($ct,0,strpos($ct,$c))); $ct = $mail['content_type']; } else { $h = $header[$x+1]; $c = strstr($h,"charset="); if($c != FALSE) $mail['charset'] = Parse_GetString($c,"charset"); } if(preg_match_all("/"(.*)"/U",$mail['charset'], $out, PREG_SET_ORDER)) $mail['charset'] = $out[0][1]; if(preg_match_all("/\"(.*)\"/U",$mail['charset'], $out, PREG_SET_ORDER)) $mail['charset'] = $out[0][1]; $c = strstr($ct,"name="); if($c != FALSE) { $mail['content_name'] = Parse_GetString($c,"name"); $mail['content_type'] = trim(substr($ct,0,strpos($ct,$c))); $ct = $mail['content_type']; } else { $h = $header[$x+1]; $c = strstr($h,"name="); if($c != FALSE) $mail['content_name'] = Parse_GetString($c,"name"); } if(preg_match_all("/"(.*)"/U",$mail['content_name'], $out, PREG_SET_ORDER)) $mail['content_name'] = $out[0][1]; if(preg_match_all("/\"(.*)\"/U",$mail['content_name'], $out, PREG_SET_ORDER)) $mail['content_name'] = $out[0][1]; $mail['content_type'] = strtolower(trim($mail['content_type'])); $pos = strpos($mail['content_type'],";"); if($pos !== FALSE) $mail['content_type'] = substr($mail['content_type'],0,$pos); return $mail; }
function Parse_ContentTransferEncoding($h,$mail) { $mail['content_encoding'] = Parse_GetString($h,"Content-Transfer-Encoding:"); return $mail; }
|
-- class God : public ChuckNorris { }; Dieser Post wurde am 08.11.2004 um 19:50 Uhr von FloSoft editiert. |