小猪cms文本回复二次开发 参考
开发要求
批量导入文本
批量导出文本
批量修改匹配规则
批量删除
部分匹配规则改为包含匹配规则
原规则 淘宝网 回复 淘 淘宝 淘宝网
新规则 淘宝网 回复 淘宝网 淘宝网站 我爱淘宝网
涉及文件
控制器
\pigcms\Lib\Action\Home\WeixinAction.class.php
\pigcms\Lib\Action\User\TextAction.class.php
\pigcms\Lib\Action\User\WeixinAction.class.php
模板
\tpl\User\default\Text_index.html
\tpl\User\default\Text_pladd.html 新增
批量导出同时备份在 /beifen/Text/文件夹下 按时间命名
二次开发仅参考
附上导出导入代码[本人是菜鸟QQ839024615]//本人菜鸟 代码来自qq839024615<br>
//批量添加<br>
public function pladd(){<br>
if(IS_POST){<br>
$db=D('Text');<br>
$data['uid']=session('uid');<br>
$data['token']=session('token');<br>
$data['uname']=session('uname');<br>
<br>
$str=$_POST['text'];<br>
$arr=explode("\n",$str);<br>
if(count($arr)>=50){$this->error('对不起,最多支持50条');}<br>
for($i=0;$i<count></count>
$Arr=$this->text_explode($arr[$i]);<br>
$precisions=$Arr['2'];<br>
$text=$Arr['1'];<br>
$keyword=$Arr['0'];<br>
<br>
$data['precisions']=$precisions;<br>
$data['keyword']=$keyword;<br>
$data['text']=$text;<br>
$data['createtime']=time();<br>
$data['updatetime']=time();<br>
<br>
$where['uid']=session('uid');<br>
$where['token']=session('token');<br>
$where['keyword']=$keyword;<br>
<br>
$save['updatetime']=time();<br>
$save['precisions']=$precisions;<br>
$save['text']=$text;<br>
$save['uname']=session('uname');<br>
//如果空行直跳过<br>
if(count($Arr)>=2){<br>
$F=$db->where($where)->find();<br>
if($F){<br>
echo $is=$db->where($where)->save($save);<br>
if($is){<br>
$this->handleKeyword($F['id'],'Text',$keyword,$precisions);<br>
echo $keyword."----更新成功<br>";<br>
}else{<br>
echo $keyword."----更新失败<br>";<br>
}<br>
}else{<br>
$is=$db->add($data);<br>
if($is){<br>
$this->handleKeyword($is,'Text',$keyword,$precisions);<br>
echo $keyword."----创建成功<br>";<br>
}else{<br>
echo $keyword."----创建失败<br>";<br>
}<br>
}<br>
}else{<br>
echo "空行已过滤<br>"; <br>
}<br>
}<br>
echo "<a>返回查看</a>";<br>
}else{<br>
$this->display();<br>
}<br>
}<br>
//批量导出<br>
public function export(){<br>
<br>
$db=D('Text');<br>
$p=$_GET['p'];<br>
if($p){<br>
$name=$_GET['name'];<br>
$p=$p+1;<br>
}else{<br>
$name=Date('Y-m-d His',time());<br>
$p=1;<br>
}<br>
<br>
$where['uid']=session('uid');<br>
$where['token']=session('token');<br>
$count=$db->where($where)->count();<br>
$page=new Page($count,50);<br>
$list=$db->where($where)->order('updatetime desc')->limit($page->firstRow.','.$page->listRows)->select();<br>
for($i=0;$i<count></count>
$body=$list[$i]['keyword']."|".$list[$i]['text']."|".$list[$i]['precisions'];<br>
$this->text_beifen($name,$body);<br>
}<br>
if($p>=($count/50)){<br>
$this->success('导出完毕',"/beifen/Text/".$name.".txt");<br>
}else{<br>
$this->success('正在第'.$p.'页',U('Text/export','p='.$p.'&name='.$name));<br>
}<br>
}<br>
//分切<br>
public function text_explode($text){<br>
$arr=explode("|",$text);<br>
return $arr;<br>
}<br>
//写记事本<br>
public function text_beifen($name="",$body=""){<br>
$fp = fopen("beifen/Text/".$name.".txt", 'ab'); <br>
flock($fp, LOCK_EX); <br>
fwrite($fp, $body."\r\n" );<br>
flock($fp, LOCK_UN); <br>
fclose($fp); <br>
}<br>
//本人菜鸟 代码来自qq839024615
AD:真正免费,域名+虚机+企业邮箱=0元

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment