wsq_stat.inc.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id$
  7. */
  8. if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
  9. exit('Access Denied');
  10. }
  11. require_once DISCUZ_ROOT.'./source/plugin/wechat/wsq.class.php';
  12. require_once DISCUZ_ROOT . './source/plugin/wechat/setting.class.php';
  13. WeChatSetting::menu();
  14. showtips(lang('plugin/wechat', 'discuzqr_tips'));
  15. $data = wsq::stat();
  16. $d = date('Ymd', TIMESTAMP);
  17. if(!$data || $data->code != 0) {
  18. cpmsg_error('wechat:stat_failed');
  19. }
  20. $xa = $uv = $pv = $newthread = $reply = $share = $reflow = array();
  21. foreach($data->res as $d) {
  22. $xa[$d->ftime] = substr($d->ftime, 4, 2).'<br/>'.substr($d->ftime, 6, 2);
  23. $uv[$d->ftime] = intval($uv[$d->ftime]) + intval($d->uv);
  24. $pv[$d->ftime] = intval($pv[$d->ftime]) + intval($d->pv);
  25. $newthread[$d->ftime] = intval($newthread[$d->ftime]) + intval($d->newthread_num);
  26. $reply[$d->ftime] = intval($reply[$d->ftime]) + intval($d->reply_num);
  27. $share[$d->ftime] = intval($share[$d->ftime]) + intval($d->share_num);
  28. $reflow[$d->ftime] = intval($reflow[$d->ftime]) + intval($d->reflow_num);
  29. }
  30. $xas = "'".implode('\',\'', $xa)."'";
  31. $uvs = implode(',', $uv);
  32. $pvs = implode(',', $pv);
  33. $newthreads = implode(',', $newthread);
  34. $replys = implode(',', $reply);
  35. $shares = implode(',', $share);
  36. $reflows = implode(',', $reflow);
  37. $langarray = array('stat_newthread', 'stat_reply', 'stat_share', 'stat_reflow');
  38. $lang = array();
  39. foreach($langarray as $l) {
  40. $lang[$l] = lang('plugin/wechat', $l);
  41. }
  42. echo <<<EOF
  43. <script src="./source/plugin/wechat/js/jquery.min.js"></script>
  44. <script type="text/javascript" src="./source/plugin/wechat/js/highcharts.js"></script>
  45. <script type="text/javascript">
  46. var jq=$.noConflict();
  47. jq(function () {
  48. jq('#chart-container').highcharts({
  49. chart: {type: 'line'},
  50. title: {text: ''},
  51. xAxis: {categories: [$xas]},
  52. yAxis: {min:0, title: {text: ''}, plotLines: [{value: 0, width: 1, color: '#808080'}]},
  53. plotOptions: {line: {dataLabels: { enabled: false},enableMouseTracking: true}},
  54. series: [{name: 'UV', data: [$uvs]}, {name: 'PV', data: [$pvs]}, {name: '$lang[stat_newthread]',data: [$newthreads]}, {name: '$lang[stat_reply]',data: [$replys]}, {name: '$lang[stat_share]',data: [$shares]}, {name: '$lang[stat_reflow]',data: [$reflows]}]
  55. });
  56. });
  57. </script>
  58. <div id="chart-container" style="min-width:800px;height:400px"></div>
  59. EOF;
  60. $xa = array_reverse($xa, true);
  61. showtableheader('');
  62. showsubtitle(array('', 'UV', 'PV', $lang['stat_newthread'], $lang['stat_reply'], $lang['stat_share'], $lang['stat_reflow']));
  63. foreach($xa as $key=>$value) {
  64. showtablerow('', array(), array(
  65. $key,
  66. $uv[$key],
  67. $pv[$key],
  68. $newthread[$key],
  69. $reply[$key],
  70. $share[$key],
  71. $reflow[$key]
  72. ));
  73. }
  74. showtablefooter();