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.

393 lines
21 KiB

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