Detailed Description
Working with user's accounts.
- Author
- Dodonov A.A.
Definition at line 26 of file user_algorithms.php.
Constructor & Destructor Documentation
Constructor.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 67 of file user_algorithms.php.
{
try
{
$this->Security =
get_package(
'security' ,
'last' , __FILE__ );
$this->UserAccess =
get_package(
'user::user_access' ,
'last' , __FILE__ );
}
catch( Exception $e )
{
}
}
Member Function Documentation
Function deletes user.
- Parameters
-
| $ids | - id of the deleting user. |
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 547 of file user_algorithms.php.
{
try
{
$ids = $this->Security->get( $ids , 'integer_list' );
$Users = $this->UserAccess->unsafe_select( $this->UserAccess->NativeTable.
".id IN( $ids ) and `system` = 0" );
$this->UserAccess->delete( implode(
',' ,
get_field_ex( $Users ,
'id' ) ) );
}
catch( Exception $e )
{
}
}
Function validates email's existance.
- Parameters
-
| $Email | - Email of the validated user. |
- Returns
- true if user exists, false otherwise.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 586 of file user_algorithms.php.
{
try
{
$Email = $this->Security->get( $Email , 'email' );
$Records = $this->UserAccess->unsafe_select( "email LIKE '$Email'" );
return( count( $Records ) == 1 );
}
catch( Exception $e )
{
}
}
| generate_password |
( |
|
$Length = 10 | ) |
|
Function generates password.
- Parameters
-
| $Length | - Password length. |
- Returns
- Password.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 678 of file user_algorithms.php.
{
try
{
$Letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
$c = strlen( $Letters );
$Password = '';
for( $i = 0 ; $i < $Length ; $i++ )
{
$Password .= $Letters[ rand( 0 , $c - 1 ) ];
}
return( $Password );
}
catch( Exception $e )
{
}
}
Function returns user by it's id.
- Parameters
-
| $id | - Id of the searching user. |
- Returns
- User object.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 102 of file user_algorithms.php.
{
try
{
$id = $this->Security->get( $id , 'integer' );
$Users = $this->UserAccess->unsafe_select( $this->UserAccess->NativeTable.".id = $id" );
if( count( $Users ) === 0 || count( $Users ) > 1 )
{
throw( new Exception( 'User with id '.$id.' was not found' ) );
}
else
{
return( $Users[ 0 ] );
}
}
catch( Exception $e )
{
}
}
Function returns id of the logged in user.
- Returns
- Id of the logged in user.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 242 of file user_algorithms.php.
{
try
{
{
return( $_SESSION[ 'user_id' ] );
}
else
{
return( $this->UserAccess->GuestUserId );
}
return( false );
}
catch( Exception $e )
{
}
}
Function returns login of the logged in user.
- Returns
- Login of the logged in user, if no user is logged in, then "guest" is returned.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 199 of file user_algorithms.php.
{
try
{
{
return( $_SESSION[ 'login' ] );
}
else
{
return( 'guest' );
}
return( false );
}
catch( Exception $e )
{
}
}
| get_password_hash |
( |
|
$Login = false | ) |
|
Function returns md5 hash of the password.
- Parameters
-
| $Login | - login of the deleting user. |
- Returns
- md5 hash of the password.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 472 of file user_algorithms.php.
{
try
{
if( $Login === false )
{
}
$User = $this->UserAccess->get_user( $Login );
return(
$User->password );
}
catch( Exception $e )
{
}
}
Function returns object of the logged in user.
- Returns
- Id of the logged in user.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 284 of file user_algorithms.php.
{
try
{
if( $this->User === false )
{
}
return( $this->User );
}
catch( Exception $e )
{
}
}
Function validates if user with the login $Login is logged in.
- Returns
- true if logged in, false otherwise.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 161 of file user_algorithms.php.
{
try
{
if( isset( $_SESSION[ 'login' ] ) )
{
return( true );
}
return( false );
}
catch( Exception $e )
{
}
}
Function logins user.
- Parameters
-
| $Login | - Login of the user to be logged in. |
| $id | - id of the user to be logged in. |
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 323 of file user_algorithms.php.
{
try
{
{
$_SESSION[ 'login' ] = $Login;
$_SESSION[ 'user_id' ] = $id;
$this->User = false;
}
else
{
return( false );
}
}
catch( Exception $e )
{
}
}
Function logouts user.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 361 of file user_algorithms.php.
{
try
{
unset( $_SESSION[ 'login' ] );
unset( $_SESSION[ 'id' ] );
$this->User = false;
}
catch( Exception $e )
{
}
}
Function starts sessions.
- Author
- Dodonov A.A.
Definition at line 135 of file user_algorithms.php.
{
if( session_id() == '' )
{
}
}
Function validates if user is active.
- Parameters
-
| $Login | - login of the deleting user. |
- Returns
- true if the user is active, false otherwise.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 400 of file user_algorithms.php.
{
try
{
$User = $this->UserAccess->get_user( $Login );
return(
$User->active ==
'active' );
}
catch( Exception $e )
{
}
}
Function validates if user is banned.
- Parameters
-
| $Login | - login of the deleting user. |
- Returns
- true if the user is active, false otherwise.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 436 of file user_algorithms.php.
{
try
{
$User = $this->UserAccess->get_user( $Login );
}
catch( Exception $e )
{
}
}
Function validates user's existance.
- Parameters
-
| $Login | - login of the validated user. |
- Returns
- true if user exists, false otherwise.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 513 of file user_algorithms.php.
{
try
{
$Login = $this->Security->get( $Login , 'string' );
$this->UserAccess->get_user( $Login );
return( true );
}
catch( Exception $e )
{
return( false );
}
}
| validate_auth |
( |
|
$Login, |
|
|
|
$Password, |
|
|
|
$HashPassed = false |
|
) |
| |
Function validates login and password.
- Parameters
-
| $Login | - Inputed login. |
| $Password | - Inputed password. |
| $HashPassed | - true if md5 hash of the password was put in $Password. |
- Returns
- false if login and password validation was passed.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 632 of file user_algorithms.php.
{
try
{
$Login = $this->Security->get( $Login , 'string' );
$Password = $this->Security->get( $Password , 'string' );
$User = $this->UserAccess->get_user( $Login );
if( $HashPassed )
{
}
else
{
}
}
catch( Exception $e )
{
}
}
Field Documentation
The documentation for this class was generated from the following file: