<?php
Function checkuserlogin(){ //检测用户是否登录
    global $tablepre;
	$username=get_cookie('username');
    If ($username!=""){
        $sql="select clubuser_name,clubuser_password,bbsmanager from {$tablepre}clubuser where clubuser_name='".$username."'";
        $rs=mysql_query($sql);
        $row = mysql_fetch_array($rs);
        $rsnum= mysql_num_rows($rs);
		mysql_free_result($rs);
        if ($rsnum==0){
            $userlogin="N";
			}
        else{
            If ($row[1]=base64_decode((get_cookie('clubuser_password')))){
               $userlogin="Y";
			   set_cookie('bz',$row[2],time()+3600);
			   }
            Else{
               $userlogin="N";
            }
        }
		//$db->close(); 
      }
    else{
        $userlogin="N";
    } 
	return $userlogin;
}
?>