I’ve been writing a php/html page encoder/decoder… I know it already exists but it’s a university project so go on XDDD
I encode the pages that I want to protect let’s say hypothetically with base64_encode and when I receive a request of any pages I have a loader that reads the coded page, decrypts it and with eval executes it. The real problems arise when I try to decrypt and execute a mixed php/html page. Obviously eval can’t execute html code so my question is do I really become crazy about splitting the page executing the php code and print the html? And also if I include an encoded php or php/html page do I really have to reuse the method up here?
I hope someone can really help me because i have a week left before the deadline and I can’t change the project at this point.
chris here the function and the fisrt calling in $param[0] i’ve got the filename called
function MyInclude($filename)
{
// create the temp file
$temp_filename = "tmp.php";
$handle = fopen($temp_filename , 'w+');
if (!$handle)
die('Error creating temp file');
// write the decrypted data, close the handle
$tmp=file_get_contents($filename);
$data=MCrypt_Decode($tmp,'PFL_EPU_V100_mia');
fwrite($handle,$data );
fclose($handle);
// start output buffering to contain any output the script creates
ob_start();
try {
include($temp_filename);
} catch (Exception $e) {
die('There was an error in the encrypted file, cannot process');
}
// get the output, clear the buffer
$output = ob_get_contents();
ob_end_clean();
//destroy the temp file
unlink($temp_filename);
// now you can output the buffer, if desired:
echo $output;
}
MyInclude($param[0]);
the $param[0] file here
<?php
session_start();
$_SESSION['title']='Home';
MyInclude("header.php");
?>
<body>
sono il body <?php echo APP_PATH; ?>
</body>
<?
echo "boss";
MyInclude("footer.php");
?>
any idea about it??? or you need some other code??? let me know T_T
Mike
Is it possible to decrypt the page, write it to a file, then
includeit? That would let the PHP interpreter do what it does best – interpret PHP documents. That will include HTML/PHP combinations without relying oneval.The outline of that would be:
Function references
fopen: https://www.php.net/manual/en/function.fopen.php
fwrite: https://www.php.net/manual/en/function.fwrite.php
fclose: https://www.php.net/manual/en/function.fclose.php
ob_start: https://www.php.net/manual/en/function.ob-start.php
ob_get_contents: https://www.php.net/manual/en/function.ob-get-contents.php
ob_end_clean: https://www.php.net/manual/en/function.ob-end-clean.php
unlink: http://www.php.net/manual/en/function.unlink.php