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

258 lines
9.3KB

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