PageRenderTime 47ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/e/class/tempfun.php

https://github.com/westeast/xwdede
PHP | 1742 lines | 1536 code | 58 blank | 148 comment | 164 complexity | ccaa217f872a69b88be6841e3cdf516a MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. //修改留言板模板
  3. function EditGbooktemp($temptext,$userid,$username){
  4. global $empire,$public_r,$dbtbpre;
  5. if(!$temptext)
  6. {printerror("EmptyTemptext","history.go(-1)");}
  7. //验证权限
  8. CheckLevel($userid,$username,$classid,"template");
  9. $temptext=RepPhpAspJspcode($temptext);
  10. $gid=(int)$_POST['gid'];
  11. $sql=$empire->query("update ".GetDoTemptb("enewspubtemp",$gid)." set gbooktemp='".addslashes($temptext)."' limit 1");
  12. //备份模板
  13. AddEBakTemp('pubgbooktemp',$gid,1,'',$temptext,0,0,'',0,0,'',0,0,0,$userid,$username);
  14. if($gid==$public_r['deftempid']||(!$public_r['deftempid']&&($gid==1||$gid==0)))
  15. {
  16. ReGbooktemp();
  17. }
  18. if($sql)
  19. {
  20. //操作日志
  21. insert_dolog("gid=$gid");
  22. printerror("EditGbooktempSuccess","template/EditPublicTemp.php?tname=gbooktemp&gid=$gid#gbooktemp");
  23. }
  24. else
  25. {printerror("DbError","history.go(-1)");}
  26. }
  27. //修改控制面板模板
  28. function EditCptemp($temptext,$userid,$username){
  29. global $empire,$public_r,$dbtbpre;
  30. if(!$temptext)
  31. {printerror("EmptyTemptext","history.go(-1)");}
  32. //验证权限
  33. CheckLevel($userid,$username,$classid,"template");
  34. $temptext=RepPhpAspJspcode($temptext);
  35. $gid=(int)$_POST['gid'];
  36. $sql=$empire->query("update ".GetDoTemptb("enewspubtemp",$gid)." set cptemp='".addslashes($temptext)."' limit 1");
  37. //备份模板
  38. AddEBakTemp('pubcptemp',$gid,1,'',$temptext,0,0,'',0,0,'',0,0,0,$userid,$username);
  39. if($gid==$public_r['deftempid']||(!$public_r['deftempid']&&($gid==1||$gid==0)))
  40. {
  41. ReCptemp();
  42. }
  43. if($sql)
  44. {
  45. //操作日志
  46. insert_dolog("gid=$gid");
  47. printerror("EditCptempSuccess","template/EditPublicTemp.php?tname=cptemp&gid=$gid#cptemp");
  48. }
  49. else
  50. {printerror("DbError","history.go(-1)");}
  51. }
  52. //修改登陆状态模板
  53. function EditLoginIframe($temptext,$userid,$username){
  54. global $empire,$public_r,$dbtbpre;
  55. if(!$temptext)
  56. {printerror("EmptyTemptext","history.go(-1)");}
  57. //验证权限
  58. CheckLevel($userid,$username,$classid,"template");
  59. $temptext=RepPhpAspJspcode($temptext);
  60. $gid=(int)$_POST['gid'];
  61. $sql=$empire->query("update ".GetDoTemptb("enewspubtemp",$gid)." set loginiframe='".addslashes($temptext)."' limit 1");
  62. //备份模板
  63. AddEBakTemp('publoginiframe',$gid,1,'',$temptext,0,0,'',0,0,'',0,0,0,$userid,$username);
  64. if($gid==$public_r['deftempid']||(!$public_r['deftempid']&&($gid==1||$gid==0)))
  65. {
  66. ReLoginIframe();
  67. }
  68. if($sql)
  69. {
  70. //操作日志
  71. insert_dolog("gid=$gid");
  72. printerror("EditLoginIframeSuccess","template/EditPublicTemp.php?tname=loginiframe&gid=$gid#loginiframe");
  73. }
  74. else
  75. {printerror("DbError","history.go(-1)");}
  76. }
  77. //修改JS调用登陆状态模板
  78. function EditLoginJstemp($temptext,$userid,$username){
  79. global $empire,$public_r,$dbtbpre;
  80. if(!$temptext)
  81. {printerror("EmptyTemptext","history.go(-1)");}
  82. //验证权限
  83. CheckLevel($userid,$username,$classid,"template");
  84. $temptext=RepPhpAspJspcode($temptext);
  85. $gid=(int)$_POST['gid'];
  86. $sql=$empire->query("update ".GetDoTemptb("enewspubtemp",$gid)." set loginjstemp='".addslashes($temptext)."' limit 1");
  87. //备份模板
  88. AddEBakTemp('publoginjstemp',$gid,1,'',$temptext,0,0,'',0,0,'',0,0,0,$userid,$username);
  89. if($gid==$public_r['deftempid']||(!$public_r['deftempid']&&($gid==1||$gid==0)))
  90. {
  91. ReLoginIframe();
  92. }
  93. if($sql)
  94. {
  95. //操作日志
  96. insert_dolog("gid=$gid");
  97. printerror("EditLoginJstempSuccess","template/EditPublicTemp.php?tname=loginjstemp&gid=$gid#loginjstemp");
  98. }
  99. else
  100. {printerror("DbError","history.go(-1)");}
  101. }
  102. //修改全站搜索模板
  103. function EditSchallTemp($temptext,$sub,$formatdate,$userid,$username){
  104. global $empire,$public_r,$dbtbpre;
  105. if(!$temptext)
  106. {printerror("EmptyTemptext","history.go(-1)");}
  107. //验证权限
  108. CheckLevel($userid,$username,$classid,"template");
  109. $temptext=RepPhpAspJspcode($temptext);
  110. $gid=(int)$_POST['gid'];
  111. $sub=(int)$sub;
  112. $sql=$empire->query("update ".GetDoTemptb("enewspubtemp",$gid)." set schalltemp='".addslashes($temptext)."',schallsubnum='$sub',schalldate='".addslashes($formatdate)."' limit 1");
  113. //备份模板
  114. AddEBakTemp('pubschalltemp',$gid,1,'',$temptext,$sub,0,'',0,0,$formatdate,0,0,0,$userid,$username);
  115. if($gid==$public_r['deftempid']||(!$public_r['deftempid']&&($gid==1||$gid==0)))
  116. {
  117. ReSchAlltemp();
  118. }
  119. if($sql)
  120. {
  121. //操作日志
  122. insert_dolog("gid=$gid");
  123. printerror("EditSchallTempSuccess","template/EditPublicTemp.php?tname=schalltemp&gid=$gid#schalltemp");
  124. }
  125. else
  126. {printerror("DbError","history.go(-1)");}
  127. }
  128. //增加标签
  129. function AddBq($add,$bqsay,$userid,$username){
  130. global $empire,$dbtbpre;
  131. if(!$add[bqname]||!$add[funname]||!$add[bq])
  132. {printerror("EmptyBqname","history.go(-1)");}
  133. //验证权限
  134. CheckLevel($userid,$username,$classid,"bq");
  135. //标签重复
  136. $num=$empire->gettotal("select count(*) as total from {$dbtbpre}enewsbq where bq='$add[bq]' limit 1");
  137. if($num)
  138. {printerror("ReBq","history.go(-1)");}
  139. //函数是否存在
  140. if(!function_exists($add[funname]))
  141. {
  142. printerror("NotFun","history.go(-1)");
  143. }
  144. $classid=(int)$add['classid'];
  145. $add[isclose]=(int)$add[isclose];
  146. $myorder=(int)$add[myorder];
  147. $bqsay=RepPhpAspJspcodeText($bqsay);
  148. $sql=$empire->query("insert into {$dbtbpre}enewsbq(bqname,bqsay,funname,bq,issys,bqgs,isclose,classid,myorder) values('".$add[bqname]."','".addslashes($bqsay)."','$add[funname]','$add[bq]',0,'".addslashes($add[bqgs])."',$add[isclose],$classid,'$myorder');");
  149. $bqid=$empire->lastid();
  150. if($sql)
  151. {
  152. //操作日志
  153. insert_dolog("bqid=".$bqid."<br>bqname=".$add[bqname]);
  154. printerror("AddBqSuccess","template/AddBq.php?enews=AddBq");
  155. }
  156. else
  157. {printerror("DbError","history.go(-1)");}
  158. }
  159. //修改标签
  160. function EditBq($add,$bqsay,$userid,$username){
  161. global $empire,$dbtbpre;
  162. $add[bqid]=(int)$add[bqid];
  163. if(!$add[bqname]||!$add[funname]||!$add[bq]||!$add[bqid])
  164. {printerror("EmptyBqname","history.go(-1)");}
  165. //验证权限
  166. CheckLevel($userid,$username,$classid,"bq");
  167. //标签重复
  168. $num=$empire->gettotal("select count(*) as total from {$dbtbpre}enewsbq where bq='$add[bq]' and bqid<>'$add[bqid]' limit 1");
  169. if($num)
  170. {printerror("ReBq","history.go(-1)");}
  171. //函数是否存在
  172. if(!function_exists($add[funname]))
  173. {
  174. printerror("NotFun","history.go(-1)");
  175. }
  176. $bqsay=RepPhpAspJspcodeText($bqsay);
  177. $classid=(int)$add['classid'];
  178. $add[isclose]=(int)$add[isclose];
  179. $myorder=(int)$add[myorder];
  180. $sql=$empire->query("update {$dbtbpre}enewsbq set bqname='$add[bqname]',bqsay='".addslashes($bqsay)."',funname='$add[funname]',bq='$add[bq]',bqgs='".addslashes($add[bqgs])."',isclose=$add[isclose],classid=$classid,myorder='$myorder' where bqid='$add[bqid]'");
  181. if($sql)
  182. {
  183. //操作日志
  184. insert_dolog("bqid=".$add[bqid]."<br>bqname=".$add[bqname]);
  185. printerror("EditBqSuccess","template/ListBq.php?classid=$add[cid]");
  186. }
  187. else
  188. {printerror("DbError","history.go(-1)");}
  189. }
  190. //删除标签
  191. function DelBq($bqid,$cid,$userid,$username){
  192. global $empire,$dbtbpre;
  193. $bqid=(int)$bqid;
  194. if(empty($bqid))
  195. {printerror("NotDelBqid","history.go(-1)");}
  196. //验证权限
  197. CheckLevel($userid,$username,$classid,"bq");
  198. $num=$empire->gettotal("select count(*) as total from {$dbtbpre}enewsbq where bqid='$bqid' and issys=0");
  199. if(empty($num))
  200. {printerror("NotDelSysBq","history.go(-1)");}
  201. $r=$empire->fetch1("select bqname from {$dbtbpre}enewsbq where bqid='$bqid'");
  202. $sql=$empire->query("delete from {$dbtbpre}enewsbq where bqid='$bqid'");
  203. if($sql)
  204. {
  205. //操作日志
  206. insert_dolog("bqid=".$bqid."<br>bqname=".$r[bqname]);
  207. printerror("DelBqSuccess","template/ListBq.php?classid=$cid");
  208. }
  209. else
  210. {printerror("DbError","history.go(-1)");}
  211. }
  212. //修改搜索页面
  213. function EditSearchTemp($tempname,$temptext,$userid,$username){
  214. global $empire,$dbtbpre,$public_r;
  215. if(empty($temptext)||empty($tempname))
  216. {printerror("EmptySearchTemp","history.go(-1)");}
  217. //操作权限
  218. CheckLevel($userid,$username,$classid,"template");
  219. $temptext=RepPhpAspJspcode($temptext);
  220. $tempname=RepPostVar($tempname);
  221. if($tempname=="searchtemp")//搜索表单模板
  222. {
  223. $f="searchtemp";
  224. $tname="searchformtemp";
  225. $temptype='pubsearchtemp';
  226. }
  227. elseif($tempname=="searchjstemp")//搜索JS模板(横向)
  228. {
  229. $temptext=str_replace("\r\n","",$temptext);
  230. $f="searchjstemp";
  231. $tname="searchformjs";
  232. $temptype='pubsearchjstemp';
  233. }
  234. else//搜索JS模板(纵向)
  235. {
  236. $temptext=str_replace("\r\n","",$temptext);
  237. $f="searchjstemp1";
  238. $tname="searchformjs1";
  239. $temptype='pubsearchjstemp1';
  240. }
  241. $gid=(int)$_POST['gid'];
  242. $sql=$empire->query("update ".GetDoTemptb("enewspubtemp",$gid)." set ".$f."='".addslashes($temptext)."'");
  243. //备份模板
  244. AddEBakTemp($temptype,$gid,1,'',$temptext,0,0,'',0,0,'',0,0,0,$userid,$username);
  245. if($gid==$public_r['deftempid']||(!$public_r['deftempid']&&($gid==1||$gid==0)))
  246. {
  247. GetSearch();
  248. }
  249. if($sql)
  250. {
  251. //操作日志
  252. insert_dolog("temp=$f&gid=$gid");
  253. printerror("EditSearchTempSuccess","template/EditPublicTemp.php?tname=$tname&gid=$gid#$tempname");
  254. }
  255. else
  256. {printerror("DbError","history.go(-1)");}
  257. }
  258. //修改相关链接模板
  259. function EditOtherLinkTemp($tempname,$temptext,$userid,$username){
  260. global $empire,$dbtbpre;
  261. if(empty($temptext)||empty($tempname))
  262. {printerror("EmptyOtherLinkTemp","history.go(-1)");}
  263. //操作权限
  264. CheckLevel($userid,$username,$classid,"template");
  265. $tempname=RepPostVar($tempname);
  266. $temptext=RepPhpAspJspcode($temptext);
  267. $f="otherlinktemp";
  268. $tname="otherlinktemp";
  269. $otherlinktempsub=(int)$_POST['otherlinktempsub'];
  270. $otherlinktempdate=$_POST['otherlinktempdate'];
  271. $gid=(int)$_POST['gid'];
  272. $sql=$empire->query("update ".GetDoTemptb("enewspubtemp",$gid)." set ".$f."='".addslashes($temptext)."',otherlinktempsub=$otherlinktempsub,otherlinktempdate='".addslashes($otherlinktempdate)."'");
  273. //备份模板
  274. AddEBakTemp('pubotherlinktemp',$gid,1,'',$temptext,0,0,'',0,0,$otherlinktempdate,$otherlinktempsub,0,0,$userid,$username);
  275. if($sql)
  276. {
  277. //操作日志
  278. insert_dolog("temp=$f&gid=$gid");
  279. printerror("EditOtherLinkTempSuccess","template/EditPublicTemp.php?tname=$tname&gid=$gid#$tempname");
  280. }
  281. else
  282. {printerror("DbError","history.go(-1)");}
  283. }
  284. //修改其它公共模板
  285. function EditOtherPubTemp($tempname,$temptext,$userid,$username){
  286. global $empire,$dbtbpre,$public_r;
  287. if(empty($temptext)||empty($tempname))
  288. {printerror("EmptyEditDownTemp","history.go(-1)");}
  289. //操作权限
  290. CheckLevel($userid,$username,$classid,"template");
  291. $edittemplist=',pljstemp,downpagetemp,downsofttemp,onlinemovietemp,listpagetemp,';
  292. $temptext=RepPhpAspJspcode($temptext);
  293. $tempname=RepPostVar($tempname);
  294. if(!strstr($edittemplist,','.$tempname.','))
  295. {
  296. printerror("EmptyEditDownTemp","history.go(-1)");
  297. }
  298. if($tempname=='downsofttemp')
  299. {
  300. $temptype='pubdownsofttemp';
  301. }
  302. elseif($tempname=='onlinemovietemp')
  303. {
  304. $temptype='pubonlinemovietemp';
  305. }
  306. elseif($tempname=='listpagetemp')
  307. {
  308. $temptype='publistpagetemp';
  309. }
  310. elseif($tempname=='pljstemp')
  311. {
  312. $temptype='pubpljstemp';
  313. }
  314. elseif($tempname=='downpagetemp')
  315. {
  316. $temptype='pubdownpagetemp';
  317. }
  318. $gid=(int)$_POST['gid'];
  319. $sql=$empire->query("update ".GetDoTemptb("enewspubtemp",$gid)." set ".$tempname."='".addslashes($temptext)."'");
  320. //备份模板
  321. AddEBakTemp($temptype,$gid,1,'',$temptext,0,0,'',0,0,'',0,0,0,$userid,$username);
  322. if($gid==$public_r['deftempid']||(!$public_r['deftempid']&&($gid==1||$gid==0)))
  323. {
  324. if($tempname=="downsofttemp"||$tempname=="onlinemovietemp"||$tempname=="listpagetemp")
  325. {
  326. GetConfig();
  327. }
  328. elseif($tempname=="downpagetemp")
  329. {
  330. GetDownloadPage();
  331. }
  332. elseif($tempname=="pljstemp")
  333. {
  334. GetPlJsPage();
  335. }
  336. else
  337. {
  338. }
  339. }
  340. if($sql)
  341. {
  342. //操作日志
  343. insert_dolog("temp=$tempname&gid=$gid");
  344. printerror("EditDownTempSuccess","template/EditPublicTemp.php?tname=$tempname&gid=$gid#$tempname");
  345. }
  346. else
  347. {printerror("DbError","history.go(-1)");}
  348. }
  349. //修改首页模板
  350. function EditIndextemp($temptext,$userid,$username){
  351. global $empire,$dbtbpre,$public_r;
  352. if(!$temptext)
  353. {
  354. printerror("EmptyIndexTemp","history.go(-1)");
  355. }
  356. CheckLevel($userid,$username,$classid,"template");//操作权限
  357. $temptext=RepPhpAspJspcode($temptext);
  358. $gid=(int)$_POST['gid'];
  359. $sql=$empire->query("update ".GetDoTemptb("enewspubtemp",$gid)." set indextemp='".addslashes($temptext)."'");
  360. //备份模板
  361. AddEBakTemp('pubindextemp',$gid,1,'',$temptext,0,0,'',0,0,'',0,0,0,$userid,$username);
  362. //刷新首页
  363. if($gid==$public_r['deftempid']||(!$public_r['deftempid']&&($gid==1||$gid==0)))
  364. {
  365. NewsBq($classid,$temptext,1,0);
  366. //删除动态模板缓存文件
  367. DelOneTempTmpfile('indexpage');
  368. }
  369. if($sql)
  370. {
  371. insert_dolog("gid=$gid");//操作日志
  372. printerror("EditPublicTempSuccess","template/EditPublicTemp.php?tname=indextemp&gid=$gid");
  373. }
  374. else
  375. {
  376. printerror("DbError","history.go(-1)");
  377. }
  378. }
  379. //预览首页方案
  380. function PreviewIndexpage($tempid,$userid,$username){
  381. global $empire,$dbtbpre,$public_r,$emod_r,$class_r,$class_zr,$fun_r,$navclassid,$navinfor,$class_tr,$level_r,$etable_r;
  382. //验证权限
  383. CheckLevel($userid,$username,$classid,"template");
  384. $tempid=(int)$tempid;
  385. if(!$tempid)
  386. {
  387. printerror('ErrorUrl','');
  388. }
  389. $tempr=$empire->fetch1("select tempid,temptext from {$dbtbpre}enewsindexpage where tempid='$tempid'");
  390. if(!$tempr['tempid'])
  391. {
  392. printerror('ErrorUrl','');
  393. }
  394. $indextext=stripSlashes($tempr['temptext']);
  395. $indextext=ReplaceTempvar($indextext);//替换全局模板变量
  396. $pr=$empire->fetch1("select sitekey,siteintro from {$dbtbpre}enewspublic limit 1");
  397. //页面
  398. $pagetitle=htmlspecialchars($public_r['sitename']);
  399. $pagekey=htmlspecialchars($pr['sitekey']);
  400. $pagedes=htmlspecialchars($pr['siteintro']);
  401. $url="<a href=\"".$public_r[newsurl]."\">".$fun_r['index']."</a>";//栏目导航
  402. $onclick='';
  403. $file=ECMS_PATH.'e/data/tmp/indexpage'.$tempid.'.php';
  404. $indextext=ReplaceSvars($indextext,$url,0,$pagetitle,$pagekey,$pagedes,$add,0);
  405. $indextext=str_replace("[!--page.stats--]",$onclick,$indextext);
  406. //替换标签
  407. $indextext=DoRepEcmsLoopBq($indextext);
  408. $indextext=RepBq($indextext);
  409. //写文件
  410. WriteFiletext($file,AddCheckViewTempCode().$indextext);
  411. //读取文件内容
  412. ob_start();
  413. include($file);
  414. $string=ob_get_contents();
  415. ob_end_clean();
  416. $string=RepExeCode($string);//解析代码
  417. echo stripSlashes($string);
  418. exit();
  419. }
  420. //批量导入栏目模板
  421. function LoadTempInClass($path,$start,$userid,$username){
  422. global $empire,$public_r,$dbtbpre;
  423. //验证权限
  424. CheckLevel($userid,$username,$classid,"template");
  425. $start=(int)$start;
  426. if(empty($public_r[loadtempnum]))
  427. {$public_r[loadtempnum]=50;}
  428. $b=0;
  429. $sql=$empire->query("select classid,classtempid,islist from {$dbtbpre}enewsclass where islast=0 and islist<>1 and classid>$start order by classid limit ".$public_r[loadtempnum]);
  430. while($r=$empire->fetch($sql))
  431. {
  432. $b=1;
  433. $newstart=$r[classid];
  434. if($r[islist]==3)
  435. {
  436. continue;
  437. }
  438. $file="../data/LoadTemp/".$r[classid].".htm";
  439. if(file_exists($file))
  440. {
  441. $data=addslashes(ReadFiletext($file));
  442. $data=RepPhpAspJspcode($data);
  443. if($r[islist]==2)
  444. {
  445. $usql=$empire->query("update {$dbtbpre}enewsclassadd set classtext='".$data."' where classid='$r[classid]'");
  446. }
  447. else
  448. {
  449. $usql=$empire->query("update {$dbtbpre}enewsclasstemp set temptext='".$data."' where tempid='$r[classtempid]'");
  450. }
  451. NewsBq($r[classid],$data,0,0);
  452. }
  453. }
  454. if(empty($b))
  455. {
  456. //操作日志
  457. insert_dolog("");
  458. printerror("LoadClassTempSuccess","template/LoadTemp.php");
  459. }
  460. echo $fun_r['LoadOneTempSuccess']."(ID:<font color=red><b>".$newstart."</b></font>)<script>self.location.href='ecmstemp.php?enews=LoadTempInClass&start=$newstart';</script>";
  461. exit();
  462. }
  463. //批量更换栏目列表模板
  464. function ChangeClassListtemp($classid,$listtempid,$userid,$username){
  465. global $empire,$class_r,$dbtbpre;
  466. if(empty($listtempid))
  467. {printerror("EmptChangeListtempid","history.go(-1)");}
  468. //验证权限
  469. CheckLevel($userid,$username,$classid,"template");
  470. $listtempid=(int)$listtempid;
  471. if(empty($classid))
  472. {$where="classid<>0";}
  473. else
  474. {
  475. //中级栏目
  476. if(empty($class_r[$classid][islast]))
  477. {
  478. $where=ReturnClass($class_r[$classid][sonclass]);
  479. }
  480. //终极栏目
  481. else
  482. {
  483. $where="classid='$classid'";
  484. }
  485. }
  486. $sql=$empire->query("update {$dbtbpre}enewsclass set listtempid=$listtempid where ".$where);
  487. GetClass();
  488. if($sql)
  489. {
  490. //操作日志
  491. insert_dolog("classid=$classid&listtempid=$listtempid");
  492. printerror("ChangeClassListtempSuccess","history.go(-1)");
  493. }
  494. else
  495. {printerror("DbError","history.go(-1)");}
  496. }
  497. //导出标签
  498. function LoadOutBq($add,$userid,$username){
  499. global $empire,$dbtbpre;
  500. $bqid=(int)$add['bqid'];
  501. if(!$bqid||!$add['funvalue'])
  502. {
  503. printerror("EmptyLoadBqid","history.go(-1)");
  504. }
  505. //验证权限
  506. CheckLevel($userid,$username,$classid,"bq");
  507. $r=$empire->fetch1("select bqid,bqname,bqsay,funname,bq,bqgs from {$dbtbpre}enewsbq where bqid=$bqid");
  508. if(!$r[bqid])
  509. {
  510. printerror("NotThisBqid","history.go(-1)");
  511. }
  512. $add['funvalue']=ClearAddsData($add['funvalue']);
  513. $field="<!--#empirecms.bq-phome.net#--!>";
  514. $str=$r['bqname'].$field.stripSlashes($r['bqsay']).$field.$r['funname'].$field.$r['bq'].$field.stripSlashes($r['bqgs']).$field.$add['funvalue'];
  515. $filename=$r['bq'].time().".bq";
  516. $filepath=ECMS_PATH.'e/data/tmp/temp/'.$filename;
  517. WriteFiletext_n($filepath,$str);
  518. DownLoadFile($filename,$filepath,1);
  519. //操作日志
  520. insert_dolog("bqid=".$bqid."<br>bqname=".$r[bqname]);
  521. exit();
  522. }
  523. //导入标签
  524. function LoadInBq($add,$file,$file_name,$file_type,$file_size,$userid,$username){
  525. global $empire,$dbtbpre;
  526. //验证权限
  527. CheckLevel($userid,$username,$classid,"bq");
  528. $classid=(int)$add['classid'];
  529. if(!$file_name||!$file_size)
  530. {
  531. printerror("EmptyLoadInBqFile","history.go(-1)");
  532. }
  533. //扩展名
  534. $filetype=GetFiletype($file_name);
  535. if($filetype!=".bq")
  536. {
  537. printerror("LoadInBqMustBq","history.go(-1)");
  538. }
  539. $field="<!--#empirecms.bq-phome.net#--!>";
  540. $path=ECMS_PATH.'e/data/tmp/temp/uploadbq'.time().'.bq';
  541. //上传文件
  542. $cp=@move_uploaded_file($file,$path);
  543. DoChmodFile($path);
  544. $data=ReadFiletext($path);
  545. DelFiletext($path);
  546. $r=explode($field,$data);
  547. $num=$empire->gettotal("select count(*) as total from {$dbtbpre}enewsbq where bq='$r[3]' or funname='$r[2]' limit 1");
  548. if($num)
  549. {
  550. printerror("ReLoadInBq","history.go(-1)");
  551. }
  552. $sql=$empire->query("insert into {$dbtbpre}enewsbq(bqname,bqsay,funname,bq,issys,bqgs,isclose,classid,myorder) values('".addslashes($r[0])."','".addslashes($r[1])."','".addslashes($r[2])."','".addslashes($r[3])."',0,'".addslashes($r[4])."',0,$classid,0);");
  553. $bqid=$empire->lastid();
  554. //操作日志
  555. insert_dolog("bqid=".$bqid."<br>bqname=".$r[0]);
  556. return $r;
  557. }
  558. //-----------------------批量替换模板字符
  559. function DoRepTemp($add,$userid,$username){
  560. global $empire,$dbtbpre;
  561. //验证权限
  562. CheckLevel($userid,$username,$classid,"template");
  563. $oldword=RepPhpAspJspcode(addslashes($add['oldword']));
  564. $newword=RepPhpAspJspcode(addslashes($add['newword']));
  565. if(!$oldword)
  566. {
  567. printerror("EmptyRepTemp","history.go(-1)");
  568. }
  569. $gid=(int)$add['gid'];
  570. //公共表
  571. if($add['indextemp']||$add['cptemp']||$add['sformtemp']||$add['otherlinktemp']||$add['gbooktemp']||$add['loginiframe']||$add['pljstemp']||$add['schalltemp']||$add['loginjstemp']||$add['downpagetemp'])
  572. {
  573. $set='';
  574. //首页模板
  575. if($add['indextemp'])
  576. {
  577. $set.=",indextemp=REPLACE(indextemp,'".$oldword."','".$newword."')";
  578. }
  579. //控制面板模板
  580. if($add['cptemp'])
  581. {
  582. $set.=",cptemp=REPLACE(cptemp,'".$oldword."','".$newword."')";
  583. }
  584. //搜索表单模板
  585. if($add['sformtemp'])
  586. {
  587. $set.=",searchtemp=REPLACE(searchtemp,'".$oldword."','".$newword."')";
  588. }
  589. //相关信息模板
  590. if($add['otherlinktemp'])
  591. {
  592. $set.=",otherlinktemp=REPLACE(otherlinktemp,'".$oldword."','".$newword."')";
  593. }
  594. //留言板模板
  595. if($add['gbooktemp'])
  596. {
  597. $set.=",gbooktemp=REPLACE(gbooktemp,'".$oldword."','".$newword."')";
  598. }
  599. //登陆状态模板
  600. if($add['loginiframe'])
  601. {
  602. $set.=",loginiframe=REPLACE(loginiframe,'".$oldword."','".$newword."')";
  603. }
  604. //评论JS模板
  605. if($add['pljstemp'])
  606. {
  607. $set.=",pljstemp=REPLACE(pljstemp,'".$oldword."','".$newword."')";
  608. }
  609. //全站搜索模板
  610. if($add['schalltemp'])
  611. {
  612. $set.=",schalltemp=REPLACE(schalltemp,'".$oldword."','".$newword."')";
  613. }
  614. //JS调用登陆状态模板
  615. if($add['loginjstemp'])
  616. {
  617. $set.=",loginjstemp=REPLACE(loginjstemp,'".$oldword."','".$newword."')";
  618. }
  619. //最终下载页模板
  620. if($add['downpagetemp'])
  621. {
  622. $set.=",downpagetemp=REPLACE(downpagetemp,'".$oldword."','".$newword."')";
  623. }
  624. $empire->query("update ".GetDoTemptb("enewspubtemp",$gid)." set id=1".$set." limit 1");
  625. }
  626. //修改栏目封面模板
  627. if($add['classtemp'])
  628. {
  629. $empire->query("update ".GetDoTemptb("enewsclasstemp",$gid)." set temptext=REPLACE(temptext,'".$oldword."','".$newword."')");
  630. }
  631. //修改标签模板
  632. if($add['bqtemp'])
  633. {
  634. $empire->query("update ".GetDoTemptb("enewsbqtemp",$gid)." set temptext=REPLACE(temptext,'".$oldword."','".$newword."'),listvar=REPLACE(listvar,'".$oldword."','".$newword."')");
  635. }
  636. //修改列表模板
  637. if($add['listtemp'])
  638. {
  639. $empire->query("update ".GetDoTemptb("enewslisttemp",$gid)." set temptext=REPLACE(temptext,'".$oldword."','".$newword."'),listvar=REPLACE(listvar,'".$oldword."','".$newword."')");
  640. }
  641. //修改内容模板
  642. if($add['newstemp'])
  643. {
  644. $empire->query("update ".GetDoTemptb("enewsnewstemp",$gid)." set temptext=REPLACE(temptext,'".$oldword."','".$newword."')");
  645. }
  646. //修改搜索模板
  647. if($add['searchtemp'])
  648. {
  649. $empire->query("update ".GetDoTemptb("enewssearchtemp",$gid)." set temptext=REPLACE(temptext,'".$oldword."','".$newword."'),listvar=REPLACE(listvar,'".$oldword."','".$newword."')");
  650. }
  651. //修改自定义页面
  652. if($add['userpage'])
  653. {
  654. $empire->query("update {$dbtbpre}enewspage set pagetext=REPLACE(pagetext,'".$oldword."','".$newword."')");
  655. }
  656. //修改自定义页面模板
  657. if($add['pagetemp'])
  658. {
  659. $empire->query("update ".GetDoTemptb("enewspagetemp",$gid)." set temptext=REPLACE(temptext,'".$oldword."','".$newword."')");
  660. }
  661. //评论列表模板
  662. if($add['pltemp'])
  663. {
  664. $empire->query("update ".GetDoTemptb("enewspltemp",$gid)." set temptext=REPLACE(temptext,'".$oldword."','".$newword."')");
  665. }
  666. //打印模板
  667. if($add['printtemp'])
  668. {
  669. $empire->query("update ".GetDoTemptb("enewsprinttemp",$gid)." set temptext=REPLACE(temptext,'".$oldword."','".$newword."')");
  670. }
  671. //模板变量
  672. if($add['tempvar'])
  673. {
  674. $empire->query("update ".GetDoTemptb("enewstempvar",$gid)." set varvalue=REPLACE(varvalue,'".$oldword."','".$newword."')");
  675. }
  676. //修改JS模板
  677. if($add['jstemp'])
  678. {
  679. $empire->query("update ".GetDoTemptb("enewsjstemp",$gid)." set temptext=REPLACE(temptext,'".$oldword."','".$newword."')");
  680. }
  681. //修改投票模板
  682. if($add['votetemp'])
  683. {
  684. $empire->query("update ".GetDoTemptb("enewsvotetemp",$gid)." set temptext=REPLACE(temptext,'".$oldword."','".$newword."')");
  685. }
  686. //反馈表单模板
  687. if($add['feedbackbtemp'])
  688. {
  689. $empire->query("update {$dbtbpre}enewsfeedbackclass set btemp=REPLACE(btemp,'".$oldword."','".$newword."')");
  690. }
  691. //操作日志
  692. insert_dolog("gid=$gid");
  693. printerror("RepTempSuccess","history.go(-1)");
  694. }
  695. //修改模板组
  696. function EditTempGroup($add,$userid,$username){
  697. global $empire,$dbtbpre;
  698. //验证权限
  699. CheckLevel($userid,$username,$classid,"tempgroup");
  700. $gid=$add['gid'];
  701. $gname=$add['gname'];
  702. $count=count($gid);
  703. for($i=0;$i<$count;$i++)
  704. {
  705. $usql=$empire->query("update {$dbtbpre}enewstempgroup set gname='".$gname[$i]."' where gid='".$gid[$i]."'");
  706. }
  707. //操作日志
  708. insert_dolog("");
  709. printerror("EditTempGroupSuccess","TempGroup.php");
  710. }
  711. //默认模板组
  712. function DefTtempGroup($add,$userid,$username){
  713. global $empire,$dbtbpre;
  714. //验证权限
  715. CheckLevel($userid,$username,$classid,"tempgroup");
  716. $gid=(int)$add['changegid'];
  717. if(!$gid)
  718. {
  719. printerror("EmptyTempGroup","");
  720. }
  721. $r=$empire->fetch1("select gid,gname from {$dbtbpre}enewstempgroup where gid=$gid");
  722. if(!$r['gid'])
  723. {
  724. printerror("EmptyTempGroup","");
  725. }
  726. $usql=$empire->query("update {$dbtbpre}enewstempgroup set isdefault=0");
  727. $sql=$empire->query("update {$dbtbpre}enewstempgroup set isdefault=1 where gid=$gid");
  728. $upsql=$empire->query("update {$dbtbpre}enewspublic set deftempid=$gid limit 1");
  729. if($usql&&$sql&&$upsql)
  730. {
  731. GetConfig();
  732. //操作日志
  733. insert_dolog("gid=$gid&gname=$r[gname]");
  734. printerror("DefTempGroupSuccess","TempGroup.php");
  735. }
  736. else
  737. {
  738. printerror("DbError","");
  739. }
  740. }
  741. //返回模板表
  742. function ReturnTemptbList(){
  743. $templist="enewsbqtemp,enewsjstemp,enewslisttemp,enewsnewstemp,enewspubtemp,enewssearchtemp,enewstempvar,enewsvotetemp,enewsclasstemp,enewspltemp,enewsprinttemp,enewspagetemp";
  744. return $templist;
  745. }
  746. //删除模板数据表
  747. function DelTempTb($gid){
  748. global $empire,$dbtbpre;
  749. if($gid==1)
  750. {
  751. return "";
  752. }
  753. $templist=ReturnTemptbList();
  754. $r=explode(",",$templist);
  755. $count=count($r);
  756. $droptb="";
  757. for($i=0;$i<$count;$i++)
  758. {
  759. $dh=",";
  760. if($i==0)
  761. {
  762. $dh="";
  763. }
  764. $droptb.=$dh.$dbtbpre.$r[$i]."_".$gid;
  765. }
  766. $sql=$empire->query("DROP TABLE IF EXISTS ".$droptb.";");
  767. return $sql;
  768. }
  769. //清空模板数据表
  770. function ClearTempTb($gid,$en){
  771. global $empire,$dbtbpre;
  772. $templist=ReturnTemptbList();
  773. $r=explode(",",$templist);
  774. $count=count($r);
  775. for($i=0;$i<$count;$i++)
  776. {
  777. $tb=$dbtbpre.$r[$i].$en;
  778. $empire->query("TRUNCATE `".$tb."`;");
  779. }
  780. }
  781. //新建模板数据表
  782. function CreateTempTb($gid,$en){
  783. global $empire,$dbtbpre;
  784. if($gid==1)
  785. {
  786. return "";
  787. }
  788. $templist=ReturnTemptbList();
  789. $r=explode(",",$templist);
  790. $count=count($r);
  791. for($i=0;$i<$count;$i++)
  792. {
  793. $otb=$dbtbpre.$r[$i];
  794. $tb=$dbtbpre.$r[$i].$en;
  795. CopyEcmsTb($otb,$tb);
  796. }
  797. }
  798. //删除模板组
  799. function DelTempGroup($add,$userid,$username){
  800. global $empire,$dbtbpre;
  801. //验证权限
  802. CheckLevel($userid,$username,$classid,"tempgroup");
  803. $gid=(int)$add['changegid'];
  804. if(!$gid)
  805. {
  806. printerror("EmptyDelTempGroup","");
  807. }
  808. if($gid==1)
  809. {
  810. printerror("NotDelDefTempGroup","");
  811. }
  812. $r=$empire->fetch1("select gid,gname,isdefault from {$dbtbpre}enewstempgroup where gid=$gid");
  813. if(!$r['gid'])
  814. {
  815. printerror("EmptyDelTempGroup","");
  816. }
  817. $sql=$empire->query("delete from {$dbtbpre}enewstempgroup where gid=$gid");
  818. if($r['isdefault'])
  819. {
  820. $upsql=$empire->query("update {$dbtbpre}enewspublic set deftempid=0 limit 1");
  821. GetConfig();
  822. }
  823. DelTempTb($gid);
  824. //删除备份记录
  825. $empire->query("delete from {$dbtbpre}enewstempbak where gid='$gid'");
  826. if($sql)
  827. {
  828. //操作日志
  829. insert_dolog("gid=$gid&gname=$r[gname]");
  830. printerror("DelTempGroupSuccess","TempGroup.php");
  831. }
  832. else
  833. {
  834. printerror("DbError","");
  835. }
  836. }
  837. //导出模板组
  838. function LoadTempGroup($add,$userid,$username){
  839. global $empire,$dbtbpre;
  840. //验证权限
  841. CheckLevel($userid,$username,$classid,"tempgroup");
  842. $gid=(int)$add['changegid'];
  843. if(!$gid)
  844. {
  845. printerror("EmptyLoadTempGroup","");
  846. }
  847. $r=$empire->fetch1("select gid,gname from {$dbtbpre}enewstempgroup where gid=$gid");
  848. if(!$r['gid'])
  849. {
  850. printerror("EmptyLoadTempGroup","");
  851. }
  852. $pageexp="<!---ecms.temp--->";
  853. $record="<!---ecms.record--->";
  854. $field="<!---ecms.field--->";
  855. if($gid==1)
  856. {
  857. $en="";
  858. }
  859. else
  860. {
  861. $en="_".$gid;
  862. }
  863. $bqtemp=LoadTGBqtemp($gid,$en,$pageexp,$record,$field);//标签模板
  864. $jstemp=LoadTGJstemp($gid,$en,$pageexp,$record,$field);//JS模板
  865. $listtemp=LoadTGListtemp($gid,$en,$pageexp,$record,$field);//列表模板
  866. $newstemp=LoadTGNewstemp($gid,$en,$pageexp,$record,$field);//内容模板
  867. $pubtemp=LoadTGPubtemp($gid,$en,$pageexp,$record,$field);//公共模板
  868. $searchtemp=LoadTGSearchtemp($gid,$en,$pageexp,$record,$field);//搜索模板
  869. $tempvar=LoadTGTempvar($gid,$en,$pageexp,$record,$field);//模板变量
  870. $votetemp=LoadTGVotetemp($gid,$en,$pageexp,$record,$field);//投票模板
  871. $classtemp=LoadTGClasstemp($gid,$en,$pageexp,$record,$field);//栏目模板
  872. $pltemp=LoadTGPltemp($gid,$en,$pageexp,$record,$field);//评论模板
  873. $printtemp=LoadTGPrinttemp($gid,$en,$pageexp,$record,$field);//打印模板
  874. $pagetemp=LoadTGPagetemp($gid,$en,$pageexp,$record,$field);//自定义页面模板
  875. $loadtemptext=$r['gname'].$pageexp.$bqtemp.$pageexp.$jstemp.$pageexp.$listtemp.$pageexp.$newstemp.$pageexp.$pubtemp.$pageexp.$searchtemp.$pageexp.$tempvar.$pageexp.$votetemp.$pageexp.$classtemp.$pageexp.$pltemp.$pageexp.$printtemp.$pageexp.$pagetemp;
  876. $loadtemptext=stripSlashes($loadtemptext);
  877. $file="e".time().".temp";
  878. $filepath=ECMS_PATH.'e/data/tmp/temp/'.$file;
  879. WriteFiletext_n($filepath,$loadtemptext);
  880. DownLoadFile($file,$filepath,1);
  881. //操作日志
  882. insert_dolog("gid=$gid&gname=$r[gname]");
  883. exit();
  884. }
  885. //模板转编码
  886. function LoadInTempChangeChar($tempchar,$text){
  887. global $phome_ecms_charver;
  888. @include_once(ECMS_PATH.'e/class/EmpireCMS_version.php');
  889. if($tempchar=='GB2312')//简体GB2312
  890. {
  891. if($phome_ecms_charver=='gb2312')
  892. {
  893. return $text;
  894. }
  895. if($phome_ecms_charver=='utf-8')
  896. {
  897. if(EmpireCMS_CHARVER=='TC-UTF-8')//繁体
  898. {
  899. $text=DoIconvVal("GB2312","BIG5",$text,1);
  900. $text=DoIconvVal("BIG5","UTF8",$text);
  901. }
  902. else//简体
  903. {
  904. $text=DoIconvVal("GB2312","UTF8",$text,1);
  905. }
  906. $text=preg_replace(array('/charset=gbk/i','/charset=gb2312/i'),array('charset=utf-8','charset=utf-8'),$text);
  907. }
  908. elseif($phome_ecms_charver=='big5')
  909. {
  910. $text=DoIconvVal("GB2312","BIG5",$text,1);
  911. $text=preg_replace(array('/charset=gbk/i','/charset=gb2312/i'),array('charset=big5','charset=big5'),$text);
  912. }
  913. }
  914. elseif($tempchar=='UTF8')//简体UTF-8
  915. {
  916. if($phome_ecms_charver=='utf-8'&&EmpireCMS_CHARVER=='UTF-8')
  917. {
  918. return $text;
  919. }
  920. if($phome_ecms_charver=='gb2312')
  921. {
  922. $text=DoIconvVal("UTF8","GB2312",$text,1);
  923. $text=preg_replace('/charset=utf-8/i','charset=gb2312',$text);
  924. }
  925. elseif($phome_ecms_charver=='big5')
  926. {
  927. $text=DoIconvVal("UTF8","GB2312",$text,1);
  928. $text=DoIconvVal("GB2312","BIG5",$text);
  929. $text=preg_replace('/charset=utf-8/i','charset=big5',$text);
  930. }
  931. elseif($phome_ecms_charver=='utf-8')//繁体
  932. {
  933. $text=DoIconvVal("UTF8","GB2312",$text,1);
  934. $text=DoIconvVal("GB2312","BIG5",$text);
  935. $text=DoIconvVal("BIG5","UTF8",$text);
  936. }
  937. }
  938. elseif($tempchar=='BIG5')//繁体BIG5
  939. {
  940. if($phome_ecms_charver=='big5')
  941. {
  942. return $text;
  943. }
  944. if($phome_ecms_charver=='gb2312')
  945. {
  946. $text=DoIconvVal("BIG5","GB2312",$text,1);
  947. $text=preg_replace('/charset=big5/i','charset=gb2312',$text);
  948. }
  949. elseif($phome_ecms_charver=='utf-8')
  950. {
  951. if(EmpireCMS_CHARVER=='UTF-8')//简体
  952. {
  953. $text=DoIconvVal("BIG5","GB2312",$text,1);
  954. $text=DoIconvVal("GB2312","UTF8",$text);
  955. }
  956. else//繁体
  957. {
  958. $text=DoIconvVal("BIG5","UTF8",$text,1);
  959. }
  960. $text=preg_replace('/charset=big5/i','charset=utf-8',$text);
  961. }
  962. }
  963. elseif($tempchar=='TCUTF8')//繁体UTF-8
  964. {
  965. if($phome_ecms_charver=='utf-8'&&EmpireCMS_CHARVER=='TC-UTF-8')
  966. {
  967. return $text;
  968. }
  969. if($phome_ecms_charver=='gb2312')
  970. {
  971. $text=DoIconvVal("UTF8","BIG5",$text,1);
  972. $text=DoIconvVal("BIG5","GB2312",$text);
  973. $text=preg_replace('/charset=utf-8/i','charset=gb2312',$text);
  974. }
  975. elseif($phome_ecms_charver=='big5')
  976. {
  977. $text=DoIconvVal("UTF8","BIG5",$text,1);
  978. $text=preg_replace('/charset=utf-8/i','charset=big5',$text);
  979. }
  980. elseif($phome_ecms_charver=='utf-8')//简体
  981. {
  982. $text=DoIconvVal("UTF8","BIG5",$text,1);
  983. $text=DoIconvVal("BIG5","GB2312",$text);
  984. $text=DoIconvVal("GB2312","UTF8",$text);
  985. }
  986. }
  987. return $text;
  988. }
  989. //导入模板组
  990. function LoadInTempGroup($add,$file,$file_name,$file_type,$file_size,$userid,$username){
  991. global $empire,$dbtbpre;
  992. //验证权限
  993. CheckLevel($userid,$username,$classid,"tempgroup");
  994. if(!$file_name||!$file_size)
  995. {
  996. printerror("EmptyLoadInTempGroup","");
  997. }
  998. $gid=(int)$add['gid'];
  999. //扩展名
  1000. $filetype=GetFiletype($file_name);
  1001. if($filetype!=".temp")
  1002. {
  1003. printerror("LoadInTempGroupMusttemp","");
  1004. }
  1005. //上传文件
  1006. $path=ECMS_PATH.'e/data/tmp/temp/uploadtg'.time().make_password(10).'.temp';
  1007. $cp=@move_uploaded_file($file,$path);
  1008. DoChmodFile($path);
  1009. $data=ReadFiletext($path);
  1010. DelFiletext($path);
  1011. //转码
  1012. if($add['ChangeChar'])
  1013. {
  1014. $data=LoadInTempChangeChar($add['tempchar'],$data);
  1015. }
  1016. if(empty($data))
  1017. {
  1018. printerror("EmptyLoadInTempGroup","");
  1019. }
  1020. //入库
  1021. $pageexp="<!---ecms.temp--->";
  1022. $record="<!---ecms.record--->";
  1023. $field="<!---ecms.field--->";
  1024. $pr=explode($pageexp,$data);
  1025. if(empty($gid))//新建模板组
  1026. {
  1027. $sql=$empire->query("insert into {$dbtbpre}enewstempgroup(gname,isdefault) values('".addslashes($pr[0])."',0);");
  1028. $gid=$empire->lastid();
  1029. $gname=$pr[0];
  1030. $en="_".$gid;
  1031. CreateTempTb($gid,$en);//复制表
  1032. }
  1033. else//覆盖模板组
  1034. {
  1035. $r=$empire->fetch1("select gid,gname from {$dbtbpre}enewstempgroup where gid=$gid");
  1036. if(!$r['gid'])
  1037. {
  1038. printerror("LoadInTempGroupMusttemp","");
  1039. }
  1040. if($gid==1)
  1041. {
  1042. $en="";
  1043. }
  1044. else
  1045. {
  1046. $en="_".$gid;
  1047. }
  1048. $gname=$r['gname'];
  1049. ClearTempTb($gid,$en);//清空表
  1050. }
  1051. //版本
  1052. $isold=0;
  1053. $ckcount=count($pr);
  1054. if($ckcount<=10)//5.1
  1055. {
  1056. $isold=1;
  1057. }
  1058. elseif($ckcount<=11)//6.0
  1059. {
  1060. $isold=2;
  1061. }
  1062. LoadInTGBqtemp($gid,$en,$record,$field,$pr[1]);//标签模板
  1063. LoadInTGJstemp($gid,$en,$record,$field,$pr[2]);//JS模板
  1064. LoadInTGListtemp($gid,$en,$record,$field,$pr[3]);//列表模板
  1065. LoadInTGNewstemp($gid,$en,$record,$field,$pr[4]);//内容模板
  1066. LoadInTGPubtemp($gid,$en,$record,$field,$pr[5],$isold);//公共模板
  1067. LoadInTGSearchtemp($gid,$en,$record,$field,$pr[6]);//搜索模板
  1068. LoadInTGTempvar($gid,$en,$record,$field,$pr[7]);//模板变量
  1069. LoadInTGVotetemp($gid,$en,$record,$field,$pr[8]);//投票模板
  1070. LoadInTGClasstemp($gid,$en,$record,$field,$pr[9]);//栏目模板
  1071. if($isold!=1)
  1072. {
  1073. LoadInTGPltemp($gid,$en,$record,$field,$pr[10]);//评论模板
  1074. }
  1075. if($isold==0)
  1076. {
  1077. LoadInTGPrinttemp($gid,$en,$record,$field,$pr[11]);//打印模板
  1078. }
  1079. LoadInTGPagetemp($gid,$en,$record,$field,$pr[12]);//自定义页面模板
  1080. //操作日志
  1081. insert_dolog("gid=$gid&gname=$gname");
  1082. printerror("LoadInTempGroupSuccess","TempGroup.php");
  1083. }
  1084. //替换模板组存放格式
  1085. function ReplaceLoadTGTemp($pageexp,$record,$field,$text){
  1086. $text=str_replace($pageexp,"",$text);
  1087. $text=str_replace($record,"",$text);
  1088. $text=str_replace($field,"",$text);
  1089. return $text;
  1090. }
  1091. //标签模板
  1092. function LoadTGBqtemp($gid,$en,$pageexp,$record,$field){
  1093. global $empire,$dbtbpre;
  1094. $tb=$dbtbpre."enewsbqtemp".$en;
  1095. $sql=$empire->query("select * from ".$tb." order by tempid");
  1096. $classid=0;
  1097. while($r=$empire->fetch($sql))
  1098. {
  1099. $r['temptext']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['temptext']);
  1100. $r['listvar']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['listvar']);
  1101. $text.=$r['tempid'].$field.$r['tempname'].$field.$r['modid'].$field.$r['temptext'].$field.$r['showdate'].$field.$r['listvar'].$field.$r['subnews'].$field.$r['rownum'].$field.$classid.$field.$r['docode'].$record;
  1102. }
  1103. return $text;
  1104. }
  1105. function LoadInTGBqtemp($gid,$en,$record,$field,$text){
  1106. global $empire,$dbtbpre;
  1107. if(empty($text))
  1108. {
  1109. return "";
  1110. }
  1111. $tb=$dbtbpre."enewsbqtemp".$en;
  1112. $rr=explode($record,$text);
  1113. $count=count($rr);
  1114. for($i=0;$i<$count-1;$i++)
  1115. {
  1116. $r=explode($field,$rr[$i]);
  1117. $sql=$empire->query("insert into ".$tb."(tempid,tempname,modid,temptext,showdate,listvar,subnews,rownum,classid,docode) values('$r[0]','".addslashes($r[1])."','$r[2]','".addslashes($r[3])."','".addslashes($r[4])."','".addslashes($r[5])."','$r[6]','$r[7]','$r[8]','$r[9]');");
  1118. }
  1119. }
  1120. //JS模板
  1121. function LoadTGJstemp($gid,$en,$pageexp,$record,$field){
  1122. global $empire,$dbtbpre;
  1123. $tb=$dbtbpre."enewsjstemp".$en;
  1124. $sql=$empire->query("select * from ".$tb." order by tempid");
  1125. $classid=0;
  1126. while($r=$empire->fetch($sql))
  1127. {
  1128. $r['temptext']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['temptext']);
  1129. $text.=$r['tempid'].$field.$r['tempname'].$field.$r['temptext'].$field.$classid.$field.$r['isdefault'].$field.$r['showdate'].$field.$r['modid'].$field.$r['subnews'].$field.$r['subtitle'].$record;
  1130. }
  1131. return $text;
  1132. }
  1133. function LoadInTGJstemp($gid,$en,$record,$field,$text){
  1134. global $empire,$dbtbpre;
  1135. if(empty($text))
  1136. {
  1137. return "";
  1138. }
  1139. $tb=$dbtbpre."enewsjstemp".$en;
  1140. $rr=explode($record,$text);
  1141. $count=count($rr);
  1142. for($i=0;$i<$count-1;$i++)
  1143. {
  1144. $r=explode($field,$rr[$i]);
  1145. if(empty($r[6]))
  1146. {
  1147. $r[6]=1;
  1148. }
  1149. $sql=$empire->query("insert into ".$tb."(tempid,tempname,temptext,classid,isdefault,showdate,modid,subnews,subtitle) values('$r[0]','".addslashes($r[1])."','".addslashes($r[2])."','$r[3]','$r[4]','".addslashes($r[5])."','$r[6]','$r[7]','$r[8]');");
  1150. }
  1151. }
  1152. //列表模板
  1153. function LoadTGListtemp($gid,$en,$pageexp,$record,$field){
  1154. global $empire,$dbtbpre;
  1155. $tb=$dbtbpre."enewslisttemp".$en;
  1156. $sql=$empire->query("select * from ".$tb." order by tempid");
  1157. $classid=0;
  1158. while($r=$empire->fetch($sql))
  1159. {
  1160. $r['temptext']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['temptext']);
  1161. $r['listvar']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['listvar']);
  1162. $text.=$r['tempid'].$field.$r['tempname'].$field.$r['temptext'].$field.$r['subnews'].$field.$r['isdefault'].$field.$r['listvar'].$field.$r['rownum'].$field.$r['modid'].$field.$r['showdate'].$field.$r['subtitle'].$field.$classid.$field.$r['docode'].$record;
  1163. }
  1164. return $text;
  1165. }
  1166. function LoadInTGListtemp($gid,$en,$record,$field,$text){
  1167. global $empire,$dbtbpre;
  1168. if(empty($text))
  1169. {
  1170. return "";
  1171. }
  1172. $tb=$dbtbpre."enewslisttemp".$en;
  1173. $rr=explode($record,$text);
  1174. $count=count($rr);
  1175. for($i=0;$i<$count-1;$i++)
  1176. {
  1177. $r=explode($field,$rr[$i]);
  1178. $sql=$empire->query("insert into ".$tb."(tempid,tempname,temptext,subnews,isdefault,listvar,rownum,modid,showdate,subtitle,classid,docode) values('$r[0]','".addslashes($r[1])."','".addslashes($r[2])."','$r[3]','$r[4]','".addslashes($r[5])."','$r[6]','$r[7]','".addslashes($r[8])."','$r[9]','$r[10]','$r[11]');");
  1179. }
  1180. }
  1181. //内容模板
  1182. function LoadTGNewstemp($gid,$en,$pageexp,$record,$field){
  1183. global $empire,$dbtbpre;
  1184. $tb=$dbtbpre."enewsnewstemp".$en;
  1185. $sql=$empire->query("select * from ".$tb." order by tempid");
  1186. $classid=0;
  1187. while($r=$empire->fetch($sql))
  1188. {
  1189. $r['temptext']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['temptext']);
  1190. $text.=$r['tempid'].$field.$r['tempname'].$field.$r['isdefault'].$field.$r['temptext'].$field.$r['showdate'].$field.$r['modid'].$field.$classid.$record;
  1191. }
  1192. return $text;
  1193. }
  1194. function LoadInTGNewstemp($gid,$en,$record,$field,$text){
  1195. global $empire,$dbtbpre;
  1196. if(empty($text))
  1197. {
  1198. return "";
  1199. }
  1200. $text=RepTemplateJsUrl($text,1,0);//替换JS地址
  1201. $tb=$dbtbpre."enewsnewstemp".$en;
  1202. $rr=explode($record,$text);
  1203. $count=count($rr);
  1204. for($i=0;$i<$count-1;$i++)
  1205. {
  1206. $r=explode($field,$rr[$i]);
  1207. $sql=$empire->query("insert into ".$tb."(tempid,tempname,isdefault,temptext,showdate,modid,classid) values('$r[0]','".addslashes($r[1])."','$r[2]','".addslashes($r[3])."','".addslashes($r[4])."','$r[5]','$r[6]');");
  1208. }
  1209. }
  1210. //公共模板
  1211. function LoadTGPubtemp($gid,$en,$pageexp,$record,$field){
  1212. global $empire,$dbtbpre;
  1213. $tb=$dbtbpre."enewspubtemp".$en;
  1214. $r=$empire->fetch1("select * from ".$tb." limit 1");
  1215. $r['indextemp']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['indextemp']);
  1216. $r['cptemp']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['cptemp']);
  1217. $r['searchtemp']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['searchtemp']);
  1218. $r['searchjstemp']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['searchjstemp']);
  1219. $r['searchjstemp1']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['searchjstemp1']);
  1220. $r['otherlinktemp']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['otherlinktemp']);
  1221. $r['downsofttemp']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['downsofttemp']);
  1222. $r['onlinemovietemp']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['onlinemovietemp']);
  1223. $r['listpagetemp']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['listpagetemp']);
  1224. $r['gbooktemp']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['gbooktemp']);
  1225. $r['loginiframe']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['loginiframe']);
  1226. $r['loginjstemp']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['loginjstemp']);
  1227. $r['downpagetemp']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['downpagetemp']);
  1228. $r['pljstemp']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['pljstemp']);
  1229. $r['schalltemp']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['schalltemp']);
  1230. $text.=$r['id'].$field.$r['indextemp'].$field.''.$field.$r['cptemp'].$field.$r['searchtemp'].$field.$r['searchjstemp'].$field.$r['searchjstemp1'].$field.$r['otherlinktemp'].$field.''.$field.$r['downsofttemp'].$field.$r['onlinemovietemp'].$field.$r['listpagetemp'].$field.$r['gbooktemp'].$field.$r['loginiframe'].$field.$r['otherlinktempsub'].$field.$r['otherlinktempdate'].$field.$r['loginjstemp'].$field.$r['downpagetemp'].$field.$r['pljstemp'].$field.$r['schalltemp'].$field.$r['schallsubnum'].$field.$r['schalldate'].$record;
  1231. return $text;
  1232. }
  1233. function LoadInTGPubtemp($gid,$en,$record,$field,$text,$isold=0){
  1234. global $empire,$dbtbpre,$fun_r;
  1235. if(empty($text))
  1236. {
  1237. return "";
  1238. }
  1239. $tb=$dbtbpre."enewspubtemp".$en;
  1240. $rr=explode($record,$text);
  1241. $r=explode($field,$rr[0]);
  1242. //相关链接设置
  1243. if(empty($r[14]))
  1244. {
  1245. $r[14]=30;
  1246. }
  1247. if(empty($r[15]))
  1248. {
  1249. $r[15]='Y-m-d H:i:s';
  1250. }
  1251. if(empty($r[21]))
  1252. {
  1253. $r[21]='Y-m-d H:i:s';
  1254. }
  1255. $sql=$empire->query("insert into ".$tb."(id,indextemp,cptemp,searchtemp,searchjstemp,searchjstemp1,otherlinktemp,downsofttemp,onlinemovietemp,listpagetemp,gbooktemp,loginiframe,otherlinktempsub,otherlinktempdate,loginjstemp,downpagetemp,pljstemp,schalltemp,schallsubnum,schalldate) values('$r[0]','".addslashes($r[1])."','".addslashes($r[3])."','".addslashes($r[4])."','".addslashes($r[5])."','".addslashes($r[6])."','".addslashes($r[7])."','".addslashes($r[9])."','".addslashes($r[10])."','".addslashes($r[11])."','".addslashes($r[12])."','".addslashes($r[13])."','$r[14]','$r[15]','".addslashes($r[16])."','".addslashes($r[17])."','".addslashes($r[18])."','".addslashes($r[19])."','$r[20]','$r[21]');");
  1256. //5.1以下版本
  1257. if($isold==1&&$r[2])
  1258. {
  1259. $pltb=$dbtbpre."enewspltemp".$en;
  1260. $pltempname=$fun_r['PlListTempname'];
  1261. $empire->query("insert into ".$pltb."(tempid,tempname,temptext,isdefault) values(NULL,'".addslashes($pltempname)."','".addslashes($r[2])."',1);");
  1262. }
  1263. //6.0以下版本
  1264. if(($isold==1||$isold==2)&&$r[8])
  1265. {
  1266. $printtb=$dbtbpre."enewsprinttemp".$en;
  1267. $printtempname=$fun_r['PrintTempname'];
  1268. $empire->query("insert into ".$printtb."(tempid,tempname,temptext,isdefault,showdate,modid) values(NULL,'".addslashes($printtempname)."','".addslashes($r[8])."',1,'Y-m-d H:i:s',1);");
  1269. }
  1270. }
  1271. //搜索模板
  1272. function LoadTGSearchtemp($gid,$en,$pageexp,$record,$field){
  1273. global $empire,$dbtbpre;
  1274. $tb=$dbtbpre."enewssearchtemp".$en;
  1275. $sql=$empire->query("select * from ".$tb." order by tempid");
  1276. $classid=0;
  1277. while($r=$empire->fetch($sql))
  1278. {
  1279. $r['temptext']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['temptext']);
  1280. $r['listvar']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['listvar']);
  1281. $text.=$r['tempid'].$field.$r['tempname'].$field.$r['temptext'].$field.$r['subnews'].$field.$r['isdefault'].$field.$r['listvar'].$field.$r['rownum'].$field.$r['modid'].$field.$r['showdate'].$field.$r['subtitle'].$field.$classid.$field.$r['docode'].$record;
  1282. }
  1283. return $text;
  1284. }
  1285. function LoadInTGSearchtemp($gid,$en,$record,$field,$text){
  1286. global $empire,$dbtbpre;
  1287. if(empty($text))
  1288. {
  1289. return "";
  1290. }
  1291. $tb=$dbtbpre."enewssearchtemp".$en;
  1292. $rr=explode($record,$text);
  1293. $count=count($rr);
  1294. for($i=0;$i<$count-1;$i++)
  1295. {
  1296. $r=explode($field,$rr[$i]);
  1297. $sql=$empire->query("insert into ".$tb."(tempid,tempname,temptext,subnews,isdefault,listvar,rownum,modid,showdate,subtitle,classid,docode) values('$r[0]','".addslashes($r[1])."','".addslashes($r[2])."','$r[3]','$r[4]','".addslashes($r[5])."','$r[6]','$r[7]','".addslashes($r[8])."','$r[9]','$r[10]','$r[11]');");
  1298. }
  1299. }
  1300. //模板变量
  1301. function LoadTGTempvar($gid,$en,$pageexp,$record,$field){
  1302. global $empire,$dbtbpre;
  1303. $tb=$dbtbpre."enewstempvar".$en;
  1304. $sql=$empire->query("select * from ".$tb." order by varid");
  1305. $classid=0;
  1306. while($r=$empire->fetch($sql))
  1307. {
  1308. $r['varvalue']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['varvalue']);
  1309. $text.=$r['varid'].$field.$r['myvar'].$field.$r['varname'].$field.$r['varvalue'].$field.$classid.$field.$r['isclose'].$field.$r['myorder'].$record;
  1310. }
  1311. return $text;
  1312. }
  1313. function LoadInTGTempvar($gid,$en,$record,$field,$text){
  1314. global $empire,$dbtbpre;
  1315. if(empty($text))
  1316. {
  1317. return "";
  1318. }
  1319. $tb=$dbtbpre."enewstempvar".$en;
  1320. $rr=explode($record,$text);
  1321. $count=count($rr);
  1322. for($i=0;$i<$count-1;$i++)
  1323. {
  1324. $r=explode($field,$rr[$i]);
  1325. $sql=$empire->query("insert into ".$tb."(varid,myvar,varname,varvalue,classid,isclose,myorder) values('$r[0]','".addslashes($r[1])."','".addslashes($r[2])."','".addslashes($r[3])."','$r[4]','$r[5]','$r[6]');");
  1326. }
  1327. }
  1328. //投票模板
  1329. function LoadTGVotetemp($gid,$en,$pageexp,$record,$field){
  1330. global $empire,$dbtbpre;
  1331. $tb=$dbtbpre."enewsvotetemp".$en;
  1332. $sql=$empire->query("select * from ".$tb." order by tempid");
  1333. $classid=0;
  1334. while($r=$empire->fetch($sql))
  1335. {
  1336. $r['temptext']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['temptext']);
  1337. $text.=$r['tempid'].$field.$r['tempname'].$field.$r['temptext'].$record;
  1338. }
  1339. return $text;
  1340. }
  1341. function LoadInTGVotetemp($gid,$en,$record,$field,$text){
  1342. global $empire,$dbtbpre;
  1343. if(empty($text))
  1344. {
  1345. return "";
  1346. }
  1347. $tb=$dbtbpre."enewsvotetemp".$en;
  1348. $rr=explode($record,$text);
  1349. $count=count($rr);
  1350. for($i=0;$i<$count-1;$i++)
  1351. {
  1352. $r=explode($field,$rr[$i]);
  1353. $sql=$empire->query("insert into ".$tb."(tempid,tempname,temptext) values('$r[0]','".addslashes($r[1])."','".addslashes($r[2])."');");
  1354. }
  1355. }
  1356. //栏目封面模板
  1357. function LoadTGClasstemp($gid,$en,$pageexp,$record,$field){
  1358. global $empire,$dbtbpre;
  1359. $tb=$dbtbpre."enewsclasstemp".$en;
  1360. $sql=$empire->query("select * from ".$tb." order by tempid");
  1361. $classid=0;
  1362. while($r=$empire->fetch($sql))
  1363. {
  1364. $r['temptext']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['temptext']);
  1365. $text.=$r['tempid'].$field.$r['tempname'].$field.$r['temptext'].$field.$classid.$record;
  1366. }
  1367. return $text;
  1368. }
  1369. function LoadInTGClasstemp($gid,$en,$record,$field,$text){
  1370. global $empire,$dbtbpre;
  1371. if(empty($text))
  1372. {
  1373. return "";
  1374. }
  1375. $tb=$dbtbpre."enewsclasstemp".$en;
  1376. $rr=explode($record,$text);
  1377. $count=count($rr);
  1378. for($i=0;$i<$count-1;$i++)
  1379. {
  1380. $r=explode($field,$rr[$i]);
  1381. $sql=$empire->query("insert into ".$tb."(tempid,tempname,temptext,classid) values('$r[0]','".addslashes($r[1])."','".addslashes($r[2])."','$r[3]');");
  1382. }
  1383. }
  1384. //评论列表模板
  1385. function LoadTGPltemp($gid,$en,$pageexp,$record,$field){
  1386. global $empire,$dbtbpre;
  1387. $tb=$dbtbpre."enewspltemp".$en;
  1388. $sql=$empire->query("select * from ".$tb." order by tempid");
  1389. while($r=$empire->fetch($sql))
  1390. {
  1391. $r['temptext']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['temptext']);
  1392. $text.=$r['tempid'].$field.$r['tempname'].$field.$r['temptext'].$field.$r['isdefault'].$record;
  1393. }
  1394. return $text;
  1395. }
  1396. function LoadInTGPltemp($gid,$en,$record,$field,$text){
  1397. global $empire,$dbtbpre;
  1398. if(empty($text))
  1399. {
  1400. return "";
  1401. }
  1402. $tb=$dbtbpre."enewspltemp".$en;
  1403. $rr=explode($record,$text);
  1404. $count=count($rr);
  1405. for($i=0;$i<$count-1;$i++)
  1406. {
  1407. $r=explode($field,$rr[$i]);
  1408. $sql=$empire->query("insert into ".$tb."(tempid,tempname,temptext,isdefault) values('$r[0]','".addslashes($r[1])."','".addslashes($r[2])."','$r[3]');");
  1409. }
  1410. }
  1411. //打印模板
  1412. function LoadTGPrinttemp($gid,$en,$pageexp,$record,$field){
  1413. global $empire,$dbtbpre;
  1414. $tb=$dbtbpre."enewsprinttemp".$en;
  1415. $sql=$empire->query("select * from ".$tb." order by tempid");
  1416. while($r=$empire->fetch($sql))
  1417. {
  1418. $r['temptext']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['temptext']);
  1419. $text.=$r['tempid'].$field.$r['tempname'].$field.$r['temptext'].$field.$r['isdefault'].$field.$r['showdate'].$field.$r['modid'].$record;
  1420. }
  1421. return $text;
  1422. }
  1423. function LoadInTGPrinttemp($gid,$en,$record,$field,$text){
  1424. global $empire,$dbtbpre;
  1425. if(empty($text))
  1426. {
  1427. return "";
  1428. }
  1429. $tb=$dbtbpre."enewsprinttemp".$en;
  1430. $rr=explode($record,$text);
  1431. $count=count($rr);
  1432. for($i=0;$i<$count-1;$i++)
  1433. {
  1434. $r=explode($field,$rr[$i]);
  1435. $sql=$empire->query("insert into ".$tb."(tempid,tempname,temptext,isdefault,showdate,modid) values('$r[0]','".addslashes($r[1])."','".addslashes($r[2])."','$r[3]','".addslashes($r[4])."','$r[5]');");
  1436. }
  1437. }
  1438. //自定义页面模板
  1439. function LoadTGPagetemp($gid,$en,$pageexp,$record,$field){
  1440. global $empire,$dbtbpre;
  1441. $tb=$dbtbpre."enewspagetemp".$en;
  1442. $sql=$empire->query("select * from ".$tb." order by tempid");
  1443. $classid=0;
  1444. while($r=$empire->fetch($sql))
  1445. {
  1446. $r['temptext']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['temptext']);
  1447. $text.=$r['tempid'].$field.$r['tempname'].$field.$r['temptext'].$record;
  1448. }
  1449. return $text;
  1450. }
  1451. function Lo

Large files files are truncated, but you can click here to view the full file