花魁直播高品质美女在线视频互动社区 - 花魁直播官方版

 歡迎來到素材無憂網(wǎng),按 + 收藏我們
登錄 注冊 退出 找回密碼

帝國cms實現(xiàn)文章點擊月、周、日排行效果方法

時間: 2019-05-28 10:09 閱讀: 作者:素材無憂網(wǎng)

在模型管理增加相應3個字段,分別是:DayHits WeekHits MonthHits 這3個字段全部在主表,int類型字段

再增加 ConditionHits 字段,為文本型,同樣在主表 注意大小寫

$time=mktime(0,0,0,8,5,2010);//設置日期為2010年8月5號
$wzid=35;//文章ID35
$Week=date("w",$time);//今天星期幾
$Number=date("j",$time);//今天幾號
$Month=date("m",$time);//今天是幾月
$Years=date("Y",$time);//今天那年
$d=cal_days_in_month(CAL_GREGORIAN,$Month,$Years);//去得本月總天數(shù)
$Week_r=$Number-$Week;//本周日是幾號
if($Week_r<1){$Week_r=cal_days_in_month(CAL_GREGORIAN,$Month-1,$Years)+$Week_r;}
$Week_l=$Number+7-$Week-1;//本周六是幾號
if($Week_l>$d){$Week_l=$Week_l-$d;}
$newsrs=$empire->fetch1("select ConditionHits from {$dbtbpre}ecms_news where `id`={$wzid}");
$DayHitstime_k=mktime(0,0,0,date("m",$time),$Number,date("Y",$time));
$DayHitstime_j=$DayHitstime_k+86400;
if(empty($newsrs['ConditionHits'])){//判斷月、周、日點擊條件是否為空,如果為空,初始值
$empire->query("UPDATE `{$dbtbpre}ecms_news` SET `ConditionHits`='".$Number."|".$Week_r."-".$Week_l."|".$Month."',`DayHits`=1,`WeekHits`=1,`MonthHits`=1 WHERE `id`={$wzid}");
}else{
$Daytj=explode("|",$newsrs['ConditionHits']);
print_r($Daytj);
if($newsrs['ConditionHits']!="".$Number."|".$Week_r."-".$Week_l."|".$Month.""){
if((int)$Daytj[0]!=$Number){
$empire->query("UPDATE `{$dbtbpre}ecms_news` SET `ConditionHits`='".$Number."|".$Daytj[1]."|".$Daytj[2]."',`DayHits`=0 WHERE `id`={$wzid}");
}
if($Daytj[1]!="".$Week_r."-".$Week_l.""){
$empire->query("UPDATE `{$dbtbpre}ecms_news` SET `ConditionHits`='".$Daytj[0]."|".$Week_r."-".$Week_l."|".$Daytj[2]."',`WeekHits`=0 WHERE `id`={$wzid}");
}
if((int)$Daytj[2]!=(int)$Month){
$empire->query("UPDATE `{$dbtbpre}ecms_news` SET `ConditionHits`='".$Daytj[0]."|".$Daytj[1]."|".$Month."',`MonthHits`=0 WHERE `id`={$wzid}");
}
}else{
if((int)$Daytj[0]==$Number){
$empire->query("UPDATE `{$dbtbpre}ecms_news` SET `DayHits`=DayHits+1 WHERE `id`={$wzid}");//今日點擊+1
}
if($Daytj[1]==$Week_r."-".$Week_l){
$empire->query("UPDATE `{$dbtbpre}ecms_news` SET `WeekHits`=WeekHits+1 WHERE `id`={$wzid}");//本周點擊+1
}
if((int)$Daytj[2]==(int)$Month){
$empire->query("UPDATE `{$dbtbpre}ecms_news` SET `MonthHits`=MonthHits+1 WHERE `id`={$wzid}");//本月點擊+1
}
}
}

版權聲明: 本站資源均來自互聯(lián)網(wǎng)或會員發(fā)布,如果侵犯了您的權益請與我們聯(lián)系,我們將在24小時內(nèi)刪除!謝謝!

轉載請注明: 帝國cms實現(xiàn)文章點擊月、周、日排行效果方法

標簽:  
相關文章
模板推薦