index.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. <?php
  2. $altCfg = $ubillingConfig->getAlter();
  3. $legacyPonizerView = 0;
  4. set_time_limit(0);
  5. if ($altCfg['PON_ENABLED']) {
  6. if (cfr('PON')) {
  7. //Checking is ponizer legacy enabled?
  8. if (isset($altCfg['PONIZER_LEGACY_VIEW'])) {
  9. if ($altCfg['PONIZER_LEGACY_VIEW']) {
  10. $legacyPonizerView = $altCfg['PONIZER_LEGACY_VIEW'];
  11. }
  12. }
  13. //Creating new PONizer object instance
  14. if ($legacyPonizerView) {
  15. $pon = new PONizerLegacy();
  16. } else {
  17. $oltLoadData = '';
  18. if (ubRouting::checkGet(array('ajaxonu', 'oltid'))) {
  19. //load only selected OLTs data on ONU list rendering
  20. $oltLoadData = ubRouting::get('oltid');
  21. }
  22. $pon = new PONizer($oltLoadData);
  23. }
  24. //getting ONU json data from some OLT
  25. if (ubRouting::checkGet(array('ajaxonu', 'oltid'))) {
  26. $pon->ajaxOnuData(ubRouting::get('oltid', 'int'));
  27. }
  28. //getting full ONU list json data
  29. if ($legacyPonizerView) {
  30. if (ubRouting::checkGet(array('ajaxonu', 'legacyView'))) {
  31. $pon->ajaxOnuData();
  32. }
  33. }
  34. //creating new ONU device
  35. if (ubRouting::checkPost(array('createnewonu', 'newoltid'))) {
  36. //MAC or Serial is required
  37. if (ubRouting::checkPost('newmac') OR ubRouting::checkPost('newserial')) {
  38. if (cfr('PONEDIT')) {
  39. $onuCreateResult = $pon->onuCreate(ubRouting::post('newonumodelid'), ubRouting::post('newoltid'), ubRouting::post('newip'), ubRouting::post('newmac'), ubRouting::post('newserial'), ubRouting::post('newlogin'));
  40. if ($onuCreateResult) {
  41. $newCreatedONUId = simple_get_lastid('pononu');
  42. if ($ubillingConfig->getAlterParam('OPT82_ENABLED')) {
  43. multinet_rebuild_all_handlers();
  44. }
  45. ubRouting::nav($pon::URL_ONU . $newCreatedONUId);
  46. } else {
  47. show_error(__('This MAC have wrong format') . ' ' . __('or') . ' ' . __('MAC duplicate'));
  48. }
  49. } else {
  50. log_register('PON CREATE ONU ACCESS VIOLATION');
  51. show_error(__('Access denied'));
  52. }
  53. }
  54. }
  55. //perform search in nethosts for a MAC and a login linked to it
  56. if (ubRouting::checkGet(array('searchunknownonu', 'searchunknownmac'))) {
  57. die($pon->getUserByONUMAC(ubRouting::get('searchunknownmac'), ubRouting::get('searchunknownincrement'), ubRouting::get('searchunknownserialize')));
  58. }
  59. //getting unregistered ONU list
  60. if (ubRouting::checkGet('ajaxunknownonu')) {
  61. $pon->ajaxOnuUnknownData();
  62. }
  63. //getting OLT FDB list
  64. if (ubRouting::checkGet(array('ajaxoltfdb', 'onuid'))) {
  65. $pon->ajaxOltFdbData(ubRouting::get('onuid', 'int'));
  66. }
  67. //edits existing ONU in database
  68. if (ubRouting::checkPost(array('editonu', 'editoltid', 'editmac'))) {
  69. $pon->onuSave(ubRouting::post('editonu'), ubRouting::post('editonumodelid'), ubRouting::post('editoltid'), ubRouting::post('editip'), ubRouting::post('editmac'), ubRouting::post('editserial'), ubRouting::post('editlogin'));
  70. if ($ubillingConfig->getAlterParam('OPT82_ENABLED')) {
  71. multinet_rebuild_all_handlers();
  72. }
  73. ubRouting::nav($pon::URL_ONU . ubRouting::post('editonu'));
  74. }
  75. //deleting existing ONU
  76. if (ubRouting::checkGet('deleteonu')) {
  77. if (cfr('PONDEL')) {
  78. $pon->onuDelete(ubRouting::get('deleteonu'));
  79. if ($ubillingConfig->getAlterParam('OPT82_ENABLED')) {
  80. multinet_rebuild_all_handlers();
  81. }
  82. ubRouting::nav($pon::URL_ONULIST);
  83. } else {
  84. log_register('PON DELETE ONU [' . ubRouting::get('deleteonu', 'int') . '] ACCESS VIOLATION');
  85. show_error(__('Access denied'));
  86. }
  87. }
  88. //burial of some ONU
  89. if (ubRouting::checkGet('onuburial')) {
  90. if (cfr('PONEDIT')) {
  91. $pon->onuBurial(ubRouting::get('onuburial'));
  92. ubRouting::nav($pon::URL_ONU . ubRouting::get('onuburial'));
  93. } else {
  94. show_error(__('Access denied'));
  95. }
  96. }
  97. //resurrection of some ONU
  98. if (ubRouting::checkGet('onuresurrect')) {
  99. if (cfr('PONEDIT')) {
  100. $pon->onuResurrect(ubRouting::get('onuresurrect'));
  101. ubRouting::nav($pon::URL_ONU . ubRouting::get('onuresurrect'));
  102. } else {
  103. show_error(__('Access denied'));
  104. }
  105. }
  106. //assigning ONU with some user
  107. if (ubRouting::checkPost(array('assignonulogin', 'assignonuid'))) {
  108. if (cfr('PONEDIT')) {
  109. $pon->onuAssign(ubRouting::post('assignonuid'), ubRouting::post('assignonulogin'));
  110. if ($ubillingConfig->getAlterParam('OPT82_ENABLED')) {
  111. multinet_rebuild_all_handlers();
  112. }
  113. ubRouting::nav($pon::URL_ONU . ubRouting::post('assignonuid'));
  114. } else {
  115. show_error(__('Access denied'));
  116. }
  117. }
  118. //force OLT polling
  119. if (ubRouting::checkGet('forcepoll')) {
  120. $pon->oltDevicesPolling(true);
  121. if (ubRouting::checkGet('uol')) {
  122. //back to unknown ONU list
  123. ubRouting::nav($pon::URL_ME . '&unknownonulist=true');
  124. } else {
  125. //or just to OLT list
  126. ubRouting::nav($pon::URL_ONULIST);
  127. }
  128. }
  129. //force single OLT polling
  130. if (ubRouting::checkGet('forceoltidpoll')) {
  131. $pon->pollOltSignal(ubRouting::get('forceoltidpoll'));
  132. if (!ubRouting::checkGet('IndividualRefresh') OR ! wf_getBoolFromVar(ubRouting::get('IndividualRefresh'), true)) {
  133. ubRouting::nav($pon::URL_ME);
  134. }
  135. }
  136. //user assigned ONU search or assign form
  137. if (ubRouting::checkGet('username')) {
  138. //try to detect ONU id by user login
  139. $login = ubRouting::get('username');
  140. $userOnuIds = $pon->getOnuIdByUserAll($login);
  141. if ($userOnuIds) {
  142. if (sizeof($userOnuIds) > 1) {
  143. //multiple ONUs here... rendering ONU navigation here
  144. show_window(__('This user has multiple devices assigned'), $pon->renderOnuNavBar($userOnuIds));
  145. show_window('', web_UserControls(ubRouting::get('username')));
  146. } else {
  147. //redirecting to single assigned ONU
  148. ubRouting::nav($pon::URL_ONU . $userOnuIds[0]);
  149. }
  150. } else {
  151. //rendering assign form
  152. show_window(__('ONU assign'), $pon->onuAssignForm($login));
  153. }
  154. }
  155. //unknown ONU list
  156. if (ubRouting::checkGet('unknownonulist')) {
  157. if (cfr('PONEDIT')) {
  158. if (ubRouting::checkGet(array('fastreg', 'oltid', 'onumac'))) {
  159. $newOltId = ubRouting::get('oltid', 'int');
  160. $newOnuMac = ubRouting::get('onumac', 'mres');
  161. show_window(__('Register new ONU'), wf_BackLink($pon::URL_ME . '&unknownonulist=true', __('Back'), true) . $pon->onuRegisterForm($newOltId, $newOnuMac));
  162. } else {
  163. show_window(__('Unknown ONU'), $pon->controls() . $pon->renderUnknownOnuList());
  164. }
  165. } else {
  166. show_error(__('Access denied'));
  167. }
  168. }
  169. //All OLTs FDB cache list
  170. if (ubRouting::checkGet('fdbcachelist')) {
  171. if (ubRouting::checkGet('ajaxfdblist')) {
  172. $pon->ajaxFdbCacheList();
  173. }
  174. if (ubRouting::checkGet('fixonuoltassings')) {
  175. if (cfr('ROOT')) {
  176. show_window(__('Fix OLT inconsistencies'), $pon->fixOnuOltAssigns());
  177. } else {
  178. show_error(__('Access denied'));
  179. }
  180. } else {
  181. show_window(__('Current FDB cache'), $pon->renderOnuFdbCache());
  182. }
  183. }
  184. //Custom OLT interfaces description
  185. if (ubRouting::checkGet(array('oltid', 'if'))) {
  186. if (cfr('PONEDIT')) {
  187. if (@$altCfg['PON_IFDESC']) {
  188. //saving manual descriptions
  189. if (ubRouting::checkPost(array('newoltiddesc', 'newoltif'))) {
  190. $pon->ponInterfaces->save();
  191. ubRouting::nav($pon::URL_ME . '&oltid=' . ubRouting::post('newoltiddesc') . '&if=' . ubRouting::post('newoltif'));
  192. }
  193. //manual interface description controller
  194. show_window(__('Description'), $pon->ponInterfaces->renderIfForm(ubRouting::get('oltid'), ubRouting::get('if')));
  195. } else {
  196. show_error(__('This module is disabled'));
  197. }
  198. } else {
  199. show_error(__('Access denied'));
  200. }
  201. }
  202. //Basic OLTs stats
  203. if (ubRouting::checkGet('oltstats')) {
  204. show_window(__('Stats'), $pon->renderOltStats());
  205. }
  206. //pondata cache cleanup
  207. if (ubRouting::checkGet('pondatacleanup')) {
  208. if (cfr('ROOT')) {
  209. $oltData = new OLTAttractor();
  210. $ponDataCleanupResult = $oltData->flushAllCacheData();
  211. log_register('PON DATACACHE FLUSHED `' . $ponDataCleanupResult . '` CONTAINERS');
  212. ubRouting::nav($pon::URL_ME . '&oltstats=true');
  213. }
  214. }
  215. //OLTs polling log render here
  216. if (ubRouting::checkGet('polllogs')) {
  217. show_window(__('OLT polling log'), $pon->renderLogControls());
  218. if (ubRouting::checkGet('zenlog')) {
  219. $ponyZen = new ZenFlow('oltpollzen', $pon->renderPollingLog(), 3000);
  220. show_window(__('Zen') . ' ' . __('Log'), $ponyZen->render());
  221. } else {
  222. show_window(__('Log'), $pon->renderPollingLog());
  223. }
  224. }
  225. //ONU search here
  226. if (ubRouting::checkGet('onusearch')) {
  227. if (ubRouting::checkPost('onusearchquery')) {
  228. show_window('', wf_BackLink($pon::URL_ONULIST));
  229. if (@$altCfg['PON_ONU_SEARCH_ENABLED']) {
  230. show_window(__('Search') . ' ' . __('ONU'), $pon->renderOnuSearchForm());
  231. show_window(__('Search results'), $pon->renderOnuSearchResult());
  232. } else {
  233. show_error(__('Search') . ' ' . __('ONU') . ' ' . __('Disabled'));
  234. }
  235. } else {
  236. show_window('', wf_BackLink($pon::URL_ONULIST));
  237. show_warning(__('Search query') . ' ' . __('is empty'));
  238. }
  239. }
  240. //ONU assigment check
  241. if (ubRouting::get('action') == 'checkONUAssignment' AND ubRouting::checkGet('onumac')) {
  242. $pon->checkONUAssignmentReply();
  243. }
  244. // background ONU creation form callback
  245. if (ubRouting::checkGet(array('renderCreateForm'))) {
  246. if (ubRouting::checkGet('renderDynamically') && wf_getBoolFromVar(ubRouting::get('renderDynamically'), true)) {
  247. $CPECreateForm = $pon->onuRegisterForm(ubRouting::get('oltid'), ubRouting::get('onumac'), ubRouting::get('userLogin'), ubRouting::get('userIP'), wf_getBoolFromVar(ubRouting::get('renderedOutside'), true), wf_getBoolFromVar(ubRouting::get('reloadPageAfterDone'), true), ubRouting::get('ActionCtrlID'), ubRouting::get('ModalWID'));
  248. die(wf_modalAutoForm(__('Register new ONU'), $CPECreateForm, ubRouting::get('ModalWID'), ubRouting::get('ModalWBID'), true));
  249. } else {
  250. die($pon->onuRegisterForm(ubRouting::get('oltid'), ubRouting::get('onumac'), ubRouting::get('userLogin'), ubRouting::get('userIP'), wf_getBoolFromVar(ubRouting::get('renderedOutside'), true), wf_getBoolFromVar(ubRouting::get('reloadPageAfterDone'), true), ubRouting::get('ActionCtrlID'), ubRouting::get('ModalWID')));
  251. }
  252. }
  253. //Unknown ONU batch registration here
  254. if (ubRouting::checkGet('onumassreg')) {
  255. if (cfr('ROOT')) {
  256. if (!ubRouting::checkPost('runmassonureg')) {
  257. //Unknown ONU list and form here
  258. show_window('', wf_BackLink('?module=ponizer&unknownonulist=true'));
  259. show_window(__('Register all unknown ONUs'), $pon->renderBatchOnuRegForm());
  260. show_window(__('Unknown ONU'), $pon->renderBatchOnuRegList());
  261. } else {
  262. //running batch ONU register subroutine
  263. show_window(__('Register all unknown ONUs'), $pon->runBatchOnuRegister());
  264. }
  265. } else {
  266. show_error(__('Access denied'));
  267. }
  268. }
  269. //ONU editing form aka ONU profile here
  270. if (ubRouting::checkGet('editonu')) {
  271. //deleting additional users
  272. if (ubRouting::checkGet(array('deleteextuser'))) {
  273. if (cfr('PONEDIT')) {
  274. $pon->deleteOnuExtUser(ubRouting::get('deleteextuser'));
  275. ubRouting::nav($pon::URL_ONU . ubRouting::get('editonu'));
  276. }
  277. }
  278. //creating new additional user
  279. if (ubRouting::checkPost(array('newpononuextid', 'newpononuextlogin'))) {
  280. if (cfr('PONEDIT')) {
  281. $pon->createOnuExtUser(ubRouting::post('newpononuextid'), ubRouting::post('newpononuextlogin'));
  282. ubRouting::nav($pon::URL_ONU . ubRouting::get('editonu'));
  283. }
  284. }
  285. //show ONU editing interface aka ONU profile
  286. show_window(__('Edit'), $pon->onuEditForm(ubRouting::get('editonu')));
  287. show_window(__('ONU FDB'), $pon->renderOltFdbList(ubRouting::get('editonu')));
  288. $pon->loadonuSignalHistory(ubRouting::get('editonu'), true);
  289. }
  290. //Rendering all OLTs ONUs list and main module controls
  291. if (ubRouting::checkGet('onulist')) {
  292. show_window(__('ONU directory'), $pon->controls());
  293. //rendering available ONU list
  294. $pon->renderOnuList();
  295. zb_BillingStats(true);
  296. }
  297. //no extra routes or extra post data received
  298. if (sizeof(ubRouting::rawGet()) == 1 AND sizeof(ubRouting::rawPost()) == 1) {
  299. show_error(__('Strange exception'));
  300. show_window('', wf_img('skins/ponywrong.png'));
  301. }
  302. } else {
  303. show_error(__('You cant control this module'));
  304. }
  305. } else {
  306. show_error(__('This module disabled'));
  307. }