File tree Expand file tree Collapse file tree 2 files changed +23
-7
lines changed
Expand file tree Collapse file tree 2 files changed +23
-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 session has the same reset token as the current request prevent restarting again.
15+ // This happens when the server is restarted, the admin panel goes down and the browser reloads
16+ // the /restart/index.php page once the server goes online causing restart loop.
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+ touch ($ reset_token_file . '_persistent ' );
32+ exec (HESTIA_CMD . "v-restart-system yes " , $ output , $ return_var );
33+ }
34+ unset($ output );
1835 }
19- unset($ output );
2036}
2137
2238header ("Location: /list/server/ " );
23- exit ;
39+ 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