<?php
/*
===========================注册模块控制器
*/
class cls_tab_sys_admin_log extends cls_base_table
{
	function __construct()
	{
		parent::__construct();
	}
	//保存
	function on_save()
	{
		global $obj_ctl_user,$get_act,$obj_db,$get_id;
		$arr_return=array("err"=>"","id"=>0);
		$str_pagename=basename($_SERVER["SCRIPT_FILENAME"]);
		$str_dirname=basename(dirname($_SERVER["SCRIPT_FILENAME"]));
		$str_modelname="";
		if(strlen($str_dirname)>6&&substr($str_dirname,0,5)=="admin"){
			$str_modelname=substr($str_dirname,6);
		}
		if(in_array($str_pagename,array("top.php","menu.php","index.php"))) return $arr_return;
		$str_param="";
		$arr_x=array("theworld_client_delete","login_sid","site_val");
		foreach($_GET as $item=>$key){
			if(in_array($item,$arr_x)) continue;
			if(is_array($key)) $key=implode(",",$key);
			if(strlen($key)>500) $key=format_len($key,300);
			$str_param.=$item."=".$key."<br>";
		}
		foreach($_POST as $item=>$key){
			if(in_array($item,$arr_x)) continue;
			if(is_array($key)) $key=implode(",",$key);
			if(strlen($key)>500) $key=format_len($key,300);
			$str_param.=$item."=".$key."<br>";
		}
		if($str_param==""||$str_param=="NULL"||empty($str_param)){
			return $arr_return;
		}
		$arr_act_not=array("edit","search");
		if(in_array($get_act,$arr_act_not)) return $arr_return;
		$arr_return=array("err"=>"","id"=>0);
		$arr_fields["log_addtime"]=TIME;
		$arr_fields["log_ip"]=get_user_ip();
		$arr_fields["log_user_id"]=$obj_ctl_user->id;
		$arr_fields["log_act"]=$get_act;
		$arr_fields["log_act_param"]=$str_param;
		$arr_fields["log_page"]=$str_pagename;
		$arr_fields["log_modelkey"]=$str_modelname;
		if($get_act==""){
			$lng_time=format_date_int(format_date(TIME,"Y-m-d"));
			$str_sql="select * from ".DB_PRE."sys_admin_log where log_ip='".$arr_fields["log_ip"]."' and log_user_id='".$arr_fields["log_user_id"]."' and log_page='".$arr_fields["log_page"]."' and log_addtime>'".$lng_time."'";
			$obj_result=$obj_db->query($str_sql);
			if(!$obj_rs=$obj_db->fetch_array($obj_result))
			{
				$arr_return=parent::on_insert(DB_PRE."sys_admin_log",$arr_fields);
			}
		}else{
			$arr_return=parent::on_insert(DB_PRE."sys_admin_log",$arr_fields);
		}
		return $arr_return;
	}
	//删除
	function on_del($arr_id,$msg_time1="",$msg_time2="")
	{
		$arr_return=array("err"=>"");
		$str_id=get_arr_id($arr_id);
		if($str_id=="" && $msg_time1=="" && $msg_time2==""){
			$arr_return["err"]="没有指定要删除的记录！";
			return $arr_return;
		}
		$str_where="";
		if(!empty($str_id)){
			$str_where="log_id in(".$str_id.")";
		}else{
			if($msg_time1!="" && is_date($msg_time1)){
				$str_where="log_addtime>='".strtotime($msg_time1)."'";
			}
			if($msg_time2!="" && is_date($msg_time2)){
				if($str_where!=""){
					$str_where.=" and log_addtime>='".strtotime($msg_time1)."'";
				}else{
					$str_where="log_addtime<='".strtotime($msg_time2)."'";
				}
			}
		}
		if($str_where==""){
			$arr_return["err"]="没有指定要删除的记录！";
			return $arr_return;
		}
		$arr_return=parent::on_del(DB_PRE."sys_admin_log",$str_where);
		return $arr_return;
	}

}
?>