找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 1309|回复: 0
打印 上一主题 下一主题

PHP系统命令函数使用分析

[复制链接]

2560

主题

2560

帖子

7622

积分

论坛元老

Rank: 8Rank: 8

积分
7622
跳转到指定楼层
楼主
发表于 2018-2-14 08:15:49 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

            [U]复制代码[/U] 代码如下:
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执行linux系统命令的常用函数使用说明
  • php中使用exec,system等函数调用系统命令的方法(不建议使用,可导致安全问题)
  • php模拟ping命令(php exec函数的使用方法)
  • PHP启动windows应用程序、执行bat批处理、执行cmd命令的方法(exec、system函数详解)
  • PHP执行linux命令常用函数汇总
  • 利用PHP命令行模式采集股票趋势信息
  • php通过执行CutyCapt命令实现网页截图的方法
  • php  redis扩展支持scan命令实现方法
  • php外部执行命令函数用法小结
            
  • 分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
    收藏收藏
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    用户反馈
    客户端