File_Passwd
[ class tree: File_Passwd ] [ index: File_Passwd ] [ all elements ]

Class: File_Passwd_Authbasic

Source Location: /File_Passwd-1.1.7/Passwd/Authbasic.php

Class Overview

File_Passwd_Common
   |
   --File_Passwd_Authbasic

Manipulate AuthUserFiles as used for HTTP Basic Authentication.


Author(s):

Version:

  • $Revision: 1.17 $

Methods


Inherited Variables

Inherited Methods

Class: File_Passwd_Common

File_Passwd_Common::__construct()
Constructor (ZE2)
File_Passwd_Common::delUser()
Delete a certain user
File_Passwd_Common::getFile()
Get path of passwd file
File_Passwd_Common::listUser()
List user
File_Passwd_Common::load()
Loads the file
File_Passwd_Common::parse()
Parse the content of the file
File_Passwd_Common::save()
Apply changes and rewrite passwd file
File_Passwd_Common::setFile()
Set path to passwd file
File_Passwd_Common::userExists()
Check if a certain user already exists
File_Passwd_Common::_auth()
Base method for File_Passwd::staticAuth()
File_Passwd_Common::_close()
Closes a prior opened and locked file handle
File_Passwd_Common::_open()
Opens a file, locks it exclusively and returns the filehandle
File_Passwd_Common::_save()
Save the modified content to the passwd file

Class Details

[line 58]
Manipulate AuthUserFiles as used for HTTP Basic Authentication.

<u> Usage Example: </u>

  1.    $htp &File_Passwd::factory('AuthBasic');
  2.    $htp->setMode('sha');
  3.    $htp->setFile('/www/mike/auth/.htpasswd');
  4.    $htp->load();
  5.    $htp->addUser('mike''secret');
  6.    $htp->save();

<u> Output of listUser() </u>

      array
       + user => crypted_passwd
       + user => crypted_passwd

  • Author: Michael Wallner <mike@php.net>
  • Version: $Revision: 1.17 $
  • Access: public


[ Top ]


Method Detail

__construct (Constructor)   [line 104]

File_Passwd_Authbasic __construct( [string $file = '.htpasswd'])

Constructor (ZE2)

Rewritten because DES encryption is not supportet by the Win32 httpd.

  • Access: protected

Overrides File_Passwd_Common::__construct() (Constructor (ZE2))

Parameters:

string   $file   —  path to AuthUserFile

[ Top ]

File_Passwd_Authbasic (Constructor)   [line 90]

File_Passwd_Authbasic File_Passwd_Authbasic( [string $file = '.htpasswd'])

Constructor
  • Access: public

Parameters:

string   $file   —  path to AuthUserFile

[ Top ]

addUser   [line 185]

mixed addUser( string $user, string $pass)

Add an user

The username must start with an alphabetical character and must NOT contain any other characters than alphanumerics, the underline and dash.

Returns a PEAR_Error if:

  • user already exists
  • user contains illegal characters

  • Return: true on success or PEAR_Error
  • Throws: PEAR_Error
  • Access: public

Parameters:

string   $user   — 
string   $pass   — 

[ Top ]

changePasswd   [line 214]

mixed changePasswd( string $user, string $pass)

Change the password of a certain user

Returns a PEAR_Error if user doesn't exist.

  • Return: true on success or a PEAR_Error
  • Throws: PEAR_Error
  • Access: public

Parameters:

string   $user   —  the user whose password should be changed
string   $pass   —  the new plaintext password

[ Top ]

generatePasswd   [line 376]

mixed generatePasswd( string $pass, [string $mode = FILE_PASSWD_DES], [string $salt = null])

Generate Password

Returns PEAR_Error FILE_PASSD_E_INVALID_ENC_MODE if the supplied encryption mode is not supported.

  • Return: The crypted password on success or PEAR_Error on failure.
  • Access: public

Parameters:

string   $pass   —  The plaintext password.
string   $mode   —  The encryption mode to use (des|md5|sha).
string   $salt   —  The salt to use.

[ Top ]

getMode   [line 257]

string getMode( )

Get actual encryption mode
  • Access: public

[ Top ]

listModes   [line 277]

array listModes( )

Get supported encryption modes

   array
    + md5
    + sha
    + des

ATTN: DES encryption not available on Win32!

  • Access: public

[ Top ]

parse   [line 346]

mixed parse( )

Parse the AuthUserFile

Returns a PEAR_Error if AuthUserFile has invalid format.

  • Return: true on success or PEAR_error
  • Throws: PEAR_Error
  • Access: public

Overrides File_Passwd_Common::parse() (Parse the content of the file)
[ Top ]

save   [line 160]

mixed save( )

Apply changes and rewrite AuthUserFile

Returns a PEAR_Error if:

  • directory in which the file should reside couldn't be created
  • file couldn't be opened in write mode
  • file couldn't be locked exclusively
  • file couldn't be unlocked
  • file couldn't be closed

  • Return: true on success or PEAR_Error
  • Throws: PEAR_Error
  • Access: public

Overrides File_Passwd_Common::save() (Apply changes and rewrite passwd file)
[ Top ]

setMode   [line 296]

mixed setMode( string $mode)

Set the encryption mode

You can choose one of md5, sha or des.

ATTN: DES encryption not available on Win32!

Returns a PEAR_Error if a specific encryption mode is not supported.

  • Return: true on succes or PEAR_Error
  • Throws: PEAR_Error
  • Access: public

Parameters:

string   $mode   — 

[ Top ]

staticAuth   [line 132]

mixed staticAuth( string $file, string $user, string $pass, string $mode)

Fast authentication of a certain user

Returns a PEAR_Error if:

  • file doesn't exist
  • file couldn't be opened in read mode
  • file couldn't be locked exclusively
  • file couldn't be unlocked (only if auth fails)
  • file couldn't be closed (only if auth fails)

  • Return: true if authenticated, false if not or PEAR_Error
  • Throws: PEAR_Error
  • Access: public

Parameters:

string   $file   —  path to passwd file
string   $user   —  user to authenticate
string   $pass   —  plaintext password
string   $mode   —  des, sha or md5

[ Top ]

verifyPasswd   [line 239]

mixed verifyPasswd( string $user, string $pass)

Verify password

Returns a PEAR_Error if:

  • user doesn't exist
  • an invalid encryption mode was supplied

  • Return: true if passwords equal, false if they don't, or PEAR_Error
  • Throws: PEAR_Error
  • Access: public

Parameters:

string   $user   —  the user whose password should be verified
string   $pass   —  the plaintext password to verify

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:28:09 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.