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

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