Sindbad~EG File Manager

Current Path : /usr/home/beeson/public_html/WebMathXpert/Demos/PolygonDemo/
Upload File :
Current File : //usr/home/beeson/public_html/WebMathXpert/Demos/PolygonDemo/test3.php

<!DOCTYPE html>
<?php
$serverAddress = 'localhost'; // Adjust the server address
$serverPort = 12347; // Adjust the server port
$timeout = 5; // Connection timeout in seconds
$startupDelay = 2; // Delay for server startup in seconds, if server is not already running

if (!(isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || 
   $_SERVER['HTTPS'] == 1) ||  
   isset($_SERVER['HTTP_X_FORWARDED_PROTO']) &&   
   $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'))
{
   $redirect = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
   header('HTTP/1.1 301 Moved Permanently');
   header('Location: ' . $redirect);
   exit();
}
?>
<html>
<head>
    <title>PHP to C Socket Example</title>
</head>
<body>
    <form action="index.php" method="post">
        <input type="text" name="data" placeholder="polygon 7">
        <input type="submit" value="Send">
    </form>
<?php
function isServerRunning() 
{
    echo("hey");
    $command = 'ps aux | grep PolygonServer | grep -v grep | wc -l';
    $output = shell_exec($command);
    $processCount = intval(trim($output));
    echo "within isServerRunning; $processCount\n";
    return $processCount > 0;
}

echo "got here\n";
   if (!isServerRunning()) 
    {
        // Server is not running, start it
        $startCommand = './PolygonServer'; // path to server program
        $startCommand = $startCommand .  ' > /dev/null 2>&1 &';    // background
        echo("Server is not running, so it will now be started.\n");
        echo("Running $startCommand \n");
        // Start the server in the background
        exec($startCommand);

        // Wait for the server to start up
        sleep($startupDelay);
    }
    
?>
</body>
</html>

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists