<commit_before><?php
$databases = getListOfDatabases();

if ($_REQUEST['database'] || !isset($_SESSION['database']) || empty($_SESSION['database']))
{
    {
        if (in_array($_REQUEST['database'], $databases))
        {
            $_SESSION['database'] = $_REQUEST['database'];
            $redirect             = true;
        }
    }


    function getListOfDatabases()
    {
        $url        = "http://" . $_SESSION['host'] . "/db/?u=" . $_SESSION['user'] . "&p=" . $_SESSION['pw'];
        $httpResult = getUrlContent($url);

        if (200 == $httpResult['status_code'])
        {

            $json = json_decode($httpResult['results']);
            print_r($json);
            $result = array();
            foreach ($json as $key => $value)
            {
                $result[] = $value;
            }

            return $result;
        }
        else
        {
            // TODO error handling
        }
    }

    function getUrlContent($url)
	{
	    $ch = curl_init();
	    curl_setopt($ch, CURLOPT_URL, $url);
	    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
	    curl_setopt($ch, CURLOPT_TIMEOUT, 5);
	    $data       = curl_exec($ch);
	    $statuscode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
	    curl_close($ch);

	    return ['status_code' => $statuscode, 'results' => $data];
	}
}<commit_msg>Moved functions outside of if block<commit_after><?php
$databases = getListOfDatabases();

if ($_REQUEST['database'] || !isset($_SESSION['database']) || empty($_SESSION['database']))
{
    {
        if (in_array($_REQUEST['database'], $databases))
        {
            $_SESSION['database'] = $_REQUEST['database'];
            $redirect             = true;
        }
    }



}

function getListOfDatabases()
    {
        $url        = "http://" . $_SESSION['host'] . "/db/?u=" . $_SESSION['user'] . "&p=" . $_SESSION['pw'];
        $httpResult = getUrlContent($url);

        if (200 == $httpResult['status_code'])
        {

            $json = json_decode($httpResult['results']);
            print_r($json);
            $result = array();
            foreach ($json as $key => $value)
            {
                $result[] = $value;
            }

            return $result;
        }
        else
        {
            // TODO error handling
        }
    }

function getUrlContent($url)
	{
	    $ch = curl_init();
	    curl_setopt($ch, CURLOPT_URL, $url);
	    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
	    curl_setopt($ch, CURLOPT_TIMEOUT, 5);
	    $data       = curl_exec($ch);
	    $statuscode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
	    curl_close($ch);

	    return ['status_code' => $statuscode, 'results' => $data];
	}
{'fraction_non_alphanumeric': 0.16823104693140795, 'fraction_numerical': 0.004332129963898917, 'mean_word_length': 2.078888888888889, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '742475', 'n_tokens_mistral': 895, 'n_tokens_neox': 840, 'n_words': 151}