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.

198 lines
8.4 KiB

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