<commit_before><?php
error_reporting(0); // Set E_ALL for debuging

session_start();

if (!isset($_SESSION['Auth']['User']['id'])) {
    header("HTTP/1.0 401 Unauthorized");
    echo '{"error": "Login failed."}';
    exit;
}

is_readable('./vendor/autoload.php') && require './vendor/autoload.php';
require './autoload.php';

function access($attr, $path, $data, $volume, $isDir, $relpath) {
    $basename = basename($path);
    return $basename[0] === '.'                  // if file/folder begins with '.' (dot)
             && strlen($relpath) !== 1           // but with out volume root
        ? !($attr == 'read' || $attr == 'write') // set read+write to false, other (locked+hidden) set to true
        :  null;                                 // else elFinder decide it itself
}

$opts = array(
    'roots'  => array(
        array(
            'driver' => 'LocalFileSystem',
            'path'   => '{{UPLOADS_PATH}}',
            'URL'    => '{{UPLOADS_URL}}',
            'trashHash'     => 't1_Lw',                         // elFinder's hash of trash folder
            'winHashFix'    => DIRECTORY_SEPARATOR !== '/',     // to make hash same to Linux one on windows too
            'uploadDeny'    => array('all'),                    // All Mimetypes not allowed to upload
            'uploadAllow'   => array('image', 'text/plain'),    // Mimetype `image` and `text/plain` allowed to upload
            'uploadOrder'   => array('deny', 'allow'),          // allowed Mimetype `image` and `text/plain` only
            'accessControl' => 'access',                        // disable and hide dot starting files (OPTIONAL)
        ),
        // Trash volume
        array(
            'id'            => '1',
            'driver'        => 'Trash',
            'path'          => '{{UPLOADS_PATH}}.trash',
            'tmbURL'        => '{{UPLOADS_URL}}/.trash/.tmb/',
            'winHashFix'    => DIRECTORY_SEPARATOR !== '/', // to make hash same to Linux one on windows too
            'uploadDeny'    => array('all'),                // Recomend the same settings as the original volume that uses the trash
            'uploadAllow'   => array('image', 'text/plain'), // Same as above
            'uploadOrder'   => array('deny', 'allow'),      // Same as above
            'accessControl' => 'access',                    // Same as above
        ),
    )
);

$connector = new elFinderConnector(new elFinder($opts));
$connector->run();
<commit_msg>fixed for sniffer<commit_after><?php
error_reporting(0); //Set E_ALL for debuging

session_start();

if (!isset($_SESSION['Auth']['User']['id'])) {
    header("HTTP/1.0 401 Unauthorized");
    echo '{"error": "Login failed."}';
    exit;
}

is_readable('./vendor/autoload.php') && require './vendor/autoload.php';
require './autoload.php';

/**
 * Control file access using "accessControl" callback.
 * This method will disable accessing files/folders starting from '.' (dot)
 * @param string $attr attribute name (read|write|locked|hidden)
 * @param string $path absolute file path
 * @param string $data value of volume option `accessControlData`
 * @param object $volume elFinder volume driver object
 * @param bool|null $isDir path is directory (true: directory, false: file, null: unknown)
 * @param string $relpath file path relative to volume root directory started with directory separator
 * @return bool|null
 */
function access($attr, $path, $data, $volume, $isDir, $relpath)
{
    $basename = basename($path);

    return $basename[0] === '.' // if file/folder begins with '.' (dot)
             && strlen($relpath) !== 1 // but with out volume root
        ? !($attr == 'read' || $attr == 'write') // set read+write to false, other (locked+hidden) set to true
        : null; //else elFinder decide it itself
}

$opts = [
    'roots' => [
        [
            'driver' => 'LocalFileSystem',
            'path' => '{{UPLOADS_PATH}}',
            'URL' => '{{UPLOADS_URL}}',
            'trashHash' => 't1_Lw', // elFinder's hash of trash folder
            'winHashFix' => DIRECTORY_SEPARATOR !== '/', // to make hash same to Linux one on windows too
            'uploadDeny' => ['all'], // All Mimetypes not allowed to upload
            'uploadAllow' => ['image', 'text/plain'], // Mimetype `image` and `text/plain` allowed to upload
            'uploadOrder' => ['deny', 'allow'], // allowed Mimetype `image` and `text/plain` only
            'accessControl' => 'access', // disable and hide dot starting files (OPTIONAL)
        ],
        // Trash volume
        [
            'id' => '1',
            'driver' => 'Trash',
            'path' => '{{UPLOADS_PATH}}.trash',
            'tmbURL' => '{{UPLOADS_URL}}/.trash/.tmb/',
            'winHashFix' => DIRECTORY_SEPARATOR !== '/', // to make hash same to Linux one on windows too
            'uploadDeny' => ['all'], // Recomend the same settings as the original volume that uses the trash
            'uploadAllow' => ['image', 'text/plain'], // Same as above
            'uploadOrder' => ['deny', 'allow'], // Same as above
            'accessControl' => 'access', // Same as above
        ],
    ],
];

$connector = new elFinderConnector(new elFinder($opts));
$connector->run();

{'fraction_non_alphanumeric': 0.1635666347075743, 'fraction_numerical': 0.003835091083413231, 'mean_word_length': 2.235732009925558, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7304024', 'n_tokens_mistral': 1522, 'n_tokens_neox': 1513, 'n_words': 446}