<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Data; use Illuminate\Support\Facades\Storage; use Illuminate\Support\Str; use League\Flysystem\FilesystemInterface; use ModStart\Core\Util\FileUtil; 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(array $DzdHs) { goto LJcfL; rHJJw: $this->repository = new DatabaseDataRepository(); goto ckXwV; LJcfL: $this->option = $DzdHs; goto ySjJN; C6Y3i: $this->localStorage = Storage::disk('data'); goto rHJJw; ySjJN: config(array('filesystems.disks.data' => array('driver' => 'local', 'root' => base_path('public/')))); goto C6Y3i; ckXwV: } public abstract function init(); public abstract function has($oU8qf); public abstract function move($RNE_j, $Gp4Ek); public abstract function delete($oU8qf); public function softDelete($oU8qf) { $this->move($oU8qf, self::DATA . '/_trash/' . date('Ymd_H') . '/' . $oU8qf); } public abstract function put($oU8qf, $xMSF0); public abstract function get($oU8qf); public abstract function size($oU8qf); public abstract function multiPartInit($lyajz); public abstract function multiPartUpload($lyajz); public function updateDriverDomain($Y0YxF) { return $Y0YxF; } public function getDriverFullPath($ceAjB) { if (Str::startsWith($ceAjB, '//')) { $ceAjB = 'http:' . $ceAjB; } else { $ceAjB = ltrim($ceAjB, '/'); } return '/' . $ceAjB; } public function getDriverFullPathInternal($ceAjB) { if (Str::startsWith($ceAjB, '//')) { $ceAjB = 'http:' . $ceAjB; } else { $ceAjB = ltrim($ceAjB, '/'); } return '/' . $ceAjB; } public function repository() { return $this->repository; } protected function multiPartInitToken(array $lyajz) { goto EPyOW; GniaN: $oU8qf = $lyajz['file']; goto VjiJ0; VjiJ0: ksort($oU8qf, SORT_STRING); goto Cyima; EPyOW: $KD2ht = $lyajz['category']; goto GniaN; b1I24: $NGfHZ = self::DATA_CHUNK . '/token/' . $J5ee9 . '.php'; goto xsrdH; xsrdH: if (file_exists($NGfHZ)) { $oU8qf = (include $NGfHZ); } else { goto GG96n; OTZ5e: $oU8qf['hash'] = $J5ee9; goto dSj2S; dSj2S: $hD2nn = FileUtil::extension($oU8qf['name']); goto e81aY; e81aY: $oU8qf['path'] = strtolower(Str::random(32)) . '.' . $hD2nn; goto QBNBd; GG96n: $oU8qf['chunkUploaded'] = 0; goto OTZ5e; QBNBd: $oU8qf['fullPath'] = self::DATA_TEMP . '/' . $KD2ht . '/' . $oU8qf['path']; goto jnybG; jnybG: } goto jfwSt; jfwSt: return $oU8qf; goto U7RoP; Cyima: $J5ee9 = md5(serialize($oU8qf)); goto b1I24; U7RoP: } protected function uploadChunkTokenAndDeleteToken($kRdVK) { goto iaiqu; PAXop: $this->localStorage->delete($NGfHZ); goto bKYzt; BN0qZ: $NGfHZ = self::DATA_CHUNK . '/token/' . $J5ee9 . '.php'; goto PAXop; iaiqu: $J5ee9 = $kRdVK['hash']; goto BN0qZ; bKYzt: } protected function uploadChunkTokenAndUpdateToken($kRdVK) { goto WbXaJ; iNciy: $NGfHZ = self::DATA_CHUNK . '/token/' . $J5ee9 . '.php'; goto sSL49; WbXaJ: $J5ee9 = $kRdVK['hash']; goto iNciy; sSL49: $this->localStorage->put($NGfHZ, '<' . '?php return ' . var_export($kRdVK, true) . ';'); goto GaGb5; GaGb5: } }