ListTempvar.php 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <?php
  2. define('EmpireCMSAdmin','1');
  3. require("../../class/connect.php");
  4. require("../../class/db_sql.php");
  5. require("../../class/functions.php");
  6. require "../".LoadLang("pub/fun.php");
  7. $link=db_connect();
  8. $empire=new mysqlquery();
  9. $editor=1;
  10. //验证用户
  11. $lur=is_login();
  12. $logininid=$lur['userid'];
  13. $loginin=$lur['username'];
  14. $loginrnd=$lur['rnd'];
  15. $loginlevel=$lur['groupid'];
  16. $loginadminstyleid=$lur['adminstyleid'];
  17. //ehash
  18. $ecms_hashur=hReturnEcmsHashStrAll();
  19. //验证权限
  20. CheckLevel($logininid,$loginin,$classid,"tempvar");
  21. //增加模板全局变量
  22. function AddTempvar($add,$userid,$username){
  23. global $empire,$dbtbpre;
  24. if(!$add[myvar]||!$add[varvalue]||!$add[varname])
  25. {printerror("EmptyTempvar","history.go(-1)");}
  26. //验证权限
  27. CheckLevel($userid,$username,$classid,"tempvar");
  28. $add[myvar]=hRepPostStr($add[myvar],1);
  29. $add[varname]=hRepPostStr($add[varname],1);
  30. $classid=(int)$add[classid];
  31. $isclose=(int)$add[isclose];
  32. $add[myorder]=(int)$add[myorder];
  33. $add[varvalue]=RepPhpAspJspcode($add[varvalue]);
  34. $gid=(int)$add['gid'];
  35. $sql=$empire->query("insert into ".GetDoTemptb("enewstempvar",$gid)."(myvar,varname,varvalue,classid,isclose,myorder) values('$add[myvar]','$add[varname]','".eaddslashes2($add[varvalue])."',".$classid.",".$isclose.",$add[myorder]);");
  36. $lastid=$empire->lastid();
  37. //备份模板
  38. AddEBakTemp('tempvar',$gid,$lastid,$add[myvar],$add[varvalue],$add[myorder],0,$add[varname],0,0,'',0,$classid,$isclose,$userid,$username);
  39. if($sql)
  40. {
  41. //操作日志
  42. insert_dolog("varid=".$lastid."<br>var=".$add[myvar]."&gid=$gid");
  43. printerror("AddTempvarSuccess","AddTempvar.php?enews=AddTempvar&gid=$gid".hReturnEcmsHashStrHref2(0));
  44. }
  45. else
  46. {printerror("DbError","history.go(-1)");}
  47. }
  48. //修改模板变量
  49. function EditTempvar($add,$userid,$username){
  50. global $empire,$dbtbpre;
  51. $add[varid]=(int)$add['varid'];
  52. if(!$add[varid]||!$add[myvar]||!$add[varvalue]||!$add[varname])
  53. {printerror("EmptyTempvar","history.go(-1)");}
  54. //验证权限
  55. CheckLevel($userid,$username,$classid,"tempvar");
  56. $add[myvar]=hRepPostStr($add[myvar],1);
  57. $add[varname]=hRepPostStr($add[varname],1);
  58. $add[varvalue]=RepPhpAspJspcode($add[varvalue]);
  59. $classid=(int)$add[classid];
  60. $isclose=(int)$add[isclose];
  61. $add[myorder]=(int)$add[myorder];
  62. $gid=(int)$add['gid'];
  63. $sql=$empire->query("update ".GetDoTemptb("enewstempvar",$gid)." set myvar='$add[myvar]',varname='$add[varname]',varvalue='".eaddslashes2($add[varvalue])."',classid=$classid,isclose=$isclose,myorder=$add[myorder] where varid='$add[varid]'");
  64. //备份模板
  65. AddEBakTemp('tempvar',$gid,$add[varid],$add[myvar],$add[varvalue],$add[myorder],0,$add[varname],0,0,'',0,$classid,$isclose,$userid,$username);
  66. if($sql)
  67. {
  68. //操作日志
  69. insert_dolog("varid=".$add[varid]."<br>var=".$add[myvar]."&gid=$gid");
  70. printerror("EditTempvarSuccess","ListTempvar.php?classid=$add[cid]&gid=$gid".hReturnEcmsHashStrHref2(0));
  71. }
  72. else
  73. {printerror("DbError","history.go(-1)");}
  74. }
  75. //删除模板变量
  76. function DelTempvar($varid,$cid,$userid,$username){
  77. global $empire,$dbtbpre;
  78. $varid=(int)$varid;
  79. if(!$varid)
  80. {printerror("NotDelTempvarid","history.go(-1)");}
  81. //验证权限
  82. CheckLevel($userid,$username,$classid,"tempvar");
  83. $gid=(int)$_GET['gid'];
  84. $r=$empire->fetch1("select myvar from ".GetDoTemptb("enewstempvar",$gid)." where varid='$varid'");
  85. $sql=$empire->query("delete from ".GetDoTemptb("enewstempvar",$gid)." where varid='$varid'");
  86. //删除备份记录
  87. DelEbakTempAll('tempvar',$gid,$varid);
  88. if($sql)
  89. {
  90. //操作日志
  91. insert_dolog("varid=".$varid."<br>var=".$r[myvar]."&gid=$gid");
  92. printerror("DelTempvarSuccess","ListTempvar.php?classid=$cid&gid=$gid".hReturnEcmsHashStrHref2(0));
  93. }
  94. else
  95. {printerror("DbError","history.go(-1)");}
  96. }
  97. $enews=$_POST['enews'];
  98. if(empty($enews))
  99. {$enews=$_GET['enews'];}
  100. if($enews)
  101. {
  102. hCheckEcmsRHash();
  103. include("../../class/tempfun.php");
  104. }
  105. //增加模板变量
  106. if($enews=="AddTempvar")
  107. {
  108. $add=$_POST;
  109. AddTempvar($add,$logininid,$loginin);
  110. }
  111. //修改模板变量
  112. elseif($enews=="EditTempvar")
  113. {
  114. $add=$_POST;
  115. EditTempvar($add,$logininid,$loginin);
  116. }
  117. //删除模板变量
  118. elseif($enews=="DelTempvar")
  119. {
  120. $varid=$_GET['varid'];
  121. $cid=$_GET['cid'];
  122. DelTempvar($varid,$cid,$logininid,$loginin);
  123. }
  124. $gid=(int)$_GET['gid'];
  125. $gname=CheckTempGroup($gid);
  126. $urlgname=$gname."&nbsp;>&nbsp;";
  127. $search="&gid=$gid".$ecms_hashur['ehref'];
  128. $page=(int)$_GET['page'];
  129. $page=RepPIntvar($page);
  130. $start=0;
  131. $line=25;//每页显示条数
  132. $page_line=12;//每页显示链接数
  133. $offset=$page*$line;//总偏移量
  134. $query="select varid,myvar,varvalue,varname,isclose from ".GetDoTemptb("enewstempvar",$gid);
  135. $totalquery="select count(*) as total from ".GetDoTemptb("enewstempvar",$gid);
  136. //类别
  137. $add="";
  138. $classid=(int)$_GET['classid'];
  139. if($classid)
  140. {
  141. $add=" where classid=$classid";
  142. $search.="&classid=$classid";
  143. }
  144. $query.=$add;
  145. $totalquery.=$add;
  146. $num=$empire->gettotal($totalquery);//取得总条数
  147. $query=$query." order by varid desc limit $offset,$line";
  148. $sql=$empire->query($query);
  149. $returnpage=page2($num,$line,$page_line,$start,$page,$search);
  150. //类别
  151. $cstr="";
  152. $csql=$empire->query("select classid,classname from {$dbtbpre}enewstempvarclass order by classid");
  153. while($cr=$empire->fetch($csql))
  154. {
  155. $select="";
  156. if($cr[classid]==$classid)
  157. {
  158. $select=" selected";
  159. }
  160. $cstr.="<option value='".$cr[classid]."'".$select.">".$cr[classname]."</option>";
  161. }
  162. ?>
  163. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  164. <html>
  165. <head>
  166. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  167. <link href="../adminstyle/<?=$loginadminstyleid?>/adminstyle.css" rel="stylesheet" type="text/css">
  168. <title>管理模板变量</title>
  169. </head>
  170. <body>
  171. <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
  172. <tr>
  173. <td width="50%" height="25">位置:
  174. <?=$urlgname?>
  175. <a href="ListTempvar.php?gid=<?=$gid?><?=$ecms_hashur['ehref']?>">管理模板变量</a></td>
  176. <td><div align="right" class="emenubutton">
  177. <input type="button" name="Submit5" value="增加模板变量" onclick="self.location.href='AddTempvar.php?enews=AddTempvar&gid=<?=$gid?><?=$ecms_hashur['ehref']?>';">
  178. &nbsp;&nbsp;
  179. <input type="button" name="Submit5" value="管理模板变量分类" onclick="self.location.href='TempvarClass.php?gid=<?=$gid?><?=$ecms_hashur['ehref']?>';">
  180. </div></td>
  181. </tr>
  182. </table>
  183. <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
  184. <tr>
  185. <td> 选择类别:
  186. <select name="classid" id="classid" onchange=window.location='ListTempvar.php?<?=$ecms_hashur['ehref']?>&gid=<?=$gid?>&classid='+this.options[this.selectedIndex].value>
  187. <option value="0">显示所有类别</option>
  188. <?=$cstr?>
  189. </select>
  190. </td>
  191. </tr>
  192. </table><br>
  193. <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
  194. <tr class="header">
  195. <td width="6%" height="25"> <div align="center">ID</div></td>
  196. <td width="28%" height="25"> <div align="center">变量标识</div></td>
  197. <td width="33%" height="25"> <div align="center">模板变量名</div></td>
  198. <td width="15%"><div align="center">开启</div></td>
  199. <td width="18%" height="25"> <div align="center">操作</div></td>
  200. </tr>
  201. <?
  202. while($r=$empire->fetch($sql))
  203. {
  204. //开启
  205. if($r[isclose])
  206. {
  207. $isclose="<font color=red>关闭</font>";
  208. }
  209. else
  210. {
  211. $isclose="开启";
  212. }
  213. ?>
  214. <tr bgcolor="#FFFFFF" onmouseout="this.style.backgroundColor='#ffffff'" onmouseover="this.style.backgroundColor='#C3EFFF'">
  215. <td height="25"> <div align="center">
  216. <a href="EditTempid.php?tempno=7&tempid=<?=$r['varid']?>&gid=<?=$gid?><?=$ecms_hashur['ehref']?>" target="_blank" title="修改模板ID"><?=$r[varid]?></a>
  217. </div></td>
  218. <td height="25"> <div align="center">
  219. <?=$r[varname]?>
  220. </div></td>
  221. <td height="25"> <div align="center">
  222. <input name=text1 type=text value="[!--temp.<?=$r[myvar]?>--]" size="32">
  223. </div></td>
  224. <td><div align="center"><?=$isclose?></div></td>
  225. <td height="25"> <div align="center">[<a href="AddTempvar.php?enews=EditTempvar&varid=<?=$r[varid]?>&cid=<?=$classid?>&gid=<?=$gid?><?=$ecms_hashur['ehref']?>">修改</a>]&nbsp;[<a href="ListTempvar.php?enews=DelTempvar&varid=<?=$r[varid]?>&cid=<?=$classid?>&gid=<?=$gid?><?=$ecms_hashur['href']?>" onclick="return confirm('确认要删除?');">删除</a>]</div></td>
  226. </tr>
  227. <?
  228. }
  229. ?>
  230. <tr bgcolor="#FFFFFF">
  231. <td height="25" colspan="5">&nbsp;&nbsp;&nbsp;
  232. <?=$returnpage?>
  233. </td>
  234. </tr>
  235. </table>
  236. </body>
  237. </html>
  238. <?
  239. db_close();
  240. $empire=null;
  241. ?>