PHP Exec()或System()导致500错误


PHP Exec() or System() Causes 500 Error

我认为这是一个相当简单的问题。这是我的测试代码(很明显,当我真正写这篇文章时,我会添加安全预防措施)-

<?php
    if (isset($_POST['url']) && !empty($_POST['url'])) {
        system('wget --no-parent --timestamping --convert-links --page-requisites --no-directories --no-host-directories -erobots=off '.$_POST['url']);
} else {
    echo '<form method="post"><input type="url" name="url"><input type="submit"></form>';
}
?>

PHP或Apache2中是否有一些模块需要启用/安装才能正常工作?如果有帮助的话,我会通过浏览器访问这个页面。即使还没有调用命令(if语句的这一部分没有运行),如果我注释掉system()或exec()行,500错误也会消失,这种情况也会发生。

您的代码对我有效,请检查是否为您禁用了system函数。您可以使用ini_get('disable_functions')来检查它是否已禁用。

您提供的代码中存在错误;最后你把点放错了地方:

 '.$_POST['url']);

而不是

 .'$_POST['url']);