2016-08-26 12:43:45 +00:00
|
|
|
<?php
|
|
|
|
|
2016-08-31 11:53:46 +00:00
|
|
|
namespace Edi;
|
|
|
|
|
|
|
|
abstract class Method extends \Vn\Lib\Method
|
2016-08-26 12:43:45 +00:00
|
|
|
{
|
|
|
|
protected $imap;
|
|
|
|
protected $imapConf;
|
|
|
|
protected $mailbox;
|
|
|
|
|
2016-10-16 14:16:08 +00:00
|
|
|
abstract function ediRun ($db);
|
2016-08-26 12:43:45 +00:00
|
|
|
|
2016-10-16 14:16:08 +00:00
|
|
|
function run ($db)
|
2016-08-26 12:43:45 +00:00
|
|
|
{
|
|
|
|
$db->selectDb ('edi');
|
|
|
|
|
|
|
|
$imapConf = $db->getRow (
|
|
|
|
'SELECT host, user, pass, success_folder, error_folder FROM imap_config');
|
|
|
|
|
2016-12-05 12:39:29 +00:00
|
|
|
$this->mailbox = sprintf ('{%s/imap/ssl/novalidate-cert}',
|
2016-08-26 12:43:45 +00:00
|
|
|
$imapConf['host']);
|
|
|
|
|
|
|
|
$imap = imap_open ($this->mailbox
|
|
|
|
,$imapConf['user']
|
|
|
|
,base64_decode ($imapConf['pass'])
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->imap = $imap;
|
|
|
|
$this->imapConf = $imapConf;
|
|
|
|
|
|
|
|
if ($imap)
|
|
|
|
{
|
2016-10-16 14:16:08 +00:00
|
|
|
$this->ediRun ($db);
|
2016-08-26 12:43:45 +00:00
|
|
|
imap_expunge ($imap);
|
|
|
|
imap_close ($imap);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
error_log (imap_last_error ());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|