writer.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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,"writer");
  21. //------------------增加作者
  22. function AddWriter($writer,$email,$userid,$username){
  23. global $empire,$dbtbpre;
  24. if(!$writer)
  25. {printerror("EmptyWriter","history.go(-1)");}
  26. //验证权限
  27. CheckLevel($userid,$username,$classid,"writer");
  28. $writer=hRepPostStr($writer,1);
  29. $email=hRepPostStr($email,1);
  30. $sql=$empire->query("insert into {$dbtbpre}enewswriter(writer,email) values('$writer','$email');");
  31. $lastid=$empire->lastid();
  32. GetConfig();//更新缓存
  33. if($sql)
  34. {
  35. //操作日志
  36. insert_dolog("wid=".$lastid."<br>writer=".$writer);
  37. printerror("AddWriterSuccess","writer.php".hReturnEcmsHashStrHref2(1));
  38. }
  39. else
  40. {printerror("DbError","history.go(-1)");}
  41. }
  42. //----------------修改作者
  43. function EditWriter($wid,$writer,$email,$userid,$username){
  44. global $empire,$dbtbpre;
  45. if(!$writer||!$wid)
  46. {printerror("EmptyWriter","history.go(-1)");}
  47. //验证权限
  48. CheckLevel($userid,$username,$classid,"writer");
  49. $wid=(int)$wid;
  50. $writer=hRepPostStr($writer,1);
  51. $email=hRepPostStr($email,1);
  52. $sql=$empire->query("update {$dbtbpre}enewswriter set writer='$writer',email='$email' where wid='$wid'");
  53. GetConfig();//更新缓存
  54. if($sql)
  55. {
  56. //操作日志
  57. insert_dolog("wid=".$wid."<br>writer=".$writer);
  58. printerror("EditWriterSuccess","writer.php".hReturnEcmsHashStrHref2(1));
  59. }
  60. else
  61. {printerror("DbError","history.go(-1)");}
  62. }
  63. //---------------删除作者
  64. function DelWriter($wid,$userid,$username){
  65. global $empire,$dbtbpre;
  66. $wid=(int)$wid;
  67. if(!$wid)
  68. {printerror("NotDelWid","history.go(-1)");}
  69. //验证权限
  70. CheckLevel($userid,$username,$classid,"writer");
  71. $r=$empire->fetch1("select writer from {$dbtbpre}enewswriter where wid='$wid'");
  72. $sql=$empire->query("delete from {$dbtbpre}enewswriter where wid='$wid'");
  73. GetConfig();//更新缓存
  74. if($sql)
  75. {
  76. //操作日志
  77. insert_dolog("wid=".$wid."<br>writer=".$r[writer]);
  78. printerror("DelWriterSuccess","writer.php".hReturnEcmsHashStrHref2(1));
  79. }
  80. else
  81. {printerror("DbError","history.go(-1)");}
  82. }
  83. $enews=$_POST['enews'];
  84. if(empty($enews))
  85. {$enews=$_GET['enews'];}
  86. if($enews)
  87. {
  88. hCheckEcmsRHash();
  89. }
  90. if($enews=="AddWriter")
  91. {
  92. $writer=$_POST['writer'];
  93. $email=$_POST['email'];
  94. AddWriter($writer,$email,$logininid,$loginin);
  95. }
  96. elseif($enews=="EditWriter")
  97. {
  98. $wid=$_POST['wid'];
  99. $writer=$_POST['writer'];
  100. $email=$_POST['email'];
  101. EditWriter($wid,$writer,$email,$logininid,$loginin);
  102. }
  103. elseif($enews=="DelWriter")
  104. {
  105. $wid=$_GET['wid'];
  106. DelWriter($wid,$logininid,$loginin);
  107. }
  108. else
  109. {}
  110. $page=(int)$_GET['page'];
  111. $page=RepPIntvar($page);
  112. $start=0;
  113. $line=30;//每页显示条数
  114. $page_line=12;//每页显示链接数
  115. $offset=$page*$line;//总偏移量
  116. $search='';
  117. $search.=$ecms_hashur['ehref'];
  118. $totalquery="select count(*) as total from {$dbtbpre}enewswriter";
  119. $num=$empire->gettotal($totalquery);
  120. $query="select wid,writer,email from {$dbtbpre}enewswriter order by wid desc limit $offset,$line";
  121. $sql=$empire->query($query);
  122. $addwritername=RepPostStr($_GET['addwritername'],1);
  123. $search.="&addwritername=$addwritername";
  124. $returnpage=page2($num,$line,$page_line,$start,$page,$search);
  125. ?>
  126. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  127. <html>
  128. <head>
  129. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  130. <title>管理作者</title>
  131. <link href="../adminstyle/<?=$loginadminstyleid?>/adminstyle.css" rel="stylesheet" type="text/css">
  132. </head>
  133. <body>
  134. <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
  135. <tr>
  136. <td>位置:<a href="writer.php<?=$ecms_hashur['whehref']?>">管理作者</a></td>
  137. </tr>
  138. </table>
  139. <form name="form1" method="post" action="writer.php">
  140. <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
  141. <?=$ecms_hashur['form']?>
  142. <tr class="header">
  143. <td height="25">增加作者:
  144. <input name=enews type=hidden id="enews" value=AddWriter>
  145. </td>
  146. </tr>
  147. <tr>
  148. <td height="25" bgcolor="#FFFFFF"> 作者名称:
  149. <input name="writer" type="text" id="writer" value="<?=$addwritername?>">
  150. 联系邮箱:
  151. <input name="email" type="text" id="email" value="mailto:" size="36">
  152. <input type="submit" name="Submit" value="增加">
  153. <input type="reset" name="Submit2" value="重置"></td>
  154. </tr>
  155. </table>
  156. </form>
  157. <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
  158. <tr class="header">
  159. <td width="70%" height="25">作者</td>
  160. <td width="30%" height="25"><div align="center">操作</div></td>
  161. </tr>
  162. <?
  163. while($r=$empire->fetch($sql))
  164. {
  165. ?>
  166. <form name=form2 method=post action=writer.php>
  167. <?=$ecms_hashur['form']?>
  168. <input type=hidden name=enews value=EditWriter>
  169. <input type=hidden name=wid value=<?=$r[wid]?>>
  170. <tr bgcolor="#FFFFFF" onmouseout="this.style.backgroundColor='#ffffff'" onmouseover="this.style.backgroundColor='#C3EFFF'">
  171. <td height="25">作者名称:
  172. <input name="writer" type="text" id="writer" value="<?=$r[writer]?>">
  173. 联系邮箱:
  174. <input name="email" type="text" id="email" value="<?=$r[email]?>" size="30">
  175. </td>
  176. <td height="25"><div align="center">
  177. <input type="submit" name="Submit3" value="修改">
  178. &nbsp;
  179. <input type="button" name="Submit4" value="删除" onclick="if(confirm('确认要删除?')){self.location.href='writer.php?enews=DelWriter&wid=<?=$r[wid]?><?=$ecms_hashur['href']?>';}">
  180. </div></td>
  181. </tr>
  182. </form>
  183. <?
  184. }
  185. db_close();
  186. $empire=null;
  187. ?>
  188. <tr bgcolor="#FFFFFF">
  189. <td height="25" colspan="2">
  190. <?=$returnpage?>
  191. </td>
  192. </tr>
  193. </table>
  194. </body>
  195. </html>