在PHP中,shell_exec和proc_open有其他替代方法吗? [英] Are there any alternatives to shell_exec and proc_open in PHP?

查看:311
本文介绍了在PHP中,shell_exec和proc_open有其他替代方法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎我不能在共享服务器上使用shell_execproc_open.

It seems like I can't use shell_exec or proc_open on my shared server.

当我尝试使用它时收到的消息是:

The message I get when I try to use it is:

警告:出于安全原因,第4行的/home/georgee/public_html/admin/email.php中已禁用shell_exec()

Warning: shell_exec() has been disabled for security reasons in /home/georgee/public_html/admin/email.php on line 4

这些功能还有其他选择吗?

Are there any alternatives to these functions?

推荐答案

我假设您要使用它进行异步处理,例如在单独的进程中发送电子邮件(因此,email.php中的错误).如果是这样,请检查是否已启用 cURL .您可以通过HTTP请求触发脚本,而无需等待响应.

I assume you want to use this for async processing, for instance sending eMails in a separate process (hence the error in email.php). If so, please check if cURL is enabled. You can trigger your scripts through an HTTP request without waiting for the response.

进一步阅读:

  • Asynchronous/parallel HTTP requests using PHP multi_curl
  • How to use curl_multi() without blocking
  • How do I make an asynchronous GET request in PHP?

如果cURL不可用,请尝试与非阻塞流一起使用:

If cURL is not available, try to use with non-blocking streams:

  • http://de.php.net/manual/en/function.stream-set-blocking.php
  • http://thethoughtlab.blogspot.com/2007/04/non-blocking-io-with-php-mio.html

为提高安全性,请考虑使用自定义的API密钥,因此,未经许可,无法触发电子邮件发送URL.将此作为GET或POST传递.您还可以验证请求是否来自同一服务器.

For added security, consider using a self-defined API key, so the eMail sending URL cannot be triggered without permission. Pass this in as a GET or POST. You could also validate if the request came from the same server.

这篇关于在PHP中,shell_exec和proc_open有其他替代方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆