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

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

WBOY
Release: 2016-07-25 09:05:41
Original
992 people have browsed it
  1. function set_writeable($file_name)
  2. {
  3. if(@chmod($file_name,0555))
  4. {
  5. echo "Modify read-only attribute of index.php file successfully";
  6. }
  7. else
  8. {
  9. echo "Failed to modify the read-only attribute of the index.php file. The space provider does not support this operation!";
  10. }
  11. }
  12. set_writeable("index.php");
  13. ?>
Copy code

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 will 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 up index.php to read and write:

  1. function set_writeable($file_name)
  2. {
  3. if(@chmod($file_name,0777))
  4. {
  5. echo "Modify index.php file read and write attributes successfully";
  6. }
  7. else
  8. {
  9. echo "Failed to modify the read and write attributes of the index.php file. The space provider does not support this operation!";
  10. }
  11. }
  12. set_writeable("index.php");
  13. ?>
Copy code

Save the above content as: setwrite.php, and access it through the browser to set the read and write permissions.



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