- 积分
- 127905
- 在线时间
- 小时
- 注册时间
- 2010-9-23
- 最后登录
- 1970-1-1
|
最近有网友反馈房产信息推荐跟高亮效果过一段时间后自动消失的问题,原因是推荐/高亮有自己的有效期,过了这个有效期后效果就会自动消失。
下面具体分析下是如何实现的:
1.首先是进行推荐/高亮的操作,具体执行代码在source\module\category\house\threadmod.php文件
推荐的部分代码如下:
- if($_G['gp_operation'] == 'recommend') {
- $isrecommend = intval($_G['gp_isrecommend']);
- $statussql = "recommend='".intval($_G['gp_isrecommend'])."'";
- $addnumsql = 'todayrecommend=todayrecommend+1';
- $expiration = TIMESTAMP + 86400 * 3;
复制代码
其中$expiration = TIMESTAMP + 86400 * 3;就是推荐自己的有效期,如果想要自己修改有效期,更改后面的86400 * 3即可。(86400=3600*24,即1天,这里有效期默认为3天)
高亮的部分代码如下:
- elseif($_G['gp_operation'] == 'highlight') {
- $highlight_style = $_G['gp_highlight_style'];
- $highlight_color = $_G['gp_highlight_color'];
- $stylebin = '';
- for($i = 1; $i <= 3; $i++) {
- $stylebin .= empty($highlight_style[$i]) ? '0' : '1';
- }
- $highlight_style = bindec($stylebin);
- if($highlight_style < 0 || $highlight_style > 7 || $highlight_color < 0 || $highlight_color > 8) {
- showmessage('undefined_action', NULL);
- }
- $statussql = "highlight='$highlight_style$highlight_color'";
- $addnumsql = 'todayhighlight=todayhighlight+1';
- $expiration = TIMESTAMP + 86400;
复制代码 其中$expiration = TIMESTAMP + 86400;就是高亮自己的有效期,如果想要自己修改有效期,更改后面的86400即可。(86400=3600*24,即1天,这里有效期默认为1天)
2.推荐/高亮的效果是如何取消的,具体执行代码在source\module\category\house\view.php文件
具体代码如下:
- if($sortdata['highlight'] || $sortdata['recommend']) {
- if($sortdata['highlight']) {
- $highlight = DB::fetch_first("SELECT expiration FROM ".DB::table('category_threadmod')." WHERE tid='$tid' AND action='highlight' ORDER BY expiration DESC LIMIT 1");
- if(TIMESTAMP > $highlight['expiration'] && !empty($highlight['expiration'])) {
- DB::query("UPDATE ".DB::table('category_sortvalue')."$sortid SET highlight='0' WHERE tid='$tid'", 'UNBUFFERED');
- }
- }
- if($sortdata['recommend']) {
- $recommend = DB::fetch_first("SELECT expiration FROM ".DB::table('category_threadmod')." WHERE tid='$tid' AND action='recommend' ORDER BY expiration DESC LIMIT 1");
- if(TIMESTAMP > $recommend['expiration'] && !empty($recommend['expiration'])) {
- DB::query("UPDATE ".DB::table('category_sortvalue')."$sortid SET recommend='0' WHERE tid='$tid'", 'UNBUFFERED');
- }
- }
- }
复制代码 这里如果高亮/推荐的有效期小于当前时间,那么就更新高亮/推荐的操作,即取消效果。
其中的这句代码
- DB::query("UPDATE ".DB::table('category_sortvalue')."$sortid SET highlight='0' WHERE tid='$tid'", 'UNBUFFERED');
复制代码 会取消高亮的效果。
其中的这句代码
- DB::query("UPDATE ".DB::table('category_sortvalue')."$sortid SET recommend='0' WHERE tid='$tid'", 'UNBUFFERED');
复制代码
会取消推荐的效果。
|
|