Sindbad~EG File Manager

Current Path : /home/beeson/public_html/WebMathXpert/
Upload File :
Current File : //home/beeson/public_html/WebMathXpert/AutoTest.php

<?php
// Set HTTP header to prevent caching
header("Cache-Control: no-cache, must-revalidate");

header("Expires: Sat, 1 Jan 2000 00:00:00 GMT"); // Date in the past
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Pragma: no-cache");

// Start or resume the session
session_start();
$sessionId = session_id();  // guaranteed not to contain a pipe character
ini_set('display_errors', 1);
error_reporting(E_ALL);

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();
}

 $nextpagesymbol = "https://localhost:8443/SymbolicDoc.php";
 $nextpagegraph =  "https://localhost:8443/GraphDoc.php";

$language = "english";
$firstTopic = 45;     // first symbolic topic is 44, but it's "evaluate numerically"; so full autotest starts with 45.   97 is cubics
$lastTopic = 179;     // last symbolic topic
// to autotest a single topic or a range, vary those numbers

?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>AutoTest for MathXpert</title>
<style>
    iframe {
        width: 100%;
        height: 1000px;
        border: none;
    }
    #status {
        padding: 10px;
        background-color: #f0f0f0;
        border: 1px solid #ddd;
        margin-bottom: 10px;
    }
</style>
</head>
<body>
<div id="status">Starting autotest...</div>
<iframe name="testFrame"></iframe> <!-- This is where responses will be displayed -->

<script>
function updateStatus(topic, problem) {
    document.getElementById('status').innerText = 'Testing topic ' + topic + ', problem ' + problem;
}
</script>

<?php
// topic numbers start at 1, so we put 0 in for the 0-th entry:
$problemsPerTopic = [0,28, 50, 50, 50, 20, 16, 29, 26, 14, 
12, 11,  7,  6, 24,  8,  3,  1, 14,  9, 
21, 21, 26, 22, 45, 37, 20, 10,  9, 20, 
20, 20,  2,  6, 23, 16, 10,  9,  9,  9, 
 2,  2, 10,  8, 50, 32, 33, 51, 50, 50, 
50, 52, 50, 55, 54, 55, 47, 50, 51, 50, 
57, 50, 61, 64, 47, 50, 50, 55, 55, 55, 
48, 50, 50, 58, 54, 57, 50, 50, 57, 50, 
52, 51, 51, 66, 50, 50, 54, 56, 61, 59, 
58, 58, 46, 55, 50, 50, 50, 50, 63, 50, 
53, 52, 47, 87, 59, 50, 62, 49, 49, 47, 
50, 51, 58, 61, 59, 55, 54, 53, 50, 50, 
54, 55, 50, 27, 21, 73, 50, 45,  1, 53,
56, 30, 50, 54, 51, 50, 56, 43, 48, 56, 
36, 76, 50, 45, 50, 54, 58, 59, 50, 50, 
54, 51, 61, 51, 52, 49, 69, 52, 54, 13, 
47, 61, 44, 50, 49, 62, 50, 53, 60, 60, 
71, 55, 77, 50, 24, 22, 15, 7, 26, 17];

$delayMilliseconds = 800; // Delay between submissions in milliseconds
$counter = 0;

// PHP will write one Javascript program for each problem to be autotested

for ($topic = $firstTopic; $topic <= $lastTopic; $topic++) {
    $nproblems =  $problemsPerTopic[$topic]; 
    for ($problem = 1; $problem <= $nproblems-1; $problem++) {
        echo "<script>
            setTimeout(function(){
                updateStatus({$topic}, {$problem});
                var form = document.createElement('form');
                form.setAttribute('method', 'post');
                form.setAttribute('action', 'SymbolicDoc.php');
                form.setAttribute('target', 'testFrame');

                var languageField = document.createElement('input');
                languageField.setAttribute('type', 'hidden');
                languageField.setAttribute('name', 'language');
                languageField.setAttribute('value', '{$language}');
                form.appendChild(languageField);

                var widthField = document.createElement('input');
                widthField.setAttribute('type', 'hidden');
                widthField.setAttribute('name', 'width');
                widthField.setAttribute('value', document.body.clientWidth);
                form.appendChild(widthField);

                var autoTopicField = document.createElement('input');
                autoTopicField.setAttribute('type', 'hidden');
                autoTopicField.setAttribute('name', 'autoTopicField');
                autoTopicField.setAttribute('value', '{$topic}');
                form.appendChild(autoTopicField);

                var autoProblemField = document.createElement('input');
                autoProblemField.setAttribute('type', 'hidden');
                autoProblemField.setAttribute('name', 'autoProblemField');
                autoProblemField.setAttribute('value', '{$problem}');
                form.appendChild(autoProblemField);

                document.body.appendChild(form);
                form.submit();
                setTimeout(function() {
                    document.body.removeChild(form);
                }, 1000); // Delay to ensure form is processed
            }, {$counter} * {$delayMilliseconds});
        </script>";
        $counter++; // Increment counter to increase delay for each submission
    }
}
?>
</body>
</html>

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