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.

368 lines
20 KiB

1 year ago
1 year ago
1 year 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 bt && bt.hasOwnProperty("compute_confirm")){
  45. bt.compute_confirm = function (config, callback) {
  46. layer.open({
  47. type: 1,
  48. title: config.title,
  49. area: '430px',
  50. closeBtn: 2,
  51. shadeClose: true,
  52. btn: [lan['public'].ok, lan['public'].cancel],
  53. content:
  54. '<div class="bt-form hint_confirm pd30">\
  55. <div class="hint_title">\
  56. <i class="hint-confirm-icon"></i>\
  57. <div class="hint_con">' +
  58. config.msg +
  59. '</div>\
  60. </div>\
  61. </div>',
  62. yes: function (layers, index) {
  63. layer.close(layers)
  64. if (callback) callback()
  65. }
  66. });
  67. }
  68. }
  69. if("undefined" != typeof database && database.hasOwnProperty("del_database")){
  70. database.del_database = function (wid, dbname,obj, callback) {
  71. var title = '',
  72. tips = '是否确认【删除数据库】,删除后可能会影响业务使用!';
  73. if(obj && obj.db_type > 0) tips = '远程数据库不支持数据库回收站,删除后将无法恢复,请谨慎操作';
  74. title = typeof dbname === "function" ?'批量删除数据库':'删除数据库 [ '+ dbname +' ]';
  75. layer.open({
  76. type:1,
  77. title:title,
  78. icon:0,
  79. skin:'delete_site_layer',
  80. area: "530px",
  81. closeBtn: 2,
  82. shadeClose: true,
  83. content:"<div class=\'bt-form webDelete pd30\' id=\'site_delete_form\'>" +
  84. "<i class=\'layui-layer-ico layui-layer-ico0\'></i>" +
  85. "<div class=\'f13 check_title\' style=\'margin-bottom: 20px;\'>"+tips+"</div>" +
  86. "<div style=\'color:red;margin:18px 0 18px 18px;font-size:14px;font-weight: bold;\'>注意:数据无价,请谨慎操作!!!"+(!recycle_bin_db_open?'<br>风险操作:当前数据库回收站未开启,删除数据库将永久消失!':'')+"</div>" +
  87. "</div>",
  88. btn:[lan.public.ok,lan.public.cancel],
  89. yes:function(indexs){
  90. var data = {id: wid,name: dbname};
  91. if(typeof dbname === "function"){
  92. delete data.id;
  93. delete data.name;
  94. }
  95. layer.close(indexs)
  96. var arrs = wid instanceof Array ? wid : [wid]
  97. var ids = JSON.stringify(arrs), countDown = 9;
  98. if (arrs.length == 1) countDown = 4
  99. title = typeof dbname === "function" ?'二次验证信息,批量删除数据库':'二次验证信息,删除数据库 [ ' + dbname + ' ]';
  100. var loadT = bt.load('正在检测数据库数据信息,请稍后...')
  101. bt_tools.send({url:'database/'+bt.data.db_tab_name+'/check_del_data',data:{data:JSON.stringify({ids: ids})}},function(res){
  102. loadT.close()
  103. layer.open({
  104. type:1,
  105. title:title,
  106. closeBtn: 2,
  107. skin: 'verify_site_layer_info',
  108. area: '740px',
  109. content: '<div class="check_delete_site_main pd30">' +
  110. '<i class="layui-layer-ico layui-layer-ico0"></i>' +
  111. '<div class="check_layer_title">堡塔温馨提示您,请冷静几秒钟,确认是否要删除以下数据。</div>' +
  112. '<div class="check_layer_content">' +
  113. '<div class="check_layer_item">' +
  114. '<div class="check_layer_site"></div>' +
  115. '<div class="check_layer_database"></div>' +
  116. '</div>' +
  117. '</div>' +
  118. '<div class="check_layer_error ' + (recycle_bin_db_open ? 'hide' : '') + '"><span class="glyphicon glyphicon-info-sign"></span>风险事项:当前未开启数据库回收站功能,删除数据库后,数据库将永久消失!</div>' +
  119. '<div class="check_layer_message"><span style="color:red">注意:请仔细阅读以上要删除信息,防止数据库被误删</span></div>' +
  120. '</div>',
  121. btn: ['确认删除', '取消删除'],
  122. success: function (layers) {
  123. var html = '', rdata = res.data;
  124. var filterData = rdata.filter(function(el){
  125. return ids.indexOf(el.id) != -1
  126. })
  127. for (var i = 0; i < filterData.length; i++) {
  128. var item = filterData[i], newTime = parseInt(new Date().getTime() / 1000),
  129. t_icon = '<span class="glyphicon glyphicon-info-sign" style="color: red;width:15px;height: 15px;;vertical-align: middle;"></span>';
  130. database_html = (function(item){
  131. var is_time_rule = (newTime - item.st_time) > (86400 * 30) && (item.total > 1024 * 10),
  132. is_database_rule = res.db_size <= item.total,
  133. database_time = bt.format_data(item.st_time, 'yyyy-MM-dd'),
  134. database_size = bt.format_size(item.total);
  135. var f_size = '<i ' + (is_database_rule ? 'class="warning"' : '') + ' style = "vertical-align: middle;" > ' + database_size + '</i> ' + (is_database_rule ? t_icon : '');
  136. var t_size = '注意:此数据库较大,可能为重要数据,请谨慎操作.\n数据库:' + database_size;
  137. return '<div class="check_layer_database">' +
  138. '<span title="数据库:' + item.name + '">数据库:' + item.name + '</span>' +
  139. '<span title="' + t_size+'">大小:' + f_size +'</span>' +
  140. '<span title="' + (is_time_rule && item.total != 0 ? '重要:此数据库创建时间较早,可能为重要数据,请谨慎操作.' : '') + '时间:' + database_time+'">创建时间:<i ' + (is_time_rule && item.total != 0 ? 'class="warning"' : '') + '>' + database_time + '</i></span>' +
  141. '</div>'
  142. }(item))
  143. if(database_html !== '') html += '<div class="check_layer_item">' + database_html +'</div>';
  144. }
  145. if(html === '') html = '<div style="text-align: center;width: 100%;height: 100%;line-height: 300px;font-size: 15px;">无数据</div>'
  146. $('.check_layer_content').html(html)
  147. },
  148. yes:function(indes,layers){
  149. if(typeof dbname === "function"){
  150. dbname(data)
  151. }else{
  152. bt.database.del_database(data, function (rdata) {
  153. layer.closeAll()
  154. if (rdata.status) database_table.$refresh_table_list(true);
  155. if (callback) callback(rdata);
  156. bt.msg(rdata);
  157. })
  158. }
  159. }
  160. })
  161. })
  162. }
  163. })
  164. }
  165. }
  166. if("undefined" != typeof site && site.hasOwnProperty("del_site")){
  167. site.del_site = function(wid, wname, callback) {
  168. var title = typeof wname === "function" ? '批量删除站点' : '删除站点 [ ' + wname + ' ]';
  169. recycle_bin_open = bt.get_cookie("is_recycle") || bt.get_cookie("is_recycle") == null ? true : false
  170. layer.open({
  171. type: 1,
  172. title: title,
  173. icon: 0,
  174. skin: 'delete_site_layer',
  175. area: "440px",
  176. closeBtn: 2,
  177. shadeClose: true,
  178. content: "<div class=\'bt-form webDelete pd30\' id=\'site_delete_form\'>" +
  179. '<i class="layui-layer-ico layui-layer-ico0"></i>' +
  180. "<div class=\'f13 check_title\'>是否要删除关联的FTP、数据库、站点目录!</div>" +
  181. "<div class=\"check_type_group\">" +
  182. "<label><input type=\"checkbox\" name=\"ftp\"><span>FTP</span></label>" +
  183. "<label><input type=\"checkbox\" name=\"database\"><span>数据库</span>" + (!recycle_bin_db_open ? '<span class="glyphicon glyphicon-info-sign" style="color: red"></span>' : '') + "</label>" +
  184. "<label><input type=\"checkbox\" name=\"path\"><span>站点目录</span>" + (!recycle_bin_open ? '<span class="glyphicon glyphicon-info-sign" style="color: red"></span>' : '') + "</label>" +
  185. "</div>" +
  186. "</div>",
  187. btn: [lan.public.ok, lan.public.cancel],
  188. success: function (layers, indexs) {
  189. $(layers).find('.check_type_group label').hover(function () {
  190. var name = $(this).find('input').attr('name');
  191. if (name === 'data' && !recycle_bin_db_open) {
  192. layer.tips('风险操作:当前数据库回收站未开启,删除数据库将永久消失!', this, { tips: [1, 'red'], time: 0 })
  193. } else if (name === 'path' && !recycle_bin_open) {
  194. layer.tips('风险操作:当前文件回收站未开启,删除站点目录将永久消失!', this, { tips: [1, 'red'], time: 0 })
  195. }
  196. }, function () {
  197. layer.closeAll('tips');
  198. })
  199. },
  200. yes: function (indexs) {
  201. var data = { id: wid, webname: wname };
  202. $('#site_delete_form input[type=checkbox]').each(function (index, item) {
  203. if ($(item).is(':checked')) data[$(item).attr('name')] = 1
  204. })
  205. var is_database = data.hasOwnProperty('database'), is_path = data.hasOwnProperty('path'), is_ftp = data.hasOwnProperty('ftp');
  206. if ((!is_database && !is_path) && (!is_ftp || is_ftp)) {
  207. if (typeof wname === "function") {
  208. wname(data)
  209. return false;
  210. }
  211. bt.site.del_site(data, function (rdata) {
  212. layer.close(indexs);
  213. if (callback) callback(rdata);
  214. bt.msg(rdata);
  215. })
  216. return false
  217. }
  218. if (typeof wname === "function") {
  219. delete data.id;
  220. delete data.webname;
  221. }
  222. layer.close(indexs)
  223. var arrs = wid instanceof Array ? wid : [wid]
  224. var ids = JSON.stringify(arrs), countDown = 9;
  225. if (arrs.length == 1) countDown = 4
  226. title = typeof wname === "function" ? '二次验证信息,批量删除站点' : '二次验证信息,删除站点 [ ' + wname + ' ]';
  227. var loadT = bt.load('正在检测站点数据信息,请稍后...')
  228. bt.send('check_del_data', 'site/check_del_data', { ids: ids }, function (res) {
  229. loadT.close()
  230. layer.open({
  231. type: 1,
  232. title: title,
  233. closeBtn: 2,
  234. skin: 'verify_site_layer_info',
  235. area: '740px',
  236. content: '<div class="check_delete_site_main pd30">' +
  237. '<i class="layui-layer-ico layui-layer-ico0"></i>' +
  238. '<div class="check_layer_title">堡塔温馨提示您,请冷静几秒钟,确认以下要删除的数据。</div>' +
  239. '<div class="check_layer_content">' +
  240. '<div class="check_layer_item">' +
  241. '<div class="check_layer_site"></div>' +
  242. '<div class="check_layer_database"></div>' +
  243. '</div>' +
  244. '</div>' +
  245. '<div class="check_layer_error ' + (data.database && recycle_bin_db_open ? 'hide' : '') + '"><span class="glyphicon glyphicon-info-sign"></span>风险事项:当前未开启数据库回收站功能,删除数据库后,数据库将永久消失!</div>' +
  246. '<div class="check_layer_error ' + (data.path && recycle_bin_open ? 'hide' : '') + '"><span class="glyphicon glyphicon-info-sign"></span>风险事项:当前未开启文件回收站功能,删除站点目录后,站点目录将永久消失!</div>' +
  247. '<div class="check_layer_message"><span style="color:red">注意:请仔细阅读以上要删除信息,防止网站数据被误删</span></div>' +
  248. '</div>',
  249. // recycle_bin_db_open &&
  250. // recycle_bin_open &&
  251. btn: ['确认删除', '取消删除'],
  252. success: function (layers) {
  253. var html = '', rdata = res.data;
  254. for (var i = 0; i < rdata.length; i++) {
  255. var item = rdata[i], newTime = parseInt(new Date().getTime() / 1000),
  256. t_icon = '<span class="glyphicon glyphicon-info-sign" style="color: red;width:15px;height: 15px;;vertical-align: middle;"></span>';
  257. site_html = (function (item) {
  258. if (!is_path) return ''
  259. var is_time_rule = (newTime - item.st_time) > (86400 * 30) && (item.total > 1024 * 10),
  260. is_path_rule = res.file_size <= item.total,
  261. dir_time = bt.format_data(item.st_time, 'yyyy-MM-dd'),
  262. dir_size = bt.format_size(item.total);
  263. var f_html = '<i ' + (is_path_rule ? 'class="warning"' : '') + ' style = "vertical-align: middle;" > ' + dir_size + '</i> ' + (is_path_rule ? t_icon : '');
  264. var f_title = (is_path_rule ? '注意:此目录较大,可能为重要数据,请谨慎操作.\n' : '') + '目录:' + item.path + '(' + (item.limit ? '大于' : '') + dir_size + ')';
  265. return '<div class="check_layer_site">' +
  266. '<span title="站点:' + item.name + '">站点名:' + item.name + '</span>' +
  267. '<span title="' + f_title + '" >目录:<span style="vertical-align: middle;max-width: 160px;width: auto;">' + item.path + '</span> (' + f_html + ')</span>' +
  268. '<span title="' + (is_time_rule ? '注意:此站点创建时间较早,可能为重要数据,请谨慎操作.\n' : '') + '时间:' + dir_time + '">创建时间:<i ' + (is_time_rule ? 'class="warning"' : '') + '>' + dir_time + '</i></span>' +
  269. '</div>'
  270. }(item)),
  271. database_html = (function (item) {
  272. if (!is_database || !item.database) return '';
  273. var is_time_rule = (newTime - item.st_time) > (86400 * 30) && (item.total > 1024 * 10),
  274. is_database_rule = res.db_size <= item.database.total,
  275. database_time = bt.format_data(item.database.st_time, 'yyyy-MM-dd'),
  276. database_size = bt.format_size(item.database.total);
  277. var f_size = '<i ' + (is_database_rule ? 'class="warning"' : '') + ' style = "vertical-align: middle;" > ' + database_size + '</i> ' + (is_database_rule ? t_icon : '');
  278. var t_size = '注意:此数据库较大,可能为重要数据,请谨慎操作.\n数据库:' + database_size;
  279. return '<div class="check_layer_database">' +
  280. '<span title="数据库:' + item.database.name + '">数据库:' + item.database.name + '</span>' +
  281. '<span title="' + t_size + '">大小:' + f_size + '</span>' +
  282. '<span title="' + (is_time_rule && item.database.total != 0 ? '重要:此数据库创建时间较早,可能为重要数据,请谨慎操作.' : '') + '时间:' + database_time + '">创建时间:<i ' + (is_time_rule && item.database.total != 0 ? 'class="warning"' : '') + '>' + database_time + '</i></span>' +
  283. '</div>'
  284. }(item))
  285. if ((site_html + database_html) !== '') html += '<div class="check_layer_item">' + site_html + database_html + '</div>';
  286. }
  287. if (html === '') html = '<div style="text-align: center;width: 100%;height: 100%;line-height: 300px;font-size: 15px;">无数据</div>'
  288. $('.check_layer_content').html(html)
  289. },
  290. yes: function (indes, layers) {
  291. if (typeof wname === "function") {
  292. wname(data)
  293. } else {
  294. bt.site.del_site(data, function (rdata) {
  295. layer.closeAll()
  296. if (rdata.status) site.get_list();
  297. if (callback) callback(rdata);
  298. bt.msg(rdata);
  299. })
  300. }
  301. }
  302. })
  303. })
  304. }
  305. })
  306. if(bt.get_cookie("is_recycle") || bt.get_cookie("is_recycle")==null){
  307. $('[name="path"]').attr('checked',true)
  308. }else{
  309. $('[name="path"]').removeProp('checked');
  310. }
  311. }
  312. }
  313. if("undefined" != typeof bt && bt.hasOwnProperty("firewall") && bt.firewall.hasOwnProperty("add_accept_port")){
  314. bt.firewall.add_accept_port = function(type, port, ps, callback) {
  315. var action = "AddDropAddress";
  316. if (type == 'port') {
  317. ports = port.split(':');
  318. if (port.indexOf('-') != -1) ports = port.split('-');
  319. for (var i = 0; i < ports.length; i++) {
  320. if (!bt.check_port(ports[i])) {
  321. layer.msg(lan.firewall.port_err, { icon: 5 });
  322. return;
  323. }
  324. }
  325. action = "AddAcceptPort";
  326. }
  327. loading = bt.load();
  328. bt.send(action, 'firewall/' + action, { port: port, type: type, ps: ps }, function(rdata) {
  329. loading.close();
  330. if (callback) callback(rdata);
  331. })
  332. }
  333. }
  334. function SafeMessage(j, h, g, f) {
  335. if(f == undefined) {
  336. f = ""
  337. }
  338. var mess = layer.open({
  339. type: 1,
  340. title: j,
  341. area: "350px",
  342. closeBtn: 2,
  343. shadeClose: true,
  344. 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>"
  345. });
  346. $(".bt-cancel").click(function(){
  347. layer.close(mess);
  348. });
  349. $("#toSubmit").click(function() {
  350. layer.close(mess);
  351. g();
  352. })
  353. }
  354. $(document).ready(function () {
  355. if($('#updata_pro_info').length>0){
  356. $('#updata_pro_info').html('');
  357. bt.set_cookie('productPurchase', 1);
  358. }
  359. })