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

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