[英]Can php run code on server side without user request?
Server 1 Pings/Request URL http://website.com/page.php?code=NeedThat 服务器1 Pings /请求URL http://website.com/page.php?code=NeedThat
Server 2 "page.php" grabs "NeedThat" and execute img src or JavaScript on server side 服务器2“ page.php”获取“ NeedThat”并在服务器端执行img src或JavaScript
Image Code on page.php page.php上的图像代码
Thanks a lot forr the help got it! 非常感谢forr的帮助!
Executing gotit.php
is easy. 执行
gotit.php
很容易。 You just use curl or (if allowed) file_get_contents to download the image src. 您只需使用curl或(如果允许)file_get_contents即可下载图像src。 For the JavaScript, you need to figure out what network requests that causes, then do them manually.
对于JavaScript,您需要找出引起网络请求的原因,然后手动执行。
EDIT: If gotit needs to keep outputting that image, then you can have page.php parse the HTML, then do its own request to the resulting src (which will be website.com/sale.php...). 编辑:如果getit需要继续输出该图像,则可以让page.php解析HTML,然后对生成的src进行自己的请求(将是website.com/sale.php ...)。
If you just need to run another script, file_get_contents can be filled out with the correct parameters and have the return value saved as such: 如果只需要运行另一个脚本,则可以使用正确的参数填写file_get_contents,并将返回值保存为:
$result = file_get_contents('http://location.com/page.php?code=' . $code);
More advanced solutions can be crafter with something like curl, but for a simple request, file_get_contents should suffice. 可以使用curl之类的东西来设计更高级的解决方案,但是对于一个简单的请求,file_get_contents应该足够了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.