<commit_before><?php
/**
 * A hierarchical users and rights system plugin for Pico.
 *
 * @author  <NAME>
 * @link    http://lxl.io
 * @link    http://philecms.github.io/Phile
 * @license http://opensource.org/licenses/MIT
 */
class PhileUsers extends \Phile\Plugin\AbstractPlugin implements \Phile\EventObserverInterface {

    private $user;
    private $users;
    private $rights;
    private $base_url;
    private $hash_type;

    private $config;
    private $twig_vars;

    public function __construct() {
        \Phile\Event::registerEvent('config_loaded', $this);
        \Phile\Event::registerEvent('after_parse_content', $this);
        \Phile\Event::registerEvent('request_uri', $this);
        $this->config = \Phile\Registry::get('Phile_Settings');
        $this->twig_vars = \Phile\Registry::get('templateVars');
    }

    public function on($eventKey, $data = null) {
        if ($eventKey == 'config_loaded') {
            $this->config_loaded($data);
        } elseif ($eventKey == 'request_uri') {
            $this->request_uri($data['uri']);
        } elseif ($eventKey == 'after_parse_content') {
            $this->export_twig_vars();
        }
        // TODO call getPages() somewhere
    }

    /**
     * Store settings and define the current user.
     */
    private function config_loaded(&$data) {
        $this->base_url = $this->config['base_url'];
        $this->users = @$this->config['users'];
        $this->rights = @$this->config['rights'];
        if (in_array($this->config['hash_type'], hash_algos())) {
            $this->hash_type = $this->config['hash_type'];
        } else {
            $this->hash_type = 'sha256';
        }

        $this->user = '';
        $this->check_login();
    }

    /**
     * If the requested url is unauthorized for the current user
     * display page "403" and send 403 headers.
     */
    private function request_uri(&$uri) {
        $page_url = rtrim($uri, '/');<commit_msg>Use sha512 by default<commit_after><?php
/**
 * A hierarchical users and rights system plugin for Pico.
 *
 * @author  <NAME>
 * @link    http://lxl.io
 * @link    http://philecms.github.io/Phile
 * @license http://opensource.org/licenses/MIT
 */
class PhileUsers extends \Phile\Plugin\AbstractPlugin implements \Phile\EventObserverInterface {

    private $user;
    private $users;
    private $rights;
    private $base_url;
    private $hash_type;

    private $config;
    private $twig_vars;

    public function __construct() {
        \Phile\Event::registerEvent('config_loaded', $this);
        \Phile\Event::registerEvent('after_parse_content', $this);
        \Phile\Event::registerEvent('request_uri', $this);
        $this->config = \Phile\Registry::get('Phile_Settings');
        $this->twig_vars = \Phile\Registry::get('templateVars');
    }

    public function on($eventKey, $data = null) {
        if ($eventKey == 'config_loaded') {
            $this->config_loaded($data);
        } elseif ($eventKey == 'request_uri') {
            $this->request_uri($data['uri']);
        } elseif ($eventKey == 'after_parse_content') {
            $this->export_twig_vars();
        }
        // TODO call getPages() somewhere
    }

    /**
     * Store settings and define the current user.
     */
    private function config_loaded(&$data) {
        $this->base_url = $this->config['base_url'];
        $this->users = @$this->config['users'];
        $this->rights = @$this->config['rights'];
        if (in_array($this->config['hash_type'], hash_algos())) {
            $this->hash_type = $this->config['hash_type'];
        } else {
            $this->hash_type = 'sha512';
        }

        $this->user = '';
        $this->check_login();
    }

    /**
     * If the requested url is unauthorized for the current user
     * display page "403" and send 403 headers.
     */
    private function request_uri(&$uri) {
        $page_url = rtrim($uri, '/');
{'fraction_non_alphanumeric': 0.15826972010178117, 'fraction_numerical': 0.0053435114503816794, 'mean_word_length': 2.5801457194899817, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 39, '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': '1909501', 'n_tokens_mistral': 1215, 'n_tokens_neox': 1178, 'n_words': 243}