国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
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.

312 lines
11KB

  1. function AddNew() {
  2. $DE('addTab').style.display = 'block';
  3. }
  4. function CloseTab(tb) {
  5. $DE(tb).style.display = 'none';
  6. }
  7. function ListAll() {
  8. $DE('editTab').style.display = 'block';
  9. fetch('index_body.php?dopost=editshow').then(resp => resp.text()).then((d) => {
  10. $DE('editTabBody').innerHTML = d;
  11. });
  12. }
  13. function ShowWaitDiv() {
  14. $DE('loaddiv').style.display = 'block';
  15. return true;
  16. }
  17. function DedeCopyToClipboard(text) {
  18. if (navigator.clipboard) {
  19. navigator.clipboard.writeText(text);
  20. } else {
  21. var textarea = document.createElement('textarea');
  22. document.body.appendChild(textarea);
  23. // 隐藏此输入框
  24. textarea.style.position = 'fixed';
  25. textarea.style.clip = 'rect(0 0 0 0)';
  26. textarea.style.top = '10px';
  27. textarea.style.display = 'none';
  28. textarea.value = text;
  29. textarea.select();
  30. document.execCommand('copy', true);
  31. document.body.removeChild(textarea);
  32. }
  33. }
  34. $(function () {
  35. $.get("index_testenv.php", function (data) {
  36. if (data !== '') {
  37. $("#body-tips").html(data);
  38. }
  39. });
  40. $.get("index_body.php?dopost=get_articles", function (data) {
  41. if (data !== '') {
  42. $("#system-word").html(data);
  43. }
  44. });
  45. });
  46. function copyFn(){
  47. var val = document.getElementById('text');
  48. window.getSelection().selectAllChildren(val);
  49. document.execCommand ("Copy");
  50. alert("环境配置信息已复制");
  51. }
  52. //Dedebiz info
  53. var dedebizInfo;
  54. function ViewDedeBIZ() {
  55. console.log(dedebizInfo);
  56. ShowMsg(`
  57. <table class="table table-borderless w-100">
  58. <tr>
  59. <td width="90">版本号:</td>
  60. <td>V${dedebizInfo.result.server_version}</td>
  61. <td width="90">服务器系统:</td>
  62. <td>${dedebizInfo.result.server_goos}(${dedebizInfo.result.server_goarch})</td>
  63. </tr>
  64. <tr>
  65. <td>运行时间:</td>
  66. <td>${dedebizInfo.result.server_run_time}</td>
  67. <td>内存占用:</td>
  68. <td>${dedebizInfo.result.server_memory_usage}%</td>
  69. </tr>
  70. </table>
  71. `);
  72. }
  73. function LoadServer() {
  74. $.get("index_body.php?dopost=system_info", function (data) {
  75. let rsp = JSON.parse(data);
  76. if (rsp.code === 200) {
  77. let infoStr = `<table class="table table-borderless w-100">`;
  78. if (typeof rsp.result.domain !== "undefined") {
  79. infoStr += `
  80. <tr>
  81. <td width="90">授权域名:</td>
  82. <td>${rsp.result.domain}</td>
  83. <td width="90">授权版本:</td>
  84. <td>${rsp.result.auth_version}.x.x(时间:${rsp.result.auth_at})</td>
  85. </tr>
  86. `;
  87. }
  88. /*多余代码*/
  89. if (typeof rsp.result.title !== "undefined") {
  90. infoStr += `
  91. `;
  92. }
  93. /*多余代码*/
  94. if (typeof rsp.result.auth_version !== "undefined" && typeof rsp.result.auth_at !== "undefined") {
  95. infoStr += `
  96. <tr>
  97. <td>站点名称:</td>
  98. <td>${rsp.result.title}(${rsp.result.stype})</td>
  99. <td>证书组件:</td>
  100. <td>
  101. <a href="${cfg_biz_dedebizUrl}/auth/?domain=${rsp.result.domain}" target="_blank" class="btn btn-success btn-sm">授权证书</a>
  102. <a href="javascript:ViewDedeBIZ()" class="btn btn-primary btn-sm">组件信息</a>
  103. </td>
  104. </tr>
  105. `;
  106. }
  107. /*多余代码*/
  108. if (rsp.result.core === null || rsp.result.core.code != 200) {
  109. //下面是DedeBIZ Core组件信息
  110. infoStr += `
  111. `;
  112. } else {
  113. dedebizInfo = JSON.parse(rsp.result.core.data);
  114. infoStr += `
  115. `;
  116. }
  117. /*多余代码*/
  118. infoStr += "</table>";
  119. $("#system-info").html(infoStr);
  120. } else {
  121. $("#system-info").html(`
  122. <table class="table table-borderless w-100">
  123. <tr>
  124. <td>${rsp.msg}</td>
  125. </tr>
  126. <tr>
  127. <td>如果您已购买商业版授权,可以在我们的授权中心查询到相信关授权信息,如果查询结果与实际授权不符,则说明您可能购买了非法商业授权,请及时与我们取得联系。</td>
  128. </tr>
  129. </table>
  130. <!--最新软件该提示-->
  131. <table class="table table-borderless w-100">
  132. <tr>
  133. <td>您的后台已是最新软件版本</td>
  134. </tr>
  135. </table>
  136. <!--最新软件该提示-->
  137. <!--正常新版本升级该提示,然后回到最新软件该提示-->
  138. <table class="table table-borderless w-100">
  139. <tr>
  140. <td colspan="2">本更新提供了重要的安全性更新,建议所有用户升级,软件更新将覆盖以下文件,请做好备份。<a href="" class="btn btn-success btn-sm">下一步</a></td>
  141. </tr>
  142. <tr>
  143. <td width="90">文件1:</td>
  144. <td>/system/database/dedesqlite.class.php</td>
  145. </tr>
  146. <tr>
  147. <td>文件2:</td>
  148. <td>/system/database/dedesqlite.class.php</td>
  149. </tr>
  150. <tr>
  151. <td>文件3:</td>
  152. <td>/system/database/dedesqlite.class.php</td>
  153. </tr>
  154. </table>
  155. <!--正常新版本升级该提示-->
  156. <!--用户换后台该提示,然后回到正常新版本升级该提示,做后回到最新软件该提示-->
  157. <table class="table table-borderless w-100">
  158. <tr>
  159. <td>更新诊断出数据结构有问题,可能无法正常使用后台,是否尝试修复数据?</td>
  160. </tr>
  161. <tr>
  162. <td>
  163. <a href="" class="btn btn-success btn-sm">修复</a>
  164. <a href="" class="btn btn-secondary btn-sm">取消</a>
  165. </td>
  166. </tr>
  167. </table>
  168. <!--用户换后台该提示-->
  169. `);
  170. }
  171. });
  172. }
  173. Date.prototype.Format = function (fmt) { //author: meizz
  174. var o = {
  175. "M+": this.getMonth() + 1, //月份
  176. "d+": this.getDate(), //日
  177. "h+": this.getHours(), //小时
  178. "m+": this.getMinutes(), //分
  179. "s+": this.getSeconds(), //秒
  180. "q+": Math.floor((this.getMonth() + 3) / 3), //季度
  181. "S": this.getMilliseconds() //毫秒
  182. };
  183. if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  184. for (var k in o)
  185. if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  186. return fmt;
  187. }
  188. function LoadStat() {
  189. $.get("index_body.php?dopost=get_statistics", function (data) {
  190. let rsp = JSON.parse(data);
  191. if (rsp.code == 200) {
  192. var tpv = parseInt(rsp.result.pv);
  193. var tuv = parseInt(rsp.result.uv);
  194. var tip = parseInt(rsp.result.ip);
  195. var tvv = parseInt(rsp.result.vv);
  196. $("#today_pv").html(tpv);
  197. $("#today_uv").html(tuv);
  198. $("#today_ip").html(tip);
  199. $("#today_vv").html(tvv);
  200. $.get("index_body.php?dopost=get_statistics&sdate=-1", function (data) {
  201. let rsp = JSON.parse(data);
  202. if (rsp.code == 200) {
  203. $("#total_pv").html(parseInt(rsp.result.pv) + tpv);
  204. $("#total_uv").html(parseInt(rsp.result.uv) + tuv);
  205. $("#total_ip").html(parseInt(rsp.result.ip) + tip);
  206. $("#total_vv").html(parseInt(rsp.result.vv) + tvv);
  207. }
  208. });
  209. }
  210. });
  211. var d = new Date();
  212. d.setDate(d.getDate() - 1);
  213. var s = d.Format("yyyy-MM-dd");
  214. s = s.replaceAll("-", "");
  215. $.get("index_body.php?dopost=get_statistics&sdate=" + s, function (data) {
  216. let rsp = JSON.parse(data);
  217. if (rsp.code == 200) {
  218. $("#yestoday_pv").html(rsp.result.pv);
  219. $("#yestoday_uv").html(rsp.result.uv);
  220. $("#yestoday_ip").html(rsp.result.ip);
  221. $("#yestoday_vv").html(rsp.result.vv);
  222. }
  223. });
  224. }
  225. async function LoadStatChart() {
  226. const ctx = document.getElementById('statChart').getContext('2d');
  227. let labels = [];
  228. let dates = [];
  229. let pvs = [];
  230. let ips = [];
  231. let uvs = [];
  232. let vvs = [];
  233. for (let i = 15; i > 0; i--) {
  234. var d = new Date();
  235. d.setDate(d.getDate() - i);
  236. var s = d.Format("yyyy-MM-dd");
  237. labels.push(d.Format("MM-dd"));
  238. s = s.replaceAll("-", "");
  239. dates.push(s);
  240. }
  241. let resp = await fetch("index_body.php?dopost=get_statistics_multi&sdates=" + dates.join(","));
  242. let data = await resp.json();
  243. if (data.code == 200) {
  244. data.result.forEach(e => {
  245. pvs.push(typeof e.pv == "undefined" ? 0 : e.pv);
  246. ips.push(typeof e.ip == "undefined" ? 0 : e.ip);
  247. uvs.push(typeof e.uv == "undefined" ? 0 : e.uv);
  248. vvs.push(typeof e.vv == "undefined" ? 0 : e.vv);
  249. });
  250. }
  251. const myChart = new Chart(ctx, {
  252. type: 'line',
  253. options: {
  254. responsive: true,
  255. plugins: {
  256. legend: {
  257. position: 'right',
  258. }
  259. }
  260. },
  261. data: {
  262. labels: labels,
  263. datasets: [
  264. {
  265. label: 'PV',
  266. data: pvs,
  267. borderColor: 'rgba(54, 162, 235, 1)',
  268. backgroundColor: 'rgba(54, 162, 235, 0.2)',
  269. borderWidth: 1
  270. }, {
  271. label: 'UV',
  272. data: uvs,
  273. borderColor: 'rgba(255, 206, 86, 1)',
  274. backgroundColor: 'rgba(255, 206, 86, 0.2)',
  275. borderWidth: 1
  276. }, {
  277. label: 'IP',
  278. data: ips,
  279. borderColor: 'rgba(255, 99, 132, 1)',
  280. backgroundColor: 'rgba(255, 99, 132, 0.2)',
  281. borderWidth: 1
  282. }
  283. , {
  284. label: 'VV',
  285. data: vvs,
  286. borderColor: 'rgba(75, 192, 192, 1)',
  287. backgroundColor: 'rgba(75, 192, 192, 0.2)',
  288. borderWidth: 1
  289. }
  290. ]
  291. },
  292. });
  293. }
  294. $(document).ready(function () {
  295. LoadServer();
  296. LoadStat();
  297. LoadStatChart();
  298. setInterval(function () {
  299. LoadServer();
  300. }, 60000)
  301. });