Пример #1
0
 function password_save()
 {
     $rcmail = rcmail::get_instance();
     $this->load_config();
     $this->add_texts('localization/');
     $this->register_handler('plugin.body', array($this, 'password_form'));
     $rcmail->output->set_pagetitle($this->gettext('changepasswd'));
     if (!isset($_POST['_confpasswd']) || !isset($_POST['_newpasswd'])) {
         $rcmail->output->command('display_message', $this->gettext('nopassword'), 'error');
     } elseif ($_POST['_confpasswd'] != $_POST['_newpasswd']) {
         $rcmail->output->command('display_message', $this->gettext('passwordinconsistency'), 'error');
     } elseif (strlen($_POST['_newpasswd']) < $rcmail->config->get('password_length')) {
         $rcmail->output->command('display_message', $this->gettext('passwordlenght') . $rcmail->config->get('password_length'), 'error');
     } else {
         $newpwd = get_input_value('_newpasswd', RCUBE_INPUT_POST);
         if (!($res = $this->_save($newpwd))) {
             $rcmail->output->command('display_message', $this->gettext('successfullysaved'), 'confirmation');
             $_SESSION['password'] = $rcmail->encrypt($newpwd);
         } else {
             $rcmail->output->command('display_message', $res, 'error');
         }
     }
     rcmail_overwrite_action('plugin.imscp_pw_changer');
     $rcmail->output->send('plugin');
 }
 function authenticate($args)
 {
     if (isset($_POST['_user']) && isset($_POST['_pass'])) {
         $args['host'] = $this->getHost(get_input_value('_user', RCUBE_INPUT_POST));
     }
     return $args;
 }
Пример #3
0
 function save()
 {
     $policy_id = get_input_value('_spampolicy_name', RCUBE_INPUT_POST);
     $move_junk = get_input_value('_spammove', RCUBE_INPUT_POST);
     if (!$move_junk) {
         $move_junk = 'n';
     } else {
         $move_junk = 'y';
     }
     try {
         $session_id = $this->soap->login($this->rcmail_inst->config->get('remote_soap_user'), $this->rcmail_inst->config->get('remote_soap_pass'));
         $mail_user = $this->soap->mail_user_get($session_id, array('login' => $this->rcmail_inst->user->data['username']));
         $spam_user = $this->soap->mail_spamfilter_user_get($session_id, array('email' => $mail_user[0]['email']));
         $uid = $this->soap->client_get_id($session_id, $mail_user[0]['sys_userid']);
         if ($spam_user[0]['id'] == '') {
             $params = array('server_id' => $mail_user[0]['server_id'], 'priority' => '5', 'policy_id' => $policy_id, 'email' => $mail_user[0]['email'], 'fullname' => $mail_user[0]['email'], 'local' => 'Y');
             $add = $this->soap->mail_spamfilter_user_add($session_id, $uid, $params);
         } else {
             $params = $spam_user[0];
             $params['policy_id'] = $policy_id;
             $update = $this->soap->mail_spamfilter_user_update($session_id, $uid, $spam_user[0]['id'], $params);
         }
         $params = $mail_user[0];
         unset($params['password']);
         unset($params['autoresponder_start_date']);
         unset($params['autoresponder_end_date']);
         $params['move_junk'] = $move_junk;
         $update = $this->soap->mail_user_update($session_id, $uid, $mail_user[0]['mailuser_id'], $params);
         $this->soap->logout($session_id);
         $this->rcmail_inst->output->command('display_message', $this->gettext('successfullysaved'), 'confirmation');
     } catch (SoapFault $e) {
         $this->rcmail_inst->output->command('display_message', 'Soap Error: ' . $e->getMessage(), 'error');
     }
     $this->init_html();
 }
Пример #4
0
 /**
  * Handler for request action
  */
 function save_vcard()
 {
     $this->add_texts('localization', true);
     $uid = get_input_value('_uid', RCUBE_INPUT_POST);
     $mbox = get_input_value('_mbox', RCUBE_INPUT_POST);
     $mime_id = get_input_value('_part', RCUBE_INPUT_POST);
     $rcmail = rcmail::get_instance();
     $part = $uid && $mime_id ? $rcmail->imap->get_message_part($uid, $mime_id) : null;
     $error_msg = $this->gettext('vcardsavefailed');
     if ($part && ($vcard = new rcube_vcard($part)) && $vcard->displayname && $vcard->email) {
         $contacts = $rcmail->get_address_book(null, true);
         // check for existing contacts
         $existing = $contacts->search('email', $vcard->email[0], true, false);
         if ($done = $existing->count) {
             $rcmail->output->command('display_message', $this->gettext('contactexists'), 'warning');
         } else {
             // add contact
             $success = $contacts->insert(array('name' => $vcard->displayname, 'firstname' => $vcard->firstname, 'surname' => $vcard->surname, 'email' => $vcard->email[0], 'vcard' => $vcard->export()));
             if ($success) {
                 $rcmail->output->command('display_message', $this->gettext('addedsuccessfully'), 'confirmation');
             } else {
                 $rcmail->output->command('display_message', $error_msg, 'error');
             }
         }
     } else {
         $rcmail->output->command('display_message', $error_msg, 'error');
     }
     $rcmail->output->send();
 }
 function password_save()
 {
     $rcmail = rcmail::get_instance();
     $this->load_config();
     $this->add_texts('localization/');
     $this->register_handler('plugin.body', array($this, 'password_form'));
     $rcmail->output->set_pagetitle($this->gettext('changepasswd'));
     $confirm = $rcmail->config->get('password_confirm_current');
     if ($confirm && !isset($_POST['_curpasswd']) || !isset($_POST['_newpasswd'])) {
         $rcmail->output->command('display_message', $this->gettext('nopassword'), 'error');
     } else {
         $curpwd = get_input_value('_curpasswd', RCUBE_INPUT_POST);
         $newpwd = get_input_value('_newpasswd', RCUBE_INPUT_POST);
         if ($confirm && $rcmail->decrypt($_SESSION['password']) != $curpwd) {
             $rcmail->output->command('display_message', $this->gettext('passwordincorrect'), 'error');
         } else {
             if (!($res = $this->_save($curpwd, $newpwd))) {
                 $rcmail->output->command('display_message', $this->gettext('successfullysaved'), 'confirmation');
                 $_SESSION['password'] = $rcmail->encrypt($newpwd);
             } else {
                 $rcmail->output->command('display_message', $res, 'error');
             }
         }
     }
     rcmail_overwrite_action('plugin.password');
     $rcmail->output->send('plugin');
 }
Пример #6
0
 function save_prefs($args)
 {
     if ($args['section'] == 'mailview') {
         $args['prefs']['hide_blockquote_limit'] = (int) get_input_value('_hide_blockquote_limit', RCUBE_INPUT_POST);
     }
     return $args;
 }
Пример #7
0
 function password_save()
 {
     $rcmail = rcmail::get_instance();
     $this->load_config();
     $this->add_texts('localization/');
     $this->register_handler('plugin.body', array($this, 'password_form'));
     $rcmail->output->set_pagetitle($this->gettext('changepasswd'));
     $confirm = $rcmail->config->get('password_confirm_current');
     $required_length = intval($rcmail->config->get('password_minimum_length'));
     $check_strength = $rcmail->config->get('password_require_nonalpha');
     if ($confirm && !isset($_POST['_curpasswd']) || !isset($_POST['_newpasswd'])) {
         $rcmail->output->command('display_message', $this->gettext('nopassword'), 'error');
     } else {
         $charset = strtoupper($rcmail->config->get('password_charset', 'ISO-8859-1'));
         $rc_charset = strtoupper($rcmail->output->get_charset());
         $curpwd = get_input_value('_curpasswd', RCUBE_INPUT_POST, true, $charset);
         $newpwd = get_input_value('_newpasswd', RCUBE_INPUT_POST, true);
         $conpwd = get_input_value('_confpasswd', RCUBE_INPUT_POST, true);
         // check allowed characters according to the configured 'password_charset' option
         // by converting the password entered by the user to this charset and back to UTF-8
         $orig_pwd = $newpwd;
         $chk_pwd = rcube_charset_convert($orig_pwd, $rc_charset, $charset);
         $chk_pwd = rcube_charset_convert($chk_pwd, $charset, $rc_charset);
         // WARNING: Default password_charset is ISO-8859-1, so conversion will
         // change national characters. This may disable possibility of using
         // the same password in other MUA's.
         // We're doing this for consistence with Roundcube core
         $newpwd = rcube_charset_convert($newpwd, $rc_charset, $charset);
         $conpwd = rcube_charset_convert($conpwd, $rc_charset, $charset);
         if ($chk_pwd != $orig_pwd) {
             $rcmail->output->command('display_message', $this->gettext('passwordforbidden'), 'error');
         } else {
             if ($conpwd != $newpwd) {
                 $rcmail->output->command('display_message', $this->gettext('passwordinconsistency'), 'error');
             } else {
                 if ($confirm && $rcmail->decrypt($_SESSION['password']) != $curpwd) {
                     $rcmail->output->command('display_message', $this->gettext('passwordincorrect'), 'error');
                 } else {
                     if ($required_length && strlen($newpwd) < $required_length) {
                         $rcmail->output->command('display_message', $this->gettext(array('name' => 'passwordshort', 'vars' => array('length' => $required_length))), 'error');
                     } else {
                         if ($check_strength && (!preg_match("/[0-9]/", $newpwd) || !preg_match("/[^A-Za-z0-9]/", $newpwd))) {
                             $rcmail->output->command('display_message', $this->gettext('passwordweak'), 'error');
                         } else {
                             if (!($res = $this->_save($curpwd, $newpwd))) {
                                 $rcmail->output->command('display_message', $this->gettext('successfullysaved'), 'confirmation');
                                 $_SESSION['password'] = $rcmail->encrypt($newpwd);
                             } else {
                                 $rcmail->output->command('display_message', $res, 'error');
                             }
                         }
                     }
                 }
             }
         }
     }
     rcmail_overwrite_action('plugin.password');
     $rcmail->output->send('plugin');
 }
Пример #8
0
 function preferences_save($p)
 {
     try {
         $this->saveData(array('ar_enabled' => get_input_value('_ar_enabled', RCUBE_INPUT_POST), 'ar_subject' => get_input_value('_ar_subject', RCUBE_INPUT_POST), 'ar_body' => get_input_value('_ar_body', RCUBE_INPUT_POST), 'ar_ae_enabled' => get_input_value('_ar_ae_enabled', RCUBE_INPUT_POST), 'ar_ae_date' => get_input_value('_ar_ae_date', RCUBE_INPUT_POST), 'fw_enabled' => get_input_value('_fw_enabled', RCUBE_INPUT_POST), 'fw_address' => get_input_value('_fw_address', RCUBE_INPUT_POST), 'fw_keeporiginal' => get_input_value('_fw_keeporiginal', RCUBE_INPUT_POST)));
     } catch (Exception $e) {
         $p['abort'] = true;
         $p['result'] = false;
         $p['message'] = $e->getMessage();
     }
     return $p;
 }
 function save()
 {
     $id = rcube_utils::get_input_value('_id', RCUBE_INPUT_POST);
     $name = rcube_utils::get_input_value('_filtername', RCUBE_INPUT_POST);
     $source = rcube_utils::get_input_value('_filtersource', RCUBE_INPUT_POST);
     $op = rcube_utils::get_input_value('_filterop', RCUBE_INPUT_POST);
     $searchterm = rcube_utils::get_input_value('_filtersearchterm', RCUBE_INPUT_POST);
     $action = rcube_utils::get_input_value('_filteraction', RCUBE_INPUT_POST);
     $target = mb_convert_encoding(get_input_value('_filtertarget', RCUBE_INPUT_POST), 'UTF-8', 'UTF7-IMAP');
     $enabled = rcube_utils::get_input_value('_filterenabled', RCUBE_INPUT_POST);
     if (!$enabled) {
         $enabled = 'n';
     } else {
         $enabled = 'y';
     }
     try {
         $session_id = $this->soap->login($this->rcmail_inst->config->get('remote_soap_user'), $this->rcmail_inst->config->get('remote_soap_pass'));
         $mail_user = $this->soap->mail_user_get($session_id, array('login' => $this->rcmail_inst->user->data['username']));
         $mail_server = $this->soap->server_get($session_id, $mail_user[0]['server_id'], 'mail');
         $uid = $this->soap->client_get_id($session_id, $mail_user[0]['sys_userid']);
         if ($mail_server['mail_filter_syntax'] == 'maildrop') {
             $target = str_replace("INBOX.", "", $target);
         }
         if ($id == 0 || $id == '') {
             $filter = $this->soap->mail_user_filter_get($session_id, array('mailuser_id' => $mail_user[0]['mailuser_id']));
             $limit = $this->rcmail_inst->config->get('filter_limit');
             if (count($filter) < $limit) {
                 $params = array('mailuser_id' => $mail_user[0]['mailuser_id'], 'rulename' => $name, 'source' => $source, 'searchterm' => $searchterm, 'op' => $op, 'action' => $action, 'target' => $target, 'active' => $enabled);
                 $add = $this->soap->mail_user_filter_add($session_id, $uid, $params);
                 $this->rcmail_inst->output->command('display_message', $this->gettext('successfullysaved'), 'confirmation');
             } else {
                 $this->rcmail_inst->output->command('display_message', 'Error: ' . $this->gettext('filterlimitreached'), 'error');
             }
         } else {
             $filter = $this->soap->mail_user_filter_get($session_id, $id);
             if ($filter['mailuser_id'] == $mail_user[0]['mailuser_id']) {
                 $params = array('mailuser_id' => $mail_user[0]['mailuser_id'], 'rulename' => $name, 'source' => $source, 'searchterm' => $searchterm, 'op' => $op, 'action' => $action, 'target' => $target, 'active' => $enabled);
                 $update = $this->soap->mail_user_filter_update($session_id, $uid, $id, $params);
             } else {
                 $this->rcmail_inst->output->command('display_message', 'Error: ' . $this->gettext('opnotpermitted'), 'error');
             }
         }
         $this->soap->logout($session_id);
     } catch (SoapFault $e) {
         $this->rcmail_inst->output->command('display_message', 'Soap Error: ' . $e->getMessage(), 'error');
     }
     $this->init_html();
 }
Пример #10
0
 public function readfolder()
 {
     $imap = rcmail::get_instance()->imap;
     $cbox = get_input_value('_cur', RCUBE_INPUT_GET);
     $mbox = get_input_value('_mbox', RCUBE_INPUT_GET);
     $uids = $imap->search_once($mbox, 'ALL UNSEEN', true);
     if (!is_array($uids)) {
         return false;
     }
     $imap->set_flag($uids, 'SEEN', $mbox);
     if ($cbox == $mbox) {
         $this->api->output->command('toggle_read_status', 'read', $uids);
     }
     rcmail_send_unread_count($mbox, true);
     $this->api->output->send();
 }
Пример #11
0
 function request_action()
 {
     $this->add_texts('localization');
     $GLOBALS['IMAP_FLAGS']['JUNK'] = 'Junk';
     $GLOBALS['IMAP_FLAGS']['NONJUNK'] = 'NonJunk';
     $uids = get_input_value('_uid', RCUBE_INPUT_POST);
     $mbox = get_input_value('_mbox', RCUBE_INPUT_POST);
     $rcmail = rcmail::get_instance();
     $rcmail->imap->unset_flag($uids, 'NONJUNK');
     $rcmail->imap->set_flag($uids, 'JUNK');
     if (($junk_mbox = $rcmail->config->get('junk_mbox')) && $mbox != $junk_mbox) {
         $rcmail->output->command('move_messages', $junk_mbox);
     }
     $rcmail->output->command('display_message', $this->gettext('reportedasjunk'), 'confirmation');
     $rcmail->output->send();
 }
Пример #12
0
 function change_charset($args)
 {
     if ($msg_uid = get_input_value('_uid', RCUBE_INPUT_GET)) {
         $rcmail = rcmail::get_instance();
         $alter_charset = (array) $rcmail->config->get('alter_charset', array());
         $headers = $rcmail->imap->get_headers($msg_uid);
         if ($alias_charset = get_input_value('_alter_charset', RCUBE_INPUT_GET)) {
             $output_charset = $alter_charset[$alias_charset];
         }
         $input_charset = $rcmail->output->get_charset();
         $charset = $this->charset($msg_uid);
         $msg_body = rcube_charset_convert($args[body], $input_charset, $charset);
         $args['body'] = rcube_charset_convert($msg_body, $output_charset);
         return $args;
     }
 }
Пример #13
0
 function saveSmtpSettings($args)
 {
     $identities = rcmail::get_instance()->config->get('identity_smtp');
     $id = intval($args['id']);
     if (!isset($identities)) {
         $identities = array();
     }
     $smtp_standard = get_input_value('_smtp_standard', RCUBE_INPUT_POST);
     $password = get_input_value('_smtp_pass', RCUBE_INPUT_POST);
     if ($password != $identities[$id]['smtp_pass']) {
         $password = rcmail::get_instance()->encrypt($password);
     }
     $smtpSettingsRecord = array('smtp_standard' => isset($smtp_standard), 'smtp_server' => get_input_value('_smtp_server', RCUBE_INPUT_POST), 'smtp_port' => get_input_value('_smtp_port', RCUBE_INPUT_POST), 'smtp_user' => get_input_value('_smtp_user', RCUBE_INPUT_POST), 'smtp_pass' => $password);
     unset($identities[$id]);
     $identities += array($id => $smtpSettingsRecord);
     rcmail::get_instance()->user->save_prefs(array('identity_smtp' => $identities));
 }
Пример #14
0
 /**
  * Handler for submitted form
  *
  * Check fields and save to default identity if valid.
  * Afterwards the session flag is removed and we're done.
  */
 function save_data()
 {
     $rcmail = rcmail::get_instance();
     $identity = $rcmail->user->get_identity();
     $identities_level = intval($rcmail->config->get('identities_level', 0));
     $save_data = array('name' => get_input_value('_name', RCUBE_INPUT_POST), 'email' => get_input_value('_email', RCUBE_INPUT_POST));
     // don't let the user alter the e-mail address if disabled by config
     if ($identities_level == 1 || $identities_level == 3) {
         $save_data['email'] = $identity['email'];
     }
     // save data if not empty
     if (!empty($save_data['name']) && !empty($save_data['email'])) {
         $rcmail->user->update_identity($identity['identity_id'], $save_data);
         $rcmail->session->remove('plugin.newuserdialog');
     }
     $rcmail->output->redirect('');
 }
 function pfadmin_autoresponder_save()
 {
     $rcmail = rcmail::get_instance();
     $user = $rcmail->user->data['username'];
     $enabled = get_input_value('_autoresponderenabled', RCUBE_INPUT_POST);
     if (!$enabled) {
         $enabled = 0;
     }
     if (isset($_SESSION['dnsblacklisted']) && $_SESSION['dnsblacklisted'] != 'pass') {
         $enabled = 0;
     }
     $subject = get_input_value('_autorespondersubject', RCUBE_INPUT_POST);
     $body = get_input_value('_autoresponderbody', RCUBE_INPUT_POST);
     $date = get_input_value('_autoresponderdate', RCUBE_INPUT_POST);
     $datefrom = get_input_value('_autoresponderdatefrom', RCUBE_INPUT_POST);
     // check $datefrom
     if (preg_match("/^\\s*\$/", $datefrom) or !preg_match($this->date_format_regexp, $datefrom)) {
         $datefrom = "now()";
     }
     if (preg_match("/^\\s*\$/", $date) or !preg_match($this->date_format_regexp, $date)) {
         $date = "NULL";
     }
     if (!$enabled) {
         $date = $datefrom = "NULL";
     }
     if (!($res = $this->_save($user, $enabled, $subject, $body, $date, $datefrom))) {
         if (isset($_SESSION['dnsblacklisted']) && $_SESSION['dnsblacklisted'] != 'pass') {
             $this->add_texts('../dnsbl/localization/');
             $rcmail->output->command('display_message', sprintf(rcube_label('dnsblacklisted', 'pfadmin_autoresponder'), $_SESSION['clientip']), 'error');
         } else {
             $rcmail->output->command('display_message', $this->gettext('successfullysaved'), 'confirmation');
         }
     } else {
         $rcmail->output->command('display_message', "DUPA." . $res, 'error');
     }
     if (!$rcmail->config->get('db_persistent')) {
         if ($dsn = $rcmail->config->get('db_dsnw')) {
             $rcmail->db = rcube_db::factory($dsn, '', false);
         }
     }
     $this->pfadmin_autoresponder_init();
 }
 function save()
 {
     $enabled = get_input_value('_autoreplyenabled', RCUBE_INPUT_POST);
     $body = get_input_value('_autoreplybody', RCUBE_INPUT_POST);
     $subject = get_input_value('_autoreplysubject', RCUBE_INPUT_POST);
     $startdate = get_input_value('_autoreplystarton', RCUBE_INPUT_POST);
     $enddate = get_input_value('_autoreplyendby', RCUBE_INPUT_POST);
     $server_tz = new DateTimeZone(date_default_timezone_get());
     $server_offset = $server_tz->getOffset(new DateTime());
     $user_tz = new DateTimeZone($this->rcmail_inst->config->get('timezone'));
     $user_offset = $user_tz->getOffset(new DateTime());
     $startdate = strtotime($startdate) - ($user_offset - $server_offset);
     $enddate = strtotime($enddate) - ($user_offset - $server_offset);
     if ($enddate < $startdate) {
         $enddate = $startdate + 86400;
     }
     $startdate = array('year' => date("Y", $startdate), 'month' => date("m", $startdate), 'day' => date("d", $startdate), 'hour' => date("H", $startdate), 'minute' => date("i", $startdate));
     $enddate = array('year' => date("Y", $enddate), 'month' => date("m", $enddate), 'day' => date("d", $enddate), 'hour' => date("H", $enddate), 'minute' => date("i", $enddate));
     if (!$enabled) {
         $enabled = 'n';
     } else {
         $enabled = 'y';
     }
     try {
         $session_id = $this->soap->login($this->rcmail_inst->config->get('remote_soap_user'), $this->rcmail_inst->config->get('remote_soap_pass'));
         $mail_user = $this->soap->mail_user_get($session_id, array('login' => $this->rcmail_inst->user->data['username']));
         $uid = $this->soap->client_get_id($session_id, $mail_user[0]['sys_userid']);
         $params = $mail_user[0];
         unset($params['password']);
         $params['autoresponder'] = $enabled;
         $params['autoresponder_text'] = $body;
         $params['autoresponder_subject'] = $subject;
         $params['autoresponder_start_date'] = $startdate;
         $params['autoresponder_end_date'] = $enddate;
         $update = $this->soap->mail_user_update($session_id, $uid, $mail_user[0]['mailuser_id'], $params);
         $this->soap->logout($session_id);
         $this->rcmail_inst->output->command('display_message', $this->gettext('successfullysaved'), 'confirmation');
     } catch (SoapFault $e) {
         $this->rcmail_inst->output->command('display_message', 'Soap Error: ' . $e->getMessage(), 'error');
     }
     $this->init_html();
 }
Пример #17
0
 function password_save()
 {
     $rcmail = rcmail::get_instance();
     $this->load_config();
     $this->add_texts('localization/');
     $this->register_handler('plugin.body', array($this, 'password_form'));
     $rcmail->output->set_pagetitle($this->gettext('changepasswd'));
     $confirm = $rcmail->config->get('password_confirm_current');
     $required_length = intval($rcmail->config->get('password_minimum_length'));
     $check_strength = $rcmail->config->get('password_require_nonalpha');
     if ($confirm && !isset($_POST['_curpasswd']) || !isset($_POST['_newpasswd'])) {
         $rcmail->output->command('display_message', $this->gettext('nopassword'), 'error');
     } else {
         $curpwd = get_input_value('_curpasswd', RCUBE_INPUT_POST);
         $newpwd = get_input_value('_newpasswd', RCUBE_INPUT_POST);
         $conpwd = get_input_value('_confpasswd', RCUBE_INPUT_POST);
         if ($conpwd != $newpwd) {
             $rcmail->output->command('display_message', $this->gettext('passwordinconsistency'), 'error');
         } else {
             if ($confirm && $rcmail->decrypt($_SESSION['password']) != $curpwd) {
                 $rcmail->output->command('display_message', $this->gettext('passwordincorrect'), 'error');
             } else {
                 if ($required_length && strlen($newpwd) < $required_length) {
                     $rcmail->output->command('display_message', $this->gettext(array('name' => 'passwordshort', 'vars' => array('length' => $required_length))), 'error');
                 } else {
                     if ($check_strength && (!preg_match("/[0-9]/", $newpwd) || !preg_match("/[^A-Za-z0-9]/", $newpwd))) {
                         $rcmail->output->command('display_message', $this->gettext('passwordweak'), 'error');
                     } else {
                         if (!($res = $this->_save($curpwd, $newpwd))) {
                             $rcmail->output->command('display_message', $this->gettext('successfullysaved'), 'confirmation');
                             $_SESSION['password'] = $rcmail->encrypt($newpwd);
                         } else {
                             $rcmail->output->command('display_message', $res, 'error');
                         }
                     }
                 }
             }
         }
     }
     rcmail_overwrite_action('plugin.password');
     $rcmail->output->send('plugin');
 }
 function login_after($args)
 {
     if (!$this->is_enabled() || !$this->is_required()) {
         return $args;
     }
     $otp = get_input_value('_yubikey', RCUBE_INPUT_POST);
     $id = $this->get('yubikey_id');
     $id2 = $this->get('yubikey_id2');
     $id3 = $this->get('yubikey_id3');
     $url = $this->get('yubikey_api_url');
     $https = true;
     if (!empty($url) && ($_url = parse_url($url))) {
         if ($_url['scheme'] == "http") {
             $https = false;
         }
         $urlpart = $_url['host'];
         if (!empty($_url['port'])) {
             $urlpart .= ':' . $_url['port'];
         }
         $urlpart .= $_url['path'];
     }
     // make sure that there is a YubiKey ID in the user's prefs
     // and that it matches the first 12 characters of the OTP
     if (empty($id) && empty($id2) && empty($id3)) {
         $this->fail();
     }
     if (substr($otp, 0, 12) !== $id && substr($otp, 0, 12) !== $id2 && substr($otp, 0, 12) !== $id3) {
         $this->fail();
     } else {
         try {
             $yubi = new Auth_Yubico($this->get('yubikey_api_id'), $this->get('yubikey_api_key'), $https, true);
             if (!empty($urlpart)) {
                 $yubi->addURLpart($urlpart);
             }
             $yubi->verify($otp);
         } catch (Exception $e) {
             $this->fail();
         }
     }
     return $args;
 }
Пример #19
0
 /**
  * Plugin initialization.
  */
 function init()
 {
     $rcmail = rcmail::get_instance();
     $this->rc = $rcmail;
     if ($this->rc->task == 'mail') {
         // message parse/display hooks
         $this->add_hook('message_part_structure', array($this, 'parse_structure'));
         $this->add_hook('message_body_prefix', array($this, 'status_message'));
         // message displaying
         if ($rcmail->action == 'show' || $rcmail->action == 'preview') {
             $this->add_hook('message_load', array($this, 'message_load'));
             $this->add_hook('template_object_messagebody', array($this, 'message_output'));
             $this->register_action('plugin.enigmaimport', array($this, 'import_file'));
         } else {
             if ($rcmail->action == 'compose') {
                 $this->load_ui();
                 $this->ui->init($section);
             } else {
                 if ($rcmail->action == 'sendmail') {
                     //$this->add_hook('outgoing_message_body', array($this, 'msg_encode'));
                     //$this->add_hook('outgoing_message_body', array($this, 'msg_sign'));
                 }
             }
         }
     } else {
         if ($this->rc->task == 'settings') {
             // add hooks for Enigma settings
             $this->add_hook('preferences_sections_list', array($this, 'preferences_section'));
             $this->add_hook('preferences_list', array($this, 'preferences_list'));
             $this->add_hook('preferences_save', array($this, 'preferences_save'));
             // register handler for keys/certs management
             $this->register_action('plugin.enigma', array($this, 'preferences_ui'));
             // grab keys/certs management iframe requests
             $section = get_input_value('_section', RCUBE_INPUT_GET);
             if ($this->rc->action == 'edit-prefs' && preg_match('/^enigma(certs|keys)/', $section)) {
                 $this->load_ui();
                 $this->ui->init($section);
             }
         }
     }
 }
Пример #20
0
 function save()
 {
     $enabled = get_input_value('_autoreplyenabled', RCUBE_INPUT_POST);
     $body = get_input_value('_autoreplybody', RCUBE_INPUT_POST);
     $subject = get_input_value('_autoreplysubject', RCUBE_INPUT_POST);
     $startdate = get_input_value('_autoreplystarton', RCUBE_INPUT_POST);
     $enddate = get_input_value('_autoreplyendby', RCUBE_INPUT_POST);
     if (strtotime($enddate) < strtotime($startdate)) {
         $enddate = $startdate;
     }
     $startdate = gmdate("Y-m-d H:i", strtotime($startdate));
     $enddate = gmdate("Y-m-d H:i", strtotime($enddate));
     $startdate = array('year' => substr($startdate, 0, 4), 'month' => substr($startdate, 5, 2), 'day' => substr($startdate, 8, 2), 'hour' => substr($startdate, 11, 2), 'minute' => substr($startdate, 14, 2));
     $enddate = array('year' => substr($enddate, 0, 4), 'month' => substr($enddate, 5, 2), 'day' => substr($enddate, 8, 2), 'hour' => substr($enddate, 11, 2), 'minute' => substr($enddate, 14, 2));
     if (!$enabled) {
         $enabled = 'n';
     } else {
         $enabled = 'y';
     }
     try {
         $session_id = $this->soap->login($this->rcmail_inst->config->get('remote_soap_user'), $this->rcmail_inst->config->get('remote_soap_pass'));
         $mail_user = $this->soap->mail_user_get($session_id, array('login' => $this->rcmail_inst->user->data['username']));
         $uid = $this->soap->client_get_id($session_id, $mail_user[0]['sys_userid']);
         $params = $mail_user[0];
         unset($params['password']);
         $params['autoresponder'] = $enabled;
         $params['autoresponder_text'] = $body;
         $params['autoresponder_subject'] = $subject;
         $params['autoresponder_start_date'] = $startdate;
         $params['autoresponder_end_date'] = $enddate;
         $update = $this->soap->mail_user_update($session_id, $uid, $mail_user[0]['mailuser_id'], $params);
         $this->soap->logout($session_id);
         $this->rcmail_inst->output->command('display_message', $this->gettext('successfullysaved'), 'confirmation');
     } catch (SoapFault $e) {
         $this->rcmail_inst->output->command('display_message', 'Soap Error: ' . $e->getMessage(), 'error');
     }
     $this->init_html();
 }
Пример #21
0
 function init()
 {
     $rcmail = rcmail::get_instance();
     $this->load_config();
     if ($rcmail->config->get('sauserprefs_whitelist_abook_id', false)) {
         $this->addressbook = $rcmail->config->get('sauserprefs_whitelist_abook_id');
     }
     if ($rcmail->task == 'settings') {
         $this->add_texts('localization/', array('sauserprefs'));
         $this->sections = array('general' => array('id' => 'general', 'section' => $this->gettext('spamgeneralsettings')), 'tests' => array('id' => 'tests', 'section' => $this->gettext('spamtests')), 'bayes' => array('id' => 'bayes', 'section' => $this->gettext('bayes')), 'headers' => array('id' => 'headers', 'section' => $this->gettext('headers')), 'report' => array('id' => 'report', 'section' => $this->gettext('spamreportsettings')), 'addresses' => array('id' => 'addresses', 'section' => $this->gettext('spamaddressrules')));
         $this->cur_section = get_input_value('_section', RCUBE_INPUT_GPC);
         $this->register_action('plugin.sauserprefs', array($this, 'init_html'));
         $this->register_action('plugin.sauserprefs.edit', array($this, 'init_html'));
         $this->register_action('plugin.sauserprefs.save', array($this, 'save'));
         $this->register_action('plugin.sauserprefs.whitelist_import', array($this, 'whitelist_import'));
         $this->register_action('plugin.sauserprefs.purge_bayes', array($this, 'purge_bayes'));
         $this->include_script('sauserprefs.js');
     } elseif ($rcmail->config->get('sauserprefs_whitelist_sync')) {
         $this->add_hook('contact_create', array($this, 'contact_add'));
         $this->add_hook('contact_update', array($this, 'contact_save'));
         $this->add_hook('contact_delete', array($this, 'contact_delete'));
     }
 }
Пример #22
0
 function save()
 {
     $address = strtolower(get_input_value('_forwardingaddress', RCUBE_INPUT_POST));
     try {
         $session_id = $this->soap->login($this->rcmail_inst->config->get('remote_soap_user'), $this->rcmail_inst->config->get('remote_soap_pass'));
         $mail_user = $this->soap->mail_user_get($session_id, array('login' => $this->rcmail_inst->user->data['username']));
         if ($address == $mail_user[0]['email']) {
             $this->rcmail_inst->output->command('display_message', $this->gettext('forwardingloop'), 'error');
         } else {
             $uid = $this->soap->client_get_id($session_id, $mail_user[0]['sys_userid']);
             $params = $mail_user[0];
             unset($params['password']);
             unset($params['autoresponder_start_date']);
             unset($params['autoresponder_end_date']);
             $params['cc'] = $address;
             $update = $this->soap->mail_user_update($session_id, $uid, $mail_user[0]['mailuser_id'], $params);
             $this->rcmail_inst->output->command('display_message', $this->gettext('successfullysaved'), 'confirmation');
         }
         $this->soap->logout($session_id);
     } catch (SoapFault $e) {
         $this->rcmail_inst->output->command('display_message', 'Soap Error: ' . $e->getMessage(), 'error');
     }
     $this->init_html();
 }
Пример #23
0
 /**
  * Handler for keys/certs import request action
  */
 function import_file()
 {
     $uid = get_input_value('_uid', RCUBE_INPUT_POST);
     $mbox = get_input_value('_mbox', RCUBE_INPUT_POST);
     $mime_id = get_input_value('_part', RCUBE_INPUT_POST);
     if ($uid && $mime_id) {
         $part = $this->rc->storage->get_message_part($uid, $mime_id);
     }
     if ($part && is_array($result = $this->import_key($part))) {
         $this->rc->output->show_message('enigma.keysimportsuccess', 'confirmation', array('new' => $result['imported'], 'old' => $result['unchanged']));
     } else {
         $this->rc->output->show_message('enigma.keysimportfailed', 'error');
     }
     $this->rc->output->send();
 }
Пример #24
0
 function login_after($args)
 {
     // update the already existing cookie (because of expiration time).
     if (self::is_persistent_cookie_available()) {
         self::set_persistent_cookie();
     } else {
         if (get_input_value('_ifpl', RCUBE_INPUT_POST)) {
             self::set_persistent_cookie();
         }
     }
     return $args;
 }
 /**
  * Returns a list of addressbook's groups.
  *
  * @return array addressbook's groups list.
  */
 public function get_addressbook_groups()
 {
     // get addressbook's id from request
     $address_book_id = get_input_value('address_book_id', RCUBE_INPUT_POST);
     // get key from request. Key identifies the row wich sent the request
     $key = get_input_value('key', RCUBE_INPUT_POST);
     // get addressbook by id
     $rcube_contacts = $this->rcmail->get_address_book($address_book_id);
     // send back to client a group list in array form
     $response = array('groups' => $rcube_contacts->list_groups(), 'key' => $key);
     $this->rcmail->output->command('plugin.recipient_to_contact_get_addressbook_groups_response', $response);
 }
Пример #26
0
        $OUTPUT->command('redirect', '?');
    }
    // check if installer is still active
    if ($RCMAIL->config->get('enable_installer') && is_readable('./installer/index.php')) {
        $OUTPUT->add_footer(html::div(array('style' => "background:#ef9398; border:2px solid #dc5757; padding:0.5em; margin:2em auto; width:50em"), html::tag('h2', array('style' => "margin-top:0.2em"), "Installer script is still accessible") . html::p(null, "The install script of your RoundCube installation is still stored in its default location!") . html::p(null, "Please <b>remove</b> the whole <tt>installer</tt> folder from the RoundCube directory because .\n        these files may expose sensitive configuration data like server passwords and encryption keys\n        to the public. Make sure you cannot access the <a href=\"./installer/\">installer script</a> from your browser.")));
    }
    $OUTPUT->set_env('task', 'login');
    $OUTPUT->send('login');
}
// handle keep-alive signal
if ($RCMAIL->action == 'keep-alive') {
    $OUTPUT->reset();
    $OUTPUT->send();
} else {
    if ($RCMAIL->action == 'save-pref') {
        $RCMAIL->user->save_prefs(array(get_input_value('_name', RCUBE_INPUT_POST) => get_input_value('_value', RCUBE_INPUT_POST)));
        $OUTPUT->reset();
        $OUTPUT->send();
    }
}
// map task/action to a certain include file
$action_map = array('mail' => array('preview' => 'show.inc', 'print' => 'show.inc', 'moveto' => 'move_del.inc', 'delete' => 'move_del.inc', 'send' => 'sendmail.inc', 'expunge' => 'folders.inc', 'purge' => 'folders.inc', 'remove-attachment' => 'attachments.inc', 'display-attachment' => 'attachments.inc', 'upload' => 'attachments.inc'), 'addressbook' => array('add' => 'edit.inc'), 'settings' => array('folders' => 'manage_folders.inc', 'create-folder' => 'manage_folders.inc', 'rename-folder' => 'manage_folders.inc', 'delete-folder' => 'manage_folders.inc', 'subscribe' => 'manage_folders.inc', 'unsubscribe' => 'manage_folders.inc', 'add-identity' => 'edit_identity.inc'));
// include task specific functions
if (is_file($incfile = 'program/steps/' . $RCMAIL->task . '/func.inc')) {
    include_once $incfile;
}
// allow 5 "redirects" to another action
$redirects = 0;
$incstep = null;
while ($redirects < 5) {
    $stepfile = !empty($action_map[$RCMAIL->task][$RCMAIL->action]) ? $action_map[$RCMAIL->task][$RCMAIL->action] : strtr($RCMAIL->action, '-', '_') . '.inc';
Пример #27
0
 public function mail_message2task()
 {
     $uid = get_input_value('_uid', RCUBE_INPUT_POST);
     $mbox = get_input_value('_mbox', RCUBE_INPUT_POST);
     $task = array();
     // establish imap connection
     $imap = $this->rc->get_storage();
     $imap->set_mailbox($mbox);
     $message = new rcube_message($uid);
     if ($message->headers) {
         $task['title'] = trim($message->subject);
         $task['description'] = trim($message->first_text_part());
         $task['id'] = -$uid;
         $this->load_driver();
         // copy mail attachments to task
         if ($message->attachments && $this->driver->attachments) {
             if (!is_array($_SESSION[self::SESSION_KEY]) || $_SESSION[self::SESSION_KEY]['id'] != $task['id']) {
                 $_SESSION[self::SESSION_KEY] = array();
                 $_SESSION[self::SESSION_KEY]['id'] = $task['id'];
                 $_SESSION[self::SESSION_KEY]['attachments'] = array();
             }
             foreach ((array) $message->attachments as $part) {
                 $attachment = array('data' => $imap->get_message_part($uid, $part->mime_id, $part), 'size' => $part->size, 'name' => $part->filename, 'mimetype' => $part->mimetype, 'group' => $task['id']);
                 $attachment = $this->rc->plugins->exec_hook('attachment_save', $attachment);
                 if ($attachment['status'] && !$attachment['abort']) {
                     $id = $attachment['id'];
                     $attachment['classname'] = rcube_utils::file2class($attachment['mimetype'], $attachment['name']);
                     // store new attachment in session
                     unset($attachment['status'], $attachment['abort'], $attachment['data']);
                     $_SESSION[self::SESSION_KEY]['attachments'][$id] = $attachment;
                     $attachment['id'] = 'rcmfile' . $attachment['id'];
                     // add prefix to consider it 'new'
                     $task['attachments'][] = $attachment;
                 }
             }
         }
         $this->rc->output->command('plugin.mail2taskdialog', $task);
     } else {
         $this->rc->output->command('display_message', $this->gettext('messageopenerror'), 'error');
     }
     $this->rc->output->send();
 }
Пример #28
0
 function set_flags()
 {
     #write_log($this->name, print_r($_GET, true));
     $imap = $this->rc->imap;
     $cbox = get_input_value('_cur', RCUBE_INPUT_GET);
     $mbox = get_input_value('_mbox', RCUBE_INPUT_GET);
     $toggle_label = get_input_value('_toggle_label', RCUBE_INPUT_GET);
     $flag_uids = get_input_value('_flag_uids', RCUBE_INPUT_GET);
     $flag_uids = explode(',', $flag_uids);
     $unflag_uids = get_input_value('_unflag_uids', RCUBE_INPUT_GET);
     $unflag_uids = explode(',', $unflag_uids);
     $imap->conn->flags = array_merge($imap->conn->flags, $this->add_tb_flags);
     #write_log($this->name, print_r($flag_uids, true));
     #write_log($this->name, print_r($unflag_uids, true));
     if (!is_array($unflag_uids) || !is_array($flag_uids)) {
         return false;
     }
     $imap->set_flag($flag_uids, $toggle_label, $mbox);
     $imap->set_flag($unflag_uids, "UN{$toggle_label}", $mbox);
     $this->api->output->send();
 }
 /**
  * Called when messages are dragged
  *
  * @access  public
  */
 function mov_del_override($args)
 {
     global $RCMAIL;
     // return if not an all folder search
     if (!$_SESSION['all_folder_search']['uid_mboxes']) {
         // use roundcube's mov_del.inc
         $args['abort'] = false;
     } else {
         // count messages before changing anything
         //$old_count = $IMAP->messagecount();
         //$old_pages = ceil($old_count / $IMAP->page_size);
         // move messages
         if (!empty($_POST['_uid']) && !empty($_POST['_target_mbox'])) {
             $count = sizeof(explode(',', $uids = get_input_value('_uid', RCUBE_INPUT_POST)));
             $target = get_input_value('_target_mbox', RCUBE_INPUT_POST);
             $mbox = $_SESSION['all_folder_search']['uid_mboxes'][$uids[0]];
             $RCMAIL->imap->set_mailbox($mbox);
             // flag messages as read before moving them
             if ($CONFIG['read_when_deleted'] && $target == $CONFIG['trash_mbox']) {
                 $RCMAIL->imap->set_flag($uids, 'SEEN');
             }
             console("moving {$uids} from {$mbox} to {$target}");
             $moved = $RCMAIL->imap->move_message($uids, $target, $mbox);
             if (!$moved) {
                 // send error message
                 if ($_POST['_from'] != 'show') {
                     $RCMAIL->output->command('list_mailbox');
                 }
                 $RCMAIL->output->show_message('errormoving', 'error');
                 $RCMAIL->output->send();
                 exit;
             } else {
                 $RCMAIL->output->show_message("Successfully moved message from {$mbox} to {$target}");
             }
             $addrows = true;
         }
         // send response
         $RCMAIL->output->send();
         // dont execute roundcube's mov_del.inc
         $args['abort'] = true;
     }
     return $args;
 }
 /**
  * Adds a CardDAV server contact
  *
  * @param  string  $vcard vCard
  * @return boolean
  */
 private function carddav_add($vcard)
 {
     $sync = true;
     if ($this->rc->action == 'copy') {
         $this->counter++;
         $cids = get_input_value('_cid', RCUBE_INPUT_POST);
         $cids = explode(',', $cids);
         if ($this->counter < count($cids)) {
             $sync = false;
         }
     }
     $vcard = $this->vcard_check($vcard);
     $server = current(carddav::get_carddav_server($this->carddav_server_id));
     $arr = parse_url($server['url']);
     $carddav_backend = new carddav_backend($server['url']);
     if ($this->rc->decrypt($server['password']) == '%p') {
         $server['password'] = $this->rcpassword;
     }
     $carddav_backend->set_auth($server['username'], $this->rc->decrypt($server['password']), $server['authtype']);
     if ($carddav_backend->check_connection()) {
         $vcard_id = $carddav_backend->add($vcard);
         if ($sync && $this->rc->action != 'import') {
             if ($this->rc->action == 'copy') {
                 $vcard_id = false;
             }
             $this->carddav_addressbook_sync($server, false, $vcard_id);
             $cid = $this->rc->db->insert_id(get_table_name($this->db_name));
             return $cid;
         } else {
             return true;
         }
     }
     return false;
 }