【发布时间】:2023-03-17 20:50:02
【问题描述】:
如何使用 PHP 轻松找到当前 url 和该 URL 中的所有 GET 参数?我想跟踪哪些 GET 参数被传递到当前 url。如果有人可以给我 PHP 命令来执行此操作,那就太好了!
谢谢!
这是我的代码:
<?php
$filedir = './';
$filename = $_GET['file'];
//security check
if(strpos(realpath($filename), PATH_TO_VALID_MP3s) !== 0) { die('bad path!'); }
$path = $filedir . $filename;
if (!is_file($path) OR connection_status() != 0)
{
exit();
}
ob_end_clean();
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Expires: '. gmdate('D, d M Y H:i:s', mktime(date('H')+2, date('i'), date('s'), date('m'), date('d'), date('Y'))).' GMT');
header('Last-Modified: '. gmdate('D, d M Y H:i:s').' GMT');
header('Content-Type: application/octet-stream');
header('Content-Length: '. @filesize($path));
header('Content-Disposition: attachment; filename="'. $filename .'"');
header('Content-Transfer-Encoding: binary');
if ($file = @fopen($path, 'rb'))
{
while (!feof($file) AND connection_status() == 0)
{
echo fread($file, 1024 * 8);
}
flush();
}
@fclose($file);
?>
【问题讨论】:
-
$passedGetParams = $_GET;? -
顺便说一句,许多
how to get current page url in php问题可能重复。