/** * Reloads the config values from the backup server. * @access public */ public function reloadBackupConfig() { $this->pop_host = shn_db_get_config("pop", "pop_host2"); $this->pop_port = shn_db_get_config("pop", "pop_port2"); $this->pop_popimap = shn_db_get_config("pop", "pop_popimap2"); $this->pop_ssl = shn_db_get_config("pop", "pop_ssl2"); $this->pop_cron = shn_db_get_config("pop", "pop_cron2"); $this->smtp_host = shn_db_get_config("pop", "smtp_host2"); $this->smtp_port = shn_db_get_config("pop", "smtp_port2"); $this->smtp_ssl = shn_db_get_config("pop", "smtp_ssl2"); $this->smtp_auth = shn_db_get_config("pop", "smtp_auth2"); $this->username = shn_db_get_config("pop", "pop_username2"); $this->password = shn_db_get_config("pop", "pop_password2"); $this->smtp_reply_address = shn_db_get_config("pop", "smtp_reply_address2"); }
private function loopInbox() { global $global; // download all message information from inbox $this->overview = imap_fetch_overview($this->mailbox, "1:" . $this->messageCount, 0); $this->size = sizeof($this->overview); // loop through each message for ($i = $this->size - 1; $i >= 0; $i--) { $raw = imap_fetchstructure($this->mailbox, $i); error_log("DUMPPPPPP::>>" . var_export($raw) . "<<::::"); $this->person = null; // clear out the last person... $this->person = new person(); $this->person->init(); $this->person->rep_uuid = 2; $this->ecode = 0; $this->toggleActivity = true; // retrieve current message's data $this->currentMessage = $this->overview[$i]; $this->currentSubject = $this->currentMessage->subject; $this->currentDate = $this->currentMessage->date; $this->currentFrom = $this->currentMessage->from; $this->currentAttachments = null; // reset from last person $this->currentAttachments = array(); $this->currentMessageHasXML = false; $this->senderAddress = $this->overview[$i]->from; $this->fixDate(); // reformat the date for our purposes $this->fixFrom(); // strip extra characters from the from field $this->fixAddress(); // fix email address of excess characters $this->getAttachmentsAndParseXML($i); // grab all attachments $this->messages .= "From: " . $this->currentFrom . "<br>"; $this->messages .= "Subject: " . $this->currentSubject . "<br>"; // Time Sensitive Action Required: NIH Password Expires on 04/04/2012 19:07:11 $needle[] = "/Time Sensitive Action Required/"; if (preg_match($needle[$i], $this->currentSubject) > 0) { global $conf; $body = "Please update the password on this account before it expires: <b>" . shn_db_get_config("mpres", "username") . "</b><br><br>Email Subject:<br>" . $this->currentSubject; $p = new pop(); $p->sendMessage($conf['audit_email'], "", "{ " . $conf['site_name'] . " Password Expiration Notice }", $body, $body); echo $p->spit(); // email has XML attachment.... } elseif ($this->currentMessageHasXML) { // catch all parsing errors... if ($this->ecode != 0) { $this->messages .= "LPF XML email found but failed during parsing with error code: " . $this->ecode . ".<br>"; $this->replyError("Your person record was successfully received, but we failed to parse the XML. Please report this to lpfsupport@mail.nih.gov"); // event is closed... error } elseif (!$this->person->isEventOpen()) { $this->messages .= "LPF XML email found however, the event being reported to is closed, so the person was not inserted.<br>"; $this->replyError("Your person record was successfully received, but the event you are reporting to is closed so the record was not inserted."); // insert! } else { $this->person->insert(); $this->mpresLog(); $this->messages .= "LPF XML email found and person <a href=\"https://" . $this->person->p_uuid . "\" target=\"_blank\">" . $this->person->p_uuid . "</a> inserted.<br>"; $this->replySuccess($this->person->p_uuid, $this->person->incident_id); } // unstructured email... attempt to parse subject } else { $this->person->incident_id = $this->incident_id; if (!$this->person->isEventOpen()) { $this->messages .= "Unstructured email found, however the event being reported to is closed, so the person was not inserted.<br>"; $this->replyError("We are not accepting email reports at this time. Sorry, but your person was not inserted into our system."); } else { $this->person->createUUID(); $this->extractStatusFromSubject(); $name = new nameParser($this->currentSubject); $this->person->given_name = $name->getFirstName(); $this->person->family_name = $name->getLastName(); $this->person->full_name = $this->person->given_name . " " . $this->person->family_name; $this->person->last_updated = date('Y-m-d H:i:s'); $this->person->creation_time = date('Y-m-d H:i:s'); $this->person->author_name = $this->currentFrom; $this->person->author_email = $this->currentFrom; $this->person->xmlFormat = "MPRES"; $this->person->arrival_vanilla_email = true; $this->person->insert(); $this->mpresLog(); $this->messages .= "Unstructured email found and person <a href=\"https://" . $this->person->p_uuid . "\" target=\"_blank\">" . $this->person->p_uuid . "</a> inserted.<br>"; $this->replySuccess($this->person->p_uuid, $this->person->incident_id); } } // delete the message from the inbox imap_delete($this->mailbox, $i + 1); $this->messages .= "Message #" . $i . " deleted.<br>"; } }