Define constants How to prevent the address bar from accessing background files directly

Source: Internet
Author: User
Define constants How to prevent the address bar from accessing background files directly
Define is not cross-page, but recently read an open source PHP project It is this: such as a.php: direct define (' In_tm ', TRUE);
b.php Direct if (!defined (' In_tm '))
{
Exit (' Access Denied ');
}
if ($_session["admin"]!= "Silence")
{
Include template (' login.htm ');
Exit
}。。。。。
It's totally useless. Include included! But when I do this simulation, define is not cross-page! Does it have any settings that make ' In_tm ' work on another page?
Similar to Discuz to prevent the address bar directly access to the background file is how to implement it?

------Solution--------------------
If you can confirm that no files have been explicitly embedded before judging.
So he's using the Auto_prepend_file in php.ini.

In fact, as long as the project can run, you only need to print out the results of get_included_files to know what files are embedded

------Solution--------------------
This must be useful include included, just you don't see
------Solution--------------------
But when I do this simulation, define is not cross-page! Does it have any settings that make ' In_tm ' work on another page?

b.php
if (!defined (' In_tm '))
{
Exit (' Access Denied ');
}

a.php
Define (' In_tm ', TRUE);
Include ' b.php ';

Access b.php must be completed by accessing a.php, otherwise access Denied
  • Related Article

    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.