php问题eval/html/php

标签 php html eval encryption

我一直在写一个 php/html 页面编码器/解码器...我知道它已经存在但它是一个大学项目所以继续 XDDD

我对我想保护的页面进行编码让我们假设使用 base64_encode 并且当我收到任何页面的请求时我有一个加载器读取编码页面,解密它并使用 eval 执行它。当我尝试解密和执行混合的 php/html 页面时,真正的问题出现了。显然 eval 不能执行 html 代码,所以我的问题是我是否真的对拆分执行 php 代码的页面并打印 html 感到疯狂?另外,如果我包含一个编码的 php 或 php/html 页面,我真的必须重用这里的方法吗?

我希望有人能真正帮助我,因为我距离截止日期还有一周,此时我无法更改项目。

chris 这里是函数和第一个调用 $param[0] 的文件名

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]);

$param[0] 文件在这里

<?php
 session_start();
 $_SESSION['title']='Home';
 MyInclude("header.php");
?>

<body>
    sono il body <?php echo APP_PATH; ?>
</body>

<?
echo "boss";
 MyInclude("footer.php");
?>

有什么想法吗???或者你需要一些其他代码???让我知道T_T

迈克

最佳答案

您可以 eval() 一个包含混合 html 和 php 的字符串,只要包含标签即可。

http://php.net/manual/en/function.eval.php

关于php问题eval/html/php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7181366/

相关文章:

php - 如何在 api 平台中通过过滤实现自定义项获取端点?

php - MySQL PHP 查询问题

php - Ajax 调用中的 500 内部服务器错误 (Laravel)

Javascript 在刷新之前不运行

javascript - Jquery Enable button on click div 并显示相应的元素

string - 阻止 R 解析 ~ 到用户的主目录

javascript - 这是 Chrome 错误还是我对 "use strict"和 eval 的使用无效?

php - 无法 Eloquent 自动创建连接

html - 仅CSS的砌体布局

php - 评估 PHP 和安全措施,创建 PHP 演示编辑器