<?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($yFteQ) { goto VeTQe; JZ1AD: $this->repository = new DatabaseDataRepository(); goto tm1SX; grPyy: config(array('filesystems.disks.data' => array('driver' => 'local', 'root' => base_path('public/')))); goto xA26b; VeTQe: $this->option = $yFteQ; goto grPyy; xA26b: $this->localStorage = Storage::disk('data'); goto JZ1AD; tm1SX: } public function driverName() { return null; } public abstract function init(); public abstract function has($yHf3t); public abstract function move($KUvwa, $QCEgc); public abstract function delete($yHf3t); public function softDelete($yHf3t) { return $this->move($yHf3t, self::DATA . '/_trash/' . date('Ymd_H') . '/' . $yHf3t); } public abstract function put($yHf3t, $cgjRu); public abstract function get($yHf3t); public abstract function size($yHf3t); public abstract function multiPartInit($oK4I3); public abstract function multiPartUpload($oK4I3); public function updateDriverDomain($SjN8A) { return $SjN8A; } public function domain() { return ''; } public function domainInternal() { return ''; } public function getDriverFullPath($LclBr) { goto h7QVK; OdDQ6: if (Str::startsWith($LclBr, '//')) { $LclBr = 'http:' . $LclBr; } else { $LclBr = ltrim($LclBr, '/'); } goto RDEo2; h7QVK: if (empty($LclBr)) { return $LclBr; } goto OdDQ6; RDEo2: if (PathUtil::isPublicNetPath($LclBr)) { return $LclBr; } goto JuvJ5; JuvJ5: return config('data.baseUrl', '/') . $LclBr; goto wz95p; wz95p: } public function getDriverFullPathInternal($LclBr) { goto CUX0B; CUX0B: if (Str::startsWith($LclBr, '//')) { $LclBr = 'http:' . $LclBr; } else { $LclBr = ltrim($LclBr, '/'); } goto xqjQM; xqjQM: if (PathUtil::isPublicNetPath($LclBr)) { return $LclBr; } goto Dbu1o; Dbu1o: return config('data.baseUrl', '/') . $LclBr; goto Js0FF; Js0FF: } public function repository() { return $this->repository; } protected function multiPartInitToken(array $oK4I3) { goto aaG1P; m2rpN: if (file_exists($qNxT5)) { $yHf3t = (include $qNxT5); } else { goto ZvJN_; T2dyk: $yHf3t['hash'] = $a3qUm; goto TKFfE; Wpz_9: $yHf3t['path'] = strtolower(Str::random(32)) . '.' . $NAKt6; goto oNfwU; TKFfE: $NAKt6 = FileUtil::extension($yHf3t['name']); goto Wpz_9; ZvJN_: $yHf3t['chunkUploaded'] = 0; goto T2dyk; oNfwU: $yHf3t['fullPath'] = self::DATA_TEMP . '/' . $W8QzG . '/' . $yHf3t['path']; goto Uj4XV; Uj4XV: } goto VbrC8; VbrC8: return $yHf3t; goto hdZUB; ZVk6B: ksort($yHf3t, SORT_STRING); goto ytoVd; JMhJz: $a3qUm = md5(serialize($yHf3t) . ':' . serialize($EQtOk)); goto t6mDv; aaG1P: $W8QzG = $oK4I3['category']; goto KMYsV; KMYsV: $yHf3t = $oK4I3['file']; goto ZVk6B; wTK54: $EQtOk['uploadMaxSize'] = EnvUtil::env('uploadMaxSize'); goto JMhJz; t6mDv: $qNxT5 = self::DATA_CHUNK . '/token/' . $a3qUm . '.php'; goto m2rpN; ytoVd: $EQtOk = array(); goto wTK54; hdZUB: } protected function uploadChunkTokenAndDeleteToken($R0P9s) { goto V3WSb; PZylh: $qNxT5 = self::DATA_CHUNK . '/token/' . $a3qUm . '.php'; goto P17DQ; V3WSb: $a3qUm = $R0P9s['hash']; goto PZylh; P17DQ: $this->localStorage->delete($qNxT5); goto PoRtt; PoRtt: } protected function uploadChunkTokenAndUpdateToken($R0P9s) { goto tSpQP; tSpQP: $a3qUm = $R0P9s['hash']; goto yz6Mm; yz6Mm: $qNxT5 = self::DATA_CHUNK . '/token/' . $a3qUm . '.php'; goto Xe_zg; Xe_zg: $this->localStorage->put($qNxT5, '<' . '?php return ' . var_export($R0P9s, true) . ';'); goto h7loP; h7loP: } }