<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Vendor\Web\Controller; use Illuminate\Routing\Controller; use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\DB; use Illuminate\Support\Str; use ModStart\Admin\Auth\Admin; use ModStart\Core\Dao\ModelUtil; use ModStart\Core\Input\InputPackage; use ModStart\Core\Input\Response; use ModStart\Core\Util\CurlUtil; use ModStart\Core\Util\RandomUtil; use ModStart\Module\ModuleManager; use PDO; class InstallController extends Controller { public function lock() { goto lv0Vf; WMa0a: return Response::send(0, 'install lock ok ^_^'); goto G5F7i; lv0Vf: $oRfVL = storage_path('install.lock'); goto P4PyP; zim6C: file_put_contents($oRfVL, 'lock'); goto WMa0a; P4PyP: if (file_exists($oRfVL)) { return Response::send(0, 'install lock error -_-'); } goto zim6C; G5F7i: } public function ping() { try { goto aiOeU; Of4Di: $dTlXv = trim(Artisan::output()); goto bXFdt; bXFdt: if (0 == $LnwsT && Str::contains($dTlXv, 'Current application environment')) { return 'ok'; } goto pO0nc; aiOeU: $LnwsT = Artisan::call('env'); goto Of4Di; pO0nc: return 'ERROR: code=' . $LnwsT . ', msg:' . $dTlXv; goto lmS02; lmS02: } catch (\Exception $oQDcC) { return 'ERROR:' . $oQDcC->getMessage(); } } public function prepare() { goto qsm5E; beWNM: try { new PDO("mysql:host={$zYZi6};dbname={$EYxpf}", $Jf43P, $DKSq3); } catch (\Exception $oQDcC) { return Response::jsonError('连接数据信息 ' . $zYZi6 . '.' . $EYxpf . ' 失败!'); } goto BmTgh; RqRyC: if (empty($JnzBs)) { return Response::jsonError('管理用户不能为空'); } goto jSs8G; zyDyY: if (!empty($uDi7K['envs'])) { foreach ($uDi7K['envs'] as $AmOfS) { $H0rDK = preg_replace('/' . $AmOfS['name'] . '=(.*?)\\n/', $AmOfS['name'] . '=' . $Cj1F4->getTrimString($AmOfS['name']) . '
', $H0rDK); } } goto A9FE8; w4Ihm: return Response::jsonSuccess(); goto hjYow; A9FE8: file_put_contents(base_path('.env'), $H0rDK); goto w4Ihm; CrtDl: $Jf43P = $Cj1F4->getTrimString('db_username'); goto aaEXC; zcS46: $Cj1F4 = InputPackage::buildFromInput(); goto BK8ee; o7gHe: $uDi7K = $Cj1F4->getJson('INSTALL_CONFIG'); goto Aq84e; Gccan: $EYxpf = $Cj1F4->getTrimString('db_database'); goto CrtDl; iBDVY: if (empty($Jf43P)) { return Response::jsonError('数据库用户明不能为空'); } goto RqRyC; RYKKl: $wWQF0 = $Cj1F4->getTrimString('password'); goto xE4jv; xE4jv: $ziVSQ = $Cj1F4->getBoolean('installDemo'); goto aXykw; jSs8G: if (empty($wWQF0)) { return Response::jsonError('管理用户密码不能为空'); } goto CdqKd; E4LhN: $H0rDK = preg_replace('/DB_PASSWORD=(.*?)\\n/', 'DB_PASSWORD=' . $DKSq3 . '
', $H0rDK); goto ubEps; qsm5E: if (file_exists(storage_path('install.lock'))) { return Response::jsonError('系统不能重复安装（请删除install.lock文件后重试）'); } goto zcS46; BmTgh: $H0rDK = file_get_contents(base_path('env.example')); goto yCwSA; wyAwE: $H0rDK = preg_replace('/DB_DATABASE=(.*?)\\n/', 'DB_DATABASE=' . $EYxpf . '
', $H0rDK); goto nyo1e; cjb9M: $FVm67 = $Cj1F4->getTrimString('db_prefix', ''); goto IUTKl; ULuH5: if (empty($EYxpf)) { return Response::jsonError('数据库数据库不能为空'); } goto iBDVY; QlwZn: $H0rDK = preg_replace('/APP_KEY=(.*?)\\n/', 'APP_KEY=' . RandomUtil::string(32) . '
', $H0rDK); goto zyDyY; ubEps: $H0rDK = preg_replace('/DB_PREFIX=(.*?)\\n/', 'DB_PREFIX=' . $FVm67 . '
', $H0rDK); goto QlwZn; Aq84e: if (empty($zYZi6)) { return Response::jsonError('数据库主机名不能为空'); } goto ULuH5; IUTKl: $JnzBs = $Cj1F4->getTrimString('username'); goto RYKKl; nyo1e: $H0rDK = preg_replace('/DB_USERNAME=(.*?)\\n/', 'DB_USERNAME=' . $Jf43P . '
', $H0rDK); goto E4LhN; BK8ee: $zYZi6 = $Cj1F4->getTrimString('db_host'); goto Gccan; yCwSA: $H0rDK = preg_replace('/DB_HOST=(.*?)\\n/', 'DB_HOST=' . $zYZi6 . '
', $H0rDK); goto wyAwE; CdqKd: if (file_exists(base_path('license.txt')) && !$bl_SZ) { return Response::jsonError('请先同意《软件安装许可协议》'); } goto beWNM; aXykw: $bl_SZ = $Cj1F4->getBoolean('installLicense'); goto o7gHe; aaEXC: $DKSq3 = $Cj1F4->getTrimString('db_password', ''); goto cjb9M; hjYow: } public function execute() { goto MxO1I; tVUZO: if ($F_8is === 0) { Admin::add($JnzBs, $wWQF0); } goto j4zkk; CxxAE: file_put_contents(storage_path('install.lock'), 'lock'); goto o2Umw; vm_vl: if (empty($wWQF0)) { return Response::jsonError('管理用户密码为空'); } goto EA7nP; TChJd: if (0 != $LnwsT) { return Response::jsonError("安装错误 exitCode({$LnwsT})"); } goto DDmhm; ef2UY: $wWQF0 = $Cj1F4->getTrimString('password'); goto a_rC2; a_rC2: $ziVSQ = $Cj1F4->getBoolean('installDemo'); goto f7qOp; MxO1I: if (file_exists(storage_path('install.lock'))) { return Response::jsonError('系统不能重复安装（请删除install.lock文件后重试）'); } goto ar7Hi; ar7Hi: $Cj1F4 = InputPackage::buildFromInput(); goto G6eon; o2Umw: return Response::json(0, '安装成功，点击即将跳转到管理后台', null, '/admin'); goto Dkxe8; G6eon: $JnzBs = $Cj1F4->getTrimString('username'); goto ef2UY; eMV0z: if ($ziVSQ && file_exists($SEC4E = public_path('data_demo/data.php'))) { goto gEvym; NOJVm: if (!empty($I3SIX['inserts'])) { foreach ($I3SIX['inserts'] as $fnOXp => $vKRZ2) { ModelUtil::insertAll($fnOXp, $vKRZ2); } } goto h_2Zj; h_2Zj: if (!empty($I3SIX['updates'])) { foreach ($I3SIX['updates'] as $Lu5WV) { DB::table($Lu5WV['table'])->where($Lu5WV['where'])->update($Lu5WV['update']); } } goto WVnU6; gEvym: $I3SIX = (include $SEC4E); goto NOJVm; WVnU6: } goto CxxAE; EA7nP: $LnwsT = Artisan::call('migrate'); goto TChJd; f7qOp: if (empty($JnzBs)) { return Response::jsonError('管理用户名为空'); } goto vm_vl; j4zkk: foreach (ModuleManager::listAllInstalledModulesInRequiredOrder() as $DOMdu) { goto XQMrW; O9l4F: if (Response::isError($yvBIN)) { return Response::generateError($yvBIN['msg']); } goto msPe1; XQMrW: if (!ModuleManager::isExists($DOMdu)) { continue; } goto SIAYp; SIAYp: $yvBIN = ModuleManager::install($DOMdu); goto O9l4F; msPe1: } goto eMV0z; DDmhm: $F_8is = ModelUtil::count('admin_user'); goto tVUZO; Dkxe8: } }