statistics.class.php

来自「Phpcms2008 是一款基于 PHP+Mysql 架构的网站内容管理系统」· PHP 代码 · 共 72 行

PHP
72
字号
<?phpclass statistics{	function statistics()	{		$this->__construct();	}		function __construct(){		global $db;		$this->table = DB_PRE.'content';		$this->db =& $db; 	}		function count($userid, $startime = '', $stoptime = '', $catid = '')	{		if(!empty($startime) && !is_numeric($startime))		{			$startime = strtotime($startime." 00:00:00");			$startime = "AND `inputtime` >= '$startime'";		}		elseif (!empty($startime) && is_numeric($startime))		{			$startime = "AND `inputtime` >= '$startime'";		}		if (!empty($stoptime) && !is_numeric($stoptime)) {			$stoptime = strtotime($stoptime.' 23:59:59');			$stoptime = "AND `inputtime` <= '$stoptime'";		}		elseif (!empty($stoptime) && is_numeric($stoptime)) 		{			$stoptime = "AND `inputtime` <= '$stoptime'";		}		if (!empty($catid)) {			$catid = "AND `catid` = '$catid'";		}		$r = $this->db->get_one("SELECT COUNT(contentid) as count FROM ".$this->table." WHERE `userid` = '$userid' $startime $stoptime $catid");		$count = $r['count'];		return $count;	}		function day($userid, $catid = '')	{		return $this->count($userid, date('Y-m-d'), date('Y-m-d'), $catid);	}		function yesterday($userid, $catid = '')	{		$time = date('Y-m-d', TIME-86400);		$startime = strtotime($time." 00:00:00");		$stoptime = strtotime($time." 23:59:59");		return $this->count($userid, $startime, $stoptime, $catid);	}		function week($userid, $catid = '')	{		$stoptime = date('Y-m-d');					$w = date('w', TIME);		if($w == 0) $w = 7;		$w--;		$startime = strtotime(date('Y-m-d', TIME-$w*86400)." 00:00:00");		return $this->count($userid, $startime, $stoptime, $catid);	}		function month($userid, $catid = '')	{		$stoptime = date('Y-m-d');		$startime = strtotime(date('Y-m-0',TIME)." 00:00:00");		return $this->count($userid, $startime, $stoptime, $catid);	}}?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?