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

251 lines
6.6KB

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