#!/usr/local/bin/php -q \nReturn-Path: Phorummail <$email>"); } exit(); } // read in headers reset($stdin); // Would be nice to use array_shift() here, but that's PHP4 only. while (list($linenum,$line) = each($stdin)) { $line = trim($line); $parts=explode(": ", $line); $type=$parts[0]; unset($parts[0]); $value=trim(implode(": ", $parts)); // Use strtolower to avoid case problems $eHeaders[strtolower($type)]=$value; unset($stdin[$linenum]); if (empty($line)) { break; } } // read in the body ## We do this in the post function now. // $body=str_replace("\r\n", "\n", trim(implode("", $stdin))); $body.="\n\n"; $body.="------------------------------------------\n"; $body.="Posted to Phorum via PhorumMail\n"; if (empty($eHeaders["date"])) { $datestamp = date("Y-m-d H:i:s"); } else { $datestamp = date("Y-m-d H:i:s", strtotime($eHeaders["date"], time())); } if(@ereg("([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)", $eHeaders["received"], $regs)){ $ip=$regs[0]; } else{ $ip="PhorumMail"; } $host = @gethostbyaddr($ip); if (empty($eHeaders["from"])) { $author=''; $email=''; } else { if(ereg('"([^"]+)" <([^>]+)>', $eHeaders["from"], $regs)){ $author=$regs[1]; $email=$regs[2]; } else if(ereg('([^<]+)<([^>]+)>', $eHeaders["from"], $regs)){ $author=trim($regs[1]); $email=$regs[2]; } else if(substr($eHeaders["from"],0,1)=="<"){ $author=substr($eHeaders["from"], 1, -1); $email=$author; } else{ $author=$eHeaders["from"]; $email=$eHeaders["from"]; } } $thread = 0; $parent = 0; if (empty($eHeaders["subject"])) { $subject = ''; } else { $subject = trim($eHeaders["subject"]); // Strip out [$ForumEmailTag] if it exists. // Use eregi, because some software seems to tamper with the case of the tag! if (eregi("^([^[]*)\\[$ForumEmailTag\\](.*)$", $subject, $regs)) { $subject = trim($regs[1]) . ' ' . trim($regs[2]); $subject = trim($subject); } // Look for "[forum:thread:parent]" at the end of the subject // We aren't actually using these anymore, but their presence would // screw up the threading. if (ereg('^(.+) +\[([0-9]+):([0-9]+):([0-9]+)\]$', $subject, $regs)) { $subject = $regs[1]; // $forum=$regs[2]; // $thread=$regs[3]; // $parent=$regs[4]; } } $forum = $num; if (!empty($eHeaders["x-phorum-$phorummailcode-forum"]) && (strcmp($eHeaders["x-phorum-$phorummailcode-forum"],$ForumName) == 0)) { if (!empty($eHeaders["x-phorum-$phorummailcode-thread"])) { $thread = $eHeaders["x-phorum-$phorummailcode-thread"]; } if (!empty($eHeaders["x-phorum-$phorummailcode-parent"])) { $parent = $eHeaders["x-phorum-$phorummailcode-parent"]; } } $action="post"; $toaddress = empty($eHeaders["to"]) ? '' : $eHeaders["to"]; $msgid = empty($eHeaders["message-id"]) ? '' : $eHeaders["message-id"]; // The email this is a reply to should be in In-Reply-To, but some // mailers seem to use References instead. // Both fields can have multiple message ids in them, so just grab the first. $inreplyto = ''; if (@ereg('^(<[^>]+>)', $eHeaders["in-reply-to"], $regs)) { $inreplyto = $regs[1]; } else if (@ereg('^(<[^>]+>)', $eHeaders["references"], $regs)) { $inreplyto = $regs[1]; } $IsError = check_data($host, $author, $subject, $body, $email); if (!empty($IsError)) { violation(); } $author=trim($author); $subject=trim($subject); $email=trim($email); $body=chop($body); list($author, $subject, $email, $body) = censor($author, $subject, $email, $body); $author = addslashes($author); $email = addslashes($email); $subject = addslashes($subject); $body = addslashes($body); $plain_author=stripslashes($author); $plain_subject=stripslashes(ereg_replace("<[^>]+>", "", $subject)); $plain_body=stripslashes(ereg_replace("<[^>]+>", "", $body)); $author = htmlspecialchars($author); $email = htmlspecialchars($email); $subject = htmlspecialchars($subject); $org_attachment = ''; if(($email==$ForumModPass && $ForumModPass!="") || ($email==$Password && $Password!="")){ $ForumModeration=''; $email=$ForumModEmail; $author = "$author"; $subject = "$subject"; $body="$body"; $host="$ForumStaffHost"; } else{ $body=eregi_replace("", "", $body); if($ForumAllowHTML=="Y"){ $body="$body"; } } // If there are no Phorum headers, put it in the database. if(empty($eHeaders["x-phorum-$phorummailcode-version"])){ post_to_database(); } // Notify people who wanted replies sent to them post_to_email(); ?>