zen.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * The zen file of misc module of ZenTaoPMS.
  4. *
  5. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
  6. * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  7. * @author Yuting Wang<wangyuting@easycorp.ltd>
  8. * @package misc
  9. * @link https://www.zentao.net
  10. */
  11. class miscZen extends misc
  12. {
  13. /**
  14. * 打印 hello world。
  15. * print hello world.
  16. *
  17. * @access public
  18. * @return string
  19. */
  20. public function hello()
  21. {
  22. return 'hello world from hello()<br />';
  23. }
  24. /**
  25. * Encode the statistics data into a binary string.
  26. *
  27. * @param array $statistics Statistics data.
  28. * @access public
  29. * @return array
  30. */
  31. public function encodeStatistics($statistics)
  32. {
  33. if(empty($statistics)) return array();
  34. $packInt = function($value) { return pack('N', $value);};
  35. $packStr = function($value) { return pack('a*', $value . "\0"); };
  36. $packedData = $packInt(zget($statistics, 'user', 0));
  37. $packedData .= $packInt(zget($statistics, 'execution', 0));
  38. $packedData .= $packInt(zget($statistics, 'task', 0));
  39. $packedData .= $packInt(zget($statistics, 'product', 0));
  40. $packedData .= $packInt(zget($statistics, 'story', 0));
  41. $packedData .= $packInt(zget($statistics, 'doc', 0));
  42. $packedData .= $packInt(zget($statistics, 'bug', 0));
  43. $packedData .= $packInt(zget($statistics, 'case', 0));
  44. $packedData .= $packInt(zget(zget($statistics, 'project', array()), 'scrum', 0));
  45. $packedData .= $packInt(zget(zget($statistics, 'project', array()), 'waterfall', 0));
  46. $packedData .= $packInt(zget(zget($statistics, 'project', array()), 'kanban', 0));
  47. $packedData .= $packInt(zget(zget($statistics, 'project', array()), 'agileplus', 0));
  48. $packedData .= $packInt(zget(zget($statistics, 'project', array()), 'waterfallplus', 0));
  49. $packedData .= $packInt(zget(zget($statistics, 'project', array()), 'ipd', 0));
  50. $packedData .= $packStr(zget($statistics, 'OS', ''));
  51. $packedData .= $packStr(zget($statistics, 'phpversion', ''));
  52. $packedData .= $packStr(zget($statistics, 'dbversion', ''));
  53. return array('data' => bin2hex($packedData));
  54. }
  55. }