$i++; $currentClients = intval(trim($strings[$i])); continue; } } } fclose($conn); $players = "{$currentClients} / {$maxplayers}"; if ($currentClients == $maxplayers && $maxplayers == 0) { $query33 = "SELECT active FROM swift_servers WHERE id={$srvid}"; $result4 = mysqli_fetch_array(mysqli_query($mysql, $query33)); if (intval($result4['active']) == 1) { echo "\nServer {$server} active, but dead. Rebooting"; $time = time(); $query2 = "INSERT INTO swift_logs (username, ip, action, time) VALUES ('CRON Task', '{$hostIp}', 'Restarted server {$server} (players 0 / 0)', '{$time}')"; restartServer($hostIp, $sshport, $account, $accpass, $startcmd); mysqli_query($mysql, $query2); continue; } } } } /* 3D Specific H&S statistics update code */ if ($srvid == 6) { $motd = ""; $gametype = ""; $conn = fsockopen("udp://127.0.0.1", 20100); socket_set_timeout($conn, 2); fwrite($conn, "ÿÿÿÿrcon rconpassword gametype"); while ($o = fgets($conn)) { if (strpos($o, "Gametype") !== false) {
$hostname = $row['hostname']; $port = $row['port']; $hostip = $row['ip']; $srvId = $row['srvId']; $sshport = $row['sshport']; $players = $row['players']; $startcmd = trim($row['startcmd']); $startcmd = str_replace("{port}", $port, $startcmd); $date = date("H:i, F j Y ", time()); $startcmd = str_replace("{date}", $date, $startcmd); $data = true; $task = ""; if ($active) { //Before showing everything to the user, parse ALL servers which are active (not stopped) and check that are they running. if (!checkStatus($hostip, $sshport, $acc, $pwd)) { restartServer($hostip, $sshport, $acc, $pwd, $startcmd); } $active = "Running"; $task = "<center><i class=\"stop icon\" title=\"Stop the server\" onclick=\"serverAction(true, {$srvId});\" style=\"cursor:pointer;color:blue;\"></i> <i class=\"refresh icon\" title=\"Restart the server\" style=\"cursor:pointer;color:green;\" onclick=\"serverAction(false, {$srvId});\"></i> <i class=\"remove icon\" title=\"Delete this server\" style=\"cursor:pointer;color:red;\" onclick=\"srvdel('{$srvId}', '{$name}');\"></i> <i class=\"settings icon\" style=\"cursor:pointer;\" title=\"Check & modify the parameters of this server\" onclick=\"location.href='edit/?id={$srvId}'\"></i><i class=\"cloud upload icon\" style=\"cursor:pointer;\" title=\"Update the 1fx. Mod on this server\" onclick=\"location.href='update/?id={$srvId}'\"></i><i class=\"ban icon\" title=\"Check the banlist of this server\" style=\"cursor:pointer;\" onclick=\"location.href='bl/?srvid={$srvId}'\"></i></center>"; } else { $active = "Stopped"; $task = "<center><i class=\"play icon\" title=\"Start the server\" onclick=\"location.href='?start={$srvId}'\" style=\"cursor:pointer;color:blue;\"></i> <i class=\"remove icon\" title=\"Delete this server\" style=\"cursor:pointer;color:red\" onclick=\"srvdel('{$srvId}', '{$name}');\"></i> <i class=\"settings icon\" style=\"cursor:pointer;\" title=\"Check & modify the parameters of this server\" onclick=\"location.href='edit/?id={$srvId}'\"></i><i class=\"cloud upload icon\" style=\"cursor:pointer;\" title=\"Update the 1fx. Mod on this server\" onclick=\"location.href='update/?id={$srvId}'\"></i></center>"; } echo "<tr><td>{$active}</td><td>{$name}</td><td>{$players}</td><td>{$hostip}</td><td>{$port}</td><td>{$hostname}</td><td>{$owner}</td><td>{$acc}</td><td>{$pwd}</td><td>{$task}</td></tr>"; } if (!$data) { echo "<tr class=\"no-records-found\"><td colspan=\"9\">No records found. You can add a new host machine by clicking the Add new host button.</td></tr>"; } ?> </tbody> </table>