<commit_before><?php

// Only activate FirePHP if certain header prefixes are found:
//  * x-wf-
//  * x-insight

$__FIREPHP__headers = false;
if(function_exists('getallheaders')) {
    $__FIREPHP__headers = getallheaders();
} else {
    $__FIREPHP__headers = $_SERVER;
}
$__FIREPHP__activate = false;
foreach( $__FIREPHP__headers as $name => $value ) {
    $name = strtolower($name);
    if(substr($name, 0, 5) == 'http_') {
        $name = str_replace(' ', '-', str_replace('_', ' ', substr($name, 5)));
    }
    if(substr($name, 0, 5)=='x-wf-') {
        $__FIREPHP__activate = true;
    } else
    if(substr($name, 0, 9)=='x-insight') {
        $__FIREPHP__activate = true;
    }
}
unset($__FIREPHP__headers);

if($__FIREPHP__activate) {

    unset($__FIREPHP__activate);

    set_include_path(get_include_path() . PATH_SEPARATOR . dirname(dirname(__FILE__)));
    
    require_once('FirePHP/Insight.php');
    
    FirePHP::setInstance(new FirePHP_Insight());
    
    Insight_Helper__main();

} else {

    unset($__FIREPHP__activate);

    class FirePHP {
        public function getEnabled() {
            return false;
        }
        public function detectClientExtension() {
            return false;
        }
        public function __call($name, $arguments) {
            return new FirePHP();
        }
        public static function __callStatic($name, $arguments) {
            return new FirePHP();
        }
    }

}<commit_msg>Bugfix: Avoid globals pollution during initialization<commit_after><?php

// This function is called at the bottom of this page
function FirePHP__main() {

    // Only activate FirePHP if certain header prefixes are found:
    //  * x-wf-
    //  * x-insight
    
    $headers = false;
    if(function_exists('getallheaders')) {
        $headers = getallheaders();
    } else {
        $headers = $_SERVER;
    }
    $activate = false;
    foreach( $headers as $name => $value ) {
        $name = strtolower($name);
        if(substr($name, 0, 5) == 'http_') {
            $name = str_replace(' ', '-', str_replace('_', ' ', substr($name, 5)));
        }
        if(substr($name, 0, 5)=='x-wf-') {
            $activate = true;
        } else
        if(substr($name, 0, 9)=='x-insight') {
            $activate = true;
        }
    }
    
    if($activate) {
    
        set_include_path(get_include_path() . PATH_SEPARATOR . dirname(dirname(__FILE__)));
        
        require_once('FirePHP/Insight.php');
        
        FirePHP::setInstance(new FirePHP_Insight());
        
        Insight_Helper__main();
    
    } else {
    
        class FirePHP {
            protected static $instance = null;
            public static function getInstance() {
                if(!self::$instance) {
                    self::$instance = new FirePHP();
                }
                return self::$instance;
            }
            public function getEnabled() {
                return false;
            }
            public function detectClientExtension() {
                return false;
            }
            public function __call($name, $arguments) {
                return self::getInstance();
            }
            public static function __callStatic($name, $arguments) {
                return self::getInstance();
            }
        }
    }
}

FirePHP__main();
{'fraction_non_alphanumeric': 0.13313343328335833, 'fraction_numerical': 0.004197901049475262, 'mean_word_length': 2.027223230490018, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4905712', 'n_tokens_mistral': 1014, 'n_tokens_neox': 981, 'n_words': 203}