ListPicNews.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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,"picnews");
  21. //增加图片信息
  22. function AddPicNews($add,$title,$pic_url,$url,$pic_width,$pic_height,$open_pic,$border,$pictext,$userid,$username){
  23. global $empire,$dbtbpre;
  24. if(!$title||!$pic_url||!$url||!$add[classid])
  25. {printerror("MustEnter","history.go(-1)");}
  26. //操作权限
  27. CheckLevel($userid,$username,$classid,"picnews");
  28. $add[classid]=(int)$add[classid];
  29. $border=(int)$border;
  30. $title=hRepPostStr($title,1);
  31. $pic_url=hRepPostStr2($pic_url);
  32. $url=hRepPostStr2($url);
  33. $pic_width=hRepPostStr($pic_width,1);
  34. $pic_height=hRepPostStr($pic_height,1);
  35. $open_pic=hRepPostStr($open_pic,1);
  36. $pictext=hRepPostStr2($pictext);
  37. $sql=$empire->query("insert into {$dbtbpre}enewspic(title,pic_url,url,pic_width,pic_height,open_pic,border,pictext,classid) values('$title','$pic_url','$url','$pic_width','$pic_height','$open_pic',$border,'$pictext',$add[classid]);");
  38. //生成js
  39. $picid=$empire->lastid();
  40. GetPicJs($picid);
  41. if($sql)
  42. {
  43. //操作日志
  44. insert_dolog("picid=".$picid."<br>title=".$title);
  45. printerror("AddPicNewsSuccess","AddPicNews.php?enews=AddPicNews".hReturnEcmsHashStrHref2(0));
  46. }
  47. else
  48. {printerror("DbError","history.go(-1)");}
  49. }
  50. //生成图片信息js
  51. function GetPicJs($picid){
  52. global $empire,$dbtbpre;
  53. $r=$empire->fetch1("select * from {$dbtbpre}enewspic where picid='$picid'");
  54. $string="<a href='".$r[url]."' title='".$r[title]."' target='".$r[open_pic]."'><img src='".$r[pic_url]."' width=".$r[pic_width]." height=".$r[pic_height]." border=".$r[border]."><br>".$r[title]."</a>";
  55. $string="document.write(\"".addslashes($string)."\");";
  56. $filename="../../../d/js/pic/pic_".$picid.".js";
  57. WriteFiletext_n($filename,$string);
  58. }
  59. //删除图片信息js
  60. function DelPicJs($picid){
  61. $filename="../../../d/js/pic/pic_".$picid.".js";
  62. DelFiletext($filename);
  63. }
  64. //修改图片信息
  65. function EditPicNews($add,$picid,$title,$pic_url,$url,$pic_width,$pic_height,$open_pic,$border,$pictext,$userid,$username){
  66. global $empire,$dbtbpre;
  67. $picid=(int)$picid;
  68. if(!$picid||!$title||!$pic_url||!$url||!$add[classid])
  69. {printerror("MustEnter","history.go(-1)");}
  70. //操作权限
  71. CheckLevel($userid,$username,$classid,"picnews");
  72. $add[classid]=(int)$add[classid];
  73. $border=(int)$border;
  74. $title=hRepPostStr($title,1);
  75. $pic_url=hRepPostStr2($pic_url);
  76. $url=hRepPostStr2($url);
  77. $pic_width=hRepPostStr($pic_width,1);
  78. $pic_height=hRepPostStr($pic_height,1);
  79. $open_pic=hRepPostStr($open_pic,1);
  80. $pictext=hRepPostStr2($pictext);
  81. $sql=$empire->query("update {$dbtbpre}enewspic set title='$title',pic_url='$pic_url',url='$url',pic_width='$pic_width',pic_height='$pic_height',open_pic='$open_pic',border=$border,pictext='$pictext',classid=$add[classid] where picid='$picid'");
  82. //生成js
  83. GetPicJs($picid);
  84. if($sql)
  85. {
  86. //操作日志
  87. insert_dolog("picid=".$picid."<br>title=".$title);
  88. printerror("EditPicNewsSuccess","ListPicNews.php".hReturnEcmsHashStrHref2(1));
  89. }
  90. else
  91. {printerror("DbError","history.go(-1)");}
  92. }
  93. //删除图片信息
  94. function DelPicNews($picid,$userid,$username){
  95. global $empire,$dbtbpre;
  96. $picid=(int)$picid;
  97. if(!$picid)
  98. {printerror("NotDelPicnewsid","history.go(-1)");}
  99. //操作权限
  100. CheckLevel($userid,$username,$classid,"picnews");
  101. $r=$empire->fetch1("select title from {$dbtbpre}enewspic where picid='$picid'");
  102. $sql=$empire->query("delete from {$dbtbpre}enewspic where picid='$picid'");
  103. //删除图片js
  104. DelPicJs($picid);
  105. if($sql)
  106. {
  107. //操作日志
  108. insert_dolog("picid=".$picid."<br>title=".$r[title]);
  109. printerror("DelPicNewsSuccess","ListPicNews.php".hReturnEcmsHashStrHref2(1));
  110. }
  111. else
  112. {printerror("DbError","history.go(-1)");}
  113. }
  114. //批量删除图片信息
  115. function DelPicNews_all($picid,$userid,$username){
  116. global $empire,$dbtbpre;
  117. //操作权限
  118. CheckLevel($userid,$username,$classid,"picnews");
  119. $count=count($picid);
  120. if(!$count)
  121. {printerror("NotDelPicnewsid","history.go(-1)");}
  122. for($i=0;$i<$count;$i++)
  123. {
  124. $picid[$i]=(int)$picid[$i];
  125. $add.="picid='$picid[$i]' or ";
  126. //删除图片js
  127. DelPicJs($picid[$i]);
  128. }
  129. $add=substr($add,0,strlen($add)-4);
  130. $sql=$empire->query("delete from {$dbtbpre}enewspic where ".$add);
  131. if($sql)
  132. {
  133. //操作日志
  134. insert_dolog("");
  135. printerror("DelPicNewsSuccess","ListPicNews.php".hReturnEcmsHashStrHref2(1));
  136. }
  137. else
  138. {
  139. printerror("DbError","history.go(-1)");
  140. }
  141. }
  142. $enews=$_POST['enews'];
  143. if(empty($enews))
  144. {$enews=$_GET['enews'];}
  145. if($enews)
  146. {
  147. hCheckEcmsRHash();
  148. }
  149. //增加图片新闻
  150. if($enews=="AddPicNews")
  151. {
  152. $add=$_POST['add'];
  153. $title=$_POST['title'];
  154. $pic_url=$_POST['pic_url'];
  155. $url=$_POST['url'];
  156. $pic_width=$_POST['pic_width'];
  157. $pic_height=$_POST['pic_height'];
  158. $open_pic=$_POST['open_pic'];
  159. $border=$_POST['border'];
  160. $pictext=$_POST['pictext'];
  161. AddPicNews($add,$title,$pic_url,$url,$pic_width,$pic_height,$open_pic,$border,$pictext,$logininid,$loginin);
  162. }
  163. //修改图片新闻
  164. elseif($enews=="EditPicNews")
  165. {
  166. $add=$_POST['add'];
  167. $picid=$_POST['picid'];
  168. $title=$_POST['title'];
  169. $pic_url=$_POST['pic_url'];
  170. $url=$_POST['url'];
  171. $pic_width=$_POST['pic_width'];
  172. $pic_height=$_POST['pic_height'];
  173. $open_pic=$_POST['open_pic'];
  174. $border=$_POST['border'];
  175. $pictext=$_POST['pictext'];
  176. EditPicNews($add,$picid,$title,$pic_url,$url,$pic_width,$pic_height,$open_pic,$border,$pictext,$logininid,$loginin);
  177. }
  178. //删除图片新闻
  179. elseif($enews=="DelPicNews")
  180. {
  181. $picid=$_GET['picid'];
  182. DelPicNews($picid,$logininid,$loginin);
  183. }
  184. //批量删除图片新闻
  185. elseif($enews=="DelPicNews_all")
  186. {
  187. $picid=$_POST['picid'];
  188. DelPicNews_all($picid,$logininid,$loginin);
  189. }
  190. $start=0;
  191. $page=(int)$_GET['page'];
  192. $page=RepPIntvar($page);
  193. $add="";
  194. $search="";
  195. $search.=$ecms_hashur['ehref'];
  196. $classid=(int)$_GET['classid'];
  197. if($classid)
  198. {
  199. $add=" where classid='$classid'";
  200. $search.="&classid=$classid";
  201. }
  202. $line=10;//每行显示
  203. $page_line=15;
  204. $offset=$page*$line;
  205. $totalquery="select count(*) as total from {$dbtbpre}enewspic".$add;
  206. $num=$empire->gettotal($totalquery);//取得总条数
  207. $query="select picid,title,pic_url,url,pic_width,pic_height,open_pic,border,pictext from {$dbtbpre}enewspic".$add;
  208. $query.=" order by picid desc limit $offset,$line";
  209. $sql=$empire->query($query);
  210. $returnpage=page2($num,$line,$page_line,$start,$page,$search);
  211. //图片类别
  212. $csql=$empire->query("select classid,classname from {$dbtbpre}enewspicclass order by classid");
  213. while($cr=$empire->fetch($csql))
  214. {
  215. if($classid==$cr[classid])
  216. {$select=" selected";}
  217. else
  218. {$select="";}
  219. $class.="<option value=".$cr[classid].$select.">".$cr[classname]."</option>";
  220. }
  221. ?>
  222. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  223. <html>
  224. <head>
  225. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  226. <title>管理图片信息</title>
  227. <link href="../adminstyle/<?=$loginadminstyleid?>/adminstyle.css" rel="stylesheet" type="text/css">
  228. </head>
  229. <body>
  230. <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
  231. <tr>
  232. <td width="50%">位置:<a href="ListPicNews.php<?=$ecms_hashur['whehref']?>">管理图片信息</a></td>
  233. <td><div align="right" class="emenubutton">
  234. <input type="button" name="Submit5" value="增加图片信息" onclick="self.location.href='AddPicNews.php?enews=AddPicNews<?=$ecms_hashur['ehref']?>';">
  235. &nbsp;&nbsp;
  236. <input type="button" name="Submit52" value="管理图片信息分类" onclick="self.location.href='PicClass.php<?=$ecms_hashur['whehref']?>';">
  237. </div></td>
  238. </tr>
  239. </table>
  240. <br>
  241. <table width="100%" border="0" cellspacing="1" cellpadding="3">
  242. <tr>
  243. <td>分类:
  244. <select name="classid" id="classid" onchange=window.location='ListPicNews.php?<?=$ecms_hashur['ehref']?>&classid='+this.options[this.selectedIndex].value>
  245. <option value="0">所有类别</option>
  246. <?=$class?>
  247. </select></td>
  248. </tr>
  249. </table>
  250. <form name="form1" method="post" action="ListPicNews.php" onsubmit="return confirm('确认要删除?');">
  251. <input type=hidden name=enews value=DelPicNews_all>
  252. <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
  253. <?=$ecms_hashur['form']?>
  254. <tr class="header">
  255. <td width="10%" height="25"><div align="center">ID</div></td>
  256. <td width="64%" height="25"><div align="center">预览</div></td>
  257. <td width="26%" height="25"><div align="center">操作</div></td>
  258. </tr>
  259. <?
  260. while($r=$empire->fetch($sql))
  261. {
  262. ?>
  263. <tr bgcolor="#FFFFFF" id=pic<?=$r[picid]?>>
  264. <td height="25"><div align="center">
  265. <?=$r[picid]?>
  266. </div></td>
  267. <td height="25"><div align="center"><a href="<?=$r[url]?>" target="<?=$r[open_pic]?>" title="<?=$r[title]?>"><img src="<?=$r[pic_url]?>" height="<?=$r[pic_height]?>" width="<?=$r[pic_width]?>" border="<?=$r[border]?>"></a><br>
  268. <?=$r[title]?>
  269. </div></td>
  270. <td height="25"><div align="center">[<a href="AddPicNews.php?enews=EditPicNews&picid=<?=$r[picid]?><?=$ecms_hashur['ehref']?>">修改</a>]
  271. [<a href="ListPicNews.php?enews=DelPicNews&picid=<?=$r[picid]?><?=$ecms_hashur['href']?>" onclick="return confirm('确认要删除?');">删除</a>
  272. <input name="picid[]" type="checkbox" id="picid[]" value="<?=$r[picid]?>" onclick="if(this.checked){pic<?=$r[picid]?>.style.backgroundColor='#DBEAF5';}else{pic<?=$r[picid]?>.style.backgroundColor='#ffffff';}">
  273. ]</div></td>
  274. </tr>
  275. <?
  276. }
  277. ?>
  278. <tr bgcolor="#FFFFFF">
  279. <td height="25" colspan="3">&nbsp;
  280. <?=$returnpage?>
  281. &nbsp;&nbsp;
  282. <input type="submit" name="Submit" value="批量删除"></td>
  283. </tr>
  284. <tr bgcolor="#FFFFFF">
  285. <td height="25" colspan="3"><font color="#666666">JS调用方式:&lt;script src=
  286. <?=$public_r[newsurl]?>
  287. d/js/pic/pic_图片信息ID.js&gt;&lt;/script&gt;</font></td>
  288. </tr>
  289. </table>
  290. </form>
  291. </body>
  292. </html>
  293. <?
  294. db_close();
  295. $empire=null;
  296. ?>