php include的妙用,实现路径加密

yipeiwu_com6年前PHP代码库
1、中转程序include.inc
复制代码 代码如下:

<?
include_once 'include/Base.php';
$path = '';
$url = isBase::decrypt(urlDecode($_SERVER['QUERY_STRING']));
parse_str($url); //获取通过url地址GET传递过来的变量
if(!empty($_POST['path'])){ //获取POST传递过来的变量
$path = $_POST['path'];
$path = isBase::decrypt(urlDecode($path));
}
//解析真实路径
if(empty($path)){
//header("Location: login.php");
exit;
}
if(!preg_match("/(^http:\/)|([?|&|=])/",$path)){
//跳转到实际执行文件的路径
chdir(dirname($path));
include_once basename($path);
exit;
}
?>

index.php与include.inc同目录
复制代码 代码如下:

<?
include include.inc;
?>

2、修改程序中的链接()
复制代码 代码如下:

"index.php?".encrypt("path=/test/test.php&test=123&test2=4321")

3、修改程序中的POST表单
Form都提交到为 index.php
中间加一个隐藏表单 <hidden name=path value="/test/test.php">

4、修改前端Html页面的路径
baseref=/test

5、加解密函数,朋友们自己动手写吧。

总结:
用这种方法比较繁琐,只能隐藏后台脚本的路径,前端的脚本路径仍然可以在源文件中看得到(baseref) 在地址栏上看到的地址都是index.php?xxxxxxxx

相关文章

PHP设计模式之PHP迭代器模式讲解

PHP设计模式之PHP迭代器模式讲解

迭代器有时又称光标(cursor)是程式设计的软件设计模式,可在容器物件(container,例如list或vector)上遍访的接口,设计人员无需关心容器物件的内容。 各种语言实作It...

PHP开发框架总结收藏

开发框架WACT http://wact.sourceforge.net/老牌的PHP编程框架,实现了很多企业级的开发模式Horde http://www.horde.org/horde...

Mac系统下安装PHP Xdebug

Mac系统下安装PHP Xdebug

Mac下安装PHP调试工具Xdebug 安装步骤 brew install php70 brew install php70-xdebug php -i | grep...

基于php常用函数总结(数组,字符串,时间,文件操作)

数组:【重点1】implode(分隔,arr) 把数组值数据按指定字符连接起来例如:$arr=array('1','2','3','4');$str=implode('-',$arr);...

PHP添加Xdebug扩展的方法

xdegug是一个很好的php调试扩展,安装方法也很简单,基本和其他的扩展安装方式差不多. 一、下载对应的DLL 下载地址:https://xdebug.org/download.php...