a few minor changes
This commit is contained in:
@@ -176,77 +176,6 @@ function settings_post(&$a) {
|
||||
|
||||
check_form_security_token_redirectOnErr('/settings/connectors', 'settings_connectors');
|
||||
|
||||
if(x($_POST, 'imap-submit')) {
|
||||
|
||||
$mail_server = ((x($_POST,'mail_server')) ? $_POST['mail_server'] : '');
|
||||
$mail_port = ((x($_POST,'mail_port')) ? $_POST['mail_port'] : '');
|
||||
$mail_ssl = ((x($_POST,'mail_ssl')) ? strtolower(trim($_POST['mail_ssl'])) : '');
|
||||
$mail_user = ((x($_POST,'mail_user')) ? $_POST['mail_user'] : '');
|
||||
$mail_pass = ((x($_POST,'mail_pass')) ? trim($_POST['mail_pass']) : '');
|
||||
$mail_action = ((x($_POST,'mail_action')) ? trim($_POST['mail_action']) : '');
|
||||
$mail_movetofolder = ((x($_POST,'mail_movetofolder')) ? trim($_POST['mail_movetofolder']) : '');
|
||||
$mail_replyto = ((x($_POST,'mail_replyto')) ? $_POST['mail_replyto'] : '');
|
||||
$mail_pubmail = ((x($_POST,'mail_pubmail')) ? $_POST['mail_pubmail'] : '');
|
||||
|
||||
|
||||
$mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1);
|
||||
if(get_config('system','dfrn_only'))
|
||||
$mail_disabled = 1;
|
||||
|
||||
if(! $mail_disabled) {
|
||||
$failed = false;
|
||||
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
|
||||
intval(local_user())
|
||||
);
|
||||
if(! count($r)) {
|
||||
q("INSERT INTO `mailacct` (`uid`) VALUES (%d)",
|
||||
intval(local_user())
|
||||
);
|
||||
}
|
||||
if(strlen($mail_pass)) {
|
||||
$pass = '';
|
||||
openssl_public_encrypt($mail_pass,$pass,$a->user['pubkey']);
|
||||
q("UPDATE `mailacct` SET `pass` = '%s' WHERE `uid` = %d LIMIT 1",
|
||||
dbesc(bin2hex($pass)),
|
||||
intval(local_user())
|
||||
);
|
||||
}
|
||||
$r = q("UPDATE `mailacct` SET `server` = '%s', `port` = %d, `ssltype` = '%s', `user` = '%s',
|
||||
`action` = %d, `movetofolder` = '%s',
|
||||
`mailbox` = 'INBOX', `reply_to` = '%s', `pubmail` = %d WHERE `uid` = %d LIMIT 1",
|
||||
dbesc($mail_server),
|
||||
intval($mail_port),
|
||||
dbesc($mail_ssl),
|
||||
dbesc($mail_user),
|
||||
intval($mail_action),
|
||||
dbesc($mail_movetofolder),
|
||||
dbesc($mail_replyto),
|
||||
intval($mail_pubmail),
|
||||
intval(local_user())
|
||||
);
|
||||
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
|
||||
intval(local_user())
|
||||
);
|
||||
if(count($r)) {
|
||||
$eacct = $r[0];
|
||||
require_once('include/email.php');
|
||||
$mb = construct_mailbox_name($eacct);
|
||||
if(strlen($eacct['server'])) {
|
||||
$dcrpass = '';
|
||||
openssl_private_decrypt(hex2bin($eacct['pass']),$dcrpass,$a->user['prvkey']);
|
||||
$mbox = email_connect($mb,$mail_user,$dcrpass);
|
||||
unset($dcrpass);
|
||||
if(! $mbox) {
|
||||
$failed = true;
|
||||
notice( t('Failed to connect with email account using the settings provided.') . EOL);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(! $failed)
|
||||
info( t('Email settings updated.') . EOL);
|
||||
}
|
||||
}
|
||||
|
||||
call_hooks('connector_settings_post', $_POST);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user