简体   繁体   English

我可以使用header()传递查询字符串参数吗?

[英]Can I use header() to pass query string parameters?

I'm using XAMPP on Windows. 我在Windows上使用XAMPP。

I've congigured Apache to redirect all requests to a controller.php file. 我已经将Apache配置为将所有请求重定向到controller.php文件。 The controller logs all requests to the database before any other processing takes place and it does a few other things too including checking permission to access the files involved. 在执行任何其他处理之前,控制器会将所有请求记录到数据库,并且还会执行其他一些操作,包括检查访问所涉及文件的权限。

Most requests map to a file which I then serve with appropriate headers and a readfile. 大多数请求映射到一个文件,然后我使用适当的头文件和一个读取文件。 For example: 例如:

header ( 'Content-Type: text/css' );
header ( 'Content-Length: ' . filesize ( $file ) );
readfile ( $file );

My problem is that if the URL contains a query string I don't know how to pass that to the file. 我的问题是,如果URL包含查询字符串,我不知道如何将其传递给该文件。

http:///myswf.swf?q1=test maps to C:\\SWF\\myswf.swf http:///myswf.swf?q1 =测试映射到C:\\ SWF \\ myswf.swf

header ( 'Content-Type: applicaton/x-shockwave-flash' );
header ( 'Content-Length: ' . filesize ( $file ) );
readfile ( $file );

fails to pass the q1 parameter to the SWF. 无法将q1参数传递给SWF。

I can't tinker with the SWF. 我无法修补SWF。

How should I call the SWF and successfully pass the parameters from within PHP? 我应该如何调用SWF并成功从PHP中传递参数?

The SWF file is not executed on the server. SWF文件未在服务器上执行。 As such, you cannot "pass" anything to the SWF file. 因此,您无法将任何内容“传递” SWF文件中。 The file is simply downloaded by the client and then run in the browser, which is were it will get the URL parameters. 该文件只是由客户端下载,然后在浏览器中运行,它将获取URL参数。 From the client side, this looks like this (simplified): 从客户端来看,这看起来像这样(简化):

As long as the process works like this on the client side, it doesn't matter how exactly you serve the file. 只要该过程在客户端这样工作,就无论您如何准确地提供文件。

As far as i understand it, you cannot use GET parameters in a filename, so readfile(filename.php?q=123); 据我所知,你不能在文件名中使用GET参数,所以readfile(filename.php?q = 123); will NOT pass parameters, 不会传递参数,

In fact i think the only way you could do this is with a remote file_get_contents(); 事实上,我认为你可以做到这一点的唯一方法是使用远程file_get_contents(); suchas: 如:

echo file_get_contents("http://domain.com/file.swf?params");

In that case, the webserver at domain.com will handle the parameters to the swf file, this means though that the SWF file will need to be publically accessible, but no-one will figure where it is located, so you could have a folder like domain.com/asfqwasc213412sad/file.swf to obscure it 在这种情况下,domain.com上的web服务器将处理swf文件的参数,这意味着SWF文件需要公开访问,但没有人会知道它所在的位置,所以你可以有一个文件夹比如domain.com/asfqwasc213412sad/file.swf来模糊它

Im not too experienced on how SWF handles GET params, so this is all assumption in terms of serving the SWF file with the params 我对SWF如何处理GET参数没有太多经验,所以这就是用params服务SWF文件的所有假设

Update Thank you @deceze for this info, this probably won't work on SWF files because of the way the params work 更新感谢@deceze获取此信息,由于params的工作方式,这可能不适用于SWF文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM