How can I prevent php templates from being stolen?

Source: Internet
Author: User
& Nbsp; in many programs, php (as the mainstream development language) files are used as templates, in this way, php (as the mainstream development language) can be parsed directly in the template, but the disadvantage is that you can directly access this file to display all the code, this has brought great convenience to those who steal templates. SyntaxHighlighter uses php (as the mainstream development language) files in many programs as templates, in this way, php (as the mainstream development language) can be parsed directly in the template, but the disadvantage is that you can directly access this file to display all the code, this makes template stealing extremely convenient.

In fact, it is very easy to prevent php (as the mainstream development language) template files from being directly accessed. you only need to add the following code in the file header:

The following is a code snippet:
$ Thisfilename = "templates/geek/index. php (as the mainstream development language)"; // The relative path to which the template file is directly accessed
If (strtolower (substr ($ _ SERVER ["php (as the mainstream development language) _ SELF"],-Len ($ thisfilename) ==$ thisfilename) exit;
?>

The code looks very simple. The principle of the two statements is also very simple:

Determine the access path of the client. if the direct path of the template file is included, exit the execution.

Generally, we place all template files under a special directory, and this path does not need to be accessed directly.

Hope to help friends.

 

Never-ending technical exchanges

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.