How can I prevent php templates from being stolen directly ?. Php (as the mainstream development language) files are used as templates in many programs. in this way, php (as the mainstream development language) can be parsed directly in the template, however, php (as the mainstream development language) files are also used as templates in many programs. in this way, php (as the mainstream development language) can be parsed directly in the template, however, the disadvantage is that you can directly access this file to display all the code, which makes template stealing very 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
Pipeline (as the mainstream development language) file as a template, this can be directly parsed in the template php (as the mainstream development language) language, but also...