What are some potential security risks of using PHP to reboot a server?

One potential security risk of using PHP to reboot a server is the possibility of unauthorized users gaining access to the script and being able to reboot the server without proper authorization. To mitigate this risk, it is important to implement proper authentication and authorization checks within the PHP script before allowing the server reboot command to be executed.

<?php
// Check if the user is authenticated and authorized to reboot the server
if($authenticated && $authorized) {
  // Reboot the server
  shell_exec('sudo reboot');
  echo 'Server rebooted successfully';
} else {
  echo 'Unauthorized access';
}
?>