此功能已有插件,插件更好用:https://www.moyublog.com/notes/1142.html
當(dāng)一個(gè)站大量采集信息,一次發(fā)布不利于長(zhǎng)期SEO,所以從網(wǎng)上找了這個(gè)腳本稍作修改。分享給大家,其實(shí)也很簡(jiǎn)單,但比帝國(guó)自帶的計(jì)劃任務(wù)功能好的是,不用開(kāi)啟后臺(tái)才運(yùn)行,腳本放到服務(wù)器上后加入服務(wù)器的計(jì)劃任務(wù)便可以每天定時(shí)審核發(fā)布信息。
query ( "SELECT classid,islast from {$dbtbpre}enewsclass where $where" );
$class = array ();
$pclass = array ();
while ( $r = $empire->fetch ( $class_list ) ) {
?? ?if ($r ['islast'] == '0') {
?? ??? ?array_push ( $pclass, $r ['classid'] );
?? ??? ?// 非終極欄目不可以發(fā)不信息,所以不參與信息審核
?? ?} else {
?? ??? ?array_push ( $class, $r ['classid'] );
?? ?}
}
foreach ( $class as $key => $val ) {
?? ?ecmscheck ( $val, $news_table, $news_num );
?? ?// 審核} ?// 刷新非終極欄目
?? ?foreach ( $pclass as $key => $value ) {
?? ??? ?echo '上級(jí)欄目'.$value.'已經(jīng)更新
';
?? ??? ?ReListHtml ( $value, 1 );
?? ?}
?? ?ReIndex();
?? ?//刷新首頁(yè) ?
?? ?/*** * @param ?$classid* @param ?$table* @param ?$num*/
?? ?function ecmscheck($classid, $table, $num) {
?? ??? ?global $empire, $class_r, $dbtbpre;
?? ??? ?$time = time ();
?? ??? ?// 每周一審核的設(shè)置為推薦
?? ??? ?$isgood = '0';
?? ??? ?$day = strftime ( "%A" );
?? ??? ?if ($day == 'Monday') {
?? ??? ??? ?$isgood = '1';
?? ??? ?}
?? ??? ?$res = $empire->query ( "select id from {$dbtbpre}ecms_" . $table . "_check where classid =" . $classid . " ORDER BY `truetime` ASC LIMIT {$num}" );
?? ??? ?while ( $r = $empire->fetch ( $res ) ) {
?? ??? ??? ?$data [] = $r ['id'];
?? ??? ?}
?? ??? ?CheckNews_auto ( $classid, $data );
?? ?}
?? ?/*** 審核信息* @param ?$classid* @param ?$id*/
?? ?function CheckNews_auto($classid, $id) {
?? ??? ?global $empire, $class_r, $dbtbpre, $emod_r, $adddatar;
?? ??? ?$classid = ( int ) $classid;
?? ??? ?$count = count ( $id );
?? ??? ?$time = time();
?? ??? ?//每周一審核的設(shè)置為推薦
?? ??? ?$isgood = strftime('%A') == 'Monday'?1:0;
?? ??? ?for ($i = 0; $i < $count; $i ++) {
?? ??? ??? ?$infoid = ( int ) $id [$i];
?? ??? ??? ?$infor = $empire->fetch1 ( "select * from {$dbtbpre}ecms_" . $class_r [$classid] [tbname] . "_check where id='$infoid' limit 1" );
?? ??? ??? ?//$picurl = empty($infor['titlepic'])?'/images/smallpic/'.rand(1,300).'.jpg':$infor['titlepic'];?
?? ??? ??? ?//為了網(wǎng)站能好看點(diǎn)設(shè)置一個(gè)1-300的隨機(jī)圖片
?? ??? ??? ?$res = $empire->query("update {$dbtbpre}ecms_".$class_r[$classid][tbname]."_check set truetime='$time',newstime='$time',lastdotime='$time',isgood='$isgood' where id='$infoid' limit 1");
?? ??? ??? ?$sql = $empire->query ( "update {$dbtbpre}ecms_" . $class_r [$classid] [tbname] . "_index set checked=1,truetime='$time',newstime='$time',lastdotime='$time' where id='$infoid'" );
?? ??? ??? ?// 未審核表轉(zhuǎn)換
?? ??? ??? ?MoveCheckInfoData ( $class_r [$classid] [tbname], 0, $infor ['stb'], "id='$infoid'" );
?? ??? ??? ?// 更新欄目信息數(shù)
?? ??? ??? ?AddClassInfos ( $infor ['classid'], '', '+1' );
?? ??? ??? ?// 刷新信息
?? ??? ??? ?GetHtml ( $infor ['classid'], $infor ['id'], $infor, 0 );
?? ??? ??? ?echo '信息 '.$infor ['id'].' 內(nèi)容頁(yè)已經(jīng)更新
';
?? ??? ??? ?// 刷新列表
?? ??? ??? ?ReListHtml ( $infor ['classid'], 1 );
?? ??? ??? ?echo '終極欄目 '.$infor ['classid'].' 已經(jīng)更新
';
?? ??? ?}
?? ?}
?? ?//刷新首頁(yè)function ReIndex(){
?? ?$indextemp=GetIndextemp();
?? ?//取得模板
?? ?NewsBq($classid,$indextemp,1,0);
?? ?echo '首頁(yè)已經(jīng)刷新';
}
?>
自己放到e/extend/sc/.index.php 文件夾里面
然后在服務(wù)器上搞個(gè)計(jì)劃任務(wù) 定時(shí)打開(kāi)這個(gè)地址 hide后面加 ?pwd=密碼 即可!
版權(quán)聲明: 本站資源均來(lái)自互聯(lián)網(wǎng)或會(huì)員發(fā)布,如果侵犯了您的權(quán)益請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)刪除!謝謝!
轉(zhuǎn)載請(qǐng)注明: 帝國(guó)CMS自動(dòng)審核發(fā)布信息腳本