在 PHP 中保护 ASX 文件
我的网站上有一个仅限会员的区域,用户可以在其中登录并查看 Windows Media 流媒体内容。
我已经创建了一个 PHP 脚本来提供 ASX 文件,但是我无法使用会话信息来验证它。 我认为这是因为 WMP 发出请求而不是 php 页面。
谁能建议一种优雅的方法来保护 ASX 文件?
I have a members only area on my site where users can login and view Windows Media streaming content.
I have created a PHP script to serve the ASX file however I cannot validate this with session information. I think this is because the WMP is making the request and not a php page.
Can anyone suggest an elegant way to protect ASX files?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你可以试试这个:
You can try this:
我要做的是将 PHP 会话 ID 合并到 .asx 请求中。 通常,该标识符存储在 cookie 中,并在每次页面请求时传递给 PHP。 在这种情况下,WMP 不会一起发送 cookie,因此您无法知道请求是否经过身份验证。
当您输出 ASX 文件的下载链接时,将会话标识符附加为 GET 变量:
现在,当您在
download_asx_file.php
顶部调用session_start()
时,它会应该正确找到并加载您的会话,并允许您正常进行身份验证。注意:SID 常量的计算结果为
PHPSESSID=12345678
(或用户会话发生的任何内容)What I would do is incorporate the PHP session ID into the .asx request. Normally this identifier is stored in a cookie, and passed to PHP on each page request. In this case WMP is not sending a cookie along, so you have no way of knowing whether or not the request is authenticated or not.
When you output the download link for the ASX file, tack on the session identifier as a GET variable:
Now when you call
session_start()
at the top ofdownload_asx_file.php
it should find and load your session correctly, and allow you to authenticate as normal.Note: The SID constant is evaluated to
PHPSESSID=12345678
(or whatever that user's session happens to be)