q_functions.php 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. <?php
  2. define('InEmpireCMSQfun',TRUE);
  3. //自定义字段返回模板字段处理
  4. function doReturnAddTempf($temp){
  5. $record="<!--record-->";
  6. $field="<!--field--->";
  7. $r=explode($record,$temp);
  8. $count=count($r);
  9. $str=',';
  10. for($i=0;$i<$count-1;$i++)
  11. {
  12. $r1=explode($field,$r[$i]);
  13. $str.=$r1[1].",";
  14. }
  15. if($str==',,')
  16. {
  17. $str=',';
  18. }
  19. return $str;
  20. }
  21. //返回字段
  22. function ReturnAddF($modid,$rdata=0){
  23. global $empire,$dbtbpre;
  24. $modid=(int)$modid;
  25. $record="<!--record-->";
  26. $field="<!--field--->";
  27. $mr=$empire->fetch1("select tempvar,enter,listandf,setandf,listtempvar from {$dbtbpre}enewsmod where mid='$modid'");
  28. //模板字段
  29. if($rdata==1)//内容
  30. {
  31. $ret_r['tempvar']=doReturnAddTempf($mr['tempvar']);
  32. }
  33. elseif($rdata==2)//列表
  34. {
  35. $ret_r['listtempvar']=doReturnAddTempf($mr['listtempvar']);
  36. }
  37. else//全部
  38. {
  39. $ret_r['tempvar']=doReturnAddTempf($mr['tempvar']);
  40. $ret_r['listtempvar']=doReturnAddTempf($mr['listtempvar']);
  41. }
  42. $ret_r['listandf']=$mr['listandf'];
  43. $ret_r['setandf']=$mr['setandf'];
  44. return $ret_r;
  45. }
  46. //替换php代码
  47. function RepPhpAspJspcode($string){
  48. //$string=str_replace("<?xml","[!--ecms.xml--]",$string);
  49. $string=str_replace("<\\","&lt;\\",$string);
  50. $string=str_replace("\\>","\\&gt;",$string);
  51. $string=str_replace("<?","&lt;?",$string);
  52. $string=str_replace("<%","&lt;%",$string);
  53. if(@stristr($string,' language'))
  54. {
  55. $string=preg_replace(array('!<script!i','!</script>!i'),array('&lt;script','&lt;/script&gt;'),$string);
  56. }
  57. //$string=str_replace("[!--ecms.xml--]","<?xml",$string);
  58. return $string;
  59. }
  60. //组合复选框数据
  61. function ReturnFBCheckboxAddF($r,$f,$checkboxf){
  62. $val=$r;
  63. if(is_array($r)&&strstr($checkboxf,','.$f.','))
  64. {
  65. $val='';
  66. $count=count($r);
  67. for($i=0;$i<$count;$i++)
  68. {
  69. $val.=$r[$i].'|';
  70. }
  71. if($val)
  72. {
  73. $val='|'.$val;
  74. }
  75. }
  76. return $val;
  77. }
  78. //提交反馈信息
  79. function AddFeedback($add){
  80. global $empire,$dbtbpre,$level_r,$public_r;
  81. CheckCanPostUrl();//验证来源
  82. if($add['bid'])
  83. {
  84. $bid=(int)$add['bid'];
  85. }
  86. else
  87. {
  88. $bid=(int)getcvar('feedbackbid');
  89. }
  90. if(empty($bid))
  91. {
  92. printerror("EmptyFeedbackname","history.go(-1)",1);
  93. }
  94. //验证码
  95. $keyvname='checkfeedbackkey';
  96. if($public_r['fbkey_ok'])
  97. {
  98. ecmsCheckShowKey($keyvname,$add['key'],1);
  99. }
  100. //版面是否存在
  101. $br=$empire->fetch1("select bid,enter,mustenter,filef,groupid,checkboxf from {$dbtbpre}enewsfeedbackclass where bid='$bid';");
  102. if(empty($br['bid']))
  103. {
  104. printerror("EmptyFeedback","history.go(-1)",1);
  105. }
  106. //权限
  107. $user=array();
  108. if($br['groupid'])
  109. {
  110. $user=islogin();
  111. if($level_r[$br[groupid]][level]>$level_r[$user[groupid]][level])
  112. {
  113. printerror("HaveNotEnLevel","history.go(-1)",1);
  114. }
  115. }
  116. //实名验证
  117. eCheckHaveTruename('fb',$user['userid'],$user['username'],$user['isern'],$user['checked'],0);
  118. $pr=$empire->fetch1("select feedbacktfile,feedbackfilesize,feedbackfiletype from {$dbtbpre}enewspublic limit 1");
  119. //必填项
  120. $mustr=explode(",",$br['mustenter']);
  121. $count=count($mustr);
  122. for($i=1;$i<$count-1;$i++)
  123. {
  124. $mf=$mustr[$i];
  125. if(strstr($br['filef'],",".$mf.","))//附件
  126. {
  127. if(!$pr['feedbacktfile'])
  128. {
  129. printerror("NotOpenFBFile","",1);
  130. }
  131. if(!$_FILES[$mf]['name'])
  132. {
  133. printerror("EmptyFeedbackname","",1);
  134. }
  135. }
  136. else
  137. {
  138. $chmustval=ReturnFBCheckboxAddF($add[$mf],$mf,$br['checkboxf']);
  139. if(!trim($chmustval))
  140. {
  141. printerror("EmptyFeedbackname","",1);
  142. }
  143. }
  144. }
  145. $saytime=date("Y-m-d H:i:s");
  146. //字段处理
  147. $dh="";
  148. $tranf="";
  149. $record="<!--record-->";
  150. $field="<!--field--->";
  151. $er=explode($record,$br['enter']);
  152. $count=count($er);
  153. for($i=0;$i<$count-1;$i++)
  154. {
  155. $er1=explode($field,$er[$i]);
  156. $f=$er1[1];
  157. //附件
  158. $add[$f]=str_replace('[!#@-','ecms',$add[$f]);
  159. if(strstr($br['filef'],",".$f.","))
  160. {
  161. if($_FILES[$f]['name'])
  162. {
  163. if(!$pr['feedbacktfile'])
  164. {
  165. printerror("NotOpenFBFile","",1);
  166. }
  167. $filetype=GetFiletype($_FILES[$f]['name']);//取得文件类型
  168. if(CheckSaveTranFiletype($filetype))
  169. {
  170. printerror("NotQTranFiletype","",1);
  171. }
  172. if(!strstr($pr['feedbackfiletype'],"|".$filetype."|"))
  173. {
  174. printerror("NotQTranFiletype","",1);
  175. }
  176. if($_FILES[$f]['size']>$pr['feedbackfilesize']*1024)//文件大小
  177. {
  178. printerror("TooBigQTranFile","",1);
  179. }
  180. $tranf.=$dh.$f;
  181. $dh=",";
  182. $fval="[!#@-".$f."-@!]";
  183. }
  184. else
  185. {
  186. $fval="";
  187. }
  188. }
  189. else
  190. {
  191. $add[$f]=ReturnFBCheckboxAddF($add[$f],$f,$br['checkboxf']);
  192. $fval=$add[$f];
  193. }
  194. $addf.=",`".$f."`";
  195. $addval.=",'".addslashes(RepPostStr($fval))."'";
  196. }
  197. $type=0;
  198. $classid=0;
  199. $filename='';
  200. $filepath='';
  201. $userid=(int)getcvar('mluserid');
  202. $username=RepPostVar(getcvar('mlusername'));
  203. $filepass=ReturnTranFilepass();
  204. //上传附件
  205. if($tranf)
  206. {
  207. $dh="";
  208. $tranr=explode(",",$tranf);
  209. $count=count($tranr);
  210. for($i=0;$i<$count;$i++)
  211. {
  212. $tf=$tranr[$i];
  213. $tfr=DoTranFile($_FILES[$tf]['tmp_name'],$_FILES[$tf]['name'],$_FILES[$tf]['type'],$_FILES[$tf]['size'],$classid);
  214. if($tfr['tran'])
  215. {
  216. $filepath=$tfr[filepath];
  217. //写入数据库
  218. $filetime=$saytime;
  219. $filesize=(int)$_FILES[$tf]['size'];
  220. eInsertFileTable($tfr[filename],$filesize,$tfr[filepath],'[Member]'.$username,$classid,'[FB]'.addslashes(RepPostStr($add[title])),$type,$filepass,$filepass,$public_r[fpath],0,4,0);
  221. $repfval=($tfr[filepath]?$tfr[filepath].'/':'').$tfr[filename];
  222. $filename.=$dh.$tfr[filename];
  223. $dh=",";
  224. }
  225. else
  226. {
  227. $repfval="";
  228. }
  229. $addval=str_replace("[!#@-".$tf."-@!]",$repfval,$addval);
  230. }
  231. }
  232. $filepath=dgdb_tosave($filepath);
  233. $filename=dgdb_tosave($filename);
  234. $ip=egetip();
  235. $eipport=egetipport();
  236. $sql=$empire->query("insert into {$dbtbpre}enewsfeedback(bid,saytime,ip,filepath,filename,userid,username,haveread,eipport".$addf.") values('$bid','$saytime','$ip','$filepath','$filename','$userid','$username',0,'$eipport'".$addval.");");
  237. $fid=$empire->lastid();
  238. //更新附件
  239. UpdateTheFileOther(4,$fid,$filepass,'other');
  240. ecmsEmptyShowKey($keyvname);//清空验证码
  241. if($sql)
  242. {
  243. $reurl=DoingReturnUrl("../tool/feedback/?bid=$bid",$add['ecmsfrom']);
  244. printerror("AddFeedbackSuccess",$reurl,1);
  245. }
  246. else
  247. {printerror("DbError","history.go(-1)",1);}
  248. }
  249. //--------------发送错误报告
  250. function AddError($add){
  251. global $empire,$class_r,$dbtbpre,$public_r;
  252. CheckCanPostUrl();//验证来源
  253. $id=(int)$add['id'];
  254. $classid=(int)$add['classid'];
  255. if(!$classid||!$id||!trim($add[errortext]))
  256. {printerror("EmptyErrortext","history.go(-1)",1);}
  257. //验证码
  258. $keyvname='checkreportkey';
  259. if($public_r['reportkey'])
  260. {
  261. ecmsCheckShowKey($keyvname,$add['key'],1);
  262. }
  263. //返回标题链接
  264. if(empty($class_r[$classid][tbname]))
  265. {
  266. printerror("ErrorUrl","history.go(-1)",1);
  267. }
  268. $r=$empire->fetch1("select isurl,titleurl,classid,id from {$dbtbpre}ecms_".$class_r[$classid][tbname]." where id='$id' limit 1");
  269. if(empty($r[id])||$r['classid']!=$classid)
  270. {
  271. printerror("ErrorUrl","history.go(-1)",1);
  272. }
  273. $cid=(int)$add[cid];
  274. $titleurl=sys_ReturnBqTitleLink($r);
  275. $email=RepPostStr($add[email]);
  276. $ip=egetip();
  277. $errortext=RepPostStr($add[errortext]);
  278. $errortime=date("Y-m-d H:i:s");
  279. $sql=$empire->query("insert into {$dbtbpre}enewsdownerror(id,errortext,errorip,errortime,email,classid,cid) values($id,'".addslashes($errortext)."','$ip','$errortime','".addslashes($email)."',$classid,'$cid');");
  280. ecmsEmptyShowKey($keyvname);//清空验证码
  281. if($sql)
  282. {
  283. printerror("AddErrorSuccess",$titleurl,1);
  284. }
  285. else
  286. {
  287. printerror("DbError","history.go(-1)",1);
  288. }
  289. }
  290. //替换全局模板变量
  291. function ReplaceTempvar($temp){
  292. global $empire;
  293. if(empty($temp))
  294. {return $temp;}
  295. $sql=$empire->query("select myvar,varvalue from ".GetTemptb("enewstempvar")." where isclose=0 order by myorder desc,varid");
  296. while($r=$empire->fetch($sql))
  297. {
  298. $myvar="[!--temp.".$r[myvar]."--]";
  299. $temp=str_replace($myvar,$r[varvalue],$temp);
  300. }
  301. return $temp;
  302. }
  303. ?>