对URL加密和解密的一个函数
如果你的页面访问入口是这种类型:xxxx.php?cGFnZWlkPTEmtLS9qMjLPWFkbWluJmFjdGlvbj1pbml0X2RlZmF1bHQ=那么需要进行_GET变更的解析,下面是两个函数,一种是判断是否是BASE64加密函数,一种是对其进行解析的函数
xxxx.php?cGFnZWlkPTEmtLS9qMjLPWFkbWluJmFjdGlvbj1pbml0X2RlZmF1bHQ=这咱例子的生成是使用这样的写法:
xxxx.php?".base64_encode("ID=33&action=init")."
使用本函数,会得到ID和action的值
PHP代码
//判断GET变量是否为BASE64编码,不是很科学,需要进一步改进此函数 function isBase64() { global $_SERVER; $QUERY_STRING = $_SERVER['QUERY_STRING']; $Code = base64_decode($QUERY_STRING);//print base64_decode($Code); $Array = explode('=',$Code); if(sizeof($Array)>1) { return 1; } else return 0; } //重置_GET变量 function CheckBase64() { global $_GET,$_SERVER; $QUERY_STRING = $_SERVER['QUERY_STRING']; $QUERY_STRING_ARRAY = explode('&',$QUERY_STRING); $QUERY_STRING = $QUERY_STRING_ARRAY[0]; $QUERY_STRING = base64_decode($QUERY_STRING); $Array = explode('&',$QUERY_STRING); $_GET = array(); //形成新的_GET变量信息 $NewArray = array(); for($i=0;$i<sizeof($Array);$i++) { if($Array[$i]!="") { $ElementArray = explode('=',$Array[$i]); $_GET[(String)$ElementArray[0]] = $ElementArray[1]; $NewArray[$i] = $ElementArray[0]."=".$ElementArray[1]; } } //附加GET变量形成部分 for($i=1;$i<sizeof($QUERY_STRING_ARRAY);$i++) { if($QUERY_STRING_ARRAY[$i]!="") { $ElementArray = explode('=',$QUERY_STRING_ARRAY[$i]); $_GET[(String)$ElementArray[0]] = $ElementArray[1]; $NewArray[$i] = $ElementArray[0]."=".$ElementArray[1]; } } //形成新的_SERVER变量信息 $_SERVER['QUERY_STRING'] = join('&',$NewArray); $_SERVER['REQUEST_URI'] = $_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']; }
Copy after login
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Assassin's Creed Shadows: Seashell Riddle Solution
1 weeks ago
By DDD
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Where to find the Crane Control Keycard in Atomfall
1 weeks ago
By DDD

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics
CakePHP Tutorial
1359
52

