微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

PHP系统命令函数使用分析

<div class="codetitle"><a style="CURSOR: pointer" data="71444" class="copybut" id="copybut71444" onclick="doCopy('code71444')"> 代码如下:

<div class="codebody" id="code71444">
function execute($cmd) {
$res = '';
if ($cmd) {
if(function_exists('system')) {
@ob_start();
@system($cmd);
$res = @ob_get_contents();
@ob_end_clean();
} elseif(function_exists('passthru')) {
@ob_start();
@passthru($cmd);
$res = @ob_get_contents();
@ob_end_clean();
} elseif(function_exists('shell_exec')) {
$res = @shell_exec($cmd);
} elseif(function_exists('exec')) {
@exec($cmd,$res);
$res = join(“\n",$res);
} elseif(@is_resource($f = @popen($cmd,"r"))) {
$res = '';
while(!@feof($f)) {
$res .= @fread($f,1024);
}
@pclose($f);
}
}
return $res;
}

原文地址:https://www.jb51.cc/php/25860.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐