Home > php教程 > php手册 > 小猪cms文本回复二次开发 参考

小猪cms文本回复二次开发 参考

WBOY
Release: 2016-06-07 11:39:48
Original
1395 people have browsed it

小猪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/文件夹下 按时间命名

小猪cms文本回复二次开发 参考

小猪cms文本回复二次开发 参考

小猪cms文本回复二次开发 参考

二次开发仅参考
附上导出导入代码[本人是菜鸟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元

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template