春哥博客 技术文章 帝国CMS信息反馈发送到邮箱代码

帝国CMS信息反馈发送到邮箱代码

文章顶部广告位

最近有点客户要求信息反馈要发送到邮箱里,和大家分享一下。
方法请修改e/class/q_functions.php文件,请看如下代码,红色为新加入的代码
//提交反馈信息
function AddFeedback($add){
global $empire,$dbtbpre,$level_r,$public_r;
CheckCanPostUrl();//验证来源
$bid=(int)getcvar(‘feedbackbid’);
if(empty($bid))
{
$bid=intval($add[bid]);
}
if(empty($bid))
{
printerror(“EmptyFeedbackname”,”history.go(-1)”,1);
}
//验证码
$keyvname=’checkfeedbackkey’;
if($public_r[‘fbkey_ok’])
{
ecmsCheckShowKey($keyvname,$add[‘key’],1);
}
//版面是否存在
$br=$empire->fetch1(“select bid,enter,mustenter,filef,groupid,checkboxf from {$dbtbpre}enewsfeedbackclass where bid=’$bid’;”);
if(empty($br[‘bid’]))
{
printerror(“EmptyFeedback”,”history.go(-1)”,1);
}
//权限
if($br[‘groupid’])
{
$user=islogin();
if($level_r[$br[groupid]][level]>$level_r[$user[groupid]][level])
{
printerror(“HaveNotEnLevel”,”history.go(-1)”,1);
}
}
$pr=$empire->fetch1(“select feedbacktfile,feedbackfilesize,feedbackfiletype from {$dbtbpre}enewspublic limit 1”);
//必填项
$mustr=explode(“,”,$br[‘mustenter’]);
$count=count($mustr);

for($i=1;$i<$count-1;$i++)
{
$mf=$mustr[$i];
if(strstr($br[‘filef’],”,”.$mf.”,”))//附件
{
if(!$pr[‘feedbacktfile’])
{
printerror(“NotOpenFBFile”,””,1);
}
if(!$_FILES[$mf][‘name’])
{
printerror(“EmptyFeedbackname”,””,1);
}
}
else
{
$chmustval=ReturnFBCheckboxAddF($add[$mf],$mf,$br[‘checkboxf’]);
if(!trim($chmustval))
{
echo $add[$mf].’-‘.$mf.’-‘.$br[‘checkboxf’];
exit();
printerror(“EmptyFeedbackname”,””,1);
}
}
}

$saytime=date(“Y-m-d H:i:s”);
//字段处理
$dh=””;
$tranf=””;
$record=”<!–record–>”;
$field=”<!–field—>”;
$er=explode($record,$br[‘enter’]);
$count=count($er);
for($i=0;$i<$count-1;$i++)
{
$er1=explode($field,$er[$i]);
$f=$er1[1];
//附件
$add[$f]=str_replace(‘[!#@-‘,”,$add[$f]);
if(strstr($br[‘filef’],”,”.$f.”,”))
{
if($_FILES[$f][‘name’])
{
if(!$pr[‘feedbacktfile’])
{
printerror(“NotOpenFBFile”,””,1);
}
$filetype=GetFiletype($_FILES[$f][‘name’]);//取得文件类型
if(CheckSaveTranFiletype($filetype))
{
printerror(“NotQTranFiletype”,””,1);
}
if(!strstr($pr[‘feedbackfiletype’],”|”.$filetype.”|”))
{
printerror(“NotQTranFiletype”,””,1);
}
if($_FILES[$f][‘size’]>$pr[‘feedbackfilesize’]*1024)//文件大小
{
printerror(“TooBigQTranFile”,””,1);
}
$tranf.=$dh.$f;
$dh=”,”;
$fval=”[!#@-“.$f.”-@!]”;
}
else
{
$fval=””;
}
}
else
{
$add[$f]=ReturnFBCheckboxAddF($add[$f],$f,$br[‘checkboxf’]);
$fval=$add[$f];
}
$addf.=”,`”.$f.”`”;
$addval.=”,'”.doaddslashes(RepPostStr($fval)).”‘”;
}
$type=0;
$userid=(int)getcvar(‘mluserid’);
$username=RepPostVar(getcvar(‘mlusername’));
//上传附件
if($tranf)
{
$filepath=date(“Y-m-d”);
$path1=ECMS_PATH.”d/file/p/”.$filepath;
$mk=DoMkdir($path1);//不存在则建立目录
$dh=””;
$tranr=explode(“,”,$tranf);
$count=count($tranr);
for($i=0;$i<$count;$i++)
{
$tf=$tranr[$i];
//文件名
$filetype=GetFiletype($_FILES[$tf][‘name’]);//取得文件类型
$insertfile=md5(uniqid(microtime()));
$tranfilename=$insertfile.$filetype;
$path=$path1.”/”.$tranfilename;
//上传文件
$cp=@move_uploaded_file($_FILES[$tf][‘tmp_name’],$path);
if($cp)
{
DoChmodFile($path);
//写入数据库
$filetime=$saytime;
$filesize=(int)$_FILES[$tf][‘size’];
$classid=(int)$classid;
$sql=$empire->query(“insert into {$dbtbpre}enewsfile(filename,filesize,adduser,path,filetime,classid,no,type,id,cjid,fpath) values(‘$tranfilename’,$filesize,'[Member]”.$username.”‘,’$filepath’,’$filetime’,$classid,'[FB]”.addslashes(RepPostStr($add[title])).”‘,’$type’,0,0,’$public_r[fpath]’);”);
$repfval=$filepath.”/”.$tranfilename;
$filename.=$dh.$tranfilename;
$dh=”,”;
}
else
{
$repfval=””;
}
$addval=str_replace(“[!#@-“.$tf.”-@!]”,$repfval,$addval);
}
}
$ip=egetip();
$sql=$empire->query(“insert into {$dbtbpre}enewsfeedback(bid,saytime,ip,filepath,filename,userid,username”.$addf.”) values(‘$bid’,’$saytime’,’$ip’,’$filepath’,’$filename’,$userid,’$username'”.$addval.”);”);
ecmsEmptyShowKey($keyvname);//清空验证码
if($sql)
{
            $feed_id = $empire->lastid();
$feedback_body = feedback_body($feed_id);
@include(ECMS_PATH.’e/class/SendEmail.inc.php’);
EcmsToSendMail(‘要发送的邮件地址’,$feedback_body[1],$feedback_body[2]);

$feedback_url=empty($_POST[‘feedback_url’])?$public_r[newsurl]:$_POST[‘feedback_url’];
$reurl=DoingReturnUrl($feedback_url,$add[‘ecmsfrom’]);
printerror(“AddFeedbackSuccess”,$reurl,1);
}
else
{printerror(“DbError”,”history.go(-1)”,1);}
}

/*—-信息反馈内容—-*/
function feedback_body($id)
{
global $empire,$dbtbpre,$level_r,$public_r;
$r=$empire->fetch1(“select * from {$dbtbpre}enewsfeedback where id=’$id’ limit 1”);
$br=$empire->fetch1(“select bname,enter,filef from {$dbtbpre}enewsfeedbackclass where bid=’$r[bid]'”);
$username=”游客”;
if($r[‘userid’])
{
$username=”<a href=’../member/AddMember.php?enews=EditMember&userid=”.$r[‘userid’].”‘ target=_blank>”.$r[‘username’].”</a>”;
}
$record=”<!–record–>”;
$field=”<!–field—>”;
$er=explode($record,$br[‘enter’]);
$count=count($er);
for($i=0;$i<$count-1;$i++)
{
$er1=explode($field,$er[$i]);
//附件
if(strstr($br[‘filef’],”,”.$er1[1].”,”))
{
if($r[$er1[1]])
{
$fileurl=$public_r[‘fileurl’].”p/”.$r[$er1[1]];
$val=”<b>附件:</b><a href='”.$fileurl.”‘ target=_blank>”.$r[$er1[1]].”</a>”;
}
else
{
$val=””;
}
}
else
{
$val=$r[$er1[1]];
}
$feedbackinfo.=”<tr bgcolor=’#FFFFFF’><td height=25>”.$er1[0].”:</td><td><div align=left>”.nl2br($val).”</div></td></tr>”;
}
$body[1]=$br[bname];
$body[2]='<table width=”100%” border=”0″ align=”center” cellpadding=”3″ cellspacing=”1″ bgcolor=”#8CBDEF”> <tr class=header>
<td height=”25″ colspan=”2″ bgcolor=”#8CBDEF”><font color=”#FFFFFF”>&nbsp;&nbsp;’.$br[‘bname’].'</font></td>
</tr><tr bgcolor=”#FFFFFF”>
<td height=”25″ width=”19%”>发送时间:</td>
<td height=”25″ width=”81%” align=left>’.date(‘Y-m-d’,time()).'</td>
</tr>’.$feedbackinfo.'</table>’;
return $body;
}

还要注意,邮件设置发送调的帝国自带的功能,要在后系统设置是设置才能正常发送。如果你能用帝国自带的找回密码邮件发送,这个就能用。设置请看下图

文章底部广告位
本文来自网络,不代表春哥博客立场,转载请注明出处:https://blog.qlzhan.com/515.html

作者: admin

上一篇
下一篇

发表评论

您的电子邮箱地址不会被公开。

返回顶部