index.php 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <?php
  2. if (cfr('ZBSMAN')) {
  3. /**
  4. * Returns array of users which denied from userstats usage
  5. *
  6. * @return array
  7. */
  8. function zb_GetUserStatsDeniedAll() {
  9. $access_raw = zb_StorageGet('ZBS_DENIED');
  10. $result = array();
  11. if (!empty($access_raw)) {
  12. $access_raw = base64_decode($access_raw);
  13. $access_raw = unserialize($access_raw);
  14. $result = $access_raw;
  15. } else {
  16. //first access
  17. $newarray = serialize($result);
  18. $newarray = base64_encode($newarray);
  19. zb_StorageSet('ZBS_DENIED', $newarray);
  20. }
  21. return ($result);
  22. }
  23. /**
  24. * Sets user as denied for using userstats
  25. *
  26. * @param string $login
  27. *
  28. * @return void
  29. */
  30. function zb_SetUserStatsDenied($login) {
  31. $access = zb_GetUserStatsDeniedAll();
  32. if (!empty($login)) {
  33. $access[$login] = 'NOP';
  34. $newarray = serialize($access);
  35. $newarray = base64_encode($newarray);
  36. zb_StorageSet('ZBS_DENIED', $newarray);
  37. log_register("ZBSMAN SET DENIED (" . $login . ")");
  38. }
  39. }
  40. /**
  41. * Sets user as allowed for usage of userstats
  42. *
  43. * @param string $login
  44. *
  45. * @return void
  46. */
  47. function zb_SetUserStatsUnDenied($login) {
  48. $access = zb_GetUserStatsDeniedAll();
  49. if (!empty($login)) {
  50. if (isset($access[$login])) {
  51. unset($access[$login]);
  52. $newarray = serialize($access);
  53. $newarray = base64_encode($newarray);
  54. zb_StorageSet('ZBS_DENIED', $newarray);
  55. log_register("ZBSMAN SET ALLOWED (" . $login . ")");
  56. }
  57. }
  58. }
  59. /**
  60. * Returns array of users which is denied from usage of helpdesk
  61. *
  62. * @return array
  63. */
  64. function zb_GetHelpdeskDeniedAll() {
  65. $access_raw = zb_StorageGet('ZBS_HELP_DENIED');
  66. $result = array();
  67. if (!empty($access_raw)) {
  68. $access_raw = base64_decode($access_raw);
  69. $access_raw = unserialize($access_raw);
  70. $result = $access_raw;
  71. } else {
  72. //first access
  73. $newarray = serialize($result);
  74. $newarray = base64_encode($newarray);
  75. zb_StorageSet('ZBS_HELP_DENIED', $newarray);
  76. }
  77. return ($result);
  78. }
  79. /**
  80. * Sets user as denied for helpdesk usage
  81. *
  82. * @param string $login
  83. *
  84. * @return void
  85. */
  86. function zb_SetHelpdeskDenied($login) {
  87. $access = zb_GetHelpdeskDeniedAll();
  88. if (!empty($login)) {
  89. $access[$login] = 'NOP';
  90. $newarray = serialize($access);
  91. $newarray = base64_encode($newarray);
  92. zb_StorageSet('ZBS_HELP_DENIED', $newarray);
  93. log_register("ZBSMAN SET HELPDESKDENIED (" . $login . ")");
  94. }
  95. }
  96. /**
  97. * Sets user as allowed for helpdesk usage
  98. *
  99. * @param string $login
  100. *
  101. * @return void
  102. */
  103. function zb_SetHelpdeskUnDenied($login) {
  104. $access = zb_GetHelpdeskDeniedAll();
  105. if (!empty($login)) {
  106. if (isset($access[$login])) {
  107. unset($access[$login]);
  108. $newarray = serialize($access);
  109. $newarray = base64_encode($newarray);
  110. zb_StorageSet('ZBS_HELP_DENIED', $newarray);
  111. log_register("ZBSMAN SET ALLOWED (" . $login . ")");
  112. }
  113. }
  114. }
  115. /**
  116. * Renders userstats/helpdesk access modification form
  117. *
  118. * @param string $login
  119. *
  120. * @return string
  121. */
  122. function web_ZbsManEditForm($login) {
  123. $access = zb_GetUserStatsDeniedAll();
  124. $helpdesk = zb_GetHelpdeskDeniedAll();
  125. if (isset($access[$login])) {
  126. $checked_us = true;
  127. } else {
  128. $checked_us = false;
  129. }
  130. if (isset($helpdesk[$login])) {
  131. $checked_hd = true;
  132. } else {
  133. $checked_hd = false;
  134. }
  135. $inputs = wf_CheckInput('access_denied', __('Userstats access denied for this user'), true, $checked_us);
  136. $inputs .= wf_CheckInput('helpdesk_denied', __('Helpdesk access denied for this user'), true, $checked_hd);
  137. $inputs .= wf_HiddenInput('zbsman_change', 'true');
  138. $inputs .= wf_Submit(__('Save'));
  139. $result = wf_Form('', 'POST', $inputs, 'glamour');
  140. return ($result);
  141. }
  142. /**
  143. * Renders lists of users denied to use of userstats/helpdesk
  144. *
  145. * @return void
  146. */
  147. function web_ZbsManUserLists() {
  148. $access = zb_GetUserStatsDeniedAll();
  149. $access = array_keys($access);
  150. $helpdesk = zb_GetHelpdeskDeniedAll();
  151. $helpdesk = array_keys($helpdesk);
  152. show_window(__('Users that cant access Userstats'), web_UserArrayShower($access));
  153. show_window(__('Users that cant access ticketing service'), web_UserArrayShower($helpdesk));
  154. }
  155. /**
  156. * Controller part
  157. */
  158. if (ubRouting::checkGet('username')) {
  159. $altCfg = $ubillingConfig->getAlter();
  160. $login = ubRouting::get('username', 'mres');
  161. if (ubRouting::checkPost('zbsman_change')) {
  162. //set user denied
  163. if (ubRouting::checkPost('access_denied')) {
  164. zb_SetUserStatsDenied($login);
  165. ubRouting::nav("?module=pl_zbsman&username=" . $login);
  166. } else {
  167. zb_SetUserStatsUnDenied($login);
  168. ubRouting::nav("?module=pl_zbsman&username=" . $login);
  169. }
  170. //set user helpdesk denied
  171. if (ubRouting::checkPost('helpdesk_denied')) {
  172. zb_SetHelpdeskDenied($login);
  173. ubRouting::nav("?module=pl_zbsman&username=" . $login);
  174. } else {
  175. zb_SetHelpdeskUnDenied($login);
  176. ubRouting::nav("?module=pl_zbsman&username=" . $login);
  177. }
  178. }
  179. //userstats permissions
  180. if (!ubRouting::checkGet('showzbsdenied') AND ! ubRouting::checkGet('showopdenied') AND ! ubRouting::checkGet('showipauthdenied')) {
  181. $zbsDeniedControls = wf_Link('?module=pl_zbsman&username=' . $login . '&showzbsdenied=true', web_icon_charts('Who?'));
  182. show_window(__('Userstats access controls') . ' ' . $zbsDeniedControls, web_ZbsManEditForm($login));
  183. } else {
  184. if (ubRouting::checkGet('showzbsdenied')) {
  185. show_window('', wf_BackLink('?module=pl_zbsman&username=' . $login));
  186. web_ZbsManUserLists();
  187. }
  188. }
  189. //IP auth management
  190. $ipAuthDenied = new IpAuthDenied();
  191. //changing state if required
  192. if (ubRouting::checkPost($ipAuthDenied::PROUTE_DENY_LOGIN)) {
  193. $ipAuthDenied->setUserDenyState(ubRouting::post($ipAuthDenied::PROUTE_DENY_LOGIN), ubRouting::checkPost($ipAuthDenied::PROUTE_DENY_FLAG));
  194. ubRouting::nav("?module=pl_zbsman&username=" . $login);
  195. }
  196. //render form
  197. if (!ubRouting::checkGet('showzbsdenied') AND ! ubRouting::checkGet('showopdenied') AND ! ubRouting::checkGet('showipauthdenied')) {
  198. $ipAuthDeniedControls = wf_Link('?module=pl_zbsman&username=' . $login . '&showipauthdenied=true', web_icon_charts('Who?'));
  199. show_window(__('IP authorization') . ' ' . $ipAuthDeniedControls, $ipAuthDenied->renderModifyForm($login));
  200. } else {
  201. //render denied list
  202. if (ubRouting::checkGet('showipauthdenied')) {
  203. $allIpAuthDenied = $ipAuthDenied->getAllDenied();
  204. show_window('', wf_BackLink('?module=pl_zbsman&username=' . $login));
  205. show_window(__('Users with IP authorization denied'), web_UserArrayShower($allIpAuthDenied));
  206. }
  207. }
  208. //openpayz access management
  209. if (@$altCfg['OPENPAYZ_SUPPORT']) {
  210. $opDenied = new OpDenied();
  211. //changing state if required
  212. if (ubRouting::checkPost($opDenied::PROUTE_DENY_LOGIN)) {
  213. $opDenied->setUserDenyState(ubRouting::post($opDenied::PROUTE_DENY_LOGIN), ubRouting::checkPost($opDenied::PROUTE_DENY_FLAG));
  214. ubRouting::nav("?module=pl_zbsman&username=" . $login);
  215. }
  216. //render form
  217. if (!ubRouting::checkGet('showzbsdenied') AND ! ubRouting::checkGet('showopdenied') AND ! ubRouting::checkGet('showipauthdenied')) {
  218. $opDeniedControls = wf_Link('?module=pl_zbsman&username=' . $login . '&showopdenied=true', web_icon_charts('Who?'));
  219. show_window(__('OpenPayz access') . ' ' . $opDeniedControls, $opDenied->renderModifyForm($login));
  220. } else {
  221. //render denied list
  222. if (ubRouting::checkGet('showopdenied')) {
  223. $allOpDenied = $opDenied->getAllDenied();
  224. show_window('', wf_BackLink('?module=pl_zbsman&username=' . $login));
  225. show_window(__('Users which denied from OpenPayz usage'), web_UserArrayShower($allOpDenied));
  226. }
  227. }
  228. }
  229. //backlinks
  230. show_window('', web_UserControls($login));
  231. } else {
  232. show_error(__('Strange exeption'));
  233. }
  234. } else {
  235. show_error(__('You cant control this module'));
  236. }
  237. ?>