假设我的 PHP 文件有
<?php
include 'function.php';
// CODE I CAN WRITE BELOW
...
?>
有什么方法可以查看该文件中的特定功能。假设有一个函数:
function add($a,$b) {return $a+$b;}
然后我可以将该函数打印给用户,以便他们可以在包含文件中看到它的样子吗?如果我真的可以说,看,这里是整个包含文件的源代码,而不使用show_source或类似的,那会很好,open_basedir所以我不能
完整脚本
error_reporting(0);
include 'function.php';
$dir = 'sandbox/' . sha1($_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT']) . '/';
if(!file_exists($dir)){
mkdir($dir);
}
switch ($_GET["action"] ?? "") {
case 'pwd':
echo $dir;
break;
case 'upload':
$data = $_GET["data"] ?? "";
file_put_contents("$dir" . "index.php", $data);
case 'shell':
initShellEnv($dir);
include $dir . "index.php";
break;
default:
highlight_file(__FILE__);
break;
}