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

Class: File_Passwd_Common

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

Class Overview


Baseclass for File_Passwd_* classes.


Author(s):

Version:

  • $Revision: 1.18 $

Variables

Methods


Child classes:

File_Passwd_Authbasic
Manipulate AuthUserFiles as used for HTTP Basic Authentication.
File_Passwd_Authdigest
Manipulate AuthDigestFiles as used for HTTP Digest Authentication.
File_Passwd_Custom
Manipulate custom formatted passwd files
File_Passwd_Cvs
Manipulate CVS pserver passwd files.
File_Passwd_Smb
Manipulate SMB server passwd files.
File_Passwd_Unix
Manipulate standard Unix passwd files.

Inherited Variables

Inherited Methods


Class Details

[line 52]
Baseclass for File_Passwd_* classes.

<u> Provides basic operations: </u>

  • opening & closing
  • locking & unlocking
  • loading & saving
  • check if user exist
  • delete a certain user
  • list users

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


[ Top ]


Class Variables

$_contents = array()

[line 68]

file content
  • Access: protected

Type:   aray


[ Top ]

$_file =  'passwd'

[line 60]

passwd file
  • Access: protected

Type:   string


[ Top ]

$_pcre =  '/^[a-z]+[a-z0-9_-]*$/i'

[line 84]

PCRE for valid chars
  • Access: protected

Type:   string


[ Top ]

$_users = array()

[line 76]

users
  • Access: protected

Type:   array


[ Top ]



Method Detail

__construct (Constructor)   [line 92]

File_Passwd_Common __construct( [string $file = 'passwd'])

Constructor (ZE2)
  • Access: protected

Overridden in child classes as:

File_Passwd_Authbasic::__construct()
Constructor (ZE2)
File_Passwd_Smb::__construct()
Constructor (ZE2)

Parameters:

string   $file     path to passwd file

[ Top ]

delUser   [line 303]

mixed delUser( string $user)

Delete a certain user

Returns a PEAR_Error if user doesn't exist.

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

Parameters:

string   $user     

[ Top ]

getFile   [line 276]

string getFile( )

Get path of passwd file
  • Access: public

[ Top ]

listUser   [line 325]

mixed listUser( [string $user = ''])

List user

Returns a PEAR_Error if $user doesn't exist.

  • Return: array of a/all user(s) or PEAR_Error
  • Throws: PEAR_Error
  • Access: public

Parameters:

string   $user     the user to list or all users if empty

[ Top ]

load   [line 216]

mixed load( )

Loads the file

Returns a PEAR_Error if:

  • directory in which the file should reside couldn't be created
  • file couldn't be opened in read 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

[ Top ]

parse   [line 107]

object PEAR_Error parse( )

Parse the content of the file

You must overwrite this method in your File_Passwd_* class.

  • Abstract:
  • Access: public

Overridden in child classes as:

File_Passwd_Authbasic::parse()
Parse the AuthUserFile
File_Passwd_Authdigest::parse()
Parse the AuthDigestFile
File_Passwd_Custom::parse()
Parse the Custom password file
File_Passwd_Cvs::parse()
Parse the CVS passwd file
File_Passwd_Smb::parse()
Parse smbpasswd file
File_Passwd_Unix::parse()
Parse the Unix password file

[ Top ]

save   [line 125]

object PEAR_Error save( )

Apply changes and rewrite passwd file

You must overwrite this method in your File_Passwd_* class.

  • Abstract:
  • Access: public

Overridden in child classes as:

File_Passwd_Authbasic::save()
Apply changes and rewrite AuthUserFile
File_Passwd_Authdigest::save()
Apply changes and rewrite AuthDigestFile
File_Passwd_Custom::save()
Apply changes an rewrite passwd file
File_Passwd_Cvs::save()
Apply changes and rewrite CVS passwd file
File_Passwd_Smb::save()
Apply changes and rewrite CVS passwd file
File_Passwd_Unix::save()
Apply changes an rewrite passwd file

[ Top ]

setFile   [line 265]

void setFile( $file)

Set path to passwd file
  • Access: public

Parameters:

   $file     

[ Top ]

userExists   [line 288]

bool userExists( string $user)

Check if a certain user already exists
  • Access: public

Parameters:

string   $user     the name of the user to check if already exists

[ Top ]

_auth   [line 357]

mixed _auth( string $file, string $id, [string $sep = ':'])

Base method for File_Passwd::staticAuth()

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: line of passwd file containing $id, false if $id wasn't found or PEAR_Error
  • Throws: PEAR_Error
  • Access: protected

Parameters:

string   $file     path to passwd file
string   $id     user_id to search for
string   $sep     field separator

[ Top ]

_close   [line 185]

mixed _close( &$file_handle, resource $file_handle)

Closes a prior opened and locked file handle

Returns a PEAR_Error if:

  • file couldn't be unlocked
  • file couldn't be closed

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

Parameters:

resource   $file_handle     the file handle to operate on
   &$file_handle     

[ Top ]

_open   [line 146]

mixed &_open( string $mode, [ $file = null])

Opens a file, locks it exclusively and returns the filehandle

Returns a PEAR_Error if:

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

  • Return: resource of type file handle or PEAR_Error
  • Throws: PEAR_Error
  • Access: protected

Parameters:

string   $mode     the mode to open the file with
   $file     

[ Top ]

_save   [line 249]

mixed _save( $content)

Save the modified content to the passwd file

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: protected

Parameters:

   $content     

[ Top ]


Documentation generated on Sun, 04 Jan 2009 13:00:06 -0500 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.