<commit_before><?php
    class FileCacher{
        public function __construct($url, $config) {
            $this->user = (logged_in()) ? Visitor::current()->login : "guest" ;
            $this->path = INCLUDES_DIR."/caches/".sanitize($this->user);

            $this->caches = INCLUDES_DIR."/caches";
            $this->url = $url;
            $this->file = $this->path."/".md5($this->url).".html";

            # If the cache directory is not writable, disable this module and cancel execution.
            if (!is_writable($this->caches))
                cancel_module("cacher");

            # Remove all expired files.
            $this->remove_expired();
        }

        public function url_available(){
            return file_exists($this->file);
        }

        public function get(){
            if (DEBUG)
                error_log("SERVING cache file for ".$this->url."...");

            $cache = array('contents' => file_get_contents($this->file), 'headers' => array());

            if (substr_count($cache['contents'], "<feed"))
              $cache['contents'][] = "Content-Type: application/atom+xml; charset=UTF-8";

            return $cache;
        }

        public function set($value){
            if (DEBUG)
                error_log("GENERATING cache file for ".$this->url."...");
<commit_msg>Fixed a typo in FileCacher.<commit_after><?php
    class FileCacher{
        public function __construct($url, $config) {
            $this->user = (logged_in()) ? Visitor::current()->login : "guest" ;
            $this->path = INCLUDES_DIR."/caches/".sanitize($this->user);

            $this->caches = INCLUDES_DIR."/caches";
            $this->url = $url;
            $this->file = $this->path."/".md5($this->url).".html";

            # If the cache directory is not writable, disable this module and cancel execution.
            if (!is_writable($this->caches))
                cancel_module("cacher");

            # Remove all expired files.
            $this->remove_expired();
        }

        public function url_available(){
            return file_exists($this->file);
        }

        public function get(){
            if (DEBUG)
                error_log("SERVING cache file for ".$this->url."...");

            $cache = array('contents' => file_get_contents($this->file), 'headers' => array());

            if (substr_count($cache['contents'], "<feed"))
                $cache["headers"][] = "Content-Type: application/atom+xml; charset=UTF-8";

            return $cache;
        }

        public function set($value){
            if (DEBUG)
                error_log("GENERATING cache file for ".$this->url."...");

{'fraction_non_alphanumeric': 0.161604799400075, 'fraction_numerical': 0.0014998125234345708, 'mean_word_length': 1.944812362030905, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '493794', 'n_tokens_mistral': 761, 'n_tokens_neox': 727, 'n_words': 162}