ListSpClass.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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,"sp");
  21. //增加碎片分类
  22. function AddSpClass($add,$userid,$username){
  23. global $empire,$dbtbpre;
  24. if(!$add[classname])
  25. {
  26. printerror("EmptySpClassname","history.go(-1)");
  27. }
  28. //验证权限
  29. CheckLevel($userid,$username,$classid,"sp");
  30. $add['classname']=hRepPostStr($add['classname'],1);
  31. $add['classsay']=hRepPostStr($add['classsay'],1);
  32. $sql=$empire->query("insert into {$dbtbpre}enewsspclass(classname,classsay) values('$add[classname]','$add[classsay]');");
  33. $classid=$empire->lastid();
  34. if($sql)
  35. {
  36. //操作日志
  37. insert_dolog("classid=".$classid."<br>classname=".$add[classname]);
  38. printerror("AddSpClassSuccess","AddSpClass.php?enews=AddSpClass".hReturnEcmsHashStrHref2(0));
  39. }
  40. else
  41. {printerror("DbError","history.go(-1)");}
  42. }
  43. //修改碎片分类
  44. function EditSpClass($add,$userid,$username){
  45. global $empire,$dbtbpre;
  46. $classid=(int)$add[classid];
  47. if(!$classid||!$add[classname])
  48. {
  49. printerror("EmptySpClassname","history.go(-1)");
  50. }
  51. //验证权限
  52. CheckLevel($userid,$username,$classid,"sp");
  53. $add['classname']=hRepPostStr($add['classname'],1);
  54. $add['classsay']=hRepPostStr($add['classsay'],1);
  55. $sql=$empire->query("update {$dbtbpre}enewsspclass set classname='$add[classname]',classsay='$add[classsay]' where classid='$classid'");
  56. if($sql)
  57. {
  58. //操作日志
  59. insert_dolog("classid=".$classid."<br>classname=".$add[classname]);
  60. printerror("EditSpClassSuccess","ListSpClass.php".hReturnEcmsHashStrHref2(1));
  61. }
  62. else
  63. {printerror("DbError","history.go(-1)");}
  64. }
  65. //删除碎片分类
  66. function DelSpClass($classid,$userid,$username){
  67. global $empire,$dbtbpre;
  68. $classid=(int)$classid;
  69. if(!$classid)
  70. {
  71. printerror("NotDelSpClassid","history.go(-1)");
  72. }
  73. //验证权限
  74. CheckLevel($userid,$username,$classid,"sp");
  75. $r=$empire->fetch1("select classname from {$dbtbpre}enewsspclass where classid='$classid'");
  76. $sql=$empire->query("delete from {$dbtbpre}enewsspclass where classid='$classid'");
  77. if($sql)
  78. {
  79. //操作日志
  80. insert_dolog("classid=".$classid."<br>classname=".$r[classname]);
  81. printerror("DelSpClassSuccess","ListSpClass.php".hReturnEcmsHashStrHref2(1));
  82. }
  83. else
  84. {printerror("DbError","history.go(-1)");}
  85. }
  86. $enews=$_POST['enews'];
  87. if(empty($enews))
  88. {$enews=$_GET['enews'];}
  89. if($enews)
  90. {
  91. hCheckEcmsRHash();
  92. }
  93. if($enews=="AddSpClass")//增加碎片分类
  94. {
  95. AddSpClass($_POST,$logininid,$loginin);
  96. }
  97. elseif($enews=="EditSpClass")//修改碎片分类
  98. {
  99. EditSpClass($_POST,$logininid,$loginin);
  100. }
  101. elseif($enews=="DelSpClass")//删除碎片分类
  102. {
  103. $classid=$_GET['classid'];
  104. DelSpClass($classid,$logininid,$loginin);
  105. }
  106. $search=$ecms_hashur['ehref'];
  107. $page=(int)$_GET['page'];
  108. $page=RepPIntvar($page);
  109. $start=0;
  110. $line=30;//每页显示条数
  111. $page_line=12;//每页显示链接数
  112. $offset=$page*$line;//总偏移量
  113. $query="select classid,classname from {$dbtbpre}enewsspclass";
  114. $totalquery="select count(*) as total from {$dbtbpre}enewsspclass";
  115. $num=$empire->gettotal($totalquery);//取得总条数
  116. $query=$query." order by classid desc limit $offset,$line";
  117. $sql=$empire->query($query);
  118. $returnpage=page2($num,$line,$page_line,$start,$page,$search);
  119. $url="<a href=ListSp.php".$ecms_hashur['whehref'].">管理碎片</a>&nbsp;>&nbsp;<a href=ListSpClass.php".$ecms_hashur['whehref'].">管理碎片分类</a>";
  120. ?>
  121. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  122. <html>
  123. <head>
  124. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  125. <title>碎片分类</title>
  126. <link href="../adminstyle/<?=$loginadminstyleid?>/adminstyle.css" rel="stylesheet" type="text/css">
  127. </head>
  128. <body>
  129. <table width="100%" border="0" cellspacing="1" cellpadding="3">
  130. <tr>
  131. <td width="50%">位置:
  132. <?=$url?>
  133. </td>
  134. <td><div align="right" class="emenubutton">
  135. <input type="button" name="Submit5" value="增加碎片分类" onclick="self.location.href='AddSpClass.php?enews=AddSpClass<?=$ecms_hashur['ehref']?>';">
  136. </div></td>
  137. </tr>
  138. </table>
  139. <br>
  140. <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
  141. <tr class="header">
  142. <td width="9%" height="25"><div align="center">ID</div></td>
  143. <td width="70%" height="25"><div align="center">分类名称</div></td>
  144. <td width="21%" height="25"><div align="center">操作</div></td>
  145. </tr>
  146. <?
  147. while($r=$empire->fetch($sql))
  148. {
  149. ?>
  150. <tr bgcolor="#FFFFFF" onmouseout="this.style.backgroundColor='#ffffff'" onmouseover="this.style.backgroundColor='#C3EFFF'">
  151. <td height="25"><div align="center">
  152. <?=$r[classid]?>
  153. </div></td>
  154. <td height="25" align="center">
  155. <a href="ListSp.php?<?=$ecms_hashur['ehref']?>&cid=<?=$r[classid]?>" target="_blank"><?=$r[classname]?></a>
  156. </td>
  157. <td height="25"><div align="center">[<a href="AddSpClass.php?enews=EditSpClass&classid=<?=$r[classid]?><?=$ecms_hashur['ehref']?>">修改</a>]
  158. [<a href="ListSpClass.php?enews=DelSpClass&classid=<?=$r[classid]?><?=$ecms_hashur['href']?>" onclick="return confirm('确认要删除?');">删除</a>]</div></td>
  159. </tr>
  160. <?
  161. }
  162. ?>
  163. <tr bgcolor="#FFFFFF">
  164. <td height="25" colspan="3">&nbsp;
  165. <?=$returnpage?>
  166. </td>
  167. </tr>
  168. </table>
  169. </body>
  170. </html>
  171. <?
  172. db_close();
  173. $empire=null;
  174. ?>