Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the method that php forbids access?

2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "what is the method of php forbidden access", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's take you to learn "what is the method of php forbidden access"!

php Forbidden Access Method: 1. Write "if( $_SERVER ['HTTP_REFERER']== "" ){...} in the head of the php file. "Code;2. Define an identification variable in the program;3. Get the variable in config.php.

Operating environment: Windows 7 system, PHP7.1 version, DELL G3 computer

How does php disable access methods?

php Ways to disable direct access to.php files from browser input addresses:

The specific implementation method is as follows:

Generally speaking, for some important files we do not want users to directly enter the address to access, we need to make some settings. Here is a summary of some php methods that prohibit accessing.PHP files directly from the browser input address, which is very practical.

For example, www.jb51.net/xx.php is a file I don't want anyone to access directly from the browser.

However, if you cannot access https://www.jb51.net/xx.php from any website, you cannot jump to another address if you establish a connection with this machine.

1. Write the following code at the head of the xx.php file

The code is as follows:

$fromurl="https://www.jb51.net/"; //jump to this address. if( $_SERVER['HTTP_REFERER'] == "" ){header("Location:".$ fromurl); exit;}

This way, we only need to simply falsify the source. For this, we can also do the following:

2. Define an identification variable in your program

The code is as follows:

define('IN_SYS', TRUE);

3. Get this variable in config.php

The code is as follows:

if(! defined ('IN_SYS')) { exit ('Forbidden access'); }

The latter two methods are ones we encounter in many cms.

At this point, I believe that we have a deeper understanding of "php prohibited access method", may wish to actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report