2016-08-26 12:43:45 +00:00
|
|
|
<?php
|
|
|
|
|
2016-08-31 11:53:46 +00:00
|
|
|
namespace Edi;
|
|
|
|
|
2018-05-23 10:14:20 +00:00
|
|
|
abstract class Method extends \Vn\Lib\Method {
|
2016-08-26 12:43:45 +00:00
|
|
|
protected $imap;
|
|
|
|
protected $imapConf;
|
|
|
|
protected $mailbox;
|
|
|
|
|
2018-05-23 10:14:20 +00:00
|
|
|
abstract function ediRun($db);
|
2016-08-26 12:43:45 +00:00
|
|
|
|
2018-05-23 10:14:20 +00:00
|
|
|
function run($db) {
|
|
|
|
$db->selectDb('edi');
|
2016-08-26 12:43:45 +00:00
|
|
|
|
2018-05-23 10:14:20 +00:00
|
|
|
$imapConf = $db->getRow(
|
2022-07-07 12:55:34 +00:00
|
|
|
"SELECT ic.host, ic.user, ic.pass, ic.successFolder, ic.errorFolder
|
|
|
|
FROM imapConfig ic
|
|
|
|
JOIN util.config c ON c.environment = ic.environment");
|
|
|
|
|
2018-05-23 10:14:20 +00:00
|
|
|
$this->mailbox = sprintf('{%s/imap/ssl/novalidate-cert}',
|
2016-08-26 12:43:45 +00:00
|
|
|
$imapConf['host']);
|
|
|
|
|
2018-05-23 10:14:20 +00:00
|
|
|
$imap = imap_open($this->mailbox
|
2016-08-26 12:43:45 +00:00
|
|
|
,$imapConf['user']
|
2018-05-23 10:14:20 +00:00
|
|
|
,base64_decode($imapConf['pass'])
|
2016-08-26 12:43:45 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
$this->imap = $imap;
|
|
|
|
$this->imapConf = $imapConf;
|
|
|
|
|
2018-05-23 10:14:20 +00:00
|
|
|
if ($imap) {
|
|
|
|
$this->ediRun($db);
|
|
|
|
imap_expunge($imap);
|
|
|
|
imap_close($imap);
|
2018-05-23 11:09:55 +00:00
|
|
|
} else
|
2018-05-23 10:14:20 +00:00
|
|
|
error_log(imap_last_error());
|
2016-08-26 12:43:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|