<span style=
"color: #0000ff;"
>
class
</span><span style=
"color: #000000;"
> User{
</span><span style=
"color: #0000ff;"
>
const
</span> I = 1; <span style=
"color: #008000;"
>
<span style=
"color: #0000ff;"
>
const
</span> FD = 2; <span style=
"color: #008000;"
>
<span style=
"color: #0000ff;"
>
const
</span> FN = 4; <span style=
"color: #008000;"
>
<span style=
"color: #0000ff;"
>
const
</span> FC = 8; <span style=
"color: #008000;"
>
<span style=
"color: #0000ff;"
>
const
</span> FL = 16; <span style=
"color: #008000;"
>
<span style=
"color: #0000ff;"
>
const
</span> D = 32; <span style=
"color: #008000;"
>
<span style=
"color: #0000ff;"
>
const
</span> N = 64; <span style=
"color: #008000;"
>
<span style=
"color: #0000ff;"
>
const
</span> A = 128; <span style=
"color: #008000;"
>
<span style=
"color: #0000ff;"
>
const
</span> W = 256; <span style=
"color: #008000;"
>
<span style=
"color: #0000ff;"
>
const
</span> R = 512; <span style=
"color: #008000;"
>
<span style=
"color: #0000ff;"
>PRivate</span> <span style=
"color: #800080;"
>
$hash_salt
</span> =
''
<span style=
"color: #000000;"
>;
</span><span style=
"color: #0000ff;"
>
private
</span> <span style=
"color: #800080;"
>
$user_file
</span><span style=
"color: #000000;"
>;
</span><span style=
"color: #0000ff;"
>
private
</span> <span style=
"color: #800080;"
>
$group_file
</span><span style=
"color: #000000;"
>;
</span><span style=
"color: #0000ff;"
>
private
</span> <span style=
"color: #800080;"
>
$users
</span> = <span style=
"color: #0000ff;"
>
array
</span><span style=
"color: #000000;"
>();
</span><span style=
"color: #0000ff;"
>
private
</span> <span style=
"color: #800080;"
>
$groups
</span> = <span style=
"color: #0000ff;"
>
array
</span><span style=
"color: #000000;"
>();
</span><span style=
"color: #0000ff;"
>
private
</span> <span style=
"color: #800080;"
>
$file_hash
</span> =
''
<span style=
"color: #000000;"
>;
</span><span style=
"color: #0000ff;"
>
public
</span> <span style=
"color: #0000ff;"
>
function
</span><span style=
"color: #000000;"
> __construct(){
</span><span style=
"color: #800080;"
>
$this
</span>->user_file = BASE_PATH.
'/conf/users'
<span style=
"color: #000000;"
>;
</span><span style=
"color: #800080;"
>
$this
</span>->group_file = BASE_PATH.
'/conf/groups'
<span style=
"color: #000000;"
>;
</span><span style=
"color: #800080;"
>
$this
</span>-><span style=
"color: #000000;"
>reload();
}
</span><span style=
"color: #008000;"
>
</span>
<span style=
"color: #0000ff;"
>
public
</span> <span style=
"color: #0000ff;"
>
static
</span> <span style=
"color: #0000ff;"
>
function
</span> AC(<span style=
"color: #800080;"
>
$access
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #800080;"
>
$str
</span> =
''
<span style=
"color: #000000;"
>;
</span><span style=
"color: #800080;"
>
$char
</span> = <span style=
"color: #0000ff;"
>
array
</span>(
'R'
,
'W'
,
'A'
,
'N'
,
'D'
,
'L'
,
'C'
,
'N'
,
'D'
,
'I'
<span style=
"color: #000000;"
>);
</span><span style=
"color: #0000ff;"
>
for
</span>(<span style=
"color: #800080;"
>
$i
</span> = 0; <span style=
"color: #800080;"
>
$i
</span>
$i
++<span style=
"color: #000000;"
>){
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #800080;"
>
$access
</span> & <span style=
"color: #008080;"
>pow</span>(2,9-<span style=
"color: #800080;"
>
$i
</span>))<span style=
"color: #800080;"
>
$str
</span>.= <span style=
"color: #800080;"
>
$char
</span>[<span style=
"color: #800080;"
>
$i
</span>];<span style=
"color: #0000ff;"
>
else
</span> <span style=
"color: #800080;"
>
$str
</span>.=
'-'
<span style=
"color: #000000;"
>;
}
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #800080;"
>
$str
</span><span style=
"color: #000000;"
>;
}
</span><span style=
"color: #008000;"
>
</span>
<span style=
"color: #0000ff;"
>
public
</span> <span style=
"color: #0000ff;"
>
function
</span><span style=
"color: #000000;"
> reload(){
</span><span style=
"color: #800080;"
>
$user_file_hash
</span> = <span style=
"color: #008080;"
>md5_file</span>(<span style=
"color: #800080;"
>
$this
</span>-><span style=
"color: #000000;"
>user_file);
</span><span style=
"color: #800080;"
>
$group_file_hash
</span> = <span style=
"color: #008080;"
>md5_file</span>(<span style=
"color: #800080;"
>
$this
</span>-><span style=
"color: #000000;"
>group_file);
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #800080;"
>
$this
</span>->file_hash != <span style=
"color: #008080;"
>md5</span>(<span style=
"color: #800080;"
>
$user_file_hash
</span>.<span style=
"color: #800080;"
>
$group_file_hash
</span><span style=
"color: #000000;"
>)){
</span><span style=
"color: #0000ff;"
>
if
</span>((<span style=
"color: #800080;"
>
$user
</span> = <span style=
"color: #008080;"
>
file_get_contents
</span>(<span style=
"color: #800080;"
>
$this
</span>->user_file)) !== <span style=
"color: #0000ff;"
>false</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #800080;"
>
$this
</span>->users = json_decode(<span style=
"color: #800080;"
>
$user
</span>,<span style=
"color: #0000ff;"
>true</span><span style=
"color: #000000;"
>);
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #800080;"
>
$this
</span>-><span style=
"color: #000000;"
>users){
</span><span style=
"color: #008000;"
>
<span style=
"color: #0000ff;"
>
foreach
</span> (<span style=
"color: #800080;"
>
$this
</span>->users <span style=
"color: #0000ff;"
>
as
</span> <span style=
"color: #800080;"
>
$user
</span>=><span style=
"color: #800080;"
>
$profile
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #0000ff;"
>isset</span>(<span style=
"color: #800080;"
>
$profile
</span>[
'folder'
<span style=
"color: #000000;"
>])){
</span><span style=
"color: #800080;"
>
$this
</span>->users[<span style=
"color: #800080;"
>
$user
</span>][
'folder'
] = <span style=
"color: #800080;"
>
$this
</span>->sortFolder(<span style=
"color: #800080;"
>
$profile
</span>[
'folder'
<span style=
"color: #000000;"
>]);
}
}
}
}
</span><span style=
"color: #0000ff;"
>
if
</span>((<span style=
"color: #800080;"
>
$group
</span> = <span style=
"color: #008080;"
>
file_get_contents
</span>(<span style=
"color: #800080;"
>
$this
</span>->group_file)) !== <span style=
"color: #0000ff;"
>false</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #800080;"
>
$this
</span>->groups = json_decode(<span style=
"color: #800080;"
>
$group
</span>,<span style=
"color: #0000ff;"
>true</span><span style=
"color: #000000;"
>);
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #800080;"
>
$this
</span>-><span style=
"color: #000000;"
>groups){
</span><span style=
"color: #008000;"
>
<span style=
"color: #0000ff;"
>
foreach
</span> (<span style=
"color: #800080;"
>
$this
</span>->groups <span style=
"color: #0000ff;"
>
as
</span> <span style=
"color: #800080;"
>
$group
</span>=><span style=
"color: #800080;"
>
$profile
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #0000ff;"
>isset</span>(<span style=
"color: #800080;"
>
$profile
</span>[
'folder'
<span style=
"color: #000000;"
>])){
</span><span style=
"color: #800080;"
>
$this
</span>->groups[<span style=
"color: #800080;"
>
$group
</span>][
'folder'
] = <span style=
"color: #800080;"
>
$this
</span>->sortFolder(<span style=
"color: #800080;"
>
$profile
</span>[
'folder'
<span style=
"color: #000000;"
>]);
}
}
}
}
</span><span style=
"color: #800080;"
>
$this
</span>->file_hash = <span style=
"color: #008080;"
>md5</span>(<span style=
"color: #800080;"
>
$user_file_hash
</span>.<span style=
"color: #800080;"
>
$group_file_hash
</span><span style=
"color: #000000;"
>);
}
}
</span><span style=
"color: #008000;"
>
</span>
<span style=
"color: #0000ff;"
>
private
</span> <span style=
"color: #0000ff;"
>
function
</span> sortFolder(<span style=
"color: #800080;"
>
$folder
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #008080;"
>uasort</span>(<span style=
"color: #800080;"
>
$folder
</span>, <span style=
"color: #0000ff;"
>
function
</span>(<span style=
"color: #800080;"
>
$a
</span>,<span style=
"color: #800080;"
>
$b
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #008080;"
>
strnatcmp
</span>(<span style=
"color: #800080;"
>
$a
</span>[
'path'
], <span style=
"color: #800080;"
>
$b
</span>[
'path'
<span style=
"color: #000000;"
>]);
});
</span><span style=
"color: #800080;"
>
$result
</span> = <span style=
"color: #0000ff;"
>
array
</span><span style=
"color: #000000;"
>();
</span><span style=
"color: #0000ff;"
>
foreach
</span> (<span style=
"color: #800080;"
>
$folder
</span> <span style=
"color: #0000ff;"
>
as
</span> <span style=
"color: #800080;"
>
$v
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #800080;"
>
$result
</span>[] = <span style=
"color: #800080;"
>
$v
</span><span style=
"color: #000000;"
>;
}
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #800080;"
>
$result
</span><span style=
"color: #000000;"
>;
}
</span><span style=
"color: #008000;"
>
</span>
<span style=
"color: #0000ff;"
>
public
</span> <span style=
"color: #0000ff;"
>
function
</span><span style=
"color: #000000;"
> save(){
</span><span style=
"color: #008080;"
>
file_put_contents
</span>(<span style=
"color: #800080;"
>
$this
</span>->user_file, json_encode(<span style=
"color: #800080;"
>
$this
</span>->users),<span style=
"color: #000000;"
>LOCK_EX);
</span><span style=
"color: #008080;"
>
file_put_contents
</span>(<span style=
"color: #800080;"
>
$this
</span>->group_file, json_encode(<span style=
"color: #800080;"
>
$this
</span>->groups),<span style=
"color: #000000;"
>LOCK_EX);
}
</span><span style=
"color: #008000;"
>
</span>
<span style=
"color: #0000ff;"
>
public
</span> <span style=
"color: #0000ff;"
>
function
</span> addUser(<span style=
"color: #800080;"
>
$user
</span>,<span style=
"color: #800080;"
>
$pass
</span>,<span style=
"color: #800080;"
>
$home
</span>,<span style=
"color: #800080;"
>
$expired
</span>,<span style=
"color: #800080;"
>
$active
</span>=<span style=
"color: #0000ff;"
>true</span>,<span style=
"color: #800080;"
>
$group
</span>=
''
,<span style=
"color: #800080;"
>
$description
</span>=
''
,<span style=
"color: #800080;"
>
$email
</span> =
''
<span style=
"color: #000000;"
>){
</span><span style=
"color: #800080;"
>
$user
</span> = <span style=
"color: #008080;"
>
strtolower
</span>(<span style=
"color: #800080;"
>
$user
</span><span style=
"color: #000000;"
>);
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #0000ff;"
>isset</span>(<span style=
"color: #800080;"
>
$this
</span>->users[<span style=
"color: #800080;"
>
$user
</span>]) || <span style=
"color: #0000ff;"
>
empty
</span>(<span style=
"color: #800080;"
>
$user
</span><span style=
"color: #000000;"
>)){
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #0000ff;"
>false</span><span style=
"color: #000000;"
>;
}
</span><span style=
"color: #800080;"
>
$this
</span>->users[<span style=
"color: #800080;"
>
$user
</span>] = <span style=
"color: #0000ff;"
>
array
</span><span style=
"color: #000000;"
>(
</span>
'pass'
=> <span style=
"color: #008080;"
>md5</span>(<span style=
"color: #800080;"
>
$user
</span>.<span style=
"color: #800080;"
>
$this
</span>->hash_salt.<span style=
"color: #800080;"
>
$pass
</span>),
'home'
=> <span style=
"color: #800080;"
>
$home
</span>,
'expired'
=> <span style=
"color: #800080;"
>
$expired
</span>,
'active'
=> <span style=
"color: #800080;"
>
$active
</span>,
'group'
=> <span style=
"color: #800080;"
>
$group
</span>,
'description'
=> <span style=
"color: #800080;"
>
$description
</span>,
'email'
=> <span style=
"color: #800080;"
>
$email
</span>,<span style=
"color: #000000;"
>
);
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #0000ff;"
>true</span><span style=
"color: #000000;"
>;
}
</span><span style=
"color: #008000;"
>
</span>
<span style=
"color: #0000ff;"
>
public
</span> <span style=
"color: #0000ff;"
>
function
</span> setUserProfile(<span style=
"color: #800080;"
>
$user
</span>,<span style=
"color: #800080;"
>
$profile
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #800080;"
>
$user
</span> = <span style=
"color: #008080;"
>
strtolower
</span>(<span style=
"color: #800080;"
>
$user
</span><span style=
"color: #000000;"
>);
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #008080;"
>
is_array
</span>(<span style=
"color: #800080;"
>
$profile
</span>) && <span style=
"color: #0000ff;"
>isset</span>(<span style=
"color: #800080;"
>
$this
</span>->users[<span style=
"color: #800080;"
>
$user
</span><span style=
"color: #000000;"
>])){
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #0000ff;"
>isset</span>(<span style=
"color: #800080;"
>
$profile
</span>[
'pass'
<span style=
"color: #000000;"
>])){
</span><span style=
"color: #800080;"
>
$profile
</span>[
'pass'
] = <span style=
"color: #008080;"
>md5</span>(<span style=
"color: #800080;"
>
$user
</span>.<span style=
"color: #800080;"
>
$this
</span>->hash_salt.<span style=
"color: #800080;"
>
$profile
</span>[
'pass'
<span style=
"color: #000000;"
>]);
}
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #0000ff;"
>isset</span>(<span style=
"color: #800080;"
>
$profile
</span>[
'active'
<span style=
"color: #000000;"
>])){
</span><span style=
"color: #0000ff;"
>
if
</span>(!<span style=
"color: #008080;"
>
is_bool
</span>(<span style=
"color: #800080;"
>
$profile
</span>[
'active'
<span style=
"color: #000000;"
>])){
</span><span style=
"color: #800080;"
>
$profile
</span>[
'active'
] = <span style=
"color: #800080;"
>
$profile
</span>[
'active'
] ==
'true'
? <span style=
"color: #0000ff;"
>true</span> : <span style=
"color: #0000ff;"
>false</span><span style=
"color: #000000;"
>;
}
}
</span><span style=
"color: #800080;"
>
$this
</span>->users[<span style=
"color: #800080;"
>
$user
</span>] = <span style=
"color: #008080;"
>
array_merge
</span>(<span style=
"color: #800080;"
>
$this
</span>->users[<span style=
"color: #800080;"
>
$user
</span>],<span style=
"color: #800080;"
>
$profile
</span><span style=
"color: #000000;"
>);
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #0000ff;"
>true</span><span style=
"color: #000000;"
>;
}
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #0000ff;"
>false</span><span style=
"color: #000000;"
>;
}
</span><span style=
"color: #008000;"
>
</span>
<span style=
"color: #0000ff;"
>
public
</span> <span style=
"color: #0000ff;"
>
function
</span> getUserProfile(<span style=
"color: #800080;"
>
$user
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #800080;"
>
$user
</span> = <span style=
"color: #008080;"
>
strtolower
</span>(<span style=
"color: #800080;"
>
$user
</span><span style=
"color: #000000;"
>);
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #0000ff;"
>isset</span>(<span style=
"color: #800080;"
>
$this
</span>->users[<span style=
"color: #800080;"
>
$user
</span><span style=
"color: #000000;"
>])){
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #800080;"
>
$this
</span>->users[<span style=
"color: #800080;"
>
$user
</span><span style=
"color: #000000;"
>];
}
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #0000ff;"
>false</span><span style=
"color: #000000;"
>;
}
</span><span style=
"color: #008000;"
>
</span>
<span style=
"color: #0000ff;"
>
public
</span> <span style=
"color: #0000ff;"
>
function
</span> delUser(<span style=
"color: #800080;"
>
$user
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #800080;"
>
$user
</span> = <span style=
"color: #008080;"
>
strtolower
</span>(<span style=
"color: #800080;"
>
$user
</span><span style=
"color: #000000;"
>);
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #0000ff;"
>isset</span>(<span style=
"color: #800080;"
>
$this
</span>->users[<span style=
"color: #800080;"
>
$user
</span><span style=
"color: #000000;"
>])){
</span><span style=
"color: #0000ff;"
>unset</span>(<span style=
"color: #800080;"
>
$this
</span>->users[<span style=
"color: #800080;"
>
$user
</span><span style=
"color: #000000;"
>]);
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #0000ff;"
>true</span><span style=
"color: #000000;"
>;
}
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #0000ff;"
>false</span><span style=
"color: #000000;"
>;
}
</span><span style=
"color: #008000;"
>
</span>
<span style=
"color: #0000ff;"
>
public
</span> <span style=
"color: #0000ff;"
>
function
</span><span style=
"color: #000000;"
> getUserList(){
</span><span style=
"color: #800080;"
>
$list
</span> = <span style=
"color: #0000ff;"
>
array
</span><span style=
"color: #000000;"
>();
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #800080;"
>
$this
</span>-><span style=
"color: #000000;"
>users){
</span><span style=
"color: #0000ff;"
>
foreach
</span> (<span style=
"color: #800080;"
>
$this
</span>->users <span style=
"color: #0000ff;"
>
as
</span> <span style=
"color: #800080;"
>
$user
</span>=><span style=
"color: #800080;"
>
$profile
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #800080;"
>
$list
</span>[] = <span style=
"color: #800080;"
>
$user
</span><span style=
"color: #000000;"
>;
}
}
</span><span style=
"color: #008080;"
>sort</span>(<span style=
"color: #800080;"
>
$list
</span><span style=
"color: #000000;"
>);
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #800080;"
>
$list
</span><span style=
"color: #000000;"
>;
}
</span><span style=
"color: #008000;"
>
</span>
<span style=
"color: #0000ff;"
>
public
</span> <span style=
"color: #0000ff;"
>
function
</span> addGroup(<span style=
"color: #800080;"
>
$group
</span>,<span style=
"color: #800080;"
>
$home
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #800080;"
>
$group
</span> = <span style=
"color: #008080;"
>
strtolower
</span>(<span style=
"color: #800080;"
>
$group
</span><span style=
"color: #000000;"
>);
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #0000ff;"
>isset</span>(<span style=
"color: #800080;"
>
$this
</span>->groups[<span style=
"color: #800080;"
>
$group
</span><span style=
"color: #000000;"
>])){
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #0000ff;"
>false</span><span style=
"color: #000000;"
>;
}
</span><span style=
"color: #800080;"
>
$this
</span>->groups[<span style=
"color: #800080;"
>
$group
</span>] = <span style=
"color: #0000ff;"
>
array
</span><span style=
"color: #000000;"
>(
</span>
'home'
=> <span style=
"color: #800080;"
>
$home
</span><span style=
"color: #000000;"
>
);
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #0000ff;"
>true</span><span style=
"color: #000000;"
>;
}
</span><span style=
"color: #008000;"
>
</span>
<span style=
"color: #0000ff;"
>
public
</span> <span style=
"color: #0000ff;"
>
function
</span> setGroupProfile(<span style=
"color: #800080;"
>
$group
</span>,<span style=
"color: #800080;"
>
$profile
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #800080;"
>
$group
</span> = <span style=
"color: #008080;"
>
strtolower
</span>(<span style=
"color: #800080;"
>
$group
</span><span style=
"color: #000000;"
>);
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #008080;"
>
is_array
</span>(<span style=
"color: #800080;"
>
$profile
</span>) && <span style=
"color: #0000ff;"
>isset</span>(<span style=
"color: #800080;"
>
$this
</span>->groups[<span style=
"color: #800080;"
>
$group
</span><span style=
"color: #000000;"
>])){
</span><span style=
"color: #800080;"
>
$this
</span>->groups[<span style=
"color: #800080;"
>
$group
</span>] = <span style=
"color: #008080;"
>
array_merge
</span>(<span style=
"color: #800080;"
>
$this
</span>->groups[<span style=
"color: #800080;"
>
$group
</span>],<span style=
"color: #800080;"
>
$profile
</span><span style=
"color: #000000;"
>);
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #0000ff;"
>true</span><span style=
"color: #000000;"
>;
}
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #0000ff;"
>false</span><span style=
"color: #000000;"
>;
}
</span><span style=
"color: #008000;"
>
</span>
<span style=
"color: #0000ff;"
>
public
</span> <span style=
"color: #0000ff;"
>
function
</span> getGroupProfile(<span style=
"color: #800080;"
>
$group
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #800080;"
>
$group
</span> = <span style=
"color: #008080;"
>
strtolower
</span>(<span style=
"color: #800080;"
>
$group
</span><span style=
"color: #000000;"
>);
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #0000ff;"
>isset</span>(<span style=
"color: #800080;"
>
$this
</span>->groups[<span style=
"color: #800080;"
>
$group
</span><span style=
"color: #000000;"
>])){
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #800080;"
>
$this
</span>->groups[<span style=
"color: #800080;"
>
$group
</span><span style=
"color: #000000;"
>];
}
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #0000ff;"
>false</span><span style=
"color: #000000;"
>;
}
</span><span style=
"color: #008000;"
>
</span>
<span style=
"color: #0000ff;"
>
public
</span> <span style=
"color: #0000ff;"
>
function
</span> delGroup(<span style=
"color: #800080;"
>
$group
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #800080;"
>
$group
</span> = <span style=
"color: #008080;"
>
strtolower
</span>(<span style=
"color: #800080;"
>
$group
</span><span style=
"color: #000000;"
>);
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #0000ff;"
>isset</span>(<span style=
"color: #800080;"
>
$this
</span>->groups[<span style=
"color: #800080;"
>
$group
</span><span style=
"color: #000000;"
>])){
</span><span style=
"color: #0000ff;"
>unset</span>(<span style=
"color: #800080;"
>
$this
</span>->groups[<span style=
"color: #800080;"
>
$group
</span><span style=
"color: #000000;"
>]);
</span><span style=
"color: #0000ff;"
>
foreach
</span> (<span style=
"color: #800080;"
>
$this
</span>->users <span style=
"color: #0000ff;"
>
as
</span> <span style=
"color: #800080;"
>
$user
</span> => <span style=
"color: #800080;"
>
$profile
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #800080;"
>
$profile
</span>[
'group'
] == <span style=
"color: #800080;"
>
$group
</span><span style=
"color: #000000;"
>)
</span><span style=
"color: #800080;"
>
$this
</span>->users[<span style=
"color: #800080;"
>
$user
</span>][
'group'
] =
''
<span style=
"color: #000000;"
>;
}
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #0000ff;"
>true</span><span style=
"color: #000000;"
>;
}
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #0000ff;"
>false</span><span style=
"color: #000000;"
>;
}
</span><span style=
"color: #008000;"
>
</span>
<span style=
"color: #0000ff;"
>
public
</span> <span style=
"color: #0000ff;"
>
function
</span><span style=
"color: #000000;"
> getGroupList(){
</span><span style=
"color: #800080;"
>
$list
</span> = <span style=
"color: #0000ff;"
>
array
</span><span style=
"color: #000000;"
>();
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #800080;"
>
$this
</span>-><span style=
"color: #000000;"
>groups){
</span><span style=
"color: #0000ff;"
>
foreach
</span> (<span style=
"color: #800080;"
>
$this
</span>->groups <span style=
"color: #0000ff;"
>
as
</span> <span style=
"color: #800080;"
>
$group
</span>=><span style=
"color: #800080;"
>
$profile
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #800080;"
>
$list
</span>[] = <span style=
"color: #800080;"
>
$group
</span><span style=
"color: #000000;"
>;
}
}
</span><span style=
"color: #008080;"
>sort</span>(<span style=
"color: #800080;"
>
$list
</span><span style=
"color: #000000;"
>);
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #800080;"
>
$list
</span><span style=
"color: #000000;"
>;
}
</span><span style=
"color: #008000;"
>
</span>
<span style=
"color: #0000ff;"
>
public
</span> <span style=
"color: #0000ff;"
>
function
</span> getUserListOfGroup(<span style=
"color: #800080;"
>
$group
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #800080;"
>
$list
</span> = <span style=
"color: #0000ff;"
>
array
</span><span style=
"color: #000000;"
>();
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #0000ff;"
>isset</span>(<span style=
"color: #800080;"
>
$this
</span>->groups[<span style=
"color: #800080;"
>
$group
</span>]) && <span style=
"color: #800080;"
>
$this
</span>-><span style=
"color: #000000;"
>users){
</span><span style=
"color: #0000ff;"
>
foreach
</span> (<span style=
"color: #800080;"
>
$this
</span>->users <span style=
"color: #0000ff;"
>
as
</span> <span style=
"color: #800080;"
>
$user
</span>=><span style=
"color: #800080;"
>
$profile
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #0000ff;"
>isset</span>(<span style=
"color: #800080;"
>
$profile
</span>[
'group'
]) && <span style=
"color: #800080;"
>
$profile
</span>[
'group'
] == <span style=
"color: #800080;"
>
$group
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #800080;"
>
$list
</span>[] = <span style=
"color: #800080;"
>
$user
</span><span style=
"color: #000000;"
>;
}
}
}
</span><span style=
"color: #008080;"
>sort</span>(<span style=
"color: #800080;"
>
$list
</span><span style=
"color: #000000;"
>);
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #800080;"
>
$list
</span><span style=
"color: #000000;"
>;
}
</span><span style=
"color: #008000;"
>
</span>
<span style=
"color: #0000ff;"
>
public
</span> <span style=
"color: #0000ff;"
>
function
</span> checkUser(<span style=
"color: #800080;"
>
$user
</span>,<span style=
"color: #800080;"
>
$pass
</span>,<span style=
"color: #800080;"
>
$ip
</span> =
''
<span style=
"color: #000000;"
>){
</span><span style=
"color: #800080;"
>
$this
</span>-><span style=
"color: #000000;"
>reload();
</span><span style=
"color: #800080;"
>
$user
</span> = <span style=
"color: #008080;"
>
strtolower
</span>(<span style=
"color: #800080;"
>
$user
</span><span style=
"color: #000000;"
>);
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #0000ff;"
>isset</span>(<span style=
"color: #800080;"
>
$this
</span>->users[<span style=
"color: #800080;"
>
$user
</span><span style=
"color: #000000;"
>])){
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #800080;"
>
$this
</span>->users[<span style=
"color: #800080;"
>
$user
</span>][
'active'
] && <span style=
"color: #008080;"
>time</span>()
strtotime
(<span style=
"color: #800080;"
>
$this
</span>->users[<span style=
"color: #800080;"
>
$user
</span>][
'expired'
<span style=
"color: #000000;"
>])
</span>&& <span style=
"color: #800080;"
>
$this
</span>->users[<span style=
"color: #800080;"
>
$user
</span>][
'pass'
] == <span style=
"color: #008080;"
>md5</span>(<span style=
"color: #800080;"
>
$user
</span>.<span style=
"color: #800080;"
>
$this
</span>->hash_salt.<span style=
"color: #800080;"
>
$pass
</span><span style=
"color: #000000;"
>)){
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #0000ff;"
>
empty
</span>(<span style=
"color: #800080;"
>
$ip
</span><span style=
"color: #000000;"
>)){
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #0000ff;"
>true</span><span style=
"color: #000000;"
>;
}</span><span style=
"color: #0000ff;"
>
else
</span><span style=
"color: #000000;"
>{
</span><span style=
"color: #008000;"
>
<span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #800080;"
>
$this
</span>->checkIP(<span style=
"color: #800080;"
>
$user
</span>, <span style=
"color: #800080;"
>
$ip
</span><span style=
"color: #000000;"
>);
}
}</span><span style=
"color: #0000ff;"
>
else
</span><span style=
"color: #000000;"
>{
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #0000ff;"
>false</span><span style=
"color: #000000;"
>;
}
}
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #0000ff;"
>false</span><span style=
"color: #000000;"
>;
}
</span><span style=
"color: #008000;"
>
</span>
<span style=
"color: #0000ff;"
>
public
</span> <span style=
"color: #0000ff;"
>
function
</span> checkUserBasicAuth(<span style=
"color: #800080;"
>
$base64
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #800080;"
>
$base64
</span> = <span style=
"color: #008080;"
>trim</span>(<span style=
"color: #008080;"
>
str_replace
</span>(
'Basic '
,
''
, <span style=
"color: #800080;"
>
$base64
</span><span style=
"color: #000000;"
>));
</span><span style=
"color: #800080;"
>
$str
</span> = <span style=
"color: #008080;"
>
base64_decode
</span>(<span style=
"color: #800080;"
>
$base64
</span><span style=
"color: #000000;"
>);
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #800080;"
>
$str
</span> !== <span style=
"color: #0000ff;"
>false</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #0000ff;"
>list</span>(<span style=
"color: #800080;"
>
$user
</span>,<span style=
"color: #800080;"
>
$pass
</span>) = <span style=
"color: #008080;"
>
explode
</span>(
':'
, <span style=
"color: #800080;"
>
$str
</span>,2<span style=
"color: #000000;"
>);
</span><span style=
"color: #800080;"
>
$this
</span>-><span style=
"color: #000000;"
>reload();
</span><span style=
"color: #800080;"
>
$user
</span> = <span style=
"color: #008080;"
>
strtolower
</span>(<span style=
"color: #800080;"
>
$user
</span><span style=
"color: #000000;"
>);
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #0000ff;"
>isset</span>(<span style=
"color: #800080;"
>
$this
</span>->users[<span style=
"color: #800080;"
>
$user
</span><span style=
"color: #000000;"
>])){
</span><span style=
"color: #800080;"
>
$group
</span> = <span style=
"color: #800080;"
>
$this
</span>->users[<span style=
"color: #800080;"
>
$user
</span>][
'group'
<span style=
"color: #000000;"
>];
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #800080;"
>
$group
</span> ==
'admin'
&& <span style=
"color: #800080;"
>
$this
</span>->users[<span style=
"color: #800080;"
>
$user
</span>][
'active'
] && <span style=
"color: #008080;"
>time</span>()
strtotime
(<span style=
"color: #800080;"
>
$this
</span>->users[<span style=
"color: #800080;"
>
$user
</span>][
'expired'
<span style=
"color: #000000;"
>])
</span>&& <span style=
"color: #800080;"
>
$this
</span>->users[<span style=
"color: #800080;"
>
$user
</span>][
'pass'
] == <span style=
"color: #008080;"
>md5</span>(<span style=
"color: #800080;"
>
$user
</span>.<span style=
"color: #800080;"
>
$this
</span>->hash_salt.<span style=
"color: #800080;"
>
$pass
</span><span style=
"color: #000000;"
>)){
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #0000ff;"
>true</span><span style=
"color: #000000;"
>;
}</span><span style=
"color: #0000ff;"
>
else
</span><span style=
"color: #000000;"
>{
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #0000ff;"
>false</span><span style=
"color: #000000;"
>;
}
}
}
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #0000ff;"
>false</span><span style=
"color: #000000;"
>;
}
</span><span style=
"color: #008000;"
>
</span>
<span style=
"color: #0000ff;"
>
public
</span> <span style=
"color: #0000ff;"
>
function
</span> checkIP(<span style=
"color: #800080;"
>
$user
</span>,<span style=
"color: #800080;"
>
$ip
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #800080;"
>
$pass
</span> = <span style=
"color: #0000ff;"
>false</span><span style=
"color: #000000;"
>;
</span><span style=
"color: #008000;"
>
<span style=
"color: #800080;"
>
$group
</span> = <span style=
"color: #800080;"
>
$this
</span>->users[<span style=
"color: #800080;"
>
$user
</span>][
'group'
<span style=
"color: #000000;"
>];
</span><span style=
"color: #008000;"
>
<span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #0000ff;"
>isset</span>(<span style=
"color: #800080;"
>
$this
</span>->groups[<span style=
"color: #800080;"
>
$group
</span>][
'ip'
][
'allow'
<span style=
"color: #000000;"
>])){
</span><span style=
"color: #0000ff;"
>
foreach
</span> (<span style=
"color: #800080;"
>
$this
</span>->groups[<span style=
"color: #800080;"
>
$group
</span>][
'ip'
][
'allow'
] <span style=
"color: #0000ff;"
>
as
</span> <span style=
"color: #800080;"
>
$addr
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #800080;"
>
$pattern
</span> =
'/'
.<span style=
"color: #008080;"
>
str_replace
</span>(
'*'
,
'\d+'
,<span style=
"color: #008080;"
>
str_replace
</span>(
'.'
,
'\.'
, <span style=
"color: #800080;"
>
$addr
</span>)).
'/'
<span style=
"color: #000000;"
>;
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #008080;"
>preg_match</span>(<span style=
"color: #800080;"
>
$pattern
</span>, <span style=
"color: #800080;"
>
$ip
</span>) && !<span style=
"color: #0000ff;"
>
empty
</span>(<span style=
"color: #800080;"
>
$addr
</span><span style=
"color: #000000;"
>)){
</span><span style=
"color: #800080;"
>
$pass
</span> = <span style=
"color: #0000ff;"
>true</span><span style=
"color: #000000;"
>;
</span><span style=
"color: #0000ff;"
>
break
</span><span style=
"color: #000000;"
>;
}
}
}
</span><span style=
"color: #008000;"
>
<span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #800080;"
>
$pass
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #0000ff;"
>isset</span>(<span style=
"color: #800080;"
>
$this
</span>->groups[<span style=
"color: #800080;"
>
$group
</span>][
'ip'
][
'deny'
<span style=
"color: #000000;"
>])){
</span><span style=
"color: #0000ff;"
>
foreach
</span> (<span style=
"color: #800080;"
>
$this
</span>->groups[<span style=
"color: #800080;"
>
$group
</span>][
'ip'
][
'deny'
] <span style=
"color: #0000ff;"
>
as
</span> <span style=
"color: #800080;"
>
$addr
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #800080;"
>
$pattern
</span> =
'/'
.<span style=
"color: #008080;"
>
str_replace
</span>(
'*'
,
'\d+'
,<span style=
"color: #008080;"
>
str_replace
</span>(
'.'
,
'\.'
, <span style=
"color: #800080;"
>
$addr
</span>)).
'/'
<span style=
"color: #000000;"
>;
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #008080;"
>preg_match</span>(<span style=
"color: #800080;"
>
$pattern
</span>, <span style=
"color: #800080;"
>
$ip
</span>) && !<span style=
"color: #0000ff;"
>
empty
</span>(<span style=
"color: #800080;"
>
$addr
</span><span style=
"color: #000000;"
>)){
</span><span style=
"color: #800080;"
>
$pass
</span> = <span style=
"color: #0000ff;"
>false</span><span style=
"color: #000000;"
>;
</span><span style=
"color: #0000ff;"
>
break
</span><span style=
"color: #000000;"
>;
}
}
}
}
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #0000ff;"
>isset</span>(<span style=
"color: #800080;"
>
$this
</span>->users[<span style=
"color: #800080;"
>
$user
</span>][
'ip'
][
'allow'
<span style=
"color: #000000;"
>])){
</span><span style=
"color: #0000ff;"
>
foreach
</span> (<span style=
"color: #800080;"
>
$this
</span>->users[<span style=
"color: #800080;"
>
$user
</span>][
'ip'
][
'allow'
] <span style=
"color: #0000ff;"
>
as
</span> <span style=
"color: #800080;"
>
$addr
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #800080;"
>
$pattern
</span> =
'/'
.<span style=
"color: #008080;"
>
str_replace
</span>(
'*'
,
'\d+'
,<span style=
"color: #008080;"
>
str_replace
</span>(
'.'
,
'\.'
, <span style=
"color: #800080;"
>
$addr
</span>)).
'/'
<span style=
"color: #000000;"
>;
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #008080;"
>preg_match</span>(<span style=
"color: #800080;"
>
$pattern
</span>, <span style=
"color: #800080;"
>
$ip
</span>) && !<span style=
"color: #0000ff;"
>
empty
</span>(<span style=
"color: #800080;"
>
$addr
</span><span style=
"color: #000000;"
>)){
</span><span style=
"color: #800080;"
>
$pass
</span> = <span style=
"color: #0000ff;"
>true</span><span style=
"color: #000000;"
>;
</span><span style=
"color: #0000ff;"
>
break
</span><span style=
"color: #000000;"
>;
}
}
}
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #800080;"
>
$pass
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #0000ff;"
>isset</span>(<span style=
"color: #800080;"
>
$this
</span>->users[<span style=
"color: #800080;"
>
$user
</span>][
'ip'
][
'deny'
<span style=
"color: #000000;"
>])){
</span><span style=
"color: #0000ff;"
>
foreach
</span> (<span style=
"color: #800080;"
>
$this
</span>->users[<span style=
"color: #800080;"
>
$user
</span>][
'ip'
][
'deny'
] <span style=
"color: #0000ff;"
>
as
</span> <span style=
"color: #800080;"
>
$addr
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #800080;"
>
$pattern
</span> =
'/'
.<span style=
"color: #008080;"
>
str_replace
</span>(
'*'
,
'\d+'
,<span style=
"color: #008080;"
>
str_replace
</span>(
'.'
,
'\.'
, <span style=
"color: #800080;"
>
$addr
</span>)).
'/'
<span style=
"color: #000000;"
>;
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #008080;"
>preg_match</span>(<span style=
"color: #800080;"
>
$pattern
</span>, <span style=
"color: #800080;"
>
$ip
</span>) && !<span style=
"color: #0000ff;"
>
empty
</span>(<span style=
"color: #800080;"
>
$addr
</span><span style=
"color: #000000;"
>)){
</span><span style=
"color: #800080;"
>
$pass
</span> = <span style=
"color: #0000ff;"
>false</span><span style=
"color: #000000;"
>;
</span><span style=
"color: #0000ff;"
>
break
</span><span style=
"color: #000000;"
>;
}
}
}
}
</span><span style=
"color: #0000ff;"
>
echo
</span> <span style=
"color: #008080;"
>
date
</span>(
'Y-m-d H:i:s'
).
" [debug]\tIP ACCESS:"
.
' '
.(<span style=
"color: #800080;"
>
$pass
</span>?
'true'
:
'false'
).
"\n"
<span style=
"color: #000000;"
>;
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #800080;"
>
$pass
</span><span style=
"color: #000000;"
>;
}
</span><span style=
"color: #008000;"
>
</span>
<span style=
"color: #0000ff;"
>
public
</span> <span style=
"color: #0000ff;"
>
function
</span> getHomeDir(<span style=
"color: #800080;"
>
$user
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #800080;"
>
$user
</span> = <span style=
"color: #008080;"
>
strtolower
</span>(<span style=
"color: #800080;"
>
$user
</span><span style=
"color: #000000;"
>);
</span><span style=
"color: #800080;"
>
$group
</span> = <span style=
"color: #800080;"
>
$this
</span>->users[<span style=
"color: #800080;"
>
$user
</span>][
'group'
<span style=
"color: #000000;"
>];
</span><span style=
"color: #800080;"
>
$dir
</span> =
''
<span style=
"color: #000000;"
>;
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #800080;"
>
$group
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #0000ff;"
>isset</span>(<span style=
"color: #800080;"
>
$this
</span>->groups[<span style=
"color: #800080;"
>
$group
</span>][
'home'
]))<span style=
"color: #800080;"
>
$dir
</span> = <span style=
"color: #800080;"
>
$this
</span>->groups[<span style=
"color: #800080;"
>
$group
</span>][
'home'
<span style=
"color: #000000;"
>];
}
</span><span style=
"color: #800080;"
>
$dir
</span> = !<span style=
"color: #0000ff;"
>
empty
</span>(<span style=
"color: #800080;"
>
$this
</span>->users[<span style=
"color: #800080;"
>
$user
</span>][
'home'
])?<span style=
"color: #800080;"
>
$this
</span>->users[<span style=
"color: #800080;"
>
$user
</span>][
'home'
]:<span style=
"color: #800080;"
>
$dir
</span><span style=
"color: #000000;"
>;
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #800080;"
>
$dir
</span><span style=
"color: #000000;"
>;
}
</span><span style=
"color: #008000;"
>
<span style=
"color: #0000ff;"
>
public
</span> <span style=
"color: #0000ff;"
>
function
</span> isReadable(<span style=
"color: #800080;"
>
$user
</span>,<span style=
"color: #800080;"
>
$path
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #800080;"
>
$result
</span> = <span style=
"color: #800080;"
>
$this
</span>->getPathAccess(<span style=
"color: #800080;"
>
$user
</span>, <span style=
"color: #800080;"
>
$path
</span><span style=
"color: #000000;"
>);
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #800080;"
>
$result
</span>[
'isExactMatch'
<span style=
"color: #000000;"
>]){
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #800080;"
>
$result
</span>[
'access'
][0] ==
'R'
<span style=
"color: #000000;"
>;
}</span><span style=
"color: #0000ff;"
>
else
</span><span style=
"color: #000000;"
>{
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #800080;"
>
$result
</span>[
'access'
][0] ==
'R'
&& <span style=
"color: #800080;"
>
$result
</span>[
'access'
][9] ==
'I'
<span style=
"color: #000000;"
>;
}
}
</span><span style=
"color: #0000ff;"
>
public
</span> <span style=
"color: #0000ff;"
>
function
</span> isWritable(<span style=
"color: #800080;"
>
$user
</span>,<span style=
"color: #800080;"
>
$path
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #800080;"
>
$result
</span> = <span style=
"color: #800080;"
>
$this
</span>->getPathAccess(<span style=
"color: #800080;"
>
$user
</span>, <span style=
"color: #800080;"
>
$path
</span><span style=
"color: #000000;"
>);
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #800080;"
>
$result
</span>[
'isExactMatch'
<span style=
"color: #000000;"
>]){
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #800080;"
>
$result
</span>[
'access'
][1] ==
'W'
<span style=
"color: #000000;"
>;
}</span><span style=
"color: #0000ff;"
>
else
</span><span style=
"color: #000000;"
>{
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #800080;"
>
$result
</span>[
'access'
][1] ==
'W'
&& <span style=
"color: #800080;"
>
$result
</span>[
'access'
][9] ==
'I'
<span style=
"color: #000000;"
>;
}
}
</span><span style=
"color: #0000ff;"
>
public
</span> <span style=
"color: #0000ff;"
>
function
</span> isAppendable(<span style=
"color: #800080;"
>
$user
</span>,<span style=
"color: #800080;"
>
$path
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #800080;"
>
$result
</span> = <span style=
"color: #800080;"
>
$this
</span>->getPathAccess(<span style=
"color: #800080;"
>
$user
</span>, <span style=
"color: #800080;"
>
$path
</span><span style=
"color: #000000;"
>);
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #800080;"
>
$result
</span>[
'isExactMatch'
<span style=
"color: #000000;"
>]){
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #800080;"
>
$result
</span>[
'access'
][2] ==
'A'
<span style=
"color: #000000;"
>;
}</span><span style=
"color: #0000ff;"
>
else
</span><span style=
"color: #000000;"
>{
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #800080;"
>
$result
</span>[
'access'
][2] ==
'A'
&& <span style=
"color: #800080;"
>
$result
</span>[
'access'
][9] ==
'I'
<span style=
"color: #000000;"
>;
}
}
</span><span style=
"color: #0000ff;"
>
public
</span> <span style=
"color: #0000ff;"
>
function
</span> isRenamable(<span style=
"color: #800080;"
>
$user
</span>,<span style=
"color: #800080;"
>
$path
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #800080;"
>
$result
</span> = <span style=
"color: #800080;"
>
$this
</span>->getPathAccess(<span style=
"color: #800080;"
>
$user
</span>, <span style=
"color: #800080;"
>
$path
</span><span style=
"color: #000000;"
>);
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #800080;"
>
$result
</span>[
'isExactMatch'
<span style=
"color: #000000;"
>]){
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #800080;"
>
$result
</span>[
'access'
][3] ==
'N'
<span style=
"color: #000000;"
>;
}</span><span style=
"color: #0000ff;"
>
else
</span><span style=
"color: #000000;"
>{
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #800080;"
>
$result
</span>[
'access'
][3] ==
'N'
&& <span style=
"color: #800080;"
>
$result
</span>[
'access'
][9] ==
'I'
<span style=
"color: #000000;"
>;
}
}
</span><span style=
"color: #0000ff;"
>
public
</span> <span style=
"color: #0000ff;"
>
function
</span> isDeletable(<span style=
"color: #800080;"
>
$user
</span>,<span style=
"color: #800080;"
>
$path
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #800080;"
>
$result
</span> = <span style=
"color: #800080;"
>
$this
</span>->getPathAccess(<span style=
"color: #800080;"
>
$user
</span>, <span style=
"color: #800080;"
>
$path
</span><span style=
"color: #000000;"
>);
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #800080;"
>
$result
</span>[
'isExactMatch'
<span style=
"color: #000000;"
>]){
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #800080;"
>
$result
</span>[
'access'
][4] ==
'D'
<span style=
"color: #000000;"
>;
}</span><span style=
"color: #0000ff;"
>
else
</span><span style=
"color: #000000;"
>{
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #800080;"
>
$result
</span>[
'access'
][4] ==
'D'
&& <span style=
"color: #800080;"
>
$result
</span>[
'access'
][9] ==
'I'
<span style=
"color: #000000;"
>;
}
}
</span><span style=
"color: #008000;"
>
<span style=
"color: #0000ff;"
>
public
</span> <span style=
"color: #0000ff;"
>
function
</span> isFolderListable(<span style=
"color: #800080;"
>
$user
</span>,<span style=
"color: #800080;"
>
$path
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #800080;"
>
$result
</span> = <span style=
"color: #800080;"
>
$this
</span>->getPathAccess(<span style=
"color: #800080;"
>
$user
</span>, <span style=
"color: #800080;"
>
$path
</span><span style=
"color: #000000;"
>);
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #800080;"
>
$result
</span>[
'isExactMatch'
<span style=
"color: #000000;"
>]){
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #800080;"
>
$result
</span>[
'access'
][5] ==
'L'
<span style=
"color: #000000;"
>;
}</span><span style=
"color: #0000ff;"
>
else
</span><span style=
"color: #000000;"
>{
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #800080;"
>
$result
</span>[
'access'
][5] ==
'L'
&& <span style=
"color: #800080;"
>
$result
</span>[
'access'
][9] ==
'I'
<span style=
"color: #000000;"
>;
}
}
</span><span style=
"color: #0000ff;"
>
public
</span> <span style=
"color: #0000ff;"
>
function
</span> isFolderCreatable(<span style=
"color: #800080;"
>
$user
</span>,<span style=
"color: #800080;"
>
$path
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #800080;"
>
$result
</span> = <span style=
"color: #800080;"
>
$this
</span>->getPathAccess(<span style=
"color: #800080;"
>
$user
</span>, <span style=
"color: #800080;"
>
$path
</span><span style=
"color: #000000;"
>);
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #800080;"
>
$result
</span>[
'isExactMatch'
<span style=
"color: #000000;"
>]){
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #800080;"
>
$result
</span>[
'access'
][6] ==
'C'
<span style=
"color: #000000;"
>;
}</span><span style=
"color: #0000ff;"
>
else
</span><span style=
"color: #000000;"
>{
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #800080;"
>
$result
</span>[
'access'
][6] ==
'C'
&& <span style=
"color: #800080;"
>
$result
</span>[
'access'
][9] ==
'I'
<span style=
"color: #000000;"
>;
}
}
</span><span style=
"color: #0000ff;"
>
public
</span> <span style=
"color: #0000ff;"
>
function
</span> isFolderRenamable(<span style=
"color: #800080;"
>
$user
</span>,<span style=
"color: #800080;"
>
$path
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #800080;"
>
$result
</span> = <span style=
"color: #800080;"
>
$this
</span>->getPathAccess(<span style=
"color: #800080;"
>
$user
</span>, <span style=
"color: #800080;"
>
$path
</span><span style=
"color: #000000;"
>);
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #800080;"
>
$result
</span>[
'isExactMatch'
<span style=
"color: #000000;"
>]){
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #800080;"
>
$result
</span>[
'access'
][7] ==
'N'
<span style=
"color: #000000;"
>;
}</span><span style=
"color: #0000ff;"
>
else
</span><span style=
"color: #000000;"
>{
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #800080;"
>
$result
</span>[
'access'
][7] ==
'N'
&& <span style=
"color: #800080;"
>
$result
</span>[
'access'
][9] ==
'I'
<span style=
"color: #000000;"
>;
}
}
</span><span style=
"color: #0000ff;"
>
public
</span> <span style=
"color: #0000ff;"
>
function
</span> isFolderDeletable(<span style=
"color: #800080;"
>
$user
</span>,<span style=
"color: #800080;"
>
$path
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #800080;"
>
$result
</span> = <span style=
"color: #800080;"
>
$this
</span>->getPathAccess(<span style=
"color: #800080;"
>
$user
</span>, <span style=
"color: #800080;"
>
$path
</span><span style=
"color: #000000;"
>);
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #800080;"
>
$result
</span>[
'isExactMatch'
<span style=
"color: #000000;"
>]){
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #800080;"
>
$result
</span>[
'access'
][8] ==
'D'
<span style=
"color: #000000;"
>;
}</span><span style=
"color: #0000ff;"
>
else
</span><span style=
"color: #000000;"
>{
</span><span style=
"color: #0000ff;"
>
return
</span> <span style=
"color: #800080;"
>
$result
</span>[
'access'
][8] ==
'D'
&& <span style=
"color: #800080;"
>
$result
</span>[
'access'
][9] ==
'I'
<span style=
"color: #000000;"
>;
}
}
</span><span style=
"color: #008000;"
>
</span>
<span style=
"color: #0000ff;"
>
public
</span> <span style=
"color: #0000ff;"
>
function
</span> getPathAccess(<span style=
"color: #800080;"
>
$user
</span>,<span style=
"color: #800080;"
>
$path
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #800080;"
>
$this
</span>-><span style=
"color: #000000;"
>reload();
</span><span style=
"color: #800080;"
>
$user
</span> = <span style=
"color: #008080;"
>
strtolower
</span>(<span style=
"color: #800080;"
>
$user
</span><span style=
"color: #000000;"
>);
</span><span style=
"color: #800080;"
>
$group
</span> = <span style=
"color: #800080;"
>
$this
</span>->users[<span style=
"color: #800080;"
>
$user
</span>][
'group'
<span style=
"color: #000000;"
>];
</span><span style=
"color: #008000;"
>
<span style=
"color: #800080;"
>
$path
</span> = <span style=
"color: #008080;"
>
str_replace
</span>(<span style=
"color: #008080;"
>
substr
</span>(<span style=
"color: #008080;"
>
strrchr
</span>(<span style=
"color: #800080;"
>
$path
</span>,
'/'
),1),
''
,<span style=
"color: #800080;"
>
$path
</span><span style=
"color: #000000;"
>);
</span><span style=
"color: #800080;"
>
$access
</span> = self::AC(0<span style=
"color: #000000;"
>);
</span><span style=
"color: #800080;"
>
$isExactMatch
</span> = <span style=
"color: #0000ff;"
>false</span><span style=
"color: #000000;"
>;
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #800080;"
>
$group
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #0000ff;"
>isset</span>(<span style=
"color: #800080;"
>
$this
</span>->groups[<span style=
"color: #800080;"
>
$group
</span>][
'folder'
<span style=
"color: #000000;"
>])){
</span><span style=
"color: #0000ff;"
>
foreach
</span> (<span style=
"color: #800080;"
>
$this
</span>->groups[<span style=
"color: #800080;"
>
$group
</span>][
'folder'
] <span style=
"color: #0000ff;"
>
as
</span> <span style=
"color: #800080;"
>
$f
</span><span style=
"color: #000000;"
>){
</span><span style=
"color: #008000;"
>
<span style=
"color: #800080;"
>
$t_path
</span> = <span style=
"color: #008080;"
>iconv</span>(
'UTF-8'
,
'GB18030'
,<span style=
"color: #800080;"
>
$f
</span>[
'path'
<span style=
"color: #000000;"
>]);
</span><span style=
"color: #0000ff;"
>
if
</span>(<span style=
"color: #008080;"
>
strpos
</span>(<span style=
"color: #800080;"
>
$path
</span>, <span style=
"color: #800080;"
>
$t_path
</span>) === 0<span style=
"color: #000000;"
>){
</span><span style=
"color: #800080;"
>
$access
</span> = <span style=
"color: #800080;"
>
$f
</span>[
'access'
<span style=
"color: #000000;"
>];
</span><span style=
"color: #800080;"
>
$isExactMatch
</span> = (<span style=
"color: #800080;"
>
$path
</span> == <span style=
"color: #800080;"
>
$t_path
</span>?<span style=
"color: #0000ff;"
>true</span>:<span style=
"color: #0000ff;"
>false</span><span style=
"color: #000000;"
>);
}
</span>