<?php
class cls_tab_sys_session extends cls_base_table
{
	private $tab_session;
	private $obj_db;
	//¹¹Ôìº¯Êý
	function __construct()
	{
		global $obj_db;
		parent::__construct();
		$this->obj_db=$obj_db;
		$this->tab_session=DB_PRE."sys_session";
	}
	function on_save($arr_fields=array())
	{
		$arr_return=array("err"=>"");
		if(!isset($arr_fields["session_sid"])) $arr_fields["session_sid"]="";
		$str_sid=$arr_fields["session_sid"];
		unset($arr_fields["session_sid"]);//ÊÍ·Åid
		if($str_sid==""){
			$arr_fields["session_ip"]=get_user_ip();
			$arr_fields["session_addtime"]=TIME;
			$arr_fields["session_sid"]=str_replace("=","",base64_encode(get_user_ip().TIME).rand(1,999));
			$lng_addtime=TIME-86400;
			$str_sql="delete from ".DB_PRE."sys_session where session_addtime<".$lng_addtime;
			$this->obj_db->execute($str_sql);
			parent::on_insert($this->tab_session,$arr_fields);
			$arr_return["sid"]=$arr_fields["session_sid"];
		}else{
			$str_where="session_sid='".mysql_real_escape_string($str_sid)."'";
			parent::on_update($this->tab_session,$arr_fields,$str_where);
			$arr_return["sid"]=$str_sid;
		}
		return $arr_return;
	}

}
?>
