PHP系统命令函数使用分析
(编辑:jimmy 日期: 2024/11/19 浏览:3 次 )
复制代码 代码如下:
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;
}
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;
}
下一篇:解析PHP实现下载文件的两种方法