-2

How would I easily find the current url and all of the GET paramaters in that URL with PHP? I want to track which GET paramaters are being passed to the current url. If somebody could give me the PHP command to do this, then that would be great! Thanks! Here is my code:

<?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);
?>
4

2 回答 2

1

$_SERVER$_GET数组是你的朋友;)

于 2013-05-13T21:14:40.940 回答
0

已经存在一个包含所有 GET 变量的全局变量。

$_GET

http://php.net/manual/en/reserved.variables.get.php

另一种选择是$_REQUEST全局。

http://php.net/manual/en/reserved.variables.request.php

默认情况下包含 $_GET、$_POST 和 $_COOKIE 内容的关联数组。

于 2013-05-13T21:15:32.777 回答