<?php
/**
 * Includes of Monkey WordPress Theme of mobantu.com
**/
$options = get_option('monkey-options');
$qqid = $options['qqid'];
$weiboid = $options['weiboid'];
$weixinid = $options['weixinid'];
?>
<?php if($weixinid){?>
<script src="http://res.wx.qq.com/connect/zh_CN/htmledition/js/wxLogin.js"></script>
<?php }?>
<div id="sign" class="sign">
    <div class="part loginPart">
    <form id="login" action="<?php echo get_option('home'); ?>/wp-login.php" method="post" novalidate="novalidate">
        <div id="register-active" class="switch">还没账号？马上注册&gt;&gt;</div>
        <h3>登录<p class="status"></p></h3>
        <p>
            <label class="icon" for="username"><i class="fa fa-user"></i></label>
            <input class="input-control" id="username" type="text" placeholder="请输入用户名" name="username" required="" aria-required="true">
        </p>
        <p>
            <label class="icon" for="password"><i class="fa fa-lock"></i></label>
            <input class="input-control" id="password" type="password" placeholder="请输入密码" name="password" required="" aria-required="true">
        </p>
        <p class="safe">
            <label class="remembermetext" for="rememberme"><input name="rememberme" type="checkbox" checked="checked" id="rememberme" class="rememberme" value="forever">记住我的登录</label>
            <a class="lost" href="<?php echo get_option('home'); ?>/wp-login.php?action=lostpassword"><?php _e('忘记密码 ?','tinection'); ?></a>
        </p>
        <p>
            <input class="submit login-loader" type="button" value="登录" name="submit">
            <input type="hidden" name="action" value="mobantu_login">
        </p>
        <a class="close"><i class="headericon-close"></i></a>
        <input type="hidden" id="security" name="security" value="<?php echo  wp_create_nonce( 'security_nonce' );?>">
		<input type="hidden" name="_wp_http_referer" value="<?php echo $_SERVER['REQUEST_URI']; ?>">
	</form>
    <div id="weixin_login"></div>
    <?php if($qqid || $weixinid || $weiboid){?>
    <div class="other-sign">
      <p>使用第三方帐号快捷登录</p>
      <?php if($qqid){?><div class="2-col"><a class="qqlogin" href="<?php echo get_bloginfo('url').'/oauth/qq?rurl='.selfURL();?>" rel="nofollow"><i class="icon-qq"></i> <span>QQ登录</span></a></div><?php }?>
      <?php if($weixinid){?><div class="2-col"><a class="weixinlogin" href="javascript:;" rel="nofollow"><i class="icon-weixin"></i> <span>微信登录</span></a></div><?php }?>
	  <?php if($weiboid){?><div class="2-col"><a class="weibologin" href="<?php echo get_bloginfo('url').'/oauth/weibo?rurl='.selfURL();?>" rel="nofollow"><i class="icon-weibo"></i> <span>微博登录</span></a></div><?php }?>
    </div>
    <?php }?>
    <div class="sign-tips"></div>
    </div>
    <div class="part registerPart">
    <form id="register" action="<?php bloginfo('url'); ?>/wp-login.php?action=register" method="post" novalidate="novalidate">
        <div id="login-active" class="switch">已有账号？快去登录&gt;&gt;</div>
        <h3>注册<p class="status"></p></h3>    
        <p>
            <label class="icon" for="user_name"><i class="fa fa-user"></i></label>
            <input class="input-control" id="user_name" type="text" name="user_name" placeholder="输入英文用户名" required="" aria-required="true">
        </p>
        <p>
            <label class="icon" for="user_email"><i class="fa fa-envelope"></i></label>
            <input class="input-control" id="user_email" type="email" name="user_email" placeholder="输入常用邮箱" required="" aria-required="true">
        </p>
        <p>
            <label class="icon" for="user_pass"><i class="fa fa-lock"></i></label>
            <input class="input-control" id="user_pass" type="password" name="user_pass" placeholder="密码最小长度为6" required="" aria-required="true">
        </p>
        <p>
            <label class="icon" for="user_pass2"><i class="fa fa-retweet"></i></label>
            <input class="input-control" id="user_pass2" type="password" name="user_pass2" placeholder="再次输入密码" required="" aria-required="true">
        </p>
        <p id="captcha_inline">

            <input type="hidden" name="action" value="mobantu_register">
            <input class="submit inline register-loader" type="button" value="注册" name="submit" style="height: 38px;">
        </p>
        <a class="close"><i class="headericon-close"></i></a>  
        <input type="hidden" id="user_security" name="user_security" value="<?php echo  wp_create_nonce( 'user_security_nonce' );?>"><input type="hidden" name="_wp_http_referer" value="<?php echo $_SERVER['REQUEST_URI']; ?>"> 
    </form>
    <div class="sign-tips"></div>
    </div>
    <div class="clear"></div>
</div>
<?php if($weixinid){?>
<script>
	$(".weixinlogin").click(function(){
		$.post(
			_MBT.uri+'/includes/action/login.php',
			{
				action: "weixin_state"
			},
			function (data) {
				if (data) {
					$("#login").hide();
					$('#weixin_login').show();
					var obj = new WxLogin({
					  id: "weixin_login",
					  appid: "<?php echo $options['weixinid'];?>",
					  scope: "snsapi_login",
					  redirect_uri: encodeURIComponent("<?php bloginfo('url');?>/oauth/weixin/"),
					  state: data,
					  style: "black",
					  href: ""
					});
					$('#weixin_login').append('<div style="text-align:center;cursor:pointer;font-size:14px;color:#2faf16" class="return-login">返回普通登录</div>');
					$(".return-login").click(function(){
						$('#weixin_login').hide();
						$("#login").show();
					})
				}
				
			}
		);
		
	})
</script>
<?php }?>