<?php
highlight_file(__FILE__);
class emmm //后端类 {
public static function checkFile(&$page) //page接收 但是没有对其赋值 & 符号表示可以在函数内部对page进行修改赋值 {
$whitelist = ["source"=>"source.php","hint"=>"hint.php"]; //定义数组
if (! isset($page) || !is_string($page)) { // 第一个 waf page 必须是是字符串 并且不为空
echo "you can't see it";
return false;}
if (in_array($page, $whitelist)) {
return true; // 第二个waf page 在 whitelist数组中}
$_page = mb_substr( //page 就是 ? 之前的
$page,
0,
mb_strpos($page . '?', '?') //切片 但是切之前 把$page 拼接一个 ? 这个的目的就是为了快速找到这个 page
// 函数strpos :例如这个 strpops(word.?,?) 返回的就是 ? 所在的位置
//mb_substr() 切片 把$page 进行切片 切的是是从 0 到 ?所在位数的位置 的位置
// 这个组合的意思 page=php? 进行切片就是 php);
if (in_array($_page, $whitelist)) {
return true;}
$_page = urldecode($page); //下面这个就是重复的了 进行url解密(web自带所以这个不是waf)
$_page = mb_substr(
$_page,
0,
mb_strpos($_page . '?', '?') // 意思就是 _page 必须加上 ? 然后前面的内容需要是在白名单中);
if (in_array($_page, $whitelist)) {
return true;}
echo "you can't see it";
return false;}}// 所以这个函数的作用就是 对我们输入的page 进行添加 一个 ? 然后获取前面的内容进行白名单判断
if (! empty($_REQUEST['file']) //file的参数不能空&& is_string($_REQUEST['file']) // file是字符串&& emmm::checkFile($_REQUEST['file'])// 上面的意思) {
include $_REQUEST['file']; //文件包含 但是上面有条件
exit;} else {
echo "<br><img src=\"https://i.loli.net/2018/11/01/5bdb0d93dc794.jpg\" />";}
?>