index.php 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <?php
  2. if (cfr('VISOR')) {
  3. $altCfg = $ubillingConfig->getAlter();
  4. if ($altCfg['VISOR_ENABLED']) {
  5. $visor = new UbillingVisor();
  6. //basic controls
  7. show_window('', $visor->panel());
  8. //users listing
  9. if (ubRouting::get('ajaxusers')) {
  10. $visor->ajaxUsersList();
  11. }
  12. //user cameras listing
  13. if (ubRouting::checkGet(array('ajaxusercams'))) {
  14. $visor->ajaxUserCams(ubRouting::get('ajaxusercams', 'int'));
  15. }
  16. //all available cameras listing
  17. if (ubRouting::get('ajaxallcams')) {
  18. $visor->ajaxAllCams();
  19. }
  20. //new user creation
  21. if (ubRouting::checkPost(array('newusercreate', 'newusername'))) {
  22. $userRegistrationResult = $visor->createUser();
  23. ubRouting::nav($visor::URL_ME . $visor::URL_USERVIEW . $userRegistrationResult);
  24. }
  25. //all cameras listing
  26. if (ubRouting::get('cams')) {
  27. show_window(__('Cams'), $visor->renderCamerasContainer($visor::URL_ME . $visor::URL_ALLCAMS));
  28. }
  29. //users deletion
  30. if (ubRouting::checkPost(array('userdeleteprocessing', 'deleteconfirmation'))) {
  31. if (ubRouting::post('deleteconfirmation') == 'confirm') {
  32. $deletionResult = $visor->deleteUser(ubRouting::post('userdeleteprocessing', 'int'));
  33. if (empty($deletionResult)) {
  34. ubRouting::nav($visor::URL_ME . $visor::URL_USERS);
  35. } else {
  36. show_error($deletionResult);
  37. show_window('', wf_BackLink($visor::URL_ME . $visor::URL_USERS));
  38. }
  39. } else {
  40. log_register('VISOR USER DELETE TRY [' . ubRouting::post('userdeleteprocessing') . ']');
  41. }
  42. }
  43. //camera creation
  44. if (ubRouting::checkPost(array('newcameravisorid', 'newcameralogin'))) {
  45. $visor->createCamera();
  46. ubRouting::nav($visor::URL_ME . $visor::URL_USERVIEW . ubRouting::post('newcameravisorid', 'int'));
  47. }
  48. //user editing
  49. if (ubRouting::checkPost(array('edituserid', 'editusername'))) {
  50. $visor->saveUser();
  51. ubRouting::nav($visor::URL_ME . $visor::URL_USERVIEW . ubRouting::post('edituserid'));
  52. }
  53. //primary camera editing
  54. if (ubRouting::checkPost(array('editprimarycamerauserid'))) {
  55. $visor->savePrimary();
  56. ubRouting::nav($visor::URL_ME . $visor::URL_USERVIEW . ubRouting::post('editprimarycamerauserid'));
  57. }
  58. //users list rendering
  59. if (ubRouting::checkGet(array('users'))) {
  60. show_window(__('Users'), $visor->renderUsers());
  61. zb_BillingStats(true);
  62. }
  63. //camera options editing
  64. if (ubRouting::checkPost(array('editcameraid'))) {
  65. $visor->saveCamera();
  66. ubRouting::nav($visor::URL_ME . $visor::URL_CAMVIEW . ubRouting::post('editcameraid'));
  67. }
  68. //camera user detection on black magic action
  69. if (ubRouting::checkGet(array('username'))) {
  70. $userLogin = ubRouting::get('username');
  71. $userIdDetected = $visor->getCameraUser($userLogin);
  72. if (!empty($userIdDetected)) {
  73. ubRouting::nav($visor::URL_ME . $visor::URL_USERVIEW . $userIdDetected);
  74. } else {
  75. $primaryVisorId = $visor->getPrimaryAccountUserId($userLogin);
  76. if ($primaryVisorId) {
  77. ubRouting::nav($visor::URL_ME . $visor::URL_USERVIEW . $primaryVisorId);
  78. } else {
  79. //new camera creation interface
  80. show_window(__('Create camera'), $visor->renderCameraCreateInterface($userLogin));
  81. show_window('', web_UserControls($userLogin));
  82. }
  83. }
  84. }
  85. //user profile rendering
  86. if (ubRouting::checkGet(array('showuser'))) {
  87. show_window(__('Video surveillance user profile'), $visor->renderUserProfile(ubRouting::get('showuser')));
  88. }
  89. //camera profile/editing interface
  90. if (ubRouting::checkGet(array('showcamera'))) {
  91. show_window(__('Camera'), $visor->renderCameraForm(ubRouting::get('showcamera')));
  92. }
  93. //new DVR creation
  94. if (ubRouting::checkPost(array('newdvr'))) {
  95. $visor->createDVR();
  96. ubRouting::nav($visor::URL_ME . $visor::URL_DVRS);
  97. }
  98. //deleting existing DVR
  99. if (ubRouting::checkGet(array('deletedvrid'))) {
  100. $dvrDeletionResult = $visor->deleteDVR(ubRouting::get('deletedvrid'));
  101. if (empty($dvrDeletionResult)) {
  102. ubRouting::nav($visor::URL_ME . $visor::URL_DVRS);
  103. } else {
  104. show_error($dvrDeletionResult);
  105. show_window('', wf_BackLink($visor::URL_ME . $visor::URL_DVRS));
  106. }
  107. }
  108. //deleting existing camera
  109. if (ubRouting::checkPost(array('cameradeleteprocessing', 'deleteconfirmation'))) {
  110. if (ubRouting::post('deleteconfirmation') == 'confirm') {
  111. $camDeletionResult = $visor->deleteCamera(ubRouting::post('cameradeleteprocessing', 'int'));
  112. if (empty($camDeletionResult)) {
  113. ubRouting::nav($visor::URL_ME . $visor::URL_CAMS);
  114. } else {
  115. show_error($camDeletionResult);
  116. }
  117. }
  118. }
  119. //channel user assign/delete assign
  120. if (ubRouting::checkPost(array('editchannelguid', 'editchanneldvrid'))) {
  121. $visor->saveChannelAssign();
  122. ubRouting::nav($visor::URL_ME . $visor::URL_CHANEDIT . ubRouting::post('editchannelguid') . '&dvrid=' . ubRouting::post('editchanneldvrid'));
  123. }
  124. //channel record mode editing
  125. if (ubRouting::checkPost(array('recordchannelguid', 'recordchanneldvrid', 'recordchannelmode'))) {
  126. $visor->saveChannelRecordMode();
  127. ubRouting::nav($visor::URL_ME . $visor::URL_CHANEDIT . ubRouting::post('recordchannelguid') . '&dvrid=' . ubRouting::post('recordchanneldvrid'));
  128. }
  129. //DVR editing
  130. if (ubRouting::checkPost(array('editdvrid', 'editdvrip'))) {
  131. $visor->saveDVR();
  132. ubRouting::nav($visor::URL_ME . $visor::URL_DVRS);
  133. }
  134. //existing DVR listing
  135. if (ubRouting::checkGet('dvrs')) {
  136. show_window(__('DVRs'), $visor->renderDVRsList());
  137. }
  138. //existing DVR channels preview & management
  139. if (ubRouting::checkGet('channels')) {
  140. show_window(__('Channels'), $visor->renderChannelsPreview());
  141. }
  142. //channel editing form
  143. if (ubRouting::checkGet(array('editchannel', 'dvrid'))) {
  144. $channelId = ubRouting::get('editchannel');
  145. $dvrId = ubRouting::get('dvrid');
  146. $dvrName = $visor->getDvrName($dvrId);
  147. show_window(__('Edit') . ' ' . __('channel') . ' ' . $channelId . ' @ ' . $dvrName, $visor->renderChannelEditForm($channelId, $dvrId));
  148. }
  149. //DVRs health
  150. if (ubRouting::checkGet('health')) {
  151. show_window(__('DVR health'), $visor->renderDVRsHealth());
  152. }
  153. //Tariff changes detection
  154. if (ubRouting::checkGet('tariffchanges')) {
  155. show_window(__('Tariff will change'), $visor->renderTariffChangesReport());
  156. }
  157. } else {
  158. show_error(__('This module is disabled'));
  159. }
  160. } else {
  161. show_error(__('Access denied'));
  162. }