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

204 lines
5.5KB

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