<commit_before><?php

require_once('init.php');

include 'templates/head.html';

$_OUTPUT['random'] = rand(1941,2010).'-'.str_pad(rand(1,12), 2, '0', STR_PAD_LEFT).'-'.str_pad(rand(1,28), 2, '0', STR_PAD_LEFT);

if (isset($_GET['date'])):
    $_OUTPUT['date'] = $_GET['date'];
endif;

echo $twig -> render(file_get_contents('templates/form.html'), $_OUTPUT);

if (isset($_GET['date'])):

    // Convert the input into a timestamp
    $timestamp = strtotime($_GET['date']);
    $_OUTPUT['date'] = date('l, F jS, Y', $timestamp);

    //Loop through the songs
    $_OUTPUT['song'] = array();
    $_OUTPUT['songcount'] = 0;
    foreach($_DATA['songs'] as $loopsong):
        //Convert the date to a timestamp
        $songdate = strtotime($loopsong['date']);
        if ($songdate < $timestamp):
            $_OUTPUT['song'] = $loopsong;
            break;
        endif;
        $_OUTPUT['songcount']++;
    endforeach;

    if (empty($_OUTPUT['song'])):
        echo $twig -> render(file_get_contents('templates/nosong.html'), $_OUTPUT);
    else:

        // Grab the current time as a timestamp
        $now = time();
        // Calculate the difference between then and now (in seconds)
        $elapsed = $now - $timestamp;
        // Convert the elapsed time into years
        $lightyears = $elapsed/60/60/24/365;
        // Calculate the distance in parsecs
        $parsecs = $lightyears*0.306594845;

        //Loop through the stars
        $_OUTPUT['star'] = array();
        $_OUTPUT['starcount'] = 0;
        foreach ($_DATA['stars'] as $loopstar):
            if (floatval($parsecs) > floatval($loopstar['distance'])):
                $_OUTPUT['star'] = $loopstar;
                break;
            endif;
            $_OUTPUT['starcount']++;
        endforeach;

        if (empty($_OUTPUT['star'])):
            //Nothing matched.
            echo $twig -> render(file_get_contents('templates/nostar.html'), $_OUTPUT);
        else:
            echo $twig -> render(file_get_contents('templates/result.html'), $_OUTPUT);
        endif;
    endif;
endif;

include 'templates/foot.html';

?><commit_msg>Fix star count for songs<commit_after><?php

require_once('init.php');

include 'templates/head.html';

$_OUTPUT['random'] = rand(1941,2010).'-'.str_pad(rand(1,12), 2, '0', STR_PAD_LEFT).'-'.str_pad(rand(1,28), 2, '0', STR_PAD_LEFT);

if (isset($_GET['date'])):
    $_OUTPUT['date'] = $_GET['date'];
endif;

echo $twig -> render(file_get_contents('templates/form.html'), $_OUTPUT);

if (isset($_GET['date'])):

    // Convert the input into a timestamp
    $timestamp = strtotime($_GET['date']);
    $_OUTPUT['date'] = date('l, F jS, Y', $timestamp);

    //Loop through the songs
    $_OUTPUT['song'] = array();
    $_OUTPUT['songcount'] = 0;
    foreach($_DATA['songs'] as $loopsong):
        //Convert the date to a timestamp
        $songdate = strtotime($loopsong['date']);
        if ($songdate < $timestamp):
            $_OUTPUT['song'] = $loopsong;
            break;
        endif;
        $_OUTPUT['songcount']++;
    endforeach;

    if (empty($_OUTPUT['song'])):
        echo $twig -> render(file_get_contents('templates/nosong.html'), $_OUTPUT);
    else:

        // Grab the current time as a timestamp
        $now = time();
        // Calculate the difference between then and now (in seconds)
        $elapsed = $now - $timestamp;
        // Convert the elapsed time into years
        $lightyears = $elapsed/60/60/24/365;
        // Calculate the distance in parsecs
        $parsecs = $lightyears*0.306594845;

        //Loop through the stars
        $_OUTPUT['star'] = array();
        $_OUTPUT['starcount'] = count($_DATA['stars']);
        foreach ($_DATA['stars'] as $loopstar):
            if (floatval($parsecs) > floatval($loopstar['distance'])):
                $_OUTPUT['star'] = $loopstar;
                break;
            endif;
            $_OUTPUT['starcount']--;
        endforeach;

        if (empty($_OUTPUT['star'])):
            //Nothing matched.
            echo $twig -> render(file_get_contents('templates/nostar.html'), $_OUTPUT);
        else:
            echo $twig -> render(file_get_contents('templates/result.html'), $_OUTPUT);
        endif;
    endif;
endif;

include 'templates/foot.html';

?>
{'fraction_non_alphanumeric': 0.173230192217534, 'fraction_numerical': 0.01804969526488514, 'mean_word_length': 2.606931530008453, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2907650', 'n_tokens_mistral': 1377, 'n_tokens_neox': 1286, 'n_words': 298}