[PATCH] Auth::changePassword

From: Date: Wed, 25 Feb 2004 23:00:20 +0000
Subject: [PATCH] Auth::changePassword
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-25872@lists.php.net to get a copy of this message
Hello all. I created a patch[1] for Auth that implements a changePassword function. It accepts two simple arguments(username, new password) and returns true, false, or AUTH_METHOD_NOT_SUPPORTED. It's documented, commented, and tested. I also provided implementations for this method in all 4 containers that currently support Adding/removing users. DB, File, MDB, and SMBPasswd. All worked fine in my test environment. The generic Container also implements an empty function that merely returns AUTH_METHOD_NOT_SUPPORTED, and Auth itself implements a function that calls the Container's function. Each function was added using the same CS and style as the other functions around it so they'll be easy to maintain by the curreny maintainers. I also fixed some typo's in the inline-documentation, updated some minor strings/docs/comments to make them easier to understand, and fixed some CS violations ( if(..){, else on seperate lines, whitespace). I also added this function to the package.xml'sc Changelog. Sorry if this is bad practice :) This patch includes the patch provided by "m at tacker dot org " in Bug #798 [2] for DB.php. Also, I noticed the docs for Auth[3] are somewhat outdated. THey don't mention the new add/remove user functions, nor some of the other new functions of the program. Could someone advise how I'd best proceed to get these added to the manual? :) Could someone please import this patch into CVS? Thanks in advance :) -- Cipriano [1] ATTACHMENT or http://www.cipri.com/pear/Auth.diff.txt [2] http://pear.php.net/bugs/bug.php?id=798 [3] http://pear.php.net/manual/en/package.authentication.php

? Auth.diff.txt Index: Auth.php =================================================================== RCS file: /repository/pear/Auth/Auth.php,v retrieving revision 1.72 diff -u -r1.72 Auth.php --- Auth.php 3 Feb 2004 21:51:25 -0000 1.72 +++ Auth.php 25 Feb 2004 22:37:55 -0000 @@ -57,11 +57,11 @@ var $expired = false; /** - * Maximum time of idleness in seconds + * Maximum idletime in seconds * * The difference to $expire is, that the idletime gets - * refreshed each time, checkAuth() is called. If this - * variable is set to 0, idle time is never checked. + * refreshed each time checkAuth() is called. If this + * variable is set to 0, idletime is never checked. * * @var integer * @see setIdle(), checkAuth() @@ -85,14 +85,14 @@ var $storage = ''; /** - * Function defined by the user, that creates the login screen + * User-defined function that creates the login screen * * @var string */ var $loginFunction = ''; /** - * Should the login form be displayed? + * Should the login form be displayed, and are users allowed to authenticate via this page? * * @var bool * @see setShowlogin() @@ -160,8 +160,9 @@ /** * Flag to use advanced security - * when set extra checks will be made, to see if the user ip - * or useragent have changed accross requests, set to off by default to preserve BC + * When set extra checks will be made to see if the + * user's IP or useragent have changed across requests. + * Turned off by default to preserve BC. * * @var boolean */ @@ -238,12 +239,12 @@ * Assign data from login form to internal values * * This function takes the values for username and password - * from $HTTP_POST_VARS and assigns them to internal variables. - * If you wish to use another source apart from $HTTP_POST_VARS, + * from $HTTP_POST_VARS/$_POST and assigns them to internal variables. + * If you wish to use another source apart from $HTTP_POST_VARS/$_POST, * you have to derive this function. * * @access private - * @global $HTTP_POST_VARS + * @global $HTTP_POST_VARS, $_POST * @see Auth * @return void */ @@ -483,12 +484,12 @@ function getAuthData($name = null) { $session = &Auth::_importGlobalVariable('session'); - if(!isset($session[$this->_sessionName]['data'])){ - return(null); + if (!isset($session[$this->_sessionName]['data'])) { + return null; } if (is_null($name)) { - if(isset($session[$this->_sessionName]['data'])) { + if (isset($session[$this->_sessionName]['data'])) { return $session[$this->_sessionName]['data']; } else { return null; @@ -524,7 +525,7 @@ $session[$this->_sessionName] = array(); } - if(!isset($session[$this->_sessionName]['data'])){ + if (!isset($session[$this->_sessionName]['data'])) { $session[$this->_sessionName]['data'] = array(); } @@ -537,7 +538,7 @@ $session[$this->_sessionName]['idle'] = time(); } - function setAdvancedSecurity($flag=true){ + function setAdvancedSecurity($flag=true) { $this->advancedsecurity = $flag; } @@ -554,10 +555,10 @@ { $session = &$this->_importGlobalVariable('session'); - if($this->advancedsecurity){ + if ($this->advancedsecurity) { // Check for ip change - if(isset($session[$this->_sessionName]['sessionip']) && isset($_SERVER['REMOTE_ADDR']) && $session[$this->_sessionName]['sessionip'] != $_SERVER['REMOTE_ADDR']){ - // Check if the ip of the user has changed, if so we assume a man in the middle attach an log him out + if (isset($session[$this->_sessionName]['sessionip']) && isset($_SERVER['REMOTE_ADDR']) && $session[$this->_sessionName]['sessionip'] != $_SERVER['REMOTE_ADDR']) { + // Check if the IP of the user has changed, if so we assume a man in the middle attack and log him out $this->logout(); $this->expired = true; $this->status = AUTH_SECURITY_BREACH; @@ -565,8 +566,8 @@ } // Check for useragent change - if(isset($session[$this->_sessionName]['sessionuseragent']) && isset($_SERVER['HTTP_USER_AGENT']) && $session[$this->_sessionName]['sessionuseragent'] != $_SERVER['HTTP_USER_AGENT']){ - // Check if the ip of the user has changed, if so we assume a man in the middle attach an log him out + if (isset($session[$this->_sessionName]['sessionuseragent']) && isset($_SERVER['HTTP_USER_AGENT']) && $session[$this->_sessionName]['sessionuseragent'] != $_SERVER['HTTP_USER_AGENT']) { + // Check if the User-Agent of the user has changed, if so we assume a man in the middle attack and log him out $this->logout(); $this->expired = true; $this->status = AUTH_SECURITY_BREACH; @@ -662,13 +663,13 @@ echo '<center>'."\n"; if (!empty($this->status) && $this->status == AUTH_EXPIRED) { - echo '<i>Your session expired. Please login again!</i>'."\n"; + echo '<i>Your session has expired. Please login again!</i>'."\n"; } else if (!empty($this->status) && $this->status == AUTH_IDLED) { echo '<i>You have been idle for too long. Please login again!</i>'."\n"; } else if (!empty ($this->status) && $this->status == AUTH_WRONG_LOGIN) { echo '<i>Wrong login data!</i>'."\n"; } else if (!empty ($this->status) && $this->status == AUTH_SECURITY_BREACH) { - echo '<i>Security problem your ip has changed!</i>'."\n"; + echo '<i>Security problem. Either your IP or your User-Agent(Browser) has changed!</i>'."\n"; } PEAR::raiseError('You are using the built-in login screen of PEAR::Auth.<br />See the <a href="http://pear.php.net/manual/">manual</a> for details on how to create your own login function.', null); @@ -738,7 +739,7 @@ function updateIdle() { $session = &$this->_importGlobalVariable('session'); - $session[$this->_sessionName]['idle'] = time(); + $session[$this->_sessionName]['idle'] = time(); } // }}} @@ -841,6 +842,23 @@ } // }}} + // {{{ changePassword() + + /** + * Change password for user in the storage container + * + * @access public + * @param string Username + * @param string The new password + * @return mixed True on success, PEAR error object on error + * and AUTH_METHOD_NOT_SUPPORTED otherwise. + */ + function changePassword($username, $password) + { + return $this->storage->changePassword($username, $password); + } + + // }}} // {{{ _importGlobalVariable() /** Index: Container.php =================================================================== RCS file: /repository/pear/Auth/Container.php,v retrieving revision 1.16 diff -u -r1.16 Container.php --- Container.php 9 Feb 2004 20:24:32 -0000 1.16 +++ Container.php 25 Feb 2004 22:37:55 -0000 @@ -96,8 +96,7 @@ default : if (function_exists($cryptType)) { return ($cryptType($password1) == $password2); - } - else if (method_exists($this,$cryptType)) { + } elseif (method_exists($this,$cryptType)) { return ($this->$cryptType($password1) == $password2); } else { return false; @@ -127,15 +126,15 @@ function getUser($username) { $users = $this->listUsers(); - if($users === AUTH_METHOD_NOT_SUPPORTED){ - return(AUTH_METHOD_NOT_SUPPORTED); + if ($users === AUTH_METHOD_NOT_SUPPORTED) { + return AUTH_METHOD_NOT_SUPPORTED; } - for($i=0;$c = count($users),$i<$c;$i++){ - if($users[$i]['username'] == $username){ - return($users[$i]); + for ($i=0; $c = count($users), $i<$c; $i++) { + if ($users[$i]['username'] == $username) { + return $users[$i]; } } - return(false); + return false; } @@ -171,5 +170,21 @@ // }}} + + // {{{ changePassword() + + /** + * Change password for user in the storage container + * + * @param string Username + * @param string The new password + */ + function changePassword($username, $password) + { + return AUTH_METHOD_NOT_SUPPORTED; + } + + // }}} + } ?> Index: package.xml =================================================================== RCS file: /repository/pear/Auth/package.xml,v retrieving revision 1.41 diff -u -r1.41 package.xml --- package.xml 3 Feb 2004 21:53:34 -0000 1.41 +++ package.xml 25 Feb 2004 22:37:56 -0000 @@ -46,15 +46,16 @@ <state>beta</state> <notes> <![CDATA[ +* Added method changePassword to container to change users' password. <cipri@campai.nl> * Added method setAdvancedSecurity and set advanced security to off by default, if turned on auth will perform aditional - secirity checks if ip or user agent has changed accross requests + security checks if ip or user agent has changed across requests * Login is now performed only if showLogin is true, do not allow for logins to be performed from any page which calls auth->start spotted by Matt Eaton <pear@divinehawk.com> [16/Jan/2004 - yavo] NOTE reconsider this before relase * Fixed bug noted by Jeroen Houben <jeroen@terena.nl>, calling loginFailedCallback would not have the proper status set [16/Jan/2004 - yavo] * Added check for ip change which user is logged in, this is considered a security violation and the user is logged out [16/Dec/2003 - yavo] -* Added PEAR container, authenticate the use against the pear web site +* Added PEAR container, authenticate the user against the pear web site (probably php.net also) [16/Dec/2003 - yavo] ]]> </notes> Index: Container/DB.php =================================================================== RCS file: /repository/pear/Auth/Container/DB.php,v retrieving revision 1.43 diff -u -r1.43 DB.php --- Container/DB.php 21 Feb 2004 21:22:47 -0000 1.43 +++ Container/DB.php 25 Feb 2004 22:37:59 -0000 @@ -92,7 +92,7 @@ function _connect($dsn) { if (is_string($dsn) || is_array($dsn)) { - $this->db = DB::Connect($dsn); + $this->db = DB::Connect($dsn, $this->options['db_options']); } elseif (get_parent_class($dsn) == "db_common") { $this->db = $dsn; } elseif (DB::isError($dsn)) { @@ -129,7 +129,7 @@ { if (!DB::isConnection($this->db)) { $res = $this->_connect($this->options['dsn']); - if(DB::isError($res) || PEAR::isError($res)){ + if (DB::isError($res) || PEAR::isError($res)) { return $res; } } @@ -177,6 +177,7 @@ $this->options['dsn'] = ''; $this->options['db_fields'] = ''; $this->options['cryptType'] = 'md5'; + $this->options['db_options'] = array(); } // }}} @@ -197,8 +198,8 @@ } /* Include additional fields if they exist */ - if(!empty($this->options['db_fields'])){ - if(is_array($this->options['db_fields'])){ + if (!empty($this->options['db_fields'])) { + if (is_array($this->options['db_fields'])) { $this->options['db_fields'] = join($this->options['db_fields'], ', '); } $this->options['db_fields'] = ', '.$this->options['db_fields']; @@ -229,8 +230,8 @@ return PEAR::raiseError($err->getMessage(), $err->getCode()); } - // Find if db_fileds contains a *, i so assume all col are selected - if(strstr($this->options['db_fields'], '*')){ + // Find if db_fields contains a *, if so assume all col are selected + if (strstr($this->options['db_fields'], '*')) { $sql_from = "*"; } else{ @@ -275,7 +276,7 @@ } // Use reference to the auth object if exists // This is because the auth session variable can change so a static call to setAuthData does not make sence - if(is_object($this->_auth_obj)){ + if (is_object($this->_auth_obj)) { $this->_auth_obj->setAuthData($key, $value); } else { Auth::setAuthData($key, $value); @@ -301,8 +302,8 @@ $retVal = array(); - // Find if db_fileds contains a *, i so assume all col are selected - if(strstr($this->options['db_fields'], '*')){ + // Find if db_fields contains a *, if so assume all col are selected + if (strstr($this->options['db_fields'], '*')) { $sql_from = "*"; } else{ @@ -341,10 +342,9 @@ */ function addUser($username, $password, $additional = "") { - if(isset($this->options['cryptType']) && $this->options['cryptType'] == 'none'){ + if (isset($this->options['cryptType']) && $this->options['cryptType'] == 'none') { $cryptFunction = 'strval'; - } - elseif (isset($this->options['cryptType']) && function_exists($this->options['cryptType'])) { + } elseif (isset($this->options['cryptType']) && function_exists($this->options['cryptType'])) { $cryptFunction = $this->options['cryptType']; } else { $cryptFunction = 'md5'; @@ -375,9 +375,9 @@ $res = $this->query($query); if (DB::isError($res)) { - return PEAR::raiseError($res->getMessage(), $res->getCode()); + return PEAR::raiseError($res->getMessage(), $res->getCode()); } else { - return true; + return true; } } @@ -410,5 +410,43 @@ } // }}} + // {{{ changePassword() + + /** + * Change password for user in the storage container + * + * @param string Username + * @param string The new password (plain text) + */ + function changePassword($username, $password) + { + if (isset($this->options['cryptType']) && $this->options['cryptType'] == 'none') { + $cryptFunction = 'strval'; + } elseif (isset($this->options['cryptType']) && function_exists($this->options['cryptType'])) { + $cryptFunction = $this->options['cryptType']; + } else { + $cryptFunction = 'md5'; + } + + $password = $cryptFunction($password); + + $query = sprintf("UPDATE %s SET %s = '%s' WHERE %s = '%s'", + $this->options['table'], + $this->options['passwordcol'], + $password, + $this->options['usernamecol'], + $username + ); + + $res = $this->query($query); + + if (DB::isError($res)) { + return PEAR::raiseError($res->getMessage(), $res->getCode()); + } else { + return true; + } + } + + // }}} } ?> Index: Container/File.php =================================================================== RCS file: /repository/pear/Auth/Container/File.php,v retrieving revision 1.14 diff -u -r1.14 File.php --- Container/File.php 29 Oct 2003 13:42:40 -0000 1.14 +++ Container/File.php 25 Feb 2004 22:37:59 -0000 @@ -124,7 +124,7 @@ } $res = $pw_obj->addUser($user, $pass, $cvs); - if(PEAR::isError($res)){ + if (PEAR::isError($res)) { return false; } @@ -154,7 +154,36 @@ $res = $pw_obj->delUser($user); - if(PEAR::isError($res)){ + if (PEAR::isError($res)) { + return false; + } + + $res = $pw_obj->save(); + if (PEAR::isError($res)) { + return false; + } + + return true; + } + + // }}} + // {{{ changePassword() + + /** + * Change password for user in the storage container + * + * @param string Username + * @param string The new password + */ + function changePassword($username, $password) + { + $pw_obj = &$this->_load(); + if (PEAR::isError($pw_obj)) { + return false; + } + + $res = $pw_obj->changePasswd($user, $pass); + if (PEAR::isError($res)) { return false; } Index: Container/IMAP.php =================================================================== RCS file: /repository/pear/Auth/Container/IMAP.php,v retrieving revision 1.7 diff -u -r1.7 IMAP.php --- Container/IMAP.php 20 Oct 2003 09:38:29 -0000 1.7 +++ Container/IMAP.php 25 Feb 2004 22:38:01 -0000 @@ -157,7 +157,7 @@ { $dsn = '{'.$this->options['host'].':'.$this->options['port'].$this->options['baseDSN'].'}'; $conn = @imap_open ($dsn, $username, $password, OP_HALFOPEN); - if (is_resource($conn)){ + if (is_resource($conn)) { $this->activeUser = $username; @imap_close($conn); return true; Index: Container/LDAP.php =================================================================== RCS file: /repository/pear/Auth/Container/LDAP.php,v retrieving revision 1.14 diff -u -r1.14 LDAP.php --- Container/LDAP.php 2 Jun 2003 16:55:10 -0000 1.14 +++ Container/LDAP.php 25 Feb 2004 22:38:03 -0000 @@ -187,20 +187,20 @@ $conn_params = array($this->options['host'], $this->options['port']); } - if(($this->conn_id = @call_user_func_array('ldap_connect', $conn_params)) === false) { + if (($this->conn_id = @call_user_func_array('ldap_connect', $conn_params)) === false) { return PEAR::raiseError('Auth_Container_LDAP: Could not connect to server.', 41, PEAR_ERROR_DIE); } $this->_debug('Successfully connected to server', __LINE__); // try switchig to LDAPv3 $ver = 0; - if(@ldap_get_option($this->conn_id, LDAP_OPT_PROTOCOL_VERSION, $ver) && $ver >= 2) { + if (@ldap_get_option($this->conn_id, LDAP_OPT_PROTOCOL_VERSION, $ver) && $ver >= 2) { $this->_debug('Switching to LDAPv3', __LINE__); @ldap_set_option($this->conn_id, LDAP_OPT_PROTOCOL_VERSION, 3); } // bind with credentials or anonymously - if($this->options['binddn'] && $this->options['bindpw']) { + if ($this->options['binddn'] && $this->options['bindpw']) { $this->_debug('Binding with credentials', __LINE__); $bind_params = array($this->conn_id, $this->options['binddn'], $this->options['bindpw']); } else { @@ -224,7 +224,7 @@ */ function _disconnect() { - if($this->_isValidLink()) { + if ($this->_isValidLink()) { $this->_debug('disconnecting from server'); @ldap_unbind($this->conn_id); } @@ -273,8 +273,8 @@ */ function _isValidLink() { - if(is_resource($this->conn_id)) { - if(get_resource_type($this->conn_id) == 'ldap link') { + if (is_resource($this->conn_id)) { + if (get_resource_type($this->conn_id) == 'ldap link') { return true; } } @@ -386,7 +386,7 @@ $this->_debug('Bind successful', __LINE__); // check group if appropiate - if(isset($this->options['group'])) { + if (isset($this->options['group'])) { // decide whether memberattr value is a dn or the username $this->_debug('Checking group membership', __LINE__); return $this->checkGroup(($this->options['memberisdn']) ? $user_dn : $username); @@ -426,7 +426,7 @@ // make search base dn $search_basedn = $this->options['groupdn']; - if($search_basedn != '' && substr($search_basedn, -1) != ',') { + if ($search_basedn != '' && substr($search_basedn, -1) != ',') { $search_basedn .= ','; } $search_basedn .= $this->options['basedn']; @@ -436,8 +436,8 @@ $this->_debug("Searching with $filter in $search_basedn", __LINE__); // search - if(($result_id = @call_user_func_array($this->ldap_search_func, $func_params)) != false) { - if(ldap_count_entries($this->conn_id, $result_id) == 1) { + if (($result_id = @call_user_func_array($this->ldap_search_func, $func_params)) != false) { + if (ldap_count_entries($this->conn_id, $result_id) == 1) { ldap_free_result($result_id); $this->_debug('User is member of group', __LINE__); $this->_disconnect(); @@ -460,8 +460,8 @@ */ function _debug($msg = '', $line = 0) { - if($this->options['debug'] === true) { - if($msg == '' && $this->_isValidLink()) { + if ($this->options['debug'] === true) { + if ($msg == '' && $this->_isValidLink()) { $msg = 'LDAP_Error: ' . @ldap_err2str(@ldap_errno($this->_conn_id)); } print("$line: $msg <br />"); Index: Container/MDB.php =================================================================== RCS file: /repository/pear/Auth/Container/MDB.php,v retrieving revision 1.13 diff -u -r1.13 MDB.php --- Container/MDB.php 21 Feb 2004 21:22:47 -0000 1.13 +++ Container/MDB.php 25 Feb 2004 22:38:07 -0000 @@ -227,7 +227,7 @@ // Find if db_fileds contains a *, i so assume all col are selected if (strstr($this->options['db_fields'], '*')) { $sql_from = '*'; - } else{ + } else { $sql_from = $this->options['usernamecol'] . ', '. $this->options['passwordcol'] . $this->options['db_fields']; } @@ -258,7 +258,7 @@ } // Use reference to the auth object if exists // This is because the auth session variable can change so a static call to setAuthData does not make sence - if(is_object($this->_auth_obj)){ + if (is_object($this->_auth_obj)) { $this->_auth_obj->setAuthData($key, $value); } else { Auth::setAuthData($key, $value); @@ -287,7 +287,7 @@ // Find if db_fileds contains a *, i so assume all col are selected if (strstr($this->options['db_fields'], '*')) { $sql_from = '*'; - } else{ + } else { $sql_from = $this->options['db_fields']; } @@ -325,10 +325,9 @@ function addUser($username, $password, $additional = "") { - if(isset($this->options['cryptType']) && $this->options['cryptType'] == 'none'){ + if (isset($this->options['cryptType']) && $this->options['cryptType'] == 'none') { $cryptFunction = 'strval'; - } - elseif (isset($this->options['cryptType']) && function_exists($this->options['cryptType'])) { + } elseif (isset($this->options['cryptType']) && function_exists($this->options['cryptType'])) { $cryptFunction = $this->options['cryptType']; } else { $cryptFunction = 'md5'; @@ -392,5 +391,41 @@ } // }}} + // {{{ changePassword() + + /** + * Change password for user in the storage container + * + * @param string Username + * @param string The new password + */ + function changePassword($username, $password) + { + if (isset($this->options['cryptType']) && $this->options['cryptType'] == 'none') { + $cryptFunction = 'strval'; + } elseif (isset($this->options['cryptType']) && function_exists($this->options['cryptType'])) { + $cryptFunction = $this->options['cryptType']; + } else { + $cryptFunction = 'md5'; + } + + $query = sprintf("UPDATE %s SET %s = %s WHERE %s = %s", + $this->options['table'], + $this->options['passwordcol'], + $password, + $this->options['usernamecol'], + $username + ); + + $res = $this->query($query); + + if (MDB::isError($res)) { + return PEAR::raiseError($res->getMessage(), $res->code); + } else { + return true; + } + } + // }}} + } ?> \ No newline at end of file Index: Container/PEAR.php =================================================================== RCS file: /repository/pear/Auth/Container/PEAR.php,v retrieving revision 1.2 diff -u -r1.2 PEAR.php --- Container/PEAR.php 15 Dec 2003 23:52:55 -0000 1.2 +++ Container/PEAR.php 25 Feb 2004 22:38:07 -0000 @@ -3,27 +3,28 @@ include_once('XML/RPC.php'); class Auth_Container_Pear { - function Auth_Container_pear(){ + function Auth_Container_pear() + { } - function fetchData($username, $password){ + function fetchData($username, $password) + { $rpc = new XML_RPC_Client('/xmlrpc.php', 'pear.php.net'); $rpc_message = new XML_RPC_Message("user.info", array(new XML_RPC_Value($username, "string")) ); // Error Checking howto ??? $result = $rpc->send($rpc_message); $value = $result->value(); $userinfo = xml_rpc_decode($value); - if($userinfo['password'] == md5($password)){ + if ($userinfo['password'] == md5($password)) { $this->activeUser = $userinfo['handle']; - foreach($userinfo as $uk=>$uv){ + foreach ($userinfo as $uk=>$uv) { $this->_auth_obj->setAuthData($uk, $uv); } - return(true); + return true; } - return(false); + return false; } } - ?> \ No newline at end of file Index: Container/POP3.php =================================================================== RCS file: /repository/pear/Auth/Container/POP3.php,v retrieving revision 1.3 diff -u -r1.3 POP3.php --- Container/POP3.php 28 Jul 2003 21:39:39 -0000 1.3 +++ Container/POP3.php 25 Feb 2004 22:38:07 -0000 @@ -57,23 +57,20 @@ */ function Auth_Container_POP3($server=null) { - if(isset($server)){ - if(is_array($server)){ - if(isset($server['host'])){ + if (isset($server)) { + if (is_array($server)) { + if (isset($server['host'])) { $this->server = $server['host']; } - if(isset($server['port'])){ + if (isset($server['port'])) { $this->port = $server['port']; } - } - else{ - if(strstr($server, ':')){ + } else { + if (strstr($server, ':')) { $serverparts = explode(':', trim($server)); $this->server = $serverparts[0]; $this->port = $serverparts[1]; - } - else - { + } else { $this->server = $server; } } @@ -94,8 +91,8 @@ { $pop3 =& new Net_POP3(); $res = $pop3->connect($this->server, $this->port); - if(!$res){ - return($res); + if (!$res) { + return $res; } $result = $pop3->login($username, $password); $pop3->disconnect(); Index: Container/SMBPasswd.php =================================================================== RCS file: /repository/pear/Auth/Container/SMBPasswd.php,v retrieving revision 1.1 diff -u -r1.1 SMBPasswd.php --- Container/SMBPasswd.php 13 May 2003 19:23:54 -0000 1.1 +++ Container/SMBPasswd.php 25 Feb 2004 22:38:08 -0000 @@ -129,6 +129,24 @@ } // }}} + // {{{ changePassword() + + /** + * Change password for user in the storage container + * + * @param string Username + * @param string The new password + */ + function changePassword($username, $password) + { + $res = $this->pwfile->modUser($username, '', $password); + if ($res === true) { + return $this->pwfile->save(); + } + return $res; + } + + // }}} } ?>
« previous php.pear.dev (#25872) next »