action.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <?php
  2. // by 请勿倒卖,已申请软著,否则追究法律责任
  3. namespace app\admin;
  4. class action extends Base
  5. {
  6. public function initialize()
  7. {
  8. parent::initialize();
  9. $this->Administrator(6);
  10. $this->header();
  11. }
  12. public function __destruct()
  13. {
  14. ?> <script>
  15. $('input[name=sort]').on('input', function () {
  16. var sort = $(this).val();
  17. if (sort != $(this).attr('data-sort'))
  18. $.ajax({
  19. url: '?c=ajax&a=action_sort',
  20. data: {id: $(this).attr('data-id'), sort: sort},
  21. type: 'post',
  22. success: function (ret) {
  23. console.log(ret)
  24. }
  25. });
  26. });
  27. </script>
  28. <?php
  29. $this->footer();
  30. }
  31. function index($map = [])
  32. {
  33. $_var_0 = db("action")->where("pid", "0")->order("sort")->select();
  34. $_var_1 = db("action")->where("pid", "0")->count();
  35. ?><div class="container"><?php
  36. $this->nav3();
  37. ?><table class="tb tb2">
  38. <tr><th class="partition">目录列表</th></tr>
  39. </table>
  40. <table class="tb tb2">
  41. <tr class="header">
  42. <th>ID</th>
  43. <th>名称</th>
  44. <th>描述</th>
  45. <th>排序</th>
  46. <th>状态</th>
  47. <th>编辑操作</th>
  48. </tr><?php
  49. if ($_var_1 == 0) {
  50. ?><tr><td colspan="2" class="td27">没有目录管理</td></tr><?php
  51. }
  52. function eachrow($_var_2, $_var_3 = '<b></b>')
  53. {
  54. ?><tr class="hover">
  55. <td class="td25"><?php echo $_var_2["id"];?></td>
  56. <td>
  57. <?php echo $_var_3;?><a href="?c=<?php echo $_var_2["c"];?>&a=<?php echo $_var_2["a"];?>" class="act"><?php echo $_var_2["name"];?></a>
  58. </td>
  59. <td><?php echo lightnum($_var_2["note"]);?></td>
  60. <td><input type="text" name="sort" data-id="<?php echo $_var_2["id"];?>" value="<?php echo $_var_2["sort"];?>" data-value="<?php echo $_var_2["sort"];?>" style="width: 30px;"/></td>
  61. <td>
  62. <a href="?c=action&a=change_status&id=<?php echo $_var_2["id"];?>&status=<?php echo $_var_2["status"] ? "0" : "1";?>&hash=<?php echo $_COOKIE["in_adminpassword"];?>">
  63. <img src="static/admincp/image/show_<?php echo $_var_2["status"] ? "yes" : "no";?>.gif" />
  64. </a>
  65. </td>
  66. <td><a href="?c=action&a=edit&pid=<?php echo $_var_2["id"];?>" class="act">新增子目录</a><?php
  67. if (!$_var_2["lock_on"]) {
  68. ?><a href="?c=action&a=edit&id=<?php echo $_var_2["id"];?>" class="act">编辑</a><a class="act" style="cursor:pointer" onclick="del_msg('?c=action&a=del&id=<?php echo $_var_2["id"];?>&hash=<?php echo $_COOKIE["in_adminpassword"];?>');">删除</a><?php
  69. }
  70. ?></td></tr><?php
  71. }
  72. if ($_var_0) {
  73. foreach ($_var_0 as $_var_4) {
  74. eachrow($_var_4);
  75. $_var_5 = db("action")->where("pid", $_var_4["id"])->order("sort")->select();
  76. foreach ($_var_5 as $_var_6) {
  77. eachrow($_var_6, "<b>┃━━━</b>");
  78. $_var_7 = db("action")->where("pid", $_var_6["id"])->order("sort")->select();
  79. foreach ($_var_7 as $_var_8) {
  80. eachrow($_var_8, "<b>┃━━━━━━</b>");
  81. }
  82. }
  83. }
  84. }
  85. ?></table></div><?php
  86. }
  87. function edit()
  88. {
  89. $_var_9 = SafeRequest("id", "get");
  90. $_var_10 = SafeRequest("pid", "get");
  91. $_var_11 = $_var_9 ? "编辑" : "新增";
  92. $_var_12 = db("action")->where("id", $_var_9)->find();
  93. ?><div class="container"><?php
  94. $this->nav3();
  95. ?><table class="tb tb2">
  96. <form action="?c=action&a=save" method="post" name="form">
  97. <input type="hidden" name="id" value="<?php echo $_var_9;?>"/>
  98. <input type="hidden" name="pid" value="<?php echo $_var_10 ? $_var_10 : $_var_12["pid"];?>"/>
  99. <input type="hidden" name="hash" value="<?php echo $_COOKIE["in_adminpassword"];?>" />
  100. <tr><th colspan="15" class="partition"><?php echo $_var_11;?>目录</th></tr>
  101. <tr><td colspan="2" class="td27">目录名称:</td></tr>
  102. <tr><td class="vtop rowform">
  103. <input type="text" class="txt" value="<?php echo $_var_12["name"];?>" name="name" id="name">
  104. </td>
  105. </tr>
  106. <tr><td colspan="2" class="td27">iframe:</td></tr>
  107. <tr><td class="vtop rowform">
  108. <input type="text" class="txt" name="c" id="c" value="<?php echo $_var_12["c"];?>">
  109. </td>
  110. </tr>
  111. <tr><td colspan="2" class="td27">action:</td></tr>
  112. <tr><td class="vtop rowform">
  113. <input type="text" class="txt" name="a" id="a" value="<?php echo $_var_12["a"];?>">
  114. </td>
  115. </tr>
  116. <tr><td colspan="2" class="td27">param:</td></tr>
  117. <tr><td class="vtop rowform">
  118. <input type="text" class="txt" name="p" id="p" value="<?php echo $_var_12["p"];?>">
  119. </td>
  120. </tr>
  121. <tr><td colspan="2" class="td27">描述:</td></tr>
  122. <tr><td class="vtop rowform">
  123. <textarea rows="6" name="note" class="tarea" id="note"><?php echo $_var_12["note"];?></textarea>
  124. </td>
  125. </tr>
  126. <tr><td colspan="15">
  127. <div class="fixsel">
  128. <input type="submit" class="btn" onclick="return CheckForm();" value="提交" />
  129. </div>
  130. </td></tr>
  131. </form>
  132. </table>
  133. </div>
  134. <?php
  135. }
  136. function del()
  137. {
  138. if (!submitcheck("hash", -1)) {
  139. $this->ShowMessage("链接来路不明,无法提交!", $_SERVER["PHP_SELF"], "infotitle3", 3000, 1);
  140. }
  141. $_var_13 = intval(SafeRequest("id", "get"));
  142. if (db("action")->where("pid", $_var_13)->count()) {
  143. $this->ShowMessage("抱歉,不允许删除非空目录!", "?c=action", "infotitle3", 3000, 1);
  144. }
  145. $_var_14 = db("action")->where("id", $_var_13)->delete();
  146. if ($_var_14) {
  147. $this->ShowMessage("恭喜您,目录管理删除成功!", "?c=action", "infotitle2", 3000, 1);
  148. }
  149. }
  150. function save()
  151. {
  152. if (!submitcheck("hash", 1)) {
  153. $this->ShowMessage("表单来路不明,无法提交!", $_SERVER["PHP_SELF"], "infotitle3", 3000, 1);
  154. }
  155. $_var_15 = intval(SafeRequest("id", "post"));
  156. $_var_16 = SafeRequest("name", "post");
  157. if (!$_var_16) {
  158. $this->ShowMessage("目录名称不能为空", $_SERVER["PHP_SELF"], "infotitle3", 3000, 1);
  159. }
  160. $_var_17 = SafeRequest("c", "post");
  161. if (!$_var_17) {
  162. $this->ShowMessage("iframe不能为空", $_SERVER["PHP_SELF"], "infotitle3", 3000, 1);
  163. }
  164. $_var_18 = SafeRequest("a", "post");
  165. $_var_18 = $_var_18 ? $_var_18 : "index";
  166. $_var_19 = SafeRequest("p", "post");
  167. $_var_20 = SafeRequest("pid", "post");
  168. $_var_21 = SafeRequest("note", "post");
  169. $_var_22 = ["name" => $_var_16, "c" => $_var_17, "a" => $_var_18, "p" => $_var_19, "pid" => $_var_20, "note" => $_var_21];
  170. if ($_var_15) {
  171. $_var_23 = db("action")->where("id", $_var_15)->update($_var_22);
  172. } else {
  173. if (db("action")->where("name", $_var_16)->where("c", $_var_17)->where("a", $_var_18)->where("p", $_var_19)->count()) {
  174. $this->ShowMessage("已存在相同的目录", $_SERVER["PHP_SELF"], "infotitle3", 3000, 1);
  175. }
  176. $_var_23 = db("action")->insert($_var_22);
  177. }
  178. $_var_23 && $this->ShowMessage("恭喜您,目录保存成功!", "?c=action", "infotitle2", 1000, 1);
  179. $this->ShowMessage("目录保存失败!请稍后重试!", $_SERVER["HTTP_REFERER"], "infotitle3", 3000, 1);
  180. }
  181. function change_status()
  182. {
  183. if (!submitcheck("hash", -1)) {
  184. $this->ShowMessage("链接来路不明,无法提交!", $_SERVER["PHP_SELF"], "infotitle3", 3000, 1);
  185. }
  186. $_var_24 = intval(SafeRequest("id", "get"));
  187. $_var_25 = intval(SafeRequest("status", "get"));
  188. $_var_26 = db("action")->where("id", $_var_24)->update(["status" => $_var_25]);
  189. if ($_var_26) {
  190. $this->ShowMessage("恭喜您,状态切换成功!", "?c=action", "infotitle2", 1000, 1);
  191. } else {
  192. $this->ShowMessage("恭喜您,状态切换成功!", "?c=action", "infotitle2", 1000, 1);
  193. }
  194. }
  195. }