<commit_before><?php
// Below Average //Shale Data Manager JSON // Krisdb2009 // 1.5.5 // Unix Safe // Collision Safe //
//Settings
$pathToDB     = __DIR__.'/DB/';
$ext          = '.dat';
$crypt        = $DBencryptionKey; //16/24/32 Char long key
$cryptEnabled = true;
//

//Clean path input because its dirty
function cleanPath($path)
{
    $path = str_replace('\\', '/', $path);
    $list = array('.', './', '../');
    $path = str_replace($list, '', $path);
    return $path;
}
//

//$array = loadDB('asdf\asdf\asdf'); //Loads a database to an array
function loadDB($path)
{
    $path = cleanPath($path);
    global $pathToDB;
    global $ext;
    global $crypt;
    if(file_exists($pathToDB.$path.$ext))
    {
        $file = fopen($pathToDB.$path.$ext, "r"); //File Path Open
        $locked = true;
        while($locked)
        {
            if(flock($file, LOCK_SH)) //If can lock read.
            {
                $data = json_decode(decrypt(@fread($file, filesize($pathToDB.$path.$ext)), $crypt), true);
                flock($file, LOCK_UN);
                $locked = false;
            }
            else
            {
                $locked = true;
            }
        }
        fclose($file);
    }
    else
    {
        $data = array();
    }
    return $data;
}

//
<commit_msg>Update shaledatamanager.lib.php<commit_after><?php
// Below Average //Shale Data Manager JSON // Krisdb2009 // 1.5.5 // Unix Safe // Collision Safe //
//Settings
$pathToDB     = __DIR__.'/DB/';
$ext          = '.dat';
$crypt        = $DBencryptionKey; //16/24/32 Char long key
$cryptEnabled = true;
//

//Clean path input because its dirty
function cleanPath($path)
{
    $path = str_replace('\\', '/', $path);
    $list = array('.', './', '../');
    $path = str_replace($list, '', $path);
    return $path;
}
//

//$array = loadDB('asdf\asdf\asdf'); //Loads a database to an array
function loadDB($path)
{
    $path = cleanPath($path);
    global $pathToDB;
    global $ext;
    global $crypt;
    if(file_exists($pathToDB.$path.$ext))
    {
        $file = fopen($pathToDB.$path.$ext, "r"); //File Path Open
        $locked = true;
        while($locked)
        {
            if(flock($file, LOCK_SH)) //If can lock read.
            {
                $data = json_decode(decrypt(@file_get_contents($pathToDB.$path.$ext), $crypt), true);
                flock($file, LOCK_UN);
                $locked = false;
            }
            else
            {
                $locked = true;
            }
        }
        fclose($file);
    }
    else
    {
        $data = array();
    }
    return $data;
}

//

{'fraction_non_alphanumeric': 0.17590822179732313, 'fraction_numerical': 0.00994263862332696, 'mean_word_length': 1.7565858798735512, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '493332', 'n_tokens_mistral': 884, 'n_tokens_neox': 851, 'n_words': 192}