完善discuz的@圈人功能
来源:互联网 发布:淘宝网每天的访问量 编辑:程序博客网 时间:2024/05/16 00:55
对于原始的discuz的@圈人功能,存在一下几个缺陷:
1/ 如果在圈人的时候,在其后不小心对人名进行了字体/颜色/大小之类的样式设定时,如[i]@02nice[/i],后台逻辑代码中分析到的人名会无法匹配
2/ 如果在圈人的时候,在人名之后换行,后台也会无法匹配
修改方式:
在论坛用户发表主题/回复/发帖时,对于用户编辑内容提交过程中,圈人增加用户链接的效果内容是会保存在数据库中的。
主要有三个文件,三处内容相似:
post_newthread.php
post_newreply.php
post_editpost.php
修改方式$tmp_search ,通过正则表达式,将获取到的人名进行过滤,将包含[/b],[/color],[/u]等样式字符过滤掉,保留原始的人名,当然这里所不考虑含有这些字符串的人名。
if($_G['group']['allowat']) { $atlist = $atlist_tmp = array(); preg_match_all("/@([^\r\n]*?)\s/i", $message.' ', $atlist_tmp); $atlist_tmp = array_slice(array_unique($atlist_tmp[1]), 0, $_G['group']['allowat']); if(!empty($atlist_tmp)) { if(empty($_G['setting']['at_anyone'])) { foreach(C::t('home_follow')->fetch_all_by_uid_fusername($_G['uid'], $atlist_tmp) as $row) { $atlist[$row['followuid']] = $row['fusername']; } if(count($atlist) < $_G['group']['allowat']) { $query = C::t('home_friend')->fetch_all_by_uid_username($_G['uid'], $atlist_tmp); foreach($query as $row) { $atlist[$row['fuid']] = $row['fusername']; } } } else { // edit,修复@, foreach ($atlist_tmp as $atlist_key => $atlist_value) { $tmp_search = "/\[\/(b|color|u|i|size|strong|backcolor|font)\]/"; $atlist_value = preg_replace($tmp_search, "", $atlist_value); $atlist_tmp[$atlist_key] = $atlist_value; } foreach(C::t('common_member')->fetch_all_by_username($atlist_tmp) as $row) { $atlist[$row['uid']] = $row['username']; } } } if($atlist) { // edit,修复@, foreach($atlist as $atuid => $atusername) { $atsearch[] = "/@".str_replace('/', '\/', preg_quote($atusername))."/i"; $atreplace[] = "[url=home.php?mod=space&uid=$atuid]@{$atusername}[/url]"; } $message = preg_replace($atsearch, $atreplace, $message.' ', 1); } }
- 完善discuz的@圈人功能
- CSDN的相册里如何圈人?圈人功能如何使用?
- 功能最完善的uboot
- 单链表的实现-功能完善
- discuz的注册功能设置
- discuz开启门户的功能
- 功能完善
- 【discuz x3】如何开启discuz x3的debug调试功能
- 【discuz x3】如何开启discuz x3的debug调试功能
- 完善你的Blog功能(一)
- 功能完善的即时通讯+视频会议源码
- 完善treeview控件的数据绑定功能
- dedecms独立模型分页功能的完善
- node.js用户注册功能的完善
- 购物车功能的优化完善
- 共享您的问卷,调查圈推出问卷转移功能
- 完善注册新用户功能
- FlashPlayer功能完善
- Android中关于Handler Message Looper 异步消息处理机制的最完整分析 从源码角度进行剖析
- struts.xml配置详解
- coco2dx资源汇
- Apache负载均衡设置方法: mod_proxy
- 并查集
- 完善discuz的@圈人功能
- Struts2中的Action
- Android的jni实例
- jQuery事件函数传递参数
- set 的应用
- js闭包
- POJ 1330 Nearest Common Ancestors (LCA)
- iOS 单件:只保留一个实例
- QT出现Driver not loaded的问题及解决办法