Пример #1
0
 private function _save($curpass, $passwd)
 {
     $config = rcmail::get_instance()->config;
     $driver = $this->home . '/drivers/' . $config->get('password_driver', 'sql') . '.php';
     if (!is_readable($driver)) {
         raise_error(array('code' => 600, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Password plugin: Unable to open driver file {$driver}"), true, false);
         return $this->gettext('internalerror');
     }
     include $driver;
     if (!function_exists('password_save')) {
         raise_error(array('code' => 600, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Password plugin: Broken driver: {$driver}"), true, false);
         return $this->gettext('internalerror');
     }
     $result = password_save($curpass, $passwd);
     if (is_array($result)) {
         $result = $result['code'];
         $message = $result['message'];
     }
     switch ($result) {
         case PASSWORD_SUCCESS:
             return;
         case PASSWORD_CRYPT_ERROR:
             $reason = $this->gettext('crypterror');
         case PASSWORD_CONNECT_ERROR:
             $reason = $this->gettext('connecterror');
         case PASSWORD_ERROR:
         default:
             $reason = $this->gettext('internalerror');
     }
     if ($message) {
         $reason .= ' ' . $message;
     }
     return $reason;
 }
 private function _save($curpass, $passwd)
 {
     $config = rcmail::get_instance()->config;
     $driver = $this->home . '/drivers/' . $config->get('password_driver', 'sql') . '.php';
     if ($config->get('password_driver', 'sql') != 'alliance') {
         if (!is_readable($driver)) {
             raise_error(array('code' => 600, 'type' => 'php', 'file' => __FILE__, 'message' => "Password plugin: Unable to open driver file {$driver}"), true, false);
             return $this->gettext('internalerror');
         }
         include $driver;
         if (!function_exists('password_save')) {
             raise_error(array('code' => 600, 'type' => 'php', 'file' => __FILE__, 'message' => "Password plugin: Broken driver: {$driver}"), true, false);
             return $this->gettext('internalerror');
         }
         $result = password_save($curpass, $passwd);
     } else {
         $uid_parts = split("@", $_SESSION['username']);
         $uid = $uid_parts[0];
         include_once "changeOpenLDAPPwd.class.php";
         $objChangePasswd = new csChangeOpenLDAPPasswd();
         $res = $objChangePasswd->changePWD($uid, $curpass, $passwd, $passwd);
         if ($res) {
             $result = PASSWORD_SUCCESS;
         } else {
             $result = PASSWORD_ERROR;
         }
     }
     switch ($result) {
         case PASSWORD_SUCCESS:
             return;
         case PASSWORD_CRYPT_ERROR:
             return $this->gettext('crypterror');
         case PASSWORD_CONNECT_ERROR:
             return $this->gettext('connecterror');
         case PASSWORD_ERROR:
         default:
             return $this->gettext('internalerror');
     }
 }