first
This commit is contained in:
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\Framework\Misc;
|
||||
|
||||
use Nextend\Framework\Misc\Base64\Decoder;
|
||||
use Nextend\Framework\Misc\Base64\Encoder;
|
||||
|
||||
class Base64 {
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function decode($data) {
|
||||
return Decoder::decode($data);
|
||||
}
|
||||
|
||||
public static function encode($data) {
|
||||
return Encoder::encode($data);
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\Framework\Misc\Base64;
|
||||
|
||||
class Decoder {
|
||||
|
||||
public static function decode($data) {
|
||||
|
||||
if (function_exists('base64_decode')) {
|
||||
return base64_decode($data);
|
||||
}
|
||||
|
||||
return self::decodeShim($data);
|
||||
}
|
||||
|
||||
private static function decodeShim($input) {
|
||||
$keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
||||
$i = 0;
|
||||
$output = "";
|
||||
|
||||
// remove all characters that are not A-Z, a-z, 0-9, +, /, or =
|
||||
$filter = $input;
|
||||
$input = preg_replace("[^A-Za-z0-9\+\/\=]", "", $input);
|
||||
if ($filter != $input) {
|
||||
return false;
|
||||
}
|
||||
|
||||
do {
|
||||
$enc1 = strpos($keyStr, substr($input, $i++, 1));
|
||||
$enc2 = strpos($keyStr, substr($input, $i++, 1));
|
||||
$enc3 = strpos($keyStr, substr($input, $i++, 1));
|
||||
$enc4 = strpos($keyStr, substr($input, $i++, 1));
|
||||
$chr1 = ($enc1 << 2) | ($enc2 >> 4);
|
||||
$chr2 = (($enc2 & 15) << 4) | ($enc3 >> 2);
|
||||
$chr3 = (($enc3 & 3) << 6) | $enc4;
|
||||
$output = $output . chr((int)$chr1);
|
||||
if ($enc3 != 64) {
|
||||
$output = $output . chr((int)$chr2);
|
||||
}
|
||||
if ($enc4 != 64) {
|
||||
$output = $output . chr((int)$chr3);
|
||||
}
|
||||
} while ($i < strlen($input));
|
||||
|
||||
return urldecode($output);
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Misc\Base64;
|
||||
|
||||
class Encoder {
|
||||
|
||||
public static function encode($data) {
|
||||
|
||||
if (function_exists('base64_encode')) {
|
||||
return base64_encode($data);
|
||||
}
|
||||
|
||||
return self::encodeShim($data);
|
||||
}
|
||||
|
||||
private static function encodeShim($data) {
|
||||
$b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
||||
$o1 = $o2 = $o3 = $h1 = $h2 = $h3 = $h4 = $bits = $i = 0;
|
||||
$ac = 0;
|
||||
$enc = '';
|
||||
$tmp_arr = array();
|
||||
if (!$data) {
|
||||
return $data;
|
||||
}
|
||||
do {
|
||||
// pack three octets into four hexets
|
||||
$o1 = self::charCodeAt($data, $i++);
|
||||
$o2 = self::charCodeAt($data, $i++);
|
||||
$o3 = self::charCodeAt($data, $i++);
|
||||
$bits = $o1 << 16 | $o2 << 8 | $o3;
|
||||
$h1 = $bits >> 18 & 0x3f;
|
||||
$h2 = $bits >> 12 & 0x3f;
|
||||
$h3 = $bits >> 6 & 0x3f;
|
||||
$h4 = $bits & 0x3f;
|
||||
// use hexets to index into b64, and append result to encoded string
|
||||
$tmp_arr[$ac++] = self::charAt($b64, $h1) . self::charAt($b64, $h2) . self::charAt($b64, $h3) . self::charAt($b64, $h4);
|
||||
} while ($i < strlen($data));
|
||||
$enc = implode('', $tmp_arr);
|
||||
$r = (strlen($data) % 3);
|
||||
|
||||
return ($r ? substr($enc, 0, ($r - 3)) . substr('===', $r) : $enc);
|
||||
}
|
||||
|
||||
private static function charCodeAt($data, $char) {
|
||||
return ord(substr($data, $char, 1));
|
||||
}
|
||||
|
||||
private static function charAt($data, $char) {
|
||||
return substr($data, $char, 1);
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\Framework\Misc;
|
||||
|
||||
use Nextend\Framework\Notification\Notification;
|
||||
use Nextend\Framework\Request\Request;
|
||||
|
||||
class HttpClient {
|
||||
|
||||
public static function getCacertPath() {
|
||||
return dirname(__FILE__) . '/cacert.pem';
|
||||
}
|
||||
|
||||
public static function get($url, $options = array()) {
|
||||
$options = array_merge(array('user-agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36'), $options);
|
||||
|
||||
$request = wp_remote_get($url, $options);
|
||||
if (is_wp_error($request)) {
|
||||
foreach ($request->get_error_messages() as $errorMessage) {
|
||||
Notification::error($errorMessage);
|
||||
}
|
||||
|
||||
return false;
|
||||
} else {
|
||||
$data = wp_remote_retrieve_body($request);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private static function parseHeaders(array $headers, $header = null) {
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Misc;
|
||||
|
||||
|
||||
use Nextend\Framework\Misc\StringPhp\MultiByte;
|
||||
use Nextend\Framework\Misc\StringPhp\SingleByte;
|
||||
use Nextend\Framework\Misc\StringPhp\StringInterface;
|
||||
use Nextend\Framework\Pattern\SingletonTrait;
|
||||
|
||||
class Str {
|
||||
|
||||
use SingletonTrait;
|
||||
|
||||
/**
|
||||
* @var StringInterface
|
||||
*/
|
||||
private static $engine;
|
||||
|
||||
protected function init() {
|
||||
if (function_exists('mb_strpos')) {
|
||||
self::$engine = new MultiByte();
|
||||
} else {
|
||||
self::$engine = new SingleByte();
|
||||
}
|
||||
}
|
||||
|
||||
public static function strpos($haystack, $needle, $offset = 0) {
|
||||
return self::$engine->strpos($haystack, $needle, $offset);
|
||||
}
|
||||
|
||||
public static function substr($string, $start, $length = null) {
|
||||
return self::$engine->substr($string, $start, $length);
|
||||
}
|
||||
|
||||
public static function strlen($string) {
|
||||
return self::$engine->strlen($string);
|
||||
}
|
||||
}
|
||||
|
||||
Str::getInstance();
|
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\Framework\Misc\StringPhp;
|
||||
|
||||
class MultiByte implements StringInterface {
|
||||
|
||||
public function strpos($haystack, $needle, $offset = 0) {
|
||||
return mb_strpos($haystack, $needle, $offset);
|
||||
}
|
||||
|
||||
public function substr($string, $start, $length = null) {
|
||||
return mb_substr($string, $start, $length);
|
||||
}
|
||||
|
||||
public function strlen($string) {
|
||||
return mb_strlen($string);
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\Framework\Misc\StringPhp;
|
||||
|
||||
class SingleByte implements StringInterface {
|
||||
|
||||
public function strpos($haystack, $needle, $offset = 0) {
|
||||
return strpos($haystack, $needle, $offset);
|
||||
}
|
||||
|
||||
public function substr($string, $start, $length = null) {
|
||||
return substr($string, $start, $length);
|
||||
}
|
||||
|
||||
public function strlen($string) {
|
||||
return strlen($string);
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Nextend\Framework\Misc\StringPhp;
|
||||
|
||||
|
||||
interface StringInterface {
|
||||
|
||||
public function strpos($haystack, $needle, $offset = 0);
|
||||
|
||||
public function substr($string, $start, $length = null);
|
||||
|
||||
public function strlen($string);
|
||||
}
|
@ -0,0 +1,197 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\Framework\Misc\Zip;
|
||||
|
||||
|
||||
/**
|
||||
* Zip file creation class.
|
||||
* Makes zip files.
|
||||
*
|
||||
* @access public
|
||||
* @package PhpMyAdmin
|
||||
* @see Official ZIP file format: http://www.pkware.com/support/zip-app-note
|
||||
*/
|
||||
class Creator {
|
||||
|
||||
/**
|
||||
* Whether to echo zip as it's built or return as string from -> file
|
||||
*
|
||||
* @var boolean $doWrite
|
||||
*/
|
||||
var $doWrite = false;
|
||||
|
||||
/**
|
||||
* Array to store compressed data
|
||||
*
|
||||
* @var array $datasec
|
||||
*/
|
||||
var $datasec = array();
|
||||
|
||||
/**
|
||||
* Central directory
|
||||
*
|
||||
* @var array $ctrl_dir
|
||||
*/
|
||||
var $ctrl_dir = array();
|
||||
|
||||
/**
|
||||
* End of central directory record
|
||||
*
|
||||
* @var string $eof_ctrl_dir
|
||||
*/
|
||||
var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00";
|
||||
|
||||
/**
|
||||
* Last offset position
|
||||
*
|
||||
* @var integer $old_offset
|
||||
*/
|
||||
var $old_offset = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Sets member variable this -> doWrite to true
|
||||
* - Should be called immediately after class instantiantion
|
||||
* - If set to true, then ZIP archive are echo'ed to STDOUT as each
|
||||
* file is added via this -> addfile(), and central directories are
|
||||
* echoed to STDOUT on final call to this -> file(). Also,
|
||||
* this -> file() returns an empty string so it is safe to issue a
|
||||
* "echo $zipfile;" command
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function setDoWrite() {
|
||||
$this->doWrite = true;
|
||||
} // end of the 'setDoWrite()' method
|
||||
|
||||
/**
|
||||
* Converts an Unix timestamp to a four byte DOS date and time format (date
|
||||
* in high two bytes, time in low two bytes allowing magnitude comparison).
|
||||
*
|
||||
* @param integer $unixtime the current Unix timestamp
|
||||
*
|
||||
* @return integer the current date in a four byte DOS format
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
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;
|
||||
} // end if
|
||||
|
||||
return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) | ($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1);
|
||||
} // end of the 'unix2DosTime()' method
|
||||
|
||||
|
||||
/**
|
||||
* Adds "file" to archive
|
||||
*
|
||||
* @param string $data file contents
|
||||
* @param string $name name of the file in the archive (may contains the path)
|
||||
* @param integer $time the current timestamp
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function addFile($data, $name, $time = 0) {
|
||||
$name = str_replace('\\', '/', $name);
|
||||
|
||||
$hexdtime = pack('V', $this->unix2DosTime($time));
|
||||
|
||||
$fr = "\x50\x4b\x03\x04";
|
||||
$fr .= "\x14\x00"; // ver needed to extract
|
||||
$fr .= "\x00\x00"; // gen purpose bit flag
|
||||
$fr .= "\x08\x00"; // compression method
|
||||
$fr .= $hexdtime; // last mod time and date
|
||||
|
||||
// "local file header" segment
|
||||
$unc_len = strlen($data);
|
||||
$crc = crc32($data);
|
||||
$zdata = gzcompress($data);
|
||||
$zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2); // fix crc bug
|
||||
$c_len = strlen($zdata);
|
||||
$fr .= pack('V', $crc); // crc32
|
||||
$fr .= pack('V', $c_len); // compressed filesize
|
||||
$fr .= pack('V', $unc_len); // uncompressed filesize
|
||||
$fr .= pack('v', strlen($name)); // length of filename
|
||||
$fr .= pack('v', 0); // extra field length
|
||||
$fr .= $name;
|
||||
|
||||
// "file data" segment
|
||||
$fr .= $zdata;
|
||||
|
||||
// echo this entry on the fly, ...
|
||||
if ($this->doWrite) {
|
||||
// PHPCS - The value contains zip file binary data, so nothing to escape
|
||||
echo $fr; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
} else { // ... OR add this entry to array
|
||||
$this->datasec[] = $fr;
|
||||
}
|
||||
|
||||
// now add to central directory record
|
||||
$cdrec = "\x50\x4b\x01\x02";
|
||||
$cdrec .= "\x00\x00"; // version made by
|
||||
$cdrec .= "\x14\x00"; // version needed to extract
|
||||
$cdrec .= "\x00\x00"; // gen purpose bit flag
|
||||
$cdrec .= "\x08\x00"; // compression method
|
||||
$cdrec .= $hexdtime; // last mod time & date
|
||||
$cdrec .= pack('V', $crc); // crc32
|
||||
$cdrec .= pack('V', $c_len); // compressed filesize
|
||||
$cdrec .= pack('V', $unc_len); // uncompressed filesize
|
||||
$cdrec .= pack('v', strlen($name)); // length of filename
|
||||
$cdrec .= pack('v', 0); // extra field length
|
||||
$cdrec .= pack('v', 0); // file comment length
|
||||
$cdrec .= pack('v', 0); // disk number start
|
||||
$cdrec .= pack('v', 0); // internal file attributes
|
||||
$cdrec .= pack('V', 32); // external file attributes
|
||||
// - 'archive' bit set
|
||||
|
||||
$cdrec .= pack('V', $this->old_offset); // relative offset of local header
|
||||
$this->old_offset += strlen($fr);
|
||||
|
||||
$cdrec .= $name;
|
||||
|
||||
// optional extra field, file comment goes here
|
||||
// save to central directory
|
||||
$this->ctrl_dir[] = $cdrec;
|
||||
} // end of the 'addFile()' method
|
||||
|
||||
|
||||
/**
|
||||
* Echo central dir if ->doWrite==true, else build string to return
|
||||
*
|
||||
* @return string if ->doWrite {empty string} else the ZIP file contents
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function file() {
|
||||
$ctrldir = implode('', $this->ctrl_dir);
|
||||
$header = $ctrldir . $this->eof_ctrl_dir . pack('v', sizeof($this->ctrl_dir)) . //total #of entries "on this disk"
|
||||
pack('v', sizeof($this->ctrl_dir)) . //total #of entries overall
|
||||
pack('V', strlen($ctrldir)) . //size of central dir
|
||||
pack('V', $this->old_offset) . //offset to start of central dir
|
||||
"\x00\x00"; //.zip file comment length
|
||||
|
||||
if ($this->doWrite) { // Send central directory & end ctrl dir to STDOUT
|
||||
|
||||
// PHPCS - The value is zip file binary header, so nothing to escape.
|
||||
echo $header; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
|
||||
return ""; // Return empty string
|
||||
} else { // Return entire ZIP archive as string
|
||||
$data = implode('', $this->datasec);
|
||||
|
||||
return $data . $header;
|
||||
}
|
||||
} // end of the 'file()' method
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\Framework\Misc\Zip;
|
||||
|
||||
use Nextend\Framework\Misc\Zip\Reader\Custom;
|
||||
use Nextend\Framework\Misc\Zip\Reader\ZipExtension;
|
||||
|
||||
class Reader {
|
||||
|
||||
public static function read($path) {
|
||||
|
||||
if (class_exists('ZipArchive') && strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
|
||||
$reader = new ZipExtension();
|
||||
} else {
|
||||
$reader = new Custom();
|
||||
}
|
||||
|
||||
return $reader->read($path);
|
||||
}
|
||||
}
|
@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\Framework\Misc\Zip\Reader;
|
||||
|
||||
use Nextend\Framework\Misc\Zip\ReaderInterface;
|
||||
use Nextend\Framework\Notification\Notification;
|
||||
|
||||
class Custom implements ReaderInterface {
|
||||
|
||||
private $fileHandle;
|
||||
|
||||
private $file;
|
||||
|
||||
public function read($path) {
|
||||
$this->file = $path;
|
||||
|
||||
return $this->extract();
|
||||
}
|
||||
|
||||
private function extract() {
|
||||
$extractedData = array();
|
||||
|
||||
if (!is_readable(dirname($this->file))) {
|
||||
Notification::error(sprintf(n2_('%s is not readable'), dirname($this->file)));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$this->file || !is_file($this->file)) return false;
|
||||
$filesize = sprintf('%u', filesize($this->file));
|
||||
|
||||
$this->fileHandle = fopen($this->file, 'rb');
|
||||
|
||||
$EofCentralDirData = $this->_findEOFCentralDirectoryRecord($filesize);
|
||||
if (!is_array($EofCentralDirData)) return false;
|
||||
$centralDirectoryHeaderOffset = $EofCentralDirData['centraldiroffset'];
|
||||
for ($i = 0; $i < $EofCentralDirData['totalentries']; $i++) {
|
||||
rewind($this->fileHandle);
|
||||
fseek($this->fileHandle, $centralDirectoryHeaderOffset);
|
||||
$centralDirectoryData = $this->_readCentralDirectoryData();
|
||||
$centralDirectoryHeaderOffset += 46 + $centralDirectoryData['filenamelength'] + $centralDirectoryData['extrafieldlength'] + $centralDirectoryData['commentlength'];
|
||||
if (!is_array($centralDirectoryData) || substr($centralDirectoryData['filename'], -1) == '/') continue;
|
||||
$data = $this->_readLocalFileHeaderAndData($centralDirectoryData);
|
||||
if (!$data) continue;
|
||||
|
||||
$dir = dirname($centralDirectoryData['filename']);
|
||||
$fileName = basename($centralDirectoryData['filename']);
|
||||
if ($dir != '.' && $dir != '') {
|
||||
if (!isset($extractedData[$dir])) {
|
||||
$extractedData[$dir] = array();
|
||||
}
|
||||
$extractedData[$dir][$fileName] = $data;
|
||||
} else {
|
||||
$extractedData[$fileName] = $data;
|
||||
}
|
||||
}
|
||||
fclose($this->fileHandle);
|
||||
|
||||
return $extractedData;
|
||||
}
|
||||
|
||||
private function _findEOFCentralDirectoryRecord($filesize) {
|
||||
fseek($this->fileHandle, $filesize - 22);
|
||||
$EofCentralDirSignature = unpack('Vsignature', fread($this->fileHandle, 4));
|
||||
if ($EofCentralDirSignature['signature'] != 0x06054b50) {
|
||||
$maxLength = 65535 + 22;
|
||||
$maxLength > $filesize && $maxLength = $filesize;
|
||||
fseek($this->fileHandle, $filesize - $maxLength);
|
||||
$searchPos = ftell($this->fileHandle);
|
||||
while ($searchPos < $filesize) {
|
||||
fseek($this->fileHandle, $searchPos);
|
||||
$sigData = unpack('Vsignature', fread($this->fileHandle, 4));
|
||||
if ($sigData['signature'] == 0x06054b50) {
|
||||
break;
|
||||
}
|
||||
$searchPos++;
|
||||
}
|
||||
}
|
||||
$EofCentralDirData = unpack('vdisknum/vdiskstart/vcentraldirnum/vtotalentries/Vcentraldirsize/Vcentraldiroffset/vcommentlength', fread($this->fileHandle, 18));
|
||||
|
||||
return $EofCentralDirData;
|
||||
}
|
||||
|
||||
private function _readCentralDirectoryData() {
|
||||
$centralDirectorySignature = unpack('Vsignature', fread($this->fileHandle, 4));
|
||||
if ($centralDirectorySignature['signature'] != 0x02014b50) return false;
|
||||
$centralDirectoryData = fread($this->fileHandle, 42);
|
||||
$centralDirectoryData = unpack('vmadeversion/vextractversion/vflag/vcompressmethod/vmodtime/vmoddate/Vcrc/Vcompressedsize/Vuncompressedsize/vfilenamelength/vextrafieldlength/vcommentlength/vdiskstart/vinternal/Vexternal/Vlocalheaderoffset', $centralDirectoryData);
|
||||
$centralDirectoryData['filenamelength'] && $centralDirectoryData['filename'] = fread($this->fileHandle, $centralDirectoryData['filenamelength']);
|
||||
|
||||
return $centralDirectoryData;
|
||||
}
|
||||
|
||||
private function _readLocalFileHeaderAndData($centralDirectoryData) {
|
||||
fseek($this->fileHandle, $centralDirectoryData['localheaderoffset']);
|
||||
$localFileHeaderSignature = unpack('Vsignature', fread($this->fileHandle, 4));
|
||||
if ($localFileHeaderSignature['signature'] != 0x04034b50) return false;
|
||||
$localFileHeaderData = fread($this->fileHandle, 26);
|
||||
$localFileHeaderData = unpack('vextractversion/vflag/vcompressmethod/vmodtime/vmoddate/Vcrc/Vcompressedsize/Vuncompressedsize/vfilenamelength/vextrafieldlength', $localFileHeaderData);
|
||||
$localFileHeaderData['filenamelength'] && $localFileHeaderData['filename'] = fread($this->fileHandle, $localFileHeaderData['filenamelength']);
|
||||
if (!$this->_checkLocalFileHeaderAndCentralDir($localFileHeaderData, $centralDirectoryData)) return false;
|
||||
|
||||
if ($localFileHeaderData['flag'] & 1) return false;
|
||||
$compressedData = fread($this->fileHandle, $localFileHeaderData['compressedsize']);
|
||||
$data = $this->_unCompressData($compressedData, $localFileHeaderData['compressmethod']);
|
||||
|
||||
if (crc32($data) != $localFileHeaderData['crc'] || strlen($data) != $localFileHeaderData['uncompressedsize']) return false;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function _unCompressData($data, $compressMethod) {
|
||||
if (!$compressMethod) return $data;
|
||||
switch ($compressMethod) {
|
||||
case 8 :
|
||||
$data = gzinflate($data);
|
||||
break;
|
||||
default :
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function _checkLocalFileHeaderAndCentralDir($localFileHeaderData, $centralDirectoryData) {
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\Framework\Misc\Zip\Reader;
|
||||
|
||||
use Nextend\Framework\Misc\Zip\ReaderInterface;
|
||||
use ZipArchive;
|
||||
|
||||
class ZipExtension implements ReaderInterface {
|
||||
|
||||
public function read($path) {
|
||||
|
||||
$zip = new ZipArchive();
|
||||
|
||||
if (!$zip->open($path)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$data = array();
|
||||
|
||||
for ($i = 0; $i < $zip->numFiles; $i++) {
|
||||
|
||||
$stat = $zip->statIndex($i);
|
||||
|
||||
$this->recursiveRead($data, explode('/', $stat['name']), $zip->getFromIndex($i));
|
||||
|
||||
}
|
||||
|
||||
$zip->close();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function recursiveRead(&$data, $parts, $content) {
|
||||
if (count($parts) == 1) {
|
||||
$data[$parts[0]] = $content;
|
||||
} else {
|
||||
if (!isset($data[$parts[0]])) {
|
||||
$data[$parts[0]] = array();
|
||||
}
|
||||
$this->recursiveRead($data[array_shift($parts)], $parts, $content);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\Framework\Misc\Zip;
|
||||
|
||||
|
||||
interface ReaderInterface {
|
||||
|
||||
public function read($path);
|
||||
}
|
3988
wp-content/plugins/smart-slider-3/Nextend/Framework/Misc/cacert.pem
Normal file
3988
wp-content/plugins/smart-slider-3/Nextend/Framework/Misc/cacert.pem
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user