I am making a website that will generate a config.php when
install.php is run, it contains the database name, user, and
password in an array.
Lets say some one knows the name of this array, and writes a
script that will include the http://www.somesite.com/config.php
and will then print out the contents of the array.
Is this possible? If so how would I stop this, I made a script to
play around with it to try stopping that and this is what I came up
with.
$config = array(
"db_host"=>"localhost",
"db_name"=>"someDB",
"db_usr"=>"someUser",
"db_pwd"=>"somePass",
"websiteurl"=>"http://www.somesite.com/Website/"
);
if(substr($config[websiteurl], strlen($config[websiteurl]) - 1, 1) != "/")
$config[websiteurl] = $config[websiteurl] . "/";
$currentURL = $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
$url = $config[websiteurl] . "index.php";
if(substr($currentURL, 0, 4) == "www.")
$currentURL = substr_replace($currentURL, '', 0, 4);
if(substr($url, 0, 4) == "www.")
$url = substr_replace($url, '', 0, 4);
if($currentURL != $url)
{
unset($config);
exit;
}
But as you can see if someone sets there hosts for
www.somesite.com to point to there own server and make
there own script called index.php which includes config.php then
if they can include files remotely then they will have the database
user used by the website.