index.php 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735
  1. <?php
  2. if ($system->checkForRight('ONLINE')) {
  3. $alter_conf = $ubillingConfig->getAlter();
  4. $hp_mode = $alter_conf['ONLINE_HP_MODE'];
  5. if ($hp_mode) {
  6. /**
  7. * Renders user list JQuery DataTables container
  8. *
  9. * @global array $alter_conf
  10. *
  11. * @return string
  12. */
  13. function renderUserListContainer() {
  14. global $alter_conf;
  15. $saveState = 'false';
  16. if (isset($alter_conf['ONLINE_SAVE_STATE'])) {
  17. if ($alter_conf['ONLINE_SAVE_STATE']) {
  18. $saveState = 'true';
  19. }
  20. }
  21. $hp_mode = $alter_conf['ONLINE_HP_MODE'];
  22. $ShowContractField = false;
  23. if (isset($alter_conf['ONLINE_SHOW_CONTRACT_FIELD']) && $alter_conf['ONLINE_SHOW_CONTRACT_FIELD']) {
  24. $ShowContractField = true;
  25. }
  26. $showUserPhones = false;
  27. if (isset($alter_conf['ONLINE_SHOW_PHONES']) && $alter_conf['ONLINE_SHOW_PHONES']) {
  28. $showUserPhones = true;
  29. }
  30. $columnDefs = '';
  31. $showONUSignals = false;
  32. $showWIFISignals = false;
  33. if (isset($alter_conf['PON_ENABLED']) && $alter_conf['PON_ENABLED'] &&
  34. isset($alter_conf['ONLINE_SHOW_ONU_SIGNALS']) && $alter_conf['ONLINE_SHOW_ONU_SIGNALS']) {
  35. $showONUSignals = true;
  36. $colNum1 = (($ShowContractField and $showUserPhones) ? '5' : (($ShowContractField xor $showUserPhones) ? '4' : '3'));
  37. $columnDefs .= '{"targets": ' . $colNum1 . ',
  38. "render": function ( data, type, row ) {
  39. var sigColor = \'#000\';
  40. if (data > 0 || data < -27) {
  41. sigColor = \'#ab0000\';
  42. } else if (data > -27 && data < -25) {
  43. sigColor = \'#FF5500\';
  44. } else if (data == \'Offline\') {
  45. sigColor = \'#6500FF\';
  46. } else {
  47. sigColor = \'#005502\';
  48. }
  49. return \'<span style="color:\' + sigColor + \'">\' + data + \'</span>\';
  50. }
  51. } ';
  52. }
  53. if (isset($alter_conf['MTSIGMON_ENABLED']) && $alter_conf['MTSIGMON_ENABLED'] &&
  54. isset($alter_conf['ONLINE_SHOW_WIFI_SIGNALS']) && $alter_conf['ONLINE_SHOW_WIFI_SIGNALS']) {
  55. $showWIFISignals = true;
  56. // fuckin' XOR magic goes below this line. don't touch it(especially the parentheses) or you'll be cursed with hours of debugging
  57. // But to be serious - here we're trying to avoid a huge amount of "IFs" while checking the "ON" status of 3 optional columns:
  58. // $ShowContractField, $showUserPhones and $showONUSignals. And that's all is not just to show off with XOR or something.
  59. // Just because they go after each other in Online table and we need to apply some JQDT renderer function
  60. // for coloring only to $showWIFISignals - we need to determine certainly the number of $showWIFISignals column.
  61. // 1. We check, if all of 3 optional columns are "ON" - then $column2 will equal to "6". If not all of 3 optional columns are "ON" - we need to check further:
  62. // 2. If any 2 of 3 optional columns are "ON" and only one of those 3 is "OFF" - then $column2 will equal to "5"
  63. // 3. If only one of 3 optional columns is "ON" - then $column2 will equal to "4"
  64. // 4. Finally, if none of 3 optional columns are "ON" - then $column2 will equal to "3"
  65. $colNum2 = (($ShowContractField and $showUserPhones and $showONUSignals) ? '6' :
  66. ((($ShowContractField and $showUserPhones) xor ( $showUserPhones and $showONUSignals) xor ( $ShowContractField and $showONUSignals)) ? '5' :
  67. (($ShowContractField xor $showUserPhones xor $showONUSignals) ? '4' : '3')));
  68. $columnDefs .= (empty($columnDefs) ? '' : ', ');
  69. $columnDefs .= '{"targets": ' . $colNum2 . ',
  70. "render": function ( data, type, row ) {
  71. var signalArr = data.split(\' / \');
  72. var signal = \'\';
  73. if (1 in signalArr) {
  74. signal = (parseInt(signalArr[0]) > parseInt(signalArr[1])) ? signalArr[1] : signalArr[0];
  75. } else {
  76. signal = signalArr[0];
  77. }
  78. var sigColor = \'#000\';
  79. if (signal < -79) {
  80. sigColor = \'#ab0000\';
  81. } else if (signal > -80 && signal < -74) {
  82. sigColor = \'#FF5500\';
  83. } else {
  84. sigColor = \'#005502\';
  85. }
  86. return \'<span style="color:\' + sigColor + \'">\' + data + \'</span>\';
  87. }
  88. }, ';
  89. }
  90. $showLastFeeCharge = false;
  91. if (isset($alter_conf['ONLINE_SHOW_LAST_FEECHARGE']) && $alter_conf['ONLINE_SHOW_LAST_FEECHARGE']) {
  92. $showLastFeeCharge = true;
  93. }
  94. $columnDefs = '"columnDefs": [ ' . $columnDefs . '], ';
  95. //alternate center styling
  96. $alternateStyle = '';
  97. if (isset($alter_conf['ONLINE_ALTERNATE_VIEW'])) {
  98. if ($alter_conf['ONLINE_ALTERNATE_VIEW']) {
  99. $alternateStyle = wf_tag('style', false) . '#onlineusershp td { text-align:center !important; }' . wf_tag('style', true);
  100. }
  101. }
  102. if ($alter_conf['DN_ONLINE_DETECT']) {
  103. $columnFilters = '
  104. null, ' .
  105. ( ($hp_mode == 1 && $ShowContractField) ? 'null,' : '' ) .
  106. ' null, ' .
  107. ( ($hp_mode == 1 && $showUserPhones) ? 'null,' : '' ) .
  108. ' { "sType": "ip-address" }, ' .
  109. ( ($hp_mode == 1 && $showONUSignals) ? 'null, ' : '' ) .
  110. ( ($hp_mode == 1 && $showWIFISignals) ? 'null, ' : '' ) .
  111. ' null,
  112. null,
  113. null,
  114. { "sType": "file-size" },
  115. null,
  116. null ' .
  117. ( ($hp_mode == 1 && $showLastFeeCharge) ? ', null' : '' );
  118. } else {
  119. $columnFilters = '
  120. null, ' .
  121. ( ($hp_mode == 1 && $ShowContractField) ? 'null,' : '' ) .
  122. ' null, ' .
  123. ( ($hp_mode == 1 && $showUserPhones) ? 'null,' : '' ) .
  124. ' { "sType": "ip-address" }, ' .
  125. ( ($hp_mode == 1 && $showONUSignals) ? 'null, ' : '' ) .
  126. ( ($hp_mode == 1 && $showWIFISignals) ? 'null, ' : '' ) .
  127. ' null,
  128. null,
  129. { "sType": "file-size" },
  130. null,
  131. null ' .
  132. ( ($hp_mode == 1 && $showLastFeeCharge) ? ', null' : '' );
  133. }
  134. $dtcode = '
  135. <script type="text/javascript" charset="utf-8">
  136. jQuery.fn.dataTableExt.oSort[\'file-size-asc\'] = function(a,b) {
  137. var x = a.substring(0,a.length - 2);
  138. var y = b.substring(0,b.length - 2);
  139. var x_unit = (a.substring(a.length - 2, a.length) == "Mb" ?
  140. 1000 : (a.substring(a.length - 2, a.length) == "Gb" ? 1000000 : 1));
  141. var y_unit = (b.substring(b.length - 2, b.length) == "Mb" ?
  142. 1000 : (b.substring(b.length - 2, b.length) == "Gb" ? 1000000 : 1));
  143. x = parseInt( x * x_unit );
  144. y = parseInt( y * y_unit );
  145. return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  146. };
  147. jQuery.fn.dataTableExt.oSort[\'file-size-desc\'] = function(a,b) {
  148. var x = a.substring(0,a.length - 2);
  149. var y = b.substring(0,b.length - 2);
  150. var x_unit = (a.substring(a.length - 2, a.length) == "Mb" ?
  151. 1000 : (a.substring(a.length - 2, a.length) == "Gb" ? 1000000 : 1));
  152. var y_unit = (b.substring(b.length - 2, b.length) == "Mb" ?
  153. 1000 : (b.substring(b.length - 2, b.length) == "Gb" ? 1000000 : 1));
  154. x = parseInt( x * x_unit);
  155. y = parseInt( y * y_unit);
  156. return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  157. };
  158. jQuery.fn.dataTableExt.oSort[\'ip-address-asc\'] = function(a,b) {
  159. var m = a.split("."), x = "";
  160. var n = b.split("."), y = "";
  161. for(var i = 0; i < m.length; i++) {
  162. var item = m[i];
  163. if(item.length == 1) {
  164. x += "00" + item;
  165. } else if(item.length == 2) {
  166. x += "0" + item;
  167. } else {
  168. x += item;
  169. }
  170. }
  171. for(var i = 0; i < n.length; i++) {
  172. var item = n[i];
  173. if(item.length == 1) {
  174. y += "00" + item;
  175. } else if(item.length == 2) {
  176. y += "0" + item;
  177. } else {
  178. y += item;
  179. }
  180. }
  181. return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  182. };
  183. jQuery.fn.dataTableExt.oSort[\'ip-address-desc\'] = function(a,b) {
  184. var m = a.split("."), x = "";
  185. var n = b.split("."), y = "";
  186. for(var i = 0; i < m.length; i++) {
  187. var item = m[i];
  188. if(item.length == 1) {
  189. x += "00" + item;
  190. } else if (item.length == 2) {
  191. x += "0" + item;
  192. } else {
  193. x += item;
  194. }
  195. }
  196. for(var i = 0; i < n.length; i++) {
  197. var item = n[i];
  198. if(item.length == 1) {
  199. y += "00" + item;
  200. } else if (item.length == 2) {
  201. y += "0" + item;
  202. } else {
  203. y += item;
  204. }
  205. }
  206. return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  207. };
  208. $(document).ready(function() {
  209. $(\'#onlineusershp\').dataTable( {
  210. ' . $columnDefs . '
  211. "oLanguage": {
  212. "sLengthMenu": "' . __('Show') . ' _MENU_",
  213. "sZeroRecords": "' . __('Nothing found') . '",
  214. "sInfo": "' . __('Showing') . ' _START_ ' . __('to') . ' _END_ ' . __('of') . ' _TOTAL_ ' . __('users') . '",
  215. "sInfoEmpty": "' . __('Showing') . ' 0 ' . __('to') . ' 0 ' . __('of') . ' 0 ' . __('users') . '",
  216. "sInfoFiltered": "(' . __('Filtered') . ' ' . __('from') . ' _MAX_ ' . __('Total') . ')",
  217. "sSearch": "' . __('Search') . '",
  218. "sProcessing": "' . __('Processing') . '...",
  219. "oPaginate": {
  220. "sFirst": "' . __('First') . '",
  221. "sPrevious": "' . __('Previous') . '",
  222. "sNext": "' . __('Next') . '",
  223. "sLast": "' . __('Last') . '"
  224. },
  225. },
  226. "aoColumns": [
  227. ' . $columnFilters . '
  228. ],
  229. "bPaginate": true,
  230. "bLengthChange": true,
  231. "bFilter": true,
  232. "bSort": true,
  233. "bInfo": true,
  234. "bAutoWidth": false,
  235. "bProcessing": true,
  236. "iDisplayLength": 50,
  237. "sAjaxSource": \'?module=online&ajax\',
  238. "bDeferRender": true,
  239. "bJQueryUI": true,
  240. "pagingType": "full_numbers",
  241. "lengthMenu": [[10, 25, 50, 100, 200, -1], [10, 25, 50, 100, 200, "' . __('All') . '"]],
  242. "bStateSave": ' . $saveState . '
  243. } );
  244. } );
  245. </script>
  246. ';
  247. $customStyling = '
  248. <style>
  249. .dataTable tr {
  250. height: 33px; !important;
  251. min-height: 33px; !important;
  252. }
  253. .dataTable td th {
  254. vertical-align: middle; !important;
  255. }
  256. .dataTable img {
  257. vertical-align: middle; !important;
  258. width:15px; !important;
  259. display: inline; !important;
  260. float:left; !important;
  261. }
  262. </style>';
  263. $result = $dtcode;
  264. $result .= $customStyling;
  265. $result .= wf_tag('table', false, 'display compact', 'width="100%" id="onlineusershp"');
  266. //dn activity check
  267. if ($alter_conf['DN_ONLINE_DETECT']) {
  268. $onlineCells = wf_TableCell(__('Users online'));
  269. } else {
  270. $onlineCells = '';
  271. }
  272. $result .= wf_tag('thead', false);
  273. $result .= wf_tag('tr', false, 'row2');
  274. $result .= wf_TableCell(__('Full address'));
  275. $result .= ( ($hp_mode == 1 && $ShowContractField) ? wf_TableCell(__('Contract')) : '' );
  276. $result .= wf_TableCell(__('Real Name'));
  277. $result .= ( ($hp_mode == 1 && $showUserPhones) ? wf_TableCell(__("Phones")) : '' );
  278. $result .= wf_TableCell(__('IP'));
  279. $result .= ( ($hp_mode == 1 && $showONUSignals) ? wf_TableCell(__("ONU Signal")) : '' );
  280. $result .= ( ($hp_mode == 1 && $showWIFISignals) ? wf_TableCell(__("Signal") . ' WiFi') : '' );
  281. $result .= wf_TableCell(__('Tariff'));
  282. $result .= wf_TableCell(__('Active'));
  283. $result .= $onlineCells;
  284. $result .= wf_TableCell(__('Traffic'));
  285. $result .= wf_TableCell(__('Balance'));
  286. $result .= wf_TableCell(__('Credit'));
  287. $result .= ( ($hp_mode == 1 && $showLastFeeCharge) ? wf_TableCell(__("Last fee charge")) : '' );
  288. $result .= wf_tag('tr', true);
  289. $result .= wf_tag('thead', true);
  290. $result .= wf_tag('table', true);
  291. $result .= $alternateStyle;
  292. return ($result);
  293. }
  294. /**
  295. * Renders json data for user list. Manual HTML assebly instead of astral calls - for performance reasons.
  296. *
  297. * @global array $alter_conf
  298. *
  299. * @return string
  300. */
  301. function zb_AjaxOnlineDataSourceSafe() {
  302. global $alter_conf;
  303. $ubCache = new UbillingCache();
  304. $ishimuraOption = MultiGen::OPTION_ISHIMURA;
  305. $ishimuraTable = MultiGen::NAS_ISHIMURA;
  306. $additionalTraffic = array();
  307. if (@$alter_conf[$ishimuraOption]) {
  308. $query_hideki = "SELECT `login`,`D0`,`U0` from `" . $ishimuraTable . "` WHERE `month`='" . date("n") . "' AND `year`='" . curyear() . "'";
  309. $dataHideki = simple_queryall($query_hideki);
  310. if (!empty($dataHideki)) {
  311. foreach ($dataHideki as $io => $each) {
  312. $additionalTraffic[$each['login']] = $each['D0'] + $each['U0'];
  313. }
  314. }
  315. }
  316. if (@$alter_conf[OphanimFlow::OPTION_ENABLED]) {
  317. $ophanimFlow = new OphanimFlow();
  318. $ophTraf = $ophanimFlow->getAllUsersAggrTraff();
  319. if (!empty($ophTraf)) {
  320. foreach ($ophTraf as $ophLogin => $ophBytes) {
  321. if (isset($additionalTraffic[$ophLogin])) {
  322. $additionalTraffic[$ophLogin] += $ophBytes;
  323. } else {
  324. $additionalTraffic[$ophLogin] = $ophBytes;
  325. }
  326. }
  327. }
  328. }
  329. $allcontracts = array();
  330. $allcontractdates = array();
  331. $ShowContractField = false;
  332. $ShowContractDate = false;
  333. if (isset($alter_conf['ONLINE_SHOW_CONTRACT_FIELD']) && $alter_conf['ONLINE_SHOW_CONTRACT_FIELD']) {
  334. $ShowContractField = true;
  335. if (isset($alter_conf['ONLINE_SHOW_CONTRACT_DATE']) && $alter_conf['ONLINE_SHOW_CONTRACT_DATE']) {
  336. $ShowContractDate = true;
  337. }
  338. }
  339. if ($ShowContractField) {
  340. if ($ShowContractDate) {
  341. $query = "SELECT `contracts`.*, `contractdates`.`date` AS `contractdate`
  342. FROM `contracts`
  343. LEFT JOIN `contractdates` ON `contractdates`.`contract` = `contracts`.`contract`;
  344. ";
  345. } else {
  346. $query = "SELECT * FROM `contracts`;";
  347. }
  348. $tmpContracts = simple_queryall($query);
  349. if (!empty($tmpContracts)) {
  350. foreach ($tmpContracts as $io => $eachcontract) {
  351. $allcontracts[$eachcontract['login']] = $eachcontract['contract'];
  352. if ($ShowContractDate) {
  353. $allcontractdates[$eachcontract['login']] = $eachcontract['contractdate'];
  354. }
  355. }
  356. }
  357. }
  358. // getting user notes and adcomments to show
  359. $showUserNotes = false;
  360. $adCommentsON = false;
  361. if (isset($alter_conf['ONLINE_SHOW_USERNOTES']) && $alter_conf['ONLINE_SHOW_USERNOTES']) {
  362. $showUserNotes = true;
  363. if (isset($alter_conf['ADCOMMENTS_ENABLED']) && $alter_conf['ADCOMMENTS_ENABLED']) {
  364. $adCommentsON = true;
  365. $adcomments = new ADcomments('USERNOTES');
  366. }
  367. // collecting user notes
  368. $query = "SELECT * from `notes`";
  369. $tmpUserNotes = simple_queryall($query);
  370. if (!empty($tmpUserNotes)) {
  371. foreach ($tmpUserNotes as $io => $eachUN) {
  372. $allUserNotes[$eachUN['login']]['note'] = (empty($eachUN['note'])) ? '' : '( ' . $eachUN['note'] . ' )';
  373. $allUserNotes[$eachUN['login']]['adcomment'] = '';
  374. }
  375. }
  376. // collecting user adcomments
  377. $allAdComments = array();
  378. if ($adCommentsON) {
  379. // getting all adcomments for USERNOTES scope
  380. $allAdComments = $adcomments->getScopeItemsCommentsAll();
  381. if (!empty($allAdComments)) {
  382. foreach ($allAdComments as $eachLogin => $eachData) {
  383. $adCommentsCount = count($eachData);
  384. if (!isset($allUserNotes[$eachLogin])) {
  385. $allUserNotes[$eachLogin]['note'] = '';
  386. }
  387. if (empty($allUserNotes[$eachLogin]['note'])) {
  388. $adCommentsLink = wf_nbsp() . wf_Link('?module=notesedit&username=' . $eachLogin, __('Additional comments') . ':' . wf_nbsp(2) . $adCommentsCount);
  389. } else {
  390. $adCommentsLink = wf_nbsp() . wf_Link('?module=notesedit&username=' . $eachLogin, wf_tag('sup') . $adCommentsCount . wf_tag('sup', true));
  391. }
  392. $allUserNotes[$eachLogin]['adcomment'] = $adCommentsLink;
  393. }
  394. }
  395. }
  396. }
  397. // get users's ONU and WIFI signal level
  398. $allONUSignals = array();
  399. $allWiFiSignals = array();
  400. $showONUSignals = false;
  401. $showWIFISignals = false;
  402. if (isset($alter_conf['PON_ENABLED']) && $alter_conf['PON_ENABLED'] &&
  403. isset($alter_conf['ONLINE_SHOW_ONU_SIGNALS']) && $alter_conf['ONLINE_SHOW_ONU_SIGNALS']) {
  404. $showONUSignals = true;
  405. $allONUSignals = PONizer::getAllONUSignals();
  406. }
  407. if (isset($alter_conf['MTSIGMON_ENABLED']) && $alter_conf['MTSIGMON_ENABLED'] &&
  408. isset($alter_conf['ONLINE_SHOW_WIFI_SIGNALS']) && $alter_conf['ONLINE_SHOW_WIFI_SIGNALS']) {
  409. $showWIFISignals = true;
  410. $WiFiSigmon = new MTsigmon();
  411. $allWiFiSignals = $WiFiSigmon->getAllWiFiSignals();
  412. }
  413. $allFees = array();
  414. $showLastFeeCharge = false;
  415. if (isset($alter_conf['ONLINE_SHOW_LAST_FEECHARGE']) && $alter_conf['ONLINE_SHOW_LAST_FEECHARGE']) {
  416. $showLastFeeCharge = true;
  417. $allFees = $ubCache->get('STG_LAST_FEE_CHARGE');
  418. // yep, just trying to sustain legacy
  419. if (empty($allFees)) {
  420. $allFees = $ubCache->get('STG_FEE_CHARGE');
  421. }
  422. }
  423. $showUserPhones = false;
  424. $allUserPhones = array();
  425. if (isset($alter_conf['ONLINE_SHOW_PHONES']) && $alter_conf['ONLINE_SHOW_PHONES']) {
  426. $showUserPhones = true;
  427. $allUserPhones = zb_GetAllOnlineTabPhones();
  428. }
  429. $query = "SELECT * FROM `users`";
  430. $query_fio = "SELECT * from `realname`";
  431. $allusers = simple_queryall($query);
  432. $allfioz = simple_queryall($query_fio);
  433. $fioz = zb_UserGetAllRealnames();
  434. $detect_address = zb_AddressGetFulladdresslist();
  435. $ucount = 0;
  436. $deadUsers = array();
  437. $displayFreezeFlag = (@$alter_conf['ONLINE_SHOW_FREEZE']) ? true : false;
  438. //alternate view of online module
  439. $addrDelimiter = '';
  440. if (isset($alter_conf['ONLINE_ALTERNATE_VIEW'])) {
  441. if ($alter_conf['ONLINE_ALTERNATE_VIEW']) {
  442. $addrDelimiter = wf_tag('br');
  443. }
  444. }
  445. //hide dead users array
  446. if ($alter_conf['DEAD_HIDE']) {
  447. if (!empty($alter_conf['DEAD_TAGID'])) {
  448. $tagDead = vf($alter_conf['DEAD_TAGID'], 3);
  449. $query_dead = "SELECT `login`,`tagid` from `tags` WHERE `tagid`='" . $tagDead . "'";
  450. $alldead = simple_queryall($query_dead);
  451. if (!empty($alldead)) {
  452. foreach ($alldead as $idead => $eachDead) {
  453. $deadUsers[$eachDead['login']] = $eachDead['tagid'];
  454. }
  455. }
  456. }
  457. }
  458. $hidePictTitles = false;
  459. if (isset($alter_conf['ONLINE_HIDE_PICT_TITLES']) && $alter_conf['ONLINE_HIDE_PICT_TITLES']) {
  460. $hidePictTitles = true;
  461. }
  462. $jsonAAData = array();
  463. if (!empty($allusers)) {
  464. $totalusers = sizeof($allusers);
  465. foreach ($allusers as $io => $eachuser) {
  466. $tinet = 0;
  467. $ucount++;
  468. $cash = $eachuser['Cash'];
  469. $credit = $eachuser['Credit'];
  470. for ($classcounter = 0; $classcounter <= 9; $classcounter++) {
  471. $dc = 'D' . $classcounter . '';
  472. $uc = 'U' . $classcounter . '';
  473. $tinet = $tinet + ($eachuser[$dc] + $eachuser[$uc]);
  474. }
  475. //ishimura and ophanim traffic mixing
  476. $currentAdditionalTraff = (isset($additionalTraffic[$eachuser['login']])) ? $additionalTraffic[$eachuser['login']] : 0;
  477. $tinet = $tinet + $currentAdditionalTraff;
  478. $act = '<img src=skins/icon_active.gif>' . (($hidePictTitles) ? '' : __('Yes'));
  479. //finance check
  480. if ($cash < '-' . $credit) {
  481. $act = '<img src=skins/icon_inactive.gif>' . (($hidePictTitles) ? '' : __('No'));
  482. }
  483. if ($displayFreezeFlag) {
  484. if (@$alter_conf['ONLINE_SHOW_FREEZE_LAT']) {
  485. $act .= $eachuser['Passive'] ? ' <img src=skins/icon_passive.gif>' . date('Y-m-d', $eachuser['LastActivityTime']) : '';
  486. } else {
  487. $act .= $eachuser['Passive'] ? ' <img src=skins/icon_passive.gif>' . (($hidePictTitles) ? '' : __('Freezed')) : '';
  488. }
  489. }
  490. //online activity check
  491. if ($alter_conf['DN_ONLINE_DETECT']) {
  492. $onlineFlag = '<img src=skins/icon_nostar.gif> ' . (($hidePictTitles) ? '' : __('No'));
  493. if (file_exists(DATA_PATH . 'dn/' . $eachuser['login'])) {
  494. $onlineFlag = '<img src=skins/icon_star.gif> ' . (($hidePictTitles) ? '' : __('Yes'));
  495. }
  496. } else {
  497. $onlineFlag = '';
  498. }
  499. @$clearuseraddress = $detect_address[$eachuser['login']];
  500. //additional finance links
  501. if ($alter_conf['FAST_CASH_LINK']) {
  502. $fastcashlink = ' <a href=?module=addcash&username=' . $eachuser['login'] . '#cashfield><img src=skins/icon_dollar_16.gif title=' . __('Money') . ' border=0></a>&nbsp;';
  503. } else {
  504. $fastcashlink = '';
  505. }
  506. $onuSignal = '';
  507. $wifiSignal = '';
  508. $feeCharge = '';
  509. $userPhones = '';
  510. if ($showONUSignals and isset($allONUSignals[$eachuser['login']])) {
  511. $onuSignal = $allONUSignals[$eachuser['login']];
  512. $onuSignal = preg_replace("#[^a-z0-9A-Z\-_\.\/]#Uis", '', $onuSignal);
  513. }
  514. if ($showWIFISignals and isset($allWiFiSignals[$eachuser['login']])) {
  515. $wifiSignal = $allWiFiSignals[$eachuser['login']];
  516. $wifiSignal = preg_replace("#[^a-z0-9A-Z\-_\.\/]#Uis", '', $wifiSignal);
  517. }
  518. if ($showLastFeeCharge and isset($allFees[$eachuser['login']])) {
  519. // legacy, legacy, legacy, legacy...
  520. if (isset($allFees[$eachuser['login']]['balance_to']) and isset($allFees[$eachuser['login']]['balance_from'])) {
  521. $feeCharge = $allFees[$eachuser['login']]['max_date'] . '<br />' . ($allFees[$eachuser['login']]['balance_to'] - $allFees[$eachuser['login']]['balance_from']);
  522. } else {
  523. $feeCharge = $allFees[$eachuser['login']]['max_date'] . '<br />' . $allFees[$eachuser['login']]['summ'];
  524. }
  525. }
  526. if ($showUserPhones and isset($allUserPhones[$eachuser['login']])) {
  527. $userPhones = $allUserPhones[$eachuser['login']];
  528. }
  529. if (!$alter_conf['DEAD_HIDE']) {
  530. $jsonItem = array();
  531. $jsonItem[] = '<a href=?module=traffstats&username=' . $eachuser['login'] . '><img src=skins/icon_stats_16.gif border=0 title=' . __('Stats') . '></a> <a href=?module=userprofile&username=' . $eachuser['login'] . '><img src=skins/icon_user_16.gif border=0 title=' . __('Profile') . '></a> ' . $fastcashlink . $addrDelimiter . $clearuseraddress;
  532. if ($ShowContractField) {
  533. $jsonItem[] = @$allcontracts[$eachuser['login']] . (($ShowContractDate) ? wf_tag('br') . @$allcontractdates[$eachuser['login']] : '');
  534. }
  535. $jsonItem[] = @$fioz[$eachuser['login']] . (($showUserNotes and isset($allUserNotes[$eachuser['login']]['note'])) ? wf_delimiter(0) . $allUserNotes[$eachuser['login']]['note'] . $allUserNotes[$eachuser['login']]['adcomment'] : '');
  536. if ($showUserPhones) {
  537. $jsonItem[] = $userPhones;
  538. }
  539. $jsonItem[] = $eachuser['IP'];
  540. if ($showONUSignals) {
  541. $jsonItem[] = $onuSignal;
  542. }
  543. if ($showWIFISignals) {
  544. $jsonItem[] = $wifiSignal;
  545. }
  546. $jsonItem[] = $eachuser['Tariff'];
  547. $jsonItem[] = $act;
  548. if (!empty($onlineFlag)) {
  549. $jsonItem[] = $onlineFlag;
  550. }
  551. $jsonItem[] = zb_TraffToGb($tinet);
  552. $jsonItem[] = "" . round($eachuser['Cash'], 2);
  553. $jsonItem[] = "" . round($eachuser['Credit'], 2);
  554. if ($showLastFeeCharge) {
  555. $jsonItem[] = $feeCharge;
  556. }
  557. $jsonAAData[] = $jsonItem;
  558. } else {
  559. if (!isset($deadUsers[$eachuser['login']])) {
  560. $jsonItem = array();
  561. $jsonItem[] = '<a href=?module=traffstats&username=' . $eachuser['login'] . '><img src=skins/icon_stats_16.gif border=0 title=' . __('Stats') . '></a> <a href=?module=userprofile&username=' . $eachuser['login'] . '><img src=skins/icon_user_16.gif border=0 title=' . __('Profile') . '></a> ' . $fastcashlink . $clearuseraddress;
  562. if ($ShowContractField) {
  563. $jsonItem[] = $allcontracts[$eachuser['login']] . ( ($ShowContractDate) ? wf_tag('br') . $allcontractdates[$eachuser['login']] : '' );
  564. }
  565. $jsonItem[] = @$fioz[$eachuser['login']] . (($showUserNotes and isset($allUserNotes[$eachuser['login']]['note'])) ? wf_delimiter(0) . $allUserNotes[$eachuser['login']]['note'] . $allUserNotes[$eachuser['login']]['adcomment'] : '');
  566. if ($showUserPhones) {
  567. $jsonItem[] = $userPhones;
  568. }
  569. $jsonItem[] = $eachuser['IP'];
  570. if ($showONUSignals) {
  571. $jsonItem[] = $onuSignal;
  572. }
  573. if ($showWIFISignals) {
  574. $jsonItem[] = $wifiSignal;
  575. }
  576. $jsonItem[] = $eachuser['Tariff'];
  577. $jsonItem[] = $act;
  578. if (!empty($onlineFlag)) {
  579. $jsonItem[] = $onlineFlag;
  580. }
  581. $jsonItem[] = zb_TraffToGb($tinet);
  582. $jsonItem[] = "" . round($eachuser['Cash'], 2);
  583. $jsonItem[] = "" . round($eachuser['Credit'], 2);
  584. if ($showLastFeeCharge) {
  585. $jsonItem[] = $feeCharge;
  586. }
  587. $jsonAAData[] = $jsonItem;
  588. }
  589. }
  590. }
  591. }
  592. /**
  593. Prevail, the time has come
  594. Crush the enemy, one by one
  595. Prevail, like a venomous snake
  596. Ready to strike and dominate
  597. Prevail, we conquer as one
  598. Pound the enemy, 'till it's done
  599. Prevail!
  600. */
  601. $result = array("aaData" => $jsonAAData);
  602. return(json_encode($result));
  603. }
  604. // Ajax data source display
  605. if (isset($_GET['ajax'])) {
  606. if ($hp_mode) {
  607. //default rendering
  608. if ($hp_mode == 1) {
  609. die(zb_AjaxOnlineDataSourceSafe());
  610. }
  611. //fast with caching, for huge databases.
  612. if ($hp_mode == 2) {
  613. $defaultJsonCacheTime = 600;
  614. $onlineJsonCache = new UbillingCache();
  615. $fastJsonReply = $onlineJsonCache->getCallback('HPONLINEJSON', function () {
  616. return (zb_AjaxOnlineDataSourceSafe());
  617. }, $defaultJsonCacheTime);
  618. die($fastJsonReply);
  619. }
  620. }
  621. }
  622. show_window(__('Users'), renderUserListContainer());
  623. } else {
  624. show_error(__('This module is disabled'));
  625. }
  626. } else {
  627. show_error(__('Access denied'));
  628. }