e/class/userfun.php添加函數
//批量復制TAGS到關鍵詞function eCopyTag2Key($classid,$id,$newstime){? ?global $empire,$dbtbpre,$class_r;? ?$count = count($id); //統計ID數量? ?if (empty($count))? ?{//如果id沒選中? ? ? ?printerror("未選擇信息ID", "", 1, 0, 1);? ?}? ?$classid=(int)$classid;//這一步可省略? ?$mid=(int)$class_r[$classid][modid];//取modid值,這一步可省略? ?for($i=0;$i<$count;$i++)? ?{? ? ? ?$id[$i] = (int)$id[$i];? ? ? ?$tbname=$class_r[$classid][tbname];//獲取表名? ? ? ?$r = $empire->fetch1("select * from {$dbtbpre}ecms_".$tbname." where id='$id[$i]' limit 1");? ? ? ?$t = $empire->fetch1("select infotags from {$dbtbpre}ecms_".$tbname."_data_".$r['stb']." where id='$id[$i]'");//從信息表中取infotags和keyboard值? ? ? ?$t=array_merge($r,$t);? ? ? ?$taga=$t['infotags'].",".$t['keyboard']; //組合TAGS:在原有的infotags值上加上新keyboard? ? ? ?$tagb[$i] = explode(",",$taga); //設置數組:用,分割tag? ? ? ?$tagc=array_values(array_unique($tagb[$i])); //數組排重:排除重復?? ? ? ?for($t=0;$tquery("update {$dbtbpre}ecms_".$tbname." set keyboard='".trim($newtags[$i],",")."' where id='$id[$i]'");//將新生成的keyboard寫入到表中? ?}? ?printerror("已成功將TAGS批量復制到關鍵詞字段", "", 1, 0, 1);}//加入TAG表function eInsertTags2($tags,$classid,$id,$newstime){? ?global $empire,$dbtbpre,$class_r;? ?$tags = RepPostVar($tags);? ?//$tag = explode(",", $tags);? ?$count = count($id); //統計ID數量? ?if (empty($count))? ?{//如果id沒選中? ? ? ?printerror("未選擇信息ID", "", 1, 0, 1);? ?}? ?$classid=(int)$classid;? ?$mid=(int)$class_r[$classid][modid];//取modid值? ?for($i=0;$i<$count;$i++)? ?{? ? ? ?$id[$i] = (int)$id[$i];? ? ? ?$tbname=$class_r[$classid][tbname];//獲取表名? ? ? ?$r1 = $empire->fetch1("select * from {$dbtbpre}ecms_".$tbname." where id='$id[$i]' limit 1");? ? ? ?$t = $empire->fetch1("select infotags from {$dbtbpre}ecms_".$tbname."_data_".$r1['stb']." where id='$id[$i]'");//從信息表中取infotags和keyboard值? ? ? ?$t=array_merge($r1,$t);? ? ? ?$taga=$t['infotags'].",".$tags; //組合TAGS:在原有的infotags值上加上新tag? ? ? ?$tagb[$i] = explode(",",$taga); //設置數組:用,分割tag? ? ? ?$tagc=array_values(array_unique($tagb[$i])); //數組排重:排除重復?? ? ? ?for($t=0;$tfetch1("select tagid from {$dbtbpre}enewstags where tagname='$tagc[$t]' limit 1");//查詢有無同名的tag? ? ? ? ? ? ? ?if($r[tagid])? ? ? ? ? ? ? ?{//如果有tagid,即enewstags表中有相同tag? ? ? ? ? ? ? ? ? ?$datar=$empire->fetch1("select tagid,classid,newstime from {$dbtbpre}enewstagsdata where tagid='$r[tagid]' and id='$id[$i]' and mid='$mid' limit 1");//用tagid,id和mid對enewstagsdata進行查詢? ? ? ? ? ? ? ? ? ?if($datar[tagid])? ? ? ? ? ? ? ? ? ?{//如果有數據? ? ? ? ? ? ? ? ? ? ? ?if($datar[classid]!=$classid||$datar[newstime]!=$newstime)? ? ? ? ? ? ? ? ? ? ? ?{//如果classid和newstime不相同? ? ? ? ? ? ? ? ? ? ? ? ? ?$empire->query("update {$dbtbpre}enewstagsdata set classid='$classid',newstime='$newstime' where tagid='$r[tagid]' and id='$id[$i]' and mid='$mid' limit 1");//則開始更新? ? ? ? ? ? ? ? ? ? ? ?}? ? ? ? ? ? ? ? ? ?}? ? ? ? ? ? ? ? ? ?else? ? ? ? ? ? ? ? ? ?{//查詢后沒有此數據,則先更新enewstags表,在數量上加1? ? ? ? ? ? ? ? ? ? ? ?$empire->query("update {$dbtbpre}enewstags set num=num+1 where tagid='$r[tagid]'");? ? ? ? ? ? ? ? ? ? ? ?$empire->query("update {$dbtbpre}ecms_".$tbname."_data_".$r1['stb']." set infotags='".trim($newtags[$i],",")."' where id='$id[$i]'");//然后在信息表infotags字段中加上這個新tag,如果按舍得的方法,這一步就可以免了? ? ? ? ? ? ? ? ? ? ? ?$empire->query("insert into {$dbtbpre}enewstagsdata(tagid,classid,id,newstime,mid) values('$r[tagid]','$classid','$id[$i]','$newstime','$mid');");//然后在enewstagsdata表中插入這些數據? ? ? ? ? ? ? ? ? ?}? ? ? ? ? ? ? ?}? ? ? ? ? ? ? ?else? ? ? ? ? ? ? ?{//如果沒有此tag? ? ? ? ? ? ? ? ? ?$empire->query("update {$dbtbpre}ecms_".$tbname."_data_".$r1['stb']." set infotags='".trim($newtags[$i],",")."' where id='$id[$i]'");//先在信息表中加上此tag,如果按舍得的方法,這一步就可以免了? ? ? ? ? ? ? ? ? ?$empire->query("insert into {$dbtbpre}enewstags(tagname,num,isgood,cid) values('$tagc[$t]',1,0,0);");//在enewstags表中插入新值? ? ? ? ? ? ? ? ? ?$tagid=$empire->lastid();//把這個tagid給取出來? ? ? ? ? ? ? ? ? ?$empire->query("insert into {$dbtbpre}enewstagsdata(tagid,classid,id,newstime,mid) values('$tagid','$classid','$id[$i]','$newstime','$mid');");//既然是沒有tagid的,那就在enewstagsdata也得插入新值(不用再查詢)? ? ? ? ? ? ? ?} ? ? ? ? ? ?? ? ? ?}? ?}? ?printerror("批量添加TAGS成功", "", 1, 0, 1);}eadminecmsInfo.php我加在了123-137行,你們隨意elseif($enews=="CopyTag2Key")//列表批量復制Tags為關鍵詞{? ? ? ? ? ? ? ?$classid=$_POST['classid'];? ? ? ? ? ? ? ?$id=$_POST['id'];? ? ? ?$newstime=time(); ?? ? ? ?eCopyTag2Key($classid,$id,$newstime);}elseif($enews=="AddTags_all")//列表批量添加Tags{? ? ? ? ? ? ? ?$classid=$_POST['classid'];? ? ? ? ? ? ? ?$id=$_POST['id'];? ? ? ? ? ? ? ?$tags=$_POST['add_listtags'];? ? ? ?$newstime=time(); ?? ? ? ?eInsertTags2($tags,$classid,$id,$newstime);}
e/data/html/list/listinfo.php
???????? ? ? ?備注:多選框藍色為未審核信息;發布者紅色為會員投稿;信息ID粗體為未生成,點擊ID可刷新頁面.
改為
備注:1.先選中要操作的ID,然后在左側文本框內直接輸入多個關鍵詞,以","隔開;然后點擊批量添加TAGS即可;之后可點擊"批量復制TAGS"將TAG復制到關鍵詞字段.
2.多選框藍色為未審核信息;發布者紅色為會員投稿;信息ID粗體為未生成,點擊ID可刷新頁面.
新聞熱點
疑難解答