index.php 4.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. if (cfr('MAC')) {
  3. $altCfg = $ubillingConfig->getAlter();
  4. $newMacReportFlag = $altCfg['NMREP_INMACCHG'];
  5. $simpleSelectorFlag = $altCfg['SIMPLENEWMACSELECTOR'];
  6. if (ubRouting::checkGet('username')) {
  7. $login = ubRouting::get('username', 'callback', 'vf');
  8. // change mac if form data captured
  9. if (ubRouting::checkPost('newmac')) {
  10. $mac = trim(ubRouting::post('newmac'));
  11. $allUsedMacs = zb_getAllUsedMac();
  12. //check mac for free
  13. if (zb_checkMacFree($mac, $allUsedMacs)) {
  14. //validate mac format
  15. if (check_mac_format($mac)) {
  16. $ip = zb_UserGetIP($login);
  17. $old_mac = zb_MultinetGetMAC($ip);
  18. $userData = zb_UserGetAllData($login);
  19. $userData = $userData[$login];
  20. multinet_change_mac($ip, $mac);
  21. if ($altCfg['MULTIGEN_ENABLED']) {
  22. $newUserData = $userData;
  23. $newUserData['mac'] = strtolower($mac);
  24. $mlg = new MultiGen();
  25. if ($altCfg['MULTIGEN_POD_ON_MAC_CHANGE'] == 2) {
  26. $mlg->podOnExternalEvent($login, $userData, $newUserData);
  27. $mlg->podOnExternalEvent($login, $newUserData);
  28. }
  29. if ($altCfg['MULTIGEN_POD_ON_MAC_CHANGE'] == 1) {
  30. $mlg->podOnExternalEvent($login, $newUserData);
  31. }
  32. }
  33. log_register("MAC CHANGE (" . $login . ") " . $ip . " FROM " . $old_mac . " ON " . $mac);
  34. multinet_rebuild_all_handlers();
  35. // need reset after mac change
  36. $billing->resetuser($login);
  37. log_register("RESET User (" . $login . ")");
  38. //ressurect user if required
  39. if (@$altCfg['RESETHARD']) {
  40. zb_UserResurrect($login);
  41. }
  42. if (isset($altCfg['MACCHGDOUBLEKILL'])) {
  43. if ($altCfg['MACCHGDOUBLEKILL']) {
  44. $billing->resetuser($login);
  45. log_register("RESET User (" . $login . ") DOUBLEKILL");
  46. }
  47. }
  48. } else {
  49. //show error when MAC haz wrong format
  50. show_error(__('This MAC have wrong format'));
  51. //debuglog
  52. log_register("MACINVALID TRY (" . $login . ")");
  53. }
  54. } else {
  55. //show error when MAC is in usage
  56. show_error(__('This MAC is currently used'));
  57. //debuglog
  58. log_register('MACDUPLICATE TRY (' . $login . ') `' . $mac . '`');
  59. }
  60. }
  61. $userIp = zb_UserGetIP($login);
  62. if (!empty($userIp)) {
  63. $current_mac = zb_MultinetGetMAC($userIp);
  64. $useraddress = zb_UserGetFullAddress($login) . ' (' . $login . ')';
  65. $useSelectorInput = (($simpleSelectorFlag) AND ( !ubRouting::checkGet('oldform'))) ? false : true;
  66. $form = web_MacEditForm($useraddress, $useSelectorInput, $current_mac);
  67. if ($simpleSelectorFlag) {
  68. $form .= wf_Link('?module=macedit&username=' . $login, wf_img('skins/done_icon.png') . ' ' . __('Simple MAC selector'), false, 'ubButton');
  69. $form .= wf_Link('?module=macedit&username=' . $login . '&oldform=true', wf_img('skins/categories_icon.png') . ' ' . __('Manual MAC input'), false, 'ubButton');
  70. }
  71. $form .= wf_delimiter();
  72. if ($newMacReportFlag) {
  73. $form .= wf_tag('h2') . __('Unknown MAC address') . wf_tag('h2', true) . zb_NewMacShow();
  74. }
  75. $form .= web_UserControls($login);
  76. show_window(__('Edit MAC'), $form);
  77. } else {
  78. show_error(__('Something went wrong') . ': ' . __('User not exists'));
  79. }
  80. } else {
  81. show_error(__('Something went wrong') . ': ' . __('Empty login'));
  82. }
  83. } else {
  84. show_error(__('You cant control this module'));
  85. }