config_sign.php 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <?php
  2. namespace app\admin;
  3. class config_sign extends Base
  4. {
  5. public function initialize()
  6. {
  7. parent::initialize();
  8. $this->Administrator(2);
  9. $this->header();
  10. }
  11. public function __destruct()
  12. {
  13. ?> <script>
  14. function setImageVal(id, val) {
  15. $('#' + id).val(val);
  16. $('#' + id + 'img').attr('src', val + "?" + (new Date().getTime())).show();
  17. $('input[data-name="' + id + '"]').val('删除');
  18. $('.layui-layer-iframe').remove();
  19. }
  20. function upload_image(name) {
  21. pop.up('no', '上传图标', '/upload/admin/open_icon?id=' + name, '406px', '180px', '175px');
  22. }
  23. $('.rssbutton input[type="button"]').click(function () {
  24. var name = $(this).attr('data-name');
  25. if ($(this).val() === '上传') {
  26. upload_image(name)
  27. } else {
  28. $('input[name="' + name + '"]').val('');
  29. $('#' + name + 'img').hide();
  30. $(this).val('上传');
  31. }
  32. });
  33. $(".list_add_btn").click(function () {
  34. var name = $(this).attr("data-name");
  35. $(this).before('<div><input type="text" name="' + name + '[]">&nbsp;[] </div>');
  36. });
  37. </script>
  38. <?php
  39. $this->footer();
  40. }
  41. function index()
  42. {
  43. ?> <script>
  44. layui.use('layer', function () {
  45. layer = layui.layer;
  46. in_sign_worker('status');
  47. });
  48. function in_sign_worker(action, update) {
  49. $.post("?c=worker&a=" + action, function (ret) {
  50. if (action == 'logs') {
  51. if (update) {
  52. $("#worker_logs").html(ret.msg);
  53. } else {
  54. layer.open({
  55. type: 1,
  56. skin: 'layui-layer-rim', //加上边框
  57. area: ['800px', '600px'], //宽高
  58. content: '<div id="worker_logs" style="padding: 5px;">' + ret.msg + '</div>'
  59. });
  60. }
  61. } else {
  62. if (ret.msg) layer.msg(ret.msg);
  63. $('#IN_SIGN_WORKER').text(ret.code == 1 ? '启动' : '停止');
  64. }
  65. }, 'json');
  66. }
  67. // var si = setInterval(function () {
  68. // in_sign_worker('logs', true);
  69. // }, 1000);
  70. </script>
  71. <?php
  72. $_var_0 = $this->action != "index" ? $this->action : "system";
  73. $_var_1 = db("config")->where("category", $_var_0)->where("status", "1");
  74. $_var_2 = $_var_1->group("group")->field("group")->select()->toArray();
  75. $_var_2 = array_column($_var_2, "group");
  76. ?><form method="post" action="?c=config_setting&a=save">
  77. <input type="hidden" name="hash" value="<?php echo $_COOKIE["in_adminpassword"];?>" />
  78. <div class="container"><?php
  79. $this->nav3();
  80. ?><table class="tb tb2"><?php
  81. foreach ($_var_2 as $_var_3) {
  82. ?><tr><th colspan="15" class="partition"><?php echo $_var_3;?></th></tr><?php
  83. $_var_4 = db("config")->where("category", $_var_0)->where("group", $_var_3)->where("status", "1")->order("category,sort,name")->select();
  84. foreach ($_var_4 as $_var_5 => $_var_6) {
  85. $_var_7 = json_decode($_var_6["content"], true);
  86. $_var_8 = strtoupper($_var_6["name"]);
  87. ?><tr><td colspan="2" class="td27"><?php echo $_var_6["title"] ? $_var_6["title"] : $_var_8;?>:</td></tr><tr><td class="vtop rowform"><?php
  88. if ($_var_6["type"] == "checkbox") {
  89. $_var_6["value"] = json_decode($_var_6["value"], true);
  90. foreach ($_var_7 as $_var_9 => $_var_10) {
  91. $_var_11 = in_array($_var_9, $_var_6["value"]) ? " checked " : "";
  92. $_var_12 = $_var_9 == 0 ? "hidden" : $_var_6["type"];
  93. ?><label class="<?php echo $_var_11;?>"><input class="<?php echo $_var_12;?>" type="<?php echo $_var_12;?>" name="<?php echo $_var_8;?>[]" value="<?php echo $_var_9;?>" <?php echo $_var_11;?>>&nbsp;<?php echo $_var_9 == 0 ? "" : $_var_10;?></label><?php
  94. }
  95. } elseif ($_var_6["type"] == "button_group") {
  96. ?><div style='line-height: 30px'>当前状态:<span id='<?php echo $_var_8;?>'></span></div><?php
  97. foreach ($_var_7 as $_var_9 => $_var_10) {
  98. $_var_11 = $_var_6["value"] == $_var_9 ? " checked " : "";
  99. ?><input class="{$checked} btn" type="button" value="<?php echo $_var_10;?>" <?php echo $_var_11;?> onclick="<?php echo strtolower($_var_8);?>('<?php echo $_var_9;?>')" title="<?php echo $_var_10;?>" style="margin-right:5px;"><?php
  100. }
  101. } elseif ($_var_6["type"] == "json") {
  102. $_var_6["value"] = json_decode($_var_6["value"], true);
  103. foreach ($_var_6["value"] as $_var_9 => $_var_10) {
  104. ?><div><input type="<?php echo $_var_6["type"];?>" name="<?php echo $_var_8;?>[<?php echo $_var_9;?>]" value="<?php echo $_var_10;?>" >&nbsp;[<?php echo $_var_9;?>]</div><?php
  105. }
  106. } elseif ($_var_6["type"] == "list") {
  107. $_var_6["value"] = json_decode($_var_6["value"], true);
  108. $_var_13 = json_decode($_var_6["note"], true);
  109. foreach ($_var_6["value"] as $_var_9 => $_var_10) {
  110. ?><div><input type="<?php echo $_var_6["type"];?>" name="<?php echo $_var_8;?>[]" value="<?php echo $_var_10;?>" >&nbsp;[<?php echo is_array($_var_13) && isset($_var_13[$_var_9]) ? $_var_13[$_var_9] : $_var_9;?>] </div><?php
  111. }
  112. } elseif ($_var_6["type"] == "number") {
  113. ?><input class="txt" type="<?php echo $_var_6["type"];?>" name="<?php echo $_var_8;?>" value="<?php echo $_var_6["value"];?>" min="<?php echo $_var_7[0];?>" max="<?php echo $_var_7[1];?>"/><?php
  114. } elseif ($_var_6["type"] == "radio") {
  115. foreach ($_var_7 as $_var_9 => $_var_10) {
  116. $_var_11 = $_var_6["value"] == $_var_9 ? " checked " : "";
  117. ?><label class="<?php echo $_var_11;?>"><input class="<?php echo $_var_6["type"];?>" type="<?php echo $_var_6["type"];?>" name="<?php echo $_var_8;?>" value="<?php echo $_var_9;?>" <?php echo $_var_11;?>>&nbsp;<?php echo $_var_10;?></label><?php
  118. }
  119. } elseif ($_var_6["type"] == "select") {
  120. ?><select name="<?php echo $_var_6["name"];?>"><?php
  121. foreach ($_var_7 as $_var_9 => $_var_10) {
  122. $_var_14 = $_var_6["value"] == $_var_9 ? " selected " : "";
  123. ?><option value="<?php echo $_var_9;?>" <?php echo $_var_14;?>><?php echo $_var_10;?></option><?php
  124. }
  125. ?></select><?php
  126. } elseif ($_var_6["type"] == "textarea") {
  127. ?><textarea rows="6" name="<?php echo $_var_6["name"];?>" cols="50" class="tarea"><?php echo $_var_6["value"];?></textarea><?php
  128. } elseif ($_var_6["type"] == "image") {
  129. ?><input name="<?php echo $_var_6["name"];?>" type="hidden" class="txt" value="<?php echo $_var_6["value"];?>" id="<?php echo $_var_6["name"];?>">
  130. <div>
  131. <div class="rssbutton">
  132. <img id="<?php echo $_var_6["name"];?>img" src="/<?php echo $_var_6["value"];?>?<?php echo time();?>" width="90" height="90" alt="" <?php echo $_var_6["value"] ? "" : "style=\"display: none\"";?>/>
  133. </div>
  134. <div class="rssbutton">
  135. <input type="button" value="<?php echo $_var_6["value"] ? "删除" : "上传";?>" data-name="<?php echo $_var_6["name"];?>" style="line-height: 12px">
  136. </div>
  137. </div><?php
  138. } else {
  139. ?><input class="txt" type="<?php echo $_var_6["type"];?>" name="<?php echo $_var_8;?>" value="<?php echo $_var_6["value"];?>" /><?php
  140. }
  141. ?></td><td class="vtop tips2 <?php echo $_var_6["require"] ? "lightnum" : "";?>"><?php echo $_var_6["note"];?></td></tr><?php
  142. }
  143. }
  144. ?> <tr><td colspan="15"><div class="fixsel"><input type="submit" class="btn" value="提交" /></div></td></tr></table >
  145. </div >
  146. </form ><?php
  147. }
  148. function save()
  149. {
  150. if (!submitcheck("hash", 1)) {
  151. $this->ShowMessage("表单来路不明,无法提交!", $_SERVER["PHP_SELF"], "infotitle3", 3000, 1);
  152. }
  153. foreach ($_POST as $_var_15 => $_var_16) {
  154. if (is_array($_var_16)) {
  155. $_var_16 = json_encode($_var_16);
  156. }
  157. db("config")->where("name", $_var_15)->update(["value" => $_var_16]);
  158. }
  159. $_var_17 = db("config")->select();
  160. $_var_18 = ["<?php"];
  161. foreach ($_var_17 as $_var_15 => $_var_16) {
  162. if ($_var_16["name"] == "IN_STAT") {
  163. $_var_16["value"] = base64_encode($_var_16["value"]);
  164. }
  165. $_var_18[] = "define('" . $_var_16["name"] . "','" . $_var_16["value"] . "');";
  166. }
  167. $_var_19 = IN_ROOT . "source/system/my.php";
  168. file_put_contents($_var_19, implode("\n", $_var_18));
  169. $this->ShowMessage("恭喜您,设置保存成功!", $_SERVER["HTTP_REFERER"], "infotitle2", 1000, 1);
  170. }
  171. }