search
Homephp教程PHP源码对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(&#39;=&#39;,$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(&#39;=&#39;,$QUERY_STRING_ARRAY[$i]);
            $_GET[(String)$ElementArray[0]] = $ElementArray[1];
            $NewArray[$i] = $ElementArray[0]."=".$ElementArray[1];
        }
    }
    //形成新的_SERVER变量信息
    $_SERVER[&#39;QUERY_STRING&#39;] = join(&#39;&&#39;,$NewArray);
    $_SERVER[&#39;REQUEST_URI&#39;] = $_SERVER[&#39;PHP_SELF&#39;]."?".$_SERVER[&#39;QUERY_STRING&#39;];
}
Statement
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

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

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 agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.