<?php
// Subroutine: validate.php
// Xinfeng Chen, 2002.11.12
// require: class CUser
// input: $f_user, $f_pass, $f_savepass

$f_pass=stripslashes($f_pass);
$_user=$f_user; $_pass=md5($f_pass); $_savepass=$f_savepass;

$sv_user='';
$_ou=new CUser;

if($_user==$admname){
 if($_pass==$admpass){
  $sv_user=$admname;
  $_savepass=false;
  if(!$_ou->load($_user)){$_ou->name=$sv_user;}
 }
}elseif($_ou->load($_user)){
 if($_pass==$_ou->password){
  $sv_user=$_ou->name;
 }
}

if($sv_user){
 $_ou->lasttime=$dtime; $_ou->store($sv_user);
}

if($_savepass){
 setcookie('ck_user', $f_user, time()+3600*24*30);
 setcookie('ck_pass', $f_pass, time()+3600*24*30);
}else{
 setcookie('ck_user', '');
 setcookie('ck_pass', '');
}

$HTTP_SESSION_VARS['sv_user']=$sv_user;

?>