How does php set read-only permissions for the index. php file?

Source: Internet
Author: User
Welcome to the Linux community forum and interact with 2 million technical staff. Recently, many spaces have been suspended. Although it is not harmful, I only add an iframe advertisement code to the back of your homepage to increase traffic, however, this will cause some browsers to bring up warnings, which makes the webmaster very painful. My ftp does not have the property to directly set files in the space,

Welcome to the Linux community forum, and interact with 2 million technical staff> recently, many spaces have been infected. Although it is not harmful, I only add an iframe advertisement code to the back of your homepage, increase the traffic, but this will make some browsers pop up a warning, so it makes the webmaster very painful. My ftp does not have the property to directly set files in the space,

Welcome to the Linux community forum and interact with 2 million technicians>

Recently, many spaces have been infected with Trojans. Although it is not harmful, you only need to append an iframe advertisement code to the back of your homepage to increase the traffic. However, this will prompt warnings to Some browsers, so it makes the webmaster very painful.

My ftp does not directly set the attributes of files in the space, so I wrote a php code to modify the index. PHP file attributes are shared with you. After setting the read-only attribute, the trojan will not have the permission to append iframe ads to the end of the file.

Set the index. php read-only code:

Function set_writeable ($ file_name)

{

If (@ chmod ($ file_name, 0555 ))

{

Echo "the read-only attribute of the index. php file has been modified successfully ";

}

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.

SET index. php to read and write code:

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 and upload it to the space. Then, you can set the Read and Write settings by browsing the address in the browser.

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.