config_setting.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. <?php
  2. namespace app\admin;
  3. class config_setting extends Base
  4. {
  5. public function initialize()
  6. {
  7. parent::initialize();
  8. $this->Administrator(2);
  9. }
  10. public function __destruct()
  11. {
  12. }
  13. function index()
  14. { $this->header();
  15. $this->footer();
  16. ?> <script>
  17. layui.use('layer', function () {
  18. layer = layui.layer;
  19. in_sign_worker('status');
  20. });
  21. function in_sign_worker(action, update) {
  22. $.post("?c=worker&a=" + action, function (ret) {
  23. if (action == 'logs') {
  24. if (update) {
  25. $("#worker_logs").html(ret.msg);
  26. } else {
  27. layer.open({
  28. type: 1,
  29. skin: 'layui-layer-rim', //加上边框
  30. area: ['800px', '600px'], //宽高
  31. content: '<div id="worker_logs" style="padding: 5px;">' + ret.msg + '</div>'
  32. });
  33. }
  34. } else {
  35. if (ret.msg) layer.msg(ret.msg);
  36. $('#IN_SIGN_WORKER').text(ret.code == 1 ? '启动' : '停止');
  37. }
  38. }, 'json');
  39. }
  40. // var si = setInterval(function () {
  41. // in_sign_worker('logs', true);
  42. // }, 1000);
  43. </script>
  44. <style>
  45. textarea, input, select, .html {
  46. padding: 10px;
  47. border: 1px solid;
  48. border-color: #666 #ccc #ccc #666;
  49. background: #F9F9F9;
  50. color: #393d49;
  51. resize: none;
  52. }
  53. .rowform {
  54. width: 400px;
  55. overflow: auto;
  56. }
  57. </style>
  58. <style>
  59. #myBtn {
  60. display: none;
  61. position: fixed;
  62. bottom: 20px;
  63. right: 30px;
  64. z-index: 99;
  65. border: none;
  66. outline: none;
  67. background-color: red;
  68. color: white;
  69. cursor: pointer;
  70. padding: 15px;
  71. border-radius: 10px;
  72. }
  73. #myBtn:hover {
  74. background-color: #555;
  75. }
  76. </style>
  77. <?php
  78. $_var_0 = $this->action != "index" ? $this->action : "system";
  79. $_var_1 = db("config")->where("category", $_var_0)->where("status", "1");
  80. $_var_2 = $_var_1->group("group")->field("group")->select()->toArray();
  81. $_var_2 = array_column($_var_2, "group");
  82. ?><form method="post" action="?c=config_setting&a=save" id="form1">
  83. <input type="hidden" name="hash" value="<?php echo $_COOKIE["in_adminpassword"];?>" />
  84. <div class="container"><?php
  85. $this->nav3();
  86. ?><table class="tb tb2"><?php
  87. foreach ($_var_2 as $_var_3) {
  88. ?><tr><th colspan="15" class="partition"><?php echo $_var_3;?></th></tr><?php
  89. $_var_4 = db("config")->where("category", $_var_0)->where("group", $_var_3)->where("status", "1")->order("category,sort,name")->select();
  90. foreach ($_var_4 as $_var_5 => $_var_6) {
  91. $_var_7 = json_decode($_var_6["content"], true);
  92. $_var_8 = strtoupper($_var_6["name"]);
  93. ?><tr><td style="width:8%" class="td27"><?php echo $_var_6["title"] ? $_var_6["title"] : $_var_8;?>:</td><td class="vtop rowform"><?php
  94. if ($_var_6["type"] == "checkbox") {
  95. $_var_6["value"] = json_decode($_var_6["value"], true);
  96. foreach ($_var_7 as $_var_9 => $_var_10) {
  97. $_var_11 = in_array($_var_9, $_var_6["value"]) ? " checked " : "";
  98. $_var_12 = $_var_9 == 0 ? "hidden" : $_var_6["type"];
  99. ?><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
  100. }
  101. } elseif ($_var_6["type"] == "button_group") {
  102. ?><div style='line-height: 30px'>当前状态:<span id='<?php echo $_var_8;?>'></span></div><?php
  103. foreach ($_var_7 as $_var_9 => $_var_10) {
  104. $_var_11 = $_var_6["value"] == $_var_9 ? " checked " : "";
  105. ?><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
  106. }
  107. } elseif ($_var_6["type"] == "json") {
  108. $_var_6["value"] = json_decode($_var_6["value"], 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;?>[<?php echo $_var_9;?>]" value="<?php echo $_var_10;?>" >&nbsp;[<?php echo $_var_9;?>]</div><?php
  111. }
  112. } elseif ($_var_6["type"] == "list") {
  113. $_var_6["value"] = json_decode($_var_6["value"], true);
  114. $_var_13 = json_decode($_var_6["note"], true);
  115. foreach ($_var_6["value"] as $_var_9 => $_var_10) {
  116. ?><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
  117. }
  118. } elseif ($_var_6["type"] == "number") {
  119. ?><input class="layui-input" 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
  120. } elseif ($_var_6["type"] == "radio") {
  121. foreach ($_var_7 as $_var_9 => $_var_10) {
  122. $_var_11 = $_var_6["value"] == $_var_9 ? " checked " : "";
  123. ?><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
  124. }
  125. } elseif ($_var_6["type"] == "select") {
  126. ?><select name="<?php echo $_var_6["name"];?>"><?php
  127. foreach ($_var_7 as $_var_9 => $_var_10) {
  128. $_var_14 = $_var_6["value"] == $_var_9 ? " selected " : "";
  129. ?><option value="<?php echo $_var_9;?>" <?php echo $_var_14;?>><?php echo $_var_10;?></option><?php
  130. }
  131. ?></select><?php
  132. } elseif ($_var_6["type"] == "textarea") {
  133. ?><textarea rows="6" name="<?php echo $_var_6["name"];?>" cols="50" class="layui-textarea"><?php echo $_var_6["value"];?></textarea><?php
  134. } elseif ($_var_6["type"] == "image") {
  135. ?><input name="<?php echo $_var_6["name"];?>" type="hidden" class="layui-input" value="<?php echo $_var_6["value"];?>" id="<?php echo $_var_6["name"];?>">
  136. <div>
  137. <div class="rssbutton">
  138. <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\"";?>/>
  139. </div>
  140. <div class="rssbutton">
  141. <input type="button" value="<?php echo $_var_6["value"] ? "删除" : "上传";?>" data-name="<?php echo $_var_6["name"];?>" style="line-height: 2px">
  142. </div>
  143. </div>
  144. <script>
  145. function setImageVal(id, val) {
  146. $('#' + id).val(val);
  147. $('#' + id + 'img').attr('src', val + "?" + (new Date().getTime())).show();
  148. $('input[data-name="' + id + '"]').val('删除');
  149. $('.layui-layer-iframe').remove();
  150. }
  151. function upload_image(name) {
  152. pop.up('no', '上传图标', '/upload/admin/open_icon?id=' + name, '406px', '180px', '175px');
  153. }
  154. $('.rssbutton input[type="button"]').click(function () {
  155. var name = $(this).attr('data-name');
  156. if ($(this).val() === '上传') {
  157. upload_image(name)
  158. } else {
  159. $('input[name="' + name + '"]').val('');
  160. $('#' + name + 'img').hide();
  161. $(this).val('上传');
  162. }
  163. });
  164. $(".list_add_btn").click(function () {
  165. var name = $(this).attr("data-name");
  166. $(this).before('<div><input type="text" name="' + name + '[]">&nbsp;[] </div>');
  167. });
  168. </script><?php
  169. } else {
  170. ?><input class="layui-input" type="<?php echo $_var_6["type"];?>" name="<?php echo $_var_8;?>" value="<?php echo $_var_6["value"];?>" /><?php
  171. }
  172. ?></td><td class="vtop tips2 <?php echo $_var_6["require"] ? "lightnum" : "";?>"><?php echo $_var_6["note"];?></td></tr><?php
  173. }
  174. }
  175. ?> <tr><td colspan="15"> <div class="layui-form-item layui-layout-admin">
  176. <div class="layui-input-block">
  177. <div class="layui-footer" style="left: 0;">
  178. <button class="layui-btn" type="submit" onclick="return CheckForm1();" class="btn" value="确定" >立即提交</button>
  179. <button type="reset" class="layui-btn layui-btn-primary">重置</button>
  180. </div>
  181. </div>
  182. </div><div class="fixsel"><input type="submit" style="display:none" class="btn" value="确定" /></div></td></tr></table >
  183. </div >
  184. </form >
  185. <button onclick="topFunction()" id="myBtn" title="回顶部">返回顶部</button>
  186. <script>
  187. function CheckForm1() {
  188. $.ajax({
  189. type: 'POST',
  190. url: '?c=config_setting&a=save',
  191. data: $("#form1").serialize(),
  192. dataType: 'json',
  193. success: function (str) {
  194. if (str.status == "1") {
  195. layer.alert(str.msg,function(index){
  196. window.location.reload();
  197. });
  198. return false;
  199. /** setTimeout(function () {
  200. var index = parent.layer.getFrameIndex(window.name);
  201. parent.layer.close(index);
  202. window.parent.renderTable();
  203. }, 2000);**/
  204. }else{
  205. layer.alert(str.msg);
  206. return false;
  207. }
  208. }
  209. });
  210. return false;
  211. }
  212. </script>
  213. <?php
  214. }
  215. function save()
  216. {
  217. if (!submitcheck("hash", 1)) {
  218. //$this->ShowMessage("表单来路不明,无法提交!", $_SERVER["PHP_SELF"], "infotitle3", 3000, 1);
  219. }
  220. //var_dump('<pre>',$_POST);die;
  221. foreach ($_POST as $_var_15 => $_var_16) {
  222. if (is_array($_var_16)) {
  223. $_var_16 = json_encode($_var_16);
  224. }
  225. db("config")->where("name", $_var_15)->update(["value" => $_var_16]);
  226. }
  227. $_var_17 = db("config")->select();
  228. $_var_18 = ["<?php"];
  229. foreach ($_var_17 as $_var_15 => $_var_16) {
  230. if ($_var_16["name"] == "IN_STAT") {
  231. $_var_16["value"] = base64_encode($_var_16["value"]);
  232. }
  233. $_var_18[] = "define('" . $_var_16["name"] . "','" . $_var_16["value"] . "');";
  234. }
  235. $_var_19 = IN_ROOT . "source/system/my.php";
  236. file_put_contents($_var_19, implode("\n", $_var_18));
  237. echo json_encode(['status'=>1,'msg'=>'恭喜您,设置保存成功!']);die;
  238. $this->ShowMessage("恭喜您,设置保存成功!", $_SERVER["HTTP_REFERER"], "infotitle2", 1000, 1);
  239. }
  240. }