<?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($Ur1_b) { goto fzm5V; bPLzC: $this->repository = new DatabaseDataRepository(); goto Jq9E8; AFX8R: $this->localStorage = Storage::disk('data'); goto bPLzC; RMI3X: config(array('filesystems.disks.data' => array('driver' => 'local', 'root' => base_path('public/')))); goto AFX8R; fzm5V: $this->option = $Ur1_b; goto RMI3X; Jq9E8: } public function driverName() { return null; } public abstract function init(); public abstract function has($sCmIC); public abstract function move($FtI8I, $hjIzo); public abstract function delete($sCmIC); public function softDelete($sCmIC) { return $this->move($sCmIC, self::DATA . '/_trash/' . date('Ymd_H') . '/' . $sCmIC); } public abstract function put($sCmIC, $LTC5O); public abstract function get($sCmIC); public abstract function size($sCmIC); public abstract function multiPartInit($pFM9U); public abstract function multiPartUpload($pFM9U); public function updateDriverDomain($Sj05q) { return $Sj05q; } public function domain() { return ''; } public function domainInternal() { return ''; } public function getDriverFullPath($adFNb) { goto V58n4; V58n4: if (empty($adFNb)) { return $adFNb; } goto s96yJ; s96yJ: if (Str::startsWith($adFNb, '//')) { $adFNb = 'http:' . $adFNb; } else { $adFNb = ltrim($adFNb, '/'); } goto VyKtK; VyKtK: if (PathUtil::isPublicNetPath($adFNb)) { return $adFNb; } goto HM2zV; HM2zV: return config('data.baseUrl', '/') . $adFNb; goto eA48B; eA48B: } public function getDriverFullPathInternal($adFNb) { goto CmgG0; ibIFF: return config('data.baseUrl', '/') . $adFNb; goto ejuxP; CmgG0: if (Str::startsWith($adFNb, '//')) { $adFNb = 'http:' . $adFNb; } else { $adFNb = ltrim($adFNb, '/'); } goto UfN8o; UfN8o: if (PathUtil::isPublicNetPath($adFNb)) { return $adFNb; } goto ibIFF; ejuxP: } public function repository() { return $this->repository; } protected function multiPartInitToken(array $pFM9U) { goto dvsSF; kYqWJ: return $sCmIC; goto vncW9; c7jf0: $JdNV5 = array(); goto gA1hy; g9xpx: if (file_exists($rcRe8)) { $sCmIC = (include $rcRe8); } else { goto S8Ph0; LHMtu: $sCmIC['hash'] = $fEpHF; goto vI0dB; vI0dB: $gRGJg = FileUtil::extension($sCmIC['name']); goto BOZcB; GD5_Z: $sCmIC['fullPath'] = self::DATA_TEMP . '/' . $FVUIh . '/' . $sCmIC['path']; goto sQvTE; BOZcB: $sCmIC['path'] = strtolower(Str::random(32)) . '.' . $gRGJg; goto GD5_Z; S8Ph0: $sCmIC['chunkUploaded'] = 0; goto LHMtu; sQvTE: } goto kYqWJ; dvsSF: $FVUIh = $pFM9U['category']; goto p9yVd; p9yVd: $sCmIC = $pFM9U['file']; goto PGotX; moXYa: $fEpHF = md5(serialize($sCmIC) . ':' . serialize($JdNV5)); goto a6M2c; gA1hy: $JdNV5['uploadMaxSize'] = EnvUtil::env('uploadMaxSize'); goto moXYa; PGotX: ksort($sCmIC, SORT_STRING); goto c7jf0; a6M2c: $rcRe8 = self::DATA_CHUNK . '/token/' . $fEpHF . '.php'; goto g9xpx; vncW9: } protected function uploadChunkTokenAndDeleteToken($K6b7B) { goto BWzeq; WHt_y: $this->localStorage->delete($rcRe8); goto QOJWR; BWzeq: $fEpHF = $K6b7B['hash']; goto dx_Mc; dx_Mc: $rcRe8 = self::DATA_CHUNK . '/token/' . $fEpHF . '.php'; goto WHt_y; QOJWR: } protected function uploadChunkTokenAndUpdateToken($K6b7B) { goto hZLtE; mqLYo: $rcRe8 = self::DATA_CHUNK . '/token/' . $fEpHF . '.php'; goto E48ZO; E48ZO: $this->localStorage->put($rcRe8, '<' . '?php return ' . var_export($K6b7B, true) . ';'); goto TZIiA; hZLtE: $fEpHF = $K6b7B['hash']; goto mqLYo; TZIiA: } }