央企文库

首页 > 关于我们 > 资源分享

资源分享

帝国CMS插件 批量王

更新时间:2022-02-06 立即下载

【使用法】后台,添加sql语句,并保存,要求名称[plw]开头。

模板内容参考示范代码。主表副表字段都集成在$r数组中了。要求把最后修改的字段名写到$listtemp变量中,多个用逗号分开。

代码1:同时修改多个字段。要点--最后把需要修改的字段名写到$listtemp变量中,多个用逗号分开。

$r['newstext'].='777';

$r['smalltext']='777'.$r['smalltext'];

$r['title']='777'.$r['title'];

$listtemp="newstext,title,smalltext";

代码2:修改发布时间字段

【示范代码】

$r['newstime']=to_time('1988-12-30');

$listtemp="newstime";

代码3:批量修改smalltext

【示范代码】


 
  1. $r['newstext']=stripslashes($r['newstext']);

     

  2. $smalltext=SubSmalltextVal($r['newstext'],100);

     

  3. $r['newstext']=addslashes($smalltext);

     

  4. $listtemp="smalltext";

【示范代码】

global $public_r;

$listtemp='smalltext';

$r['newstext']=stripslashes($r['newstext']);

$smalltext=SubSmalltextVal($r['newstext'],$public_r['smalltextlen']);

$r['smalltext']=addslashes($smalltext);

$listtemp="smalltext";

【代码4】批量取消审核

$jhc=$empire->query("update {$dbtbpre}ecms_{$tbname}_index set checked=0 where id='$r[id]'");

MoveCheckInfoData($tbname,1,$r['stb'],"id='{$r[id]}'");

AddClassInfos($r['classid'],'','-1');

DelNewsFile($r[filename],$r[newspath],$r[classid],$r[$pf],$r[groupid]);

$listtemp='';

【代码5】批量审核

//未审核表转换 MoveCheckInfoData($class_r[$r[classid]][tbname],0,$r['stb'],"id='$r[id]'"); //更新栏目信息数 AddClassInfos($r['classid'],'','+1'); //刷新信息 GetHtml($r['classid'],$r['id'],$r,1); $listtemp='';

【代码6】批量修改友情链接的说明

$r['lsay']='你好我就是测试一下好用吗';

$listtemp="lsay";

【代码7】把内容中的第一张图片设置为标题图片

第一步,新建一个自定义页面模板,标题为---[批量王]提取内容图片到标题,内容如下:


 
  1. if(!$r[titlepic]){
  2.   $newstext=stripslashes($r['newstext']);
  3.          $pattern = '/<img(?=\s).*?(?<=\s)src="(.+?)"/i'; 
  4.           preg_match($pattern, $newstext, $matches);
  5.   if($matches){
  6.                 $r[titlepic]= $matches[1];//返回第一张图片地址
  7.                 if(!strstr($r[titlepic],'://')){$r[titlepic]=$_SERVER[HTTP_ORIGIN].'/'.ltrim($r[titlepic],'/'); }
  8.                 
  9.         }
  10. }
  11. $listtemp='titlepic';

第二步,打开批量王,选择出这模板,执行就可以了。

附注:使用mysql语句完成本任务的方法


 
  1. 执行以下脚本的时候请 先备份数据库!文本存放的新闻正文字段不可用!
  2. 新闻正文字段作为主表的情况用以下语句:
  3. update  phome_ecms_news  set  titlepic  =concat(replace(SUBSTRING_INDEX(SUBSTRING_INDEX(newstext,  'src=',  -1),'.gif',1),'"',''),'.gif')  where  newstext  like  '%.gif%'  and  titlepic='';
  4. update  phome_ecms_news  set  titlepic  =concat(replace(SUBSTRING_INDEX(SUBSTRING_INDEX(newstext,  'src=',  -1),'.jpg',1),'"',''),'.gif')  where  newstext  like  '%.jpg%'  and  titlepic='';
  5. update  phome_ecms_news  set  titlepic  =concat(replace(SUBSTRING_INDEX(SUBSTRING_INDEX(newstext,  'src=',  -1),'.png',1),'"',''),'.png')  where  newstext  like  '%.png%'  and  titlepic='';
  6. 新闻正文字段作为副表的情况用以下语句:
  7. update [!db.pre!]ecms_news_data_1 a, [!db.pre!]ecms_news b set b.titlepic=concat(replace(SUBSTRING_INDEX(SUBSTRING_INDEX(a.newstext,  'src=',  -1),'.gif',1),'"',''),'.gif')  where  a.newstext  like  '%.gif%'  and  b.titlepic='' and a.id=b.id;
  8. update [!db.pre!]ecms_news_data_1 a, [!db.pre!]ecms_news b set b.titlepic=concat(replace(SUBSTRING_INDEX(SUBSTRING_INDEX(a.newstext,  'src=',  -1),'.jpg',1),'"',''),'.jpg')  where  a.newstext  like  '%.jpg%'  and  b.titlepic='' and a.id=b.id;
  9. update [!db.pre!]ecms_news_data_1 a, [!db.pre!]ecms_news b set b.titlepic=concat(replace(SUBSTRING_INDEX(SUBSTRING_INDEX(a.newstext,  'src=',  -1),'.png',1),'"',''),'.png')  where  a.newstext  like  '%.png%'  and  b.titlepic='' and a.id=b.id;

【代码8】批量添加tags

网站已经有大量的tags存在,但是有些文章的标题含有tags,然而没有被添加。本段代码在批量王中执行,完成tags的添加。


 
  1. $infotagsr=explode(',',$r['infotags']);
  2. $r[title]=addslashes($r[title]);
  3. $jhcsql=$empire->query("select tagname,tagid from {$dbtbpre}enewstags where locate(tagname,'$r[title]')>0");
  4. while($jhcr=$empire->fetch($jhcsql)){
  5.    if(in_array($jhcr[tagname],$infotagsr))continue;
  6.    $infotagsr[]=$jhcr[tagname];
  7.    $empire->query("update {$dbtbpre}enewstags set num=num+1 where tagid='$jhcr[tagid]'");
  8.    $classid=(int)$r[classid];   
  9.    $mid=(int)$class_r[$classid][modid]; 
  10.    $empire->query("insert into  {$dbtbpre}enewstagsdata set tagid={$jhcr[tagid]},classid=$classid,id={$r[id]},newstime='$r[newstime]',mid=$mid");
  11. }
  12. $r['infotags']=trim(implode(',',$infotagsr),',');
  13. $listtemp='infotags';

 

【代码9】批量删除重复的信息

打开批量王,选择需要操作的数据表,比如news

操作函数选择: 批量删除

主表条件填写:


 
  1. title in
  2.     (select title FROM phome_ecms_news group by title having count(*)>1)
  3. and id not in
  4.     (select id FROM phome_ecms_news group by title having count(*)>1)

文章评论