Jump to content

how to protect php file


purencool

Recommended Posts

Sorry I have include file that has an array that holds the following information.

 

<?php $CONNECTION = array( host=>"localhost",database=>"blah",username=>"ast",password=>"q");?>

 

What i am unsure about is how do I protect this file. I might not have to but at this point I am unsure so

I am looking for some protection.

 

thanks for your direction so far

 

some frameworks like joomla, use the following to disallow direct access to certain files.

in  the index.php they define a variable and in all other files on top they place a check if a variable is defined and else throw an error . Looks a bit like this:

in index.php

<?php
define('blablabla', 1);
include('anyfolder/anyfile.php');// include the stuff you want like a config file
?>

in any other file that may not be directly accessible

<?php
defined('blablabla') or die('no direct access'); //or maybe a redirect or other error

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.