senddog.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /*
  3. * SendDog queues processing
  4. */
  5. if (ubRouting::get('action') == 'senddog') {
  6. if ($ubillingConfig->getAlterParam('SENDDOG_ENABLED')) {
  7. $sendDogAdvOn = $ubillingConfig->getAlterParam('SMS_SERVICES_ADVANCED_ENABLED');
  8. $phpMailerOn = $ubillingConfig->getAlterParam('SMS_SERVICES_ADVANCED_PHPMAILER_ON');
  9. $parallelMode = ($ubillingConfig->getAlterParam('SENDDOG_PARALLEL_MODE')) ? true : false;
  10. $dogWalkingAllowed = ($parallelMode) ? false : true;
  11. $sendDogPidFile = SendDog::PID_PATH;
  12. $sendDogProcess = new StarDust('SENDDOG');
  13. if ($parallelMode) {
  14. // no another dog walking here
  15. if (!file_exists($sendDogPidFile)) {
  16. $dogWalkingAllowed = true;
  17. }
  18. }
  19. if ($dogWalkingAllowed) {
  20. // dog walking has begun
  21. file_put_contents($sendDogPidFile, curdatetime());
  22. if ($sendDogAdvOn) {
  23. $runSendDog = new SendDogAdvanced();
  24. } else {
  25. $runSendDog = new SendDog();
  26. }
  27. if (ubRouting::get('param') == 'chkmsgstatuses') {
  28. if ($ubillingConfig->getAlterParam('SMS_HISTORY_ON')) {
  29. if ($ubillingConfig->getAlterParam('SMS_SERVICES_ADVANCED_ENABLED')) {
  30. $runSendDog->smsProcessing(true);
  31. } else {
  32. $runSendDog->smsHistoryProcessing();
  33. }
  34. //the dog check msg statuses and finished walking
  35. if (file_exists($sendDogPidFile)) {
  36. unlink($sendDogPidFile);
  37. }
  38. die('OK:SENDDOG SMS STATUS CHECK PROCESSED');
  39. } else {
  40. //walking the dog suddenly stopped
  41. if (file_exists($sendDogPidFile)) {
  42. unlink($sendDogPidFile);
  43. }
  44. die('OK:SENDDOG SMS HISTORY DISABLED');
  45. }
  46. }
  47. $sendDogProcess->start();
  48. $sendDogTelegram = $runSendDog->telegramProcessing();
  49. $sendDogEmail = $runSendDog->emailProcessing();
  50. $sendDogSms = $runSendDog->smsProcessing();
  51. $sendDogEmailPMailer = '';
  52. if ($sendDogAdvOn and $phpMailerOn) {
  53. $sendDogEmailPMailer = ' PHPEML `' . $runSendDog->phpMailProcessing() . '`';
  54. }
  55. $sendDogProcess->stop();
  56. //the dog's walk is over
  57. if (file_exists($sendDogPidFile)) {
  58. unlink($sendDogPidFile);
  59. }
  60. die('OK:SENDDOG SMS `' . $sendDogSms . '` TLG `' . $sendDogTelegram . '` EML `' . $sendDogEmail . '`' . $sendDogEmailPMailer);
  61. } else {
  62. //Who Let The Dogs Out!
  63. die('WARNING:SENDDOG_ALREADY_RUNING');
  64. }
  65. } else {
  66. die('ERROR:SENDDOG_DISABLED');
  67. }
  68. }