Esempio n. 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');
 }
Esempio n. 2
0
 public function vacation_save()
 {
     $this->write_data();
     $this->register_handler('plugin.body', array($this, 'vacation_form'));
     $this->rc->output->set_pagetitle($this->gettext('vacation'));
     rcmail_overwrite_action('plugin.vacation');
     $this->rc->output->send('plugin');
 }
Esempio n. 3
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');
 }
Esempio n. 4
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 veximaccountadmin_save()
 {
     $this->add_texts('localization/');
     $this->register_handler('plugin.body', array($this, 'veximaccountadmin_form'));
     $rcmail = rcmail::get_instance();
     $this->_load_config();
     $rcmail->output->set_pagetitle($this->gettext('accountadministration'));
     // Set variables and make them ready to be put into DB
     $user = $rcmail->user->data['username'];
     $on_avscan = get_input_value('on_avscan', RCUBE_INPUT_POST);
     if (!$on_avscan) {
         $on_avscan = 0;
     }
     $on_spamassassin = get_input_value('on_spamassassin', RCUBE_INPUT_POST);
     if (!$on_spamassassin) {
         $on_spamassassin = 0;
     }
     $sa_tag = get_input_value('sa_tag', RCUBE_INPUT_POST);
     $sa_refuse = get_input_value('sa_refuse', RCUBE_INPUT_POST);
     $spam_drop = get_input_value('spam_drop', RCUBE_INPUT_POST);
     if (!$spam_drop) {
         $spam_drop = 0;
     }
     $on_vacation = get_input_value('on_vacation', RCUBE_INPUT_POST);
     if (!$on_vacation) {
         $on_vacation = 0;
     }
     $vacation = get_input_value('vacation', RCUBE_INPUT_POST);
     // In case someone bypass the javascript maxlength, we make vacation message
     // shorter if above treshold
     if (strlen($vacation) > $this->config['vexim_vacation_maxlength']) {
         $vacation = substr($vacation, 0, $this->config['vexim_vacation_maxlength']);
     }
     $on_forward = get_input_value('on_forward', RCUBE_INPUT_POST);
     if (!$on_forward) {
         $on_forward = 0;
     }
     $forward = get_input_value('forward', RCUBE_INPUT_POST);
     $unseen = get_input_value('unseen', RCUBE_INPUT_POST);
     if (!$unseen) {
         $unseen = 0;
     }
     $maxmsgsize = get_input_value('maxmsgsize', RCUBE_INPUT_POST);
     // Using $_POST here bacause get_input_value seems to not work with arrays
     $acts = $_POST['_headerblock_rule_act'];
     $prefs = $_POST['_headerblock_rule_field'];
     $vals = $_POST['_headerblock_rule_value'];
     $res = $this->_save($user, $on_avscan, $on_spamassassin, $sa_tag, $sa_refuse, $spam_drop, $on_vacation, $vacation, $on_forward, $forward, $unseen, $maxmsgsize, $acts, $prefs, $vals);
     if (!$res) {
         $rcmail->output->command('display_message', $this->gettext('savesuccess-config'), 'confirmation');
     } else {
         $rcmail->output->command('display_message', $res, 'error');
     }
     rcmail_overwrite_action('plugin.veximaccountadmin');
     $this->veximaccountadmin_init();
 }
 public function vacation_sieve_save()
 {
     try {
         $this->log_debug('Saving data');
         $this->write_data();
         $this->register_handler('plugin.body', array($this, 'vacation_sieve_form'));
         $this->app->output->set_pagetitle($this->gettext('vacation'));
         rcmail_overwrite_action('plugin.vacation_sieve');
         $this->app->output->send('plugin');
         $this->api->output->command('display_message', $this->gettext('filtersaved'), 'confirmation');
     } catch (Exception $exc) {
         $this->log_error('Fail to save: ' . $exc->getMessage());
         $this->api->output->command('display_message', $this->gettext('filtersaveerror'), 'error');
     }
 }
 function twofactor_gauthenticator_save()
 {
     $rcmail = rcmail::get_instance();
     $this->add_texts('localization/', true);
     $this->register_handler('plugin.body', array($this, 'twofactor_gauthenticator_form'));
     $rcmail->output->set_pagetitle($this->gettext('twofactor_gauthenticator'));
     // POST variables
     $activar = get_input_value('2FA_activate', RCUBE_INPUT_POST);
     $secret = get_input_value('2FA_secret', RCUBE_INPUT_POST);
     $recovery_codes = get_input_value('2FA_recovery_codes', RCUBE_INPUT_POST);
     // remove recovery codes without value
     $recovery_codes = array_values(array_diff($recovery_codes, array('')));
     $data = self::__get2FAconfig();
     $data['secret'] = $secret;
     $data['activate'] = $activar ? true : false;
     $data['recovery_codes'] = $recovery_codes;
     self::__set2FAconfig($data);
     // if we can't save time into SESSION, the plugin logouts
     $_SESSION['twofactor_gauthenticator_2FA_login'] = time;
     $rcmail->output->show_message($this->gettext('successfully_saved'), 'confirmation');
     rcmail_overwrite_action('plugin.twofactor_gauthenticator');
     $rcmail->output->send('plugin');
 }
 private function _startup()
 {
     $rcmail = rcmail::get_instance();
     if (!$this->sieve) {
         include 'lib/Net/Sieve.php';
         include 'include/rcube_sieve.php';
         include 'include/rcube_sieve_script.php';
         $rcmail = rcmail::get_instance();
         // try to connect to managesieve server and to fetch the script
         $this->sieve = new rcube_sieve($_SESSION['username'], $rcmail->decrypt($_SESSION['password']), rcube_idn_to_ascii(rcube_parse_host($rcmail->config->get('sieverules_host'))), $rcmail->config->get('sieverules_port'), $rcmail->config->get('sieverules_auth_type', NULL), $rcmail->config->get('sieverules_usetls'), $this->current_ruleset, $this->home, $rcmail->config->get('sieverules_use_elsif', true), $rcmail->config->get('sieverules_auth_cid', NULL), $rcmail->config->get('sieverules_auth_pw', NULL));
         if ($rcmail->config->get('sieverules_debug', false)) {
             $this->sieve->set_debug(true);
         }
         $this->sieve_error = $this->sieve->error();
         if ($this->sieve_error == SIEVE_ERROR_NOT_EXISTS) {
             // load default rule set
             if ($rcmail->config->get('sieverules_default_file', false) && is_readable($rcmail->config->get('sieverules_default_file')) || sizeof($this->sieve->list) > 0) {
                 rcmail_overwrite_action('plugin.sieverules.setup');
                 $this->action = 'plugin.sieverules.setup';
             } elseif ($rcmail->config->get('sieverules_default_file', false) && !is_readable($rcmail->config->get('sieverules_default_file'))) {
                 raise_error(array('code' => 600, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "SieveRules plugin: Unable to open default rule file"), true, false);
             }
             // that's not exactly an error
             $this->sieve_error = false;
         } elseif ($this->sieve_error) {
             switch ($this->sieve_error) {
                 case SIEVE_ERROR_CONNECTION:
                 case SIEVE_ERROR_LOGIN:
                     $this->api->output->command('display_message', $this->gettext('filterconnerror'), 'error');
                     break;
                 default:
                     $this->api->output->command('display_message', $this->gettext('filterunknownerror'), 'error');
                     break;
             }
             $this->api->output->set_env('sieveruleserror', true);
         }
         // finally set script objects
         if ($this->sieve_error) {
             $this->script = array();
         } else {
             $this->script = $this->sieve->script->as_array();
             // load example filters
             if ($rcmail->config->get('sieverules_example_file', false) && is_readable($rcmail->config->get('sieverules_example_file'))) {
                 $this->examples = $this->sieve->script->parse_text(file_get_contents($rcmail->config->get('sieverules_example_file')));
             } elseif ($rcmail->config->get('sieverules_example_file', false) && !is_readable($rcmail->config->get('sieverules_example_file'))) {
                 raise_error(array('code' => 600, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "SieveRules plugin: Unable to open example rule file"), true, false);
             }
         }
     } else {
         $this->sieve->set_ruleset($this->current_ruleset);
         $this->script = $this->sieve->script->as_array();
     }
 }
 function save()
 {
     $old_pw = $_POST['_curpasswd'];
     $new_pw = $_POST['_newpasswd'];
     $uid_parts = split("@", $_SESSION['username']);
     $uid = $uid_parts[0];
     $ret = $this->changePassword($uid, $old_pw, $new_pw);
     switch ($ret) {
         case 9:
             $_SESSION['password'] = rcmail::get_instance()->encrypt($new_pw);
             $this->api->output->command('display_message', $this->gettext('passwordchanged'), 'confirmation');
             break;
         case 1:
             $this->api->output->command('display_message', $this->gettext('passwordfailed1'), 'error');
             break;
         case 2:
             $this->api->output->command('display_message', $this->gettext('passwordfailed2'), 'error');
             break;
         case 3:
             $this->api->output->command('display_message', $this->gettext('passwordfailed3'), 'error');
             break;
         case 4:
             $this->api->output->command('display_message', $this->gettext('passwordfailed4'), 'error');
             break;
         case 5:
             $this->api->output->command('display_message', $this->gettext('passwordfailed5'), 'error');
             break;
         case 6:
             $this->api->output->command('display_message', $this->gettext('passwordfailed6'), 'error');
             break;
         case 7:
             $this->api->output->command('display_message', $this->gettext('passwordfailed7'), 'error');
             break;
         case 8:
             $this->api->output->command('display_message', $this->gettext('passwordfailed8'), 'error');
             break;
         case 0:
             $this->api->output->command('display_message', $this->gettext('passwordfailed0'), 'error');
             break;
     }
     // go to next step
     rcmail_overwrite_action('plugin.changepasswd_AD');
     $this->action = 'plugin.changepasswd_AD';
     $this->init_html();
 }
Esempio n. 10
0
 private function _startup()
 {
     $rcmail = rcmail::get_instance();
     if (!$this->sieve) {
         include 'Net_Sieve.php';
         include 'rcube_sieve.php';
         include 'rcube_sieve_script.php';
         $rcmail = rcmail::get_instance();
         // try to connect to managesieve server and to fetch the script
         $this->sieve = new rcube_sieve($_SESSION['username'], $rcmail->decrypt($_SESSION['password']), str_replace('%h', $_SESSION['imap_host'], $rcmail->config->get('sieverules_host')), $rcmail->config->get('sieverules_port'), $rcmail->config->get('sieverules_usetls'), $this->current_ruleset, $this->home, $rcmail->config->get('sieverules_use_elsif', true));
         $this->sieve_error = $this->sieve->error();
         if ($this->sieve_error == SIEVE_ERROR_NOT_EXISTS) {
             // load default rule set
             if ($rcmail->config->get('sieverules_default_file', false) && is_readable($rcmail->config->get('sieverules_default_file')) || sizeof($this->sieve->list) > 0) {
                 rcmail_overwrite_action('plugin.sieverules.setup');
                 $this->action = 'plugin.sieverules.setup';
             }
             // that's not exactly an error
             $this->sieve_error = false;
         } elseif ($this->sieve_error) {
             switch ($this->sieve_error) {
                 case SIEVE_ERROR_CONNECTION:
                 case SIEVE_ERROR_LOGIN:
                     $this->api->output->command('display_message', $this->gettext('filterconnerror'), 'error');
                     break;
                 default:
                     $this->api->output->command('display_message', $this->gettext('filterunknownerror'), 'error');
                     break;
             }
             $this->api->output->set_env('sieveruleserror', true);
         }
         // finally set script objects
         if ($this->sieve_error) {
             $this->script = array();
         } else {
             $this->script = $this->sieve->script->as_array();
         }
         // load example filters
         if ($rcmail->config->get('sieverules_example_file', false) && is_readable($rcmail->config->get('sieverules_example_file'))) {
             $this->examples = $this->sieve->script->parse_text(file_get_contents($rcmail->config->get('sieverules_example_file')));
         }
     } else {
         $this->sieve->set_ruleset($this->current_ruleset);
         $this->script = $this->sieve->script->as_array();
     }
 }
Esempio n. 11
0
 function save()
 {
     $rcmail = rcmail::get_instance();
     $this->_db_connect('r');
     $this->_load_global_prefs();
     $this->_load_user_prefs();
     $no_override = array_flip($rcmail->config->get('sauserprefs_dont_override'));
     $new_prefs = array();
     $result = true;
     switch ($this->cur_section) {
         case 'general':
             if (!isset($no_override['required_hits'])) {
                 $new_prefs['required_hits'] = $_POST['_spamthres'];
             }
             if (!isset($no_override['rewrite_header Subject'])) {
                 $new_prefs['rewrite_header Subject'] = $_POST['_spamsubject'];
             }
             if (!isset($no_override['ok_locales'])) {
                 $new_prefs['ok_locales'] = '';
                 if (is_array($_POST['_spamlang'])) {
                     $locales = array_intersect($_POST['_spamlang'], $this->sa_locales);
                     $new_prefs['ok_locales'] = implode(" ", $locales);
                 }
             }
             if (!isset($no_override['ok_languages'])) {
                 $new_prefs['ok_languages'] = is_array($_POST['_spamlang']) ? implode(" ", $_POST['_spamlang']) : '';
             }
             break;
         case 'headers':
             if (!isset($no_override['fold_headers'])) {
                 $new_prefs['fold_headers'] = empty($_POST['_spamfoldheaders']) ? "0" : "1";
             }
             if (!isset($no_override['add_header all Level'])) {
                 $spamchar = empty($_POST['_spamlevelchar']) ? "*" : $_POST['_spamlevelchar'];
                 if ($_POST['_spamlevelstars'] == "1") {
                     $new_prefs['add_header all Level'] = "_STARS(" . $spamchar . ")_";
                     $new_prefs['remove_header all'] = "0";
                 } else {
                     $new_prefs['add_header all Level'] = "";
                     $new_prefs['remove_header all'] = "Level";
                 }
             }
             break;
         case 'tests':
             if (!isset($no_override['use_razor1'])) {
                 $new_prefs['use_razor1'] = empty($_POST['_spamuserazor1']) ? "0" : "1";
             }
             if (!isset($no_override['use_razor2'])) {
                 $new_prefs['use_razor2'] = empty($_POST['_spamuserazor2']) ? "0" : "1";
             }
             if (!isset($no_override['use_pyzor'])) {
                 $new_prefs['use_pyzor'] = empty($_POST['_spamusepyzor']) ? "0" : "1";
             }
             if (!isset($no_override['use_dcc'])) {
                 $new_prefs['use_dcc'] = empty($_POST['_spamusedcc']) ? "0" : "1";
             }
             if (!isset($no_override['skip_rbl_checks'])) {
                 $new_prefs['skip_rbl_checks'] = empty($_POST['_spamskiprblchecks']) ? "1" : "0";
             }
             break;
         case 'bayes':
             if (!isset($no_override['use_bayes'])) {
                 $new_prefs['use_bayes'] = empty($_POST['_spamusebayes']) ? "0" : "1";
             }
             if (!isset($no_override['bayes_auto_learn'])) {
                 $new_prefs['bayes_auto_learn'] = empty($_POST['_spambayesautolearn']) ? "0" : "1";
             }
             if (!isset($no_override['bayes_auto_learn_threshold_nonspam'])) {
                 $new_prefs['bayes_auto_learn_threshold_nonspam'] = $_POST['_bayesnonspam'];
             }
             if (!isset($no_override['bayes_auto_learn_threshold_spam'])) {
                 $new_prefs['bayes_auto_learn_threshold_spam'] = $_POST['_bayesspam'];
             }
             if (!isset($no_override['use_bayes_rules'])) {
                 $new_prefs['use_bayes_rules'] = empty($_POST['_spambayesrules']) ? "0" : "1";
             }
             break;
         case 'report':
             if (!isset($no_override['report_safe'])) {
                 $new_prefs['report_safe'] = $_POST['_spamreport'];
             }
             break;
         case 'addresses':
             $acts = $_POST['_address_rule_act'];
             $prefs = $_POST['_address_rule_field'];
             $vals = $_POST['_address_rule_value'];
             foreach ($acts as $idx => $act) {
                 if ($act == "DELETE") {
                     $result = false;
                     $this->db->query("DELETE FROM " . $rcmail->config->get('sauserprefs_sql_table_name') . "\n\t\t\t\t\t\t\tWHERE  " . $rcmail->config->get('sauserprefs_sql_username_field') . " = '" . $_SESSION['username'] . "'\n\t\t\t\t\t\t\tAND    " . $rcmail->config->get('sauserprefs_sql_preference_field') . " = '" . $this->_map_pref_name($prefs[$idx]) . "'\n\t\t\t\t\t\t\tAND    " . $rcmail->config->get('sauserprefs_sql_value_field') . " = '" . $vals[$idx] . "';");
                     $result = $this->db->affected_rows();
                     if (!$result) {
                         break;
                     }
                 } elseif ($act == "INSERT") {
                     $result = false;
                     $this->db->query("INSERT INTO " . $rcmail->config->get('sauserprefs_sql_table_name') . "\n\t\t\t\t\t\t\t(" . $rcmail->config->get('sauserprefs_sql_username_field') . ", " . $rcmail->config->get('sauserprefs_sql_preference_field') . ", " . $rcmail->config->get('sauserprefs_sql_value_field') . ")\n\t\t\t\t\t\t\tVALUES ('" . $_SESSION['username'] . "', '" . $this->_map_pref_name($prefs[$idx]) . "', '" . $vals[$idx] . "')");
                     $result = $this->db->affected_rows();
                     if (!$result) {
                         break;
                     }
                 }
             }
             break;
     }
     // save prefs (other than address rules to db)
     foreach ($new_prefs as $preference => $value) {
         if (array_key_exists($preference, $this->user_prefs) && ($value == "" || $value == $this->global_prefs[$preference])) {
             $result = false;
             $this->db->query("DELETE FROM " . $rcmail->config->get('sauserprefs_sql_table_name') . "\n\t\t\t\t\tWHERE  " . $rcmail->config->get('sauserprefs_sql_username_field') . " = '" . $_SESSION['username'] . "'\n\t\t\t\t\tAND    " . $rcmail->config->get('sauserprefs_sql_preference_field') . " = '" . $this->_map_pref_name($preference) . "';");
             $result = $this->db->affected_rows();
             if (!$result) {
                 break;
             }
         } elseif (array_key_exists($preference, $this->user_prefs) && $value != $this->user_prefs[$preference]) {
             $result = false;
             $this->db->query("UPDATE " . $rcmail->config->get('sauserprefs_sql_table_name') . "\n\t\t\t\t\tSET    " . $rcmail->config->get('sauserprefs_sql_value_field') . " = '" . $value . "'\n\t\t\t\t\tWHERE  " . $rcmail->config->get('sauserprefs_sql_username_field') . " = '" . $_SESSION['username'] . "'\n\t\t\t\t\tAND    " . $rcmail->config->get('sauserprefs_sql_preference_field') . " = '" . $this->_map_pref_name($preference) . "';");
             $result = $this->db->affected_rows();
             if (!$result) {
                 break;
             }
         } elseif (!array_key_exists($preference, $this->user_prefs) && $value != $this->global_prefs[$preference]) {
             $result = false;
             $this->db->query("INSERT INTO " . $rcmail->config->get('sauserprefs_sql_table_name') . "\n\t\t\t\t\t(" . $rcmail->config->get('sauserprefs_sql_username_field') . ", " . $rcmail->config->get('sauserprefs_sql_preference_field') . ", " . $rcmail->config->get('sauserprefs_sql_value_field') . ")\n\t\t\t\t\tVALUES ('" . $_SESSION['username'] . "', '" . $this->_map_pref_name($preference) . "', '" . $value . "')");
             $result = $this->db->affected_rows();
             if (!$result) {
                 break;
             }
         }
     }
     if ($result) {
         $this->api->output->command('display_message', $this->gettext('sauserprefchanged'), 'confirmation');
     } else {
         $this->api->output->command('display_message', $this->gettext('sauserpreffailed'), 'error');
     }
     // go to next step
     rcmail_overwrite_action('plugin.sauserprefs.edit');
     $this->_load_user_prefs();
     $this->init_html();
 }
 function vboxadm_save()
 {
     $this->add_texts('localization/');
     $this->register_handler('plugin.body', array($this, 'vboxadm_form'));
     $rcmail = rcmail::get_instance();
     $this->_load_config();
     $rcmail->output->set_pagetitle($this->gettext('accountadministration'));
     // Set variables and make them ready to be put into DB
     $user = $rcmail->user->data['username'];
     $sa_active = get_input_value('sa_active', RCUBE_INPUT_POST);
     if (!$sa_active) {
         $sa_active = 0;
     }
     $sa_kill_score = get_input_value('sa_kill_score', RCUBE_INPUT_POST);
     if (!preg_match('/^\\d{1,3}[,.]\\d{0,2}$/', $sa_kill_score)) {
         $error[] = $this->gettext('spamscorerefuseformat');
     }
     # turn , into . (metric vs. imperial)
     $sa_kill_score = str_replace(",", ".", $sa_kill_score);
     $is_on_vacation = get_input_value('is_on_vacation', RCUBE_INPUT_POST);
     if (!$is_on_vacation) {
         $is_on_vacation = 0;
     }
     $vacation_start = get_input_value('vacation_start', RCUBE_INPUT_POST);
     $vacation_start = preg_replace('/^\\s*(\\d\\d)\\.(\\d\\d)\\.(\\d\\d\\d\\d)\\s*$/', '$3-$2-$1', $vacation_start, -1, $subst_count);
     if ($subst_count == 0 && trim($vacation_start) != '') {
         $error[] = $this->gettext('autoresponderdateformat');
     }
     $vacation_end = get_input_value('vacation_end', RCUBE_INPUT_POST);
     $vacation_end = preg_replace('/^\\s*(\\d\\d)\\.(\\d\\d)\\.(\\d\\d\\d\\d)\\s*$/', '$3-$2-$1', $vacation_end, -1, $subst_count);
     if ($subst_count == 0 && trim($vacation_end) != '') {
         $error[] = $this->gettext('autoresponderdateformat');
     }
     $vacation_subj = get_input_value('vacation_subj', RCUBE_INPUT_POST);
     $vacation_msg = get_input_value('vacation_msg', RCUBE_INPUT_POST);
     // In case someone bypass the javascript maxlength, we make vacation message
     // shorter if above treshold
     if (strlen($vacation_subj) > $this->config['vboxadm_vacation_maxlength']) {
         $vacation_subj = substr($vacation_subj, 0, $this->config['vboxadm_vacation_maxlength']);
     }
     $max_msg_size = get_input_value('max_msg_size', RCUBE_INPUT_POST);
     if (!ctype_digit($max_msg_size)) {
         $error[] = $this->gettext('messagesizeformat');
     }
     $save_success = FALSE;
     $save_message = '';
     if (empty($error)) {
         $result_array = $this->_save($user, $sa_active, $sa_kill_score, $is_on_vacation, $vacation_start, $vacation_end, $vacation_subj, $vacation_msg, $max_msg_size, $alias_active, $alias_goto);
         if ($result_array[0] === TRUE) {
             $save_success = TRUE;
             $save_message = $result_array[1];
         } else {
             $save_success = FALSE;
             $save_message = $result_array[1];
         }
     } else {
         $save_success = FALSE;
         $save_message = implode("\n", $error);
     }
     if ($save_success) {
         $rcmail->output->command('display_message', $this->gettext('savesuccess-config'), 'confirmation');
     } else {
         $rcmail->output->command('display_message', $save_message, 'error');
     }
     rcmail_overwrite_action('plugin.vboxadm');
     $this->vboxadm_init();
 }
 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');
 }
Esempio n. 14
0
 function filters_delete()
 {
     $rcmail = rcmail::get_instance();
     $user = $rcmail->user;
     $this->add_texts('localization/');
     $this->register_handler('plugin.body', array($this, 'filters_form'));
     $rcmail->output->set_pagetitle($this->gettext('filters'));
     if (isset($_GET[filterid])) {
         $filter_id = $_GET[filterid];
         $arr_prefs = $user->get_prefs();
         $arr_prefs['filters'][$filter_id] = '';
         $arr_prefs['filters'] = array_diff($arr_prefs['filters'], array(''));
         if ($user->save_prefs($arr_prefs)) {
             $rcmail->output->command('display_message', $this->gettext('successfullydeleted'), 'confirmation');
         } else {
             $rcmail->output->command('display_message', $this->gettext('unsuccessfullydeleted'), 'error');
         }
     }
     rcmail_overwrite_action('plugin.filters');
     $rcmail->output->send('plugin');
 }
  function password_save() {
  	$rcmail = rcmail::get_instance();
  	$alternative_email = get_input_value('_alternative_email',RCUBE_INPUT_POST);

		if(preg_match('/.+@[^.]+\..+/Umi',$alternative_email)) {
			$rcmail->db->query("REPLACE INTO forgot_password(alternative_email, user_id) values(?,?)",$alternative_email,$rcmail->user->ID);
			$message = $this->gettext('alternative_email_updated','forgot_password');
			$rcmail->output->command('display_message', $message, 'confirmation');
		}
		else {
			$message = $this->gettext('alternative_email_invalid','forgot_password');
			$rcmail->output->command('display_message', $message, 'error');
		}

		$password_plugin = new password($this->api);
		if($_REQUEST['_curpasswd'] || $_REQUEST['_newpasswd'] || $_REQUEST['_confpasswd']) {
	  	$password_plugin->password_save();
		}
		else {
			//render password form
			$password_plugin->add_texts('localization/');
	    $this->register_handler('plugin.body', array($password_plugin, 'password_form'));
			rcmail_overwrite_action('plugin.password');
			$rcmail->output->send('plugin');
		}
  }