当前位置: 移动技术网 > IT编程>开发语言>PHP > php include的妙用,实现路径加密

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

2019年05月11日  | 移动技术网IT编程  | 我要评论
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

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网