<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Data; use Illuminate\Support\Facades\Storage; use Illuminate\Support\Str; use League\Flysystem\FilesystemInterface; use ModStart\Core\Util\EnvUtil; use ModStart\Core\Util\FileUtil; use ModStart\Core\Util\PathUtil; use ModStart\Data\Repository\DatabaseDataRepository; abstract class AbstractDataStorage { const DATA_TEMP = 'data_temp'; const DATA = 'data'; const DATA_CHUNK = 'data_chunk'; const PATTERN_DATA_TEMP = '/^data_temp\\/([a-z_]+)\\/([a-zA-Z0-9]{32}\\.[a-z0-9]*)$/'; const PATTERN_DATA = '/^data\\/([a-z_]+)\\/(\\d+\\/\\d+\\/\\d+\\/\\d+_[a-zA-Z0-9]{4}_\\d+\\.[a-z0-9]+)$/'; const PATTERN_DATA_STRING = '/data\\/([a-z_]+)\\/(\\d+\\/\\d+\\/\\d+\\/\\d+_[a-zA-Z0-9]{4}_\\d+\\.[a-z0-9]+)/'; protected $localStorage; protected $repository; protected $option = array(); public function __construct($LEG8W) { goto Qr8GZ; ma32g: $this->localStorage = Storage::disk('data'); goto QBo13; QBo13: $this->repository = new DatabaseDataRepository(); goto CYATH; QHhUK: config(array('filesystems.disks.data' => array('driver' => 'local', 'root' => base_path('public/')))); goto ma32g; Qr8GZ: $this->option = $LEG8W; goto QHhUK; CYATH: } public function driverName() { return null; } public abstract function init(); public abstract function has($aYJAK); public abstract function move($L_a53, $RP3dD); public abstract function delete($aYJAK); public function softDelete($aYJAK) { return $this->move($aYJAK, self::DATA . '/_trash/' . date('Ymd_H') . '/' . $aYJAK); } public abstract function put($aYJAK, $Afv_G); public abstract function get($aYJAK); public abstract function size($aYJAK); public abstract function multiPartInit($qHLCM); public abstract function multiPartUpload($qHLCM); public function updateDriverDomain($CnWtd) { return $CnWtd; } public function domain() { return ''; } public function domainInternal() { return ''; } public function getDriverFullPath($VF_G6) { goto ZW5vh; liq7f: if (PathUtil::isPublicNetPath($VF_G6)) { return $VF_G6; } goto LuFNr; LuFNr: return config('data.baseUrl', '/') . $VF_G6; goto Pn5ef; ZW5vh: if (empty($VF_G6)) { return $VF_G6; } goto cFB6G; cFB6G: if (Str::startsWith($VF_G6, '//')) { $VF_G6 = 'http:' . $VF_G6; } else { $VF_G6 = ltrim($VF_G6, '/'); } goto liq7f; Pn5ef: } public function getDriverFullPathInternal($VF_G6) { goto WmLSO; K2Y7b: if (PathUtil::isPublicNetPath($VF_G6)) { return $VF_G6; } goto Jg9te; Jg9te: return config('data.baseUrl', '/') . $VF_G6; goto EvExg; WmLSO: if (Str::startsWith($VF_G6, '//')) { $VF_G6 = 'http:' . $VF_G6; } else { $VF_G6 = ltrim($VF_G6, '/'); } goto K2Y7b; EvExg: } public function repository() { return $this->repository; } protected function multiPartInitToken(array $qHLCM) { goto L413a; JGIPX: return $aYJAK; goto sOKnY; a_Ins: ksort($aYJAK, SORT_STRING); goto dqZL0; uJS1Q: $aYJAK = $qHLCM['file']; goto a_Ins; pPsWX: $QkgUP['uploadMaxSize'] = EnvUtil::env('uploadMaxSize'); goto aWakF; dqZL0: $QkgUP = array(); goto pPsWX; aWakF: $rCzZc = md5(serialize($aYJAK) . ':' . serialize($QkgUP)); goto q4vVD; L413a: $ZRqAm = $qHLCM['category']; goto uJS1Q; y1yF7: if (file_exists($oJLhT)) { $aYJAK = (include $oJLhT); } else { goto mkHX5; hV5h1: $aYJAK['path'] = strtolower(Str::random(32)) . '.' . $lSZGu; goto oW_Gl; mkHX5: $aYJAK['chunkUploaded'] = 0; goto aKzW1; oW_Gl: $aYJAK['fullPath'] = self::DATA_TEMP . '/' . $ZRqAm . '/' . $aYJAK['path']; goto KjDWM; aKzW1: $aYJAK['hash'] = $rCzZc; goto DeHNh; DeHNh: $lSZGu = FileUtil::extension($aYJAK['name']); goto hV5h1; KjDWM: } goto JGIPX; q4vVD: $oJLhT = self::DATA_CHUNK . '/token/' . $rCzZc . '.php'; goto y1yF7; sOKnY: } protected function uploadChunkTokenAndDeleteToken($EerLH) { goto QMLOk; QMLOk: $rCzZc = $EerLH['hash']; goto xarhH; xarhH: $oJLhT = self::DATA_CHUNK . '/token/' . $rCzZc . '.php'; goto Ps_JC; Ps_JC: $this->localStorage->delete($oJLhT); goto flh1E; flh1E: } protected function uploadChunkTokenAndUpdateToken($EerLH) { goto RloE3; lZuet: $oJLhT = self::DATA_CHUNK . '/token/' . $rCzZc . '.php'; goto wPNDE; RloE3: $rCzZc = $EerLH['hash']; goto lZuet; wPNDE: $this->localStorage->put($oJLhT, '<' . '?php return ' . var_export($EerLH, true) . ';'); goto cs_0N; cs_0N: } }