123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- <?php
- // by 请勿倒卖,已申请软著,否则追究法律责任
- namespace app\admin;
- class secret extends Base
- {
- public function initialize()
- {
- parent::initialize();
- $this->Administrator(3);
- if ($this->action == "edit") {
- }
- $this->header();
- }
- public function __destruct()
- {
- $this->footer();
- }
- function index($_var_0 = [])
- {
- $_var_1 = db("secret")->order("in_id desc")->select();
- $_var_2 = db("secret")->count();
- ?><div class="container"><?php
- $this->nav3();
- ?><table class="tb tb2">
- <tr><th class="partition">授权列表</th></tr>
- </table>
- <table class="tb tb2">
- <tr class="header">
- <th>编号</th>
- <th>授权域名</th>
- <th>授权密匙</th>
- <th>余额</th>
- <th>基础价格</th>
- <th>稳定价格</th>
- <th>开通时间</th>
- <th>到期时间</th>
- <th>授权状态</th>
- <th>操作</th>
- </tr>
- <?php
- if ($_var_2 == 0) {
- ?><tr><td colspan="2" class="td27">没有授权</td></tr>
- <?php
- } else {
- foreach ($_var_1 as $_var_3) {
- ?><tr class="hover">
- <td class="td25"><?php echo $_var_3["in_id"];?></td>
- <td class="td29"><?php echo $_var_3["in_site"];?></td>
- <td class="td29"><?php echo $_var_3["in_md5"];?></td>
- <td class="td29"><?php echo $_var_3["money"];?></td>
- <td class="td29"><?php echo $_var_3["price"];?></td>
- <td class="td29"><?php echo $_var_3["price1"];?></td>
- <td class="td29"><?php echo date("Y-m-d", $_var_3["in_addtime"]);?></td>
- <td class="td29"><?php echo date("Y-m-d", $_var_3["in_endtime"]);?></td>
- <td><div class="parentboard"><?php
- if ($_var_3["in_endtime"] < time()) {
- ?><?php echo lightnum("已过期");?><?php
- } else {
- ?>授权中<?php
- }
- ?></div></td>
- <td><a href="?c=secret&a=edit&in_id=<?php echo $_var_3["in_id"];?>">编辑</a></td>
- <td><a href="?c=secret&a=del&in_id=<?php echo $_var_3["in_id"];?>">删除</a></td>
- </tr>
- <?php
- }
- }
- ?></table>
- </div>
- <?php
- }
- function del()
- {
- $_var_4 = intval(SafeRequest("in_id", "get"));
- db("secret")->where("in_id", $_var_4)->delete();
- $this->ShowMessage("恭喜您,授权删除成功!", "?c=secret", "infotitle2", 3000, 1);
- }
- function edit()
- {
- $_var_5 = SafeRequest("in_id", "get");
- $_var_6 = $_var_5 ? "编辑" : "新增";
- $_var_7 = db("secret")->where("in_id", $_var_5)->find();
- ?><div class="container"><?php
- $this->nav3();
- ?><table class="tb tb2">
- <form action="?c=secret&a=save" method="post" name="form">
- <input type="hidden" name="in_id" value="<?php echo $_var_5;?>"/>
- <input type="hidden" name="hash" value="<?php echo $_COOKIE["in_adminpassword"];?>" />
- <tr><th colspan="15" class="partition"><?php echo $_var_6;?>授权</th></tr>
- <tr><td colspan="2" class="td27">授权域名:</td></tr>
- <tr><td class="vtop rowform">
- <input type="text" class="txt" value="<?php echo $_var_7["in_site"];?>" name="in_site" id="in_site">
- </td>
- </tr>
- <tr><td colspan="2" class="td27">授权密钥:</td></tr>
- <tr><td class="vtop rowform">
- <input type="text" class="txt" name="in_md5" id="in_md5" value="<?php echo $_var_7["in_md5"] ?: md5(time());?>" readonly="readonly" style="background: #eee"><a href="javascript:;" onclick="randomSecret()">刷新</a>
- </td>
- </tr>
- <tr><td colspan="2" class="td27">余额:</td></tr>
- <tr><td class="vtop rowform">
- <input type="number" class="txt" name="money" id="money" value="<?php echo $_var_7["money"] ?: 0;?>">
- </td>
- </tr>
- <tr><td colspan="2" class="td27">基础价格:</td></tr>
- <tr><td class="vtop rowform">
- <input type="number" class="txt" name="price" id="price" value="<?php echo $_var_7["price"] ?: 0;?>">
- </td>
- </tr>
- <tr><td colspan="2" class="td27">稳定价格:</td></tr>
- <tr><td class="vtop rowform">
- <input type="number" class="txt" name="price1" id="price1" value="<?php echo $_var_7["price1"] ?: 0;?>">
- </td>
- </tr>
- <tr><td colspan="2" class="td27">到期时间:</td></tr>
- <tr><td class="vtop rowform">
- <input type="datetime" class="txt" name="in_endtime" id="in_endtime" value="">
- </td>
- </tr>
- <tr><td colspan="15">
- <div class="fixsel">
- <input type="submit" class="btn" onclick="return CheckForm();" value="提交" />
- </div>
- </td></tr>
- </form>
- </table>
- </div>
- <script src="/static/pack/layui/layui.js"></script>
- <script>
- $('#in_site').on('input', function () {
- randomSecret();
- });
- layui.use('laydate', function () {
- var laydate = layui.laydate;
- //执行一个laydate实例
- laydate.render({
- elem: '#in_endtime', //指定元素
- type: 'datetime',
- value: "<?php echo date("Y-m-d H:i:s", max($_var_7["in_endtime"], time()));?>"
- });
- });
- function randomString(len) {
- len = len || 32;
- var $chars = 'abcdefhijkmnprstwxyz2345678';
- /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/
- var maxPos = $chars.length;
- var pwd = '';
- for (i = 0; i < len; i++) {
- pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
- }
- return pwd;
- }
- function randomSecret() {
- $('#in_md5').val(randomString())
- }
- </script>
- <?php
- }
- function save()
- {
- $_var_8 = SafeRequest("in_id", "post");
- $_var_9 = SafeRequest("in_site", "post");
- $_var_9 = str_replace("www.", "", $_var_9);
- if (empty($_var_9)) {
- $this->ShowMessage("保存出错,授权域名不能为空!", "?c=secret&a=edit", "infotitle3", 1000, 1);
- }
- if (db("secret")->where("in_site", $_var_9)->where("in_id", "<>", $_var_8)->value("in_id")) {
- $this->ShowMessage("保存出错,授权域名已存在!", "?c=secret&a=edit", "infotitle3", 1000, 1);
- }
- $_var_10 = SafeRequest("in_md5", "post");
- $_var_11 = SafeRequest("money", "post");
- if (!is_numeric($_var_11) || $_var_11 < 0) {
- $this->ShowMessage("余额只能是大于0的数字", "?c=secret&a=edit", "infotitle3", 1000, 1);
- }
- $_var_12 = SafeRequest("price", "post");
- if (!is_numeric($_var_12) || $_var_12 < 0) {
- $this->ShowMessage("基础价格只能是大于0的数字", "?c=secret&a=edit", "infotitle3", 1000, 1);
- }
- $_var_13 = SafeRequest("price1", "post");
- if (!is_numeric($_var_13) || $_var_13 < 0) {
- $this->ShowMessage("稳定价格只能是大于0的数字", "?c=secret&a=edit", "infotitle3", 1000, 1);
- }
- $_var_14 = SafeRequest("in_endtime", "post");
- $_var_15["in_site"] = $_var_9;
- $_var_15["in_md5"] = $_var_10;
- $_var_15["money"] = $_var_11;
- $_var_15["price"] = $_var_12;
- $_var_15["price1"] = $_var_13;
- $_var_15["in_endtime"] = strtotime($_var_14);
- if ($_var_8) {
- db("secret")->where("in_id", $_var_8)->update($_var_15);
- } else {
- $_var_15["in_addtime"] = time();
- db("secret")->insertGetId($_var_15);
- }
- $this->ShowMessage("恭喜您,授权保存成功!", "?c=secret", "infotitle2", 1000, 1);
- }
- function extend()
- {
- $_var_16 = intval(SafeRequest("in_id", "get"));
- $_var_17 = intval(SafeRequest("month", "get") ?: 1);
- $_var_18 = db("secret")->where("in_id", $_var_16)->find();
- $_var_19 = strtotime("+ " . $_var_17 . " month", max($_var_18["in_endtime"], time()));
- db("secret")->where("in_id", $_var_16)->update(["in_endtime" => $_var_19]);
- $_var_19 = date("Y-m-d", $_var_19);
- $this->ShowMessage("恭喜您,已为 " . $_var_18["in_site"] . " 续期至 " . $_var_19 . " !", "?c=secret", "infotitle2", 3000, 1);
- }
- function reset()
- {
- $_var_20 = intval(SafeRequest("in_id", "get"));
- $_var_21 = db("secret")->where("in_id", $_var_20)->find();
- db("secret")->where("in_id", $_var_20)->update(["in_md5" => md5(time() . $_var_21["in_site"] . time())]);
- $this->ShowMessage("恭喜您,已为 " . $_var_21["in_site"] . " 重置密钥 !", "?c=secret", "infotitle2", 3000, 1);
- }
- }
|