File tree Expand file tree Collapse file tree 2 files changed +22
-7
lines changed
Expand file tree Collapse file tree 2 files changed +22
-7
lines changed Original file line number Diff line number Diff line change 1111 exit ();
1212}
1313
14- if ($ _SESSION ['user ' ] == 'admin ' ) {
15- if (!empty ($ _GET ['hostname ' ])) {
16- exec (HESTIA_CMD ."v-restart-system yes " , $ output , $ return_var );
17- $ _SESSION ['error_msg ' ] = 'The system is going down for reboot NOW! ' ;
14+ // If the stored reset token matches the current request one it means that we need
15+ // to prevent the action because the browser automatically reloaded the page when
16+ // the server turned on. This will prevent duplicate restarts.
17+ $ reset_token_dir = '/var/tmp/ ' ;
18+ if (isset ($ _GET ['system_reset_token ' ]) && is_numeric ($ _GET ['system_reset_token ' ])) {
19+ clearstatcache ();
20+ $ reset_token_file = $ reset_token_dir . 'hst_reset_ ' . $ _GET ['system_reset_token ' ];
21+ if (file_exists ($ reset_token_file )) {
22+ unlink ($ reset_token_file );
23+ sleep (5 );
24+ header ('location: /list/server/ ' );
25+ exit ();
26+ }
27+ if ($ _SESSION ['user ' ] == 'admin ' ) {
28+ if (!empty ($ _GET ['hostname ' ])) {
29+ touch ($ reset_token_file );
30+ $ _SESSION ['error_msg ' ] = 'The system is going down for reboot NOW! ' ;
31+ exec (HESTIA_CMD . "v-restart-system yes " , $ output , $ return_var );
32+ }
33+ unset($ output );
1834 }
19- unset($ output );
2035}
2136
2237header ("Location: /list/server/ " );
23- exit ;
38+ exit () ;
Original file line number Diff line number Diff line change 1010 < a class ="data-controls do_servicerestart ui-button danger cancel " title ="<?=__('Restart')?> ">
1111 < i class ="do_servicerestart fas fa-undo status-icon red "> </ i >
1212 < ?=__('Restart')?>
13- < input type ="hidden " name ="servicerestart_url " value ="/restart/system/?hostname=<?php echo $sys['sysinfo']['HOSTNAME'] ?>&token=<?=$_SESSION['token']?> " />
13+ < input type ="hidden " name ="servicerestart_url " value ="/restart/system/?hostname=<?php echo $sys['sysinfo']['HOSTNAME'] ?>&token=<?=$_SESSION['token']?>&system_reset_token=<?php echo time(); ?> " />
1414 < div class ="confirmation-text-servicerestart hidden " title ="<?=__('Confirmation')?> ">
1515 < p class ="confirmation "> < ?=__('RESTART_CONFIRMATION', 'Server')?> </ p >
1616 </ div >
You can’t perform that action at this time.
0 commit comments