<?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($WwRq4) { goto NTkGX; kgFIt: $this->localStorage = Storage::disk('data'); goto R3nZa; NTkGX: $this->option = $WwRq4; goto lop_a; R3nZa: $this->repository = new DatabaseDataRepository(); goto XgkhO; lop_a: config(array('filesystems.disks.data' => array('driver' => 'local', 'root' => base_path('public/')))); goto kgFIt; XgkhO: } public function driverName() { return null; } public abstract function init(); public abstract function has($qsQD8); public abstract function move($S7Ck8, $ygeGW); public abstract function delete($qsQD8); public function softDelete($qsQD8) { return $this->move($qsQD8, self::DATA . '/_trash/' . date('Ymd_H') . '/' . $qsQD8); } public abstract function put($qsQD8, $rFmqf); public abstract function get($qsQD8); public abstract function size($qsQD8); public abstract function multiPartInit($Kp99R); public abstract function multiPartUpload($Kp99R); public function updateDriverDomain($EdQjV) { return $EdQjV; } public function domain() { return ''; } public function domainInternal() { return ''; } public function getDriverFullPath($tGXA6) { goto R69nZ; jitEa: if (Str::startsWith($tGXA6, '//')) { $tGXA6 = 'http:' . $tGXA6; } else { $tGXA6 = ltrim($tGXA6, '/'); } goto zaUNS; zaUNS: if (PathUtil::isPublicNetPath($tGXA6)) { return $tGXA6; } goto jYoor; jYoor: return config('data.baseUrl', '/') . $tGXA6; goto D3vXk; R69nZ: if (empty($tGXA6)) { return $tGXA6; } goto jitEa; D3vXk: } public function getDriverFullPathInternal($tGXA6) { goto rJNpp; sqCRl: if (PathUtil::isPublicNetPath($tGXA6)) { return $tGXA6; } goto VJuub; VJuub: return config('data.baseUrl', '/') . $tGXA6; goto UdbDO; rJNpp: if (Str::startsWith($tGXA6, '//')) { $tGXA6 = 'http:' . $tGXA6; } else { $tGXA6 = ltrim($tGXA6, '/'); } goto sqCRl; UdbDO: } public function repository() { return $this->repository; } protected function multiPartInitToken(array $Kp99R) { goto XA5Zp; mRxf0: if (file_exists($WECVu)) { $qsQD8 = (include $WECVu); } else { goto Ma783; uDIuv: $qsQD8['hash'] = $p1Hjz; goto RHPJ6; Ma783: $qsQD8['chunkUploaded'] = 0; goto uDIuv; bMPY6: $qsQD8['fullPath'] = self::DATA_TEMP . '/' . $fVt3n . '/' . $qsQD8['path']; goto lCYWl; LfDJs: $qsQD8['path'] = strtolower(Str::random(32)) . '.' . $n_0ut; goto bMPY6; RHPJ6: $n_0ut = FileUtil::extension($qsQD8['name']); goto LfDJs; lCYWl: } goto v7qiZ; jlCod: $ZK8CP = array(); goto VrIB9; WYpqR: $WECVu = self::DATA_CHUNK . '/token/' . $p1Hjz . '.php'; goto mRxf0; zDMJF: ksort($qsQD8, SORT_STRING); goto jlCod; v7qiZ: return $qsQD8; goto pIPos; zqqDG: $qsQD8 = $Kp99R['file']; goto zDMJF; VrIB9: $ZK8CP['uploadMaxSize'] = EnvUtil::env('uploadMaxSize'); goto YyVJY; YyVJY: $p1Hjz = md5(serialize($qsQD8) . ':' . serialize($ZK8CP)); goto WYpqR; XA5Zp: $fVt3n = $Kp99R['category']; goto zqqDG; pIPos: } protected function uploadChunkTokenAndDeleteToken($xT5sm) { goto NP07G; NP07G: $p1Hjz = $xT5sm['hash']; goto pQLEs; pQLEs: $WECVu = self::DATA_CHUNK . '/token/' . $p1Hjz . '.php'; goto q_2bC; q_2bC: $this->localStorage->delete($WECVu); goto dyt8F; dyt8F: } protected function uploadChunkTokenAndUpdateToken($xT5sm) { goto QfjgK; M05dF: $this->localStorage->put($WECVu, '<' . '?php return ' . var_export($xT5sm, true) . ';'); goto gIamJ; QfjgK: $p1Hjz = $xT5sm['hash']; goto HNP7r; HNP7r: $WECVu = self::DATA_CHUNK . '/token/' . $p1Hjz . '.php'; goto M05dF; gIamJ: } }