} } $validHeight = Config::get("WotD.wotdImageHeight") or die("No image height in config file\r\n"); $validWidth = Config::get("WotD.wotdImageWidth") or die("No image width in config file\r\n"); $daysInterval = Config::get("WotD.interval") or die("No days interval in config file\r\n"); $email = file_get_contents("php://stdin"); $Parser = new MimeMailParser(); $Parser->setText($email); $sender = $Parser->getHeader("from"); $subject = imap_utf8($Parser->getHeader("subject")); $parsedSender = mailparse_rfc822_parse_addresses($sender); if (count($parsedSender) != 1) { OS::errorAndExit("Ignoring message '{$subject}' due to invalid sender '{$sender}'", 0); } $from = $parsedSender[0]['address']; $artist = WotdArtist::get_by_email($from); if (!$artist) { OS::errorAndExit("Ignoring message '{$subject}' because sender '{$from}' is not a WotD artist", 0); } $word = GetWotdFromSubject($subject); $attachments = $Parser->getAttachments(); if (empty($attachments)) { OS::errorAndExit("Ignoring message '{$subject}' because it has no attachments", 0); } elseif (count($attachments) > 1) { OS::errorAndExit("Ignoring message '{$subject}' because it has more than 1 attachment", 0); } $contentType = $attachments[0]->content_type; if (!StringUtil::startsWith($contentType, "image/")) { OS::errorAndExit("Ignoring message '{$subject}' because its attachment is not an image", 0); } $image = $attachments[0]->content;