Home Backend Development PHP Tutorial Introduction to PHP pseudo-static technology principles and implementation of breakthrough principles_PHP tutorial

Introduction to PHP pseudo-static technology principles and implementation of breakthrough principles_PHP tutorial

Jul 21, 2016 pm 03:00 PM
php introduce code principle copy accomplish technology method breakthrough static

Let’s talk about the implementation method first:
inj.php:

Copy code The code is as follows:

set_time_limit(10);
$id=$_GET["id"];
$id=str_replace(" ","%20",$id);
$ id=str_replace("=","%3D",$id);
$url="http://www.xxx.com/index.php/library/more/id/$id.html";
$ch=curl_init();
curl_setopt($ch,CURLOPT_URL,"$url");
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);//The information obtained by curl_init() when enabled Return in the form of a file stream instead of direct output
curl_setopt($ch,CURLOPT_HEADER,0);//When enabled, the header file information will be output as a data stream
$output=curl_exec($ch);
curl_close($ch);
print_r($output);
?>

Build a server with wamp and put the above inj.php into wamp/www/ , and then run http://127.0.0.1/inj.php?id=1
========================== ====
PHP pseudo-static implementation method 1 (using the function of Apache server)
1. Check whether Apache supports mod_rewrite
2. Let Apache support .htaccess
3 , Create .htaccess file
4. Rules:
RewriteEngine on
RewriteRule ([a-zA-Z]{1,})-([0-9]{1,}).html$index .php?action=$1&id=$2
([a-zA-Z]{1,})-([0-9]{1,}) is what the URL looks like
$1 is ([a The
$2 matched by -zA-Z]{1,}) is the
matched by [0-9]{1,}. For example: www.xx.com/page-18.html
The real URL is as follows:
action = page
id = 18
==============================
PHP pseudo-static implementation method two (encoding implementation)
$Php2Html_FileUrl = $_SERVER["REQUEST_URI"]
echo $Php2Html_FileUrl
Example: // localhost/php100/test.php ?id|1@action|2
Copy code The code is as follows:

$Php2Html_UrlString = str_replace("?"," ",str_replace("/","",strrchr(strrchr($Php2Html_FileUrl,"/"),"?")) ))
/*
The inner strrchr comes out: /test.php?id |1@action|2
The strrchr of the outer layer comes out: id|1@action|2
The str_replace of the inner layer comes out: remove the / sign. This example does not have it.
The str_replace of the outer layer comes out: remove? Remove the number, there is no one in this example
*/
$Php2Html_UrlQueryStrList = explode("@",$Php2Html_UrlString);
/*Convert str into an array divided by @: id|1 and action| 2*/
foreach($Php2Html_UrlQueryStrList as $Php2Html_UrlQueryStr)
{
$Php2Html_TmpArray = explode("|",$Php2Html_UrlQueryStr);
/* id => 1 and action => 2 */
$_GET[$Php2Html_TmpArray[0]] = $Php2Html_TmpArray[1];
}

================ ============
PHP pseudo-static implementation method three (encoding implementation)
Example: localhost/php100/test.php/1/2
Copy code The code is as follows:

$filename = basename($_SERVER["SCRIPT_NAME"]);
echo $_SERVER[ "SCRIPT_NAME"];
echo $filename;
if(strtolower($filename) == 'test.php'){
if(!empty($_GET[id])){
$id=intval($_GET[id]);
echo $id;
$action = intval($_GET[action]);
echo $action;
}else{
$nav=$_SERVER["REQUEST_URI"];
$script=$_SERVER["SRCIPT_NAME"];
//This sentence should be to get rid of the previous paragraph of the URL. . That leaves something like "1/2". .
$nav=ereg_replace("$script","",urldecode($nav));
echo $nav;
$vars = explode("/",$nav);
print_r ($vars);
$id=intval($vars[1]);
$action=intval($vars[2]);
}
echo $id.'&'. $action;
}

============================
PHP pseudo-static implementation method four (coding implementation)
Copy code The code is as follows:

function mod_rewrite(){
global $_GET;
$nav = $_SERVER["REQUEST_URI"];
$script_name = $_SERVER["SCRIPT_NAME"]
$nav=substr(ereg_replace("$script_name"), "",urldecode($nav)),1);
$nav=preg_replace("/^.ht(m){1}(l){0,1}$/","",$nav) ;//Remove the trailing htm or html
$vars=explode("/",$nav);
print_r($vars);
for($i=0;$i{
$_GET[$vars[$i]] = $vars[$i+1];
}
return $_GET;
}

==============================
PHP pseudo-static implementation method five ( Coding implementation)
Example: /1,100,8630.html
Copy code The code is as follows:

if (preg_match(“//(d+),(d+),(d+).html/si”,$path_info,$arr_path)){
$gid =intval($arr_path[1]); //Get the value 1
$sid =intval($arr_path[2]); //Get the value 100
$softid =intval($arr_path[3]); //Get the value 8630
}
else
echo "Path:Error!";

To summarize:
(1) Pseudo-static technology is easier to break through, and you need to construct the transfer injection page yourself.
(2) The principle of pseudo-static technology is very simple, which is to replace the original URL in the form of index.php?id=1 with other forms.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/328045.htmlTechArticleLet’s talk about the implementation method first: inj.php: Copy the code as follows: ?php set_time_limit(10); $id= $_GET["id"]; $id=str_replace(" ","%20",$id); $id=str_replace("=","%3D",$id); $url="http:/ /www...
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

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

To work on file upload we are going to use the form helper. Here, is an example for file upload.

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

CakePHP Creating Validators CakePHP Creating Validators Sep 10, 2024 pm 05:26 PM

Validator can be created by adding the following two lines in the controller.

CakePHP Logging CakePHP Logging Sep 10, 2024 pm 05:26 PM

Logging in CakePHP is a very easy task. You just have to use one function. You can log errors, exceptions, user activities, action taken by users, for any background process like cronjob. Logging data in CakePHP is easy. The log() function is provide

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

CakePHP Quick Guide CakePHP Quick Guide Sep 10, 2024 pm 05:27 PM

CakePHP is an open source MVC framework. It makes developing, deploying and maintaining applications much easier. CakePHP has a number of libraries to reduce the overload of most common tasks.

See all articles