autofreezemonth.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /*
  3. * auto freezing call which use AUTOFREEZE_CASH_LIMIT as month count
  4. */
  5. if (ubRouting::get('action') == 'autofreezemonth') {
  6. if (isset($alterconf['AUTOFREEZE_CASH_LIMIT'])) {
  7. $tariffPrices = zb_TariffGetPricesAll();
  8. $tariffPriceMultiplier = abs($alterconf['AUTOFREEZE_CASH_LIMIT']);
  9. $autoFreezeQuery = "SELECT * from `users` WHERE `Passive`='0' AND `Credit`='0';";
  10. $allUsersToFreeze = simple_queryall($autoFreezeQuery);
  11. $freezeCount = 0;
  12. //optional zbs SC check
  13. if (ubRouting::checkGet('param')) {
  14. if (ubRouting::get('param') == 'nocredit') {
  15. $creditZbsCheck = true;
  16. $creditZbsUsers = zb_CreditLogGetAll();
  17. } else {
  18. $creditZbsCheck = false;
  19. $creditZbsUsers = array();
  20. }
  21. } else {
  22. $creditZbsCheck = false;
  23. $creditZbsUsers = array();
  24. }
  25. if (!empty($allUsersToFreeze)) {
  26. foreach ($allUsersToFreeze as $efuidx => $eachfreezeuser) {
  27. $freezeLogin = $eachfreezeuser['login'];
  28. $freezeCash = $eachfreezeuser['Cash'];
  29. $freezeUserTariff = $eachfreezeuser['Tariff'];
  30. if (isset($tariffPrices[$freezeUserTariff])) {
  31. $freezeUserTariffPrice = $tariffPrices[$freezeUserTariff];
  32. $tariffFreezeLimit = '-' . ($freezeUserTariffPrice * $tariffPriceMultiplier);
  33. if (($freezeCash <= $tariffFreezeLimit) and ($freezeUserTariffPrice != 0)) {
  34. //zbs credit check
  35. if ($creditZbsCheck) {
  36. if (!isset($creditZbsUsers[$freezeLogin])) {
  37. $billing->setpassive($freezeLogin, '1');
  38. log_register('AUTOFREEZE (' . $freezeLogin . ') ON BALANCE ' . $freezeCash);
  39. $freezeCount++;
  40. } else {
  41. log_register('AUTOFREEZE (' . $freezeLogin . ') ON BALANCE ' . $freezeCash . ' SKIP BY ZBSSC');
  42. }
  43. } else {
  44. //normal freezing
  45. $billing->setpassive($freezeLogin, '1');
  46. log_register('AUTOFREEZE (' . $freezeLogin . ') ON BALANCE ' . $freezeCash);
  47. $freezeCount++;
  48. }
  49. }
  50. }
  51. }
  52. log_register('AUTOFREEZE DONE COUNT `' . $freezeCount . '`');
  53. die('OK:AUTOFREEZE');
  54. } else {
  55. die('OK:NO_USERS_TO_AUTOFREEZE');
  56. }
  57. } else {
  58. die('ERROR:NO_AUTOFREEZE_CASH_LIMIT');
  59. }
  60. }