index.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. if (cfr('REPORTDSTAT')) {
  3. $altCfg = $ubillingConfig->getAlter();
  4. if (@$altCfg['DSTAT_ENABLED']) {
  5. class ReportDstat {
  6. private $data = array();
  7. public function __construct() {
  8. //load actual data by users with enabled detailed stats
  9. $this->loadData();
  10. }
  11. /**
  12. * get all users with with enabled detailed stats and push it into private data prop
  13. *
  14. * @return void
  15. */
  16. private function loadData() {
  17. $query = "SELECT `login`,`Tariff`,`IP`, (`D0`+`D1`+`D2`+`D3`+`D4`+`D5`+`D6`+`D7`+`D8`+`D9`+`U0`+`U1`+`U2`+`U3`+`U4`+`U5`+`U6`+`U7`+`U8`+`U9`) AS `traffic` from `users` WHERE `DisabledDetailStat`!='1'";
  18. $alldata = simple_queryall($query);
  19. if (!empty($alldata)) {
  20. foreach ($alldata as $io => $each) {
  21. $this->data[$each['login']]['login'] = $each['login'];
  22. $this->data[$each['login']]['Tariff'] = $each['Tariff'];
  23. $this->data[$each['login']]['IP'] = $each['IP'];
  24. $this->data[$each['login']]['traffic'] = $each['traffic'];
  25. }
  26. }
  27. }
  28. /**
  29. * returns private propert data
  30. *
  31. * @return array
  32. */
  33. public function getData() {
  34. $result = $this->data;
  35. return ($result);
  36. }
  37. /**
  38. * renders report by existing private data prop
  39. *
  40. * @return string
  41. */
  42. public function render() {
  43. $cells = wf_TableCell(__('Login'));
  44. $cells .= wf_TableCell(__('Address'));
  45. $cells .= wf_TableCell(__('Real Name'));
  46. $cells .= wf_TableCell(__('IP'));
  47. $cells .= wf_TableCell(__('Tariff'));
  48. $cells .= wf_TableCell(__('Traffic'));
  49. $cells .= wf_TableCell(__('Actions'));
  50. $rows = wf_TableRow($cells, 'row1');
  51. if (!empty($this->data)) {
  52. $allrealnames = zb_UserGetAllRealnames();
  53. $alladdress = zb_AddressGetFulladdresslist();
  54. foreach ($this->data as $io => $each) {
  55. $loginLink = wf_Link("?module=userprofile&username=" . $each['login'], web_profile_icon() . ' ' . $each['login'], false, '');
  56. $cells = wf_TableCell($loginLink);
  57. $cells .= wf_TableCell(@$alladdress[$each['login']]);
  58. $cells .= wf_TableCell(@$allrealnames[$each['login']]);
  59. $cells .= wf_TableCell($each['IP']);
  60. $cells .= wf_TableCell($each['Tariff']);
  61. $cells .= wf_TableCell(stg_convert_size($each['traffic']), '', '', 'sorttable_customkey="' . $each['traffic'] . '"');
  62. $actionLinks = wf_Link('?module=pl_traffdetails&username=' . $each['login'], wf_img('skins/icon_stats.gif', __('Detailed stats')), false, '');
  63. $actionLinks .= wf_link('?module=dstatedit&username=' . $each['login'], web_edit_icon(), false, '');
  64. $cells .= wf_TableCell($actionLinks);
  65. $rows .= wf_TableRow($cells, 'row3');
  66. }
  67. }
  68. $result = wf_TableBody($rows, '100%', '0', 'sortable');
  69. return ($result);
  70. }
  71. }
  72. /**
  73. * controller and view section
  74. */
  75. $dstatReport = new ReportDstat();
  76. show_window(__('Users for which detailed statistics enabled'), $dstatReport->render());
  77. } else {
  78. show_error(__('This module is disabled'));
  79. }
  80. } else {
  81. show_error(__('You cant control this module'));
  82. }
  83. ?>