Home > Backend Development > PHP Tutorial > How to set the index.php file as read-only in php_PHP tutorial

How to set the index.php file as read-only in php_PHP tutorial

WBOY
Release: 2016-07-21 15:13:46
Original
1020 people have browsed it

After setting the read-only attribute for the index.php file, the Trojan will not have the permission to append advertisements to the end of your file.
Let’s look at the specific code below and set index.php to be read-only:

Copy code 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 was modified successfully";
}
else
{
echo " Failed to modify the read-only attribute of the index.php file. The space provider does not support this operation! ";
}
}
set_writeable("index.php");
?>

Save the above content as setread.php, then upload it to the space, and browse the address directly with the browser to set read-only.
However, after setting this read-only attribute, you do not have permission to delete index.php through ftp. If you need to delete or overwrite index.php, please use the following code to set the read and write permissions of index.php.
The following is the code to set index.php to read and write:

Copy the code The code is as follows:

function set_writeable($file_name)
{
if(@chmod($file_name,0777))
{
echo "Modify index.php file read and write attributes successfully";
}
else
{
echo "Failed to modify the read and write attributes of the index.php file. The space provider does not support this operation!";
}
}
set_writeable("index.php ");
?>

Save the above content as: setwrite.php, and you can set the read and write permissions by accessing it through the browser.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/326452.htmlTechArticleAfter setting the read-only attribute for the index.php file, the Trojan will not have the permission to append advertisements to the end of your file. Let's look at the specific code below and set index.php to be read-only: Copy the code The code is as follows...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template