autofreeze.php 2.1 KB

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