/** */ protected function _changePassword($user, $oldpass, $newpass) { // Connect $soap_uri = $this->_params['soap_uri']; $client = new SoapClient(null, array('location' => $soap_uri . 'index.php', 'uri' => $soap_uri)); // Login try { if (!($session_id = $client->login($this->_params['soap_user'], $this->_params['soap_pass']))) { throw new Passwd_Exception(sprintf(_("Login to %s failed."), $soap_uri)); } } catch (SoapFault $e) { throw new Passwd_Exception($e); } // Get user information try { $users = $client->mail_user_get($session_id, array('login' => $user)); } catch (SoapFault $e) { throw new Passwd_Exception($e); } if (count($users) != 1) { throw new Passwd_Exception(sprintf(_("%d users with login %s found, one expected."), count($users), $user)); } $user = $users[0]; // Check the passwords match $this->_comparePasswords($user['password'], $oldpass); // Set new password $user['password'] = $newpass; // Save information try { $client->mail_user_update($session_id, $user['client_id'], $user['mailuser_id'], $user); } catch (SoapFault $e) { throw new Passwd_Exception($e); } // Logout try { $client->logout($session_id); } catch (SoapFault $e) { throw new Passwd_Exception($e); } }
/** * Sets a script running on the backend. * * @param array $script The filter script information. Passed elements: * - 'name': (string) the script name. * - 'recipes': (array) the filter recipe objects. * - 'script': (string) the filter script. * * @throws Ingo_Exception */ public function setScriptActive($script) { $vacation = null; foreach ($script['recipes'] as $recipe) { if ($recipe['rule'] == Ingo::RULE_VACATION) { $vacation = $recipe['object']->vacation; break; } else { throw new Ingo_Exception('The ISPConfig transport driver only supports vacation rules.'); } } if (!$vacation) { return; } // Fill mailuser_id and client_id. $this->_getUserDetails($this->_params['password']); try { $user = $this->_soap->mail_user_get($this->_soap_session, $this->_details['mailuser_id']); $user['autoresponder'] = $recipe['object']->disable ? 'n' : 'y'; // UNIX timestamp. $start = $vacation->getVacationStart(); $end = $vacation->getVacationEnd(); if (empty($start)) { $start = time(); } if (empty($end)) { $end = time(); } $user['autoresponder_start_date'] = array('year' => date('Y', $start), 'month' => date('m', $start), 'day' => date('d', $start), 'hour' => date('H', $start), 'minute' => date('i', $start)); $user['autoresponder_end_date'] = array('year' => date('Y', $end), 'month' => date('m', $end), 'day' => date('d', $end), 'hour' => 23, 'minute' => 59); // $vacation->getVacationSubject() not supported by ISPConfig $user['autoresponder_text'] = $vacation->getVacationReason(); // otherwise ISPConfig calculates the hash of this hash... braindead unset($user['password']); $this->_soap->mail_user_update($this->_soap_session, $this->_details['client_id'], $this->_details['mailuser_id'], $user); } catch (SoapFault $e) { throw new Ingo_Exception($e); } }
function save() { $confirm = $this->rcmail_inst->config->get('password_confirm_current'); if ($confirm && !isset($_POST['_curpasswd']) || !isset($_POST['_newpasswd'])) { $this->rcmail_inst->output->command('display_message', $this->gettext('nopassword'), 'error'); } else { $curpwd = rcube_utils::get_input_value('_curpasswd', RCUBE_INPUT_POST); $newpwd = rcube_utils::get_input_value('_newpasswd', RCUBE_INPUT_POST); $pwl = $this->rcmail_inst->config->get('password_min_length'); $checkUpper = $this->rcmail_inst->config->get('password_check_upper'); $checkLower = $this->rcmail_inst->config->get('password_check_lower'); $checkSymbol = $this->rcmail_inst->config->get('password_check_symbol'); $checkNumber = $this->rcmail_inst->config->get('password_check_number'); $error = false; if (!empty($pwl)) { $pwl = max(6, $pwl); } else { $pwl = 6; } if ($confirm && $this->rcmail_inst->decrypt($_SESSION['password']) != $curpwd) { $this->rcmail_inst->output->command('display_message', $this->gettext('passwordincorrect'), 'error'); } else { if (strlen($newpwd) < $pwl) { $error = true; $this->rcmail_inst->output->command('display_message', str_replace("%d", $pwl, $this->gettext('passwordminlength')), 'error'); } if (!$error && $checkNumber && !preg_match("#[0-9]+#", $newpwd)) { $error = true; $this->rcmail_inst->output->command('display_message', $this->gettext('passwordchecknumber'), 'error'); } if (!$error && $checkLower && !preg_match("#[a-z]+#", $newpwd)) { $error = true; $this->rcmail_inst->output->command('display_message', $this->gettext('passwordchecklower'), 'error'); } if (!$error && $checkUpper && !preg_match("#[A-Z]+#", $newpwd)) { $error = true; $this->rcmail_inst->output->command('display_message', $this->gettext('passwordcheckupper'), 'error'); } if (!$error && $checkSymbol && !preg_match("#\\W+#", $newpwd)) { $error = true; $this->rcmail_inst->output->command('display_message', $this->gettext('passwordchecksymbol'), 'error'); } if (!$error) { try { $soap = new SoapClient(null, array('location' => $this->rcmail_inst->config->get('soap_url') . 'index.php', 'uri' => $this->rcmail_inst->config->get('soap_url'))); $session_id = $soap->login($this->rcmail_inst->config->get('remote_soap_user'), $this->rcmail_inst->config->get('remote_soap_pass')); $mail_user = $soap->mail_user_get($session_id, array('login' => $this->rcmail_inst->user->data['username'])); $params = $mail_user[0]; $startdate = array('year' => substr($params['autoresponder_start_date'], 0, 4), 'month' => substr($params['autoresponder_start_date'], 5, 2), 'day' => substr($params['autoresponder_start_date'], 8, 2), 'hour' => substr($params['autoresponder_start_date'], 11, 2), 'minute' => substr($params['autoresponder_start_date'], 14, 2)); $enddate = array('year' => substr($params['autoresponder_end_date'], 0, 4), 'month' => substr($params['autoresponder_end_date'], 5, 2), 'day' => substr($params['autoresponder_end_date'], 8, 2), 'hour' => substr($params['autoresponder_end_date'], 11, 2), 'minute' => substr($params['autoresponder_end_date'], 14, 2)); $params['password'] = $newpwd; $params['autoresponder_end_date'] = $enddate; $params['autoresponder_start_date'] = $startdate; $uid = $soap->client_get_id($session_id, $mail_user[0]['sys_userid']); $update = $soap->mail_user_update($session_id, $uid, $mail_user[0]['mailuser_id'], $params); $soap->logout($session_id); $this->rcmail_inst->output->command('display_message', $this->gettext('successfullysaved'), 'confirmation'); $_SESSION['password'] = $this->rcmail_inst->encrypt($newpwd); $this->rcmail_inst->user->data['password'] = $_SESSION['password']; } catch (SoapFault $e) { $this->rcmail_inst->output->command('display_message', 'Soap Error: ' . $e->getMessage(), 'error'); } } } } $this->init_html(); }
<?php require 'soap_config.php'; $client = new SoapClient(null, array('location' => $soap_location, 'uri' => $soap_uri, 'trace' => 1, 'exceptions' => 1)); try { if ($session_id = $client->login($username, $password)) { echo 'Logged successfull. Session ID:' . $session_id . '<br />'; } //* Parameters $mailuser_id = 1; $client_id = 1; //* Get the email user record $mail_user_record = $client->mail_user_get($session_id, $mailuser_id); //* Change the status to inactive $mail_user_record['name'] = 'hmmyea'; $affected_rows = $client->mail_user_update($session_id, $client_id, $mailuser_id, $mail_user_record); echo "Number of records that have been changed in the database: " . $affected_rows . "<br>"; if ($client->logout($session_id)) { echo 'Logged out.<br />'; } } catch (SoapFault $e) { echo $client->__getLastResponse(); die('SOAP Error: ' . $e->getMessage()); }