Posted on: 04/06/04 09:54am
By: lfalfa
#!/usr/local/bin/php -q <?php include('public_html/lib-common.php'); include('public_html/submit.php'); include('Mail_Mime-1.2.1/mimeDecode.php'); require_once 'Mail/RFC822.php'; // read from stdin $fd = fopen("php://stdin", "r"); $input = ""; while (!feof($fd)) { $input .= fread($fd, 1024); } fclose($fd); // Parse the incoming email $decode = new Mail_mimeDecode($input, "rn"); $structure = $decode->decode(array('include_bodies' => 1)); // See if this is a real user $rawEmail = $structure->headers['from']; $parsedEmail = Mail_RFC822::parseAddressList ($rawEmail); $email = $parsedEmail[0]->mailbox . "@" . $parsedEmail[0]->host; $uid = DB_getItem($_TABLES['users'], 'uid', "email = '{$email}'"); // Whether it's a real user or not, we'll need some more // data, either for the story submission or for the error msg $title = $structure->headers['subject']; // If this is a multipart message, then we have to iterate // through the parts to find the text/plain one. if ($structure->ctype_primary == 'text' && $structure->ctype_secondary == 'plain') { $introtext = $structure->body; } else { for ($i = 0; $i < count($structure->parts); $i++) { $aPart = $structure->parts[$i]; if ($aPart->ctype_primary == 'text' && $aPart->ctype_secondary == 'plain') { $introtext = $aPart->body; break; } } } if (!empty($uid)) { $postmode = 'plaintext'; $sid = COM_makesid(); $tid = 'Admin'; DB_save($_TABLES['storysubmission'],"sid,tid,uid,title,introtext,date,postmode","{$sid},'{$tid}',{$uid},'{$title}','{$introtext}',NOW(),'{$postmode}'",""); if (isset ($_CONF['notification']) && in_array ('story', $_CONF['notification'])) { $A['title'] = $title; $A['postmode'] = $postmode; $A['introtext'] = $introtext; $A['uid'] = $uid; $A['tid'] = $tid; // notify the site admin of a pending submission sendNotification ($_TABLES['storysubmission'], $A); // send notification of acceptance $acceptHeaders = "From: {$_CONF['site_name']} <{$_CONF['site_mail']}>rn" . "Return-Path: {$_CONF['site_mail']}rn" . "Content-Type: text/plain; charset=$charsetrn" . "X-Mailer: GeekLog " . VERSION; $acceptSubject = "Successfully processed Live From Arlington submission '$title'"; $acceptText = "Your story was successfully submitted.rn" . "An editor will review your story for approval as soon as possible.rn" . "Thank you for submitting your story!rnrn" . "-Live From Arlington Staff"; @mail( $email, $acceptSubject, $acceptText, $acceptHeaders ); } } else { // send polite rejection notice $rejectHeaders = "From: {$_CONF['site_name']} <{$_CONF['site_mail']}>rn" . "Return-Path: {$_CONF['site_mail']}rn" . "Content-Type: text/plain; charset=$charsetrn" . "X-Mailer: GeekLog " . VERSION; $rejectSubject = "Error processing Live From Arlington submission '$title'"; $rejectText = "Unfortunately, your story submission was not accepted.rn" . "An emailed story submission must be sent from the email addressrn" . "of a registered account.rnrn" . "Please sign up for an account at:rnrn" . " http://www.livefromarlington.com/users.php?mode=newrnrn" . "Or please resend your message from the email address of yourrn" . "existing account, if you have one.rnrn" . "Sorry for the inconvenience!rnrn" . "-Live From Arlington Staffrnrn" . "For your convenience, your submission appears below:rnrn"; $rejectText .= "Subject: " . $title . "rn"; $rejectText .= $introtext; @mail( $email, $rejectSubject, $rejectText, $rejectHeaders ); };
Posted on: 04/15/04 11:21am
By: Norgs
Posted on: 02/15/05 02:15pm
By: johnc10
Posted on: 02/15/05 02:27pm
By: Dirk
Posted on: 02/15/05 06:27pm
By: jlawrence
Posted on: 02/15/05 07:45pm
By: Marites
Posted on: 02/16/05 03:16am
By: johnc10