tempfun.php 61 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841
  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='".eaddslashes2($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".hReturnEcmsHashStrHref2(0)."#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='".eaddslashes2($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".hReturnEcmsHashStrHref2(0)."#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='".eaddslashes2($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".hReturnEcmsHashStrHref2(0)."#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='".eaddslashes2($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".hReturnEcmsHashStrHref2(0)."#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='".eaddslashes2($temptext)."',schallsubnum='$sub',schalldate='".eaddslashes($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".hReturnEcmsHashStrHref2(0)."#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]."','".eaddslashes2($bqsay)."','$add[funname]','$add[bq]',0,'".eaddslashes2($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".hReturnEcmsHashStrHref2(0));
  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='".eaddslashes2($bqsay)."',funname='$add[funname]',bq='$add[bq]',bqgs='".eaddslashes2($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]".hReturnEcmsHashStrHref2(0));
  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".hReturnEcmsHashStrHref2(0));
  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."='".eaddslashes2($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".hReturnEcmsHashStrHref2(0)."#$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."='".eaddslashes2($temptext)."',otherlinktempsub=$otherlinktempsub,otherlinktempdate='".eaddslashes($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".hReturnEcmsHashStrHref2(0)."#$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."='".eaddslashes2($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".hReturnEcmsHashStrHref2(0)."#$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='".eaddslashes2($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,eaddslashes($temptext),1,0);
  366. //删除动态模板缓存文件
  367. DelOneTempTmpfile('indexpage');
  368. //更新动态页面缓存
  369. $ecms_fclast=time();
  370. $empire->query("update {$dbtbpre}enewspublic_fc set fclastindex='$ecms_fclast' limit 1");
  371. }
  372. if($sql)
  373. {
  374. insert_dolog("gid=$gid");//操作日志
  375. printerror("EditPublicTempSuccess","template/EditPublicTemp.php?tname=indextemp&gid=$gid".hReturnEcmsHashStrHref2(0));
  376. }
  377. else
  378. {
  379. printerror("DbError","history.go(-1)");
  380. }
  381. }
  382. //预览首页方案
  383. function PreviewIndexpage($tempid,$userid,$username){
  384. global $empire,$dbtbpre,$public_r,$emod_r,$class_r,$class_zr,$fun_r,$navclassid,$navinfor,$class_tr,$level_r,$etable_r;
  385. //验证权限
  386. CheckLevel($userid,$username,$classid,"template");
  387. $tempid=(int)$tempid;
  388. if(!$tempid)
  389. {
  390. printerror('ErrorUrl','');
  391. }
  392. $tempr=$empire->fetch1("select tempid,temptext from {$dbtbpre}enewsindexpage where tempid='$tempid'");
  393. if(!$tempr['tempid'])
  394. {
  395. printerror('ErrorUrl','');
  396. }
  397. $indextext=stripSlashes($tempr['temptext']);
  398. $indextext=ReplaceTempvar($indextext);//替换全局模板变量
  399. $pr=$empire->fetch1("select sitekey,siteintro from {$dbtbpre}enewspublic limit 1");
  400. //页面
  401. $pagetitle=ehtmlspecialchars($public_r['sitename']);
  402. $pagekey=ehtmlspecialchars($pr['sitekey']);
  403. $pagedes=ehtmlspecialchars($pr['siteintro']);
  404. $url="<a href=\"".ReturnSiteIndexUrl()."\">".$fun_r['index']."</a>";//栏目导航
  405. $onclick='';
  406. $file=ECMS_PATH.'e/data/tmp/indexpage'.$tempid.'.php';
  407. $indextext=ReplaceSvars($indextext,$url,0,$pagetitle,$pagekey,$pagedes,$add,0);
  408. $indextext=str_replace("[!--page.stats--]",$onclick,$indextext);
  409. //替换标签
  410. $indextext=DoRepEcmsLoopBq($indextext);
  411. $indextext=RepBq($indextext);
  412. //写文件
  413. WriteFiletext($file,AddCheckViewTempCode().$indextext);
  414. //读取文件内容
  415. ob_start();
  416. include($file);
  417. $string=ob_get_contents();
  418. ob_end_clean();
  419. $string=RepExeCode($string);//解析代码
  420. echo stripSlashes($string);
  421. exit();
  422. }
  423. //批量导入栏目模板
  424. function LoadTempInClass($path,$start,$userid,$username){
  425. global $empire,$public_r,$dbtbpre;
  426. //验证权限
  427. CheckLevel($userid,$username,$classid,"template");
  428. $start=(int)$start;
  429. if(empty($public_r[loadtempnum]))
  430. {$public_r[loadtempnum]=50;}
  431. $b=0;
  432. $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]);
  433. while($r=$empire->fetch($sql))
  434. {
  435. $b=1;
  436. $newstart=$r[classid];
  437. if($r[islist]==3)
  438. {
  439. continue;
  440. }
  441. $file="../data/LoadTemp/".$r[classid].".htm";
  442. if(file_exists($file))
  443. {
  444. $data=addslashes(addslashes(ReadFiletext($file)));
  445. $data=RepPhpAspJspcode($data);
  446. if($r[islist]==2)
  447. {
  448. $usql=$empire->query("update {$dbtbpre}enewsclassadd set classtext='".$data."' where classid='$r[classid]'");
  449. }
  450. else
  451. {
  452. $usql=$empire->query("update {$dbtbpre}enewsclasstemp set temptext='".$data."' where tempid='$r[classtempid]'");
  453. }
  454. NewsBq($r[classid],$data,0,0);
  455. }
  456. }
  457. if(empty($b))
  458. {
  459. //操作日志
  460. insert_dolog("");
  461. printerror("LoadClassTempSuccess","template/LoadTemp.php".hReturnEcmsHashStrHref2(1));
  462. }
  463. echo $fun_r['LoadOneTempSuccess']."(ID:<font color=red><b>".$newstart."</b></font>)<script>self.location.href='ecmstemp.php?enews=LoadTempInClass&start=$newstart".hReturnEcmsHashStrHref(0)."';</script>";
  464. exit();
  465. }
  466. //批量更换栏目列表模板
  467. function ChangeClassListtemp($classid,$listtempid,$userid,$username){
  468. global $empire,$class_r,$dbtbpre;
  469. if(empty($listtempid))
  470. {printerror("EmptChangeListtempid","history.go(-1)");}
  471. //验证权限
  472. CheckLevel($userid,$username,$classid,"template");
  473. $listtempid=(int)$listtempid;
  474. $classid=(int)$classid;
  475. if(empty($classid))
  476. {$where="classid<>0";}
  477. else
  478. {
  479. //中级栏目
  480. if(empty($class_r[$classid][islast]))
  481. {
  482. $where=ReturnClass($class_r[$classid][sonclass]);
  483. }
  484. //终极栏目
  485. else
  486. {
  487. $where="classid='$classid'";
  488. }
  489. }
  490. $sql=$empire->query("update {$dbtbpre}enewsclass set listtempid=$listtempid where ".$where);
  491. GetClass();
  492. if($sql)
  493. {
  494. //操作日志
  495. insert_dolog("classid=$classid&listtempid=$listtempid");
  496. printerror("ChangeClassListtempSuccess","history.go(-1)");
  497. }
  498. else
  499. {printerror("DbError","history.go(-1)");}
  500. }
  501. //导出标签
  502. function LoadOutBq($add,$userid,$username){
  503. global $empire,$dbtbpre;
  504. $bqid=(int)$add['bqid'];
  505. if(!$bqid||!$add['funvalue'])
  506. {
  507. printerror("EmptyLoadBqid","history.go(-1)");
  508. }
  509. //验证权限
  510. CheckLevel($userid,$username,$classid,"bq");
  511. $r=$empire->fetch1("select bqid,bqname,bqsay,funname,bq,bqgs from {$dbtbpre}enewsbq where bqid=$bqid");
  512. if(!$r[bqid])
  513. {
  514. printerror("NotThisBqid","history.go(-1)");
  515. }
  516. $add['funvalue']=ClearAddsData($add['funvalue']);
  517. $field="<!--#empirecms.bq-phome.net#--!>";
  518. $str=$r['bqname'].$field.stripSlashes($r['bqsay']).$field.$r['funname'].$field.$r['bq'].$field.stripSlashes($r['bqgs']).$field.$add['funvalue'];
  519. $filename=$r['bq'].time().".bq";
  520. $filepath=ECMS_PATH.'e/data/tmp/temp/'.$filename;
  521. WriteFiletext_n($filepath,$str);
  522. DownLoadFile($filename,$filepath,1);
  523. //操作日志
  524. insert_dolog("bqid=".$bqid."<br>bqname=".$r[bqname]);
  525. exit();
  526. }
  527. //导入标签
  528. function LoadInBq($add,$file,$file_name,$file_type,$file_size,$userid,$username){
  529. global $empire,$dbtbpre;
  530. //验证权限
  531. CheckLevel($userid,$username,$classid,"bq");
  532. $classid=(int)$add['classid'];
  533. if(!$file_name||!$file_size)
  534. {
  535. printerror("EmptyLoadInBqFile","history.go(-1)");
  536. }
  537. //扩展名
  538. $filetype=GetFiletype($file_name);
  539. if($filetype!=".bq")
  540. {
  541. printerror("LoadInBqMustBq","history.go(-1)");
  542. }
  543. $field="<!--#empirecms.bq-phome.net#--!>";
  544. $path=ECMS_PATH.'e/data/tmp/temp/uploadbq'.time().'.bq';
  545. //上传文件
  546. $cp=@move_uploaded_file($file,$path);
  547. DoChmodFile($path);
  548. $data=ReadFiletext($path);
  549. DelFiletext($path);
  550. $r=explode($field,$data);
  551. $num=$empire->gettotal("select count(*) as total from {$dbtbpre}enewsbq where bq='$r[3]' or funname='$r[2]' limit 1");
  552. if($num)
  553. {
  554. printerror("ReLoadInBq","history.go(-1)");
  555. }
  556. $sql=$empire->query("insert into {$dbtbpre}enewsbq(bqname,bqsay,funname,bq,issys,bqgs,isclose,classid,myorder) values('".addslashes($r[0])."','".addslashes(addslashes($r[1]))."','".addslashes($r[2])."','".addslashes($r[3])."',0,'".addslashes(addslashes($r[4]))."',0,$classid,0);");
  557. $bqid=$empire->lastid();
  558. //操作日志
  559. insert_dolog("bqid=".$bqid."<br>bqname=".$r[0]);
  560. return $r;
  561. }
  562. //-----------------------批量替换模板字符
  563. function DoRepTemp($add,$userid,$username){
  564. global $empire,$dbtbpre;
  565. //验证权限
  566. CheckLevel($userid,$username,$classid,"template");
  567. $oldword=RepPhpAspJspcode(eaddslashes2($add['oldword']));
  568. $newword=RepPhpAspJspcode(eaddslashes2($add['newword']));
  569. if(!$oldword)
  570. {
  571. printerror("EmptyRepTemp","history.go(-1)");
  572. }
  573. $gid=(int)$add['gid'];
  574. //公共表
  575. if($add['indextemp']||$add['cptemp']||$add['sformtemp']||$add['otherlinktemp']||$add['gbooktemp']||$add['loginiframe']||$add['pljstemp']||$add['schalltemp']||$add['loginjstemp']||$add['downpagetemp'])
  576. {
  577. $set='';
  578. //首页模板
  579. if($add['indextemp'])
  580. {
  581. $set.=",indextemp=REPLACE(indextemp,'".$oldword."','".$newword."')";
  582. }
  583. //控制面板模板
  584. if($add['cptemp'])
  585. {
  586. $set.=",cptemp=REPLACE(cptemp,'".$oldword."','".$newword."')";
  587. }
  588. //搜索表单模板
  589. if($add['sformtemp'])
  590. {
  591. $set.=",searchtemp=REPLACE(searchtemp,'".$oldword."','".$newword."')";
  592. }
  593. //相关信息模板
  594. if($add['otherlinktemp'])
  595. {
  596. $set.=",otherlinktemp=REPLACE(otherlinktemp,'".$oldword."','".$newword."')";
  597. }
  598. //留言板模板
  599. if($add['gbooktemp'])
  600. {
  601. $set.=",gbooktemp=REPLACE(gbooktemp,'".$oldword."','".$newword."')";
  602. }
  603. //登陆状态模板
  604. if($add['loginiframe'])
  605. {
  606. $set.=",loginiframe=REPLACE(loginiframe,'".$oldword."','".$newword."')";
  607. }
  608. //评论JS模板
  609. if($add['pljstemp'])
  610. {
  611. $set.=",pljstemp=REPLACE(pljstemp,'".$oldword."','".$newword."')";
  612. }
  613. //全站搜索模板
  614. if($add['schalltemp'])
  615. {
  616. $set.=",schalltemp=REPLACE(schalltemp,'".$oldword."','".$newword."')";
  617. }
  618. //JS调用登陆状态模板
  619. if($add['loginjstemp'])
  620. {
  621. $set.=",loginjstemp=REPLACE(loginjstemp,'".$oldword."','".$newword."')";
  622. }
  623. //最终下载页模板
  624. if($add['downpagetemp'])
  625. {
  626. $set.=",downpagetemp=REPLACE(downpagetemp,'".$oldword."','".$newword."')";
  627. }
  628. $empire->query("update ".GetDoTemptb("enewspubtemp",$gid)." set id=1".$set." limit 1");
  629. }
  630. //修改栏目封面模板
  631. if($add['classtemp'])
  632. {
  633. $empire->query("update ".GetDoTemptb("enewsclasstemp",$gid)." set temptext=REPLACE(temptext,'".$oldword."','".$newword."')");
  634. }
  635. //修改标签模板
  636. if($add['bqtemp'])
  637. {
  638. $empire->query("update ".GetDoTemptb("enewsbqtemp",$gid)." set temptext=REPLACE(temptext,'".$oldword."','".$newword."'),listvar=REPLACE(listvar,'".$oldword."','".$newword."')");
  639. }
  640. //修改列表模板
  641. if($add['listtemp'])
  642. {
  643. $empire->query("update ".GetDoTemptb("enewslisttemp",$gid)." set temptext=REPLACE(temptext,'".$oldword."','".$newword."'),listvar=REPLACE(listvar,'".$oldword."','".$newword."')");
  644. }
  645. //修改内容模板
  646. if($add['newstemp'])
  647. {
  648. $empire->query("update ".GetDoTemptb("enewsnewstemp",$gid)." set temptext=REPLACE(temptext,'".$oldword."','".$newword."')");
  649. }
  650. //修改搜索模板
  651. if($add['searchtemp'])
  652. {
  653. $empire->query("update ".GetDoTemptb("enewssearchtemp",$gid)." set temptext=REPLACE(temptext,'".$oldword."','".$newword."'),listvar=REPLACE(listvar,'".$oldword."','".$newword."')");
  654. }
  655. //修改自定义页面
  656. if($add['userpage'])
  657. {
  658. $empire->query("update {$dbtbpre}enewspage set pagetext=REPLACE(pagetext,'".$oldword."','".$newword."')");
  659. }
  660. //修改自定义页面模板
  661. if($add['pagetemp'])
  662. {
  663. $empire->query("update ".GetDoTemptb("enewspagetemp",$gid)." set temptext=REPLACE(temptext,'".$oldword."','".$newword."')");
  664. }
  665. //评论列表模板
  666. if($add['pltemp'])
  667. {
  668. $empire->query("update ".GetDoTemptb("enewspltemp",$gid)." set temptext=REPLACE(temptext,'".$oldword."','".$newword."')");
  669. }
  670. //打印模板
  671. if($add['printtemp'])
  672. {
  673. $empire->query("update ".GetDoTemptb("enewsprinttemp",$gid)." set temptext=REPLACE(temptext,'".$oldword."','".$newword."')");
  674. }
  675. //模板变量
  676. if($add['tempvar'])
  677. {
  678. $empire->query("update ".GetDoTemptb("enewstempvar",$gid)." set varvalue=REPLACE(varvalue,'".$oldword."','".$newword."')");
  679. }
  680. //修改JS模板
  681. if($add['jstemp'])
  682. {
  683. $empire->query("update ".GetDoTemptb("enewsjstemp",$gid)." set temptext=REPLACE(temptext,'".$oldword."','".$newword."')");
  684. }
  685. //修改投票模板
  686. if($add['votetemp'])
  687. {
  688. $empire->query("update ".GetDoTemptb("enewsvotetemp",$gid)." set temptext=REPLACE(temptext,'".$oldword."','".$newword."')");
  689. }
  690. //反馈表单模板
  691. if($add['feedbackbtemp'])
  692. {
  693. $empire->query("update {$dbtbpre}enewsfeedbackclass set btemp=REPLACE(btemp,'".$oldword."','".$newword."')");
  694. }
  695. //操作日志
  696. insert_dolog("gid=$gid");
  697. printerror("RepTempSuccess","history.go(-1)");
  698. }
  699. //修改模板组
  700. function EditTempGroup($add,$userid,$username){
  701. global $empire,$dbtbpre;
  702. //验证权限
  703. CheckLevel($userid,$username,$classid,"tempgroup");
  704. $gid=$add['gid'];
  705. $gname=$add['gname'];
  706. $count=count($gid);
  707. for($i=0;$i<$count;$i++)
  708. {
  709. $usql=$empire->query("update {$dbtbpre}enewstempgroup set gname='".$gname[$i]."' where gid='".$gid[$i]."'");
  710. }
  711. //操作日志
  712. insert_dolog("");
  713. printerror("EditTempGroupSuccess","TempGroup.php".hReturnEcmsHashStrHref2(1));
  714. }
  715. //默认模板组
  716. function DefTtempGroup($add,$userid,$username){
  717. global $empire,$dbtbpre;
  718. //验证权限
  719. CheckLevel($userid,$username,$classid,"tempgroup");
  720. $gid=(int)$add['changegid'];
  721. if(!$gid)
  722. {
  723. printerror("EmptyTempGroup","");
  724. }
  725. $r=$empire->fetch1("select gid,gname from {$dbtbpre}enewstempgroup where gid=$gid");
  726. if(!$r['gid'])
  727. {
  728. printerror("EmptyTempGroup","");
  729. }
  730. $usql=$empire->query("update {$dbtbpre}enewstempgroup set isdefault=0");
  731. $sql=$empire->query("update {$dbtbpre}enewstempgroup set isdefault=1 where gid=$gid");
  732. $upsql=$empire->query("update {$dbtbpre}enewspublic set deftempid=$gid limit 1");
  733. if($usql&&$sql&&$upsql)
  734. {
  735. GetConfig();
  736. //操作日志
  737. insert_dolog("gid=$gid&gname=$r[gname]");
  738. printerror("DefTempGroupSuccess","TempGroup.php".hReturnEcmsHashStrHref2(1));
  739. }
  740. else
  741. {
  742. printerror("DbError","");
  743. }
  744. }
  745. //返回模板表
  746. function ReturnTemptbList(){
  747. $templist="enewsbqtemp,enewsjstemp,enewslisttemp,enewsnewstemp,enewspubtemp,enewssearchtemp,enewstempvar,enewsvotetemp,enewsclasstemp,enewspltemp,enewsprinttemp,enewspagetemp";
  748. return $templist;
  749. }
  750. //删除模板数据表
  751. function DelTempTb($gid){
  752. global $empire,$dbtbpre;
  753. if($gid==1)
  754. {
  755. return "";
  756. }
  757. $templist=ReturnTemptbList();
  758. $r=explode(",",$templist);
  759. $count=count($r);
  760. $droptb="";
  761. for($i=0;$i<$count;$i++)
  762. {
  763. $dh=",";
  764. if($i==0)
  765. {
  766. $dh="";
  767. }
  768. $droptb.=$dh.$dbtbpre.$r[$i]."_".$gid;
  769. }
  770. $sql=$empire->query("DROP TABLE IF EXISTS ".$droptb.";");
  771. return $sql;
  772. }
  773. //清空模板数据表
  774. function ClearTempTb($gid,$en){
  775. global $empire,$dbtbpre;
  776. $templist=ReturnTemptbList();
  777. $r=explode(",",$templist);
  778. $count=count($r);
  779. for($i=0;$i<$count;$i++)
  780. {
  781. $tb=$dbtbpre.$r[$i].$en;
  782. $empire->query("TRUNCATE `".$tb."`;");
  783. }
  784. }
  785. //新建模板数据表
  786. function CreateTempTb($gid,$en){
  787. global $empire,$dbtbpre;
  788. if($gid==1)
  789. {
  790. return "";
  791. }
  792. $templist=ReturnTemptbList();
  793. $r=explode(",",$templist);
  794. $count=count($r);
  795. for($i=0;$i<$count;$i++)
  796. {
  797. $otb=$dbtbpre.$r[$i];
  798. $tb=$dbtbpre.$r[$i].$en;
  799. CopyEcmsTb($otb,$tb);
  800. }
  801. }
  802. //删除模板组
  803. function DelTempGroup($add,$userid,$username){
  804. global $empire,$dbtbpre;
  805. //验证权限
  806. CheckLevel($userid,$username,$classid,"tempgroup");
  807. $gid=(int)$add['changegid'];
  808. if(!$gid)
  809. {
  810. printerror("EmptyDelTempGroup","");
  811. }
  812. if($gid==1)
  813. {
  814. printerror("NotDelDefTempGroup","");
  815. }
  816. $r=$empire->fetch1("select gid,gname,isdefault from {$dbtbpre}enewstempgroup where gid=$gid");
  817. if(!$r['gid'])
  818. {
  819. printerror("EmptyDelTempGroup","");
  820. }
  821. $sql=$empire->query("delete from {$dbtbpre}enewstempgroup where gid=$gid");
  822. if($r['isdefault'])
  823. {
  824. $upsql=$empire->query("update {$dbtbpre}enewspublic set deftempid=0 limit 1");
  825. GetConfig();
  826. }
  827. DelTempTb($gid);
  828. //删除备份记录
  829. $empire->query("delete from {$dbtbpre}enewstempbak where gid='$gid'");
  830. if($sql)
  831. {
  832. //操作日志
  833. insert_dolog("gid=$gid&gname=$r[gname]");
  834. printerror("DelTempGroupSuccess","TempGroup.php".hReturnEcmsHashStrHref2(1));
  835. }
  836. else
  837. {
  838. printerror("DbError","");
  839. }
  840. }
  841. //导出模板组
  842. function LoadTempGroup($add,$userid,$username){
  843. global $empire,$dbtbpre;
  844. //验证权限
  845. CheckLevel($userid,$username,$classid,"tempgroup");
  846. $gid=(int)$add['changegid'];
  847. if(!$gid)
  848. {
  849. printerror("EmptyLoadTempGroup","");
  850. }
  851. $r=$empire->fetch1("select gid,gname from {$dbtbpre}enewstempgroup where gid=$gid");
  852. if(!$r['gid'])
  853. {
  854. printerror("EmptyLoadTempGroup","");
  855. }
  856. //版本
  857. $thistempver=LoadTGAddVer();
  858. $pageexp="<!---ecms.temp--->";
  859. $record="<!---ecms.record--->";
  860. $field="<!---ecms.field--->";
  861. if($gid==1)
  862. {
  863. $en="";
  864. }
  865. else
  866. {
  867. $en="_".$gid;
  868. }
  869. $bqtemp=LoadTGBqtemp($gid,$en,$pageexp,$record,$field);//标签模板
  870. $jstemp=LoadTGJstemp($gid,$en,$pageexp,$record,$field);//JS模板
  871. $listtemp=LoadTGListtemp($gid,$en,$pageexp,$record,$field);//列表模板
  872. $newstemp=LoadTGNewstemp($gid,$en,$pageexp,$record,$field);//内容模板
  873. $pubtemp=LoadTGPubtemp($gid,$en,$pageexp,$record,$field);//公共模板
  874. $searchtemp=LoadTGSearchtemp($gid,$en,$pageexp,$record,$field);//搜索模板
  875. $tempvar=LoadTGTempvar($gid,$en,$pageexp,$record,$field);//模板变量
  876. $votetemp=LoadTGVotetemp($gid,$en,$pageexp,$record,$field);//投票模板
  877. $classtemp=LoadTGClasstemp($gid,$en,$pageexp,$record,$field);//栏目模板
  878. $pltemp=LoadTGPltemp($gid,$en,$pageexp,$record,$field);//评论模板
  879. $printtemp=LoadTGPrinttemp($gid,$en,$pageexp,$record,$field);//打印模板
  880. $pagetemp=LoadTGPagetemp($gid,$en,$pageexp,$record,$field);//自定义页面模板
  881. $loadtemptext=$r['gname'].$thistempver.$pageexp.$bqtemp.$pageexp.$jstemp.$pageexp.$listtemp.$pageexp.$newstemp.$pageexp.$pubtemp.$pageexp.$searchtemp.$pageexp.$tempvar.$pageexp.$votetemp.$pageexp.$classtemp.$pageexp.$pltemp.$pageexp.$printtemp.$pageexp.$pagetemp;
  882. $loadtemptext=stripSlashes($loadtemptext);
  883. $file="e".time().".temp";
  884. $filepath=ECMS_PATH.'e/data/tmp/temp/'.$file;
  885. WriteFiletext_n($filepath,$loadtemptext);
  886. DownLoadFile($file,$filepath,1);
  887. //操作日志
  888. insert_dolog("gid=$gid&gname=$r[gname]");
  889. exit();
  890. }
  891. //模板转编码
  892. function LoadInTempChangeChar($tempchar,$text){
  893. global $ecms_config;
  894. @include_once(ECMS_PATH.'e/class/EmpireCMS_version.php');
  895. if($tempchar=='GB2312')//简体GB2312
  896. {
  897. if($ecms_config['sets']['pagechar']=='gb2312')
  898. {
  899. return $text;
  900. }
  901. if($ecms_config['sets']['pagechar']=='utf-8')
  902. {
  903. if(EmpireCMS_CHARVER=='TC-UTF-8')//繁体
  904. {
  905. $text=DoIconvVal("GB2312","BIG5",$text,1);
  906. $text=DoIconvVal("BIG5","UTF8",$text);
  907. }
  908. else//简体
  909. {
  910. $text=DoIconvVal("GB2312","UTF8",$text,1);
  911. }
  912. $text=preg_replace(array('/charset=gbk/i','/charset=gb2312/i'),array('charset=utf-8','charset=utf-8'),$text);
  913. }
  914. elseif($ecms_config['sets']['pagechar']=='big5')
  915. {
  916. $text=DoIconvVal("GB2312","BIG5",$text,1);
  917. $text=preg_replace(array('/charset=gbk/i','/charset=gb2312/i'),array('charset=big5','charset=big5'),$text);
  918. }
  919. }
  920. elseif($tempchar=='UTF8')//简体UTF-8
  921. {
  922. if($ecms_config['sets']['pagechar']=='utf-8'&&EmpireCMS_CHARVER=='UTF-8')
  923. {
  924. return $text;
  925. }
  926. if($ecms_config['sets']['pagechar']=='gb2312')
  927. {
  928. $text=DoIconvVal("UTF8","GB2312",$text,1);
  929. $text=preg_replace('/charset=utf-8/i','charset=gb2312',$text);
  930. }
  931. elseif($ecms_config['sets']['pagechar']=='big5')
  932. {
  933. $text=DoIconvVal("UTF8","GB2312",$text,1);
  934. $text=DoIconvVal("GB2312","BIG5",$text);
  935. $text=preg_replace('/charset=utf-8/i','charset=big5',$text);
  936. }
  937. elseif($ecms_config['sets']['pagechar']=='utf-8')//繁体
  938. {
  939. $text=DoIconvVal("UTF8","GB2312",$text,1);
  940. $text=DoIconvVal("GB2312","BIG5",$text);
  941. $text=DoIconvVal("BIG5","UTF8",$text);
  942. }
  943. }
  944. elseif($tempchar=='BIG5')//繁体BIG5
  945. {
  946. if($ecms_config['sets']['pagechar']=='big5')
  947. {
  948. return $text;
  949. }
  950. if($ecms_config['sets']['pagechar']=='gb2312')
  951. {
  952. $text=DoIconvVal("BIG5","GB2312",$text,1);
  953. $text=preg_replace('/charset=big5/i','charset=gb2312',$text);
  954. }
  955. elseif($ecms_config['sets']['pagechar']=='utf-8')
  956. {
  957. if(EmpireCMS_CHARVER=='UTF-8')//简体
  958. {
  959. $text=DoIconvVal("BIG5","GB2312",$text,1);
  960. $text=DoIconvVal("GB2312","UTF8",$text);
  961. }
  962. else//繁体
  963. {
  964. $text=DoIconvVal("BIG5","UTF8",$text,1);
  965. }
  966. $text=preg_replace('/charset=big5/i','charset=utf-8',$text);
  967. }
  968. }
  969. elseif($tempchar=='TCUTF8')//繁体UTF-8
  970. {
  971. if($ecms_config['sets']['pagechar']=='utf-8'&&EmpireCMS_CHARVER=='TC-UTF-8')
  972. {
  973. return $text;
  974. }
  975. if($ecms_config['sets']['pagechar']=='gb2312')
  976. {
  977. $text=DoIconvVal("UTF8","BIG5",$text,1);
  978. $text=DoIconvVal("BIG5","GB2312",$text);
  979. $text=preg_replace('/charset=utf-8/i','charset=gb2312',$text);
  980. }
  981. elseif($ecms_config['sets']['pagechar']=='big5')
  982. {
  983. $text=DoIconvVal("UTF8","BIG5",$text,1);
  984. $text=preg_replace('/charset=utf-8/i','charset=big5',$text);
  985. }
  986. elseif($ecms_config['sets']['pagechar']=='utf-8')//简体
  987. {
  988. $text=DoIconvVal("UTF8","BIG5",$text,1);
  989. $text=DoIconvVal("BIG5","GB2312",$text);
  990. $text=DoIconvVal("GB2312","UTF8",$text);
  991. }
  992. }
  993. return $text;
  994. }
  995. //替换以往版本地址
  996. function LoadInTGReptext_pubvar($text){
  997. //shop
  998. $text=str_replace('/enews/?enews=AddBuycar','/ShopSys/doaction.php?enews=AddBuycar',$text);
  999. $text=str_replace('/enews?enews=AddBuycar','/ShopSys/doaction.php?enews=AddBuycar',$text);
  1000. //pl
  1001. $text=str_replace('/enews/?enews=DoForPl','/pl/doaction.php?enews=DoForPl',$text);
  1002. $text=str_replace('/enews?enews=DoForPl','/pl/doaction.php?enews=DoForPl',$text);
  1003. //member
  1004. $text=str_replace('/enews/?enews=exit','/member/doaction.php?enews=exit',$text);
  1005. $text=str_replace('/enews?enews=exit','/member/doaction.php?enews=exit',$text);
  1006. //report
  1007. $text=str_replace('/DownSys/report','/public/report',$text);
  1008. return $text;
  1009. }
  1010. //替换以往版本地址
  1011. function LoadInTGReptext_othervar($text,$type='pl'){
  1012. if($type=='pl')
  1013. {
  1014. $text=str_replace('/enews/index.php','/pl/doaction.php',$text);
  1015. }
  1016. elseif($type=='member')
  1017. {
  1018. $text=str_replace('/enews/index.php','/member/doaction.php',$text);
  1019. }
  1020. elseif($type=='shop')
  1021. {
  1022. $text=str_replace('/enews/index.php','/ShopSys/doaction.php',$text);
  1023. }
  1024. return $text;
  1025. }
  1026. //加版本号
  1027. function LoadTGAddVer(){
  1028. @include_once(ECMS_PATH.'e/class/EmpireCMS_version.php');
  1029. $ver=' ,-- '.EmpireCMS_VERSION.','.EmpireCMS_CHARVER;
  1030. return $ver;
  1031. }
  1032. //替换版本号
  1033. function LoadInTGReturnVer($gname){
  1034. $exp=' ,-- ';
  1035. $r=explode($exp,$gname);
  1036. $returnr['gname']=$r[0];
  1037. $returnr['ver']='';
  1038. $returnr['tempchar']='';
  1039. if($r[1])
  1040. {
  1041. $vr=explode(',',$r[1]);
  1042. $returnr['ver']=$vr[0];
  1043. $returnr['tempchar']=$vr[1];
  1044. }
  1045. return $returnr;
  1046. }
  1047. //导入模板组
  1048. function LoadInTempGroup($add,$file,$file_name,$file_type,$file_size,$userid,$username){
  1049. global $empire,$dbtbpre;
  1050. //验证权限
  1051. CheckLevel($userid,$username,$classid,"tempgroup");
  1052. if(!$file_name||!$file_size)
  1053. {
  1054. printerror("EmptyLoadInTempGroup","");
  1055. }
  1056. $gid=(int)$add['gid'];
  1057. //扩展名
  1058. $filetype=GetFiletype($file_name);
  1059. if($filetype!=".temp")
  1060. {
  1061. printerror("LoadInTempGroupMusttemp","");
  1062. }
  1063. //上传文件
  1064. $path=ECMS_PATH.'e/data/tmp/temp/uploadtg'.time().make_password(10).'.temp';
  1065. $cp=@move_uploaded_file($file,$path);
  1066. DoChmodFile($path);
  1067. $data=ReadFiletext($path);
  1068. DelFiletext($path);
  1069. //转码
  1070. if($add['ChangeChar'])
  1071. {
  1072. $data=LoadInTempChangeChar($add['tempchar'],$data);
  1073. }
  1074. if(empty($data))
  1075. {
  1076. printerror("EmptyLoadInTempGroup","");
  1077. }
  1078. //返回版本
  1079. $pageexp="<!---ecms.temp--->";
  1080. $checkpr=explode($pageexp,$data);
  1081. $tempverr=LoadInTGReturnVer($checkpr[0]);
  1082. $gname=$tempverr['gname'];
  1083. $thistempver=$tempverr['ver'];
  1084. $thistempchar=$tempverr['tempchar'];
  1085. //替换旧地址
  1086. $GLOBALS['loadtempver']=$thistempver;
  1087. if(empty($thistempver))
  1088. {
  1089. $data=LoadInTGReptext_pubvar($data);
  1090. }
  1091. //入库
  1092. $pageexp="<!---ecms.temp--->";
  1093. $record="<!---ecms.record--->";
  1094. $field="<!---ecms.field--->";
  1095. $pr=explode($pageexp,$data);
  1096. if(empty($gid))//新建模板组
  1097. {
  1098. $sql=$empire->query("insert into {$dbtbpre}enewstempgroup(gname,isdefault) values('".addslashes($gname)."',0);");
  1099. $gid=$empire->lastid();
  1100. $gname=$pr[0];
  1101. $en="_".$gid;
  1102. CreateTempTb($gid,$en);//复制表
  1103. }
  1104. else//覆盖模板组
  1105. {
  1106. $r=$empire->fetch1("select gid,gname from {$dbtbpre}enewstempgroup where gid=$gid");
  1107. if(!$r['gid'])
  1108. {
  1109. printerror("LoadInTempGroupMusttemp","");
  1110. }
  1111. if($gid==1)
  1112. {
  1113. $en="";
  1114. }
  1115. else
  1116. {
  1117. $en="_".$gid;
  1118. }
  1119. $gname=$r['gname'];
  1120. ClearTempTb($gid,$en);//清空表
  1121. }
  1122. //版本
  1123. $isold=0;
  1124. $ckcount=count($pr);
  1125. if($ckcount<=10)//5.1
  1126. {
  1127. $isold=1;
  1128. }
  1129. elseif($ckcount<=11)//6.0
  1130. {
  1131. $isold=2;
  1132. }
  1133. LoadInTGBqtemp($gid,$en,$record,$field,$pr[1]);//标签模板
  1134. LoadInTGJstemp($gid,$en,$record,$field,$pr[2]);//JS模板
  1135. LoadInTGListtemp($gid,$en,$record,$field,$pr[3]);//列表模板
  1136. LoadInTGNewstemp($gid,$en,$record,$field,$pr[4]);//内容模板
  1137. LoadInTGPubtemp($gid,$en,$record,$field,$pr[5],$isold);//公共模板
  1138. LoadInTGSearchtemp($gid,$en,$record,$field,$pr[6]);//搜索模板
  1139. LoadInTGTempvar($gid,$en,$record,$field,$pr[7]);//模板变量
  1140. LoadInTGVotetemp($gid,$en,$record,$field,$pr[8]);//投票模板
  1141. LoadInTGClasstemp($gid,$en,$record,$field,$pr[9]);//栏目模板
  1142. if($isold!=1)
  1143. {
  1144. LoadInTGPltemp($gid,$en,$record,$field,$pr[10]);//评论模板
  1145. }
  1146. if($isold==0)
  1147. {
  1148. LoadInTGPrinttemp($gid,$en,$record,$field,$pr[11]);//打印模板
  1149. }
  1150. LoadInTGPagetemp($gid,$en,$record,$field,$pr[12]);//自定义页面模板
  1151. //操作日志
  1152. insert_dolog("gid=$gid&gname=$gname");
  1153. printerror("LoadInTempGroupSuccess","TempGroup.php".hReturnEcmsHashStrHref2(1));
  1154. }
  1155. //替换模板组存放格式
  1156. function ReplaceLoadTGTemp($pageexp,$record,$field,$text){
  1157. $text=str_replace($pageexp,"",$text);
  1158. $text=str_replace($record,"",$text);
  1159. $text=str_replace($field,"",$text);
  1160. return $text;
  1161. }
  1162. //标签模板
  1163. function LoadTGBqtemp($gid,$en,$pageexp,$record,$field){
  1164. global $empire,$dbtbpre;
  1165. $tb=$dbtbpre."enewsbqtemp".$en;
  1166. $sql=$empire->query("select * from ".$tb." order by tempid");
  1167. $classid=0;
  1168. while($r=$empire->fetch($sql))
  1169. {
  1170. $r['temptext']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['temptext']);
  1171. $r['listvar']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['listvar']);
  1172. $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;
  1173. }
  1174. return $text;
  1175. }
  1176. function LoadInTGBqtemp($gid,$en,$record,$field,$text){
  1177. global $empire,$dbtbpre;
  1178. if(empty($text))
  1179. {
  1180. return "";
  1181. }
  1182. $tb=$dbtbpre."enewsbqtemp".$en;
  1183. $rr=explode($record,$text);
  1184. $count=count($rr);
  1185. for($i=0;$i<$count-1;$i++)
  1186. {
  1187. $r=explode($field,$rr[$i]);
  1188. $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(addslashes($r[3]))."','".addslashes($r[4])."','".addslashes(addslashes($r[5]))."','$r[6]','$r[7]','$r[8]','$r[9]');");
  1189. }
  1190. }
  1191. //JS模板
  1192. function LoadTGJstemp($gid,$en,$pageexp,$record,$field){
  1193. global $empire,$dbtbpre;
  1194. $tb=$dbtbpre."enewsjstemp".$en;
  1195. $sql=$empire->query("select * from ".$tb." order by tempid");
  1196. $classid=0;
  1197. while($r=$empire->fetch($sql))
  1198. {
  1199. $r['temptext']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['temptext']);
  1200. $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;
  1201. }
  1202. return $text;
  1203. }
  1204. function LoadInTGJstemp($gid,$en,$record,$field,$text){
  1205. global $empire,$dbtbpre;
  1206. if(empty($text))
  1207. {
  1208. return "";
  1209. }
  1210. $tb=$dbtbpre."enewsjstemp".$en;
  1211. $rr=explode($record,$text);
  1212. $count=count($rr);
  1213. for($i=0;$i<$count-1;$i++)
  1214. {
  1215. $r=explode($field,$rr[$i]);
  1216. if(empty($r[6]))
  1217. {
  1218. $r[6]=1;
  1219. }
  1220. $sql=$empire->query("insert into ".$tb."(tempid,tempname,temptext,classid,isdefault,showdate,modid,subnews,subtitle) values('$r[0]','".addslashes($r[1])."','".addslashes(addslashes($r[2]))."','$r[3]','$r[4]','".addslashes($r[5])."','$r[6]','$r[7]','$r[8]');");
  1221. }
  1222. }
  1223. //列表模板
  1224. function LoadTGListtemp($gid,$en,$pageexp,$record,$field){
  1225. global $empire,$dbtbpre;
  1226. $tb=$dbtbpre."enewslisttemp".$en;
  1227. $sql=$empire->query("select * from ".$tb." order by tempid");
  1228. $classid=0;
  1229. while($r=$empire->fetch($sql))
  1230. {
  1231. $r['temptext']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['temptext']);
  1232. $r['listvar']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['listvar']);
  1233. $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;
  1234. }
  1235. return $text;
  1236. }
  1237. function LoadInTGListtemp($gid,$en,$record,$field,$text){
  1238. global $empire,$dbtbpre;
  1239. if(empty($text))
  1240. {
  1241. return "";
  1242. }
  1243. $tb=$dbtbpre."enewslisttemp".$en;
  1244. $rr=explode($record,$text);
  1245. $count=count($rr);
  1246. for($i=0;$i<$count-1;$i++)
  1247. {
  1248. $r=explode($field,$rr[$i]);
  1249. $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(addslashes($r[2]))."','$r[3]','$r[4]','".addslashes(addslashes($r[5]))."','$r[6]','$r[7]','".addslashes($r[8])."','$r[9]','$r[10]','$r[11]');");
  1250. }
  1251. }
  1252. //内容模板
  1253. function LoadTGNewstemp($gid,$en,$pageexp,$record,$field){
  1254. global $empire,$dbtbpre;
  1255. $tb=$dbtbpre."enewsnewstemp".$en;
  1256. $sql=$empire->query("select * from ".$tb." order by tempid");
  1257. $classid=0;
  1258. while($r=$empire->fetch($sql))
  1259. {
  1260. $r['temptext']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['temptext']);
  1261. $text.=$r['tempid'].$field.$r['tempname'].$field.$r['isdefault'].$field.$r['temptext'].$field.$r['showdate'].$field.$r['modid'].$field.$classid.$record;
  1262. }
  1263. return $text;
  1264. }
  1265. function LoadInTGNewstemp($gid,$en,$record,$field,$text){
  1266. global $empire,$dbtbpre;
  1267. if(empty($text))
  1268. {
  1269. return "";
  1270. }
  1271. $text=RepTemplateJsUrl($text,1,0);//替换JS地址
  1272. $tb=$dbtbpre."enewsnewstemp".$en;
  1273. $rr=explode($record,$text);
  1274. $count=count($rr);
  1275. for($i=0;$i<$count-1;$i++)
  1276. {
  1277. $r=explode($field,$rr[$i]);
  1278. $sql=$empire->query("insert into ".$tb."(tempid,tempname,isdefault,temptext,showdate,modid,classid) values('$r[0]','".addslashes($r[1])."','$r[2]','".addslashes(addslashes($r[3]))."','".addslashes($r[4])."','$r[5]','$r[6]');");
  1279. }
  1280. }
  1281. //公共模板
  1282. function LoadTGPubtemp($gid,$en,$pageexp,$record,$field){
  1283. global $empire,$dbtbpre;
  1284. $tb=$dbtbpre."enewspubtemp".$en;
  1285. $r=$empire->fetch1("select * from ".$tb." limit 1");
  1286. $r['indextemp']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['indextemp']);
  1287. $r['cptemp']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['cptemp']);
  1288. $r['searchtemp']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['searchtemp']);
  1289. $r['searchjstemp']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['searchjstemp']);
  1290. $r['searchjstemp1']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['searchjstemp1']);
  1291. $r['otherlinktemp']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['otherlinktemp']);
  1292. $r['downsofttemp']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['downsofttemp']);
  1293. $r['onlinemovietemp']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['onlinemovietemp']);
  1294. $r['listpagetemp']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['listpagetemp']);
  1295. $r['gbooktemp']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['gbooktemp']);
  1296. $r['loginiframe']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['loginiframe']);
  1297. $r['loginjstemp']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['loginjstemp']);
  1298. $r['downpagetemp']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['downpagetemp']);
  1299. $r['pljstemp']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['pljstemp']);
  1300. $r['schalltemp']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['schalltemp']);
  1301. $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;
  1302. return $text;
  1303. }
  1304. function LoadInTGPubtemp($gid,$en,$record,$field,$text,$isold=0){
  1305. global $empire,$dbtbpre,$fun_r;
  1306. if(empty($text))
  1307. {
  1308. return "";
  1309. }
  1310. $tb=$dbtbpre."enewspubtemp".$en;
  1311. $rr=explode($record,$text);
  1312. $r=explode($field,$rr[0]);
  1313. //相关链接设置
  1314. if(empty($r[14]))
  1315. {
  1316. $r[14]=30;
  1317. }
  1318. if(empty($r[15]))
  1319. {
  1320. $r[15]='Y-m-d H:i:s';
  1321. }
  1322. if(empty($r[21]))
  1323. {
  1324. $r[21]='Y-m-d H:i:s';
  1325. }
  1326. //替换旧地址
  1327. if(empty($GLOBALS['loadtempver']))
  1328. {
  1329. //登录状态模板
  1330. $r[13]=LoadInTGReptext_othervar($r[13],'member');
  1331. $r[16]=LoadInTGReptext_othervar($r[16],'member');
  1332. //评论
  1333. $r[18]=LoadInTGReptext_othervar($r[18],'pl');
  1334. }
  1335. $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(addslashes($r[1]))."','".addslashes(addslashes($r[3]))."','".addslashes(addslashes($r[4]))."','".addslashes(addslashes($r[5]))."','".addslashes(addslashes($r[6]))."','".addslashes(addslashes($r[7]))."','".addslashes(addslashes($r[9]))."','".addslashes(addslashes($r[10]))."','".addslashes(addslashes($r[11]))."','".addslashes(addslashes($r[12]))."','".addslashes(addslashes($r[13]))."','$r[14]','$r[15]','".addslashes(addslashes($r[16]))."','".addslashes(addslashes($r[17]))."','".addslashes(addslashes($r[18]))."','".addslashes(addslashes($r[19]))."','$r[20]','$r[21]');");
  1336. //5.1以下版本
  1337. if($isold==1&&$r[2])
  1338. {
  1339. $pltb=$dbtbpre."enewspltemp".$en;
  1340. $pltempname=$fun_r['PlListTempname'];
  1341. //替换旧地址
  1342. if(empty($GLOBALS['loadtempver']))
  1343. {
  1344. $r[2]=LoadInTGReptext_othervar($r[2],'pl');
  1345. }
  1346. $empire->query("insert into ".$pltb."(tempid,tempname,temptext,isdefault) values(NULL,'".addslashes($pltempname)."','".addslashes(addslashes($r[2]))."',1);");
  1347. }
  1348. //6.0以下版本
  1349. if(($isold==1||$isold==2)&&$r[8])
  1350. {
  1351. $printtb=$dbtbpre."enewsprinttemp".$en;
  1352. $printtempname=$fun_r['PrintTempname'];
  1353. $empire->query("insert into ".$printtb."(tempid,tempname,temptext,isdefault,showdate,modid) values(NULL,'".addslashes($printtempname)."','".addslashes(addslashes($r[8]))."',1,'Y-m-d H:i:s',1);");
  1354. }
  1355. }
  1356. //搜索模板
  1357. function LoadTGSearchtemp($gid,$en,$pageexp,$record,$field){
  1358. global $empire,$dbtbpre;
  1359. $tb=$dbtbpre."enewssearchtemp".$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. $r['listvar']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['listvar']);
  1366. $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;
  1367. }
  1368. return $text;
  1369. }
  1370. function LoadInTGSearchtemp($gid,$en,$record,$field,$text){
  1371. global $empire,$dbtbpre;
  1372. if(empty($text))
  1373. {
  1374. return "";
  1375. }
  1376. $tb=$dbtbpre."enewssearchtemp".$en;
  1377. $rr=explode($record,$text);
  1378. $count=count($rr);
  1379. for($i=0;$i<$count-1;$i++)
  1380. {
  1381. $r=explode($field,$rr[$i]);
  1382. $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(addslashes($r[2]))."','$r[3]','$r[4]','".addslashes(addslashes($r[5]))."','$r[6]','$r[7]','".addslashes($r[8])."','$r[9]','$r[10]','$r[11]');");
  1383. }
  1384. }
  1385. //模板变量
  1386. function LoadTGTempvar($gid,$en,$pageexp,$record,$field){
  1387. global $empire,$dbtbpre;
  1388. $tb=$dbtbpre."enewstempvar".$en;
  1389. $sql=$empire->query("select * from ".$tb." order by varid");
  1390. $classid=0;
  1391. while($r=$empire->fetch($sql))
  1392. {
  1393. $r['varvalue']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['varvalue']);
  1394. $text.=$r['varid'].$field.$r['myvar'].$field.$r['varname'].$field.$r['varvalue'].$field.$classid.$field.$r['isclose'].$field.$r['myorder'].$record;
  1395. }
  1396. return $text;
  1397. }
  1398. function LoadInTGTempvar($gid,$en,$record,$field,$text){
  1399. global $empire,$dbtbpre;
  1400. if(empty($text))
  1401. {
  1402. return "";
  1403. }
  1404. $tb=$dbtbpre."enewstempvar".$en;
  1405. $rr=explode($record,$text);
  1406. $count=count($rr);
  1407. for($i=0;$i<$count-1;$i++)
  1408. {
  1409. $r=explode($field,$rr[$i]);
  1410. //评论变量
  1411. if(!$GLOBALS['loadtempver']&&$r[1]=='pl')
  1412. {
  1413. $r[3]=LoadInTGReptext_othervar($r[3],'pl');
  1414. }
  1415. $sql=$empire->query("insert into ".$tb."(varid,myvar,varname,varvalue,classid,isclose,myorder) values('$r[0]','".addslashes($r[1])."','".addslashes($r[2])."','".addslashes(addslashes($r[3]))."','$r[4]','$r[5]','$r[6]');");
  1416. }
  1417. }
  1418. //投票模板
  1419. function LoadTGVotetemp($gid,$en,$pageexp,$record,$field){
  1420. global $empire,$dbtbpre;
  1421. $tb=$dbtbpre."enewsvotetemp".$en;
  1422. $sql=$empire->query("select * from ".$tb." order by tempid");
  1423. $classid=0;
  1424. while($r=$empire->fetch($sql))
  1425. {
  1426. $r['temptext']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['temptext']);
  1427. $text.=$r['tempid'].$field.$r['tempname'].$field.$r['temptext'].$record;
  1428. }
  1429. return $text;
  1430. }
  1431. function LoadInTGVotetemp($gid,$en,$record,$field,$text){
  1432. global $empire,$dbtbpre;
  1433. if(empty($text))
  1434. {
  1435. return "";
  1436. }
  1437. $tb=$dbtbpre."enewsvotetemp".$en;
  1438. $rr=explode($record,$text);
  1439. $count=count($rr);
  1440. for($i=0;$i<$count-1;$i++)
  1441. {
  1442. $r=explode($field,$rr[$i]);
  1443. $sql=$empire->query("insert into ".$tb."(tempid,tempname,temptext) values('$r[0]','".addslashes($r[1])."','".addslashes(addslashes($r[2]))."');");
  1444. }
  1445. }
  1446. //栏目封面模板
  1447. function LoadTGClasstemp($gid,$en,$pageexp,$record,$field){
  1448. global $empire,$dbtbpre;
  1449. $tb=$dbtbpre."enewsclasstemp".$en;
  1450. $sql=$empire->query("select * from ".$tb." order by tempid");
  1451. $classid=0;
  1452. while($r=$empire->fetch($sql))
  1453. {
  1454. $r['temptext']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['temptext']);
  1455. $text.=$r['tempid'].$field.$r['tempname'].$field.$r['temptext'].$field.$classid.$record;
  1456. }
  1457. return $text;
  1458. }
  1459. function LoadInTGClasstemp($gid,$en,$record,$field,$text){
  1460. global $empire,$dbtbpre;
  1461. if(empty($text))
  1462. {
  1463. return "";
  1464. }
  1465. $tb=$dbtbpre."enewsclasstemp".$en;
  1466. $rr=explode($record,$text);
  1467. $count=count($rr);
  1468. for($i=0;$i<$count-1;$i++)
  1469. {
  1470. $r=explode($field,$rr[$i]);
  1471. $sql=$empire->query("insert into ".$tb."(tempid,tempname,temptext,classid) values('$r[0]','".addslashes($r[1])."','".addslashes(addslashes($r[2]))."','$r[3]');");
  1472. }
  1473. }
  1474. //评论列表模板
  1475. function LoadTGPltemp($gid,$en,$pageexp,$record,$field){
  1476. global $empire,$dbtbpre;
  1477. $tb=$dbtbpre."enewspltemp".$en;
  1478. $sql=$empire->query("select * from ".$tb." order by tempid");
  1479. while($r=$empire->fetch($sql))
  1480. {
  1481. $r['temptext']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['temptext']);
  1482. $text.=$r['tempid'].$field.$r['tempname'].$field.$r['temptext'].$field.$r['isdefault'].$record;
  1483. }
  1484. return $text;
  1485. }
  1486. function LoadInTGPltemp($gid,$en,$record,$field,$text){
  1487. global $empire,$dbtbpre;
  1488. if(empty($text))
  1489. {
  1490. return "";
  1491. }
  1492. $tb=$dbtbpre."enewspltemp".$en;
  1493. $rr=explode($record,$text);
  1494. $count=count($rr);
  1495. for($i=0;$i<$count-1;$i++)
  1496. {
  1497. $r=explode($field,$rr[$i]);
  1498. //替换旧地址
  1499. if(empty($GLOBALS['loadtempver']))
  1500. {
  1501. $r[2]=LoadInTGReptext_othervar($r[2],'pl');
  1502. }
  1503. $sql=$empire->query("insert into ".$tb."(tempid,tempname,temptext,isdefault) values('$r[0]','".addslashes($r[1])."','".addslashes(addslashes($r[2]))."','$r[3]');");
  1504. }
  1505. }
  1506. //打印模板
  1507. function LoadTGPrinttemp($gid,$en,$pageexp,$record,$field){
  1508. global $empire,$dbtbpre;
  1509. $tb=$dbtbpre."enewsprinttemp".$en;
  1510. $sql=$empire->query("select * from ".$tb." order by tempid");
  1511. while($r=$empire->fetch($sql))
  1512. {
  1513. $r['temptext']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['temptext']);
  1514. $text.=$r['tempid'].$field.$r['tempname'].$field.$r['temptext'].$field.$r['isdefault'].$field.$r['showdate'].$field.$r['modid'].$record;
  1515. }
  1516. return $text;
  1517. }
  1518. function LoadInTGPrinttemp($gid,$en,$record,$field,$text){
  1519. global $empire,$dbtbpre;
  1520. if(empty($text))
  1521. {
  1522. return "";
  1523. }
  1524. $tb=$dbtbpre."enewsprinttemp".$en;
  1525. $rr=explode($record,$text);
  1526. $count=count($rr);
  1527. for($i=0;$i<$count-1;$i++)
  1528. {
  1529. $r=explode($field,$rr[$i]);
  1530. $sql=$empire->query("insert into ".$tb."(tempid,tempname,temptext,isdefault,showdate,modid) values('$r[0]','".addslashes($r[1])."','".addslashes(addslashes($r[2]))."','$r[3]','".addslashes($r[4])."','$r[5]');");
  1531. }
  1532. }
  1533. //自定义页面模板
  1534. function LoadTGPagetemp($gid,$en,$pageexp,$record,$field){
  1535. global $empire,$dbtbpre;
  1536. $tb=$dbtbpre."enewspagetemp".$en;
  1537. $sql=$empire->query("select * from ".$tb." order by tempid");
  1538. $classid=0;
  1539. while($r=$empire->fetch($sql))
  1540. {
  1541. $r['temptext']=ReplaceLoadTGTemp($pageexp,$record,$field,$r['temptext']);
  1542. $text.=$r['tempid'].$field.$r['tempname'].$field.$r['temptext'].$record;
  1543. }
  1544. return $text;
  1545. }
  1546. function LoadInTGPagetemp($gid,$en,$record,$field,$text){
  1547. global $empire,$dbtbpre;
  1548. if(empty($text))
  1549. {
  1550. return "";
  1551. }
  1552. $tb=$dbtbpre."enewspagetemp".$en;
  1553. $rr=explode($record,$text);
  1554. $count=count($rr);
  1555. for($i=0;$i<$count-1;$i++)
  1556. {
  1557. $r=explode($field,$rr[$i]);
  1558. $sql=$empire->query("insert into ".$tb."(tempid,tempname,temptext) values('$r[0]','".addslashes($r[1])."','".addslashes(addslashes($r[2]))."');");
  1559. }
  1560. }
  1561. //----------------------备份模板-------------------
  1562. //删除多余备份记录
  1563. function DelEBakTemp($temptype,$gid,$tempid){
  1564. global $empire,$dbtbpre;
  1565. $pr=$empire->fetch1("select baktempnum from {$dbtbpre}enewspublic limit 1");
  1566. if(!$pr['baktempnum'])
  1567. {
  1568. return $pr;
  1569. }
  1570. $num=$empire->gettotal("select count(*) as total from {$dbtbpre}enewstempbak where temptype='$temptype' and gid='$gid' and tempid='$tempid'");
  1571. if($num+1>$pr['baktempnum'])
  1572. {
  1573. $limitnum=$num+1-$pr['baktempnum'];
  1574. $ids='';
  1575. $dh='';
  1576. $sql=$empire->query("select bid from {$dbtbpre}enewstempbak where temptype='$temptype' and gid='$gid' and tempid='$tempid' order by bid limit ".$limitnum);
  1577. while($r=$empire->fetch($sql))
  1578. {
  1579. $ids.=$dh.$r['bid'];
  1580. $dh=',';
  1581. }
  1582. $empire->query("delete from {$dbtbpre}enewstempbak where bid in ($ids)");
  1583. }
  1584. return $pr;
  1585. }
  1586. //删除所有备份记录
  1587. function DelEbakTempAll($temptype,$gid,$tempid){
  1588. global $empire,$dbtbpre;
  1589. $tempid=(int)$tempid;
  1590. $gid=(int)$gid;
  1591. if(!$gid)
  1592. {
  1593. $gid=GetDoTempGid();
  1594. }
  1595. if($temptype=='indexpage')
  1596. {
  1597. $gid=1;
  1598. }
  1599. $empire->query("delete from {$dbtbpre}enewstempbak where temptype='$temptype' and gid='$gid' and tempid='$tempid'");
  1600. }
  1601. //模板备份记录
  1602. function AddEBakTemp($temptype,$gid,$tempid,$tempname,$temptext,$subnews,$isdefault,$listvar,$rownum,$modid,$showdate,$subtitle,$classid,$docode,$userid,$username){
  1603. global $empire,$dbtbpre;
  1604. $tempid=(int)$tempid;
  1605. $gid=(int)$gid;
  1606. if(!$gid)
  1607. {
  1608. $gid=GetDoTempGid();
  1609. }
  1610. if($temptype=='indexpage')
  1611. {
  1612. $gid=1;
  1613. }
  1614. $pr=DelEBakTemp($temptype,$gid,$tempid);
  1615. if(!$pr['baktempnum'])
  1616. {
  1617. return '';
  1618. }
  1619. $subnews=(int)$subnews;
  1620. $isdefault=(int)$isdefault;
  1621. $rownum=(int)$rownum;
  1622. $modid=(int)$modid;
  1623. $subtitle=(int)$subtitle;
  1624. $classid=(int)$classid;
  1625. $docode=(int)$docode;
  1626. $baktime=time();
  1627. $empire->query("insert into {$dbtbpre}enewstempbak(tempid,tempname,temptext,subnews,isdefault,listvar,rownum,modid,showdate,subtitle,classid,docode,baktime,temptype,gid,lastuser) values('$tempid','".eaddslashes($tempname)."','".eaddslashes2($temptext)."','$subnews','$isdefault','".eaddslashes2($listvar)."','$rownum','$modid','".eaddslashes($showdate)."','$subtitle','$classid','$docode','$baktime','$temptype','$gid','$username');");
  1628. }
  1629. //还原模板备份
  1630. function ReEBakTemp($add,$userid,$username){
  1631. global $empire,$dbtbpre;
  1632. $bid=(int)$add['bid'];
  1633. if(!$bid)
  1634. {
  1635. printerror("NotBakTemp","history.go(-1)");
  1636. }
  1637. $r=$empire->fetch1("select * from {$dbtbpre}enewstempbak where bid='$bid'");
  1638. if(!$r['bid'])
  1639. {
  1640. printerror("NotBakTemp","history.go(-1)");
  1641. }
  1642. //操作权限
  1643. if($r['temptype']=='tempvar')
  1644. {
  1645. CheckLevel($userid,$username,$classid,"tempvar");
  1646. }
  1647. else
  1648. {
  1649. CheckLevel($userid,$username,$classid,"template");
  1650. }
  1651. $gid=(int)$r['gid'];
  1652. if(!$gid)
  1653. {
  1654. $gid=GetDoTempGid();
  1655. }
  1656. if($temptype=='indexpage')
  1657. {
  1658. $gid=1;
  1659. }
  1660. if($r['temptype']=='bqtemp')//标签模板
  1661. {
  1662. $sql=$empire->query("update ".GetDoTemptb("enewsbqtemp",$gid)." set tempname='".StripAddsData($r[tempname])."',temptext='".addslashes($r[temptext])."',modid='$r[modid]',showdate='".StripAddsData($r[showdate])."',listvar='".addslashes($r[listvar])."',subnews='$r[subnews]',rownum='$r[rownum]',classid='$r[classid]',docode='$r[docode]' where tempid='$r[tempid]'");
  1663. }
  1664. elseif($r['temptype']=='classtemp')//封面模板
  1665. {
  1666. $sql=$empire->query("update ".GetDoTemptb("enewsclasstemp",$gid)." set tempname='".StripAddsData($r[tempname])."',temptext='".addslashes($r[temptext])."',classid='$r[classid]' where tempid='$r[tempid]'");
  1667. }
  1668. elseif($r['temptype']=='jstemp')//JS模板
  1669. {
  1670. $sql=$empire->query("update ".GetDoTemptb("enewsjstemp",$gid)." set tempname='".StripAddsData($r[tempname])."',temptext='".addslashes($r[temptext])."',classid='$r[classid]',showdate='".StripAddsData($r[showdate])."',modid='$r[modid]',subnews='$r[subnews]',subtitle='$r[subtitle]' where tempid='$r[tempid]'");
  1671. }
  1672. elseif($r['temptype']=='listtemp')//列表模板
  1673. {
  1674. $sql=$empire->query("update ".GetDoTemptb("enewslisttemp",$gid)." set subnews='$r[subnews]',tempname='".StripAddsData($r[tempname])."',temptext='".addslashes($r[temptext])."',listvar='".addslashes($r[listvar])."',rownum='$r[rownum]',modid='$r[modid]',showdate='".StripAddsData($r[showdate])."',subtitle='$r[subtitle]',classid='$r[classid]',docode='$r[docode]' where tempid='$r[tempid]'");
  1675. }
  1676. elseif($r['temptype']=='newstemp')//内容模板
  1677. {
  1678. $sql=$empire->query("update ".GetDoTemptb("enewsnewstemp",$gid)." set tempname='".StripAddsData($r[tempname])."',temptext='".addslashes($r[temptext])."',showdate='".StripAddsData($r[showdate])."',modid='$r[modid]',classid='$r[classid]' where tempid='$r[tempid]'");
  1679. }
  1680. elseif($r['temptype']=='pltemp')//评论模板
  1681. {
  1682. $sql=$empire->query("update ".GetDoTemptb("enewspltemp",$gid)." set tempname='".StripAddsData($r[tempname])."',temptext='".addslashes($r[temptext])."' where tempid='$r[tempid]'");
  1683. }
  1684. elseif($r['temptype']=='printtemp')//打印模板
  1685. {
  1686. $sql=$empire->query("update ".GetDoTemptb("enewsprinttemp",$gid)." set tempname='".StripAddsData($r[tempname])."',temptext='".addslashes($r[temptext])."',showdate='".StripAddsData($r[showdate])."',modid='$r[modid]' where tempid='$r[tempid]'");
  1687. }
  1688. elseif($r['temptype']=='searchtemp')//搜索模板
  1689. {
  1690. $sql=$empire->query("update ".GetDoTemptb("enewssearchtemp",$gid)." set subnews='$r[subnews]',tempname='".StripAddsData($r[tempname])."',temptext='".addslashes($r[temptext])."',listvar='".addslashes($r[listvar])."',rownum='$r[rownum]',modid='$r[modid]',showdate='".StripAddsData($r[showdate])."',subtitle='$r[subtitle]',classid='$r[classid]',docode='$r[docode]' where tempid='$r[tempid]'");
  1691. }
  1692. elseif($r['temptype']=='tempvar')//公共模板变量
  1693. {
  1694. $sql=$empire->query("update ".GetDoTemptb("enewstempvar",$gid)." set myvar='".StripAddsData($r[tempname])."',varname='".StripAddsData($r[listvar])."',varvalue='".addslashes($r[temptext])."',classid='$r[classid]',isclose='$r[docode]',myorder='$r[subnews]' where varid='$r[tempid]'");
  1695. }
  1696. elseif($r['temptype']=='votetemp')//投票模板
  1697. {
  1698. $sql=$empire->query("update ".GetDoTemptb("enewsvotetemp",$gid)." set tempname='".StripAddsData($r[tempname])."',temptext='".addslashes($r[temptext])."' where tempid='$r[tempid]'");
  1699. }
  1700. elseif($r['temptype']=='pagetemp')//自定义页面模板
  1701. {
  1702. $sql=$empire->query("update ".GetDoTemptb("enewspagetemp",$gid)." set tempname='".StripAddsData($r[tempname])."',temptext='".addslashes($r[temptext])."' where tempid='$r[tempid]'");
  1703. }
  1704. elseif($r['temptype']=='indexpage')//首页方案模板
  1705. {
  1706. $sql=$empire->query("update {$dbtbpre}enewsindexpage set tempname='".StripAddsData($r[tempname])."',temptext='".addslashes($r[temptext])."' where tempid='$r[tempid]'");
  1707. }
  1708. //公共模板
  1709. elseif($r['temptype']=='pubindextemp')//首页模板
  1710. {
  1711. $sql=$empire->query("update ".GetDoTemptb("enewspubtemp",$gid)." set indextemp='".addslashes($r[temptext])."' limit 1");
  1712. }
  1713. elseif($r['temptype']=='pubcptemp')//控制面板模板
  1714. {
  1715. $sql=$empire->query("update ".GetDoTemptb("enewspubtemp",$gid)." set cptemp='".addslashes($r[temptext])."' limit 1");
  1716. }
  1717. elseif($r['temptype']=='pubsearchtemp')//高级搜索表单模板
  1718. {
  1719. $sql=$empire->query("update ".GetDoTemptb("enewspubtemp",$gid)." set searchtemp='".addslashes($r[temptext])."' limit 1");
  1720. }
  1721. elseif($r['temptype']=='pubsearchjstemp')//搜索JS模板[横向]
  1722. {
  1723. $sql=$empire->query("update ".GetDoTemptb("enewspubtemp",$gid)." set searchjstemp='".addslashes($r[temptext])."' limit 1");
  1724. }
  1725. elseif($r['temptype']=='pubsearchjstemp1')//搜索JS模板[纵向]
  1726. {
  1727. $sql=$empire->query("update ".GetDoTemptb("enewspubtemp",$gid)." set searchjstemp1='".addslashes($r[temptext])."' limit 1");
  1728. }
  1729. elseif($r['temptype']=='pubotherlinktemp')//相关链接模板
  1730. {
  1731. $sql=$empire->query("update ".GetDoTemptb("enewspubtemp",$gid)." set otherlinktemp='".addslashes($r[temptext])."',otherlinktempsub='$r[subtitle]',otherlinktempdate='".StripAddsData($r[showdate])."' limit 1");
  1732. }
  1733. elseif($r['temptype']=='pubdownsofttemp')//下载地址模板
  1734. {
  1735. $sql=$empire->query("update ".GetDoTemptb("enewspubtemp",$gid)." set downsofttemp='".addslashes($r[temptext])."' limit 1");
  1736. }
  1737. elseif($r['temptype']=='pubonlinemovietemp')//在线播放地址模板
  1738. {
  1739. $sql=$empire->query("update ".GetDoTemptb("enewspubtemp",$gid)." set onlinemovietemp='".addslashes($r[temptext])."' limit 1");
  1740. }
  1741. elseif($r['temptype']=='publistpagetemp')//列表分页模板
  1742. {
  1743. $sql=$empire->query("update ".GetDoTemptb("enewspubtemp",$gid)." set listpagetemp='".addslashes($r[temptext])."' limit 1");
  1744. }
  1745. elseif($r['temptype']=='pubpljstemp')//评论JS调用模板
  1746. {
  1747. $sql=$empire->query("update ".GetDoTemptb("enewspubtemp",$gid)." set pljstemp='".addslashes($r[temptext])."' limit 1");
  1748. }
  1749. elseif($r['temptype']=='pubdownpagetemp')//最终下载页模板
  1750. {
  1751. $sql=$empire->query("update ".GetDoTemptb("enewspubtemp",$gid)." set downpagetemp='".addslashes($r[temptext])."' limit 1");
  1752. }
  1753. elseif($r['temptype']=='pubgbooktemp')//留言板模板
  1754. {
  1755. $sql=$empire->query("update ".GetDoTemptb("enewspubtemp",$gid)." set gbooktemp='".addslashes($r[temptext])."' limit 1");
  1756. }
  1757. elseif($r['temptype']=='publoginiframe')//登陆状态模板
  1758. {
  1759. $sql=$empire->query("update ".GetDoTemptb("enewspubtemp",$gid)." set loginiframe='".addslashes($r[temptext])."' limit 1");
  1760. }
  1761. elseif($r['temptype']=='publoginjstemp')//JS调用登陆状态模板
  1762. {
  1763. $sql=$empire->query("update ".GetDoTemptb("enewspubtemp",$gid)." set loginjstemp='".addslashes($r[temptext])."' limit 1");
  1764. }
  1765. elseif($r['temptype']=='pubschalltemp')//全站搜索模板
  1766. {
  1767. $sql=$empire->query("update ".GetDoTemptb("enewspubtemp",$gid)." set schalltemp='".addslashes($r[temptext])."',schallsubnum='$r[subnews]',schalldate='".StripAddsData($r[showdate])."' limit 1");
  1768. }
  1769. if($sql)
  1770. {
  1771. //操作日志
  1772. insert_dolog("bid=$bid&temptype=$r[temptype]<br>tempid=$r[tempid]&tempname=$r[tempname]&gid=$r[gid]");
  1773. echo"<script>opener.ReTempBak();window.close();</script>";
  1774. exit();
  1775. }
  1776. else
  1777. {printerror("DbError","history.go(-1)");}
  1778. }
  1779. ?>