index.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <?php
  2. if (cfr('ANNIHILATION')) {
  3. /**
  4. * Totally deletes existing user with all his data
  5. *
  6. * @global object $billing
  7. * @param string $login
  8. *
  9. * @return void
  10. */
  11. function zb_AnnihilateUser($login) {
  12. global $billing;
  13. global $ubillingConfig;
  14. $altCfg = $ubillingConfig->getAlter();
  15. $user_ip = zb_UserGetIP($login);
  16. $user_aptdata = zb_AddressGetAptData($login);
  17. @$user_aptid = $user_aptdata['aptid'];
  18. //disable user before deletion - for proper OnDisconnect
  19. $billing->setdown($login, 1);
  20. $billing->setao($login, 0);
  21. //Multigen workaround. Must be performed before real user deletion, and after its disconnected.
  22. if ($altCfg['MULTIGEN_ENABLED']) {
  23. $multigen = new MultiGen();
  24. $multigen->generateNasAttributes();
  25. }
  26. //cleaning basic user data
  27. zb_AddressDeleteApartment($user_aptid);
  28. zb_AddressOrphanUser($login);
  29. if ($ubillingConfig->getAlterParam('ADDRESS_EXTENDED_ENABLED')) {
  30. zb_AddAddressExtenDelete($login);
  31. }
  32. zb_UserDeleteEmail($login);
  33. zb_UserDeleteNotes($login);
  34. zb_UserDeletePhone($login);
  35. zb_UserDeleteRealName($login);
  36. zb_UserDeleteSpeedOverride($login);
  37. //optional contract deletion
  38. if (!$altCfg['STRICT_CONTRACTS_PROTECT']) {
  39. zb_UserDeleteContract($login);
  40. }
  41. //flushing vcash
  42. zb_VserviceCashClear($login);
  43. log_register('DELETE VCASH (' . $login . ')');
  44. //custom fields and tags
  45. $cf = new CustomFields($login);
  46. $cf->flushAllUserFieldsData();
  47. zb_FlushAllUserTags($login);
  48. if (@$altCfg['VLANGEN_SUPPORT']) {
  49. vlan_delete_host($login);
  50. }
  51. //delete user from branch
  52. if (@$altCfg['BRANCHES_ENABLED']) {
  53. $branchObj = new UbillingBranches();
  54. $userBranch = $branchObj->userGetBranch($login);
  55. if (!empty($userBranch)) {
  56. $branchObj->userDeleteBranch($login);
  57. }
  58. }
  59. //openpayz static payment ID deletion
  60. if ($altCfg['OPENPAYZ_SUPPORT']) {
  61. if ($altCfg['OPENPAYZ_STATIC_ID']) {
  62. $openPayz = new OpenPayz(false, true);
  63. $openPayz->degisterStaticPaymentId($login);
  64. }
  65. }
  66. //delete user connection details
  67. if ($altCfg['CONDET_ENABLED']) {
  68. $condet = new ConnectionDetails();
  69. $condet->delete($login);
  70. log_register('CONDET FLUSH (' . $login . ')');
  71. }
  72. //switch port bindings deletion
  73. if ($altCfg['SWITCHPORT_IN_PROFILE']) {
  74. $switchPortAssigns = new SwitchPortAssign();
  75. $switchPortAssigns->delete($login);
  76. }
  77. //flushing some QinQ bindings
  78. $qinqBindingsDb = new NyanORM('qinq_bindings');
  79. $qinqBindingsDb->where('login', '=', $login);
  80. $qinqBindingsDb->delete();
  81. //cleaning multinet data
  82. multinet_delete_host($user_ip);
  83. multinet_rebuild_all_handlers();
  84. //destroing stargazer user
  85. $billing->deleteuser($login);
  86. log_register('StgUser DELETE (' . $login . ')');
  87. }
  88. /**
  89. * Renders user deletion form
  90. *
  91. * @param string $login
  92. *
  93. * @return void
  94. */
  95. function web_AnnihilateFormShow($login) {
  96. $alladdress = zb_AddressGetFulladdresslist();
  97. $inputs = __('Be careful, this module permanently deletes user and all data associated with it. Opportunities to raise from the dead no longer.');
  98. $inputs .= wf_tag('br');
  99. $inputs .= __('To ensure that we have seen the seriousness of your intentions to enter the word сonfirm the field below.');
  100. $inputs .= wf_delimiter();
  101. $inputs .= wf_tag('input', false, '', 'type="text" name="confirmation" autocomplete="off"');
  102. $inputs .= wf_HiddenInput('anihilation', 'true');
  103. $inputs .= wf_delimiter();
  104. $inputs .= wf_Submit(__('I really want to stop suffering User'));
  105. $form = wf_Form('', 'POST', $inputs, 'glamour');
  106. show_window(__('Deleting user') . ' ' . @$alladdress[$login] . ' (' . $login . ')', $form);
  107. }
  108. if (ubRouting::checkGet('username')) {
  109. $login = ubRouting::get('username');
  110. web_AnnihilateFormShow($login);
  111. //check for delete confirmation
  112. if (ubRouting::checkPost('anihilation')) {
  113. if (ubRouting::checkPost('confirmation')) {
  114. if (ubRouting::post('confirmation') == 'confirm') {
  115. zb_AnnihilateUser($login);
  116. ubRouting::nav('?module=index');
  117. } else {
  118. show_error(__('You are not mentally prepared for this') . '. ' . __('Confirmation') . ' ' . __('Failed') . '.');
  119. }
  120. } else {
  121. show_error(__('You are not mentally prepared for this'));
  122. }
  123. }
  124. show_window('', web_UserControls($login));
  125. } else {
  126. show_error(__('Strange exception') . ': GET_NO_USERNAME');
  127. show_window('', wf_tag('center') . wf_img('skins/unicornchainsawwrong.png') . wf_tag('center', true));
  128. }
  129. } else {
  130. show_error(__('You cant control this module'));
  131. }