帝國CMS自定義標簽每月月份發布文章數的統計
發布時間:2019-10-12 來源:未知 瀏覽: 關鍵詞:
兼容帝國原來的使用方法即網站信息統計標簽[totaldata]使用方法一樣 只是時間上0為所有時間不限制、1為今日、2為本月、3為本年(11表示本年1月,12表示本年二月,...,22表示本年12月) ,注意4-10不能用,否則出錯。22以上的數字不予統計即全部為0
1、把下面的代碼復制粘帖到e/class/userfun.php中<?php和?>間
//---------------------------自定義一個統計標簽,兼容帝國原來的使用方法
//修改后的信息統計。$day參數11表示本年1月,12表示本年二月,...,22表示本年12月
function user_TotalData1($classid,$enews=0,$day=0,$totaltype=0){
global $empire,$class_r,$class_zr,$dbtbpre,$fun_r,$class_tr;
if(empty($classid))
{
return "";
}
//統計類型
if($totaltype==1)//評論數
{
$totalfield='sum(plnum) as total';
}
elseif($totaltype==2)//點擊數
{
$totalfield='sum(onclick) as total';
}
elseif($totaltype==3)//下載數
{
$totalfield='sum(totaldown) as total';
}
else//信息數
{
$totalfield='count(*) as total';
}
if($day)
{
if($day==1)//今日信息
{
$date=date("Y-m-d");
$starttime=$date." 00:00:01";
$endtime=$date." 23:59:59";
}
elseif($day==2)//本月信息
{
$date=date("Y-m");
$starttime=$date."-01 00:00:01";
$endtime=$date."-".date("t")." 23:59:59";
}
elseif($day==3)//本年信息
{
$date=date("Y");
$starttime=$date."-01-01 00:00:01";
$endtime=($date+1)."-01-01 00:00:01";
}
elseif($day>10)//本年某月信息
{
$yue=$day-10;
$date=date("Y");
$starttime=$date."-".$yue."-01 00:00:01";
if($yue==12){$endtime=$date."-".$yue."-31 23:59:59";}else{$endtime=$date."-".($yue+1)."-01 00:00:01";}
}
$and=" and newstime>=".to_time($starttime)." and newstime<=".to_time($endtime);
}
if($enews==1)//統計標題分類
{
if(empty($class_tr[$classid][tbname]))
{
echo $fun_r['BqErrorTtid']."=<b>".$classid."</b>".$fun_r['BqErrorNtb'];
return "";
}
$query="select ".$totalfield." from {$dbtbpre}ecms_".$class_tr[$classid][tbname]." where ttid='$classid'".$and;
}
elseif($enews==2)//統計數據表
{
$query="select ".$totalfield." from {$dbtbpre}ecms_".$classid.(empty($and)?'':' where '.substr($and,5));
}
else//統計欄目數據
{
if(empty($class_r[$classid][tbname]))
{
echo $fun_r['BqErrorCid']."=<b>".$classid."</b>".$fun_r['BqErrorNtb'];
return "";
}
if($class_r[$classid][islast])//終極欄目
{
$where="classid='$classid'";
}
else//大欄目
{
$where=ReturnClass($class_r[$classid][sonclass]);
}
$query="select ".$totalfield." from {$dbtbpre}ecms_".$class_r[$classid][tbname]." where ".$where.$and;
}
$num=$empire->gettotal($query);
echo $num;
}
?>
2、新建標簽代碼
后臺-模板-標簽-標簽管理-增加標簽-增加內容如下:
標簽名:每月信息統計
標簽符號:TotalData1
所屬類別:
函數名:user_TotalData1
標簽格式:[totaldata]欄目ID,操作類型,時間范圍,統計類型[/totaldata]
標簽說明:
操作類型說明:
操作類型 內容
0 統計欄目數據
1 統計標題分類
2 統計數據表
時間范圍:0為不限;1為今日;2為本月;3為本年。
統計類型:0為統計信息數;1為統計評論數;2為統計點擊數;3為統計下載數。
如果操作類型是“統計數據表”,欄目ID='數據表名'
[totaldata]欄目ID,操作類型,時間范圍,統計類型[/totaldata]
新聞統計
[totaldata]2,0,3,0[/totaldata]
1、把下面的代碼復制粘帖到e/class/userfun.php中<?php和?>間
//---------------------------自定義一個統計標簽,兼容帝國原來的使用方法
//修改后的信息統計。$day參數11表示本年1月,12表示本年二月,...,22表示本年12月
function user_TotalData1($classid,$enews=0,$day=0,$totaltype=0){
global $empire,$class_r,$class_zr,$dbtbpre,$fun_r,$class_tr;
if(empty($classid))
{
return "";
}
//統計類型
if($totaltype==1)//評論數
{
$totalfield='sum(plnum) as total';
}
elseif($totaltype==2)//點擊數
{
$totalfield='sum(onclick) as total';
}
elseif($totaltype==3)//下載數
{
$totalfield='sum(totaldown) as total';
}
else//信息數
{
$totalfield='count(*) as total';
}
if($day)
{
if($day==1)//今日信息
{
$date=date("Y-m-d");
$starttime=$date." 00:00:01";
$endtime=$date." 23:59:59";
}
elseif($day==2)//本月信息
{
$date=date("Y-m");
$starttime=$date."-01 00:00:01";
$endtime=$date."-".date("t")." 23:59:59";
}
elseif($day==3)//本年信息
{
$date=date("Y");
$starttime=$date."-01-01 00:00:01";
$endtime=($date+1)."-01-01 00:00:01";
}
elseif($day>10)//本年某月信息
{
$yue=$day-10;
$date=date("Y");
$starttime=$date."-".$yue."-01 00:00:01";
if($yue==12){$endtime=$date."-".$yue."-31 23:59:59";}else{$endtime=$date."-".($yue+1)."-01 00:00:01";}
}
$and=" and newstime>=".to_time($starttime)." and newstime<=".to_time($endtime);
}
if($enews==1)//統計標題分類
{
if(empty($class_tr[$classid][tbname]))
{
echo $fun_r['BqErrorTtid']."=<b>".$classid."</b>".$fun_r['BqErrorNtb'];
return "";
}
$query="select ".$totalfield." from {$dbtbpre}ecms_".$class_tr[$classid][tbname]." where ttid='$classid'".$and;
}
elseif($enews==2)//統計數據表
{
$query="select ".$totalfield." from {$dbtbpre}ecms_".$classid.(empty($and)?'':' where '.substr($and,5));
}
else//統計欄目數據
{
if(empty($class_r[$classid][tbname]))
{
echo $fun_r['BqErrorCid']."=<b>".$classid."</b>".$fun_r['BqErrorNtb'];
return "";
}
if($class_r[$classid][islast])//終極欄目
{
$where="classid='$classid'";
}
else//大欄目
{
$where=ReturnClass($class_r[$classid][sonclass]);
}
$query="select ".$totalfield." from {$dbtbpre}ecms_".$class_r[$classid][tbname]." where ".$where.$and;
}
$num=$empire->gettotal($query);
echo $num;
}
?>
2、新建標簽代碼
后臺-模板-標簽-標簽管理-增加標簽-增加內容如下:
標簽名:每月信息統計
標簽符號:TotalData1
所屬類別:
函數名:user_TotalData1
標簽格式:[totaldata]欄目ID,操作類型,時間范圍,統計類型[/totaldata]
標簽說明:
操作類型說明:
操作類型 內容
0 統計欄目數據
1 統計標題分類
2 統計數據表
時間范圍:0為不限;1為今日;2為本月;3為本年。
統計類型:0為統計信息數;1為統計評論數;2為統計點擊數;3為統計下載數。
如果操作類型是“統計數據表”,欄目ID='數據表名'
[totaldata]欄目ID,操作類型,時間范圍,統計類型[/totaldata]
新聞統計
[totaldata]2,0,3,0[/totaldata]
責任編輯:實速科技