X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=mod%2Fsettings.php;h=22dc794dc054ff9b31ab4993419a7e72fe4f6072;hb=c052d688284fda76c612325b237d8352f2abb5d4;hp=1e82472f8c39a3c7da2bb773324f70d850e6b634;hpb=e2c9d04b368fa4eea6c86381e6216cda68fde9b4;p=friendica.git diff --git a/mod/settings.php b/mod/settings.php index 1e82472f8c..22dc794dc0 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -81,32 +81,37 @@ function settings_post(&$a) { $mail_replyto = ((x($_POST,'mail_replyto')) ? $_POST['mail_replyto'] : ''); $mail_pubmail = ((x($_POST,'mail_pubmail')) ? $_POST['mail_pubmail'] : ''); - $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1", - intval(local_user()) - ); - if(! count($r)) { - q("INSERT INTO `mailacct` (`uid`) VALUES (%d)", + + $mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1); + + if(! $mail_disabled) { + $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1", intval(local_user()) ); - } - if(strlen($mail_pass)) { - $pass = ''; - openssl(private_encrypt($mail_pass,$pass,$a->user['pubkey'])); - q("UPDATE `mailacct` SET `pass` = '%s' WHERE `uid` = %d LIMIT 1", - dbesc(hex2bin($pass)), + 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', + `mailbox` = 'INBOX', `reply_to` = '%s', `pubmail` = %d WHERE `uid` = %d LIMIT 1", + dbesc($mail_server), + intval($mail_port), + dbesc($mail_ssl), + dbesc($mail_user), + dbesc($mail_replyto), + intval($mail_pubmail), + intval(local_user()) ); } - $r = q("UPDATE `mailacct` SET `server` = '%s', `port` = %d, `ssltype` = '%s', `user` = '%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), - dbesc($mail_replyto), - intval($mail_pubmail), - intval(local_user()) - ); $notify = 0; @@ -285,19 +290,27 @@ function settings_content(&$a) { $timezone = date_default_timezone_get(); - $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1", - local_user() - ); + $mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1); - $mail_server = ((count($r)) ? $r[0]['server'] : ''); - $mail_port = ((count($r)) ? intval($r[0]['port']) : ''); - $mail_ssl = ((count($r)) ? $r[0]['ssltype'] : ''); - $mail_user = ((count($r)) ? $r[0]['user'] : ''); + if(! $mail_disabled) { + $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1", + local_user() + ); + } + else { + $r = null; + $imap_disabled = (($mail_disabled) ? ' disabled="disabled" ' : ''); + } + + $mail_server = ((count($r)) ? $r[0]['server'] : ''); + $mail_port = ((count($r) && intval($r[0]['port'])) ? intval($r[0]['port']) : ''); + $mail_ssl = ((count($r)) ? $r[0]['ssltype'] : ''); + $mail_user = ((count($r)) ? $r[0]['user'] : ''); $mail_replyto = ((count($r)) ? $r[0]['reply_to'] : ''); $mail_pubmail = ((count($r)) ? $r[0]['pubmail'] : 0); - $pageset_tpl = load_view_file('view/pagetypes.tpl'); + $pageset_tpl = file_get_contents('view/pagetypes.tpl'); $pagetype = replace_macros($pageset_tpl,array( '$normal' => (($a->user['page-flags'] == PAGE_NORMAL) ? " checked=\"checked\" " : ""), '$soapbox' => (($a->user['page-flags'] == PAGE_SOAPBOX) ? " checked=\"checked\" " : ""), @@ -331,7 +344,7 @@ function settings_content(&$a) { $profile_in_dir = ''; } else { - $opt_tpl = load_view_file("view/profile-in-directory.tpl"); + $opt_tpl = file_get_contents("view/profile-in-directory.tpl"); $profile_in_dir = replace_macros($opt_tpl,array( '$desc' => t('Publish your default profile in site directory?'), '$yes_str' => t('Yes'), @@ -342,7 +355,7 @@ function settings_content(&$a) { } if(strlen(get_config('system','directory_submit_url'))) { - $opt_tpl = load_view_file("view/profile-in-netdir.tpl"); + $opt_tpl = file_get_contents("view/profile-in-netdir.tpl"); $profile_in_net_dir = replace_macros($opt_tpl,array( '$desc' => t('Publish your default profile in global social directory?'), @@ -384,7 +397,7 @@ function settings_content(&$a) { $subdir = ((strlen($a->get_path())) ? '
' . t('or') . ' ' . $a->get_baseurl() . '/profile/' . $nickname : ''); - $tpl_addr = load_view_file("view/settings_nick_set.tpl"); + $tpl_addr = file_get_contents("view/settings_nick_set.tpl"); $prof_addr = replace_macros($tpl_addr,array( '$desc' => t('Your Identity Address is'), @@ -393,7 +406,7 @@ function settings_content(&$a) { '$basepath' => $a->get_hostname() )); - $stpl = load_view_file('view/settings.tpl'); + $stpl = file_get_contents('view/settings.tpl'); $celeb = ((($a->user['page-flags'] == PAGE_SOAPBOX) || ($a->user['page-flags'] == PAGE_COMMUNITY)) ? true : false); @@ -472,7 +485,8 @@ function settings_content(&$a) { '$imap_replyto' => $mail_replyto, '$lbl_imap7' => t('Send public posts to all email contacts:'), '$pubmail_checked' => (($mail_pubmail) ? ' checked="checked" ' : ''), - + '$mail_disabled' => (($mail_disabled) ? '
' . t('Email access is disabled on this site.') . '
' : ''), + '$imap_disabled' => $imap_disabled )); call_hooks('settings_form',$o);