PHP Setup index.php file as read-only method

Source: Internet
Author: User
Because the ftp of their own website does not have the property of directly setting the file on the space, then wrote a section of PHP code to modify the Index.php file property

After you set the read-only property for the index.php file, the Trojan does not have permission to append ads to the end of the file.
Below we look at the specific code, set index.php Read only:

The code is as follows:

<?phpfunction set_writeable ($file _name) {if (@chmod ($file _name,0555) {  echo "modified index.php file read-only attribute succeeded";} else{  echo "Modify index.php file read-only property failed, the space quotient does not support this operation!" ";}} Set_writeable ("index.php");? >

Save the above content to setread.php, then upload to the space, direct browser to browse the address can be set to read-only.
However, after you set this read-only property, you do not have permission to delete index.php yourself via FTP, or if you need to remove or overwrite index.php, use the following code to set index.php read and Write permissions.
Here is the code to set index.php read and write:

The code is as follows:

<?phpfunction set_writeable ($file _name) {if (@chmod ($file _name,0777) {  echo "modified index.php file read-write property succeeded";} else{  echo "Modify index.php file read-write properties failed, the space quotient does not support this operation!" ";}} Set_writeable ("index.php");? >

Save the above: setwrite.php, access to the browser can be set to read and write permissions.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.