<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ use ModStart\Core\Util\CurlUtil; use ModStart\Core\Util\FileUtil; use ModStart\Core\Util\RandomUtil; goto QC4lV; QC4lV: include __DIR__ . '/function.php'; goto EiIsc; EiIsc: ?>
<!doctype html>
<html class="no-js">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="renderer" content="webkit">
    <script src="/asset/vendor/jquery.js"></script>
    <script src="/asset/common/base.js"></script>
    <script src="/asset/layui/layui.js"></script>
    <link rel="stylesheet" href="/asset/layui/css/layui.css">
    <link rel="stylesheet" href="/asset/theme/default/style.css">
    <title>安装助手</title>
    <style type="text/css">
        body, html {
            min-height: 100%;
        }

        .license-content p {
            font-size: 14px;
            line-height: 1.8em;
            margin: 0;
        }
    </style>
</head>
<body style="background:#333;padding:40px 0;">
<div style="width:600px;min-height:100vh;margin:0 auto;">

    <?php  goto EwHNy; EwHNy: if (file_exists(APP_PATH . '/storage/install.lock')) { ?>
        <div class="ub-alert ub-alert-danger ub-text-center">系统无需重复安装</div>
    <?php  } else { goto c9HzI; jz81c: function_exists('token_get_all') ? text_success('缺少 Tokenizer PHP 扩展') : text_error('Tokenizer PHP 扩展'); goto Kpvmt; NP03p: version_compare(PHP_VERSION, '5.5.9', '>=') ? text_success('PHP版本' . PHP_VERSION) : text_error('PHP版本>=5.5.9 当前为' . PHP_VERSION); goto VPnsK; wHVkN: class_exists('pdo') && in_array('mysql', PDO::getAvailableDrivers()) ? text_success('PDO Mysql 驱动正常') : text_error('缺少 PDO Mysql 驱动'); goto t44pO; oTrmt: ?>
                <?php  goto uuRv4; mPoAe: ?>
</div>
                    <div class="status error" style="display:none;"><?php  goto dK6D2; wqlIh: ?>
                <?php  goto wHVkN; oQEU4: function_exists('openssl_open') ? text_success('OpenSSL PHP 扩展') : text_error('缺少 OpenSSL PHP 扩展'); goto IBVRL; h6gLd: function_exists('proc_get_status') ? text_success('proc_get_status 函数') : text_error('缺少 proc_get_status 函数'); goto oTrmt; UTYbF: text_success('最大上传：' . FileUtil::formatByte(\ModStart\Core\Util\EnvUtil::env('uploadMaxSize'))); goto y9tR7; Cy62a: is_writable(APP_PATH . '/public/') ? text_success('/public/目录可写') : text_error('/public/目录不可写'); goto vq7GO; PDwdM: echo text_success('Rewrite规则正确'); goto mPoAe; IBVRL: ?>
                <?php  goto KStds; m6h0t: if (error_counter(0) > 0) { goto w4dsy; w4dsy: ?>
            <div class="ub-alert ub-alert-danger ub-text-center">请解决以上 <?php  goto cC0or; qluSb: ?>
 个问题再进行安装</div>
        <?php  goto h62jS; cC0or: echo error_counter(0); goto qluSb; h62jS: } else { if (!env_writable()) { ?>
            <div class="ub-alert ub-alert-danger ub-text-center">/.env文件不可写，请手动配置安装</div>
        <?php  } else { goto acT_5; fGulA: ?>
"/>
                        </div>
                    </div>
                </div>
                <?php  goto QclsS; gT6kc: ?>
"/>
                        </div>
                        <div class="line">
                            <label class="label">数据表前缀</label>
                            <input type="text" style="width:100%;" name="db_prefix"
                                   value="<?php  goto mhS3B; gcRZt: ?>
"/>
                        </div>
                    </div>
                </div>
                <div class="ub-panel" style="margin-top:20px;">
                    <div class="head">
                        <div class="title">
                            安装操作
                        </div>
                    </div>
                    <div class="body">
                        <?php  goto QUwr3; eeS9h: echo htmlspecialchars(get_env_config('db_host')); goto WcWJl; uX5H0: echo htmlspecialchars(get_env_config('admin_password')); goto gcRZt; QclsS: if (!empty($sPDAc)) { goto oVcD0; l9IYO: if (!empty($sPDAc['envs'])) { goto dlsgf; dlsgf: ?>
                                <?php  goto VVynt; VVynt: foreach ($sPDAc['envs'] as $AmOfS) { goto aJJe6; JLZDw: echo htmlspecialchars($AmOfS['default']); goto xIO63; e2d7v: echo $AmOfS['desc']; goto p4Y_m; iv5kM: ?>
</div>
                                        <div class="field">
                                            <input class="form" type="text" name="<?php  goto hCzua; aJJe6: ?>
                                    <div class="line">
                                        <div class="label"><span class="ub-text-danger">*</span> <?php  goto ffHEC; gQdmI: ?>
" value="<?php  goto JLZDw; xIO63: ?>
" />
                                            <div class="help"><?php  goto e2d7v; p4Y_m: ?>
</div>
                                        </div>
                                    </div>
                                <?php  goto h291g; ffHEC: echo htmlspecialchars($AmOfS['label']); goto iv5kM; hCzua: echo $AmOfS['name']; goto gQdmI; h291g: } goto oxGqM; oxGqM: ?>
                            <?php  goto WAeSR; WAeSR: } goto lRRPb; oVcD0: ?>
                    <div class="ub-panel">
                        <div class="head">
                            <div class="title">系统配置</div>
                        </div>
                        <div class="body">
                            <?php  goto l9IYO; lRRPb: ?>
                        </div>
                    </div>
                <?php  goto a2sLy; a2sLy: } goto vAskL; acT_5: ?>
            <div style="display:none;" class="ub-form ub-form-stacked">
                <div class="ub-panel" style="background:#FFF;">
                    <div class="head">
                        <div class="title">MySQL数据库信息</div>
                    </div>
                    <div class="body">
                        <div class="line">
                            <label class="label"><span class="ub-text-danger">*</span> 主机</label>
                            <input type="text" style="width:100%;" name="db_host"
                                   value="<?php  goto eeS9h; Pf92a: ?>
"/>
                        </div>
                        <div class="line">
                            <label class="label"><span class="ub-text-danger">*</span> 密码</label>
                            <input type="text" style="width:100%;" name="password"
                                   placeholder="<?php  goto uX5H0; lfKXL: echo htmlspecialchars(get_env_config('db_name')); goto hXVOZ; WcWJl: ?>
"/>
                        </div>
                        <div class="line">
                            <label class="label"><span class="ub-text-danger">*</span> 数据库名</label>
                            <input type="text" style="width:100%;" name="db_database"
                                   value="<?php  goto lfKXL; RshbY: ?>
"/>
                        </div>
                        <div class="line">
                            <label class="label"><span class="ub-text-danger">*</span> 密码</label>
                            <input type="text" style="width:100%;" name="db_password"
                                   value="<?php  goto UTRhQ; Xcs1E: echo htmlspecialchars(get_env_config('admin_username')); goto Pf92a; AbAdJ: echo htmlspecialchars(json_encode(isset($sPDAc) ? $sPDAc : null)); goto mBEif; mBEif: ?>
" />
                            <button type="button" onclick="doSubmit();" style="width:40%;" class="btn btn-primary">提交</button>
                        </div>
                    </div>
                </div>
            </div>
        <?php  goto lUhgO; hXVOZ: ?>
"/>
                        </div>
                        <div class="line">
                            <label class="label"><span class="ub-text-danger">*</span> 用户名</label>
                            <input type="text" style="width:100%;" name="db_username"
                                   value="<?php  goto vMinN; UTRhQ: echo htmlspecialchars(get_env_config('db_password')); goto gT6kc; zQbTj: ?>
                        <div style="text-align:center;">
                            <input type="hidden" name="INSTALL_CONFIG" value="<?php  goto AbAdJ; mhS3B: echo htmlspecialchars(get_env_config('db_prefix')); goto fGulA; vMinN: echo htmlspecialchars(get_env_config('db_username')); goto RshbY; QUwr3: if (defined('DEMO_DATA') || defined('LICENSE_URL')) { goto IFS4k; hEoZn: ?>
                                    <?php  goto jc3LD; IFS4k: ?>
                            <div class="line">
                                <div class="field">
                                    <?php  goto wjzup; wjzup: if (defined('DEMO_DATA')) { ?>
                                        <div>
                                            <label style="border:none;margin-top:-10px;">
                                                <input type="checkbox" name="installDemo" value="1"/>
                                                安装演示数据
                                            </label>
                                        </div>
                                    <?php  } goto hEoZn; ze61h: ?>
                                </div>
                            </div>
                        <?php  goto QH3k_; jc3LD: if (defined('LICENSE_URL')) { goto WV6Gg; R032q: ?>
" target="_blank">《软件安装许可协议》</a>
                                        </div>
                                    <?php  goto kuy5Q; gDXbV: echo LICENSE_URL; goto R032q; WV6Gg: ?>
                                        <div>
                                            <label style="border:none;margin-top:-10px;margin-right:0;padding-right:0;">
                                                <input type="checkbox" name="installLicense" value="1"/>
                                                同意
                                            </label>
                                            <a href="<?php  goto gDXbV; kuy5Q: } goto ze61h; QH3k_: } goto zQbTj; vAskL: ?>
                <div class="ub-panel">
                    <div class="head">
                        <div class="title">管理信息</div>
                    </div>
                    <div class="body">
                        <div class="line">
                            <label class="label"><span class="ub-text-danger">*</span> 用户</label>
                            <input type="text" style="width:100%;" name="username"
                                   value="<?php  goto Xcs1E; lUhgO: } } goto DS63c; wfxVl: function_exists('proc_open') ? text_success('proc_open 函数') : text_error('缺少 proc_open 函数'); goto xho4D; fJJ5w: text_success('系统：' . PHP_OS); goto ZFDHO; rrMhJ: class_exists('pdo') ? text_success('PDO PHP 扩展') : text_error('缺少 PDO PHP 扩展'); goto wqlIh; uuRv4: function_exists('bcmul') ? text_success('bcmath 扩展') : text_error('缺少 PHP bcmath 扩展'); goto eKOMk; vq7GO: ?>
                <?php  goto Z4wHu; eKOMk: ?>
                <?php  goto rrMhJ; KStds: function_exists('exif_read_data') ? text_success('Exif PHP 扩展') : text_error('缺少 Exif PHP 扩展'); goto erWdh; Z4wHu: is_writable(APP_PATH . '/bootstrap/cache/') ? text_success('/bootstrap/cache/目录可写') : text_error('/bootstrap/cache/目录不可写'); goto M00Mt; prccd: ?>
                <?php  goto h6gLd; E8jIY: ?>
                <?php  goto COyza; erWdh: ?>
                <?php  goto wfxVl; Kpvmt: ?>
                <?php  goto gE0Il; M00Mt: ?>
                <div data-rewrite-check>
                    <div class="status loading"><div class="ub-alert">Rewrite规则检测中...</div></div>
                    <div class="status success" style="display:none;"><?php  goto PDwdM; y9tR7: ?>
                <?php  goto oQEU4; PFlW1: ?>
                <?php  goto jz81c; HG1AY: function_exists('mb_internal_encoding') ? text_success('缺少 Mbstring PHP 扩展') : text_error('Mbstring PHP 扩展'); goto PFlW1; t44pO: ?>
                <?php  goto HG1AY; VPnsK: ?>
                <?php  goto UTYbF; dK6D2: echo text_error('Rewrite规则错误', null, false); goto dthMp; xho4D: ?>
                <?php  goto bztTH; KolRA: ?>
                <?php  goto Cy62a; gE0Il: function_exists('finfo_file') ? text_success('缺少 PHP Fileinfo 扩展') : text_error('PHP Fileinfo 扩展'); goto E8jIY; COyza: is_writable(APP_PATH . '/storage/') ? text_success('/storage/目录可写') : text_error('/storage/目录不可写'); goto KolRA; c9HzI: ?>
        <h1 class="ub-text-center" style="color:#FFF;">
            安装助手
        </h1>
        <div class="ub-panel">
            <div class="head">
                <div class="title">环境检查</div>
            </div>
            <div class="body">
                <?php  goto fJJ5w; ZFDHO: ?>
                <?php  goto NP03p; DS63c: ?>
    <?php  goto Rw90D; dthMp: ?>
</div>
                    <div class="status error ub-alert ub-alert-warning" style="display:none;">
                        <div>- 配置Nginx/Apache，保证访问 /install/ping 出现 ok 字样。</div>
                    </div>
                </div>
            </div>
        </div>
        <?php  goto m6h0t; bztTH: function_exists('putenv') ? text_success('putenv 函数') : text_error('缺少 putenv 函数'); goto prccd; Rw90D: } goto ibUQ3; ibUQ3: ?>
</div>
<script>
    $(function () {
        var $rewriteCheck = $('[data-rewrite-check]');
        $.ajax({
            url: '/install/ping',
            type: 'GET',
            success: function(data){
                if('ok'===data){
                    $rewriteCheck.find('.status').hide().filter('.success').show();
                    $('.ub-form').show();
                }else{
                    $rewriteCheck.find('.status').hide().filter('.error').show();
                }
            },
            error: function(data) {
                $rewriteCheck.find('.status').hide().filter('.error').show();
            }
        });
        window.doSubmit = function(){
            var data = {};
            var $form = $('.ub-form');
            $form.find('input[type=text],input[type=hidden]').each(function(i,o){
                data[$(o).attr('name')] = $(o).val();
            });
            $form.find('input[type=checkbox]:checked').each(function(i,o){
                data[$(o).attr('name')] = $(o).val();
            });
            window.api.dialog.loadingOn('正在提交表单..');
            window.api.base.post('/install/prepare',data,function(res){
                window.api.dialog.loadingOff();
                window.api.base.defaultFormCallback(res, {
                    success: function (res) {
                        window.api.dialog.loadingOn('正在安装系统，可能需要较长时间，请耐心等待...');
                        window.api.base.post('/install/execute',data,function(res){
                            window.api.dialog.loadingOff();
                            window.api.base.defaultFormCallback(res);
                        });
                    }
                })
            });
            return false;
        };
    });
</script>
</body>
</html>