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

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
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值