index.php 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <?php
  2. if ($ubillingConfig->getAlterParam('MULTIGEN_ENABLED')) {
  3. if (cfr('MULTIGEN')) {
  4. set_time_limit(0);
  5. $multigen = new MultiGen();
  6. if (ubRouting::checkGet('editnasoptions')) {
  7. $editNasId = ubRouting::get('editnasoptions');
  8. //editing NAS options
  9. if (ubRouting::checkPost('editnasid')) {
  10. $nasOptionsSaveResult = $multigen->saveNasOptions();
  11. if (empty($nasOptionsSaveResult)) {
  12. ubRouting::nav($multigen::URL_ME . '&editnasoptions=' . $editNasId);
  13. } else {
  14. show_error($nasOptionsSaveResult);
  15. }
  16. }
  17. //editing NAS services templates
  18. if (ubRouting::checkPost('newnasservicesid')) {
  19. $nasServicesSaveResult = $multigen->saveNasServices();
  20. if (empty($nasServicesSaveResult)) {
  21. ubRouting::nav($multigen::URL_ME . '&editnasoptions=' . $editNasId);
  22. } else {
  23. show_error($nasServicesSaveResult);
  24. }
  25. }
  26. //creating some attributes
  27. if (ubRouting::checkPost('newattributenasid')) {
  28. $nasAttributeCreationResult = $multigen->createNasAttribute();
  29. if (empty($nasAttributeCreationResult)) {
  30. ubRouting::nav($multigen::URL_ME . '&editnasoptions=' . ubRouting::post('newattributenasid'));
  31. } else {
  32. show_error($nasAttributeCreationResult);
  33. }
  34. }
  35. //editing existing attribute template
  36. if (ubRouting::checkPost('chattributenasid')) {
  37. $nasAttributeChangeResult = $multigen->saveNasAttribute();
  38. if (empty($nasAttributeChangeResult)) {
  39. ubRouting::nav($multigen::URL_ME . '&editnasoptions=' . ubRouting::post('chattributenasid'));
  40. } else {
  41. show_error($nasAttributeCreationResult);
  42. }
  43. }
  44. //deletion of existing attribute
  45. if (ubRouting::checkGet('deleteattributeid')) {
  46. $attributeDeletionResult = $multigen->deleteNasAttribute(ubRouting::get('deleteattributeid'));
  47. if (empty($attributeDeletionResult)) {
  48. ubRouting::nav($multigen::URL_ME . '&editnasoptions=' . $editNasId);
  49. } else {
  50. show_error($attributeDeletionResult);
  51. }
  52. }
  53. //manual atrributes regeneration
  54. if (ubRouting::checkGet('ajnasregen')) {
  55. $multigen->generateNasAttributes();
  56. die($multigen->renderScenarioStats());
  57. }
  58. //flush all scenarios attributes
  59. if (ubRouting::checkGet('ajscenarioflush')) {
  60. $multigen->flushAllScenarios();
  61. die($multigen->renderFlushAllScenariosNotice());
  62. }
  63. //cloning NAS options
  64. if (ubRouting::checkPost(array('clonenasfromid', 'clonenastoid'))) {
  65. if (ubRouting::checkPost('clonenasagree')) {
  66. $nasCloneResult = $multigen->cloneNasConfiguration(ubRouting::post('clonenasfromid'), ubRouting::post('clonenastoid'));
  67. if (empty($nasCloneResult)) {
  68. ubRouting::nav($multigen::URL_ME . '&editnasoptions=' . $editNasId);
  69. } else {
  70. show_error($nasCloneResult);
  71. }
  72. } else {
  73. show_error(__('You are not mentally prepared for this'));
  74. }
  75. }
  76. //copypasting NAS options
  77. if (ubRouting::checkPost('nascopypastetext')) {
  78. if (ubRouting::checkPost('nascopypasteagree')) {
  79. $nasCopyPasteResult = $multigen->pasteNasConfiguration($editNasId, ubRouting::post('nascopypastetext'));
  80. if (empty($nasCopyPasteResult)) {
  81. ubRouting::nav($multigen::URL_ME . '&editnasoptions=' . $editNasId);
  82. } else {
  83. show_error($nasCopyPasteResult);
  84. }
  85. } else {
  86. show_error(__('You are not mentally prepared for this'));
  87. }
  88. }
  89. //rendering basic options form
  90. show_window(__('NAS options') . ': ' . $multigen->getNaslabel($editNasId), $multigen->renderNasOptionsEditForm($editNasId));
  91. if ($multigen->nasHaveOptions($editNasId)) {
  92. //and attributes form
  93. show_window(__('Adding of RADIUS-attribute'), $multigen->renderNasAttributesCreateForm($editNasId));
  94. //listing of some existing attributes
  95. show_window(__('NAS attributes'), $multigen->renderNasAttributesList($editNasId));
  96. } else {
  97. show_warning(__('Before setting up the attributes, you must set the base NAS options'));
  98. }
  99. //rendering NAS control panel
  100. show_window('', $multigen->nasControlPanel($editNasId));
  101. } else {
  102. //render some accounting stats
  103. if (ubRouting::checkGet('dlmultigenlog')) {
  104. $multigen->logDownload();
  105. }
  106. if (ubRouting::checkGet('ajacct')) {
  107. $multigen->renderAcctStatsAjList();
  108. }
  109. if (!ubRouting::checkGet('manualpod') AND ! ubRouting::checkGet('userattributes')) {
  110. if (!ubRouting::checkGet('lastsessions')) {
  111. //ignored in lastsessions
  112. $dateFormControls = $multigen->renderDateSerachControls();
  113. } else {
  114. $dateFormControls = '';
  115. }
  116. show_window(__('Multigen NAS sessions stats') . ' ' . $multigen->renderLogControl(), $dateFormControls . $multigen->renderAcctStatsContainer());
  117. } else {
  118. //manual POD
  119. if (ubRouting::checkGet('manualpod')) {
  120. if (ubRouting::checkPost('manualpod')) {
  121. $manualPodResult = $multigen->runManualPod();
  122. if (empty($manualPodResult)) {
  123. ubRouting::nav($multigen::URL_ME . '&manualpod=true&username=' . ubRouting::get('username'));
  124. } else {
  125. show_error($manualPodResult);
  126. }
  127. }
  128. show_window(__('Terminate user session'), $multigen->renderManualPodForm(ubRouting::get('username')));
  129. }
  130. //render user attributes
  131. if (ubRouting::checkGet(array('userattributes', 'username'))) {
  132. //attribute deletion from some scenario
  133. if (ubRouting::checkGet(array('delattr', 'delscenario'))) {
  134. $attrDeletionResult = $multigen->deleteUserAttribute(ubRouting::get('delattr', 'int'), ubRouting::get('delscenario', 'mres'));
  135. if (empty($attrDeletionResult)) {
  136. ubRouting::nav($multigen::URL_ME . '&userattributes=true&username=' . ubRouting::get('username', 'mres'));
  137. } else {
  138. show_error($attrDeletionResult);
  139. }
  140. }
  141. //render users attributes list
  142. show_window(__('User attributes'), $multigen->renderUserAttributes(ubRouting::get('username', 'mres')));
  143. }
  144. }
  145. }
  146. zb_BillingStats(true);
  147. } else {
  148. show_error(__('Access denied'));
  149. }
  150. } else {
  151. show_error(__('This module is disabled'));
  152. }