index.php 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <?php
  2. if (cfr('TRINITYTV')) {
  3. $altCfg = $ubillingConfig->getAlter();
  4. if (@$altCfg['TRINITYTV_ENABLED']) {
  5. $interface = new TrinityTv();
  6. //primary control panelas
  7. show_window(__('TrinityTV'), $interface->renderPanel());
  8. if (wf_CheckGet(array('processing'))) {
  9. $mgFeeProcessingResult = $interface->subscriptionFeeProcessing();
  10. die($mgFeeProcessingResult);
  11. }
  12. //tariffs management
  13. if (wf_CheckGet(array('tariffs'))) {
  14. //tariff creation
  15. if (wf_CheckPost(array('newtariffname'))) {
  16. $tariffCreateResult = $interface->createTariff();
  17. if (!$tariffCreateResult) {
  18. rcms_redirect($interface::URL_ME . '&' . $interface::URL_TARIFFS);
  19. } else {
  20. show_window(__('Something went wrong'), $tariffCreateResult);
  21. }
  22. }
  23. //tariff editing
  24. if (wf_CheckPost(array(
  25. 'edittariffid',
  26. 'edittariffname'
  27. ))) {
  28. $tariffSaveResult = $interface->updateTariff();
  29. if (!$tariffSaveResult) {
  30. rcms_redirect($interface::URL_ME . '&' . $interface::URL_TARIFFS);
  31. } else {
  32. show_window(__('Something went wrong'), $tariffSaveResult);
  33. }
  34. }
  35. //tariff deletion
  36. if (wf_CheckGet(array('deletetariffid'))) {
  37. $errorMsg = $interface->deleteTariff($_GET['deletetariffid']);
  38. if (empty($errorMsg)) {
  39. rcms_redirect($interface::URL_ME . '&' . $interface::URL_TARIFFS);
  40. } else {
  41. show_window(__('Something went wrong'), $errorMsg);
  42. }
  43. }
  44. show_window(__('Available tariffs'), $interface->renderTariffs());
  45. }
  46. if (wf_CheckGet(array('subscriptions'))) {
  47. if (wf_CheckGet(array('username'))) {
  48. $subscriberID = $interface->getSubscriberId($_GET['username']);
  49. if (!empty($subscriberID)) {
  50. rcms_redirect($interface::URL_SUBSCRIBER . $subscriberID);
  51. } else {
  52. show_warning(__('This user have not existing TrinityTV subscription profile. You can register it using appropriate button on upper panel.'));
  53. show_window('', web_UserControls($_GET['username']));
  54. }
  55. }
  56. //jqdt data renderer
  57. if (wf_CheckGet(array('ajsubs'))) {
  58. $interface->subscribtionsListAjax();
  59. }
  60. //rendering user list container
  61. show_window(__('Subscriptions'), $interface->renderSubscribtions());
  62. zb_BillingStats(true);
  63. }
  64. if (wf_CheckGet(array('subscriberid'))) {
  65. //user blocking
  66. if (wf_CheckGet(array('blockuser'))) {
  67. $interface->setSubscriberActive($_GET['subscriberid'], false);
  68. rcms_redirect($interface::URL_SUBSCRIBER . $_GET['subscriberid']);
  69. }
  70. //user unblocking
  71. if (wf_CheckGet(array('unblockuser'))) {
  72. $interface->setSubscriberActive($_GET['subscriberid'], true);
  73. rcms_redirect($interface::URL_SUBSCRIBER . $_GET['subscriberid']);
  74. }
  75. //user tariff editing
  76. if (wf_CheckPost(array('changebasetariff'))) {
  77. $chargeFeeNow = (ubRouting::checkPost('dontchargefeenow')) ? false : true;
  78. $interface->changeTariffs($_GET['subscriberid'], $_POST['changebasetariff'], $chargeFeeNow);
  79. rcms_redirect($interface::URL_SUBSCRIBER . $_GET['subscriberid']);
  80. }
  81. //user device assign
  82. if (wf_CheckPost(array(
  83. 'device',
  84. 'subscriberid',
  85. 'userlogin',
  86. 'mac'
  87. ))) {
  88. $assignResult = $interface->addDevice($_POST['userlogin'], $_POST['mac']);
  89. if (empty($assignResult)) {
  90. rcms_redirect($interface::URL_SUBSCRIBER . $_GET['subscriberid']);
  91. } else {
  92. show_error($assignResult);
  93. }
  94. }
  95. // user device assign bu code
  96. if (wf_CheckPost(array(
  97. 'manualassigndevice',
  98. 'subscriberid',
  99. 'userlogin',
  100. 'code'
  101. ))) {
  102. $assignResult = $interface->addDeviceByCode($_POST['userlogin'], $_POST['code']);
  103. if (empty($assignResult)) {
  104. rcms_redirect($interface::URL_SUBSCRIBER . $_GET['subscriberid']);
  105. } else {
  106. show_error($assignResult);
  107. }
  108. }
  109. //deleting existing device for some user
  110. if (wf_CheckGet(array(
  111. 'deletedeviceid',
  112. 'subscriberid'
  113. ))) {
  114. $errorMsg = $interface->deleteDeviceById($_GET['deletedeviceid']);
  115. if (empty($errorMsg)) {
  116. rcms_redirect($interface::URL_SUBSCRIBER . $_GET['subscriberid']);
  117. } else {
  118. show_error($errorMsg);
  119. }
  120. }
  121. //user profile render
  122. show_window(__('Profile'), $interface->renderUserInfo($_GET['subscriberid']));
  123. show_window(__('Devices'), $interface->renderDevices($_GET['subscriberid']));
  124. if ($altCfg['ADCOMMENTS_ENABLED']) {
  125. $adcomments = new ADcomments('TRINITYTVSUBS');
  126. show_window(__('Additional comments'), $adcomments->renderComments($_GET['subscriberid']));
  127. }
  128. show_window('', wf_BackLink($interface::URL_ME . '&subscriptions=true'));
  129. }
  130. //new user manual registration
  131. if (wf_CheckPost(array(
  132. 'manualregister',
  133. 'manualregisterlogin',
  134. 'manualregistertariff'
  135. ))) {
  136. $manualRegResult = $interface->createSubscribtion($_POST['manualregisterlogin'], $_POST['manualregistertariff']);
  137. // Если создался без ошибок редиректим в профиль
  138. if (empty($manualRegResult)) {
  139. // Получим профиль подписчика
  140. $subscriberID = $interface->getSubscriberId($_POST['manualregisterlogin']);
  141. if (!empty($subscriberID)) {
  142. rcms_redirect($interface::URL_SUBSCRIBER . $subscriberID);
  143. } else {
  144. rcms_redirect($interface::URL_ME . '&subscriptions=true');
  145. }
  146. } else {
  147. show_error($manualRegResult);
  148. }
  149. }
  150. //black magic profile redirect or new subscriber registration
  151. if (wf_CheckGet(array('username'))) {
  152. $subscriberID = $interface->getSubscriberId($_GET['username']);
  153. if (!empty($subscriberID)) {
  154. rcms_redirect($interface::URL_SUBSCRIBER . $subscriberID);
  155. } else {
  156. show_warning(__('This user have not existing TrinityTV subscription profile. You can register it using appropriate button on upper panel.'));
  157. show_window('', web_UserControls($_GET['username']));
  158. }
  159. }
  160. //subscriptions report
  161. if (wf_CheckGet(array('reports'))) {
  162. //montly accounting report
  163. show_window(__('Subscriptions report'), $interface->renderSubscribtionsReportMonthly());
  164. }
  165. //rendering devices report
  166. if (ubRouting::checkGet('devices')) {
  167. //background json data with devices info
  168. if (ubRouting::checkGet('ajdevices')) {
  169. $interface->devicesListAjax();
  170. }
  171. show_window(__('Devices'), $interface->renderDevicesList());
  172. }
  173. } else {
  174. show_error(__('This module is disabled'));
  175. }
  176. } else {
  177. show_error(__('Acccess denied'));
  178. }
  179. ?>