index.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. set_time_limit(0);
  3. if(cfr('MASSRESET')) {
  4. $altcfg= rcms_parse_ini_file(CONFIG_PATH."alter.ini");
  5. if ($altcfg['MASSRESET_ENABLED']) {
  6. //form with optional confirmation
  7. function mrst_FormShow() {
  8. global $altcfg;
  9. $inputs=__('After clicking the button below for all users will perform the standard procedure reset. By default, this will reinitialize shapers and MAC bindings.');
  10. if (!isset($altcfg['MASSRESET_NOCONFIRM'])) {
  11. $confirmKey=rand(1111,9999);
  12. $inputs.=' '.__('If you are completely sure of what you wish, enter the following numbers into the next field.').'<br>';
  13. $inputs.=wf_HiddenInput('confirmkey', $confirmKey);
  14. $inputs.=$confirmKey.' ⇨ '.wf_TextInput('confirmcheck','', '', true, 5);
  15. }
  16. $inputs.=wf_HiddenInput('runmassreset', 'true').'<br>';
  17. $inputs.=wf_Submit(__('I`m ready'));
  18. $form= wf_Form("", 'POST', $inputs, 'glamour');
  19. show_window(__('Mass user reset'),$form);
  20. }
  21. //resetting all users
  22. function mrst_MassReset() {
  23. global $altcfg,$billing;
  24. $query="SELECT `login` from `users`";
  25. $allusers= zb_UserGetAllStargazerData();
  26. if (!empty($allusers)) {
  27. foreach ($allusers as $io=>$eachuser) {
  28. //very shitty hack
  29. sleep(2);
  30. $billing->resetuser($eachuser['login']);
  31. if (!isset($altcfg['MASSRESET_NOLOG'])) {
  32. log_register("MASSRESET User (".$eachuser['login'].")");
  33. }
  34. }
  35. //preventing F5
  36. rcms_redirect("?module=massreset");
  37. } else {
  38. show_error(__('Any users found'));
  39. }
  40. }
  41. /*
  42. * Main codepart
  43. */
  44. mrst_FormShow();
  45. //mass resetting sub
  46. if (wf_CheckPost(array('runmassreset'))) {
  47. if (!isset($altcfg['MASSRESET_NOCONFIRM'])) {
  48. if (wf_CheckPost(array('confirmcheck','confirmkey'))) {
  49. if ($_POST['confirmcheck']==$_POST['confirmkey']) {
  50. //if confirmation received
  51. mrst_MassReset();
  52. } else {
  53. show_error(__('You are not mentally prepared for this'));
  54. }
  55. } else {
  56. show_error(__('You are not mentally prepared for this'));
  57. }
  58. } else {
  59. //just reset all
  60. mrst_MassReset();
  61. }
  62. }
  63. } else {
  64. show_error(__('This module is disabled'));
  65. }
  66. } else {
  67. show_error(__('Access denied'));
  68. }
  69. ?>