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

277 lines
10KB

  1. function AddNew() {
  2. $DE('addTab').style.display = 'block';
  3. }
  4. function CloseTab(tb) {
  5. $DE(tb).style.display = 'none';
  6. }
  7. function ListAll() {
  8. $DE('editTab').style.display = 'block';
  9. fetch('index_body.php?dopost=editshow').then(resp => resp.text()).then((d) => {
  10. $DE('editTabBody').innerHTML = d;
  11. });
  12. }
  13. function ShowWaitDiv() {
  14. $DE('loaddiv').style.display = 'block';
  15. return true;
  16. }
  17. function DedeCopyToClipboard(text) {
  18. if (navigator.clipboard) {
  19. navigator.clipboard.writeText(text);
  20. } else {
  21. var textarea = document.createElement('textarea');
  22. document.body.appendChild(textarea);
  23. // 隐藏此输入框
  24. textarea.style.position = 'fixed';
  25. textarea.style.clip = 'rect(0 0 0 0)';
  26. textarea.style.top = '10px';
  27. textarea.style.display = 'none';
  28. textarea.value = text;
  29. textarea.select();
  30. document.execCommand('copy', true);
  31. document.body.removeChild(textarea);
  32. }
  33. }
  34. function CopySystemInfo(txt) {
  35. DedeCopyToClipboard(txt);
  36. }
  37. $(function () {
  38. $.get("index_testenv.php", function (data) {
  39. if (data !== '') {
  40. $("#tips").html(data);
  41. }
  42. });
  43. $.get("index_body.php?dopost=get_articles", function (data) {
  44. if (data !== '') {
  45. $("#newarticles").html(data);
  46. }
  47. });
  48. });
  49. //Dedebiz info
  50. var dedebizInfo;
  51. function ViewDedeBIZ() {
  52. console.log(dedebizInfo);
  53. ShowMsg(`
  54. <table width="100%" class="table table-borderless">
  55. <tbody>
  56. <tr>
  57. <td style="width:50%">版本号:</td>
  58. <td>V${dedebizInfo.result.server_version}</td>
  59. </tr>
  60. <tr>
  61. <td style="width:50%">运行时间:</td>
  62. <td>${dedebizInfo.result.server_run_time}</td>
  63. </tr>
  64. <tr>
  65. <td style="width:50%">服务器系统:</td>
  66. <td>${dedebizInfo.result.server_goos}(${dedebizInfo.result.server_goarch})</td>
  67. </tr>
  68. <tr>
  69. <td style="width:50%">内存占用:</td>
  70. <td>${dedebizInfo.result.server_memory_usage}%</td>
  71. </tr>
  72. </tbody>
  73. </table>
  74. `);
  75. }
  76. function LoadServer() {
  77. $.get("index_body.php?dopost=system_info", function (data) {
  78. let rsp = JSON.parse(data);
  79. if (rsp.code === 200) {
  80. let infoStr = `<table width="100%" class="table table-borderless"><tbody>`;
  81. if (typeof rsp.result.domain !== "undefined") {
  82. infoStr += `
  83. <tr>
  84. <td style="width:50%">授权域名:</td>
  85. <td>${rsp.result.domain} <a href="${cfg_biz_dedebizUrl}/auth/?domain=${rsp.result.domain}" class="btn btn-success btn-sm">查看</a></td>
  86. </tr>
  87. `;
  88. }
  89. if (typeof rsp.result.title !== "undefined") {
  90. infoStr += `
  91. <tr>
  92. <td style="width:50%">站点名称:</td>
  93. <td>${rsp.result.title}</td>
  94. </tr>
  95. `;
  96. }
  97. if (typeof rsp.result.stype !== "undefined") {
  98. infoStr += `
  99. <tr>
  100. <td style="width:50%">站点类型:</td>
  101. <td>${rsp.result.stype}</td>
  102. </tr>
  103. `;
  104. }
  105. if (typeof rsp.result.auth_version !== "undefined" && typeof rsp.result.auth_at !== "undefined") {
  106. infoStr += `
  107. <tr>
  108. <td style="width:50%">授权版本:</td>
  109. <td>V${rsp.result.auth_version}.x.x(时间:${rsp.result.auth_at})</td>
  110. </tr>
  111. `;
  112. }
  113. if (rsp.result.core === null || rsp.result.core.code != 200) {
  114. //下面是DedeBIZ Core组件信息
  115. infoStr += `
  116. <tr>
  117. <td style="width:50%">版本组件:</td>
  118. <td><a href="${cfg_biz_dedebizUrl}/start?code=-1008" target="_blank" class="btn btn-danger btn-sm">如何启动组件</a></td>
  119. </tr>
  120. `;
  121. } else {
  122. dedebizInfo = JSON.parse(rsp.result.core.data);
  123. infoStr += `
  124. <tr>
  125. <td style="width:50%">版本组件:</td>
  126. <td><a href="javascript:ViewDedeBIZ()" class="btn btn-success btn-sm">查看组件信息</a></td>
  127. </tr>
  128. `;
  129. }
  130. infoStr += "</tbody></table>";
  131. $("#_systeminfo").html(infoStr);
  132. } else {
  133. $("#_systeminfo").html(`
  134. <table width="100%" class="table table-borderless">
  135. <tbody>
  136. <tr>
  137. <td style="width:60%">尚未启动商业版服务,原因:${rsp.msg}</td>
  138. <td style="text-align:right">当前版本:社区版<a href="${cfg_biz_dedebizUrl}/start?code=${rsp.code}" target="_blank" class="btn btn-success btn-sm" style="margin-left:10px">升级商业版</a></td>
  139. </tr>
  140. <tr>
  141. <td colspan="2">如果您已购买商业版授权,您可以在我们的授权中心查询到相信关授权信息,如果查询结果与实际授权不符,则说明您可能购买了非法商业授权,请及时与我们取得联系,谢谢。</td>
  142. </tr>
  143. </tbody>
  144. </table>
  145. `);
  146. }
  147. });
  148. }
  149. Date.prototype.Format = function (fmt) { //author: meizz
  150. var o = {
  151. "M+": this.getMonth() + 1, //月份
  152. "d+": this.getDate(), //日
  153. "h+": this.getHours(), //小时
  154. "m+": this.getMinutes(), //分
  155. "s+": this.getSeconds(), //秒
  156. "q+": Math.floor((this.getMonth() + 3) / 3), //季度
  157. "S": this.getMilliseconds() //毫秒
  158. };
  159. if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  160. for (var k in o)
  161. if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  162. return fmt;
  163. }
  164. function LoadStat() {
  165. $.get("index_body.php?dopost=get_statistics", function (data) {
  166. let rsp = JSON.parse(data);
  167. if (rsp.code == 200) {
  168. var tpv = parseInt(rsp.result.pv);
  169. var tuv = parseInt(rsp.result.uv);
  170. var tip = parseInt(rsp.result.ip);
  171. var tvv = parseInt(rsp.result.vv);
  172. $("#today_pv").html(tpv);
  173. $("#today_uv").html(tuv);
  174. $("#today_ip").html(tip);
  175. $("#today_vv").html(tvv);
  176. $.get("index_body.php?dopost=get_statistics&sdate=-1", function (data) {
  177. let rsp = JSON.parse(data);
  178. if (rsp.code == 200) {
  179. $("#total_pv").html(parseInt(rsp.result.pv) + tpv);
  180. $("#total_uv").html(parseInt(rsp.result.uv) + tuv);
  181. $("#total_ip").html(parseInt(rsp.result.ip) + tip);
  182. $("#total_vv").html(parseInt(rsp.result.vv) + tvv);
  183. }
  184. });
  185. }
  186. });
  187. var d = new Date();
  188. d.setDate(d.getDate() - 1);
  189. var s = d.Format("yyyy-MM-dd");
  190. s = s.replaceAll("-", "");
  191. $.get("index_body.php?dopost=get_statistics&sdate=" + s, function (data) {
  192. let rsp = JSON.parse(data);
  193. if (rsp.code == 200) {
  194. $("#yestoday_pv").html(rsp.result.pv);
  195. $("#yestoday_uv").html(rsp.result.uv);
  196. $("#yestoday_ip").html(rsp.result.ip);
  197. $("#yestoday_vv").html(rsp.result.vv);
  198. }
  199. });
  200. }
  201. async function LoadStatChart() {
  202. const ctx = document.getElementById('statChart').getContext('2d');
  203. let labels = [];
  204. let pvs = [];
  205. let ips = [];
  206. let uvs = [];
  207. let vvs = [];
  208. for (let i = 15; i > 0; i--) {
  209. var d = new Date();
  210. d.setDate(d.getDate() - i);
  211. var s = d.Format("yyyy-MM-dd");
  212. labels.push(d.Format("MM-dd"));
  213. s = s.replaceAll("-", "");
  214. let resp = await fetch("index_body.php?dopost=get_statistics&sdate=" + s);
  215. let data = await resp.json();
  216. if (data.code == 200) {
  217. pvs.push(typeof data.result.pv == "undefined" ? 0 : data.result.pv);
  218. ips.push(typeof data.result.ip == "undefined" ? 0 : data.result.ip);
  219. uvs.push(typeof data.result.uv == "undefined" ? 0 : data.result.uv);
  220. vvs.push(typeof data.result.vv == "undefined" ? 0 : data.result.vv);
  221. }
  222. }
  223. const myChart = new Chart(ctx, {
  224. type: 'line',
  225. options: {
  226. responsive: true,
  227. plugins: {
  228. legend: {
  229. position: 'top',
  230. },
  231. title: {
  232. display: true,
  233. text: `${cfg_webname}流量统计图`
  234. }
  235. }
  236. },
  237. data: {
  238. labels: labels,
  239. datasets: [
  240. {
  241. label: 'PV',
  242. data: pvs,
  243. borderColor: 'rgba(54, 162, 235, 1)',
  244. backgroundColor: 'rgba(54, 162, 235, 0.2)',
  245. borderWidth: 1
  246. }, {
  247. label: 'UV',
  248. data: uvs,
  249. borderColor: 'rgba(255, 206, 86, 1)',
  250. backgroundColor: 'rgba(255, 206, 86, 0.2)',
  251. borderWidth: 1
  252. }, {
  253. label: 'IP',
  254. data: ips,
  255. borderColor: 'rgba(255, 99, 132, 1)',
  256. backgroundColor: 'rgba(255, 99, 132, 0.2)',
  257. borderWidth: 1
  258. }
  259. , {
  260. label: '访问次数',
  261. data: vvs,
  262. borderColor: 'rgba(75, 192, 192, 1)',
  263. backgroundColor: 'rgba(75, 192, 192, 0.2)',
  264. borderWidth: 1
  265. }
  266. ]
  267. },
  268. });
  269. }
  270. $(document).ready(function () {
  271. LoadServer();
  272. LoadStat();
  273. LoadStatChart();
  274. setInterval(function () {
  275. LoadServer();
  276. }, 60000)
  277. });