/**
 * Returns the algorithm examples, source code and docblock
 *
 * @param  string $algorithm
 * @return array
 */
function get_algorithm_details($algorithm)
{
    $filename = str_replace('_', '-', $algorithm) . '.php';
    $examples = get_examples($filename);
    $source_code = get_source_code($filename);
    $docblock = get_docblock($algorithm, $source_code);
    return array($filename, $examples, $source_code, $docblock);
}
Example #2
0
    $path = sprintf("data/submits/%d/%d-compiler.log", $id, $id);
    if (file_exists($path)) {
        return htmlentities(file_get_contents($path));
    } else {
        return "Compiler log not found";
    }
}
/*---------------------------------------------------------------------------*/
// if the link is malformed, die
if (!isset($_GET['submit']) || intval($_GET['submit']) == 0 || intval($_GET['submit']) < 1 || !isset($_COOKIE['username'])) {
    die("No submit chosen.");
}
require 'database.php';
// the PlatesPHP template engine
require 'lib/vendor/autoload.php';
$title = "Submission Details";
$user_logged_in = isset($_COOKIE['username']);
// check whether the user is an admin
$admin = $user_logged_in == true ? is_admin($_COOKIE['username'], $_COOKIE['huehuehue']) : false;
// submit data
// keys: submit_id, site, timestamp, username, problem, language, status
$submit = get_submit($_GET['submit'], $dbc);
// source code of the submission
// error string will be stored here if the source is not found
$source_code = get_source_code($_GET['submit'], $submit['language']);
$compiler_log = get_compiler_log($_GET['submit']);
$test_log = get_test_log($_GET['submit']);
$data = array('title' => $title, 'admin' => $admin, 'submit' => $submit, 'source_code' => $source_code, 'compiler_log' => $compiler_log, 'test_log' => $test_log);
// render the webpage
$templates = new League\Plates\Engine('templates');
echo $templates->render('view-submit', $data);