I want to be able to chmod files online. I used: chmod ("test.html", 0755); but it gives me this error:
Warning: chmod(): Operation not permitted in /home/uname/public_html/chmod.php on line 2
Do you know why this is happening?
Thanks
Moderator: General Moderators
Files and folders permissions are stored for three user ids: owner, group and "anybody" - hence the three numbers eg 755.Mr. Tech wrote:What do you mean "rights"? The folder it is in needs to be writeable?
Code: Select all
chown -r <newowner> <directory>Code: Select all
<?php
include("config.php");
include("func.php");
if (!isset($man_user)||(isset($man_user)&&$man_user==1))
{
include("login.php");
exit;
}
$ThisFileName = basename(__FILE__);
$root = str_replace($ThisFileName,"",__FILE__);
$root = dirname($root);
/////////////////////
//write = 2
//execute = 1
//read = 4
if (@$perms=="Set")
{
$own_exec=0;$own_read=0;$own_write=0;
$grp_exec=0;$grp_read=0;$grp_write=0;
$other_exec=0;$other_read=0;$other_write=0;
/////////////////////////////////////////////////////////////////////////////////
if (@$set_own_exec==true){$own_exec=1;}
if (@$set_own_read==true){$own_read=4;}
if (@$set_own_write==true){$own_write=2;}
/////////////////
if (@$set_grp_exec==true){$grp_exec=1;}
if (@$set_grp_read==true){$grp_read=4;}
if (@$set_grp_write==true){$grp_write=2;}
/////////////////
if (@$set_other_exec==true){$other_exec=1;}
if (@$set_other_read==true){$other_read=4;}
if (@$set_other_write==true){$other_write=2;}
/////////////////
$set_own=$own_exec+$own_read+$own_write;
$set_grp=$grp_exec+$grp_read+$grp_write;
$set_other=$other_exec+$other_read+$other_write;
////////////////////////////////////////////////////////////////////////////////
$chmode=$set_own.$set_grp.$set_other;
$buf=intval($chmode/100);
$buf1=$chmode-$buf*100;
$buf_0=intval($buf1/10);
$buf2=$buf1-$buf_0*10;
////////////////////////////////////////////////////////////////////////////////
if ($file_array[0]!="")
{
$dec1=1*32768+0*4096+0*512+$buf*64+$buf_0*8+$buf2*1;
for($a=0;$a<count($file_array);$a++)
{
if (@$folder)
{
$file=$root."/".$folder."/".basename($file_array[$a]);
}
else
{
$file=$root."/".$file_array[$a];
}
chmod($file, $dec1);
}
}
/////////////////////////////////
if ($folder_array[0]!="")
{
$dec2=4*4096+0*512+$buf*64+$buf_0*8+$buf2*1;
$dec1=1*32768+0*4096+0*512+$buf*64+$buf_0*8+$buf2*1;
for($a=0;$a<count($folder_array);$a++)
{
if (@$folder)
{
$file=$root."/".$folder."/".$folder_array[$a];
}
else
{
$file=$root."/".$folder_array[$a];
}
chmod($file, $dec2);
}
}
/////////////////////////////////
}
ret_head($folder);
?>