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 session安全问题分析

因此,我们主要解决的思路是效验session ID的有效性. 以下为引用的内容: 复制代码 代码如下: <?php if(!isset($_SESSION['user_agent'...

PHP中的use关键字概述

很多开源系统如osCommerce框架中,都会在其源码中找到use这个关键字,如osCommerce框架中就在index.php文件中出现了这段源码: use osCommerce\...

PHP 长文章分页函数 带使用方法,不会分割段落,翻页在底部

复制代码 代码如下: <?php function ff_page($content,$page) { global $expert_id; $PageLength = 2000;...

PHP过滤★等特殊符号的正则

复制代码 代码如下: if(preg_match("/[ '.,:;*?~`!@#$%^&+=)(<>{}]|\]|\[|\/|\\\|\"|\|/",$user)){ ec...

深入分析php中接口与抽象类的区别

接口和抽象类真的很难区分开,引文他们很相似,方法都没有定义逻辑,都是供子类是想或继承的。区分二者只要记住一句话:接口是规范,类是实现。接口的目的是定义一个规范,大家都遵守这个规范。也就是...