rendered paste body#!/usr/local/bin/php
<?php
// read from stdin
$fd = fopen("php://stdin", "r");
$email = "";
while (!feof($fd)) {
$email .= fread($fd, 1024);
}
fclose($fd);
// handle email
$lines = explode("\n", $email);
for ($i=0; $i<count($lines); $i++) {
$headers .= $lines[$i]."\n";
if (preg_match("/^Subject: (.*)/", $lines[$i], $matches)) {
$subject = $matches[1];
}
if (preg_match("/^Date: (.*)/", $lines[$i], $matches)) {
$recv_date = $matches[1];
}
if (preg_match("/^From: (.*)/", $lines[$i], $matches)) {
$from_email = $matches[1];
}
if (preg_match("/^Name: (.*)/", $lines[$i], $matches)) {
$name = $matches[1];
}
if (preg_match("/^Current URL: (.*)/", $lines[$i], $matches)) {
$current_url = $matches[1];
}
if (preg_match("/^Services Required: (.*)/", $lines[$i], $matches)) {
$serv_req = $matches[1];
}
if (preg_match("/^Site Type: (.*)/", $lines[$i], $matches)) {
$site_type = $matches[1];
}
if (preg_match("/^Site Features: (.*)/", $lines[$i], $matches)) {
$site_feat = $matches[1];
}
if (preg_match("/^Additional Services: (.*)/", $lines[$i], $matches)) {
$add_serv = $matches[1];
}
if (preg_match("/^Estimated Start Time: (.*)/", $lines[$i], $matches)) {
$est_start = $matches[1];
}
if (preg_match("/^Budget Range: (.*)/", $lines[$i], $matches)) {
$budget = $matches[1];
}
if (preg_match("/^Location: (.*)/", $lines[$i], $matches)) {
$location = $matches[1];
}
if (preg_match("/^Pages Required: (.*)/", $lines[$i], $matches)) {
$pages_req = $matches[1];
}
if (preg_match("/^Comments: (.*)/", $lines[$i], $matches)) {
$comments = $matches[1];
$j = 1;
while (strpos($lines[$i+$j],'-----') === false) {
$comments .= $lines[$i+$j];
$j++;
}
}
if (preg_match("/^Email Address: (.*)/", $lines[$i], $matches)) {
$email_listed = $matches[1];
}
if (preg_match("/^Phone: (.*)/", $lines[$i], $matches)) {
$phone = $matches[1];
}
if (preg_match("/^Contact Method: (.*)/", $lines[$i], $matches)) {
$contact = $matches[1];
}
}
$date_stamp = strtotime($recv_date);
$recv_date = date('n/j/y g:i a',$date_stamp);
?>