<?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($oOr7L) { goto Jn3uO; vgFLb: config(array('filesystems.disks.data' => array('driver' => 'local', 'root' => base_path('public/')))); goto R_Mbf; R_Mbf: $this->localStorage = Storage::disk('data'); goto Md8ia; Md8ia: $this->repository = new DatabaseDataRepository(); goto bYT3t; Jn3uO: $this->option = $oOr7L; goto vgFLb; bYT3t: } public function driverName() { return null; } public abstract function init(); public abstract function has($RLMU5); public abstract function move($SoJ1U, $blQsO); public abstract function delete($RLMU5); public function softDelete($RLMU5) { return $this->move($RLMU5, self::DATA . '/_trash/' . date('Ymd_H') . '/' . $RLMU5); } public abstract function put($RLMU5, $DTnPC); public abstract function get($RLMU5); public abstract function size($RLMU5); public abstract function multiPartInit($zlK8N); public abstract function multiPartUpload($zlK8N); public function updateDriverDomain($OTBPk) { return $OTBPk; } public function domain() { return ''; } public function domainInternal() { return ''; } public function getDriverFullPath($S3tfG) { goto c27aK; KKVHN: if (PathUtil::isPublicNetPath($S3tfG)) { return $S3tfG; } goto BNJTy; FKTIc: if (Str::startsWith($S3tfG, '//')) { $S3tfG = 'http:' . $S3tfG; } else { $S3tfG = ltrim($S3tfG, '/'); } goto KKVHN; BNJTy: return config('data.baseUrl', '/') . $S3tfG; goto qONI1; c27aK: if (empty($S3tfG)) { return $S3tfG; } goto FKTIc; qONI1: } public function getDriverFullPathInternal($S3tfG) { goto OuaYe; OuaYe: if (Str::startsWith($S3tfG, '//')) { $S3tfG = 'http:' . $S3tfG; } else { $S3tfG = ltrim($S3tfG, '/'); } goto FSYff; FSYff: if (PathUtil::isPublicNetPath($S3tfG)) { return $S3tfG; } goto jiPO4; jiPO4: return config('data.baseUrl', '/') . $S3tfG; goto rrxw7; rrxw7: } public function repository() { return $this->repository; } protected function multiPartInitToken(array $zlK8N) { goto p3zP6; p3zP6: $QLOpy = $zlK8N['category']; goto l2CyL; l2CyL: $RLMU5 = $zlK8N['file']; goto aLIIz; awWU3: if (file_exists($jc3Nv)) { $RLMU5 = (include $jc3Nv); } else { goto zEBXs; zEBXs: $RLMU5['chunkUploaded'] = 0; goto eWGJe; eWGJe: $RLMU5['hash'] = $THL2f; goto Sz5If; Sz5If: $jpBIg = FileUtil::extension($RLMU5['name']); goto OJpuV; OJpuV: $RLMU5['path'] = strtolower(Str::random(32)) . '.' . $jpBIg; goto SE542; SE542: $RLMU5['fullPath'] = self::DATA_TEMP . '/' . $QLOpy . '/' . $RLMU5['path']; goto wZPvx; wZPvx: } goto He0YR; aLIIz: ksort($RLMU5, SORT_STRING); goto W2rgp; W2rgp: $Sm7Qs = array(); goto RTwos; RTwos: $Sm7Qs['uploadMaxSize'] = EnvUtil::env('uploadMaxSize'); goto ZKvCQ; kz7Xb: $jc3Nv = self::DATA_CHUNK . '/token/' . $THL2f . '.php'; goto awWU3; He0YR: return $RLMU5; goto MTYx6; ZKvCQ: $THL2f = md5(serialize($RLMU5) . ':' . serialize($Sm7Qs)); goto kz7Xb; MTYx6: } protected function uploadChunkTokenAndDeleteToken($iWMtt) { goto UoOBd; UoOBd: $THL2f = $iWMtt['hash']; goto QJI2o; QJI2o: $jc3Nv = self::DATA_CHUNK . '/token/' . $THL2f . '.php'; goto ruQ5R; ruQ5R: $this->localStorage->delete($jc3Nv); goto tUKWI; tUKWI: } protected function uploadChunkTokenAndUpdateToken($iWMtt) { goto fUcaF; V4HHP: $jc3Nv = self::DATA_CHUNK . '/token/' . $THL2f . '.php'; goto zwkQB; zwkQB: $this->localStorage->put($jc3Nv, '<' . '?php return ' . var_export($iWMtt, true) . ';'); goto uikoy; fUcaF: $THL2f = $iWMtt['hash']; goto V4HHP; uikoy: } }