国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

221 lines
6.2KB

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