function test_is_https($k, $v, $should_be_https)
{
    global $host, $path;
    global $https_key, $https_value;
    test_init("off", $host, $path, null, true);
    unset($_SERVER[$https_key]);
    $_SERVER[$k] = $v;
    $is_https = is_https();
    $pass = $is_https === $should_be_https ? true : false;
    pass_fail($pass);
    echo "\t\t\tHTTPS ({$k}) is set to " . ($is_https ? "on" : "off");
    if (!$pass) {
        echo "\n\t\t\tand it should be " . ($should_be_https ? "on" : "off");
    }
    echo "\n\n";
}
Esempio n. 2
0
function score_track($file, $answers = [])
{
    global $coordinate_1, $coordinate_2, $coordinate_3, $cwd;
    $file = $cwd . '/' . $file;
    $time = microtime(true);
    echo "------------------------" . PHP_EOL;
    _log("Memory", memory_get_usage(true));
    _log("Track", $file);
    _log('Creating set:');
    $set_2 = new coordinate_set();
    action('Parsing file', $set_2->parse_igc(file_get_contents($file)));
    _log("Date", $set_2->date());
    _log('Duration', $set_2->last()->timestamp() - $set_2->first()->timestamp() . 's');
    $intial = $set_2->count();
    _log('Points', $set_2->count() . " (" . $intial . ")");
    _log('Parts', $set_2->part_count());
    // action('Simplifing file', $set_2->simplify());
    // _log('Points', $set_2->count() . " (" . $intial . ")");
    // action('Trimming file', $set_2->trim());
    // _log('Points', $set_2->count() . " (" . $intial . ")");
    // _log('Parts',  $set_2->part_count());
    action('Repairing track', $set_2->repair());
    action('Graphing track', $set_2->set_graph_values());
    action('Ranging track', $set_2->set_ranges());
    if ($set_2->part_count() > 1) {
        action('Setting section', $set_2->set_section(1));
    }
    _log('Points', $set_2->count() . " (" . $intial . ")");
    _log('Parts', $set_2->part_count());
    action('Building map', ($map_2 = new distance_map($set_2)) ? "Ok" : "Fail");
    echo get_score($map_2, $od = $map_2->score_open_distance_3tp(), $answers[0], 'OD');
    echo get_score($map_2, $or = $map_2->score_out_and_return(), $answers[1], 'OR');
    echo get_score($map_2, $tr = $map_2->score_triangle(), $answers[2], 'TR');
    _log('Coordinates', $od->get_gridref());
    _log('Duration', $set_2->last()->timestamp() - $set_2->first()->timestamp() . 's');
    $task = new task($coordinate_1, $coordinate_2, $coordinate_3);
    _log('Checking task:');
    echo pass_fail('Valid task is found' . PHP_EOL, $od->completes_task($set_2) == true);
    echo pass_fail('Invalid task not found' . PHP_EOL, $task->completes_task($set_2) == false);
    _log('Outputting kml');
    $formatter = new formatter_kml($set_2, $file, $od, $or, $tr, $od);
    file_put_contents(str_replace('.igc', '.kml', $file), $formatter->output());
    _log('Outputting js');
    $formatter = new formatter_js($set_2, 10);
    file_put_contents(str_replace('.igc', '.js', $file), $formatter->output());
    _log('Outputting kml (Split)');
    $formatter = new formatter_kml_split($set_2);
    file_put_contents(str_replace('.igc', '_split.kml', $file), $formatter->output());
    _log('Outputting KML (Earth)');
    $formatter = new formatter_kml_earth($set_2, $file, $od, $or, $tr);
    file_put_contents(str_replace('.igc', '_earth.kml', $file), $formatter->output());
    unset($set_2);
    unset($formatter);
    _log("Memory", memory_get_usage(true));
}