国内流行的内容管理系统(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.

244 lines
6.4KB

  1. var dedebizInfo;
  2. function ViewDedeBIZ() {
  3. if (dedebizInfo === false) {
  4. ShowMsg("启动商业组件失败");
  5. return;
  6. }
  7. ShowMsg(`<table class="table table-borderless">
  8. <tr>
  9. <td width="25%">
  10. <div class="web-info">
  11. <p>版本号</p>
  12. <span>${dedebizInfo.result.server_version}</span>
  13. </div>
  14. </td>
  15. <td width="25%">
  16. <div class="web-info">
  17. <p>服务器系统</p>
  18. <span>${dedebizInfo.result.server_goos}</span>
  19. </div>
  20. </td>
  21. <td width="25%">
  22. <div class="web-info">
  23. <p>运行时间</p>
  24. <span>${dedebizInfo.result.server_run_time}</span>
  25. </div>
  26. </td>
  27. <td width="25%">
  28. <div class="web-info">
  29. <p>内存占用</p>
  30. <span>${dedebizInfo.result.server_memory_usage}%</span>
  31. </div>
  32. </td>
  33. </tr>
  34. </table>`);
  35. }
  36. function LoadServer() {
  37. $.get("index_body.php?dopost=system_info",function(data) {
  38. let rsp = JSON.parse(data);
  39. if (rsp.code === 200) {
  40. if (rsp.result.core.code === 200) {
  41. dedebizInfo = JSON.parse(rsp.result.core.data);
  42. } else {
  43. dedebizInfo = false;
  44. }
  45. let infoStr = `<table class="table table-borderless">`;
  46. if (typeof rsp.result.domain !== "undefined") {
  47. infoStr += `<tr>
  48. <td width="25%">
  49. <div class="web-info">
  50. <p>授权域名</p>
  51. <span>${rsp.result.domain}</span>
  52. </div>
  53. </td>
  54. <td width="25%">
  55. <div class="web-info">
  56. <p>站点名称</p>
  57. <span>${rsp.result.title}</span>
  58. </div>
  59. </td>
  60. <td width="25%">
  61. <div class="web-info">
  62. <p>站点证书</p>
  63. <span><a href="${cfg_biz_dedebizUrl}/auth/?domain=${rsp.result.domain}" target="_blank">查看证书</a></span>
  64. </div>
  65. </td>
  66. <td width="25%">
  67. <div class="web-info">
  68. <p>商业组件</p>
  69. <span><a href="javascript:ViewDedeBIZ()">组件状态</a></span>
  70. </div>
  71. </td>
  72. </tr>`;
  73. }
  74. infoStr += "</table>";
  75. $("#system-info").html(infoStr);
  76. } else {
  77. $("#system-info").html(`<table class="table table-borderless">
  78. <tr>
  79. <td>
  80. <div class="web-info">
  81. <p>${rsp.msg}</p>
  82. <span>您已购买了商业版授权,登录DedeBIZ官网会员中心可查看相关授权信息</span>
  83. </div>
  84. </td>
  85. </tr>
  86. </table>`);
  87. }
  88. });
  89. }
  90. Date.prototype.Format = function(fmt) {
  91. var o = {
  92. "M+" : this.getMonth() + 1, //月份
  93. "d+" : this.getDate(), //日
  94. "h+" : this.getHours(), //小时
  95. "m+" : this.getMinutes(), //分
  96. "s+" : this.getSeconds(), //秒
  97. "q+" : Math.floor((this.getMonth() + 3) / 3), //季度
  98. "S" : this.getMilliseconds() //毫秒
  99. };
  100. if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  101. for (var k in o)
  102. if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  103. return fmt;
  104. }
  105. function LoadStat() {
  106. $.get("index_body.php?dopost=get_statistics",function(data) {
  107. try {
  108. let rsp = JSON.parse(data);
  109. if (rsp.code == 200) {
  110. var tpv = parseInt(rsp.result.pv);
  111. var tuv = parseInt(rsp.result.uv);
  112. var tip = parseInt(rsp.result.ip);
  113. var tvv = parseInt(rsp.result.vv);
  114. $("#today_pv").html(tpv);
  115. $("#today_uv").html(tuv);
  116. $("#today_ip").html(tip);
  117. $("#today_vv").html(tvv);
  118. $.get("index_body.php?dopost=get_statistics&sdate=-1",function(data) {
  119. let rsp = JSON.parse(data);
  120. if (rsp.code == 200) {
  121. $("#total_pv").html(parseInt(rsp.result.pv) + tpv);
  122. $("#total_uv").html(parseInt(rsp.result.uv) + tuv);
  123. $("#total_ip").html(parseInt(rsp.result.ip) + tip);
  124. $("#total_vv").html(parseInt(rsp.result.vv) + tvv);
  125. }
  126. });
  127. }
  128. } catch (error) {
  129. console.log("加载流量统计数据失败")
  130. }
  131. });
  132. var d = new Date();
  133. d.setDate(d.getDate() - 1);
  134. var s = d.Format("yyyy-MM-dd");
  135. s = s.replaceAll("-", "");
  136. $.get("index_body.php?dopost=get_statistics&sdate=" + s,function(data) {
  137. try {
  138. let rsp = JSON.parse(data);
  139. if (rsp.code == 200) {
  140. $("#yestoday_pv").html(rsp.result.pv);
  141. $("#yestoday_uv").html(rsp.result.uv);
  142. $("#yestoday_ip").html(rsp.result.ip);
  143. $("#yestoday_vv").html(rsp.result.vv);
  144. }
  145. } catch (error) {
  146. console.log("加载流量统计数据失败")
  147. }
  148. });
  149. }
  150. async function LoadStatChart() {
  151. const ctx = document.getElementById('statChart').getContext('2d');
  152. let labels = [];
  153. let dates = [];
  154. let pvs = [];
  155. let ips = [];
  156. let uvs = [];
  157. let vvs = [];
  158. for (let i = 15; i > 0; i--) {
  159. var d = new Date();
  160. d.setDate(d.getDate() - i);
  161. var s = d.Format("yyyy-MM-dd");
  162. labels.push(d.Format("MM-dd"));
  163. s = s.replaceAll("-", "");
  164. dates.push(s);
  165. }
  166. let resp = await fetch("index_body.php?dopost=get_statistics_multi&sdates=" + dates.join(","));
  167. let data = await resp.json();
  168. if (data.code == 200) {
  169. data.result.forEach(e => {
  170. pvs.push(typeof e.pv == "undefined" ? 0 : e.pv);
  171. ips.push(typeof e.ip == "undefined" ? 0 : e.ip);
  172. uvs.push(typeof e.uv == "undefined" ? 0 : e.uv);
  173. vvs.push(typeof e.vv == "undefined" ? 0 : e.vv);
  174. });
  175. }
  176. Chart.defaults.font.size = 14;
  177. Chart.defaults.color = '#545b62';
  178. const myChart = new Chart(ctx, {
  179. type: 'line',
  180. options: {
  181. responsive: true,
  182. maintainAspectRatio: false,
  183. plugins: {
  184. legend: {
  185. position: 'right',
  186. }
  187. }
  188. },
  189. data: {
  190. labels: labels,
  191. datasets: [
  192. {
  193. label: 'PV',
  194. data: pvs,
  195. lineTension: .5,
  196. borderColor: 'rgba(54, 162, 235, 1)',
  197. backgroundColor: 'rgba(54, 162, 235, 0.1)',
  198. borderWidth: 2
  199. }, {
  200. label: 'UV',
  201. data: uvs,
  202. lineTension: .5,
  203. borderColor: 'rgba(255, 206, 86, 1)',
  204. backgroundColor: 'rgba(255, 206, 86, 0.1)',
  205. borderWidth: 2
  206. }, {
  207. label: 'IP',
  208. data: ips,
  209. lineTension: .5,
  210. borderColor: 'rgba(255, 99, 132, 1)',
  211. backgroundColor: 'rgba(255, 99, 132, 0.1)',
  212. borderWidth: 2
  213. }, {
  214. label: 'VV',
  215. data: vvs,
  216. lineTension: .5,
  217. borderColor: 'rgba(75, 192, 192, 1)',
  218. backgroundColor: 'rgba(75, 192, 192, 0.1)',
  219. borderWidth: 2
  220. }
  221. ]
  222. },
  223. });
  224. }
  225. $(document).ready(function() {
  226. $(function() {
  227. $.get("index_testenv.php",function(data) {
  228. if (data !== '') {
  229. $("#body-tips").html(data);
  230. }
  231. });
  232. $.get("index_body.php?dopost=get_articles",function(data) {
  233. if (data !== '') {
  234. $("#system-word").html(data);
  235. }
  236. });
  237. });
  238. LoadServer();
  239. LoadStat();
  240. LoadStatChart();
  241. setInterval(function() {
  242. LoadServer();
  243. }, 3000)
  244. });