123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- <?php
- // by 请勿倒卖,已申请软著,否则追究法律责任
- namespace app\admin;
- use PclZip;
- class cert extends Base
- {
- public function initialize()
- {
- parent::initialize();
- $this->Administrator(3);
- $this->header();
- }
- public function __destruct()
- {
- $this->footer();
- }
- function index($_var_0 = [])
- {
- $_var_1 = SafeRequest("page", "get");
- $this->type = SafeRequest("type", "get");
- is_numeric($this->type) && ($_var_0[] = ["type", "=", $this->type]);
- $this->status = SafeRequest("status", "get");
- is_numeric($this->status) && ($_var_0[] = ["status", "=", $this->status]);
- $_var_2 = db("cert")->where($_var_0)->order("in_id desc")->paginate(["page" => $_var_1]);
- $_var_3 = $_var_2->total();
- $_var_4 = getRender($_var_2, $_var_1);
- $_var_5 = $_var_2->items();
- ?> <div class="container">
- <?php
- $this->nav3();
- $this->searchForm("", "", function () {
- ?> <select name="type" onchange="document.btnsearch.submit();">
- <option value="">全部类型</option>
- <?php
- foreach (["基础版", "稳定版"] as $_var_6 => $_var_7) {
- ?> <option value="<?php echo $_var_6;?>" <?php echo is_numeric($this->type) && $this->type == $_var_6 ? "selected=\"selected\"" : "";?>>
- <?php echo $_var_7;?> </option>
- <?php
- }
- ?> </select>
- <select name="status" onchange="document.btnsearch.submit();">
- <option value="">全部状态</option>
- <?php
- foreach (["未启用", "已启用"] as $_var_6 => $_var_7) {
- ?> <option value="<?php echo $_var_6;?>" <?php echo is_numeric($this->status) && $this->status == $_var_6 ? "selected=\"selected\"" : "";?>>
- <?php echo $_var_7;?> </option>
- <?php
- }
- ?> </select>
- <?php
- });
- ?> <table class="tb tb2">
- <tr>
- <td colspan="15">
- <a href="?c=cert&a=edit" class="btn">新增证书</a>
- <!-- <a class="addtr" href="javascript:void(0)"-->
- <!-- onclick="pop.up('no', '上传证书', '/upload/cert/open', '406px', '180px', '175px');"-->
- <!-- >上传(证书目录.mobileprovision)自动新增</a>-->
- </td>
- </tr>
- <tr>
- <th class="partition">证书列表</th>
- </tr>
- </table>
- <form name="form" method="post" action="?c=cert&a=del">
- <table class="tb tb2">
- <tr class="header">
- <th>编号</th>
- <th>证书标识(.plist)</th>
- <th>证书名称(.sh)</th>
- <th>证书目录</th>
- <th>p12密码</th>
- <th>类型</th>
- <th>状态</th>
- <th>操作</th>
- <th></th>
- <th></th>
- </tr>
- <?php
- if ($_var_3 == 0) {
- ?> <tr>
- <td colspan="2" class="td27">没有证书</td>
- </tr>
- <?php
- } else {
- foreach ($_var_5 as $_var_8) {
- ?> <tr class="hover">
- <td class="td25">
- <input class="checkbox" type="checkbox" name="in_id[]"
- value="<?php echo $_var_8["in_id"];?>"><?php echo $_var_8["in_id"];?> </td>
- <td class="td29"><?php echo $_var_8["in_iden"];?></td>
- <td class="td29"><?php echo $_var_8["in_name"];?></td>
- <td class="td29"><?php echo $_var_8["in_dir"];?></td>
- <td><?php echo $_var_8["p12_pwd"];?></td>
- <td>
- <?php echo $_var_8["type"] ? "稳定版" : "基础版";?> </td>
- <td>
- <?php echo $_var_8["status"] ? "已启用" : lightnum("未启用");?> </td>
- <td>
- <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>
- </td>
- <td>
- <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>
- </td>
- <td>
- <a href="?c=cert&a=edit&in_id=<?php echo $_var_8["in_id"];?>">编辑</a>
- </td>
- <td>
- <a href="?c=cert&a=del&in_id=<?php echo $_var_8["in_id"];?>">删除</a>
- </td>
- </tr>
- <?php
- }
- ?> <tr>
- <td class="td25">
- <input type="checkbox" id="chkall" class="checkbox" onclick="CheckAll(this.form)"/>
- <label for="chkall">全选</label></td>
- <td colspan="15">
- <div class="fixsel"><input type="submit" class="btn" name="editsave" value="批量删除"/>
- </div>
- </td>
- </tr>
- <?php
- }
- ?> </table>
- </form>
- </div>
- <?php echo $_var_4;?><?php
- }
- function edit()
- {
- $_var_9 = SafeRequest("in_id", "get");
- $_var_10 = db("cert")->where("in_id", $_var_9)->find();
- $_var_11 = $_var_9 ? $_var_10["in_dir"] : uniqid();
- $_var_12 = "/upload/cert/open?dir=" . $_var_11;
- $_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>";
- $this->editemplate($_var_13);
- ?> <script>
- function uploadComplate(data) {
- if (data.ext == 'mobileprovision') {
- $("#in_iden").val(data.iden);
- $("#in_name").val(data.name);
- $("#in_dir").val(data.dir);
- }
- $('input[name=' + data.ext + ']').val(1);
- $('.' + data.ext + ' img').show();
- layer.closeAll();
- }
- </script>
- <?php
- }
- function save()
- {
- $_var_14 = SafeRequest("in_id", "post");
- $_var_15 = SafeRequest("p12", "post");
- if (!$_var_15) {
- $this->ShowMessage("请上传p12文件", $_SERVER["HTTP_REFERER"], "infotitle3", 3000, 1);
- }
- $_var_16["p12_pwd"] = SafeRequest("p12_pwd", "post");
- if (!$_var_16["p12_pwd"]) {
- $this->ShowMessage("请输入p12密码", $_SERVER["HTTP_REFERER"], "infotitle3", 3000, 1);
- }
- $_var_17 = SafeRequest("mobileprovision", "post");
- if (!$_var_17) {
- $this->ShowMessage("请上传描述文件", $_SERVER["HTTP_REFERER"], "infotitle3", 3000, 1);
- }
- $_var_16["in_iden"] = SafeRequest("in_iden", "post");
- $_var_16["in_name"] = SafeRequest("in_name", "post");
- $_var_18 = [];
- $_var_14 && ($_var_18[] = ["in_id", "<>", $_var_14]);
- if (db("cert")->where($_var_18)->where("in_name", $_var_16["in_name"])->count()) {
- $this->ShowMessage("证书名称已存在", $_SERVER["HTTP_REFERER"], "infotitle3", 3000, 1);
- }
- $_var_16["in_dir"] = SafeRequest("in_dir", "post");
- $_var_16["p12_pwd"] = SafeRequest("p12_pwd", "post");
- $_var_16["type"] = SafeRequest("type", "post");
- if ($_var_14) {
- $_var_19 = db("cert")->strict(false)->where("in_id", $_var_14)->update($_var_16);
- } else {
- $_var_19 = db("cert")->strict(false)->insert($_var_16);
- }
- if ($_var_19) {
- $_var_20 = $_var_16["in_dir"];
- $_var_21 = IN_TMP_PATH . $_var_20 . "/";
- $_var_22 = IN_CERT_PATH . $_var_20 . ".zip";
- $_var_23 = new PclZip($_var_22);
- $_var_23->create($_var_21, PCLZIP_OPT_REMOVE_PATH, $_var_21);
- }
- $this->ShowMessage("恭喜您,保存成功!", "?c=cert", "infotitle2", 1000, 1);
- }
- function del()
- {
- $_var_24 = SafeRequest("in_id", "post") ?? explode(",", SafeRequest("in_id", "get"));
- foreach ($_var_24 as $_var_25) {
- $_var_26 = db("cert")->where("in_id", $_var_25)->value("in_dir");
- @unlink("data/cert/" . $_var_26 . ".zip");
- db("cert")->where("in_id", $_var_25)->delete();
- }
- $this->ShowMessage("恭喜您,证书删除成功!", "?c=cert", "infotitle2", 3000, 1);
- }
- function type()
- {
- $_var_27 = intval(SafeRequest("in_id", "get"));
- $_var_28 = intval(SafeRequest("v", "get"));
- $_var_29 = db("cert")->where("in_id", $_var_27)->update(["type" => $_var_28]);
- $_var_30 = $_var_28 ? "稳定版" : "基础版";
- $this->ShowMessage("恭喜您,证书已切换为" . $_var_30 . "!", "?c=cert", "infotitle2", 3000, 1);
- }
- function status()
- {
- $_var_31 = intval(SafeRequest("in_id", "get"));
- $_var_32 = intval(SafeRequest("v", "get"));
- $_var_33 = db("cert")->where("in_id", $_var_31)->update(["status" => $_var_32]);
- $_var_34 = $_var_32 ? "已启用" : "已停用";
- $this->ShowMessage("恭喜您,证书" . $_var_34 . "!", "?c=cert", "infotitle2", 3000, 1);
- }
- }
|