Im working on a simple encryption app that able to encrypt php files inside a folder using this class. My problem is after decryption, all the files are not working like the variables and the functions. When I tried to echo a variable its says undefined.
Hope you help me.
Thanks.
SAMPLE CODE
<?php
require_once('func.php');
require_once('encryptionClass.php');
if(is_array($_FILES)){
$encrypted_dir = "encrypted_files/";
$saveFiles = browseDir($encrypted_dir);
foreach($saveFiles as $file){ // iterate files
if(is_file($encrypted_dir.$file))
unlink($encrypted_dir.$file); // delete file
}
foreach($_FILES['files']['name'] as $key => $value){
$file = explode(".", $_FILES['files']['name'][$key]);
$ext = array("php");
if(in_array($file[1], $ext)){
$file_name = $file[0].'.'.$file[1];
$source = $_FILES['files']['tmp_name'][$key];
$location = $encrypted_dir.$file_name;
$code = file_get_contents($source);
$encryption_key = 'CKXH2U9RPY3EFD70TLS1ZG4N8WQBOVI6AMJ5';
$cryptor = new Cryptor($encryption_key);
$crypted_token = $cryptor->encrypt($code);
$f = fopen($location, 'w');
// DATA BEING SAVE TO THE ENCRYPTED FILE
$data = '
<?php
require_once("../encryptionClass.php");
$encryption_key = "CKXH2U9RPY3EFD70TLS1ZG4N8WQBOVI6AMJ5";
$cryptor = new Cryptor($encryption_key);
$crypted_token = "'. $crypted_token .'";
$token = $cryptor->decrypt($crypted_token);
echo $token;
?>
<!-- trying to display the value of variable from $token -->
<p><?php echo $name; ?></p>
';
fwrite($f, $data);
fclose($f);
unset($code);
}
}
}
?>