<commit_before><?php

class ProposalType {
    
    var $table;
    var $col;
    
    var $generic_pages = array('proposal', 'fault', 'cal', 'feedback', 'vstat', 'users');
    
    var $visit_table;
    var $session_column;
    
    var $pages = array();
    var $prop_menu = array();
    var $ext_menu =  array();
    var $ext_admin = array();
    
    var $staff = False;
    var $visits = array();
    var $sessionids = array();
    var $proposalid;
    
    var $default = '';
    var $dir = '';

    var $staff_permission = 'super_admin';
    
    function __construct($app, $db, $user) {
        $this->app = $app;
        $this->db = $db;
        $this->user = $user;

        $this->staff = $this->user->has($this->staff_permission);
    }
    
    
    // Work out what type of proposal we are in
    function get_type() {
        global $prop_types, $bl_types, $blsr, $bcr;
        
        
        // default to use (none)
        $ty = '';
        
        $bbreq = (array)json_decode($this->app->request()->getBody());
        $request = array_merge($_REQUEST, $bbreq);

        $vis = array_key_exists('visit', $request) ? $request['visit'] : null;
        $prop = array_key_exists('prop', $request) ? $request['prop'] : null;

        if (sizeof($request) && !$this->is_assoc($request)) {
            $first = $request[0];
            if (property_exists($first, 'prop')) $prop = $first->prop;
        }

        // check if there is a visit in the address args
        if (preg_match('/([A-z]+)\d+-\d+/', $vis, $m)) {
            $bl = $this->db->pq("SELECT s.beamlinename 
                FROM blsession s 
                INNER JOIN proposal p ON p.proposalid = s.proposalid 
                WHERE CONCAT(CONCAT(CONCAT(p.proposalcode, p.proposalnumber), '-'), s.visit_number) LIKE :1", array($m[0]));
            
            if (sizeof($bl)) {
                $bl = $bl[0]['BEAMLINENAME'];
                foreach ($bl_types as $tty => $bls) {
                    if (in_array($bl, $bls)) {
                        $ty = $tty;
                        break;<commit_msg>also need to check url<commit_after><?php

class ProposalType {
    
    var $table;
    var $col;
    
    var $generic_pages = array('proposal', 'fault', 'cal', 'feedback', 'vstat', 'users');
    
    var $visit_table;
    var $session_column;
    
    var $pages = array();
    var $prop_menu = array();
    var $ext_menu =  array();
    var $ext_admin = array();
    
    var $staff = False;
    var $visits = array();
    var $sessionids = array();
    var $proposalid;
    
    var $default = '';
    var $dir = '';

    var $staff_permission = 'super_admin';
    
    function __construct($app, $db, $user) {
        $this->app = $app;
        $this->db = $db;
        $this->user = $user;

        $this->staff = $this->user->has($this->staff_permission);
    }
    
    
    // Work out what type of proposal we are in
    function get_type() {
        global $prop_types, $bl_types, $blsr, $bcr;
        
        
        // default to use (none)
        $ty = '';
        
        $bbreq = (array)json_decode($this->app->request()->getBody());
        $request = array_merge($_REQUEST, $bbreq);

        $vis = array_key_exists('visit', $request) ? $request['visit'] : null;
        $prop = array_key_exists('prop', $request) ? $request['prop'] : null;

        if (sizeof($request) && !$this->is_assoc($request)) {
            $first = $request[0];
            if (property_exists($first, 'prop')) $prop = $first->prop;
        }

        $path = $this->app->request->getResourceUri();
        if (preg_match('/\/prop\/(\w+)/', $path, $m)) $prop = $m[1];


        // check if there is a visit in the address args
        if (preg_match('/([A-z]+)\d+-\d+/', $vis, $m)) {
            $bl = $this->db->pq("SELECT s.beamlinename 
                FROM blsession s 
                INNER JOIN proposal p ON p.proposalid = s.proposalid 
                WHERE CONCAT(CONCAT(CONCAT(p.proposalcode, p.proposalnumber), '-'), s.visit_number) LIKE :1", array($m[0]));
            
            if (sizeof($bl)) {
                $bl = $bl[0]['BEAMLINENAME'];
                foreach ($bl_types as $tty => $bls) {
                    if (in_array($bl, $bls)) {
                        $ty = $tty;
                        break;
{'fraction_non_alphanumeric': 0.1687137891077636, 'fraction_numerical': 0.002085747392815759, 'mean_word_length': 1.8792528352234823, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 36, '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': '6116522', 'n_tokens_mistral': 1425, 'n_tokens_neox': 1375, 'n_words': 323}