You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

201 lines
8.7 KiB

3 years ago
  1. /*
  2. *宝塔面板去除各种计算题与延时等待
  3. */
  4. if("undefined" != typeof bt && bt.hasOwnProperty("show_confirm")){
  5. bt.show_confirm = function(title, msg, fun, error) {
  6. if (error == undefined) {
  7. error = ""
  8. }
  9. var mess = layer.open({
  10. type: 1,
  11. title: title,
  12. area: "350px",
  13. closeBtn: 2,
  14. shadeClose: true,
  15. content: "<div class='bt-form webDelete pd20 pb70'><p>" + msg + "</p>" + error + "<div class='bt-form-submit-btn'><button type='button' class='btn btn-danger btn-sm bt-cancel'>" + lan.public.cancel + "</button> <button type='button' id='toSubmit' class='btn btn-success btn-sm' >" + lan.public.ok + "</button></div></div>"
  16. });
  17. $(".bt-cancel").click(function () {
  18. layer.close(mess);
  19. });
  20. $("#toSubmit").click(function () {
  21. layer.close(mess);
  22. fun();
  23. })
  24. }
  25. }
  26. if("undefined" != typeof bt && bt.hasOwnProperty("prompt_confirm")){
  27. bt.prompt_confirm = function (title, msg, callback) {
  28. layer.open({
  29. type: 1,
  30. title: title,
  31. area: "350px",
  32. closeBtn: 2,
  33. btn: ['确认', '取消'],
  34. content: "<div class='bt-form promptDelete pd20'>\
  35. <p>" + msg + "</p>\
  36. </div>",
  37. yes: function (layers, index) {
  38. layer.close(layers)
  39. if (callback) callback()
  40. }
  41. });
  42. }
  43. }
  44. if("undefined" != typeof database && database.hasOwnProperty("del_database")){
  45. database.del_database = function (wid, dbname,obj, callback) {
  46. var tips = '是否确认【删除数据库】,删除后可能会影响业务使用!';
  47. if(obj && obj.db_type > 0) tips = '远程数据库不支持数据库回收站,删除后将无法恢复,请谨慎操作';
  48. var title = typeof dbname === "function" ?'批量删除数据库':'删除数据库 [ '+ dbname +' ]';
  49. layer.open({
  50. type:1,
  51. title:title,
  52. icon:0,
  53. skin:'delete_site_layer',
  54. area: "530px",
  55. closeBtn: 2,
  56. shadeClose: true,
  57. content:"<div class=\'bt-form webDelete pd30\' id=\'site_delete_form\'>" +
  58. "<i class=\'layui-layer-ico layui-layer-ico0\'></i>" +
  59. "<div class=\'f13 check_title\' style=\'margin-bottom: 20px;\'>"+tips+"</div>" +
  60. "<div style=\'color:red;margin:18px 0 18px 18px;font-size:14px;font-weight: bold;\'>注意:数据无价,请谨慎操作!!!"+(!recycle_bin_db_open?'<br>风险操作:当前数据库回收站未开启,删除数据库将永久消失!':'')+"</div>" +
  61. "</div>",
  62. btn:[lan.public.ok,lan.public.cancel],
  63. yes:function(indexs){
  64. var data = {id: wid,name: dbname};
  65. if(typeof dbname === "function"){
  66. delete data.id;
  67. delete data.name;
  68. }
  69. layer.close(indexs)
  70. if(typeof dbname === "function"){
  71. dbname(data)
  72. }else{
  73. bt.database.del_database(data, function (rdata) {
  74. layer.closeAll()
  75. if (rdata.status) database_table.$refresh_table_list(true);
  76. if (callback) callback(rdata);
  77. bt.msg(rdata);
  78. })
  79. }
  80. }
  81. })
  82. }
  83. }
  84. if("undefined" != typeof site && site.hasOwnProperty("del_site")){
  85. site.del_site = function(wid, wname, callback) {
  86. var title = typeof wname === "function" ?'批量删除站点':'删除站点 [ '+ wname +' ]';
  87. layer.open({
  88. type:1,
  89. title:title,
  90. icon:0,
  91. skin:'delete_site_layer',
  92. area: "440px",
  93. closeBtn: 2,
  94. shadeClose: true,
  95. content:"<div class=\'bt-form webDelete pd30\' id=\'site_delete_form\'>" +
  96. '<i class="layui-layer-ico layui-layer-ico0"></i>' +
  97. "<div class=\'f13 check_title\'>是否要删除关联的FTP、数据库、站点目录!</div>" +
  98. "<div class=\"check_type_group\">" +
  99. "<label><input type=\"checkbox\" name=\"ftp\"><span>FTP</span></label>" +
  100. "<label><input type=\"checkbox\" name=\"database\"><span>数据库</span>"+ (!recycle_bin_db_open?'<span class="glyphicon glyphicon-info-sign" style="color: red"></span>':'') +"</label>" +
  101. "<label><input type=\"checkbox\" name=\"path\"><span>站点目录</span>"+ (!recycle_bin_open?'<span class="glyphicon glyphicon-info-sign" style="color: red"></span>':'') +"</label>" +
  102. "</div>"+
  103. "</div>",
  104. btn:[lan.public.ok,lan.public.cancel],
  105. success:function(layers,indexs){
  106. $(layers).find('.check_type_group label').hover(function () {
  107. var name = $(this).find('input').attr('name');
  108. if (name === 'data' && !recycle_bin_db_open) {
  109. layer.tips('风险操作:当前数据库回收站未开启,删除数据库将永久消失!', this, { tips: [1, 'red'], time: 0 })
  110. } else if (name === 'path' && !recycle_bin_open) {
  111. layer.tips('风险操作:当前文件回收站未开启,删除站点目录将永久消失!', this, { tips: [1, 'red'], time: 0 })
  112. }
  113. }, function () {
  114. layer.closeAll('tips');
  115. })
  116. },
  117. yes:function(indexs){
  118. var data = {id: wid,webname: wname};
  119. $('#site_delete_form input[type=checkbox]').each(function (index, item) {
  120. if($(item).is(':checked')) data[$(item).attr('name')] = 1
  121. })
  122. var is_database = data.hasOwnProperty('database'),is_path = data.hasOwnProperty('path'),is_ftp = data.hasOwnProperty('ftp');
  123. if((!is_database && !is_path) && (!is_ftp || is_ftp)){
  124. if(typeof wname === "function"){
  125. wname(data)
  126. return false;
  127. }
  128. bt.site.del_site(data, function (rdata) {
  129. layer.close(indexs);
  130. if (callback) callback(rdata);
  131. bt.msg(rdata);
  132. })
  133. return false
  134. }
  135. if(typeof wname === "function"){
  136. delete data.id;
  137. delete data.webname;
  138. }
  139. layer.close(indexs)
  140. if(typeof wname === "function"){
  141. console.log(data)
  142. wname(data)
  143. }else{
  144. bt.site.del_site(data, function (rdata) {
  145. layer.closeAll()
  146. if (rdata.status) site.get_list();
  147. if (callback) callback(rdata);
  148. bt.msg(rdata);
  149. })
  150. }
  151. }
  152. })
  153. }
  154. }
  155. if("undefined" != typeof bt && bt.hasOwnProperty("firewall") && bt.firewall.hasOwnProperty("add_accept_port")){
  156. bt.firewall.add_accept_port = function(type, port, ps, callback) {
  157. var action = "AddDropAddress";
  158. if (type == 'port') {
  159. ports = port.split(':');
  160. if (port.indexOf('-') != -1) ports = port.split('-');
  161. for (var i = 0; i < ports.length; i++) {
  162. if (!bt.check_port(ports[i])) {
  163. layer.msg(lan.firewall.port_err, { icon: 5 });
  164. return;
  165. }
  166. }
  167. action = "AddAcceptPort";
  168. }
  169. loading = bt.load();
  170. bt.send(action, 'firewall/' + action, { port: port, type: type, ps: ps }, function(rdata) {
  171. loading.close();
  172. if (callback) callback(rdata);
  173. })
  174. }
  175. }
  176. function SafeMessage(j, h, g, f) {
  177. if(f == undefined) {
  178. f = ""
  179. }
  180. var mess = layer.open({
  181. type: 1,
  182. title: j,
  183. area: "350px",
  184. closeBtn: 2,
  185. shadeClose: true,
  186. content: "<div class='bt-form webDelete pd20 pb70'><p>" + h + "</p>" + f + "<div class='bt-form-submit-btn'><button type='button' class='btn btn-danger btn-sm bt-cancel'>"+lan.public.cancel+"</button> <button type='button' id='toSubmit' class='btn btn-success btn-sm' >"+lan.public.ok+"</button></div></div>"
  187. });
  188. $(".bt-cancel").click(function(){
  189. layer.close(mess);
  190. });
  191. $("#toSubmit").click(function() {
  192. layer.close(mess);
  193. g();
  194. })
  195. }
  196. $(document).ready(function () {
  197. if($('#updata_pro_info').length>0){
  198. $('#updata_pro_info').html('');
  199. bt.set_cookie('productPurchase', 1);
  200. }
  201. })