⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pcstat.php

📁 KBS的BBS源码
💻 PHP
📖 第 1 页 / 共 2 页
字号:
function getLastUpdates($link,$userNum=0){	$userNum = intval( $userNum );	if(!$userNum) $userNum = 10;	$query = "SELECT username , corpusname , description FROM users WHERE createtime != modifytime AND pctype < 2 ORDER BY modifytime DESC LIMIT 0,".intval($userNum).";";	$result = mysql_query($query,$link);	$lastUpdates = array();	while($rows = mysql_fetch_array($result))		$lastUpdates[] = $rows;	mysql_free_result($result);	return $lastUpdates;}function getUsersCnt($link){	$query = "SELECT COUNT(*) FROM users;";	$result = mysql_query($query);	$rows = mysql_fetch_row($result);	mysql_free_result($result);	return $rows[0];}	function getNodesCnt($link){	$query = "SELECT COUNT(*) FROM nodes WHERE type != 1;";	$result = mysql_query($query);	$rows = mysql_fetch_row($result);	mysql_free_result($result);	return $rows[0];}function getCommentsCnt($link){	$query = "SELECT COUNT(*) FROM comments;";	$result = mysql_query($query);	$rows = mysql_fetch_row($result);	mysql_free_result($result);	return $rows[0];}function getHotUsersByPeriod($link,$period,$num=10){	$num = intval( $num );	if($period=="day")		$queryTime = time () - 24*3600;	elseif($period=="month")		$queryTime = time () - 30*24*3600;	else		$queryTime = 0;		if($queryTime)	    $query = "SELECT COUNT(pri_id) , uid , users.username , corpusname , description ".	             "FROM logs , users ".	             "WHERE ".//ACTION LIKE '%\'s Blog(www)' ".	             "       pri_id = users.username ".	             "      AND logtime > FROM_UNIXTIME(".$queryTime.")".	             "      AND pctype < 2 ".		     "GROUP BY pri_id ".		     "ORDER BY 1 DESC ".		     "LIMIT 0 , ".$num." ;";	else	    $query = "SELECT corpusname , uid , username , description ".	    	     "FROM users WHERE pctype < 2 ORDER BY visitcount DESC LIMIT 0 , ".$num." ;";	$result = mysql_query($query,$link);	$users = array();	while($rows = mysql_fetch_array($result))		$users[] = $rows;		mysql_free_result($result);	return $users;	}function getScoreTopUsers($link, $num=10){	$query = "SELECT `corpusname`,`uid`,`username`,`description` FROM `users` WHERE `pctype`<2 ORDER BY `score` DESC LIMIT 0,{$num}";	$result = mysql_query($query, $link);	$users = array();	while($rows = mysql_fetch_array($result))		$users[] = $rows;	mysql_free_result($result);	return $users;}function getHotNodesByPeriod($link,$period,$num=10){	$num = intval( $num );	if($period=="day")		$queryTime = time () - 24*3600;	elseif($period=="month")		$queryTime = time () - 30*24*3600;	else		$queryTime = 0;	// kxn: 这里需要判断一下,如果是没有时间限制的,那么应该强制 nodes 使用 visitcount 做索引,	//      如果有时间限制的话,就不要去动他,用时间限制做主  key , 效果会好	$nodesindex = $queryTime == 0 ? " use index(visitcount) " : "";			$query = "SELECT nodes.uid , nid , subject ".		 "FROM nodes ".$nodesindex.",users ".		 "WHERE access = 0 ".		 "   AND nodes.uid = users.uid ".		 "   AND nodetype = 0 ".		 "   AND pctype < 4 ";		if($queryTime)	$query.= " AND created > FROM_UNIXTIME(".$queryTime . ")";	//$query.= "GROUP BY uid ";	$query.= "ORDER BY nodes.visitcount DESC ".		 "LIMIT 0 , ".$num." ;";	$result = mysql_query($query,$link);	$nodes = array();	while($rows = mysql_fetch_array($result))		$nodes[] = $rows;		mysql_free_result($result);	return $nodes;	}function getHotTopicsByPeriod($link,$period,$num=10){	$num = intval( $num );	if($period=="day")		$queryTime = time () - 24*3600;	elseif($period=="month")		$queryTime = time () - 30*24*3600;	else		$queryTime = 0;		$query =  "SELECT COUNT(nid) , topics.tid , topics.uid , topicname , username ".	          "FROM topics , nodes , users ".		  "WHERE topics.access = 0 ".		  "      AND topics.uid = users.uid ".		  "      AND topics.tid = nodes.tid ".		  "      AND nodetype = 0 ".		  "      AND pctype < 4 ";	if($queryTime)	$query.=  "      AND nodes.created > FROM_UNIXTIME(".$queryTime.")";	$query.=  "GROUP BY nodes.tid ".		  "ORDER BY 1 DESC ".		  "LIMIT 0 , ".$num." ;";        $result = mysql_query( $query , $link );        $topics = array();        while( $rows = mysql_fetch_array( $result ))               $topics[] = $rows;        mysql_free_result($result);        return $topics;}function getPcAnnounce($link,$num=5){	global $pcconfig;	$num = intval($num);	$query = "SELECT users.uid , subject , nid FROM nodes ,users WHERE access = 0 AND nodes.uid = users.uid AND username = '".$pcconfig["ADMIN"]."' ORDER BY nid DESC LIMIT 0 , " . $num . ";";	$result = mysql_query($query,$link);	$anns = array();	while($rows = mysql_fetch_array($result))		$anns[] = $rows;	mysql_free_result($result);	return $anns;}function getHotNodes($link,$type,$timeLong=259200,$num=20){	$timeLong = intval($timeLong);	$num = intval($num);		if("comments" == $type)		$query = "SELECT nid , subject , nodes.uid FROM nodes,users WHERE nodes.uid = users.uid AND nodetype = 0 AND pctype < 4 AND access = 0 AND type = 0 AND recommend != 2 AND created > FROM_UNIXTIME(".(time()-  $timeLong ).") ORDER BY commentcount DESC , nid DESC LIMIT 0 , ".$num.";";	elseif("trackbacks" == $type)		$query = "SELECT nid , subject , nodes.uid FROM nodes,users WHERE nodes.uid = users.uid AND nodetype = 0 AND pctype < 4 AND access = 0 AND type = 0 AND recommend != 2 AND created > FROM_UNIXTIME(".(time()-  $timeLong ).") AND trackbackcount != 0 ORDER BY trackbackcount DESC , nid DESC LIMIT 0 , ".$num.";";	else		$query = "SELECT nid , subject , nodes.uid  FROM nodes,users WHERE nodes.uid = users.uid AND nodetype = 0 AND pctype < 4 AND access = 0 AND type = 0 AND recommend != 2 AND created > FROM_UNIXTIME(".(time()- $timeLong ).") AND nodes.visitcount != 0 ORDER BY nodes.visitcount DESC , nid DESC LIMIT 0 , ".$num.";";		$result = mysql_query($query,$link);		$nodes = array();	while($rows = mysql_fetch_array($result))		$nodes[] = $rows;	mysql_free_result($result);	return $nodes;}function getRecommendNodesByTopic($link,$topic,&$nodes){    global $pcconfig;    if (!$topic || !$pcconfig["SECTION"][$topic])        return false;    $nodes = array();        $query = 'SELECT * FROM recommend WHERE topic = \''.addslashes($topic).'\' ORDER BY state DESC , rid DESC LIMIT 0 , 10;';    $result = mysql_query($query,$link);    if (!mysql_num_rows($result))        return false;    while($rows=mysql_fetch_array($result))        $nodes[] = $rows;    mysql_free_result($result);    return true;}function getSectionHotNodes($link,$section,$timeLong,$num){    global $pcconfig;    if (!$section || !$pcconfig["SECTION"][$section])        return false;        $query = "SELECT nodes.uid , nid , subject , username , corpusname  ".             " FROM nodes use index(created) ,users ".             " WHERE nodes.uid = users.uid ".             "   AND nodetype = 0 ".             "   AND pctype <= 4 ".             "   AND access = 0 ".             "   AND type = 0 ".             "   AND recommend != 2 ".             "   AND nodes.theme = '".addslashes($section)."'".             "   AND created > FROM_UNIXTIME(".(time()- $timeLong ).")".             "   AND nodes.visitcount != 0 ".             " ORDER BY nodes.visitcount DESC , nid DESC ".             " LIMIT 0 , ".intval($num).";";    $result = mysql_query($query,$link);	    if (mysql_num_rows($result)==0)	    return false;	$nodes = array();	while($rows = mysql_fetch_array($result))		$nodes[] = $rows;	mysql_free_result($result);	return $nodes;}?>

⌨️ 快捷键说明

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