What are the potential security risks of running a PHP script to shut down a computer over a network?

Running a PHP script to shut down a computer over a network can pose a significant security risk, as it can potentially be exploited by malicious actors to remotely shut down systems without authorization. To mitigate this risk, it is important to implement proper authentication and authorization mechanisms in the PHP script to ensure that only authorized users can trigger the shutdown command.

<?php

// Check if the request is coming from an authorized user
$authorized_users = ['user1', 'user2', 'user3'];
if (!in_array($_SERVER['REMOTE_ADDR'], $authorized_users)) {
    die('Unauthorized access');
}

// Shutdown the computer
exec('shutdown -s -t 0');

echo 'Computer shutdown command sent successfully';
?>