Part one
Is it safe to store password-variables in a file called config.php and then require() or include() it to another file? Can other people include or require it from a different location using http://w...config.php and then echo out the password variable? Or can it only be required/included with a relative path? Are there other ways to reveal the password?
Part two
I'm using the password with an if/else statement to protect a few pages. First page (log in) has this structure:
<?php
require "../common/config.php";
if ($pw == $adminpw) {
// HTML to display since the given password == the one give in the config.php file.
} else {
// HTML-form where user can enter the password
}
?>
The rest of the protected pages looks like this:
<?php
if ($pw != $adminpw) {
die("Incorrect or missing pw...");
} else {
// HTML to display since the given password == the one give in the config.php file.
}
?>
Is this whole thing safe or are there ways to get the password or bypass the protection?