app_pack.php 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <?php
  2. namespace app\admin;
  3. class app_pack extends Base
  4. {
  5. public function initialize()
  6. {
  7. parent::initialize();
  8. $this->Administrator(4);
  9. $this->header();
  10. }
  11. public function __destruct()
  12. {
  13. $this->footer();
  14. }
  15. function del()
  16. {
  17. $_var_9 = intval(SafeRequest("id", "get"));
  18. // var_dump($_var_9);die;
  19. $_var_10 = db("app_pack")->where("id", $_var_9)->delete();
  20. $this->ShowMessage("恭喜您,删除成功!", "?c=app_pack", "infotitle2", 1000, 1);
  21. }
  22. function index($_var_0 = [])
  23. {
  24. $_var_1 = SafeRequest("page", "get");
  25. $this->search = SafeRequest("search", "get");
  26. $this->search && ($_var_0[] = ["name|url|bundle_id", "like", "%" . $this->search . "%"]);
  27. $this->type = SafeRequest("type", "get");
  28. is_numeric($this->type) && ($_var_0[] = ["type", "=", $this->type]);
  29. $this->mapTime("create_time", true, $_var_0);
  30. $_var_2 = db("app_pack")->where($_var_0)->json(["config"])->order("id desc")->paginate(["page" => $_var_1]);
  31. $_var_3 = $_var_2->items();
  32. $_var_4 = $_var_2->total();
  33. $_var_5 = getRender($_var_2, $_var_1);
  34. ?> <div class="container">
  35. <?php
  36. $this->nav3();
  37. $this->searchForm("", "", function () {
  38. ?> <select name="type" onchange="document.btnsearch.submit();">
  39. <option value="">全部类型</option>
  40. <?php
  41. foreach (["安卓", "苹果", "苹果免签"] as $_var_6 => $_var_7) {
  42. ?> <option value="<?php echo $_var_6;?>" <?php echo $this->type == $_var_6 ? "selected=\"selected\"" : "";?>>
  43. <?php echo $_var_7;?> </option>
  44. <?php
  45. }
  46. ?> </select>
  47. <?php
  48. });
  49. ?>
  50. <style type="text/css">
  51. .checkbox {
  52. height: 14px;
  53. position: relative;
  54. top: 0;
  55. width: 18px;
  56. height: 23px;
  57. line-height: 10px;
  58. border: 1px solid #d2d2d2;
  59. font-size: 12px;
  60. border-radius: 10px;
  61. background-color: #fff;
  62. -webkit-transition: .1s linear;
  63. transition: .1s linear;
  64. }
  65. a{
  66. text-decoration: none;
  67. }
  68. a:hover{ text-decoration:none}
  69. </style>
  70. <form name="form" method="post" action="?c=app_pack&a=allsave">
  71. <table class="tb tb2">
  72. <tr>
  73. <th class="partition">应用封装列表</th>
  74. </tr>
  75. </table>
  76. <xblock>
  77. <button class="layui-btn layui-btn-normal" value="批量操作" name="allsave"><i class="layui-icon layui-icon-delete"></i>批量删除</button>
  78. </xblock>
  79. <table class="layui-table">
  80. <thead>
  81. <tr>
  82. <th>
  83. <input type="checkbox" id="chkall" class="checkbox" onclick="CheckAll(this.form);"/>
  84. </th>
  85. <th>应用ID</th>
  86. <th>所属用户</th>
  87. <th>应用图标</th>
  88. <th>应用名称</th>
  89. <th>下载</th>
  90. <th>封装地址</th>
  91. <th>应用包名</th>
  92. <th>应用版本</th>
  93. <th>应用类型</th>
  94. <th>封装时间</th>
  95. <th>有效期</th>
  96. <th>操作</th>
  97. </tr>
  98. </thead>
  99. <?php
  100. if ($_var_4 == 0) {
  101. ?><tr> <td colspan="22" style="margin:auto;text-align:center" >暂无数据</td></tr><?php
  102. } else {
  103. if ($_var_3) {
  104. foreach ($_var_3 as $_var_8) {
  105. ?>
  106. <tr>
  107. <td><input class="checkbox" type="checkbox" name="in_id[]" id="in_id" value="<?php echo $_var_8["id"];?>"></td>
  108. <td><?php echo $_var_8["id"];?></td>
  109. <td><?php echo db("user")->where("in_userid", $_var_8["user_id"])->value("in_username");?></td>
  110. <td><img src="<?php echo $_var_8["icon"] ?: $_var_8["config"]["icon"];?>" onerror="this.src='static/index/image/<?php echo $_var_8["type"] ? "iOS" : "Android";?>.png'" width="25" height="25"/></a></td>
  111. <td><?php echo $_var_8["name"];?></a></td>
  112. <td><a class="layui-btn layui-btn-normal layui-btn-xs" href="<?php echo $_var_8["file"] ? "/data/attachment/pack/" . $_var_8["file"] : getapp($_var_8["app_id"], 1);?>" target="_blank" class="act">下载</a></td>
  113. <td><a href="<?php echo $_var_8["url"];?>" target="_blank"><?php echo $_var_8["url"];?></td>
  114. <td><?php echo $_var_8["bundle_id"];?></td>
  115. <td><?php echo $_var_8["version"];?></td>
  116. <td><?php echo $_var_8["type"] == 1 ? "iOS" : ($_var_8["type"] == 2 ? "iOS免签" : "Android");?></td>
  117. <td><?php echo date("Y-m-d H:i", $_var_8["create_time"]);?></td>
  118. <td><?php echo $_var_8["period"] > 0 ? date("Y-m-d H:i", $_var_8["period"]) : "永久";?></td>
  119. <td>
  120. <a class="layui-btn layui-btn-danger layui-btn-xs" style="cursor:pointer" onclick="del_msgyy('?c=app_pack&a=del&id=<?php echo $_var_8["id"];?>');"><i class="layui-icon layui-icon-delete"></i>删除</a>
  121. <?php
  122. if ($_var_8["period"] > 0) {
  123. ?><a href="javascript:;" class="layui-btn layui-btn-warm layui-btn-xs" onclick="addTime(<?php echo $_var_8["id"];?>,<?php echo $_var_8["period"];?>)"><i class="layui-icon layui-icon-addition"></i>增加时间</a><?php
  124. }
  125. ?></td></tr><?php
  126. }
  127. }
  128. }
  129. ?> </table>
  130. <?php echo $this->render($_var_5);?> <table class="tb tb2">
  131. <tr>
  132. </tr>
  133. </table>
  134. </form>
  135. </div>
  136. <script>
  137. function addTime(id, period) {
  138. layer.prompt({title: '请输入增加的时长(天)'}, function (days, index) {
  139. layer.close(index);
  140. if (isNaN(days)) {
  141. return layer.msg(days + '不是有效的时间');
  142. }
  143. location.href = '?c=app_pack&a=addTime&id=' + id + '&days=' + days + '&period=' + period;
  144. });
  145. }
  146. </script>
  147. <?php
  148. }
  149. function addTime()
  150. {
  151. $_var_9 = SafeRequest("id", "get");
  152. $_var_10 = SafeRequest("days", "get");
  153. $_var_11 = SafeRequest("period", "get");
  154. $_var_12 = strtotime("+" . $_var_10 . " days", max($_var_11, time()));
  155. $_var_13 = db("app_pack")->where("id", "in", $_var_9)->update(["period" => $_var_12]);
  156. $_var_14 = date("Y-m-d", $_var_12);
  157. $this->ShowMessage("恭喜您,增加时间成功!到期时间:" . $_var_14, $_SERVER["HTTP_REFERER"], "infotitle2", 3000, 1);
  158. }
  159. function allsave()
  160. {
  161. if (!submitcheck("allsave")) {
  162. $this->ShowMessage("表单验证不符,无法提交!", $_SERVER["PHP_SELF"], "infotitle3", 3000, 1);
  163. }
  164. $_var_15 = RequestBox("in_id");
  165. $_var_16 = SafeRequest("in_allsave", "post");
  166. if ($_var_15 == 0) {
  167. $this->ShowMessage("批量操作失败,请先勾选要删除的应用!", $_SERVER["HTTP_REFERER"], "infotitle3", 3000, 1);
  168. } else {
  169. if ($_var_16 == 0) {
  170. $_var_17 = db("app_pack")->where("id", "in", $_var_15)->json(["config"])->select();
  171. foreach ($_var_17 as $_var_18 => $_var_19) {
  172. if ($_var_19["file"]) {
  173. @unlink(IN_ATTACHMENT_PATH . "pack/" . $_var_19["file"]);
  174. }
  175. if ($_var_19["icon"]) {
  176. @unlink(IN_ROOT . $_var_19["icon"]);
  177. }
  178. if ($_var_19["launch"]) {
  179. @unlink(IN_ROOT . $_var_19["launch"]);
  180. }
  181. if (isset($_var_19["config"]["icon"])) {
  182. @unlink(IN_ROOT . $_var_19["config"]["icon"]);
  183. }
  184. if (isset($_var_19["config"]["launch"])) {
  185. @unlink(IN_ROOT . $_var_19["config"]["launch"]);
  186. }
  187. }
  188. db("app_pack")->where("id", "in", $_var_15)->delete();
  189. $this->ShowMessage("恭喜您,应用批量删除成功!", $_SERVER["HTTP_REFERER"], "infotitle2", 3000, 1);
  190. }
  191. }
  192. }
  193. }