ListPubVar.php 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  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,"pubvar");
  21. //增加变量
  22. function AddPubVar($add,$userid,$username){
  23. global $empire,$dbtbpre;
  24. $add[myvar]=RepPostVar($add[myvar]);
  25. if(!$add[myvar]||!$add[varname])
  26. {
  27. printerror("EmptyPubVar","history.go(-1)");
  28. }
  29. //验证权限
  30. CheckLevel($userid,$username,$classid,"pubvar");
  31. //验证重复
  32. $num=$empire->gettotal("select count(*) as total from {$dbtbpre}enewspubvar where myvar='$add[myvar]' limit 1");
  33. if($num)
  34. {
  35. printerror("RePubVar","history.go(-1)");
  36. }
  37. $add['varname']=hRepPostStr($add['varname'],1);
  38. $add['varsay']=hRepPostStr($add['varsay'],1);
  39. $classid=(int)$add[classid];
  40. $tocache=(int)$add[tocache];
  41. $add[myorder]=(int)$add[myorder];
  42. $add[varvalue]=AddAddsData(RepPhpAspJspcode($add[varvalue]));
  43. $sql=$empire->query("insert into {$dbtbpre}enewspubvar(myvar,varname,varvalue,varsay,myorder,classid,tocache) values('$add[myvar]','$add[varname]','".$add[varvalue]."','$add[varsay]','$add[myorder]','$classid','$tocache');");
  44. $lastid=$empire->lastid();
  45. if($tocache)
  46. {
  47. GetConfig();
  48. }
  49. if($sql)
  50. {
  51. //操作日志
  52. insert_dolog("varid=".$lastid."<br>var=".$add[myvar]);
  53. printerror("AddPubVarSuccess","AddPubVar.php?enews=AddPubVar".hReturnEcmsHashStrHref2(0));
  54. }
  55. else
  56. {printerror("DbError","history.go(-1)");}
  57. }
  58. //修改变量
  59. function EditPubVar($add,$userid,$username){
  60. global $empire,$dbtbpre;
  61. $add[varid]=(int)$add['varid'];
  62. $add[myvar]=RepPostVar($add[myvar]);
  63. if(!$add[varid]||!$add[myvar]||!$add[varname])
  64. {
  65. printerror("EmptyPubVar","history.go(-1)");
  66. }
  67. //验证权限
  68. CheckLevel($userid,$username,$classid,"pubvar");
  69. if($add[myvar]!=$add[oldmyvar])
  70. {
  71. $num=$empire->gettotal("select count(*) as total from {$dbtbpre}enewspubvar where myvar='$add[myvar]' and varid<>$add[varid] limit 1");
  72. if($num)
  73. {
  74. printerror("RePubVar","history.go(-1)");
  75. }
  76. }
  77. $add['varname']=hRepPostStr($add['varname'],1);
  78. $add['varsay']=hRepPostStr($add['varsay'],1);
  79. $add[varvalue]=AddAddsData(RepPhpAspJspcode($add[varvalue]));
  80. $classid=(int)$add[classid];
  81. $tocache=(int)$add[tocache];
  82. $add[myorder]=(int)$add[myorder];
  83. $sql=$empire->query("update {$dbtbpre}enewspubvar set myvar='$add[myvar]',varname='$add[varname]',varvalue='".$add[varvalue]."',varsay='$add[varsay]',myorder='$add[myorder]',classid='$classid',tocache='$tocache' where varid='$add[varid]'");
  84. if($tocache||$add['oldtocache'])
  85. {
  86. GetConfig();
  87. }
  88. if($sql)
  89. {
  90. //操作日志
  91. insert_dolog("varid=".$add[varid]."<br>var=".$add[myvar]);
  92. printerror("EditPubVarSuccess","ListPubVar.php?classid=$add[cid]".hReturnEcmsHashStrHref2(0));
  93. }
  94. else
  95. {printerror("DbError","history.go(-1)");}
  96. }
  97. //删除变量
  98. function DelPubVar($varid,$cid,$userid,$username){
  99. global $empire,$dbtbpre;
  100. $varid=(int)$varid;
  101. if(!$varid)
  102. {
  103. printerror("NotDelPubVarid","history.go(-1)");
  104. }
  105. //验证权限
  106. CheckLevel($userid,$username,$classid,"pubvar");
  107. $r=$empire->fetch1("select myvar,tocache from {$dbtbpre}enewspubvar where varid='$varid'");
  108. $sql=$empire->query("delete from {$dbtbpre}enewspubvar where varid='$varid'");
  109. if($r['tocache'])
  110. {
  111. GetConfig();
  112. }
  113. if($sql)
  114. {
  115. //操作日志
  116. insert_dolog("varid=".$varid."<br>var=".$r[myvar]);
  117. printerror("DelPubVarSuccess","ListPubVar.php?classid=$cid".hReturnEcmsHashStrHref2(0));
  118. }
  119. else
  120. {printerror("DbError","history.go(-1)");}
  121. }
  122. $enews=$_POST['enews'];
  123. if(empty($enews))
  124. {$enews=$_GET['enews'];}
  125. if($enews)
  126. {
  127. hCheckEcmsRHash();
  128. }
  129. //增加变量
  130. if($enews=="AddPubVar")
  131. {
  132. $add=$_POST;
  133. AddPubVar($add,$logininid,$loginin);
  134. }
  135. //修改变量
  136. elseif($enews=="EditPubVar")
  137. {
  138. $add=$_POST;
  139. EditPubVar($add,$logininid,$loginin);
  140. }
  141. //删除变量
  142. elseif($enews=="DelPubVar")
  143. {
  144. $varid=$_GET['varid'];
  145. $cid=$_GET['cid'];
  146. DelPubVar($varid,$cid,$logininid,$loginin);
  147. }
  148. $search='';
  149. $search.=$ecms_hashur['ehref'];
  150. $page=(int)$_GET['page'];
  151. $page=RepPIntvar($page);
  152. $start=0;
  153. $line=30;//每页显示条数
  154. $page_line=12;//每页显示链接数
  155. $offset=$page*$line;//总偏移量
  156. $query="select varid,myvar,varvalue,varname,tocache,classid from {$dbtbpre}enewspubvar";
  157. $totalquery="select count(*) as total from {$dbtbpre}enewspubvar";
  158. //分类
  159. $add='';
  160. $classid=(int)$_GET['classid'];
  161. if($classid)
  162. {
  163. $add=" where classid='$classid'";
  164. $search.="&classid=$classid";
  165. }
  166. $query.=$add;
  167. $totalquery.=$add;
  168. $num=$empire->gettotal($totalquery);//取得总条数
  169. $query=$query." order by myorder,varid desc limit $offset,$line";
  170. $sql=$empire->query($query);
  171. $returnpage=page2($num,$line,$page_line,$start,$page,$search);
  172. //分类
  173. $cstr="";
  174. $csql=$empire->query("select classid,classname from {$dbtbpre}enewspubvarclass order by classid");
  175. while($cr=$empire->fetch($csql))
  176. {
  177. $select="";
  178. if($cr[classid]==$classid)
  179. {
  180. $select=" selected";
  181. }
  182. $cstr.="<option value='".$cr[classid]."'".$select.">".$cr[classname]."</option>";
  183. }
  184. ?>
  185. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  186. <html>
  187. <head>
  188. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  189. <link href="../adminstyle/<?=$loginadminstyleid?>/adminstyle.css" rel="stylesheet" type="text/css">
  190. <title>管理扩展变量</title>
  191. </head>
  192. <body>
  193. <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
  194. <tr>
  195. <td width="50%" height="25">位置: <a href="ListPubVar.php<?=$ecms_hashur['whehref']?>">管理扩展变量</a></td>
  196. <td><div align="right" class="emenubutton">
  197. <input type="button" name="Submit5" value="增加扩展变量" onclick="self.location.href='AddPubVar.php?enews=AddPubVar<?=$ecms_hashur['ehref']?>';">
  198. &nbsp;&nbsp;
  199. <input type="button" name="Submit5" value="管理扩展变量分类" onclick="self.location.href='PubVarClass.php<?=$ecms_hashur['whehref']?>';">
  200. </div></td>
  201. </tr>
  202. </table>
  203. <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
  204. <tr>
  205. <td> 选择分类:
  206. <select name="classid" id="classid" onchange=window.location='ListPubVar.php?<?=$ecms_hashur['ehref']?>&classid='+this.options[this.selectedIndex].value>
  207. <option value="0">显示所有分类</option>
  208. <?=$cstr?>
  209. </select>
  210. </td>
  211. </tr>
  212. </table><br>
  213. <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
  214. <tr class="header">
  215. <td width="5%" height="25"> <div align="center">ID</div></td>
  216. <td width="28%" height="25"> <div align="center">变量名</div></td>
  217. <td width="28%" height="25"> <div align="center">变量标识</div></td>
  218. <td width="17%"><div align="center">所属分类</div></td>
  219. <td width="8%"><div align="center">写入缓存</div></td>
  220. <td width="14%" height="25"> <div align="center">操作</div></td>
  221. </tr>
  222. <?php
  223. while($r=$empire->fetch($sql))
  224. {
  225. //分类
  226. $cname='未分类';
  227. if($r['classid'])
  228. {
  229. $lcr=$empire->fetch1("select classname from {$dbtbpre}enewspubvarclass where classid='$r[classid]'");
  230. $cname='<a href="ListPubVar.php?classid='.$r[classid].$ecms_hashur['ehref'].'">'.$lcr[classname].'</a>';
  231. }
  232. if($r[tocache])
  233. {
  234. $tocache='<font color=red>写入</font>';
  235. }
  236. else
  237. {
  238. $tocache='不写入';
  239. }
  240. ?>
  241. <tr bgcolor="#FFFFFF" onmouseout="this.style.backgroundColor='#ffffff'" onmouseover="this.style.backgroundColor='#C3EFFF'">
  242. <td height="25"> <div align="center">
  243. <?=$r[varid]?>
  244. </div></td>
  245. <td height="25"> <div align="center">
  246. <?=$r[myvar]?>
  247. </div></td>
  248. <td height="25"> <div align="center">
  249. <?=$r[varname]?>
  250. </div></td>
  251. <td><div align="center"><?=$cname?></div></td>
  252. <td><div align="center">
  253. <?=$tocache?>
  254. </div></td>
  255. <td height="25"> <div align="center">[<a href="AddPubVar.php?enews=EditPubVar&varid=<?=$r[varid]?>&cid=<?=$classid?><?=$ecms_hashur['ehref']?>">修改</a>]&nbsp;[<a href="ListPubVar.php?enews=DelPubVar&varid=<?=$r[varid]?>&cid=<?=$classid?><?=$ecms_hashur['href']?>" onclick="return confirm('确认要删除?');">删除</a>]</div></td>
  256. </tr>
  257. <?php
  258. }
  259. ?>
  260. <tr bgcolor="#FFFFFF">
  261. <td height="25" colspan="6">&nbsp;&nbsp;&nbsp;
  262. <?=$returnpage?>
  263. </td>
  264. </tr>
  265. </table>
  266. <br>
  267. <br>
  268. <table width="100%" border="0" cellspacing="1" cellpadding="3" class="tableborder">
  269. <tr class="header">
  270. <td height="25">扩展变量调用说明</td>
  271. </tr>
  272. <tr>
  273. <td height="25" bgcolor="#FFFFFF">
  274. <table width="100%" border="0" cellspacing="1" cellpadding="3">
  275. <tr>
  276. <td><strong>1、写入缓存的变量调用</strong></td>
  277. </tr>
  278. <tr>
  279. <td height="30" valign="top">在任意php或模板中用$public_r['add_变量名']可取得变量内容。</td>
  280. </tr>
  281. <tr>
  282. <td><strong>2、没有写入缓存的变量调用</strong></td>
  283. </tr>
  284. <tr>
  285. <td valign="top">可以用内置变量返回函数(数据库读取变量内容):ReturnPublicAddVar(变量名)。取多个变量内容可用逗号隔开,例子:<br>
  286. 取得单变量内容:$value=ReturnPublicAddVar('myvar'); //$value就是变量内容。<br>
  287. 取得多个变量内容:$value=ReturnPublicAddVar('myvar1,myvar2,myvar3'); //$value['myvar1']才是变量内容。</td>
  288. </tr>
  289. </table></td>
  290. </tr>
  291. </table>
  292. </body>
  293. </html>
  294. <?php
  295. db_close();
  296. $empire=null;
  297. ?>