diff options
Diffstat (limited to 'lib/user')
-rw-r--r-- | lib/user/backend.php | 14 | ||||
-rw-r--r-- | lib/user/database.php | 40 | ||||
-rw-r--r-- | lib/user/dummy.php | 20 | ||||
-rw-r--r-- | lib/user/http.php | 28 | ||||
-rw-r--r-- | lib/user/interface.php | 2 |
5 files changed, 52 insertions, 52 deletions
diff --git a/lib/user/backend.php b/lib/user/backend.php index 36e4bd9f761..2a95db93690 100644 --- a/lib/user/backend.php +++ b/lib/user/backend.php @@ -59,9 +59,9 @@ abstract class OC_User_Backend implements OC_User_Interface { * Returns the supported actions as int to be * compared with OC_USER_BACKEND_CREATE_USER etc. */ - public function getSupportedActions(){ + public function getSupportedActions() { $actions = 0; - foreach($this->possibleActions AS $action => $methodName){ + foreach($this->possibleActions AS $action => $methodName) { if(method_exists($this, $methodName)) { $actions |= $action; } @@ -78,7 +78,7 @@ abstract class OC_User_Backend implements OC_User_Interface { * Returns the supported actions as int to be * compared with OC_USER_BACKEND_CREATE_USER etc. */ - public function implementsActions($actions){ + public function implementsActions($actions) { return (bool)($this->getSupportedActions() & $actions); } @@ -89,7 +89,7 @@ abstract class OC_User_Backend implements OC_User_Interface { * * Deletes a user */ - public function deleteUser( $uid ){ + public function deleteUser( $uid ) { return false; } @@ -99,7 +99,7 @@ abstract class OC_User_Backend implements OC_User_Interface { * * Get a list of all users. */ - public function getUsers($search = '', $limit = -1, $offset = 0) { + public function getUsers($search = '', $limit = null, $offset = null) { return array(); } @@ -108,7 +108,7 @@ abstract class OC_User_Backend implements OC_User_Interface { * @param string $uid the username * @return boolean */ - public function userExists($uid){ + public function userExists($uid) { return false; } @@ -117,7 +117,7 @@ abstract class OC_User_Backend implements OC_User_Interface { * @param string $uid the username * @return boolean */ - public function getHome($uid){ + public function getHome($uid) { return false; } } diff --git a/lib/user/database.php b/lib/user/database.php index a4cffe5d0c1..76b44a2f6ca 100644 --- a/lib/user/database.php +++ b/lib/user/database.php @@ -43,9 +43,9 @@ class OC_User_Database extends OC_User_Backend { * @var PasswordHash */ static private $hasher=null; - - private function getHasher(){ - if(!self::$hasher){ + + private function getHasher() { + if(!self::$hasher) { //we don't want to use DES based crypt(), since it doesn't return a has with a recognisable prefix $forcePortable=(CRYPT_BLOWFISH!=1); self::$hasher=new PasswordHash(8,$forcePortable); @@ -53,7 +53,7 @@ class OC_User_Database extends OC_User_Backend { return self::$hasher; } - + /** * @brief Create a new user * @param $uid The username of the user to create @@ -63,8 +63,8 @@ class OC_User_Database extends OC_User_Backend { * Creates a new user. Basic checking of username is done in OC_User * itself, not in its subclasses. */ - public function createUser( $uid, $password ){ - if( $this->userExists($uid) ){ + public function createUser( $uid, $password ) { + if( $this->userExists($uid) ) { return false; }else{ $hasher=$this->getHasher(); @@ -83,7 +83,7 @@ class OC_User_Database extends OC_User_Backend { * * Deletes a user */ - public function deleteUser( $uid ){ + public function deleteUser( $uid ) { // Delete user-group-relation $query = OC_DB::prepare( 'DELETE FROM `*PREFIX*users` WHERE uid = ?' ); $query->execute( array( $uid )); @@ -98,8 +98,8 @@ class OC_User_Database extends OC_User_Backend { * * Change the password of a user */ - public function setPassword( $uid, $password ){ - if( $this->userExists($uid) ){ + public function setPassword( $uid, $password ) { + if( $this->userExists($uid) ) { $hasher=$this->getHasher(); $hash = $hasher->HashPassword($password.OC_Config::getValue('passwordsalt', '')); $query = OC_DB::prepare( 'UPDATE `*PREFIX*users` SET `password` = ? WHERE `uid` = ?' ); @@ -120,22 +120,22 @@ class OC_User_Database extends OC_User_Backend { * Check if the password is correct without logging in the user * returns the user id or false */ - public function checkPassword( $uid, $password ){ - $query = OC_DB::prepare( 'SELECT `uid`, `password` FROM `*PREFIX*users` WHERE `uid` = ?' ); + public function checkPassword( $uid, $password ) { + $query = OC_DB::prepare( 'SELECT `uid`, `password` FROM `*PREFIX*users` WHERE LOWER(`uid`) = LOWER(?)' ); $result = $query->execute( array( $uid)); $row=$result->fetchRow(); - if($row){ + if($row) { $storedHash=$row['password']; - if ($storedHash[0]=='$'){//the new phpass based hashing + if ($storedHash[0]=='$') {//the new phpass based hashing $hasher=$this->getHasher(); - if($hasher->CheckPassword($password.OC_Config::getValue('passwordsalt', ''), $storedHash)){ + if($hasher->CheckPassword($password.OC_Config::getValue('passwordsalt', ''), $storedHash)) { return $row['uid']; }else{ return false; } }else{//old sha1 based hashing - if(sha1($password)==$storedHash){ + if(sha1($password)==$storedHash) { //upgrade to new hashing $this->setPassword($row['uid'],$password); return $row['uid']; @@ -169,10 +169,10 @@ class OC_User_Database extends OC_User_Backend { * @param string $uid the username * @return boolean */ - public function userExists($uid){ - $query = OC_DB::prepare( 'SELECT * FROM `*PREFIX*users` WHERE `uid` = ?' ); + public function userExists($uid) { + $query = OC_DB::prepare( 'SELECT * FROM `*PREFIX*users` WHERE LOWER(`uid`) = LOWER(?)' ); $result = $query->execute( array( $uid )); - + return $result->numRows() > 0; } @@ -181,8 +181,8 @@ class OC_User_Database extends OC_User_Backend { * @param string $uid the username * @return boolean */ - public function getHome($uid){ - if($this->userExists($uid)){ + public function getHome($uid) { + if($this->userExists($uid)) { return OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" ) . '/' . $uid; }else{ return false; diff --git a/lib/user/dummy.php b/lib/user/dummy.php index da3edfb2df4..4dbbc02b888 100644 --- a/lib/user/dummy.php +++ b/lib/user/dummy.php @@ -35,8 +35,8 @@ class OC_User_Dummy extends OC_User_Backend { * Creates a new user. Basic checking of username is done in OC_User * itself, not in its subclasses. */ - public function createUser($uid, $password){ - if(isset($this->users[$uid])){ + public function createUser($uid, $password) { + if(isset($this->users[$uid])) { return false; }else{ $this->users[$uid]=$password; @@ -51,8 +51,8 @@ class OC_User_Dummy extends OC_User_Backend { * * Deletes a user */ - public function deleteUser( $uid ){ - if(isset($this->users[$uid])){ + public function deleteUser( $uid ) { + if(isset($this->users[$uid])) { unset($this->users[$uid]); return true; }else{ @@ -68,8 +68,8 @@ class OC_User_Dummy extends OC_User_Backend { * * Change the password of a user */ - public function setPassword($uid, $password){ - if(isset($this->users[$uid])){ + public function setPassword($uid, $password) { + if(isset($this->users[$uid])) { $this->users[$uid]=$password; return true; }else{ @@ -86,8 +86,8 @@ class OC_User_Dummy extends OC_User_Backend { * Check if the password is correct without logging in the user * returns the user id or false */ - public function checkPassword($uid, $password){ - if(isset($this->users[$uid])){ + public function checkPassword($uid, $password) { + if(isset($this->users[$uid])) { return ($this->users[$uid]==$password); }else{ return false; @@ -100,7 +100,7 @@ class OC_User_Dummy extends OC_User_Backend { * * Get a list of all users. */ - public function getUsers($search = '', $limit = -1, $offset = 0) { + public function getUsers($search = '', $limit = null, $offset = null) { return array_keys($this->users); } @@ -109,7 +109,7 @@ class OC_User_Dummy extends OC_User_Backend { * @param string $uid the username * @return boolean */ - public function userExists($uid){ + public function userExists($uid) { return isset($this->users[$uid]); } } diff --git a/lib/user/http.php b/lib/user/http.php index 547c0201b69..2668341408d 100644 --- a/lib/user/http.php +++ b/lib/user/http.php @@ -30,29 +30,29 @@ class OC_User_HTTP extends OC_User_Backend { * @param string path * @return array */ - private function parseUrl($url){ + private function parseUrl($url) { $parts=parse_url($url); $url=$parts['scheme'].'://'.$parts['host']; - if(isset($parts['port'])){ + if(isset($parts['port'])) { $url.=':'.$parts['port']; } $url.=$parts['path']; - if(isset($parts['query'])){ + if(isset($parts['query'])) { $url.='?'.$parts['query']; } return array($parts['user'],$url); - + } - + /** * check if an url is a valid login * @param string url * @return boolean */ - private function matchUrl($url){ + private function matchUrl($url) { return ! is_null(parse_url($url,PHP_URL_USER)); } - + /** * @brief Check if the password is correct * @param $uid The username @@ -62,12 +62,12 @@ class OC_User_HTTP extends OC_User_Backend { * Check if the password is correct without logging in the user * returns the user id or false */ - public function checkPassword($uid, $password){ - if(!$this->matchUrl($uid)){ + public function checkPassword($uid, $password) { + if(!$this->matchUrl($uid)) { return false; } list($user,$url)=$this->parseUrl($uid); - + $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_USERPWD, $user.':'.$password); @@ -76,7 +76,7 @@ class OC_User_HTTP extends OC_User_Backend { curl_exec($ch); $status = curl_getinfo($ch, CURLINFO_HTTP_CODE); - + curl_close($ch); return $status==200; @@ -87,7 +87,7 @@ class OC_User_HTTP extends OC_User_Backend { * @param string $uid the username * @return boolean */ - public function userExists($uid){ + public function userExists($uid) { return $this->matchUrl($uid); } @@ -96,8 +96,8 @@ class OC_User_HTTP extends OC_User_Backend { * @param string $uid the username * @return boolean */ - public function getHome($uid){ - if($this->userExists($uid)){ + public function getHome($uid) { + if($this->userExists($uid)) { return OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" ) . '/' . $uid; }else{ return false; diff --git a/lib/user/interface.php b/lib/user/interface.php index a4903898fb1..3d9f4691f24 100644 --- a/lib/user/interface.php +++ b/lib/user/interface.php @@ -48,7 +48,7 @@ interface OC_User_Interface { * * Get a list of all users. */ - public function getUsers($search = '', $limit = -1, $offset = 0); + public function getUsers($search = '', $limit = null, $offset = null); /** * @brief check if a user exists |