PHP系统命令函数使用分析

yipeiwu_com6年前PHP代码库
复制代码 代码如下:

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隐藏IP地址后两位显示为星号的方法

本文实例讲述了php隐藏IP地址后两位显示为星号的方法。分享给大家供大家参考。具体实现方法如下: 我们在很多的公共网站中都会有碰到显示用户的IP时后面几个IP段显示为星号了,这样很好的保...

php实现的debug log日志操作类实例

本文实例讲述了php实现的debug log日志操作类。分享给大家供大家参考,具体如下: <?php class Tool { public static func...

zend Framework中的Layout(模块化得布局)详解

1.首先修改application配置文件resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"指定布局文件的...

php获取远程图片的两种 CURL方式和sockets方式获取远程图片

方式1:sockets 复制代码 代码如下: $a = "/zb_users/upload/202003/hyvt1amvtlt.jpg"; $local = 'socket1.gif'...

php垃圾代码优化操作代码

公司有几个网站搭在美国的虚拟主机上,服务器上的mysql服务差不多每一天都会突然不知什么时候挂掉,然后过一会又恢复了,怀疑是超出cpu的使用限制而被自动结束了,但是实际上该服务器上的流量...