<?php

/* ========================================================================
 * $Id: login.php 2367 2017-06-09 15:01:20Z onez $
 * 
 * Email: www@onez.cn
 * QQ: 6200103
 * HomePage: http://www.onezphp.com
 * ========================================================================
 * Copyright 2016-2017 佳蓝科技.
 * 
 * ======================================================================== */

!defined('IN_ONEZ') && exit('Access Denied');
$goto=onez()->gp('goto');
!$goto && $goto=onez()->href('/index.php');
$mod=onez()->gp('mod');
$action=onez()->gp('action');
if($action=='chklogin'){
  $username=onez()->gp('username');
  $password=onez()->gp('password');
  $password_md5=md5($password);
  $T=$G['this']->data()->open('member')->one("`username`='$username' and `password`='$password_md5'");
  !$T && onez()->error('账号或密码不正确');
  onez('cache')->cookie('chat_group',"$T[id]\t$T[username]",0);
  onez()->ok('登录成功',$goto);
}
include_once(dirname(__FILE__).'/header.php');
?>
<link rel="stylesheet" href="<?php echo onez('login')->url?>/php/images/signin.css" />
<link rel="stylesheet" href="<?php echo onez('admin')->url?>/assets/css/font-awesome.min.css">
<style>
body{
  background-image:url(<?php echo $baseurl?>/images/bg.jpg);
}
</style>
<div class="signin">
	<div class="signin-head"><img src="<?php echo $baseurl?>/images/qq.jpg" alt="" class="img-circle"></div>
	<form class="form-signin" method="post" role="form">
    <p class="form-item">
      <i class="fa fa-user"></i>
      <input type="text" name="username" class="form-control" placeholder="登录账号" required autofocus />
    </p>
    <p class="form-item">
      <i class="fa fa-key"></i>
      <input type="password" name="password" class="form-control" placeholder="登录密码" required />
    </p>
		<button class="btn btn-lg btn-warning btn-block" type="submit">登录</button>
    <input type="hidden" name="action" value="chklogin" />
    
    <div class="" style="padding-top: 10px">
      <div class="pull-left">
        <a href="<?php echo onez()->href('/index.php')?>" target="_top">返回首页</a>
      </div>
      <div class="pull-right">
        <a href="<?php echo onez()->href('/register.php?goto='.urlencode($goto))?>">免费注册</a>
      </div>
      <div class="clearfix"></div>
    </div>
	</form>
</div>
<script type="text/javascript">
$(function(){
  $('.form-signin').unbind('submit').bind('submit',function(){
    $.post(window.location.href,$(this).serialize(),function(o){
      if(o.error){
        $('.rndcode-img').trigger('click');
        alert(o.error);
      }else{
        location.href=o.goto;
      }
    },'json');
    return false;
  });
});
</script>
<?php echo $this->get('footer')?>
<?php 
include_once(dirname(__FILE__).'/footer.php');
