multi-user, do not cache open mbox

This commit is contained in:
Friendika 2011-04-18 15:16:51 -07:00
parent 741a262f1b
commit 1e967eddb7
2 changed files with 22 additions and 24 deletions

View file

@ -2,7 +2,7 @@
set_time_limit(0); set_time_limit(0);
define ( 'FRIENDIKA_VERSION', '2.1.952' ); define ( 'FRIENDIKA_VERSION', '2.1.953' );
define ( 'DFRN_PROTOCOL_VERSION', '2.21' ); define ( 'DFRN_PROTOCOL_VERSION', '2.21' );
define ( 'DB_UPDATE_VERSION', 1053 ); define ( 'DB_UPDATE_VERSION', 1053 );

View file

@ -16,7 +16,6 @@ function poller_run($argv, $argc){
unset($db_host, $db_user, $db_pass, $db_data); unset($db_host, $db_user, $db_pass, $db_data);
}; };
$mbox = null;
require_once('session.php'); require_once('session.php');
require_once('datetime.php'); require_once('datetime.php');
@ -288,26 +287,25 @@ function poller_run($argv, $argc){
$xml = fetch_url($contact['poll']); $xml = fetch_url($contact['poll']);
} }
elseif($contact['network'] === NETWORK_MAIL) { elseif($contact['network'] === NETWORK_MAIL) {
if(! $mbox) { $mbox = null;
$x = q("SELECT `prvkey` FROM `user` WHERE `uid` = %d LIMIT 1", $x = q("SELECT `prvkey` FROM `user` WHERE `uid` = %d LIMIT 1",
intval($importer_uid) intval($importer_uid)
); );
$mailconf = q("SELECT * FROM `mailacct` WHERE `server` != '' AND `uid` = %d LIMIT 1", $mailconf = q("SELECT * FROM `mailacct` WHERE `server` != '' AND `uid` = %d LIMIT 1",
intval($importer_uid) intval($importer_uid)
); );
if(count($x) && count($mailconf)) { if(count($x) && count($mailconf)) {
$mailbox = construct_mailbox_name($mailconf[0]); $mailbox = construct_mailbox_name($mailconf[0]);
$password = ''; $password = '';
openssl_private_decrypt(hex2bin($mailconf[0]['pass']),$password,$x[0]['prvkey']); openssl_private_decrypt(hex2bin($mailconf[0]['pass']),$password,$x[0]['prvkey']);
$mbox = email_connect($mailbox,$mailconf[0]['user'],$password); $mbox = email_connect($mailbox,$mailconf[0]['user'],$password);
unset($password); unset($password);
if($mbox) { if($mbox) {
q("UPDATE `mailacct` SET `last_check` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1", q("UPDATE `mailacct` SET `last_check` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1",
dbesc(datetime_convert()), dbesc(datetime_convert()),
intval($mailconf[0]['id']), intval($mailconf[0]['id']),
intval($importer_uid) intval($importer_uid)
); );
}
} }
} }
if($mbox) { if($mbox) {
@ -383,6 +381,8 @@ function poller_run($argv, $argc){
); );
} }
} }
imap_close($mbox);
} }
} }
elseif($contact['network'] === NETWORK_FACEBOOK) { elseif($contact['network'] === NETWORK_FACEBOOK) {
@ -435,8 +435,6 @@ function poller_run($argv, $argc){
} }
} }
if($mbox && function_exists('imap_close'))
imap_close($mbox);
return; return;
} }