<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Data; use ModStart\Admin\Auth\AdminPermission; use ModStart\Core\Dao\ModelUtil; use ModStart\Core\Input\InputPackage; use ModStart\Core\Input\Response; use ModStart\Core\Util\CurlUtil; use ModStart\Core\Util\FileUtil; class UeditorManager { private static function basicConfig() { goto buFCG; qWsdV: return $KGvTC; goto YnmLv; zcTKq: $KGvTC = array('imageActionName' => 'image', 'imageFieldName' => 'file', 'imageMaxSize' => $J_Sjj['image']['maxSize'], 'imageAllowFiles' => array_map(function ($ohYVl) { return '.' . $ohYVl; }, $J_Sjj['image']['extensions']), 'imageCompressEnable' => true, 'imageCompressBorder' => 5000, 'imageInsertAlign' => 'none', 'imageUrlPrefix' => '', 'scrawlActionName' => 'crawl', 'scrawlFieldName' => 'file', 'scrawlMaxSize' => $J_Sjj['image']['maxSize'], 'scrawlUrlPrefix' => '', 'scrawlInsertAlign' => 'none', 'snapscreenActionName' => 'snap', 'snapscreenUrlPrefix' => '', 'snapscreenInsertAlign' => 'none', 'catcherLocalDomain' => array('127.0.0.1', 'localhost'), 'catcherActionName' => 'catch', 'catcherFieldName' => 'source', 'catcherUrlPrefix' => '', 'catcherMaxSize' => $J_Sjj['image']['maxSize'], 'catcherAllowFiles' => array_map(function ($ohYVl) { return '.' . $ohYVl; }, $J_Sjj['image']['extensions']), 'videoActionName' => 'video', 'videoFieldName' => 'file', 'videoUrlPrefix' => '', 'videoMaxSize' => $J_Sjj['video']['maxSize'], 'videoAllowFiles' => array_map(function ($ohYVl) { return '.' . $ohYVl; }, $J_Sjj['video']['extensions']), 'fileActionName' => 'file', 'fileFieldName' => 'file', 'fileUrlPrefix' => '', 'fileMaxSize' => $J_Sjj['file']['maxSize'], 'fileAllowFiles' => array_map(function ($ohYVl) { return '.' . $ohYVl; }, $J_Sjj['file']['extensions']), 'imageManagerActionName' => 'listImage', 'imageManagerListSize' => 20, 'imageManagerUrlPrefix' => '', 'imageManagerInsertAlign' => 'none', 'imageManagerAllowFiles' => array_map(function ($ohYVl) { return '.' . $ohYVl; }, $J_Sjj['image']['extensions']), 'fileManagerActionName' => 'listFile', 'fileManagerUrlPrefix' => '', 'fileManagerListSize' => 20, 'fileManagerAllowFiles' => array_map(function ($ohYVl) { return '.' . $ohYVl; }, $J_Sjj['file']['extensions'])); goto qWsdV; buFCG: $J_Sjj = config('data.upload', array()); goto zcTKq; YnmLv: } public static function handle($qQN1c, $Li62T, $UBDc8, $DzdHs = null) { goto zHIom; goKTs: $TFjGK = $R4txz->getTrimString('action'); goto eo7JO; zHIom: $KGvTC = self::basicConfig(); goto DVcLb; DVcLb: $R4txz = InputPackage::buildFromInput(); goto goKTs; eo7JO: switch ($TFjGK) { case 'config': return Response::jsonRaw($KGvTC); case 'catch': goto QTZqX; punMH: return Response::jsonRaw($jdXgt); goto IC0Rb; ugTfM: $vJR2y = array(); goto BpA0j; kRNaK: $jdXgt = array('state' => '', 'list' => null); goto owiax; V52OE: $jdXgt['list'] = $vJR2y; goto punMH; BpA0j: $I_JnK = $R4txz->getArray($KGvTC['catcherFieldName']); goto syYRO; syYRO: if (empty($I_JnK)) { $jdXgt['state'] = 'ERROR'; return Response::jsonRaw($jdXgt); } goto tcEDA; QTZqX: set_time_limit(30); goto kRNaK; tcEDA: $jdXgt['state'] = 'SUCCESS'; goto GVImf; owiax: if (AdminPermission::isDemo()) { $jdXgt['state'] = 'ERROR'; return Response::jsonRaw($jdXgt); } goto ugTfM; GVImf: foreach ($I_JnK as $kaNJf) { if (preg_match('/^(http|ftp|https):\\/\\//i', $kaNJf)) { $NSzyn = FileUtil::extension($kaNJf); if (in_array('.' . $NSzyn, $KGvTC['catcherAllowFiles'])) { if ($Mk0ir = CurlUtil::getRaw($kaNJf)) { $uotzZ = DataManager::upload('image', L('Image') . '.' . $NSzyn, $Mk0ir, $DzdHs); if ($uotzZ['code']) { $uotzZ['state'] = $uotzZ['msg']; } else { goto fJlBt; oXXp2: $sdJSp = $uotzZ['data']['fullPath']; goto c6AGU; p72sc: $vJR2y[] = array('state' => 'SUCCESS', 'url' => $sdJSp, 'size' => strlen($Mk0ir), 'title' => '', 'original' => '', 'source' => htmlspecialchars($kaNJf)); goto qa2E3; c6AGU: ModelUtil::insert($qQN1c, array('category' => $Y0YxF['category'], 'dataId' => $Y0YxF['id'], 'uploadCategoryId' => 0, 'userId' => $UBDc8)); goto p72sc; fJlBt: $Y0YxF = $uotzZ['data']['data']; goto oXXp2; qa2E3: } } else { $uotzZ['state'] = 'Get remote file error'; } } else { $uotzZ['state'] = 'File ext not allowed'; } } else { $vJR2y[] = array('state' => 'not remote image', 'url' => '', 'size' => '', 'title' => '', 'original' => '', 'source' => htmlspecialchars($kaNJf)); } } goto V52OE; IC0Rb: } goto b7b9M; b7b9M: } }