<?php
!defined('IN_ONEZ') && exit('Access Denied');
$action=onez()->gp('action');
if($action=='login'){
  $username=onez()->gp('username');
  $password=onez()->gp('password');
  $password_md5=md5($password);
  $T=$G['this']->data()->open('member')->one("`key2`='$username' and `key3`='$password_md5'");
  !$T && onez()->error('账号或密码不正确');
  onez('cache')->cookie($G['this']->cname,"$T[id]\t$T[username]",0);
  onez()->ok('登录成功',$goto);
}elseif($action=='register'){
  $qq=onez()->gp('qq');
  $username=onez()->gp('username');
  $password=onez()->gp('password');
  $password2=onez()->gp('password2');
  $password_md5=md5($password);
  if($password!=$password2){
    onez()->error('两次密码不一致');
  }
  $onez=array();
  $onez['nickname']=$nickname;
  $onez['key8']=$nickname;
  $onez['key9']=$onez['ip']=onez()->ip();
  $onez['key10']=$onez['address']=onez('ip')->init($onez['ip'])->address();
  $onez['qq']=$qq;
  $onez['key2']=$username;
  $G['this']->data()->open('member')->rows("`key2`='$onez[key2]'")>0 && onez()->error('这个账号已经存在，请更换');
  $onez['key3']=$password_md5;
  $onez['key1']='user';
  $userid=$G['this']->data()->open('member')->insert($onez);
  onez('cache')->cookie($G['this']->cname,"$u[userid]\t$username",0);
  onez()->ok('注册成功',$goto);
}
