Because the ftp of your website does not directly set the attributes of files in the space, you wrote a php code to modify the index. the PHP file attribute is index. after setting the read-only attribute for the PHP file, the Trojan has no permission to append an advertisement to the end of the file.
The code below shows how to set index. php to read-only:
The code is as follows:
Function set_writeable ($ file_name)
{
If (@ chmod ($ file_name, 0555 ))
{
Echo "the read-only attribute of the index. php file has been modified ";
}
Else
{
Echo "an error occurred while modifying the read-only attribute of the index. php file. the space provider does not support this operation! ";
}
}
Set_writeable ("index. php ");
?>
Save the preceding content as setread. php and then upload it to the space. you can directly view the address in the browser to set read-only.
However, after setting this read-only attribute, you do not have the permission to delete index. php through ftp. if you need to delete or overwrite index. php, use the following code to set the read and write permissions for index. php.
The following code sets index. php to read and write data:
The code is as follows:
Function set_writeable ($ file_name)
{
If (@ chmod ($ file_name, 0777 ))
{
Echo "the index. php file read/write attribute is successfully modified ";
}
Else
{
Echo "an error occurred while modifying the index. php file read/write attribute. the space provider does not support this operation! ";
}
}
Set_writeable ("index. php ");
?>
Save the preceding content as setwrite. php. you can set the read and write permissions by accessing the browser.