PHP including other php file issues

I have a webpage in which there are many php files, and I was wondering how can I prevent users from viewing php individually?

+3
source share
5 answers

One popular way is to define a constant in the included file:

define ("INCLUDE_OK", true);

and then check each sub-include:

if (!defined("INCLUDE_OK")) die ("This file can't be executed directly");

Alternatively, as @mikerobi says in his remote answer, save the included files in a folder outside the web root.

+6
source

PHP , . , /var/www/html, /var/www/include . , , PHP, , ../include/myinclude.php.

+2

- :

<?php
    define('AAA',true);
?>

veyr:

<?php
    defined('AAA') or die('Access denied.');
?>

htaccess.

+1

php , , , php , php (, include.php). include.inc , - , . , ..

+1

. , . , .

..

//On the main page
$check = true;
include(../someFile.php);

//someFile.php
if($check == true){
  //Display your content
}
0

Source: https://habr.com/ru/post/1768990/


All Articles