/** * Retrieves the current vacation details for the user. * * @param string $password The password for user. * * @return array Vacation details * @throws Ingo_Exception */ protected function _getUserDetails($password) { if (!is_null($this->_details)) { return $this->_details; } $this->_checkConfig(); $this->_connect(); try { $users = $this->_soap->mail_user_get($this->_soap_session, array('login' => $this->_params['username'])); } catch (SoapFault $e) { throw new Ingo_Exception($e); } if (count($users) != 1) { throw new Ingo_Exception(sprintf(_("%d users with login %s found, one expected."), count($users), $this->_params['username'])); } $user = $users[0]; $this->_details['vacation'] = $user['autoresponder'] === 'y' ? 'Y' : 'N'; $this->_details['message'] = $user['autoresponder_text']; $this->_details['mailuser_id'] = $user['mailuser_id']; // 0 == admin $this->_details['client_id'] = 0; $this->_details['autoresponder_start_date'] = $user['autoresponder_start_date']; $this->_details['autoresponder_end_date'] = $user['autoresponder_end_date']; return $this->_details; }
protected function loadData() { $client = new SoapClient(null, array('location' => SOAP_LOCATION, 'uri' => SOAP_URI)); try { //* Login to the remote server if ($session_id = $client->login(SOAP_USER, SOAP_PASS)) { $mail_user = $client->mail_user_get($session_id, array('email' => $this->email)); if (count($mail_user) == 1) { $this->host = $client->server_get($session_id, $mail_user[0]['server_id'], 'server'); $this->user = $mail_user[0]; } else { throw new Exception("Unknown Account"); } } //* Logout $client->logout($session_id); } catch (SoapFault $e) { throw new Exception('SOAP Error: ' . $e->getMessage()); } }
/** */ 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); } }
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 />'; } //* Set the function parameters. $mailuser_id = 1; $app = $client->mail_user_get($session_id, $mailuser_id); print_r($app); if ($client->logout($session_id)) { echo 'Logged out.<br />'; } } catch (SoapFault $e) { echo $client->__getLastResponse(); die('SOAP Error: ' . $e->getMessage()); }
<?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()); }