BeFrom.php 6.4 KB

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