index.php 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <?php
  2. if (cfr('SMSZILLA')) {
  3. if ($ubillingConfig->getAlterParam('SMSZILLA_ENABLED')) {
  4. if ($ubillingConfig->getAlterParam('SENDDOG_ENABLED')) {
  5. //may be to slow :(
  6. set_time_limit(0);
  7. $smszilla = new SMSZilla();
  8. //rendering module control panel
  9. show_window('', $smszilla->panel());
  10. //templates management
  11. if (ubRouting::checkGet('templates')) {
  12. //creating new template
  13. if (ubRouting::checkPost(array('newtemplatename', 'newtemplatetext'))) {
  14. $smszilla->createTemplate(ubRouting::post('newtemplatename'), ubRouting::post('newtemplatetext'));
  15. ubRouting::nav($smszilla::URL_ME . '&templates=true');
  16. }
  17. //deleting existing template
  18. if (ubRouting::checkGet('deletetemplate')) {
  19. $templateDeletionResult = $smszilla->deleteTemplate(ubRouting::get('deletetemplate'));
  20. if (empty($templateDeletionResult)) {
  21. ubRouting::nav($smszilla::URL_ME . '&templates=true');
  22. } else {
  23. show_error($templateDeletionResult);
  24. }
  25. }
  26. //editing existing template
  27. if (ubRouting::checkGet('edittemplate')) {
  28. //save changes to database
  29. if (ubRouting::checkPost(array('edittemplateid', 'edittemplatename', 'edittemplatetext'))) {
  30. $templateEditingResult = $smszilla->saveTemplate(ubRouting::post('edittemplateid'), ubRouting::post('edittemplatename'), ubRouting::post('edittemplatetext'));
  31. if (empty($templateEditingResult)) {
  32. ubRouting::nav($smszilla::URL_ME . '&templates=true&edittemplate=' . ubRouting::post('edittemplateid'));
  33. } else {
  34. show_error($templateEditingResult);
  35. }
  36. }
  37. show_window(__('Edit template'), $smszilla->renderTemplateEditForm(ubRouting::get('edittemplate')));
  38. } else {
  39. show_window(__('Available templates'), $smszilla->renderTemplatesList());
  40. }
  41. }
  42. //filters management
  43. if (ubRouting::checkGet('filters')) {
  44. //rendering ajax inputs reply
  45. if (ubRouting::checkGet('newfilterdirection')) {
  46. $smszilla->catchAjRequest();
  47. }
  48. //creatin new filter
  49. if (ubRouting::checkPost('newfilterdirection')) {
  50. $creationResult = $smszilla->createFilter();
  51. if (empty($creationResult)) {
  52. ubRouting::nav($smszilla::URL_ME . '&filters=true');
  53. } else {
  54. show_error($creationResult);
  55. }
  56. }
  57. //filter deletion
  58. if (ubRouting::checkGet('deletefilterid')) {
  59. $filterDeletionResult = $smszilla->deleteFilter(ubRouting::get('deletefilterid'));
  60. if (empty($filterDeletionResult)) {
  61. ubRouting::nav($smszilla::URL_ME . '&filters=true');
  62. } else {
  63. show_error($filterDeletionResult);
  64. }
  65. }
  66. show_window(__('New filter creation'), $smszilla->renderFilterCreateForm());
  67. show_window(__('Available filters'), $smszilla->renderFiltersList());
  68. }
  69. //sending forms, etc
  70. if (ubRouting::checkGet(array('sending'))) {
  71. show_window(__('SMS sending'), $smszilla->renderSendingForm());
  72. zb_BillingStats(true);
  73. //preview ajax reply
  74. if (ubRouting::checkGet(array('ajpreview', 'filterid', 'templateid'))) {
  75. $smszilla->ajaxPreviewReply(ubRouting::get('filterid'), ubRouting::get('templateid'));
  76. }
  77. //processing of filters and performing sending
  78. if (ubRouting::checkPost(array('sendingtemplateid', 'sendingfilterid'))) {
  79. $smszilla->filtersPreprocessing(ubRouting::post('sendingfilterid'), ubRouting::post('sendingtemplateid'));
  80. }
  81. }
  82. //numbers lists management
  83. if (ubRouting::checkGet('numlists')) {
  84. //creating new numbers list
  85. if (ubRouting::checkPost('newnumlistname')) {
  86. $numListCreationResult = $smszilla->createNumList(ubRouting::post('newnumlistname'));
  87. if (empty($numListCreationResult)) {
  88. ubRouting::nav($smszilla::URL_ME . '&numlists=true');
  89. } else {
  90. show_error($numListCreationResult);
  91. }
  92. }
  93. //deleting numlist
  94. if (ubRouting::checkGet('deletenumlistid')) {
  95. $numListDeletionResult = $smszilla->deleteNumList(ubRouting::get('deletenumlistid'));
  96. if (empty($numListDeletionResult)) {
  97. ubRouting::nav($smszilla::URL_ME . '&numlists=true');
  98. } else {
  99. show_error($numListDeletionResult);
  100. }
  101. }
  102. //uploading numbers database
  103. if (ubRouting::checkPost(array('uploadnumlistnumbers', 'newnumslistid'))) {
  104. $smszilla->catchFileUpload();
  105. }
  106. //rendering ajax reply with numbers list data
  107. if (ubRouting::checkGet('ajnums')) {
  108. $smszilla->ajaxNumbersReply();
  109. }
  110. //editing existing numlist
  111. if (ubRouting::checkPost(array('editnumlistid', 'editnumlistname'))) {
  112. $smszilla->saveNumList(ubRouting::post('editnumlistid'), ubRouting::post('editnumlistname'));
  113. ubRouting::nav($smszilla::URL_ME . '&numlists=true&editnumlistid=' . ubRouting::post('editnumlistid'));
  114. }
  115. //deleting some single number
  116. if (ubRouting::checkGet('deletenumid')) {
  117. $smszilla->deleteNumlistNumber(ubRouting::get('deletenumid'));
  118. ubRouting::nav($smszilla::URL_ME . '&numlists=true');
  119. }
  120. //creating single number
  121. if (ubRouting::checkPost(array('newsinglenumlistid', 'newsinglenumlistmobile'))) {
  122. $singNumCreationResult = $smszilla->createNumlistSingleNumber(ubRouting::post('newsinglenumlistid'), ubRouting::post('newsinglenumlistmobile'), ubRouting::post('newsinglenumlistnotes'));
  123. if (empty($singNumCreationResult)) {
  124. ubRouting::nav($smszilla::URL_ME . '&numlists=true');
  125. } else {
  126. show_error($singNumCreationResult);
  127. }
  128. }
  129. //numlist cleanup
  130. if (ubRouting::checkPost('cleanupnumlistid')) {
  131. $numlistCleanupResult = $smszilla->cleanupNumlist(ubRouting::post('cleanupnumlistid'));
  132. if (empty($numlistCleanupResult)) {
  133. ubRouting::nav($smszilla::URL_ME . '&numlists=true');
  134. } else {
  135. show_error($numlistCleanupResult);
  136. }
  137. }
  138. if (ubRouting::checkGet('editnumlistid')) {
  139. //existing numlist edit forms
  140. show_window('', wf_BackLink($smszilla::URL_ME . '&numlists=true'));
  141. show_window(__('Edit'), $smszilla->renderNumListEditForm(ubRouting::get('editnumlistid')));
  142. } else {
  143. //rendering numlists
  144. show_window(__('Numbers lists'), $smszilla->renderNumListsList());
  145. show_window(__('Upload'), $smszilla->uploadNumListNumbersForm());
  146. show_window(__('Add'), $smszilla->createNumListNumberForm());
  147. show_window(__('Cleanup') . ' ' . __('from numbers assigned to users'), $smszilla->renderCleanupNumlistForm());
  148. show_window(__('Available numbers database'), $smszilla->renderNumsContainer());
  149. }
  150. }
  151. //per-number excludes
  152. if (ubRouting::checkGet('excludes')) {
  153. //creating new excludes
  154. if (ubRouting::checkPost('newexcludenumber')) {
  155. $smszilla->createExclude(ubRouting::post('newexcludenumber'));
  156. ubRouting::nav($smszilla::URL_ME . '&excludes=true');
  157. }
  158. //deleting existing exclude
  159. if (ubRouting::checkGet('deleteexclnumid')) {
  160. $smszilla->deleteExlude(ubRouting::get('deleteexclnumid'));
  161. ubRouting::nav($smszilla::URL_ME . '&excludes=true');
  162. }
  163. //list available exluded numbers base and some forms
  164. show_window(__('Create'), $smszilla->renderExcludeCreateForm());
  165. show_window(__('Excludes'), $smszilla->renderExcludeNumsList());
  166. }
  167. } else {
  168. show_error(__('SMSZilla requires SendDog'));
  169. }
  170. } else {
  171. show_error(__('This module is disabled'));
  172. }
  173. } else {
  174. show_error(__('Access denied'));
  175. }