key.php 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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,"key");
  21. //增加关键字
  22. function AddKey($keyname,$keyurl,$userid,$username){
  23. global $empire,$dbtbpre;
  24. $cid=(int)$_POST['cid'];
  25. $fcid=(int)$_POST['fcid'];
  26. if(!$keyname||!$keyurl)
  27. {printerror("EmptyKeyname","history.go(-1)");}
  28. //验证权限
  29. CheckLevel($userid,$username,$classid,"key");
  30. $keyname=hRepPostStr($keyname,1);
  31. $keyurl=hRepPostStr($keyurl,1);
  32. $sql=$empire->query("insert into {$dbtbpre}enewskey(keyname,keyurl,cid) values('$keyname','$keyurl','$cid');");
  33. $keyid=$empire->lastid();
  34. GetConfig();//更新缓存
  35. if($sql)
  36. {
  37. //操作日志
  38. insert_dolog("keyid=".$keyid."<br>keyname=".$keyname);
  39. printerror("AddKeySuccess","key.php?fcid=$fcid".hReturnEcmsHashStrHref2(0));
  40. }
  41. else
  42. {printerror("DbError","history.go(-1)");}
  43. }
  44. //修改关键字
  45. function EditKey($keyid,$keyname,$keyurl,$userid,$username){
  46. global $empire,$dbtbpre;
  47. $cid=(int)$_POST['cid'];
  48. $fcid=(int)$_POST['fcid'];
  49. if(!$keyname||!$keyurl||!$keyid)
  50. {printerror("EmptyKeyname","history.go(-1)");}
  51. //验证权限
  52. CheckLevel($userid,$username,$classid,"key");
  53. $keyid=(int)$keyid;
  54. $keyname=hRepPostStr($keyname,1);
  55. $keyurl=hRepPostStr($keyurl,1);
  56. $sql=$empire->query("update {$dbtbpre}enewskey set keyname='$keyname',keyurl='$keyurl',cid='$cid' where keyid='$keyid'");
  57. GetConfig();//更新缓存
  58. if($sql)
  59. {
  60. //操作日志
  61. insert_dolog("keyid=".$keyid."<br>keyname=".$keyname);
  62. printerror("EditKeySuccess","key.php?fcid=$fcid".hReturnEcmsHashStrHref2(0));
  63. }
  64. else
  65. {printerror("DbError","history.go(-1)");}
  66. }
  67. //删除关键字
  68. function DelKey($keyid,$userid,$username){
  69. global $empire,$dbtbpre;
  70. $fcid=(int)$_GET['fcid'];
  71. $keyid=(int)$keyid;
  72. if(!$keyid)
  73. {printerror("NotDelKeyid","history.go(-1)");}
  74. //验证权限
  75. CheckLevel($userid,$username,$classid,"key");
  76. $r=$empire->fetch1("select keyname from {$dbtbpre}enewskey where keyid='$keyid'");
  77. $sql=$empire->query("delete from {$dbtbpre}enewskey where keyid='$keyid'");
  78. GetConfig();//更新缓存
  79. if($sql)
  80. {
  81. //操作日志
  82. insert_dolog("keyid=".$keyid."<br>keyname=".$r[keyname]);
  83. printerror("DelKeySuccess","key.php?fcid=$fcid".hReturnEcmsHashStrHref2(0));
  84. }
  85. else
  86. {printerror("DbError","history.go(-1)");}
  87. }
  88. $enews=$_POST['enews'];
  89. if(empty($enews))
  90. {$enews=$_GET['enews'];}
  91. if($enews)
  92. {
  93. hCheckEcmsRHash();
  94. }
  95. //增加关键字
  96. if($enews=="AddKey")
  97. {
  98. $keyname=$_POST['keyname'];
  99. $keyurl=$_POST['keyurl'];
  100. AddKey($keyname,$keyurl,$logininid,$loginin);
  101. }
  102. //修改关键字
  103. elseif($enews=="EditKey")
  104. {
  105. $keyid=$_POST['keyid'];
  106. $keyname=$_POST['keyname'];
  107. $keyurl=$_POST['keyurl'];
  108. EditKey($keyid,$keyname,$keyurl,$logininid,$loginin);
  109. }
  110. //删除关键字
  111. elseif($enews=="DelKey")
  112. {
  113. $keyid=$_GET['keyid'];
  114. DelKey($keyid,$logininid,$loginin);
  115. }
  116. else
  117. {}
  118. $page=(int)$_GET['page'];
  119. $page=RepPIntvar($page);
  120. $start=0;
  121. $line=30;//每页显示条数
  122. $page_line=12;//每页显示链接数
  123. $offset=$page*$line;//总偏移量
  124. $search='';
  125. $search.=$ecms_hashur['ehref'];
  126. $add='';
  127. //分类
  128. $fcid=(int)$_GET['fcid'];
  129. if($fcid)
  130. {
  131. $add=" where cid='$fcid'";
  132. $search.='&fcid='.$fcid;
  133. }
  134. $totalquery="select count(*) as total from {$dbtbpre}enewskey".$add;
  135. $num=$empire->gettotal($totalquery);
  136. $query="select keyid,keyname,keyurl,cid from {$dbtbpre}enewskey".$add." order by keyid desc limit $offset,$line";
  137. $sql=$empire->query($query);
  138. $returnpage=page2($num,$line,$page_line,$start,$page,$search);
  139. //分类
  140. $cstr='';
  141. $csql=$empire->query("select classid,classname from {$dbtbpre}enewskeyclass");
  142. while($cr=$empire->fetch($csql))
  143. {
  144. $cstr.="<option value='$cr[classid]'>$cr[classname]</option>";
  145. }
  146. ?>
  147. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  148. <html>
  149. <head>
  150. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  151. <title>关键字</title>
  152. <link href="../adminstyle/<?=$loginadminstyleid?>/adminstyle.css" rel="stylesheet" type="text/css">
  153. </head>
  154. <body>
  155. <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
  156. <tr>
  157. <td width="56%">位置:<a href="key.php<?=$ecms_hashur['whehref']?>">管理内容关键字</a></td>
  158. <td width="44%"><div align="right" class="emenubutton">
  159. <input type="button" name="Submit52" value="管理内容关键字分类" onclick="self.location.href='KeyClass.php<?=$ecms_hashur['whehref']?>';">
  160. </div></td>
  161. </tr>
  162. </table>
  163. <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
  164. <tr>
  165. <td> 选择分类:
  166. <select name="fcid" id="fcid" onchange=window.location='key.php?<?=$ecms_hashur['ehref']?>&fcid='+this.options[this.selectedIndex].value>
  167. <option value="0">显示所有分类</option>
  168. <?=$fcid?str_replace("'$fcid'>","'$fcid' selected>",$cstr):$cstr?>
  169. </select> </td>
  170. </tr>
  171. </table>
  172. <br>
  173. <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
  174. <form name="form1" method="post" action="key.php">
  175. <?=$ecms_hashur['form']?>
  176. <input type=hidden name=enews value=AddKey>
  177. <input type=hidden name=fcid value=<?=$fcid?>>
  178. <tr class="header">
  179. <td height="25">增加关键字:</td>
  180. </tr>
  181. <tr>
  182. <td height="25" bgcolor="#FFFFFF"> 关键字:
  183. <input name="keyname" type="text" id="keyname">
  184. 链接地址:
  185. <input name="keyurl" type="text" id="keyurl" value="http://" size="30">
  186. 所属分类:
  187. <select name="cid" id="cid">
  188. <option value="0">不隶属分类</option>
  189. <?=$cstr?>
  190. </select>
  191. <input type="submit" name="Submit" value="增加">
  192. <input type="reset" name="Submit2" value="重置"></td>
  193. </tr>
  194. </form>
  195. </table>
  196. <br>
  197. <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
  198. <tr class="header">
  199. <td width="70%" height="25">关键字</td>
  200. <td width="30%" height="25"><div align="center">操作</div></td>
  201. </tr>
  202. <?
  203. while($r=$empire->fetch($sql))
  204. {
  205. ?>
  206. <form name=form2 method=post action=key.php>
  207. <?=$ecms_hashur['form']?>
  208. <input type=hidden name=enews value=EditKey>
  209. <input type=hidden name=keyid value=<?=$r[keyid]?>>
  210. <input type=hidden name=fcid value=<?=$fcid?>>
  211. <tr bgcolor="#FFFFFF" onmouseout="this.style.backgroundColor='#ffffff'" onmouseover="this.style.backgroundColor='#C3EFFF'">
  212. <td height="25">关键字:
  213. <input name="keyname" type="text" id="keyname" value="<?=$r[keyname]?>">
  214. 链接地址:
  215. <input name="keyurl" type="text" id="keyurl" value="<?=$r[keyurl]?>" size="30">
  216. 所属分类:
  217. <select name="cid" id="cid">
  218. <option value="0">不隶属分类</option>
  219. <?=$r[cid]?str_replace("'$r[cid]'>","'$r[cid]' selected>",$cstr):$cstr?>
  220. </select> </td>
  221. <td height="25"><div align="center">
  222. <input type="submit" name="Submit3" value="修改">
  223. &nbsp;
  224. <input type="button" name="Submit4" value="删除" onclick="if(confirm('确认要删除?')){self.location.href='key.php?enews=DelKey&keyid=<?=$r[keyid]?>&fcid=<?=$fcid?><?=$ecms_hashur['href']?>';}">
  225. </div></td>
  226. </tr>
  227. </form>
  228. <?
  229. }
  230. db_close();
  231. $empire=null;
  232. ?>
  233. <tr bgcolor="#FFFFFF">
  234. <td height="25" colspan="2">
  235. <?=$returnpage?>
  236. </td>
  237. </tr>
  238. </table>
  239. </body>
  240. </html>