ListLink.php 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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,"link");
  21. //------------------增加友情链接
  22. function AddLink($add,$userid,$username){
  23. global $empire,$dbtbpre;
  24. if(!$add[lname]||!$add[lurl])
  25. {printerror("EmptyLname","history.go(-1)");}
  26. //验证权限
  27. CheckLevel($userid,$username,$classid,"link");
  28. $ltime=date("Y-m-d H:i:s");
  29. $add[lname]=hRepPostStr($add[lname],1);
  30. $add[lpic]=hRepPostStr2(eDoRepPostComStr($add[lpic],1));
  31. $add[lurl]=hRepPostStr2(eDoRepPostComStr($add[lurl],1));
  32. $add[email]=hRepPostStr($add[email],1);
  33. $add[onclick]=(int)$add[onclick];
  34. $add[myorder]=(int)$add[myorder];
  35. $add[ltype]=(int)$add[ltype];
  36. $add[checked]=(int)$add[checked];
  37. $add[classid]=(int)$add[classid];
  38. $add[cid]=(int)$add[cid];
  39. $add['width']=hRepPostStr($add['width'],1);
  40. $add['height']=hRepPostStr($add['height'],1);
  41. $add['target']=hRepPostStr($add['target'],1);
  42. $sql=$empire->query("insert into {$dbtbpre}enewslink(lname,lpic,lurl,ltime,onclick,width,height,target,myorder,email,lsay,ltype,checked,classid) values('".$add[lname]."','".$add[lpic]."','".$add[lurl]."','$ltime',$add[onclick],'$add[width]','$add[height]','$add[target]',$add[myorder],'".$add[email]."','".eaddslashes($add[lsay])."',$add[ltype],$add[checked],$add[classid]);");
  43. $lastid=$empire->lastid();
  44. if($sql)
  45. {
  46. //操作日志
  47. insert_dolog("lid=".$lastid."<br>lname=".$add[lname]);
  48. printerror("AddLinkSuccess","AddLink.php?enews=AddLink&cid=$add[cid]".hReturnEcmsHashStrHref2(0));
  49. }
  50. else
  51. {printerror("DbError","history.go(-1)");}
  52. }
  53. //----------------修改友情链接
  54. function EditLink($add,$userid,$username){
  55. global $empire,$dbtbpre;
  56. $add[lid]=(int)$add[lid];
  57. if(!$add[lname]||!$add[lurl]||!$add[lid])
  58. {printerror("EmptyLname","history.go(-1)");}
  59. //验证权限
  60. CheckLevel($userid,$username,$classid,"link");
  61. $add[lname]=hRepPostStr($add[lname],1);
  62. $add[lpic]=hRepPostStr2(eDoRepPostComStr($add[lpic],1));
  63. $add[lurl]=hRepPostStr2(eDoRepPostComStr($add[lurl],1));
  64. $add[email]=hRepPostStr($add[email],1);
  65. $add[onclick]=(int)$add[onclick];
  66. $add[myorder]=(int)$add[myorder];
  67. $add[ltype]=(int)$add[ltype];
  68. $add[checked]=(int)$add[checked];
  69. $add[classid]=(int)$add[classid];
  70. $add[cid]=(int)$add[cid];
  71. $add['width']=hRepPostStr($add['width'],1);
  72. $add['height']=hRepPostStr($add['height'],1);
  73. $add['target']=hRepPostStr($add['target'],1);
  74. $sql=$empire->query("update {$dbtbpre}enewslink set lname='".$add[lname]."',lpic='".$add[lpic]."',lurl='".$add[lurl]."',onclick=$add[onclick],width='$add[width]',height='$add[height]',target='$add[target]',myorder=$add[myorder],email='".$add[email]."',lsay='".eaddslashes($add[lsay])."',ltype=$add[ltype],checked=$add[checked],classid=$add[classid] where lid='$add[lid]'");
  75. if($sql)
  76. {
  77. //操作日志
  78. insert_dolog("lid=".$add[lid]."<br>lname=".$add[lname]);
  79. printerror("EditLinkSuccess","ListLink.php?classid=$add[cid]".hReturnEcmsHashStrHref2(0));
  80. }
  81. else
  82. {printerror("DbError","history.go(-1)");}
  83. }
  84. //---------------删除友情链接
  85. function DelLink($lid,$cid,$userid,$username){
  86. global $empire,$dbtbpre;
  87. $lid=(int)$lid;
  88. $cid=(int)$cid;
  89. if(!$lid)
  90. {printerror("EmptyLid","history.go(-1)");}
  91. //验证权限
  92. CheckLevel($userid,$username,$classid,"link");
  93. $r=$empire->fetch1("select lname from {$dbtbpre}enewslink where lid='$lid'");
  94. $sql=$empire->query("delete from {$dbtbpre}enewslink where lid='$lid'");
  95. if($sql)
  96. {
  97. //操作日志
  98. insert_dolog("lid=".$lid."<br>lname=".$r[lname]);
  99. printerror("DelLinkSuccess","ListLink.php?classid=$cid".hReturnEcmsHashStrHref2(0));
  100. }
  101. else
  102. {printerror("DbError","history.go(-1)");}
  103. }
  104. $enews=$_POST['enews'];
  105. if(empty($enews))
  106. {$enews=$_GET['enews'];}
  107. if($enews)
  108. {
  109. hCheckEcmsRHash();
  110. }
  111. if($enews=="AddLink")
  112. {
  113. AddLink($_POST,$logininid,$loginin);
  114. }
  115. elseif($enews=="EditLink")
  116. {
  117. EditLink($_POST,$logininid,$loginin);
  118. }
  119. elseif($enews=="DelLink")
  120. {
  121. $lid=$_GET['lid'];
  122. $cid=$_GET['cid'];
  123. DelLink($lid,$cid,$logininid,$loginin);
  124. }
  125. else
  126. {}
  127. $search=$ecms_hashur['ehref'];
  128. $page=(int)$_GET['page'];
  129. $page=RepPIntvar($page);
  130. $start=0;
  131. $line=16;//每页显示条数
  132. $page_line=25;//每页显示链接数
  133. $offset=$page*$line;//总偏移量
  134. $query="select * from {$dbtbpre}enewslink";
  135. $totalquery="select count(*) as total from {$dbtbpre}enewslink";
  136. //类别
  137. $add="";
  138. $classid=(int)$_GET['classid'];
  139. if($classid)
  140. {
  141. $add=" where classid=$classid";
  142. $search.="&classid=$classid";
  143. }
  144. $query.=$add;
  145. $totalquery.=$add;
  146. $num=$empire->gettotal($totalquery);//取得总条数
  147. $query=$query." order by myorder,lid limit $offset,$line";
  148. $sql=$empire->query($query);
  149. $returnpage=page2($num,$line,$page_line,$start,$page,$search);
  150. //类别
  151. $cstr="";
  152. $csql=$empire->query("select classid,classname from {$dbtbpre}enewslinkclass order by classid");
  153. while($cr=$empire->fetch($csql))
  154. {
  155. $select="";
  156. if($cr[classid]==$classid)
  157. {
  158. $select=" selected";
  159. }
  160. $cstr.="<option value='".$cr[classid]."'".$select.">".$cr[classname]."</option>";
  161. }
  162. ?>
  163. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  164. <html>
  165. <head>
  166. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  167. <link href="../adminstyle/<?=$loginadminstyleid?>/adminstyle.css" rel="stylesheet" type="text/css">
  168. <title>管理友情链接</title>
  169. </head>
  170. <body>
  171. <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
  172. <tr>
  173. <td width="50%" height="25">位置:<a href="ListLink.php<?=$ecms_hashur['whehref']?>">管理友情链接</a></td>
  174. <td><div align="right" class="emenubutton">
  175. <input type="button" name="Submit5" value="增加友情链接" onclick="self.location.href='AddLink.php?enews=AddLink<?=$ecms_hashur['ehref']?>';">
  176. </div></td>
  177. </tr>
  178. </table>
  179. <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
  180. <tr>
  181. <td> 选择类别:
  182. <select name="classid" id="classid" onchange=window.location='ListLink.php?<?=$ecms_hashur['ehref']?>&classid='+this.options[this.selectedIndex].value>
  183. <option value="0">显示所有类别</option>
  184. <?=$cstr?>
  185. </select> </td>
  186. </tr>
  187. </table>
  188. <br>
  189. <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
  190. <tr class="header">
  191. <td width="6%" height="25"> <div align="center">ID</div></td>
  192. <td width="51%" height="25"> <div align="center">预览</div></td>
  193. <td width="11%" height="25"> <div align="center">点击</div></td>
  194. <td width="12%"><div align="center">状态</div></td>
  195. <td width="20%" height="25"> <div align="center">操作</div></td>
  196. </tr>
  197. <?
  198. while($r=$empire->fetch($sql))
  199. {
  200. //文字
  201. if(empty($r[lpic]))
  202. {
  203. $logo="<a href='".$r[lurl]."' title='".$r[lname]."' target=".$r[target].">".$r[lname]."</a>";
  204. }
  205. //图片
  206. else
  207. {
  208. $logo="<a href='".$r[lurl]."' target=".$r[target]."><img src='".$r[lpic]."' alt='".$r[lname]."' border=0 width='".$r[width]."' height='".$r[height]."'></a>";
  209. }
  210. if(empty($r[checked]))
  211. {$checked="关闭";}
  212. else
  213. {$checked="显示";}
  214. ?>
  215. <tr bgcolor="#FFFFFF" onmouseout="this.style.backgroundColor='#ffffff'" onmouseover="this.style.backgroundColor='#C3EFFF'">
  216. <td height="25"> <div align="center">
  217. <?=$r[lid]?>
  218. </div></td>
  219. <td height="25"> <div align="center">
  220. <?=$logo?>
  221. </div></td>
  222. <td height="25"> <div align="center">
  223. <?=$r[onclick]?>
  224. </div></td>
  225. <td><div align="center"><?=$checked?></div></td>
  226. <td height="25"> <div align="center">[<a href="AddLink.php?enews=EditLink&lid=<?=$r[lid]?>&cid=<?=$classid?><?=$ecms_hashur['ehref']?>">修改</a>]&nbsp;[<a href="ListLink.php?enews=DelLink&lid=<?=$r[lid]?>&cid=<?=$classid?><?=$ecms_hashur['href']?>" onclick="return confirm('确认要删除?');">删除</a>]</div></td>
  227. </tr>
  228. <?
  229. }
  230. ?>
  231. <tr bgcolor="#FFFFFF">
  232. <td height="25" colspan="5">&nbsp;&nbsp;&nbsp;
  233. <?=$returnpage?>
  234. </td>
  235. </tr>
  236. </table>
  237. </body>
  238. </html>
  239. <?
  240. db_close();
  241. $empire=null;
  242. ?>