Hi, i have a piece of code which use to be working but now. What I've modified is I added the encryption and decryption of a session variable. It is a piece of code to dynamically load a php file.
The problem now, is even though the decrypt work alright, outputing the correct value, but php's file_exist keep telling me it does not exist. And the require_once won't include the file as well. What can be wrong?
below is the piece of code giving me problem.
the $_SESSION['hello'] contains a value i pull from database, in this case, the word "hello".
$str = "lib/".decryptString('hello',$_SESSION['hello']).".php";
$str2 = "lib/"."hello"."php";
print "[".$str."]<br>";
print "n=" . file_exists("lib/hello.php")."<br>";
print "n=" . file_exists($str)."<br>";
print "n=" . file_exists($str2)."<br>";
if (file_exists($str)) {
$str = 'require_once "lib/'.decryptString('hello',$_SESSION['hello']).'.php";';
eval($str);
}
function encryptString($theKey, $theString) {
return base64_encode(mcrypt_encrypt(MCRYPT_BLOWFISH, $theKey, $theString, MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_EC😎, MCRYPT_RAND)));
}
function decryptString($theKey, $theString) {
return mcrypt_decrypt(MCRYPT_BLOWFISH, $theKey, base64_decode($theString), MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_EC😎, MCRYPT_RAND));
}