secret.php 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <?php
  2. // by 请勿倒卖,已申请软著,否则追究法律责任
  3. namespace app\admin;
  4. class secret extends Base
  5. {
  6. public function initialize()
  7. {
  8. parent::initialize();
  9. $this->Administrator(3);
  10. if ($this->action == "edit") {
  11. }
  12. $this->header();
  13. }
  14. public function __destruct()
  15. {
  16. $this->footer();
  17. }
  18. function index($_var_0 = [])
  19. {
  20. $_var_1 = db("secret")->order("in_id desc")->select();
  21. $_var_2 = db("secret")->count();
  22. ?><div class="container"><?php
  23. $this->nav3();
  24. ?><table class="tb tb2">
  25. <tr><th class="partition">授权列表</th></tr>
  26. </table>
  27. <table class="tb tb2">
  28. <tr class="header">
  29. <th>编号</th>
  30. <th>授权域名</th>
  31. <th>授权密匙</th>
  32. <th>余额</th>
  33. <th>基础价格</th>
  34. <th>稳定价格</th>
  35. <th>开通时间</th>
  36. <th>到期时间</th>
  37. <th>授权状态</th>
  38. <th>操作</th>
  39. </tr>
  40. <?php
  41. if ($_var_2 == 0) {
  42. ?><tr><td colspan="2" class="td27">没有授权</td></tr>
  43. <?php
  44. } else {
  45. foreach ($_var_1 as $_var_3) {
  46. ?><tr class="hover">
  47. <td class="td25"><?php echo $_var_3["in_id"];?></td>
  48. <td class="td29"><?php echo $_var_3["in_site"];?></td>
  49. <td class="td29"><?php echo $_var_3["in_md5"];?></td>
  50. <td class="td29"><?php echo $_var_3["money"];?></td>
  51. <td class="td29"><?php echo $_var_3["price"];?></td>
  52. <td class="td29"><?php echo $_var_3["price1"];?></td>
  53. <td class="td29"><?php echo date("Y-m-d", $_var_3["in_addtime"]);?></td>
  54. <td class="td29"><?php echo date("Y-m-d", $_var_3["in_endtime"]);?></td>
  55. <td><div class="parentboard"><?php
  56. if ($_var_3["in_endtime"] < time()) {
  57. ?><?php echo lightnum("已过期");?><?php
  58. } else {
  59. ?>授权中<?php
  60. }
  61. ?></div></td>
  62. <td><a href="?c=secret&a=edit&in_id=<?php echo $_var_3["in_id"];?>">编辑</a></td>
  63. <td><a href="?c=secret&a=del&in_id=<?php echo $_var_3["in_id"];?>">删除</a></td>
  64. </tr>
  65. <?php
  66. }
  67. }
  68. ?></table>
  69. </div>
  70. <?php
  71. }
  72. function del()
  73. {
  74. $_var_4 = intval(SafeRequest("in_id", "get"));
  75. db("secret")->where("in_id", $_var_4)->delete();
  76. $this->ShowMessage("恭喜您,授权删除成功!", "?c=secret", "infotitle2", 3000, 1);
  77. }
  78. function edit()
  79. {
  80. $_var_5 = SafeRequest("in_id", "get");
  81. $_var_6 = $_var_5 ? "编辑" : "新增";
  82. $_var_7 = db("secret")->where("in_id", $_var_5)->find();
  83. ?><div class="container"><?php
  84. $this->nav3();
  85. ?><table class="tb tb2">
  86. <form action="?c=secret&a=save" method="post" name="form">
  87. <input type="hidden" name="in_id" value="<?php echo $_var_5;?>"/>
  88. <input type="hidden" name="hash" value="<?php echo $_COOKIE["in_adminpassword"];?>" />
  89. <tr><th colspan="15" class="partition"><?php echo $_var_6;?>授权</th></tr>
  90. <tr><td colspan="2" class="td27">授权域名:</td></tr>
  91. <tr><td class="vtop rowform">
  92. <input type="text" class="txt" value="<?php echo $_var_7["in_site"];?>" name="in_site" id="in_site">
  93. </td>
  94. </tr>
  95. <tr><td colspan="2" class="td27">授权密钥:</td></tr>
  96. <tr><td class="vtop rowform">
  97. <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>
  98. </td>
  99. </tr>
  100. <tr><td colspan="2" class="td27">余额:</td></tr>
  101. <tr><td class="vtop rowform">
  102. <input type="number" class="txt" name="money" id="money" value="<?php echo $_var_7["money"] ?: 0;?>">
  103. </td>
  104. </tr>
  105. <tr><td colspan="2" class="td27">基础价格:</td></tr>
  106. <tr><td class="vtop rowform">
  107. <input type="number" class="txt" name="price" id="price" value="<?php echo $_var_7["price"] ?: 0;?>">
  108. </td>
  109. </tr>
  110. <tr><td colspan="2" class="td27">稳定价格:</td></tr>
  111. <tr><td class="vtop rowform">
  112. <input type="number" class="txt" name="price1" id="price1" value="<?php echo $_var_7["price1"] ?: 0;?>">
  113. </td>
  114. </tr>
  115. <tr><td colspan="2" class="td27">到期时间:</td></tr>
  116. <tr><td class="vtop rowform">
  117. <input type="datetime" class="txt" name="in_endtime" id="in_endtime" value="">
  118. </td>
  119. </tr>
  120. <tr><td colspan="15">
  121. <div class="fixsel">
  122. <input type="submit" class="btn" onclick="return CheckForm();" value="提交" />
  123. </div>
  124. </td></tr>
  125. </form>
  126. </table>
  127. </div>
  128. <script src="/static/pack/layui/layui.js"></script>
  129. <script>
  130. $('#in_site').on('input', function () {
  131. randomSecret();
  132. });
  133. layui.use('laydate', function () {
  134. var laydate = layui.laydate;
  135. //执行一个laydate实例
  136. laydate.render({
  137. elem: '#in_endtime', //指定元素
  138. type: 'datetime',
  139. value: "<?php echo date("Y-m-d H:i:s", max($_var_7["in_endtime"], time()));?>"
  140. });
  141. });
  142. function randomString(len) {
  143. len = len || 32;
  144. var $chars = 'abcdefhijkmnprstwxyz2345678';
  145. /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/
  146. var maxPos = $chars.length;
  147. var pwd = '';
  148. for (i = 0; i < len; i++) {
  149. pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
  150. }
  151. return pwd;
  152. }
  153. function randomSecret() {
  154. $('#in_md5').val(randomString())
  155. }
  156. </script>
  157. <?php
  158. }
  159. function save()
  160. {
  161. $_var_8 = SafeRequest("in_id", "post");
  162. $_var_9 = SafeRequest("in_site", "post");
  163. $_var_9 = str_replace("www.", "", $_var_9);
  164. if (empty($_var_9)) {
  165. $this->ShowMessage("保存出错,授权域名不能为空!", "?c=secret&a=edit", "infotitle3", 1000, 1);
  166. }
  167. if (db("secret")->where("in_site", $_var_9)->where("in_id", "<>", $_var_8)->value("in_id")) {
  168. $this->ShowMessage("保存出错,授权域名已存在!", "?c=secret&a=edit", "infotitle3", 1000, 1);
  169. }
  170. $_var_10 = SafeRequest("in_md5", "post");
  171. $_var_11 = SafeRequest("money", "post");
  172. if (!is_numeric($_var_11) || $_var_11 < 0) {
  173. $this->ShowMessage("余额只能是大于0的数字", "?c=secret&a=edit", "infotitle3", 1000, 1);
  174. }
  175. $_var_12 = SafeRequest("price", "post");
  176. if (!is_numeric($_var_12) || $_var_12 < 0) {
  177. $this->ShowMessage("基础价格只能是大于0的数字", "?c=secret&a=edit", "infotitle3", 1000, 1);
  178. }
  179. $_var_13 = SafeRequest("price1", "post");
  180. if (!is_numeric($_var_13) || $_var_13 < 0) {
  181. $this->ShowMessage("稳定价格只能是大于0的数字", "?c=secret&a=edit", "infotitle3", 1000, 1);
  182. }
  183. $_var_14 = SafeRequest("in_endtime", "post");
  184. $_var_15["in_site"] = $_var_9;
  185. $_var_15["in_md5"] = $_var_10;
  186. $_var_15["money"] = $_var_11;
  187. $_var_15["price"] = $_var_12;
  188. $_var_15["price1"] = $_var_13;
  189. $_var_15["in_endtime"] = strtotime($_var_14);
  190. if ($_var_8) {
  191. db("secret")->where("in_id", $_var_8)->update($_var_15);
  192. } else {
  193. $_var_15["in_addtime"] = time();
  194. db("secret")->insertGetId($_var_15);
  195. }
  196. $this->ShowMessage("恭喜您,授权保存成功!", "?c=secret", "infotitle2", 1000, 1);
  197. }
  198. function extend()
  199. {
  200. $_var_16 = intval(SafeRequest("in_id", "get"));
  201. $_var_17 = intval(SafeRequest("month", "get") ?: 1);
  202. $_var_18 = db("secret")->where("in_id", $_var_16)->find();
  203. $_var_19 = strtotime("+ " . $_var_17 . " month", max($_var_18["in_endtime"], time()));
  204. db("secret")->where("in_id", $_var_16)->update(["in_endtime" => $_var_19]);
  205. $_var_19 = date("Y-m-d", $_var_19);
  206. $this->ShowMessage("恭喜您,已为 " . $_var_18["in_site"] . " 续期至 " . $_var_19 . " !", "?c=secret", "infotitle2", 3000, 1);
  207. }
  208. function reset()
  209. {
  210. $_var_20 = intval(SafeRequest("in_id", "get"));
  211. $_var_21 = db("secret")->where("in_id", $_var_20)->find();
  212. db("secret")->where("in_id", $_var_20)->update(["in_md5" => md5(time() . $_var_21["in_site"] . time())]);
  213. $this->ShowMessage("恭喜您,已为 " . $_var_21["in_site"] . " 重置密钥 !", "?c=secret", "infotitle2", 3000, 1);
  214. }
  215. }