<commit_before><?php

/**
 * @author <NAME> <<EMAIL>>
 * @version 1.0
 * @copyright Copyright &copy; 2012, Telaxus LLC
 * @license MIT
 * @package epesi-base
 */

//define('DEBUG_AUTOLOADS', 1);

if (defined('DEBUG_AUTOLOADS') && DEBUG_AUTOLOADS
        && !defined("_VALID_ACCESS")) {
    define('CID', false);
    require_once '../include.php';

    if (isset($_GET['clear'])) {
        unset($_SESSION['debug_autoloads']);
        print "Memory cleared";
        return;
    }
    print("<pre>");
    if (isset($_SESSION['debug_autoloads'])) {
        foreach ($_SESSION['debug_autoloads'] as $class => $bt) {
            print($class . "\n");
            foreach ($bt as $btx) {
                var_dump($btx);
                print("<hr>");
            }
            print("<hr><hr>");
        }
    }
    print("</pre>");
    return;
}

defined("_VALID_ACCESS") || die('Direct access forbidden');

spl_autoload_register('epesi_classes_autoloader');

function epesi_classes_autoloader($class_name) {
    if (defined('DEBUG_AUTOLOADS') && DEBUG_AUTOLOADS) {
        if (!isset($_SESSION['debug_autoloads']))
            $_SESSION['debug_autoloads'] = array();
        if (!isset($_SESSION['debug_autoloads'][$class_name]))
            $_SESSION['debug_autoloads'][$class_name] = array();
        $_SESSION['debug_autoloads'][$class_name][] = debug_backtrace();
    }

    $file = 'modules' . DIRECTORY_SEPARATOR;
    $file .= str_replace('_', DIRECTORY_SEPARATOR, $class_name);
    $file .= '.php';
    if (file_exists($file)) {
        require_once $file;
    }
}

?><commit_msg>Improve autoloader debugging<commit_after><?php

/**
 * @author <NAME> <<EMAIL>>
 * @version 1.0
 * @copyright Copyright &copy; 2012, Telaxus LLC
 * @license MIT
 * @package epesi-base
 */

/*
 * Use below defines to debug autoloading feature.
 * 'count' - count called includes for specific class name
 * 'backtrace' - stores backtraces to track place which called autoloader
 * 
 * You can see debug info only when it's enabled.
 * Open your browser to this file.
 * EPESI_ADDRESS/include/autoloader.php
 */
//define('DEBUG_AUTOLOADS', 'count');
//define('DEBUG_AUTOLOADS', 'backtrace');

if (defined('DEBUG_AUTOLOADS') && DEBUG_AUTOLOADS
        && !defined("_VALID_ACCESS")) {
    define('CID', false);
    require_once '../include.php';

    if (isset($_GET['clear'])) {
        unset($_SESSION['debug_autoloads']);
        print "Memory cleared";
        return;
    }
    print("<pre>");
    if (isset($_SESSION['debug_autoloads'])) {
        if (DEBUG_AUTOLOADS == 'count') {
            var_dump($_SESSION['debug_autoloads']);
        } elseif (DEBUG_AUTOLOADS == 'backtrace') {
            foreach ($_SESSION['debug_autoloads'] as $class => $bt) {
                print($class . "\n");
                foreach ($bt as $btx) {
                    var_dump($btx);
                    print("<hr>");
                }
                print("<hr><hr>");
            }
        }
    }
    print("</pre>");
    return;
}

defined("_VALID_ACCESS") || die('Direct access forbidden');

spl_autoload_register('epesi_classes_autoloader');

function epesi_classes_autoloader($class_name) {
    if (defined('DEBUG_AUTOLOADS') && DEBUG_AUTOLOADS) {
        if (!isset($_SESSION['debug_autoloads']))
            $_SESSION['debug_autoloads'] = array();
        if (DEBUG_AUTOLOADS == 'count') {
            if (!isset($_SESSION['debug_autoloads'][$class_name])
                    || !is_numeric($_SESSION['debug_autoloads'][$class_name]))
                $_SESSION['debug_autoloads'][$class_name] = 0;
            $_SESSION['debug_autoloads'][$class_name] += 1;
        } elseif (DEBUG_AUTOLOADS == 'backtrace') {
            if (!isset($_SESSION['debug_autoloads'][$class_name])
                    || !is_array($_SESSION['debug_autoloads'][$class_name]))
                $_SESSION['debug_autoloads'][$class_name] = array();
            $_SESSION['debug_autoloads'][$class_name][] = debug_backtrace();
        }
    }

    $file = 'modules' . DIRECTORY_SEPARATOR;
    $file .= str_replace('_', DIRECTORY_SEPARATOR, $class_name);
    $file .= '.php';
    if (file_exists($file)) {
        require_once $file;
    }
}

?>
{'fraction_non_alphanumeric': 0.17051678971183615, 'fraction_numerical': 0.00357227911407478, 'mean_word_length': 2.8181818181818183, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 23, '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': '4082878', 'n_tokens_mistral': 1370, 'n_tokens_neox': 1351, 'n_words': 235}