English 中文(简体)
包括档案在内的可分开查阅
原标题:disable access to included files

i 有一个问题。

i want to disable the direct access to my included files. (example header.tpl.php, footer.tpl.php, confic.inc.php, db-connect.inc.php ect.)

but first let me explain what i wanna do i want to all allow the access for my included files (index.php) and disable the files with a 404 header for direct access.

现在,我发现了一些冷却器(404头盔,404只包括)

页: 1 网址是:

define( MY_APP ,true);

我的模板文件是:

if(!defined( MY_APP )) {
header( HTTP/1.1 404 Not Found );
include( ./../error/404.php );  
die; }

你们看看看该法典有什么安全或其他问题?

best regards bernte

最佳回答

你们看看看该法典有什么安全或其他问题?

如果对服务器进行重组,以便不再执行,其源代码将可浏览。

但在此之后,你的做法是这样做的非常常见的方法。 但是error/404.php>。 可包含<代码>头盔(HTTP/1.1 404 Not Creat );行号,因此不必重复每个档案。 <代码>die; 说明。

在每个图书馆/图书馆档案中:

require( ../error/include_file.php );

include_file.php:

if(!defined( MY_APP ))
{
    header( HTTP/1.1 404 Not Found );
    include( 404.php );  
    die; 
}

你们的设计可能更好。 不要重复这一点。

问题回答

为什么不只把它拖在公众面前......html上,或者说你作为违约的......html的夹子,并包含......。 然后可以向书状提供,但公众会收到一份不实的404份档案。 我这样做是因为有密码的混淆文件,因此,没有任何公众可以查阅。

if (basename($_SERVER[ SCRIPT_FILENAME ]) == basename(__FILE__))
{
    //header("Location: index.php");
    exit("NOT ALLOWED");
}




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签