PHP returns 执行外部命令后出现空白页
PHP returns blank page after executing external command
我的脚本:
<?php
include 'theme.php';
/*ceklogin();*/
css();
if($_POST['wget-send'])
{
$formdir=$_POST['dir'];
$formlink=$_POST['link'];
$toSave = nl2br($_POST["link"]);
$simpan = str_replace('<br />', '', $toSave);
$filelink = fopen('/root/wget/wget-download-link.txt',a);
$filedir = fopen('/root/wget/wget-dir.txt',w);
fwrite($filedir, $formdir);
fwrite($filelink, $simpan. "\n");
}
if($_POST['restart-download'])
{
exec('mv /root/wget/wget-download-link.txt.done /root/wget/wget-download-link.txt > /dev/null 2>&1 &');
exit();
}
if($_POST['stop-wget'])
{
exec('killall wget > /dev/null 2>&1 &');
exit();
}
echo "<form action=\"".$PHP_SELF."\" method=\"post\" id=\"WgetForm\">";
echo "Download directory:<br><input type=\"text\" name=\"dir\" size=\"15\" value=\"/mnt/usb/\"/><br>";
echo '<br>Download link:';
echo ("<textarea name=\"link\" rows=\"13\" cols=\"62\"></textarea><br>");
echo '
<input type="submit" onclick="DownloadRestarted()" name="restart-download" value="Restart latest download" id="RestartWget" />
<input type="submit" onclick="LinkAdded()" name="wget-send" value="Download" id="WgetID" />
<input type="submit" onclick="WgetStopped()" name="stop-wget" value="Stop Wget" id="StopWget" />
</form>
</div>';
echo <<<HTML
<script type="text/javascript">
function LinkAdded()
{
alert("Link has been sucessfully sent to wget, it'll be downloaded soon, check the wget log for the download progress");
}
function DownloadRestarted()
{
alert("Download restarted, check the wget log for the download progress");
}
function WgetStopped()
{
alert("Wget has been successfully stopped, no download is running right now");
}
</script>
HTML;
foot();
echo '
</div>
</body>
</div>
</html>';
?>
请注意exec
部分。每当我单击 Restart latest download
和 Stop Wget
它总是 returns 一个空白页。我的脚本出了什么问题?唯一 临时 解决它的方法是摆脱 exec
部分,但这也会让我无法使这些按钮工作。
从 if
个块中删除 exit()
,这就是您的页面空白的原因
exit()
终止当前脚本
我的脚本:
<?php
include 'theme.php';
/*ceklogin();*/
css();
if($_POST['wget-send'])
{
$formdir=$_POST['dir'];
$formlink=$_POST['link'];
$toSave = nl2br($_POST["link"]);
$simpan = str_replace('<br />', '', $toSave);
$filelink = fopen('/root/wget/wget-download-link.txt',a);
$filedir = fopen('/root/wget/wget-dir.txt',w);
fwrite($filedir, $formdir);
fwrite($filelink, $simpan. "\n");
}
if($_POST['restart-download'])
{
exec('mv /root/wget/wget-download-link.txt.done /root/wget/wget-download-link.txt > /dev/null 2>&1 &');
exit();
}
if($_POST['stop-wget'])
{
exec('killall wget > /dev/null 2>&1 &');
exit();
}
echo "<form action=\"".$PHP_SELF."\" method=\"post\" id=\"WgetForm\">";
echo "Download directory:<br><input type=\"text\" name=\"dir\" size=\"15\" value=\"/mnt/usb/\"/><br>";
echo '<br>Download link:';
echo ("<textarea name=\"link\" rows=\"13\" cols=\"62\"></textarea><br>");
echo '
<input type="submit" onclick="DownloadRestarted()" name="restart-download" value="Restart latest download" id="RestartWget" />
<input type="submit" onclick="LinkAdded()" name="wget-send" value="Download" id="WgetID" />
<input type="submit" onclick="WgetStopped()" name="stop-wget" value="Stop Wget" id="StopWget" />
</form>
</div>';
echo <<<HTML
<script type="text/javascript">
function LinkAdded()
{
alert("Link has been sucessfully sent to wget, it'll be downloaded soon, check the wget log for the download progress");
}
function DownloadRestarted()
{
alert("Download restarted, check the wget log for the download progress");
}
function WgetStopped()
{
alert("Wget has been successfully stopped, no download is running right now");
}
</script>
HTML;
foot();
echo '
</div>
</body>
</div>
</html>';
?>
请注意exec
部分。每当我单击 Restart latest download
和 Stop Wget
它总是 returns 一个空白页。我的脚本出了什么问题?唯一 临时 解决它的方法是摆脱 exec
部分,但这也会让我无法使这些按钮工作。
从 if
个块中删除 exit()
,这就是您的页面空白的原因
exit()
终止当前脚本