<?php
if($_POST){
  InitGP(array('S'),'P');
  $username=$S['username'];
  $pass=md5($S['password']);
  $U=DB()->one("users","uid,ismaster,thistime,thisip","username='$username' and password='$pass'");
  !$U && jump('error','用户名或密码不正确',"?a=$a&b=$b");
  $uid=$U['uid'];
  DB()->update('users',array(
    'lasttime'=>$U['thistime'],
    'lastip'=>$U['thisip'],
    'thistime'=>$time,
    'thisip'=>$onlineip,
  ),"uid='$uid'");
  
  $uid=$U['uid'];
  $cookie=StrCode("$uid\t$username\t$U[ismaster]","ENCODE");
  _cookie('users',$cookie);
  !$S['jumpurl'] && $S['jumpurl']='?';
  jump('notice','登录成功',$S['jumpurl']);
}
theme_header();
$ot->borderA('#content2','box2');
$ot->addhead('用户登录');
$ot->addinput('用户名','username','','text',1,"");
$ot->addinput('密码','password','','password',1,"");
$ot->addinput('','jumpurl',$_GET['jumpurl'],'hidden',1,"");
$ot->setform('登录');
$ot->borderB(1);
$ot->flush();
theme_footer();
?>
</div>