phpcms v9 会员投稿后,限制一定时间内可刷新一次,类似58的刷新置顶功能

来源:互联网 发布:三网合一网站源码 编辑:程序博客网 时间:2024/04/19 04:51
24小时限制刷新说明1,修改\phpcms\modules\member\content.php在public function published()中,$_v['flag'] = $workflows[$workflowid]['flag'];的下面增加$category = $CATEGORYS[$_v['catid']];$modelid = $category['modelid'];$this->content_db = pc_base::load_model('content_model');$vvv=$this->content_db->set_model($modelid);$r = $this->content_db->get_one(array('id'=>$_v['id'],'sysadd'=>0));//为前台增加两个变量$_v['updatetime']=$r['updatetime'];$_v['can_fresh']=(time()-$r['updatetime'])>10?1:0;//86400表示1天,10表示10秒,超过24秒,则说明可刷新然后,在本文件,最下面的大括号前面,增加下面的一个刷新专用函数public function fresh(){$id = intval($_GET['id']); if(!$id){return false;} //判断该文章是否属于该会员$username = param::get_cookie('_username');$userid = param::get_cookie('_userid');$siteid = get_siteid();$catid = intval($_GET['catid']);$siteids = getcache('category_content', 'commons');$siteid = $siteids[$catid];$CATEGORYS = getcache('category_content_'.$siteid, 'commons');$category = $CATEGORYS[$catid];if(!$category){showmessage(L('operation_failure'), HTTP_REFERER);  }$modelid = $category['modelid'];$checkid = 'c-'.$id.'-'.$modelid; $where = " checkid='$checkid' and username='$username' and status=99 ";$check_pushed_db = pc_base::load_model('content_check_model'); $array = $check_pushed_db->get_one($where);if(!$array){ showmessage(L('operation_failure'), HTTP_REFERER); }else{$content_db = pc_base::load_model('content_model');$content_db->set_model($modelid);$r = $content_db->get_one(array('id'=>$id,'sysadd'=>0));if(time()-$r['updatetime']>10){//10秒就可刷新一次$content_db->fresh($id);showmessage(L('operation_success'), HTTP_REFERER);}else{showmessage(L('操作失败'), HTTP_REFERER);}}}2,修改文件\phpcms\model\content_model.class.php在其最下面的一个大括号前面增加一个类方法public function fresh($id) {$model_tablename = $this->model_tablename;//前台权限判断if(!defined('IN_ADMIN')) {$_username = param::get_cookie('_username');$us = $this->get_one(array('id'=>$id,'username'=>$_username));if(!$us) return false;}$systeminfo['updatetime'] = SYS_TIME;$this->update($systeminfo,array('id'=>$id));return true;}3,修改投稿功能.增加刷新按钮修改你的模板目录中的一个模板,\phpcms\templates\你的模板目录名\member\content_published.html在下面这句后面<a href="index.php?m=member&c=content&a=delete&catid={$info[catid]}&id={$info[id]}">删除</a>{/if}增加{if  $info[status] ==99} {if $info[can_fresh]}| <a href="index.php?m=member&c=content&a=fresh&catid={$info[catid]}&id={$info[id]}">刷新</a>{else}| 已刷新{/if}{/if}然后直接显示刷新时间在<th width="80">{L('adddate')}</th>的下面增加<th width="80">刷新时间</th>在<td align="center">{date('Y-m-d',$info['inputtime'])}</td>下面增加<td align="center">{date('Y-m-d H:i:s',$info['updatetime'])}</td>4,注册会员,投稿测试,栏目要先开启投稿权限

阅读全文
0 0