<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Core\Util; use Chumper\Zipper\Zipper; use Illuminate\Support\Str; class ZipUtil { private static function fileTreeBuild($Kxp3W) { goto O0jAE; Uv1zF: return $wAGIP; goto vDSwd; O0jAE: $wAGIP = array(); goto TWeL1; TWeL1: foreach ($Kxp3W as $WF06r) { goto RYwUX; P2Vct: $HXuVm = count($hpcN5); goto ixhZi; RYwUX: $hpcN5 = explode('/', $WF06r['path']); goto y19Wn; ixhZi: foreach ($hpcN5 as $VXSGz => $wG3zg) { goto Pzg5V; dwuxo: foreach ($N5uHF as &$Uu3Bg) { if ($Uu3Bg['name'] === $wG3zg) { goto bzcEU; ehLnZ: break; goto JEafT; YKT3v: $EBEQS = true; goto ehLnZ; bzcEU: $N5uHF =& $Uu3Bg['_child']; goto YKT3v; JEafT: } } goto KbsHv; KbsHv: if (!$EBEQS) { goto plqah; cSD75: if (!$qq0Qk) { $N5uHF =& $N5uHF[count($N5uHF) - 1]['_child']; } goto Sh9Sz; plqah: $qq0Qk = $VXSGz === $HXuVm - 1; goto UZ8ht; UZ8ht: $mTMdG = array('name' => $wG3zg); goto rsqOl; qSebH: $N5uHF[] = $mTMdG; goto cSD75; rsqOl: if ($qq0Qk) { $mTMdG['type'] = strtolower(pathinfo($wG3zg, PATHINFO_EXTENSION)); $mTMdG['size'] = $WF06r['size']; } else { $mTMdG['_child'] = array(); } goto qSebH; Sh9Sz: } goto gOZvx; Pzg5V: $EBEQS = false; goto dwuxo; gOZvx: } goto RdH6S; y19Wn: $N5uHF =& $wAGIP; goto P2Vct; RdH6S: } goto Uv1zF; vDSwd: } private static function fileTreeFilter($wAGIP, $DMbpM, $mareA = 0) { goto iOJCJ; LLr3w: return $EGG1g; goto mL3XU; e6ald: foreach ($wAGIP as $Uu3Bg) { if (call_user_func_array($DMbpM, array($Uu3Bg, $mareA))) { goto IOvYz; IOvYz: $mTMdG = $Uu3Bg; goto aWsxm; aWsxm: if (isset($Uu3Bg['_child'])) { $mTMdG['_child'] = self::fileTreeFilter($Uu3Bg['_child'], $DMbpM, $mareA + 1); } goto cmMtt; cmMtt: $EGG1g[] = $mTMdG; goto ojm6K; ojm6K: } } goto LLr3w; iOJCJ: $EGG1g = array(); goto e6ald; mL3XU: } private static function fileTreeSortNodes(&$foy7G) { usort($foy7G, function ($LoAcY, $cTI7y) { if (isset($LoAcY['type']) && isset($cTI7y['type'])) { return strcmp($LoAcY['name'], $cTI7y['name']); } else { if (isset($LoAcY['type'])) { return 1; } else { if (isset($cTI7y['type'])) { return -1; } } } return strcmp($LoAcY['name'], $cTI7y['name']); }); return $foy7G; } private static function fileTreeSort(&$wAGIP) { goto Lq9Gb; Lq9Gb: foreach ($wAGIP as &$Uu3Bg) { if (isset($Uu3Bg['_child'])) { self::fileTreeSort($Uu3Bg['_child']); } } goto gnSU9; gnSU9: self::fileTreeSortNodes($wAGIP); goto cqGFP; cqGFP: return $wAGIP; goto RLeIH; RLeIH: } public static function fileTree($QTKvb, $vFR1v = array()) { goto zVAQr; Z3hAD: if ($vFR1v['maxDepth'] > 0) { $wAGIP = self::fileTreeFilter($wAGIP, function ($Uu3Bg, $mareA) use($vFR1v) { return $mareA < $vFR1v['maxDepth']; }); } goto krySJ; krySJ: return self::fileTreeSort($wAGIP); goto sc183; zVAQr: if (!isset($vFR1v['ignoreSystem'])) { $vFR1v['ignoreSystem'] = true; } goto vbafg; wS6d_: if ($vFR1v['ignoreHidden']) { $wAGIP = self::fileTreeFilter($wAGIP, function ($Uu3Bg, $mareA) { if (Str::startsWith($Uu3Bg['name'], '.')) { return false; } return true; }); } goto GxhYl; tB950: if ($vFR1v['ignoreSystem']) { $wAGIP = self::fileTreeFilter($wAGIP, function ($Uu3Bg, $mareA) { if (isset($Uu3Bg['type'])) { if (in_array($Uu3Bg['type'], array('DS_Store'))) { return false; } } else { if (in_array($Uu3Bg['name'], array('__MACOSX'))) { return false; } } return true; }); } goto wS6d_; SeGLc: $S895a->close(); goto Ahej7; dctKK: $S895a->getRepository()->each(function ($glP3G, $vTvKL) use(&$Kxp3W) { $Kxp3W[] = array('path' => str_replace('\\', '/', $glP3G), 'size' => $vTvKL['size']); }); goto SeGLc; O5xwH: $S895a->make($QTKvb); goto NeJe8; Ahej7: $Kxp3W = ArrayUtil::sortByKey($Kxp3W, 'path'); goto tKn_4; NeJe8: $Kxp3W = array(); goto dctKK; tKn_4: $wAGIP = self::fileTreeBuild($Kxp3W); goto tB950; vbafg: if (!isset($vFR1v['ignoreHidden'])) { $vFR1v['ignoreHidden'] = true; } goto wKzeE; fkZGh: $S895a = new Zipper(); goto O5xwH; Xbvas: if (!isset($vFR1v['detectRoot'])) { $vFR1v['detectRoot'] = false; } goto fkZGh; GxhYl: if ($vFR1v['detectRoot']) { goto BuGKq; XC9D_: for (;;) { if (count($Bhs5s) > 1) { break; } if (!isset($Bhs5s[0]['_child'])) { break; } $Bhs5s = $Bhs5s[0]['_child']; } goto cMmam; BuGKq: $Bhs5s = $wAGIP; goto XC9D_; cMmam: $wAGIP = $Bhs5s; goto Jbt7B; Jbt7B: } goto Z3hAD; wKzeE: if (!isset($vFR1v['maxDepth'])) { $vFR1v['maxDepth'] = 0; } goto Xbvas; sc183: } }