<?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($Ggr9v) { goto t6m1r; iyPrT: $this->localStorage = Storage::disk('data'); goto POUyR; Jw9lh: config(array('filesystems.disks.data' => array('driver' => 'local', 'root' => base_path('public/')))); goto iyPrT; t6m1r: $this->option = $Ggr9v; goto Jw9lh; POUyR: $this->repository = new DatabaseDataRepository(); goto cOStG; cOStG: } public function driverName() { return null; } public abstract function init(); public abstract function has($ypGny); public abstract function move($lmF4G, $WLsPA); public abstract function delete($ypGny); public function softDelete($ypGny) { return $this->move($ypGny, self::DATA . '/_trash/' . date('Ymd_H') . '/' . $ypGny); } public abstract function put($ypGny, $vVYCS); public abstract function get($ypGny); public abstract function size($ypGny); public abstract function multiPartInit($ACVUe); public abstract function multiPartUpload($ACVUe); public function updateDriverDomain($zvN10) { return $zvN10; } public function domain() { return ''; } public function domainInternal() { return ''; } public function getDriverFullPath($YhsOb) { goto r7w1k; h2TFF: if (Str::startsWith($YhsOb, '//')) { $YhsOb = 'http:' . $YhsOb; } else { $YhsOb = ltrim($YhsOb, '/'); } goto Da0Nn; Da0Nn: if (PathUtil::isPublicNetPath($YhsOb)) { return $YhsOb; } goto yyq10; r7w1k: if (empty($YhsOb)) { return $YhsOb; } goto h2TFF; yyq10: return config('data.baseUrl', '/') . $YhsOb; goto wXuAD; wXuAD: } public function getDriverFullPathInternal($YhsOb) { goto HRfS9; HRfS9: if (Str::startsWith($YhsOb, '//')) { $YhsOb = 'http:' . $YhsOb; } else { $YhsOb = ltrim($YhsOb, '/'); } goto fow4o; fow4o: if (PathUtil::isPublicNetPath($YhsOb)) { return $YhsOb; } goto fdkpc; fdkpc: return config('data.baseUrl', '/') . $YhsOb; goto cMROh; cMROh: } public function repository() { return $this->repository; } protected function multiPartInitToken(array $ACVUe) { goto u3EwH; yYyB1: $F3G_2 = array(); goto EhJ2J; EhJ2J: $F3G_2['uploadMaxSize'] = EnvUtil::env('uploadMaxSize'); goto fJN36; FM2p8: $ypGny = $ACVUe['file']; goto kOo2u; jqV0Q: if (file_exists($jUKXr)) { $ypGny = (include $jUKXr); } else { goto OH2P4; ghzhR: $CkMlA = FileUtil::extension($ypGny['name']); goto OBkiR; OBkiR: $ypGny['path'] = strtolower(Str::random(32)) . '.' . $CkMlA; goto hDGGg; OH2P4: $ypGny['chunkUploaded'] = 0; goto KbUYC; KbUYC: $ypGny['hash'] = $yAv3U; goto ghzhR; hDGGg: $ypGny['fullPath'] = self::DATA_TEMP . '/' . $A1ib2 . '/' . $ypGny['path']; goto Ppxfq; Ppxfq: } goto Cd_V6; Cd_V6: return $ypGny; goto G0a4m; kOo2u: ksort($ypGny, SORT_STRING); goto yYyB1; fJN36: $yAv3U = md5(serialize($ypGny) . ':' . serialize($F3G_2)); goto OX89Z; OX89Z: $jUKXr = self::DATA_CHUNK . '/token/' . $yAv3U . '.php'; goto jqV0Q; u3EwH: $A1ib2 = $ACVUe['category']; goto FM2p8; G0a4m: } protected function uploadChunkTokenAndDeleteToken($V6wcT) { goto PKxnC; kQ8zv: $jUKXr = self::DATA_CHUNK . '/token/' . $yAv3U . '.php'; goto X6mFn; PKxnC: $yAv3U = $V6wcT['hash']; goto kQ8zv; X6mFn: $this->localStorage->delete($jUKXr); goto iwYki; iwYki: } protected function uploadChunkTokenAndUpdateToken($V6wcT) { goto SsdBy; fXckh: $this->localStorage->put($jUKXr, '<' . '?php return ' . var_export($V6wcT, true) . ';'); goto BWbst; SsdBy: $yAv3U = $V6wcT['hash']; goto WBKc0; WBKc0: $jUKXr = self::DATA_CHUNK . '/token/' . $yAv3U . '.php'; goto fXckh; BWbst: } }