Home >Backend Development >PHP Problem >How to prohibit copying code on php web pages

How to prohibit copying code on php web pages

藏色散人
藏色散人Original
2021-10-14 09:22:562681browse

How to prohibit copying code on PHP web pages: 1. Log in to the PHP virtual host; 2. Enter the root directory of the website; 3. Find the index.php file under the corresponding template; 4. Pass "document.onselectstart=new Function(...)" code implementation can prohibit copying.

How to prohibit copying code on php web pages

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

How to prohibit copying code on the php webpage?

Code that prohibits others from copying the web content of my website:

Many webmasters hope that their original articles will not be stolen by others. Because every article is written with hard work, today a webmaster’s article was copied and published by others. So how should we prevent others from copying the content of your website?

There are many methods, but the more practical ones are to prohibit copying web page content and prohibit right-clicking. Below, the editor of Wuyou Host will teach you how to modify it:

First log in to your php virtual host through your ftp tool, and enter the templates folder under the root directory of your website (for Wuyou Host users, enter the public_html directory) , enter the template corresponding to your website, and find the index.php file under the corresponding template;

Since the template formats of different files are different, index.php is only a common format, and the specifics will depend on the program.

Just put the following code in the 93f0f5c25f18dab9d176bd4f6de5d30e9c3bca370b5104690d9ef395f2c5f8d1 of the index.php file

<script language="javascript"> document.oncontextmenu=new Function("event.returnValue=false;");
//屏蔽右键 
document.onselectstart=new Function("event.returnValue=false;");
//屏蔽鼠标拖动 
</script> 
<!--禁止另存为--> 
<noscript>
<iframe>
</iframe>
</noscript>

This way no one can steal the content of your website!

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to prohibit copying code on php web pages. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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