Whether PHP can control the reading of a folder

Source: Internet
Author: User
Tags echo display
can PHP actually control the reading of a folder?
The Web server, operating system has Windows Server 2003 and CentOS Linux 5.2 two kinds. Inside there is a folder pay, which has a large pile of pure static. htm files. For example:

Http://www.example.com/pay/abc.htm
Http://www.example.com/pay/efg.htm
Http://www.example.com/pay/hij.htm
Http://www.example.com/pay/klm.htm



Only premium paid users can open and read these pages. When other users try to open, they will automatically jump to the Login.htm Web page and ask the user to log in.

Can PHP actually implement this seemingly simple function? I've wanted to use PHP and cookies or sessions before, but they're static. htm files that PHP can't control directly.


Do you want to convert all the files into PHP files and then insert the code in each PHP file to determine if the browser has a cookie:
PHP Code
  
   if (!isset ($_cookie[' check ')) {header (' Location:login.htm ');}? >



But this is too much work, and the Pay folder contains thousands of pure static. htm files.


is there a better way?



------Solution--------------------
Estimate pseudo-static, or dynamic page, if the dynamic is good, including a public page validation
If it's static, you can make it into a template page. There are a variety of ways to load a static page
URLs do not think about what to write, folder that is to set permissions
------Solution--------------------
Do you send the URL directly to the client? This idea is wrong.

Regardless of the type, files that need to be protected cannot send the original URL to the client, which is the basic principle

Use fopen to read the echo display again
  • 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.