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

📄 sort.php

📁 很好的一套PHP树形论坛程序
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php
$wind_in='st';
require_once('global.php');
require_once(R_P.'require/header.php');
$groupid=='guest'&&	Showmsg('not_login');
!$gp_allowsort && Showmsg('sort_group_right');

$per=24;
$cachenum=20;
$cachetime='';

if(empty($action)){
	@include_once(D_P.'data/bbscache/olcache.php');
	$usertotal=$guestinbbs+$userinbbs;
	$bbsinfo=$db->get_one("SELECT * FROM pw_bbsinfo WHERE id=1");
	$bbsinfo['higholtime']=get_date($bbsinfo['higholtime']);
	$rs=$db->get_one("SELECT SUM(fd.topic) as topic,SUM(fd.subtopic) as subtopic,SUM(fd.article) as article,SUM(fd.tpost) as tposts FROM pw_forums f LEFT JOIN pw_forumdata fd USING(fid) WHERE f.ifsub='0' AND f.cms!='1'");
	$topic=$rs['topic']+$rs['subtopic'];
	$article=$rs['article'];
	$tposts=$rs['tposts'];
	if($bbsinfo['tdtcontrol']!=$tdtime){
		if($db_hostweb == 1){
			$db->update("UPDATE pw_bbsinfo SET yposts='$tposts',tdtcontrol='$tdtime' WHERE id=1");
			$db->update("UPDATE pw_forumdata SET tpost=0 WHERE tpost<>'0'");
		}
		if(file_exists(D_P.'data/bbscache/ip_cache.php')){
			P_unlink(D_P.'data/bbscache/ip_cache.php');
		}
	}
	require PrintEot('sort');footer();
} elseif($action=='ipstate'){
	!$type && $type='month';
	if($type=='month'){
		$c_month=date('Y-n');
		$c_year=is_numeric($year) ? $year : date('Y');
		$p_year=$c_year-1;
		$n_year=$c_year+1;
		$summip=0;
		$m_ipdb=array();
		$query=$db->query("SELECT month,sum(nums) as nums FROM pw_ipstates WHERE month like '$c_year%' group by month");
		while($rt=$db->fetch_array($query)){
			$summip+=$rt['nums'];
			$key=substr($rt['month'],strrpos($rt['month'],'-')+1);
			$rt['_month'] = str_replace('-','_',$rt['month']);
			$m_ipdb[$key]=$rt;
		}
		for($i=1;$i<=12;$i++){
			!$m_ipdb[$i] && $m_ipdb[$i]=array('month'=>$c_year.'-'.$i,'_month'=>$c_year.'_'.$i,'nums'=>'0');
		}
		ksort($m_ipdb);
	}elseif($type=='day'){
		$c_month=$month ? str_replace('_','-',$month) : date('Y-n');
		list($Y,$M)=explode('-',$c_month);
		if(!is_numeric($Y) || !is_numeric($M)){
			Showmsg('undefined_action');
		}
		if($M==1){
			$p_month=($Y-1).'_12';
			$n_month=$Y.'_2';
		}elseif($M==12){
			$p_month=$Y.'_11';
			$n_month=($Y+1).'_1';
		}else{
			$p_month=$Y.'_'.($M-1);
			$n_month=$Y.'_'.($M+1);
		}
		$sumip=0;
		$d_ipdb=array();
		$query=$db->query("SELECT day,nums FROM pw_ipstates WHERE month='$c_month' ORDER BY day");
		while($rt=$db->fetch_array($query)){
			$sumip+=$rt['nums'];
			$key=substr($rt['day'],strrpos($rt['day'],'-')+1);
			$d_ipdb[$key]=$rt;
		}
		for($i=1;$i<=date('t',strtotime($c_month.'-1'));$i++){
			!$d_ipdb[$i] && $d_ipdb[$i]=array('day'=>"$c_month-$i",'nums'=>'0');
		}
		ksort($d_ipdb);
	}
	require PrintEot('sort');footer();
} elseif($action=='online'){
	require_once(R_P.'require/forum.php');
	require_once(D_P.'data/bbscache/forum_cache.php');
	require_once(D_P.'data/bbscache/level.php');
	$ltitle['-1']='Member';
	$onlinedb=openfile(D_P.'data/bbscache/online.php');
	if(count($onlinedb)==1){
		$onlinedb=array();
	} else{
		unset($onlinedb[0]);
	}
	$online_A=$guest_A=array();
	foreach($onlinedb as $online){
		if(trim($online)){
			$detail=explode("\t",$online);
			$online_A[$online]=$detail[1];
		}
	}
	unset($onlinedb);
	@asort($online_A);
	$online_A=@array_keys($online_A);

	$guestdb=openfile(D_P.'data/bbscache/guest.php');
	if(count($guestdb)==1){
		$guestdb=array();
	} else{
		unset($guestdb[0]);
	}
	foreach($guestdb as $online){
		if(trim($online)){
			$detail=explode("\t",$online);
			$guest_A[$online]=$detail[1];
		}
	}
	unset($guestdb);
	@asort($guest_A);
	$guest_A=@array_keys($guest_A);
	$online_A = array_merge ($online_A, $guest_A);
	unset($guest_A);
	$count=count($online_A);
	if(!is_numeric($page) || $page<1){
		$page=1;
	}
	$numofpage=$count%$db_perpage==0 ? floor($count/$db_perpage) : floor($count/$db_perpage)+1;
	$numofpage && $page>$numofpage && $page=$numofpage;
	$pages=numofpage($count,$page,$numofpage,"sort.php?action=online&");
	$start=($page-1)*$db_perpage;
	$end=min($start+$db_perpage,$count);

	$threaddb=array();
	for($i=$start;$i<$end;$i++){
		if(!$online_A[$i]) continue;
		$thread=explode("\t",$online_A[$i]);
		if(count($thread)<10){
			$thread['username']='Guest';
			$thread['ip']=$windid!=$manager ? "-" : $thread[0];
			$thread['group']='Guest';
			$thread['action']=$thread[4];
			$thread['lasttime']=$thread[5];
			$thread[2]=str_replace('<FiD>','',$thread[2]);
			$forum[$thread[2]]['name'] && $thread['forum']="<a href='index.php?fid=$thread[2]'>".$forum[$thread[2]]['name']."</a>";
			$thread['atc']=$thread[3];
		} else{
			$thread['username']=$thread[0];
			$thread['ip']=$windid!=$manager ? "-" : $thread[2];
			$thread['group']=$ltitle[$thread[5]];
			$thread['action']=$thread[6];
			$thread['lasttime']=$thread[7];
			$forum[$thread[3]]['name'] && $thread['forum']="<a href='index.php?fid=$thread[3]'>".$forum[$thread[3]]['name']."</a>";
			$thread['atc']=$thread[4];
		}
		$threaddb[]=$thread;
	}
	require_once(PrintEot('sort'));footer();
} elseif($action=='member'){
	@set_time_limit(0);
	list($db_moneyname,$db_moneyunit,$db_rvrcname,$db_rvrcunit,$db_creditname,$db_creditunit)=explode("\t",$db_credits);
	$cachetime=@filemtime(D_P."data/bbscache/member_sort.php");
	if(!$per || !file_exists(D_P."data/bbscache/member_sort.php") || ($timestamp-$cachetime>$per*3600)){
		
		if(!$type){
			$_SORTDB=$_sort=array();
			$query=$db->query("SELECT m.uid,m.username,md.postnum FROM pw_memberdata md LEFT JOIN pw_members m USING(uid) ORDER BY md.postnum DESC LIMIT $cachenum");
			while($memdb=$db->fetch_array($query)){
				if($memdb['postnum']){
					$_sort[]=$memdb;
				}
			}
			$_SORTDB['post']=$_sort;
			writeover(D_P.'data/bbscache/member_tmp.php',"<?php\r\n\$_SORTDB=".vvar_export($_SORTDB).";\r\n?>");
			refreshto("sort.php?action=member&type=digests",'update_cache');
		} elseif($type=='digests'){
			include(D_P."data/bbscache/member_tmp.php");
			$_sort=array();
			$query=$db->query("SELECT m.uid,m.username,md.digests FROM pw_memberdata md LEFT JOIN pw_members m USING(uid) ORDER BY md.digests DESC LIMIT $cachenum");
			while($memdb=$db->fetch_array($query)){
				if($memdb['digests']){
					$_sort[]=$memdb;
				}
			}
			$_SORTDB['digests']=$_sort;
			writeover(D_P.'data/bbscache/member_tmp.php',"<?php\r\n\$_SORTDB=".vvar_export($_SORTDB).";\r\n?>");
			refreshto("sort.php?action=member&type=tpost",'update_cache');
		} elseif($type=='tpost'){
			include(D_P."data/bbscache/member_tmp.php");
			$_sort=array();
			$query=$db->query("SELECT m.uid,m.username,md.todaypost FROM pw_memberdata md LEFT JOIN pw_members m USING(uid) WHERE md.lastpost>'$tdtime' ORDER BY md.todaypost DESC LIMIT $cachenum");
			while($memdb=$db->fetch_array($query)){
				if($memdb['todaypost']){
					$_sort[]=$memdb;
				}
			}
			$_SORTDB['tpost']=$_sort;
			writeover(D_P.'data/bbscache/member_tmp.php',"<?php\r\n\$_SORTDB=".vvar_export($_SORTDB).";\r\n?>");
			refreshto("sort.php?action=member&type=rvrc",'update_cache');
		} elseif($type=='rvrc'){
			include(D_P."data/bbscache/member_tmp.php");
			$_sort=array();
			$query=$db->query("SELECT m.uid,m.username,md.rvrc FROM pw_memberdata md LEFT JOIN pw_members m USING(uid) ORDER BY md.rvrc DESC LIMIT $cachenum");
			while($memdb=$db->fetch_array($query)){
				$memdb['rvrc']=floor($memdb['rvrc']/10);
				if($memdb['rvrc']){
					$_sort[]=$memdb;
				}
			}
			$_SORTDB['rvrc']=$_sort;
			writeover(D_P.'data/bbscache/member_tmp.php',"<?php\r\n\$_SORTDB=".vvar_export($_SORTDB).";\r\n?>");
			refreshto("sort.php?action=member&type=money",'update_cache');
		} elseif($type=='money'){

⌨️ 快捷键说明

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