<!--- BESCMS https://www.besyun.com -->
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8" />
    <title>{dr_lang('%s - 后台管理平台', SITE_NAME)}</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta content="width=device-width, initial-scale=1" name="viewport" />
    <link href="{$THEME_PATH}assets/icon/css/icon.css?v={CMF_UPDATE_TIME}" rel="stylesheet" type="text/css" />
    <link href="{$THEME_PATH}assets/global/css/login{if !IS_XRDEV}.min{/if}.css?v={CMF_UPDATE_TIME}" rel="stylesheet" type="text/css" />
    <link href="{php echo defined('MYCSS_FILE') ? MYCSS_FILE : $THEME_PATH.'assets/global/css/my.css';}?v={CMF_UPDATE_TIME}" rel="stylesheet" type="text/css" />
    <script src="{$THEME_PATH}assets/global/plugins/jquery.min.js?v={CMF_UPDATE_TIME}" type="text/javascript"></script>
    {if defined('SYS_ADMIN_LOGIN_AES') && SYS_ADMIN_LOGIN_AES}
    <script src="{$THEME_PATH}assets/global/plugins/crypto-js.min.js?v={CMF_UPDATE_TIME}" type="text/javascript"></script>
    {else}
    <script src="{$THEME_PATH}assets/global/plugins/jquery.md5.js?v={CMF_UPDATE_TIME}" type="text/javascript"></script>
    {/if}
    <script src="{$LANG_PATH}lang.js?v={CMF_UPDATE_TIME}" type="text/javascript"></script>
    <script src="{$THEME_PATH}assets/js/cms.js?v={CMF_UPDATE_TIME}" type="text/javascript"></script>
</head>
<body class="login">
<div class="content">
    <form class="login-form" action="" onsubmit="return dr_submit()" method="post">
        {$form}
        <div class="logo">
            <a href="{SITE_URL}"><img src="{$THEME_PATH}assets/logo-web.png" /> </a>
        </div>
        <div class="post-msg alert alert-danger display-hide">
            <span>  </span>
        </div>
       
        <div class="form-group" id="dr_row_username">
            <label class="control-label visible-ie8 visible-ie9">{dr_lang('账号')}</label>
            <div class="input-icon">
                <input style="padding-left:15px;" class="form-control placeholder-no-fix" type="text" value="<?php echo  defined('DEMO_ADMIN_USERNAME') ? DEMO_ADMIN_USERNAME : ''?>" autocomplete="off" placeholder="{dr_lang('账号')}" name="data[username]" /> </div>
        </div>
        <div class="form-group" id="dr_row_password">
            <label class="control-label visible-ie8 visible-ie9">{dr_lang('密码')}</label>
            <div class="input-icon">
                <input style="padding-left:15px;" id="password" class="form-control placeholder-no-fix" type="password" value="<?php echo  defined('DEMO_ADMIN_PASSWORD') ? DEMO_ADMIN_PASSWORD : ''?>" autocomplete="off" placeholder="{dr_lang('密码')}" name="data[password]" /> </div>
        </div>
       
        {if SYS_ADMIN_CODE}
        {if $is_mobile}
        <div class="form-group" id="dr_row_code">
            <label class="control-label visible-ie8 visible-ie9">{dr_lang('验证码')}</label>
            <div class="input-icon">
                <input  class="form-control placeholder-no-fix" type="text"  autocomplete="off" placeholder="{dr_lang('验证码')}" name="code" />
            </div>
        </div>
        <div class="form-group text-center">
            {dr_code(120, 35)}
        </div>
        {else}
        <div class="form-group" id="dr_row_code">
            <label class="control-label visible-ie8 visible-ie9">{dr_lang('验证码')}</label>
            <div class="input-group">
                <div class="input-icon">
                    <input style="padding-left: 15px" type="text" class="form-control placeholder-no-fix" autocomplete="off" placeholder="{dr_lang('验证码')}" name="code">
                </div>
                <div class="input-group-btn fc-code" style="padding-left: 10px;">
                    {dr_code(120, 35)}
                </div>
            </div>
        </div>
        {/if}
        {/if}
        
        {if $mytpl}
        {load $mytpl}
        {else}
        <div class="form-actions">
            <button type="button" onclick="dr_submit()" class="btn blue btn-block"> {dr_lang('登录后台')} </button>
        </div>
        {/if}
        
        {if defined('IS_ADMIN_MIN') && IS_ADMIN_MIN}
        {else}
        {if !SYS_ADMIN_MODE}
        <div class="form-group text-center">
            <div class="input-icon">
                <div class="mt-radio-inline">
                    <label class="mt-radio">
                        <input type="radio" name="data[mode]" value="1" {if $mode == 1}checked=""{/if}> {dr_lang('完整模式')}
                        <span></span>
                    </label>
                    <label class="mt-radio">
                        <input type="radio" name="data[mode]" value="2" {if $mode == 2}checked=""{/if}> {dr_lang('简化模式')}
                        <span></span>
                    </label>
                </div>
            </div>
        </div>
        {/if}
        {/if}
        {if SYS_ADMIN_OAUTH && $oauth}
        <link href="{$THEME_PATH}assets/icon/css/icon.css?v={CMF_UPDATE_TIME}" rel="stylesheet" type="text/css" />
        <div class="login-oauth">
            {loop $oauth $t}
            <a href="{$t.url}" class="tooltips" data-container="body" data-placement="top" data-original-title="{$t.title}"><i class="fa fa-{$t.name}"></i></a>
            {/loop}
        </div>
        {/if}
    </form>
</div>
<script src="{$THEME_PATH}assets/global/plugins/bootstrap/js/bootstrap.min.js?v={CMF_UPDATE_TIME}" type="text/javascript"></script>
<script src="{$THEME_PATH}assets/global/scripts/app.min.js?v={CMF_UPDATE_TIME}" type="text/javascript"></script>
<script type="text/javascript">
    var is_admin = 2;
    if (typeof parent.layer == 'function') {
        parent.layer.closeAll('loading');
    }
    function dr_password_md5() {
        var pwd = $('#password').val();
        if (pwd.length == 32) {
            // 已经加密过
        } else {
            {if defined('SYS_ADMIN_LOGIN_AES') && SYS_ADMIN_LOGIN_AES}
            $('.login-form').append('<input type="hidden" name="is_aes" value="1">');
            var key = CryptoJS.enc.Utf8.parse('{$crypto_key}');
            var iv = CryptoJS.enc.Utf8.parse('{$crypto_iv}');
            var pw = pwd;
            pwd = CryptoJS.AES.encrypt(pwd, key, {
                mode: CryptoJS.mode.CBC,
                iv: iv,
                padding: CryptoJS.pad.Pkcs7
            });
            {if IS_DEV}
            pwd2 = CryptoJS.AES.decrypt(pwd, key, {
                mode: CryptoJS.mode.CBC,
                iv: iv,
                padding: CryptoJS.pad.Pkcs7
            });
            pwd2 = pwd2.toString(CryptoJS.enc.Utf8);
            if (pwd2 != pw) {
                alert("CryptoJS密码解析失败");
                return;
            }
            {/if}
            {else}
            pwd = $.md5(pwd); // 进行md5加密
            {/if}
            $('#password').val(pwd);
        }
    }
    function dr_submit() {
        $('.post-msg', $('.login-form')).hide();
        // 这里进行md5加密存储
        dr_password_md5();
        $.ajax({type: "POST",dataType:"json", url: '{$login_url}', data: $(".login-form").serialize(),
            success: function(json) {
                // token 更新
                if (json.token) {
                    var token = json.token;
                    $(".login-form input[name='"+token.name+"']").val(token.value);
                }
                if (json.code == 1) {
                    window.location.href = json.data.url;
                } else {
                    {if defined('SYS_ADMIN_LOGIN_AES') && SYS_ADMIN_LOGIN_AES}
                    $('#password').val("");
                    {/if}
                    $('.fc-code img').click();
                    dr_msg(0, json.msg);
                }
            },
            error: function(HttpRequest, ajaxOptions, thrownError) {
                $('.fc-code img').click();
                var msg = HttpRequest.responseText;
                if (!msg) {
                    dr_msg(0, "{dr_lang('系统错误')}");
                } else {
                    dr_msg(0, msg);
                }
            }
        });
        return false;
    }
    jQuery(document).ready(function() {
        $('.login-form input').keypress(function (e) {
            if (e.which == 13) {
                dr_submit();
                return false;
            }
        });
        top.$('#dr_go_url').hide();
        if ($('.login-oauth .tooltips').length && $.fn.tooltip) {
            $('.login-oauth .tooltips').tooltip('destroy').tooltip({
                container: 'body',
                placement: 'top'
            });
        }
    });
    function dr_msg(code, msg) {
        $('.post-msg span', $('.login-form')).html(msg);
        $('.post-msg', $('.login-form')).show();
        if (code) {
            $('.post-msg').removeClass("alert-danger");
            $('.post-msg').addClass("alert-info");
        } else {
            $('.post-msg').addClass("alert-danger");
            $('.post-msg').removeClass("alert-info");
        }
    }
</script>
{if IS_OEM_CMS}
<script src="{$THEME_PATH}assets/global/plugins/backstretch/jquery.backstretch.min.js?v={CMF_UPDATE_TIME}" type="text/javascript"></script>
<script type="text/javascript">
    <?php $bg = array('"'.$THEME_PATH.'assets/global/login/1.jpg"',
        '"'.$THEME_PATH.'assets/global/login/2.jpg"',
        '"'.$THEME_PATH.'assets/global/login/3.jpg"',
        '"'.$THEME_PATH.'assets/global/login/4.jpg"');
    shuffle($bg);
        ?>
    jQuery(document).ready(function() {
        $.backstretch([
            {implode(',', $bg)}
        ], {
                fade: 1000,
                    duration: 8000
            }
        );
    });
</script>
{/if}
{if isset($_GET['isback']) && $_GET['isback']}
<script type="text/javascript">
    $(function(){
        dr_tips({intval($_GET['iscode'])}, "{dr_safe_replace($_GET['isback'])}")
    });
</script>
{/if}
</body>
</html>