cert.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <?php
  2. // by 请勿倒卖,已申请软著,否则追究法律责任
  3. namespace app\admin;
  4. use PclZip;
  5. class cert extends Base
  6. {
  7. public function initialize()
  8. {
  9. parent::initialize();
  10. $this->Administrator(3);
  11. $this->header();
  12. }
  13. public function __destruct()
  14. {
  15. $this->footer();
  16. }
  17. function index($_var_0 = [])
  18. {
  19. $_var_1 = SafeRequest("page", "get");
  20. $this->type = SafeRequest("type", "get");
  21. is_numeric($this->type) && ($_var_0[] = ["type", "=", $this->type]);
  22. $this->status = SafeRequest("status", "get");
  23. is_numeric($this->status) && ($_var_0[] = ["status", "=", $this->status]);
  24. $_var_2 = db("cert")->where($_var_0)->order("in_id desc")->paginate(["page" => $_var_1]);
  25. $_var_3 = $_var_2->total();
  26. $_var_4 = getRender($_var_2, $_var_1);
  27. $_var_5 = $_var_2->items();
  28. ?> <div class="container">
  29. <?php
  30. $this->nav3();
  31. $this->searchForm("", "", function () {
  32. ?> <select name="type" onchange="document.btnsearch.submit();">
  33. <option value="">全部类型</option>
  34. <?php
  35. foreach (["基础版", "稳定版"] as $_var_6 => $_var_7) {
  36. ?> <option value="<?php echo $_var_6;?>" <?php echo is_numeric($this->type) && $this->type == $_var_6 ? "selected=\"selected\"" : "";?>>
  37. <?php echo $_var_7;?> </option>
  38. <?php
  39. }
  40. ?> </select>
  41. <select name="status" onchange="document.btnsearch.submit();">
  42. <option value="">全部状态</option>
  43. <?php
  44. foreach (["未启用", "已启用"] as $_var_6 => $_var_7) {
  45. ?> <option value="<?php echo $_var_6;?>" <?php echo is_numeric($this->status) && $this->status == $_var_6 ? "selected=\"selected\"" : "";?>>
  46. <?php echo $_var_7;?> </option>
  47. <?php
  48. }
  49. ?> </select>
  50. <?php
  51. });
  52. ?> <table class="tb tb2">
  53. <tr>
  54. <td colspan="15">
  55. <a href="?c=cert&a=edit" class="btn">新增证书</a>
  56. <!-- <a class="addtr" href="javascript:void(0)"-->
  57. <!-- onclick="pop.up('no', '上传证书', '/upload/cert/open', '406px', '180px', '175px');"-->
  58. <!-- >上传(证书目录.mobileprovision)自动新增</a>-->
  59. </td>
  60. </tr>
  61. <tr>
  62. <th class="partition">证书列表</th>
  63. </tr>
  64. </table>
  65. <form name="form" method="post" action="?c=cert&a=del">
  66. <table class="tb tb2">
  67. <tr class="header">
  68. <th>编号</th>
  69. <th>证书标识(.plist)</th>
  70. <th>证书名称(.sh)</th>
  71. <th>证书目录</th>
  72. <th>p12密码</th>
  73. <th>类型</th>
  74. <th>状态</th>
  75. <th>操作</th>
  76. <th></th>
  77. <th></th>
  78. </tr>
  79. <?php
  80. if ($_var_3 == 0) {
  81. ?> <tr>
  82. <td colspan="2" class="td27">没有证书</td>
  83. </tr>
  84. <?php
  85. } else {
  86. foreach ($_var_5 as $_var_8) {
  87. ?> <tr class="hover">
  88. <td class="td25">
  89. <input class="checkbox" type="checkbox" name="in_id[]"
  90. value="<?php echo $_var_8["in_id"];?>"><?php echo $_var_8["in_id"];?> </td>
  91. <td class="td29"><?php echo $_var_8["in_iden"];?></td>
  92. <td class="td29"><?php echo $_var_8["in_name"];?></td>
  93. <td class="td29"><?php echo $_var_8["in_dir"];?></td>
  94. <td><?php echo $_var_8["p12_pwd"];?></td>
  95. <td>
  96. <?php echo $_var_8["type"] ? "稳定版" : "基础版";?> </td>
  97. <td>
  98. <?php echo $_var_8["status"] ? "已启用" : lightnum("未启用");?> </td>
  99. <td>
  100. <a href="?c=cert&a=type&in_id=<?php echo $_var_8["in_id"];?>&v=<?php echo $_var_8["type"] ? "0" : "1";?>"><?php echo $_var_8["type"] ? "切换基础版" : "切换稳定版";?></a>
  101. </td>
  102. <td>
  103. <a href="?c=cert&a=status&in_id=<?php echo $_var_8["in_id"];?>&v=<?php echo $_var_8["status"] ? "0" : "1";?>"><?php echo $_var_8["status"] ? "停用" : "启用";?></a>
  104. </td>
  105. <td>
  106. <a href="?c=cert&a=edit&in_id=<?php echo $_var_8["in_id"];?>">编辑</a>
  107. </td>
  108. <td>
  109. <a href="?c=cert&a=del&in_id=<?php echo $_var_8["in_id"];?>">删除</a>
  110. </td>
  111. </tr>
  112. <?php
  113. }
  114. ?> <tr>
  115. <td class="td25">
  116. <input type="checkbox" id="chkall" class="checkbox" onclick="CheckAll(this.form)"/>
  117. <label for="chkall">全选</label></td>
  118. <td colspan="15">
  119. <div class="fixsel"><input type="submit" class="btn" name="editsave" value="批量删除"/>
  120. </div>
  121. </td>
  122. </tr>
  123. <?php
  124. }
  125. ?> </table>
  126. </form>
  127. </div>
  128. <?php echo $_var_4;?><?php
  129. }
  130. function edit()
  131. {
  132. $_var_9 = SafeRequest("in_id", "get");
  133. $_var_10 = db("cert")->where("in_id", $_var_9)->find();
  134. $_var_11 = $_var_9 ? $_var_10["in_dir"] : uniqid();
  135. $_var_12 = "/upload/cert/open?dir=" . $_var_11;
  136. $_var_13 = "<form action=\"?c=cert&a=save\" method=\"post\" name=\"form\">\r\n<input type=\"hidden\" name=\"in_id\" value=\"" . $_var_9 . "\"/>\r\n<input type=\"hidden\" name=\"hash\" value=\"" . $_COOKIE["in_adminpassword"] . "\" />\r\n<input type=\"hidden\" name=\"p12\" value=\"" . $_var_9 . "\"/>\r\n<input type=\"hidden\" name=\"mobileprovision\" value=\"" . $_var_9 . "\"/>\r\n<input type=\"hidden\" class=\"txt\" value=\"" . $_var_10["in_dir"] . "\" name=\"in_dir\" id=\"in_dir\">\r\n<tr><th colspan=\"15\" class=\"partition\">" . ($_var_9 ? "编辑" : "增加") . "证书</th></tr>\r\n<tr><td colspan=\"2\" class=\"td27\">p12文件:</td>\r\n<tr><td class=\"vtop rowform p12\"><img src=\"/static/index/image/cert-P12.png\" height=\"35\" " . ($_var_9 ? "" : "style=\"display: none;\"") . " onclick=\"pop.up('no', '上传p12', '" . $_var_12 . "&ext=p12', '406px', '180px', '175px');\"/>\r\n<input type=\"button\" class=\"btn\" value=\"上传p12\" onclick=\"pop.up('no', '上传p12', '" . $_var_12 . "&ext=p12', '406px', '180px', '175px');\">\r\n</td></tr>\r\n<tr><td colspan=\"2\" class=\"td27\">p12密码:</td></tr>\r\n<tr><td class=\"vtop rowform\">\r\n<input type=\"text\" class=\"txt\" value=\"" . $_var_10["p12_pwd"] . "\" name=\"p12_pwd\" id=\"p12_pwd\">\r\n</td></tr>\r\n<tr><td colspan=\"2\" class=\"td27\">描述文件:</td></tr>\r\n<tr><td class=\"vtop rowform mobileprovision\">\r\n<img src=\"/static/index/image/cert-mobileprovision.png\" height=\"35\" " . ($_var_9 ? "" : "style=\"display: none;\"") . " onclick=\"pop.up('no', '上传描述', '" . $_var_12 . "&ext=mobileprovision', '406px', '180px', '175px');\"/>\r\n<input type=\"button\" class=\"btn\" value=\"上传描述\" onclick=\"pop.up('no', '上传描述', '" . $_var_12 . "&ext=mobileprovision', '406px', '180px', '175px');\">\r\n</td></tr>\r\n<tr><td colspan=\"2\" class=\"td27\">证书标识:</td></tr>\r\n<tr><td class=\"vtop rowform\">\r\n<input type=\"text\" class=\"txt\" value=\"" . $_var_10["in_iden"] . "\" name=\"in_iden\" id=\"in_iden\">\r\n</td></tr>\r\n<tr><td colspan=\"2\" class=\"td27\">证书名称:</td></tr>\r\n<tr><td class=\"vtop rowform\">\r\n<input type=\"text\" class=\"txt\" value=\"" . $_var_10["in_name"] . "\" name=\"in_name\" id=\"in_name\">\r\n</td></tr>\r\n<tr><td colspan=\"2\" class=\"td27\">类型:</td></tr>\r\n<tr><td class=\"vtop rowform\">\r\n<select name=\"type\">\r\n<option value=\"0\" " . ($_var_10["type"] == 0 ? "selected=\"selected\"" : "") . ">基础版</option>\r\n<option value=\"1\" " . ($_var_10["type"] == 1 ? "selected=\"selected\"" : "") . ">稳定版</option>\r\n</select>\r\n</td>\r\n</tr>\r\n<tr><td colspan=\"15\">\r\n<div class=\"fixsel\">\r\n<input type=\"submit\" class=\"btn\" onclick=\"return CheckForm();\" value=\"提交\" />\r\n</div>\r\n</td></tr>\r\n</form>";
  137. $this->editemplate($_var_13);
  138. ?> <script>
  139. function uploadComplate(data) {
  140. if (data.ext == 'mobileprovision') {
  141. $("#in_iden").val(data.iden);
  142. $("#in_name").val(data.name);
  143. $("#in_dir").val(data.dir);
  144. }
  145. $('input[name=' + data.ext + ']').val(1);
  146. $('.' + data.ext + ' img').show();
  147. layer.closeAll();
  148. }
  149. </script>
  150. <?php
  151. }
  152. function save()
  153. {
  154. $_var_14 = SafeRequest("in_id", "post");
  155. $_var_15 = SafeRequest("p12", "post");
  156. if (!$_var_15) {
  157. $this->ShowMessage("请上传p12文件", $_SERVER["HTTP_REFERER"], "infotitle3", 3000, 1);
  158. }
  159. $_var_16["p12_pwd"] = SafeRequest("p12_pwd", "post");
  160. if (!$_var_16["p12_pwd"]) {
  161. $this->ShowMessage("请输入p12密码", $_SERVER["HTTP_REFERER"], "infotitle3", 3000, 1);
  162. }
  163. $_var_17 = SafeRequest("mobileprovision", "post");
  164. if (!$_var_17) {
  165. $this->ShowMessage("请上传描述文件", $_SERVER["HTTP_REFERER"], "infotitle3", 3000, 1);
  166. }
  167. $_var_16["in_iden"] = SafeRequest("in_iden", "post");
  168. $_var_16["in_name"] = SafeRequest("in_name", "post");
  169. $_var_18 = [];
  170. $_var_14 && ($_var_18[] = ["in_id", "<>", $_var_14]);
  171. if (db("cert")->where($_var_18)->where("in_name", $_var_16["in_name"])->count()) {
  172. $this->ShowMessage("证书名称已存在", $_SERVER["HTTP_REFERER"], "infotitle3", 3000, 1);
  173. }
  174. $_var_16["in_dir"] = SafeRequest("in_dir", "post");
  175. $_var_16["p12_pwd"] = SafeRequest("p12_pwd", "post");
  176. $_var_16["type"] = SafeRequest("type", "post");
  177. if ($_var_14) {
  178. $_var_19 = db("cert")->strict(false)->where("in_id", $_var_14)->update($_var_16);
  179. } else {
  180. $_var_19 = db("cert")->strict(false)->insert($_var_16);
  181. }
  182. if ($_var_19) {
  183. $_var_20 = $_var_16["in_dir"];
  184. $_var_21 = IN_TMP_PATH . $_var_20 . "/";
  185. $_var_22 = IN_CERT_PATH . $_var_20 . ".zip";
  186. $_var_23 = new PclZip($_var_22);
  187. $_var_23->create($_var_21, PCLZIP_OPT_REMOVE_PATH, $_var_21);
  188. }
  189. $this->ShowMessage("恭喜您,保存成功!", "?c=cert", "infotitle2", 1000, 1);
  190. }
  191. function del()
  192. {
  193. $_var_24 = SafeRequest("in_id", "post") ?? explode(",", SafeRequest("in_id", "get"));
  194. foreach ($_var_24 as $_var_25) {
  195. $_var_26 = db("cert")->where("in_id", $_var_25)->value("in_dir");
  196. @unlink("data/cert/" . $_var_26 . ".zip");
  197. db("cert")->where("in_id", $_var_25)->delete();
  198. }
  199. $this->ShowMessage("恭喜您,证书删除成功!", "?c=cert", "infotitle2", 3000, 1);
  200. }
  201. function type()
  202. {
  203. $_var_27 = intval(SafeRequest("in_id", "get"));
  204. $_var_28 = intval(SafeRequest("v", "get"));
  205. $_var_29 = db("cert")->where("in_id", $_var_27)->update(["type" => $_var_28]);
  206. $_var_30 = $_var_28 ? "稳定版" : "基础版";
  207. $this->ShowMessage("恭喜您,证书已切换为" . $_var_30 . "!", "?c=cert", "infotitle2", 3000, 1);
  208. }
  209. function status()
  210. {
  211. $_var_31 = intval(SafeRequest("in_id", "get"));
  212. $_var_32 = intval(SafeRequest("v", "get"));
  213. $_var_33 = db("cert")->where("in_id", $_var_31)->update(["status" => $_var_32]);
  214. $_var_34 = $_var_32 ? "已启用" : "已停用";
  215. $this->ShowMessage("恭喜您,证书" . $_var_34 . "!", "?c=cert", "infotitle2", 3000, 1);
  216. }
  217. }