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.

202 lines
8.7 KiB

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