Summary of how XSS detects php to obtain the url file name currently accessed
Recommended functions:
First, PHP obtains the URL of the current page: dedecms also uses this
The Code is as follows:
// Obtain the current Script URL function GetCurUrl () {if (! Empty ($ _ SERVER ["REQUEST_URI"]) {$ scriptName = $ _ SERVER ["REQUEST_URI"]; $ nowurl = $ scriptName ;} else {$ scriptName = $ _ SERVER ["PHP_SELF"]; if (empty ($ _ SERVER ["QUERY_STRING"]) {$ nowurl = $ scriptName ;} else {$ nowurl = $ scriptName. "? ". $ _ SERVER [" QUERY_STRING "] ;}} return $ nowurl ;}
Method 1:
The Code is as follows:
<?php$url=$HTTP_SERVER_VARS['REQUEST_URI'];echo(str_replace('/','',$url));?>
Method 2:
The Code is as follows:
<? Php
$ Url = $ _ SERVER ['php _ SELF '];
$ Filename = substr ($ url, strrpos ($ url, '/') + 1 );
Echo $ filename;
?>
Method 3:
The Code is as follows:
<?php$url = $_SERVER['PHP_SELF'];$arr = explode( '/' , $url );$filename= $arr[count($arr)-1];echo $filename;?>
Method 4:
The Code is as follows:
<?php$url = $_SERVER['PHP_SELF'];$filename = end(explode('/',$url));echo $filename;?>