The implementation principle of defined (' In_ecs ') in Ecshop

Source: Internet
Author: User
In PHP often see the following code if (!defined (' in_ecs ')) {die (' Hacking attempt '); The reasons and principles of the implementation are as follows: There are some in Ecshop. PHP pages are not required to be accessed directly by the user via a URL, such as/includes/init.php, which does not require direct access and accesses your URL through the URLs/includes/ Init.php is meaningless, so we add define (' In_ecs ', true) to the PHP that can be directly asked, such as the following code in index.php, set in_ at the beginning The value of ECS is true before it is loaded init.php so the value of in_ecs in the init.php file is true, the introduction of cls_mysql.php can also be introduced, because the value of in_ecs at this time is also true define (' In_ecs '    , true); Require (DirName (__file__).  '/includes/init.php '); This results in direct access to the page with the IF (!defined (' in_ecs ')) {die (' Hacking attempt ') in PHP that cannot be accessed directly;} In this way, the direct access to the init.php will not hacking attempt from the page to the purpose of forbidden access, and other pages in the call init.php is normal to do this is also a design idea to prevent other files from not calling or prevent the foreground directly access files.

The implementation principle of defined (' In_ecs ') in Ecshop

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.