71 $this->Security =
get_package(
'security' ,
'last' , __FILE__ );
72 $this->UserAccess =
get_package(
'user::user_access' ,
'last' , __FILE__ );
106 $id = $this->Security->get( $id ,
'integer' );
108 $Users = $this->UserAccess->unsafe_select( $this->UserAccess->NativeTable.
".id = $id" );
110 if( count( $Users ) === 0 || count( $Users ) > 1 )
112 throw(
new Exception(
'User with id '.$id.
' was not found' ) );
116 return( $Users[ 0 ] );
119 catch( Exception $e )
137 if( session_id() ==
'' )
167 if( isset( $_SESSION[
'login' ] ) )
174 catch( Exception $e )
208 return( $_SESSION[
'login' ] );
218 catch( Exception $e )
250 return( $_SESSION[
'user_id' ] );
255 return( $this->UserAccess->GuestUserId );
260 catch( Exception $e )
288 if( $this->User ===
false )
293 return( $this->User );
295 catch( Exception $e )
331 $_SESSION[
'login' ] = $Login;
332 $_SESSION[
'user_id' ] = $id;
341 catch( Exception $e )
367 unset( $_SESSION[
'login' ] );
368 unset( $_SESSION[
'id' ] );
372 catch( Exception $e )
404 $User = $this->UserAccess->get_user( $Login );
406 return(
$User->active ==
'active' );
408 catch( Exception $e )
440 $User = $this->UserAccess->get_user( $Login );
442 return(
$User->banned );
444 catch( Exception $e )
476 if( $Login ===
false )
481 $User = $this->UserAccess->get_user( $Login );
483 return(
$User->password );
485 catch( Exception $e )
517 $Login = $this->Security->get( $Login ,
'string' );
519 $this->UserAccess->get_user( $Login );
523 catch( Exception $e )
547 function delete( $ids )
551 $ids = $this->Security->get( $ids ,
'integer_list' );
553 $Users = $this->UserAccess->unsafe_select( $this->UserAccess->NativeTable.
554 ".id IN( $ids ) and `system` = 0" );
556 $this->UserAccess->delete( implode(
',' ,
get_field_ex( $Users ,
'id' ) ) );
558 catch( Exception $e )
590 $Email = $this->Security->get( $Email ,
'email' );
592 $Records = $this->UserAccess->unsafe_select(
"email LIKE '$Email'" );
594 return( count( $Records ) == 1 );
596 catch( Exception $e )
636 $Login = $this->Security->get( $Login ,
'string' );
637 $Password = $this->Security->get( $Password ,
'string' );
639 $User = $this->UserAccess->get_user( $Login );
650 catch( Exception $e )
682 $Letters =
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
683 $c = strlen( $Letters );
687 for( $i = 0 ; $i < $Length ; $i++ )
689 $Password .= $Letters[ rand( 0 , $c - 1 ) ];
694 catch( Exception $e )