Home >php教程 >php手册 >帝国CMS置顶扣除积分机制

帝国CMS置顶扣除积分机制

WBOY
WBOYOriginal
2016-06-13 09:38:311311browse

首先在所需的系统模型中添加int字段 top,单选按钮0,1(0为否,1为是)。主要修改e/class/qinfofun.php两处 一处为增加,一处为编辑。

在文件中找到esetcookie("lastaddinfotime",time(),time()+3600*24);下面到//-------------修改

全部替换为:

	//置顶扣分
	$t=$empire->fetch1("select top from {$dbtbpre}ecms_".$tbname." where userid='$muserid' and id='$id' and classid='$classid' limit 1");
	if($t[top])
	{
   		$w=$empire->fetch1("select userfen from {$dbtbpre}enewsmember where userid='$muserid'");
     	if($w[userfen]>=10)
      	{
       		$sql3=$empire->query("update {$dbtbpre}enewsmember set userfen=userfen-10 where userid='$muserid'");
          	printerror("AddQinfoSuccess",$reurl,1);
      	}
     	else
       	{
        	$sql4=$empire->query("update {$dbtbpre}ecms_".$tbname." set top=0 where userid='$muserid' and id='$id' and classid='$classid' limit 1");
       		printerror("jifenbugou",$reurl,1);
      	}
	}                
   	else
	{
		printerror("AddQinfoSuccess",$reurl,1);
	}
}
else
{
	printerror("DbError","history.go(-1)",1);
}
}

找到

if($sql)
{
	$reurl=DoingReturnUrl("ListInfo.php?mid=$mid",$add['ecmsfrom']);
 	if($add['editgotoinfourl']&&$infor['checked'])//返回内容页
	{
    	if($cr['showdt']==1)
   		{
         	$reurl=$public_r[newsurl]."e/action/ShowInfo/?classid=$classid&id=$id";
     	}
 		elseif($cr['showdt']==2)
      	{
          	$reurl=$public_r[newsurl]."e/action/ShowInfo.php?classid=$classid&id=$id";
       	}
     	else
   		{
          	$reurl=$titleurl;
    	}
	}

在其下至//---------------删除之间替换为:

//置顶扣分
	$t=$empire->fetch1("select top from {$dbtbpre}ecms_".$tbname." where userid='$muserid' and id='$id' and classid='$classid' limit 1");
	if($t[top])
	{
		$w=$empire->fetch1("select userfen from {$dbtbpre}enewsmember where userid='$muserid'");
    	if($w[userfen]>=10)
     	{
         	$sql3=$empire->query("update {$dbtbpre}enewsmember set userfen=userfen-10 where userid='$muserid'");
          	printerror("EditQinfoSuccess",$reurl,1);
   		}
    	else
       	{
       		$sql4=$empire->query("update {$dbtbpre}ecms_".$tbname." set top=0 where userid='$muserid' and id='$id' and classid='$classid' limit 1");
       		printerror("jifenbugou",$reurl,1);
    	}
  	}
 	else{printerror("EditQinfoSuccess",$reurl,1);}        
	}
	else
	{printerror("DbError","history.go(-1)",1);}
}

注意上面部分的10为扣除的积分自行设置,还有jifenbuzhu自己可以该为自己需要的提示在e/data/language/gb/pub/q_message.php中添加。

又添加这个字段主要是避免与老大的那个firsttitle起冲突,避免以后升级带来的麻烦,假如会员积分不足提示积分不足但信息仍让可以提交只是不能置顶。

在列表模板中调用方法:

[e:loop={"select * from phome_ecms_house where top=1 and checked=1 and classid='$GLOBALS[navclassid]'  limit 3",3,24,0}]
<tr onmouseout="this.style.backgroundColor='#ffffff'" onmouseover="this.style.backgroundColor='#F1F5FC'">
        <td><?=$bqr[myarea]?></td>
        <td class="tx"><font color="red">[置顶]</font>
<a href="<?=$bqsr[titleurl]?>" title="<?=$bqr[title]?>" target="_blank"><?=$bqr[xiangxidizhi]?></a></td>
        <td><?=$bqr[shi]?>室<?=$bqr[ting]?>厅</td>
        <td><?=$bqr[size]?><span class="m">㎡</span></td>
        <td><?=$bqr[money]?></td>
        <td align="right"><?=date('Y-m-d',$bqr[newstime])?></td>
    </tr>
[/e:loop]

//01.23日更新功能添加到期时间字段date 到期之后置顶功能无效,上面的列表模板sql中添加 and (unix_timestamp(youxiaoqi)-UNIX_TIMESTAMP(NOW()))>0

仅供参考。

Statement:
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