在项目列表中删除php中的文件

I have a php script to display if a list of computers are active or not. Every minute or so it sends a packet to my server and it updates a file.

The php script I made checks if the file has been updated within the last 90 seconds. If it has, it will display it as active, else it will be displayed as inactive.

$thelist = "";
if ($handle = opendir('ips/')) {
    while (false !== ($file = readdir($handle))) {
        if (($file != ".") && ($file != "..") && (substr($file, - 4) == ".ips")) {
            $active = true;
            $activetext = "<a class=activeGreen>● Active</a> ";
            if(humanTiming(filemtime("ips/".$file)) > 90) {
                $activetext = "<a class=inactiveRed>● Inactive</a> ";
                $active = false;
            }
            if ($active == true) {
                $thelist = $activetext.'<a>'.basename($file, ".ips")."</a> <a>[Delete]</a><br>".$thelist;
            } else {
                $thelist .= $activetext.'<a>'.basename($file, ".ips")."</a> <a>[Delete]</a><br>";
            }
        }
    }
    closedir($handle);

    echo "<ul><p>$thelist</p></ul>";
}

function humanTiming($time) {
    $time = time() - $time; // to get the time since that moment
    $time = $time < 1 ? 1 : $time;
    $tokens = [1 => 'second'];

    foreach ($tokens as $unit => $text) {
        if ($time < $unit) continue;
        $numberOfUnits = floor($time / $unit);
        return $numberOfUnits;
    }
}

This all works, but how would I be able to make the delete button next to them delete that specific file when it's clicked?

What I ended up doing was to create a second php file, accepting url get arguments.

<?php
    if(!empty($_GET["fname"])) {
        if(file_exists($_GET["fname"])) {
            echo 'Deleting ' . htmlspecialchars($_GET["fname"]) . '!';
            unlink($_GET["fname"]);
        } else {
            echo 'Error: ' . htmlspecialchars($_GET["fname"]) . ' does not exist';
        }
    } else {
        echo 'Direct access not allowed';
    }
?>

PHP Url Arguments

PHP Delete File