-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchmod.php
More file actions
35 lines (35 loc) · 1.5 KB
/
chmod.php
File metadata and controls
35 lines (35 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
$name=(isset($_REQUEST['name']))?$_REQUEST['name']:'';
$mode=(isset($_REQUEST['mode']))?$_REQUEST['mode']:'';
$attr=(isset($_REQUEST['attr']))?$_REQUEST['attr']:'';
if ($attr!='') {
if (preg_match('/admin|root|rw/i',$attr)) {
if ((is_dir($name))&&(!is_link($name))) {
exec('chmod -vR "'.octdec($mode).'" "'.$name.'"');
} else {
chmod($name,octdec($mode));
}
} else {
if ((is_dir($name))&&(!is_link($name))) {
if (str_starts_with(basename($name),$attr.'_')) {
exec('chmod -vR "'.octdec($mode).'" "'.$name.'"');
} elseif (str_starts_with($name,$attr.'_files/')) {
exec('chmod -vR "'.octdec($mode).'" "'.$name.'"');
} elseif (str_starts_with($name,'./'.$attr.'_files/')) {
exec('chmod -vR "'.octdec($mode).'" "'.$name.'"');
} elseif (str_starts_with(basename($name),'_')) {
exec('chmod -vR "'.octdec($mode).'" "'.$name.'"'); {
}
} else {
if (str_starts_with(basename($name),$attr.'_')) {
chmod($name,octdec($mode));
} elseif (str_starts_with($name,$attr.'_files/')) {
chmod($name,octdec($mode));
} elseif (str_starts_with($name,'./'.$attr.'_files/')) {
chmod($name,octdec($mode));
} elseif (str_starts_with(basename($name),'_')) {
chmod($name,octdec($mode));
}
}
}
}