⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 feedback.php

📁 这是matlab的一个小程序
💻 PHP
字号:
<?php
require_once(dirname(__FILE__)."/../include/common.inc.php");
require_once(DEDEINC."/filter.inc.php");

if(!isset($action))
{
	$action = '';
}
$ischeck = $cfg_feedbackcheck=='Y' ? 0 : 1;
$aid = (isset($aid) && is_numeric($aid)) ? $aid : 0;
$fid = (isset($fid) && is_numeric($fid)) ? $fid : 0;
if(empty($aid) && empty($fid))
{
	ShowMsg('文档id不能为空!','-1');
	exit();
}

include_once(DEDEINC."/memberlogin.class.php");
$cfg_ml = new MemberLogin();

//顶、踩
/*
function __DigCai(){ }
*/
if($action=='good')
{
	AjaxHead();
	$row = $dsql->GetOne("Select ch.maintable,ch.addtable,ch.issystem From `#@__arctiny` arc left join `#@__channeltype` ch on ch.id = arc.channel where arc.id='$aid' ");
	if(empty($row['maintable'])) {
		$row['maintable'] = '#@__archives';
	}
	if(isset($row['issystem']) && $row['issystem']==-1)
	{
		$row['maintable'] = $row['addtable'];
		$dsql->ExecuteNoneQuery("Update `{$row['maintable']}` set scores = scores + {$cfg_caicai_add},goodpost=goodpost+1,lastpost=".time()." where aid='$aid' ");
		$row = $dsql->GetOne("Select goodpost,badpost,scores From `{$row['maintable']}` where aid='$aid' ");
	}
	else
	{
		$dsql->ExecuteNoneQuery("Update `{$row['maintable']}` set scores = scores + {$cfg_caicai_add},goodpost=goodpost+1,lastpost=".time()." where id='$aid' ");
		$row = $dsql->GetOne("Select goodpost,badpost,scores From `{$row['maintable']}` where id='$aid' ");
	}
	if(empty($formarc)) {
		echo "<a onclick=\"postBadGood('goodfb',{$aid})\">支持</a>[{$row['goodpost']}]";
	}
	else
	{
		$row['goodper'] = number_format($row['goodpost']/($row['goodpost']+$row['badpost']),3)*100;
		$row['badper'] = 100-$row['goodper'];
		$bkstr = '<div class="diggbox digg_good" onmousemove="this.style.backgroundPosition=\'left bottom\';" onmouseout="this.style.backgroundPosition=\'left top\';" onclick="javascript:postDigg(\'good\','.$aid.')">
					<div class="digg_act">顶一下</div>
					<div class="digg_num">('.$row['goodpost'].')</div>
					<div class="digg_percent">
						<div class="digg_percent_bar"><span style="width:'.$row['goodper'].'%"></span></div>
						<div class="digg_percent_num">'.$row['goodper'].'%</div>
					</div>
				</div>
				<div class="diggbox digg_bad" onmousemove="this.style.backgroundPosition=\'right bottom\';" onmouseout="this.style.backgroundPosition=\'right top\';" onclick="javascript:postDigg(\'bad\','.$aid.')">
					<div class="digg_act">踩一下</div>
					<div class="digg_num">('.$row['badpost'].')</div>
					<div class="digg_percent">
						<div class="digg_percent_bar"><span style="width:'.$row['badper'].'%"></span></div>
						<div class="digg_percent_num">'.$row['badper'].'%</div>
					</div>
				</div>';

		echo $bkstr;
	}
	exit();
}
else if($action=='bad')
{
	AjaxHead();
	$row = $dsql->GetOne("Select ch.maintable,ch.addtable,ch.issystem From `#@__arctiny` arc left join `#@__channeltype` ch on ch.id = arc.channel where arc.id='$aid' ");
	if(empty($row['maintable'])) {
		$row['maintable'] = '#@__archives';
	}
	if($row['issystem']==-1)
	{
		$row['maintable'] = $row['addtable'];
		$dsql->ExecuteNoneQuery("Update `{$row['maintable']}` set scores = scores - {$cfg_caicai_sub},badpost=badpost+1,lastpost=".time()." where aid='$aid' ");
		$row = $dsql->GetOne("Select goodpost,badpost,scores From `{$row['maintable']}` where aid='$aid' ");
	}
	else
	{
		$dsql->ExecuteNoneQuery("Update `{$row['maintable']}` set scores = scores - {$cfg_caicai_sub},badpost=badpost+1,lastpost=".time()." where id='$aid' ");
		$row = $dsql->GetOne("Select goodpost,badpost,scores From `{$row['maintable']}` where id='$aid' ");
	}
	if(empty($formarc)) {
		echo "<a onclick=\"postBadGood('badfb',{$aid})\">反对</a>[{$row['badpost']}]";
	}
	else {
		$row['goodper'] = number_format($row['goodpost']/($row['goodpost']+$row['badpost']),3)*100;
		$row['badper'] = 100-$row['goodper'];
		$bkstr = '<div class="diggbox digg_good" onmousemove="this.style.backgroundPosition=\'left bottom\';" onmouseout="this.style.backgroundPosition=\'left top\';" onclick="javascript:postDigg(\'good\','.$aid.')">
					<div class="digg_act">顶一下</div>
					<div class="digg_num">('.$row['goodpost'].')</div>
					<div class="digg_percent">
						<div class="digg_percent_bar"><span style="width:'.$row['goodper'].'%"></span></div>
						<div class="digg_percent_num">'.$row['goodper'].'%</div>
					</div>
				</div>
				<div class="diggbox digg_bad" onmousemove="this.style.backgroundPosition=\'right bottom\';" onmouseout="this.style.backgroundPosition=\'right top\';" onclick="javascript:postDigg(\'bad\','.$aid.')">
					<div class="digg_act">踩一下</div>
					<div class="digg_num">('.$row['badpost'].')</div>
					<div class="digg_percent">
						<div class="digg_percent_bar"><span style="width:'.$row['badper'].'%"></span></div>
						<div class="digg_percent_num">'.$row['badper'].'%</div>
					</div>
				</div>';

		echo $bkstr;
	}
	exit();
}
//对评论进行评价
/*
function __BadGoodFeedback(){ }
*/
else if($action=='goodfb')
{
	AjaxHead();
	$fid = intval($fid);
	$dsql->ExecuteNoneQuery("Update `#@__feedback` set good = good+1 where id='$fid' ");
	$row = $dsql->GetOne("Select good From `#@__feedback` where id='$fid' ");
	echo "<a onclick=\"postBadGood('goodfb',{$aid})\">支持</a>[{$row['good']}]";
	exit();
}
else if($action=='badfb')
{
	AjaxHead();
	$fid = intval($fid);
	$dsql->ExecuteNoneQuery("Update `#@__feedback` set bad = bad+1 where id='$fid' ");
	$row = $dsql->GetOne("Select bad From `#@__feedback` where id='$fid' ");
	echo "<a onclick=\"postBadGood('badfb',{$aid})\">反对</a>[{$row['bad']}]";
	exit();
}
//查看评论
/*
function __ViewFeedback(){ }
*/
//-----------------------------------
else if($action=='' || $action=='show')
{
	//读取文档信息
	$arcRow = GetOneArchive($aid);
	if(empty($arcRow['aid']))
	{
		ShowMsg('无法查看未知文档的评论!','-1');
		exit();
	}
	extract($arcRow, EXTR_SKIP);
	include_once(DEDEINC.'/datalistcp.class.php');
	$dlist = new DataListCP();
	$dlist->pageSize = 20;

	if(empty($ftype) || ($ftype!='good' && $ftype!='bad' && $ftype!='feedback'))
	{
		$ftype = '';
	}
	$wquery = $ftype!='' ? " And ftype like '$ftype' " : '';

	//评论内容列表
	$querystring = "select fb.*,mb.userid,mb.face as mface,mb.spacesta,mb.scores from `#@__feedback` fb
                 left join `#@__member` mb on mb.mid = fb.mid
                 where fb.aid='$aid' and fb.ischeck='1' $wquery order by fb.id desc";
	$dlist->SetParameter('aid',$aid);
	$dlist->SetParameter('action','show');
	$dlist->SetTemplate($cfg_basedir.$cfg_templets_dir.'/plus/feedback_templet.htm');
	$dlist->SetSource($querystring);
	$dlist->Display();
	exit();
}

//引用评论
//------------------------------------
/*
function __Quote(){ }
*/
else if($action=='quote')
{
	$row = $dsql->GetOne("Select * from `#@__feedback` where id ='$fid'");
		require_once(DEDEINC.'/dedetemplate.class.php');
		$dtp = new DedeTemplate();
		$dtp->LoadTemplate($cfg_basedir.$cfg_templets_dir.'/plus/feedback_quote.htm');
		$dtp->Display();
		exit();
}
//发表评论
//------------------------------------
/*
function __SendFeedback(){ }
*/
else if($action=='send')
{
	//读取文档信息
	$arcRow = GetOneArchive($aid);
	if((empty($arcRow['aid']) || $arcRow['notpost']=='1')&&empty($fid))
	{
		ShowMsg('无法对该文档发表评论!','-1');
		exit();
	}

	//是否加验证码重确认
	if(empty($isconfirm))
	{
		$isconfirm = '';
	}
	if($isconfirm!='yes' && $cfg_feedback_ck=='Y')
	{
		extract($arcRow, EXTR_SKIP);
		require_once(DEDEINC.'/dedetemplate.class.php');
		$dtp = new DedeTemplate();
		$dtp->LoadTemplate($cfg_basedir.$cfg_templets_dir.'/plus/feedback_confirm.htm');
		$dtp->Display();
		exit();
	}

	//检查验证码
	if($cfg_feedback_ck=='Y')
	{
		$validate = isset($validate) ? strtolower(trim($validate)) : '';
		$svali = GetCkVdValue();
		if(strtolower($validate)!=$svali || $svali=='')
		{
			ResetVdValue();
			ShowMsg('验证码错误!','-1');
			exit();
		}
	}

	//检查用户登录
	if(empty($notuser))
	{
		$notuser=0;
	}

	//匿名发表评论
	if($notuser==1)
	{
		$username = $cfg_ml->M_ID > 0 ? '匿名用户' : '游客';
	}

	//已登录的用户
	else if($cfg_ml->M_ID > 0)
	{
		$username = $cfg_ml->M_UserName;
	}

	//用户身份验证
	else
	{
		if($username!='' && $pwd!='')
		{
			$rs = $cfg_ml->CheckUser($username,$pwd);
			if($rs==1)
			{
				$dsql->ExecuteNoneQuery("Update `#@__member` set logintime='".time()."',loginip='".GetIP()."' where id='{$cfg_ml->M_ID}'; ");
				$username = $cfg_ml->M_UserName;
			}
			else
			{
				$username = '游客';
			}
		}
		else
		{
			$username = '游客';
		}
	}
	$ip = GetIP();
	$dtime = time();
	if(empty($face))
	{
		$face = 0;
	}
	$face = intval($face);
	extract($arcRow, EXTR_SKIP);
	$msg = cn_substrR(TrimMsg($msg),1000);
	$username = cn_substrR(HtmlReplace($username,2),20);
	if($feedbacktype!='good' && $feedbacktype!='bad')
		{
			$feedbacktype = 'feedback';
		}
	//保存评论内容
	if($comtype == 'comments')
	{
		$arctitle = addslashes($title);
		if($msg!='')
		{
			$inquery = "INSERT INTO `#@__feedback`(`aid`,`typeid`,`username`,`arctitle`,`ip`,`ischeck`,`dtime`, `mid`,`bad`,`good`,`ftype`,`face`,`msg`)
	               VALUES ('$aid','$typeid','$username','$arctitle','$ip','$ischeck','$dtime', '{$cfg_ml->M_ID}','0','0','$feedbacktype','$face','$msg'); ";
			$rs = $dsql->ExecuteNoneQuery($inquery);
			if(!$rs)
			{
				echo $dsql->GetError();
				exit();
			}
		}
	}
	//引用回复
	elseif ($comtype == 'reply')
	{
		$row = $dsql->GetOne("Select * from `#@__feedback` where id ='$fid'");
		$arctitle = $row['arctitle'];
		$aid =$row['aid'];
		$msg = $quotemsg.$msg;
		$msg = HtmlReplace($msg,2);
		$inquery = "INSERT INTO `#@__feedback`(`aid`,`typeid`,`username`,`arctitle`,`ip`,`ischeck`,`dtime`,`mid`,`bad`,`good`,`ftype`,`face`,`msg`)
				VALUES ('$aid','$typeid','$username','$arctitle','$ip','$ischeck','$dtime','{$cfg_ml->M_ID}','0','0','$feedbacktype','$face','$msg')";
		$dsql->ExecuteNoneQuery($inquery);
	}

	if($feedbacktype=='bad')
			{
				$dsql->ExecuteNoneQuery("Update `#@__archives` set scores=scores-{cfg_feedback_sub},badpost=badpost+1,lastpost='$dtime' where id='$aid' ");
			}
			else if($feedbacktype=='good')
			{
				$dsql->ExecuteNoneQuery("Update `#@__archives` set scores=scores+{$cfg_feedback_add},goodpost=goodpost+1,lastpost='$dtime' where id='$aid' ");
			}
			else
			{
				$dsql->ExecuteNoneQuery("Update `#@__archives` set scores=scores+1,lastpost='$dtime' where id='$aid' ");
			}
			if($cfg_ml->M_ID > 0)
			{
				$dsql->ExecuteNoneQuery("Update `#@__member` set scores=scores+{$cfg_sendfb_scores} where mid='{$cfg_ml->M_ID}' ");
			}
	//统计用户发出的评论
	if($cfg_ml->M_ID > 0)
	{
		$row = $dsql->GetOne("SELECT COUNT(*) AS nums FROM `#@__feedback` WHERE `mid`='".$cfg_ml->M_ID."'");
		$dsql->ExecuteNoneQuery("UPDATE `#@__member_tj` SET `feedback`='$row[nums]' WHERE `mid`='".$cfg_ml->M_ID."'");
	}

	if($ischeck==0)
	{
		ShowMsg("成功发表评论,但需审核后才会显示你的评论!","feedback.php?aid=$aid");
	}elseif($ischeck==1)
	{
		ShowMsg("成功发表评论,现在转到评论页面!","feedback.php?aid=$aid");
	}
	exit();
}
?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -