<?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($vFR1v) { goto qj5Qh; Mj4gx: $this->repository = new DatabaseDataRepository(); goto giYwT; qj5Qh: $this->option = $vFR1v; goto EZql2; jSTA1: $this->localStorage = Storage::disk('data'); goto Mj4gx; EZql2: config(array('filesystems.disks.data' => array('driver' => 'local', 'root' => base_path('public/')))); goto jSTA1; giYwT: } public function driverName() { return null; } public abstract function init(); public abstract function has($WF06r); public abstract function move($E_44J, $cJXa5); public abstract function delete($WF06r); public function softDelete($WF06r) { return $this->move($WF06r, self::DATA . '/_trash/' . date('Ymd_H') . '/' . $WF06r); } public abstract function put($WF06r, $gP2DQ); public abstract function get($WF06r); public abstract function size($WF06r); public abstract function multiPartInit($mattM); public abstract function multiPartUpload($mattM); public function updateDriverDomain($dTnlu) { return $dTnlu; } public function domain() { return ''; } public function domainInternal() { return ''; } public function getDriverFullPath($QTKvb) { goto PYizQ; V1wz6: if (Str::startsWith($QTKvb, '//')) { $QTKvb = 'http:' . $QTKvb; } else { $QTKvb = ltrim($QTKvb, '/'); } goto yP0D8; yP0D8: if (PathUtil::isPublicNetPath($QTKvb)) { return $QTKvb; } goto s6Bf0; PYizQ: if (empty($QTKvb)) { return $QTKvb; } goto V1wz6; s6Bf0: return config('data.baseUrl', '/') . $QTKvb; goto zJ_lJ; zJ_lJ: } public function getDriverFullPathInternal($QTKvb) { goto oPzgF; oPzgF: if (Str::startsWith($QTKvb, '//')) { $QTKvb = 'http:' . $QTKvb; } else { $QTKvb = ltrim($QTKvb, '/'); } goto ihn98; ihn98: if (PathUtil::isPublicNetPath($QTKvb)) { return $QTKvb; } goto npg2j; npg2j: return config('data.baseUrl', '/') . $QTKvb; goto Ab3ig; Ab3ig: } public function repository() { return $this->repository; } protected function multiPartInitToken(array $mattM) { goto Yl0fq; Ym8jE: $WF06r = $mattM['file']; goto U2hNi; eW7wH: $n0mgm = md5(serialize($WF06r) . ':' . serialize($OMoJG)); goto oi6Jx; oi6Jx: $g5mOK = self::DATA_CHUNK . '/token/' . $n0mgm . '.php'; goto V6yG4; U9Qv5: $OMoJG = array(); goto Au923; Au923: $OMoJG['uploadMaxSize'] = EnvUtil::env('uploadMaxSize'); goto eW7wH; Yl0fq: $PW0Jg = $mattM['category']; goto Ym8jE; V6yG4: if (file_exists($g5mOK)) { $WF06r = (include $g5mOK); } else { goto abO04; UwDtW: $WF06r['path'] = strtolower(Str::random(32)) . '.' . $JuuIF; goto jzN1d; slW19: $WF06r['hash'] = $n0mgm; goto KTQny; KTQny: $JuuIF = FileUtil::extension($WF06r['name']); goto UwDtW; jzN1d: $WF06r['fullPath'] = self::DATA_TEMP . '/' . $PW0Jg . '/' . $WF06r['path']; goto lcQsm; abO04: $WF06r['chunkUploaded'] = 0; goto slW19; lcQsm: } goto uuqmM; U2hNi: ksort($WF06r, SORT_STRING); goto U9Qv5; uuqmM: return $WF06r; goto UpJgZ; UpJgZ: } protected function uploadChunkTokenAndDeleteToken($faQ3n) { goto gGq2d; H1bqM: $this->localStorage->delete($g5mOK); goto NYUmy; uUtBf: $g5mOK = self::DATA_CHUNK . '/token/' . $n0mgm . '.php'; goto H1bqM; gGq2d: $n0mgm = $faQ3n['hash']; goto uUtBf; NYUmy: } protected function uploadChunkTokenAndUpdateToken($faQ3n) { goto zws7h; y01xC: $this->localStorage->put($g5mOK, '<' . '?php return ' . var_export($faQ3n, true) . ';'); goto DGZVl; l7kzC: $g5mOK = self::DATA_CHUNK . '/token/' . $n0mgm . '.php'; goto y01xC; zws7h: $n0mgm = $faQ3n['hash']; goto l7kzC; DGZVl: } }