解析/link?url=

时间:2025-04-05 08:54:09
<?php $url = "/link?url=nS2MGJqjJ4zBBpC8yDF8xDh8vibi1lVeE7gGr9UONBu"; $info = parse_url($url); $fp = fsockopen($info['host'], 80,$errno, $errstr, 30); fputs($fp,"GET {$info['path']}?{$info['query']} HTTP/1.1\r\n"); fputs($fp, "Host: {$info['host']}\r\n"); fputs($fp, "Connection: close\r\n\r\n"); $rewrite = ''; while(!feof($fp)) { $line = fgets($fp); if($line != "\r\n" ) { if(strpos($line,'Location:') !== false) { $rewrite = str_replace(array("\r","\n","Location: "),'',$line); } }else { break; } } var_dump($rewrite); //结果显示:string(22) "/" ?>