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