<?php require('../functions.php'); if (file_exists('../Configs/config.php')) exit('系统已经检测到您已经安装本程序，如需重新安装，请删除根目录/Includes/Configs/下的config.php文件即可！'); ?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>程序安装 - 天方夜谭云助手</title>
    <meta name="description" content="Responsive, Bootstrap, BS4" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimal-ui" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- for ios 7 style, multi-resolution icon of 152x152 -->
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-barstyle" content="black-translucent">
    <link rel="apple-touch-icon" href="/ThinkPHP/Users/images/logo.png">
    <meta name="apple-mobile-web-app-title" content="Flatkit">
    <!-- for Chrome on Android, multi-resolution icon of 196x196 -->
    <meta name="mobile-web-app-capable" content="yes">
    <link rel="shortcut icon" sizes="196x196" href="/ThinkPHP/Users/images/logo.png">
    <!-- style -->
    <link rel="stylesheet" href="/ThinkPHP/Users/css/animate.css/animate.min.css" type="text/css" />
    <link rel="stylesheet" href="/ThinkPHP/Users/css/glyphicons/glyphicons.css" type="text/css" />
    <link rel="stylesheet" href="/ThinkPHP/Users/css/font-awesome/css/font-awesome.min.css" type="text/css" />
    <link rel="stylesheet" href="/ThinkPHP/Users/css/material-design-icons/material-design-icons.css" type="text/css" />
    <link rel="stylesheet" href="/ThinkPHP/Users/css/ionicons/css/ionicons.min.css" type="text/css" />
    <link rel="stylesheet" href="/ThinkPHP/Users/css/simple-line-icons/css/simple-line-icons.css" type="text/css" />
    <link rel="stylesheet" href="/ThinkPHP/Users/css/bootstrap/dist/css/bootstrap.min.css" type="text/css" />
    <!-- build:css css/styles/app.min.css -->
    <link rel="stylesheet" href="/ThinkPHP/Users/css/styles/app.css" type="text/css" />
    <link rel="stylesheet" href="/ThinkPHP/Users/css/styles/style.css" type="text/css" />
    <!-- endbuild -->
    <link rel="stylesheet" href="/ThinkPHP/Users/css/styles/font.css" type="text/css" />
</head>
<body>
<div class="app" id="app">
    <!-- ############ LAYOUT START-->
    <div class="padding">
        <div class="navbar">
            <div class="pull-center">
                <!-- brand -->
                <a href="./" class="navbar-brand">
                    <div data-ui-include="'/ThinkPHP/Users/images/logo.svg'"></div>
                    <img src="/ThinkPHP/Users/images/logo.png" alt="." class="hide">
                    <span class="hidden-folded inline">程序安装</span>
                </a>
                <!-- / brand -->
            </div>
        </div>
    </div>
    <div class="b-t">
        <div class="center-block w-xxl w-auto-xs p-y-md text-center">
            <!-- 第一步 -->
            <div class="p-a-md" id="step_1">
                <h3>阅读协议</h3>
                <div class="m-y text-sm" id="msg1">
                    请先阅读协议后再进行操作！
                </div>
                <div class="list-group m-b text-left">
                    <a href="#" class="list-group-item b-l-primary">
                        1.该程序由天方夜谭一个人独立开发
                    </a>
                    <a href="#" class="list-group-item b-l-warning">
                        2.QQ：17404785,交流Q群：592427909
                    </a>
                    <a href="#" class="list-group-item b-l-success">
                        3.该程序为天方夜谭云助手商业版V1.0.0
                    </a>
                    <a href="#" class="list-group-item b-l-danger">
                        4.程序为商业版,请勿泛滥,否正后果自负
                    </a>
                    <a href="#" class="list-group-item b-l-info">
                        5.开发不易,互相尊重,版权所有,侵权必究!
                    </a>
                </div>
                <div class="m-b-md">
                    <label class="md-check">
                        <input type="checkbox" id="checkbox1"><i class="primary"></i> 我同意
                    </label>
                </div>
                <button type="submit" id="submit1" class="btn btn-lg black p-x-lg">我已经阅读协议</button>
                <div class="p-y-lg text-center">
                    <div>不会安装？点击 <a href="tencent://ContactInfo/?subcmd=ViewInfo&puin=0&uin=17404785" class="text-primary _600">寻求帮助</a>(费用：10元)</div>
                </div>
            </div>
            <!-- 第二步 -->
            <div class="p-a-md" id="step_2" style="display:none;">
                <h3>环境检测</h3>
                <div class="m-y text-sm" id="msg2">
                    如有一项不通过，则程序无法正常使用。
                </div>
                <table class="table table-striped">
                    <thead>
                    <tr>
                        <th>函数检测</th>
                        <th>需求</th>
                        <th>当前</th>
                        <th>用途</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr>
                        <td>PHP 5.3+</td>
                        <td>必须</td>
                        <td><?php echo phpversion(); ?></td>
                        <td>PHP版本支持</td>
                    </tr>
                    <tr>
                        <td>curl_exec()</td>
                        <td>必须</td>
                        <td><?php echo checkfunc('curl_exec', true); ?></td>
                        <td>抓取网页</td>
                    </tr>
                    <tr>
                        <td>file_get_contents()</td>
                        <td>必须</td>
                        <td><?php echo checkfunc('file_get_contents', true); ?></td>
                        <td>读取文件</td>
                    </tr>
                    <tr>
                        <td>fsockopen()</td>
                        <td>必须</td>
                        <td><?php echo checkfunc('fsockopen'); ?></td>
                        <td>发送邮件</td>
                    </tr>
                    <tr>
                        <td>ZipArchive</td>
                        <td>推荐</td>
                        <td><?php echo checkclass('ZipArchive'); ?></td>
                        <td>Zip 解包和压缩</td>
                    </tr>
                    <tr>
                        <td>写入权限</td>
                        <td>推荐</td>
                        <td><?php if (is_writable('./')) {
                                echo '<font color="green">可用</font>';
                            } else {
                                echo '<font color="black">不支持</font>';
                            } ?></td>
                        <td>写入文件(1/2)</td>
                    </tr>
                    <tr>
                        <td>file_put_contents()</td>
                        <td>推荐</td>
                        <td><?php echo checkfunc('file_put_contents'); ?></td>
                        <td>写入文件(2/2)</td>
                    </tr>
                    </tbody>
                </table>
                <div class="m-b-md">
                    <label class="md-check">
                        <input type="checkbox" id="checkbox2"><i class="primary"></i> 已全部通过
                    </label>
                </div>
                <button type="submit" id="submit2" class="btn btn-lg black p-x-lg">确定，下一步</button>
                <div class="p-y-lg text-center">
                    <div>不会安装？点击 <a href="tencent://ContactInfo/?subcmd=ViewInfo&puin=0&uin=17404785" class="text-primary _600">寻求帮助</a>(费用：10元)</div>
                </div>
            </div>
            <!-- 第三步 -->
            <div class="p-a-md" id="step_3" style="display:none;">
                <h3>配置数据库</h3>
                <div class="m-y text-sm" id="msg3">
                    请先填写数据库配置后再进行操作！
                </div>
                <div class="form-group">
                    <div class="row m-b">
                        <div class="col-sm-8">
                            <input type="text" name="host" class="form-control" placeholder="数据库服务器地址" value="localhost" required>
                        </div>
                        <div class="col-sm-4">
                            <input type="number" name="port" class="form-control" placeholder="端口号" value="3306" required>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <input type="text" name="name" class="form-control" placeholder="请输入数据库名称" required>
                </div>
                <div class="form-group">
                    <input type="text" name="user" class="form-control" placeholder="请输入数据用户名" required>
                </div>
                <div class="form-group">
                    <input type="password" name="pwd" class="form-control" placeholder="请输入数据库密码" required>
                </div>
                <div class="form-group">
                    <input type="text" name="prefix" class="form-control" placeholder="数据表前缀" value="yunzs_" required>
                </div>
                <div class="m-b-md">
                    <label class="md-check">
                        <input type="checkbox" id="checkbox3"><i class="primary"></i> 确认信息无误！
                    </label>
                </div>
                <button type="submit" id="submit3" class="btn btn-lg black p-x-lg">确定，下一步</button>
                <div class="p-y-lg text-center">
                    <div>不会安装？点击 <a href="tencent://ContactInfo/?subcmd=ViewInfo&puin=0&uin=17404785" class="text-primary _600">寻求帮助</a>(费用：10元)</div>
                </div>
            </div>
            <!-- 第四步 -->
            <div class="p-a-md" id="step_4" style="display:none;" qq="">
                <h3>扫码验证</h3>
                <div class="m-y text-sm" id="msg4">
                    安装前，请加QQ群：592427909，然后用添加QQ群的QQ扫描以下二维码进行验证
                </div>
				<button type="submit" id="submit4" class="btn btn-lg black p-x-lg">点击跳过验证</button>
                <div class="p-y-lg text-center">
                    <div>不会安装？点击 <a href="tencent://ContactInfo/?subcmd=ViewInfo&puin=0&uin=17404785" class="text-primary _600">寻求帮助</a>(费用：10元)</div>
                </div>
            </div>
            <!-- 第五步 -->
            <div class="p-a-md" id="step_5" style="display:none;">
                <h3>基本配置完成！</h3>
                <div class="m-y text-sm" id="msg5">
                    这将是安装的最后一步了。
                </div>
                <div class="list-group m-b text-left">
                    <a href="#" class="list-group-item b-l-primary">
                        <font class="text-primary">如有问题请联系天方夜谭或者交流群</font>
                    </a>
                    <a href="#" class="list-group-item b-l-warning">
                        <font class="text-warning">QQ：17404785,交流Q群：592427909</font>
                    </a>
                    <a href="#" class="list-group-item b-l-success">
                        <font class="text-success">友情提醒：第一个注册的为管理员账号</font>
                    </a>
                    <a href="#" class="list-group-item b-l-danger">
                        <font class="text-danger">程序为商业版,请勿泛滥,否正后果自负</font>
                    </a>
                    <a href="#" class="list-group-item b-l-info">
                        <font class="text-info">安装完成后，请尽快到后台进行监控，否正程序无法正常使用！</font>
                    </a>
                </div>
                <div class="form-group">
                    <input type="text" id="cdkey" class="form-control text-danger" placeholder="请输入程序授权码" required>
                </div>
                <div class="m-b-md">
                    <label class="md-check">
                        <input type="checkbox" id="checkbox5"><i class="primary"></i> 我知道了
                    </label>
                </div>
                <button type="submit" id="submit5" class="btn btn-lg black p-x-lg">完成安装</button>
                <div class="p-y-lg text-center">
                    <div>不会安装？点击 <a href="tencent://ContactInfo/?subcmd=ViewInfo&puin=0&uin=17404785" class="text-primary _600">寻求帮助</a>(费用：10元)</div>
                </div>
            </div>
        </div>
    </div>
    <!-- ############ LAYOUT END-->
</div>
<!-- build:js scripts/app.min.js -->
<!-- jQuery -->
<script src="/ThinkPHP/Users/libs/jquery/dist/jquery.js"></script>
<!-- Bootstrap -->
<script src="/ThinkPHP/Users/libs/tether/dist/js/tether.min.js"></script>
<script src="/ThinkPHP/Users/libs/bootstrap/dist/js/bootstrap.js"></script>
<!-- core -->
<script src="/ThinkPHP/Users/libs/jQuery-Storage-API/jquery.storageapi.min.js"></script>
<script src="/ThinkPHP/Users/libs/PACE/pace.min.js"></script>
<script src="/ThinkPHP/Users/libs/jquery-pjax/jquery.pjax.js"></script>
<script src="/ThinkPHP/Users/libs/blockUI/jquery.blockUI.js"></script>
<script src="/ThinkPHP/Users/libs/jscroll/jquery.jscroll.min.js"></script>
<script src="/ThinkPHP/Users/scripts/config.lazyload.js"></script>
<script src="/ThinkPHP/Users/scripts/ui-load.js"></script>
<script src="/ThinkPHP/Users/scripts/ui-jp.js"></script>
<script src="/ThinkPHP/Users/scripts/ui-include.js"></script>
<script src="/ThinkPHP/Users/scripts/ui-device.js"></script>
<script src="/ThinkPHP/Users/scripts/ui-form.js"></script>
<script src="/ThinkPHP/Users/scripts/ui-modal.js"></script>
<script src="/ThinkPHP/Users/scripts/ui-nav.js"></script>
<script src="/ThinkPHP/Users/scripts/ui-list.js"></script>
<script src="/ThinkPHP/Users/scripts/ui-screenfull.js"></script>
<script src="/ThinkPHP/Users/scripts/ui-scroll-to.js"></script>
<script src="/ThinkPHP/Users/scripts/ui-toggle-class.js"></script>
<script src="/ThinkPHP/Users/scripts/ui-taburl.js"></script>
<script src="/ThinkPHP/Users/scripts/app.js"></script>
<script src="/ThinkPHP/Users/scripts/ajax.js"></script>
<!-- endbuild -->
<script type="text/javascript">
    //第一步
    $('#submit1').on("click", function() {
        if($('#checkbox1').is(':checked')) {
            $('#submit1').text('请稍等...');
            $('#step_1').hide();
            $('#step_2').show();
            $(".center-block").css("width",'500px');
        }else{
            $('#msg1').html('<font color="red">请先阅读协议后再进行操作！</font>');
        }
    });

    //第二步
    $('#submit2').on("click", function() {
        if($('#checkbox2').is(':checked')) {
            $('#submit1').text('请稍等...');
            $('#step_1').hide();
            $('#step_2').hide();
            $('#step_3').show();
            $(".center-block").css("width",'344px');
        }else{
            $('#msg2').html('<font color="red">如果全部都通过请勾选：已全部通过！</font>');
        }
    });

    //第三步
    $('#submit3').on("click", function() {
        if($('#checkbox3').is(':checked')) {
            $('#submit3').attr('disabled',"true");
            $('#submit3').text('正在处理，请稍等...');
            $.ajax({
                type: "POST",
                url: '/Includes/Install/source.php',
                data: {'action':'install','host':$('[name="host"]').val(),'port':$('[name="port"]').val(),'name':$('[name="name"]').val(),'user':$('[name="user"]').val(),'pwd':$('[name="pwd"]').val(),'prefix':$('[name="prefix"]').val()},
                dataType: 'json',
                success: function (data) {
                    if (data.state=='ok'){
                        alert(data.msg);
                        $('#step_1').hide();
                        $('#step_2').hide();
                        $('#step_3').hide();
                        $('#step_4').show();
                        $(".center-block").css("width",'344px');
                    }else{
                        $('#msg3').html('<font color="red">'+data.msg+'</font>');
                        $('#submit3').text('确定，下一步');
                        $('#submit3').removeAttr("disabled");
                    }
                },
                error:function (data) {
                    $('#msg3').html('服务器内部错误！');
                    $('#submit3').removeAttr("disabled");
                }
            });
        }else{
            $('#msg3').html('<font color="red">如果你所填的信息无误，请勾选：确认信息无误！</font>');
        }
    });
	
	//第四步
	$('#submit4').on("click", function() {
		alert('验证成功！');
		$('#step_4').attr('qq',d.uin);
		$('#step_1').hide();
		$('#step_2').hide();
		$('#step_3').hide();
		$('#step_4').hide();
		$('#step_5').show();
		$(".center-block").css("width",'344px');
	});

    //第五步
    $('#submit5').on("click", function() {
        if($('#checkbox5').is(':checked')) {
            $('#submit5').attr('disabled',"true");
            $('#submit5').text('正在处理，请稍等...');
            $.ajax({
                type: "POST",
                url: '/Includes/Install/source.php',
                data: {'action':'end','host':$('[name="host"]').val(),'port':$('[name="port"]').val(),'name':$('[name="name"]').val(),'user':$('[name="user"]').val(),'pwd':$('[name="pwd"]').val(),'prefix':$('[name="prefix"]').val(),'qq':$('#step_4').attr('qq'),'cdkey':$('#cdkey').val()},
                dataType: 'json',
                success: function (data) {
                    if (data.state=='ok'){
                        alert(data.msg);
                        $('#step_1').hide();
                        $('#step_2').hide();
                        $('#step_3').hide();
                        $('#step_4').hide();
                        $(".center-block").css("width",'344px');
                        window.location='/';
                    }else{
                        $('#msg5').html('<font color="red">'+data.msg+'</font>');
                        $('#submit5').text('完成安装');
                        $('#submit5').removeAttr("disabled");
                    }
                },
                error:function (data) {
                    $('#msg5').html('服务器内部错误！');
                    $('#submit5').removeAttr("disabled");
                }
            });
        }else{
            $('#msg5').html('<font color="red">如果你同意授权协议，请勾选：我知道了！</font>');
        }
    });
</script>
</body>
</html>