<commit_before><?php

if (!defined('LEGACY2_APP')) {
    die();
}

ini_set('display_errors',0);

/* configuration variables */

// number of rows per page shown in listings
$list_rows_per_page = 20;

// title of the site
$site_title = 'Yet Another Example Legacy Application';

// ...

/* eof configuration variables */

// import some more configuration variables
require_once('includes/configuration.php');

// get current file
$current_file = basename($_SERVER['SCRIPT_NAME']);

// include used classes
require_once('includes/classes/session.php');
require_once('includes/classes/DB.php');

// start session
$sess = new session;
$sess->start();

// instanciate database handling object
$db = new Db();

// include functions
require_once('includes/functions.php');

// define filename constants
define('FILENAME_LOGIN',    'login.php');
define('FILENAME_HOME',     'index.php');
define('FILENAME_USER',     'user.php');
define('FILENAME_DIRS',     'dirs.php');
// ...

// defines which files users are allowed to access
// full_access and limit_access are arrays containing the user levels that have access to that file
$file_access = array(FILENAME_HOME => array('full_access'  => array(1, 3, 4),
                                            'limit_access' => array(5)),
                     FILENAME_USER => array('full_access'  => array(1, 3, 4),
                                            'limit_access' => array(5)),
                     FILENAME_DIRS => array('full_access'  => array(1, 3, 4),
                                            'limit_access' => array(5)),
);

// construct html header tags
$content_type = '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
$page_title   = '<title>' . $site_title . '</title>';

// if not in login page check access
if ($current_file != FILENAME_LOGIN) {
    // if not logged in or doesn't have access
    if (!isset($_SESSION['user_level'])
        || (!in_array($_SESSION['user_level'], $file_access[$current_file]['full_access'])
            && !in_array($_SESSION['user_level'], $file_access[$current_file]['limit_access'])))
    {
        redirect(FILENAME_LOGIN);
        die('Unauthorized');
    }
}

// start output buffering
#ob_start('ob_callback');
ob_start();

// output page header<commit_msg>Disable notices etc. in legacy app (to prevent Symfony error handler to capture them and convert to exception) + get correct current file name + set some vars as globals<commit_after><?php

if (!defined('LEGACY2_APP')) {
    die();
}

error_reporting(E_ERROR);
ini_set('display_errors',0);

/* configuration variables */

// number of rows per page shown in listings
$list_rows_per_page = 20;

// title of the site
$site_title = 'Yet Another Example Legacy Application';

// ...

/* eof configuration variables */

// import some more configuration variables
require_once('includes/configuration.php');

// get current file
global $current_file;
$current_file = basename(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));

// include used classes
require_once('includes/classes/session.php');
require_once('includes/classes/DB.php');

// start session
$sess = new session;
$sess->start();

// instanciate database handling object
$db = new Db();

// include functions
require_once('includes/functions.php');

// define filename constants
define('FILENAME_LOGIN',    'login.php');
define('FILENAME_HOME',     'index.php');
define('FILENAME_USER',     'user.php');
define('FILENAME_DIRS',     'dirs.php');
// ...

// defines which files users are allowed to access
// full_access and limit_access are arrays containing the user levels that have access to that file
global $file_access;
$file_access = array(FILENAME_HOME => array('full_access'  => array(1, 3, 4),
                                            'limit_access' => array(5)),
                     FILENAME_USER => array('full_access'  => array(1, 3, 4),
                                            'limit_access' => array(5)),
                     FILENAME_DIRS => array('full_access'  => array(1, 3, 4),
                                            'limit_access' => array(5)),
);

// construct html header tags
$content_type = '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
$page_title   = '<title>' . $site_title . '</title>';

// if not in login page check access
if ($current_file != FILENAME_LOGIN) {
    // if not logged in or doesn't have access
    if (!isset($_SESSION['user_level'])
        || (!in_array($_SESSION['user_level'], $file_access[$current_file]['full_access'])
            && !in_array($_SESSION['user_level'], $file_access[$current_file]['limit_access'])))
    {
        redirect(FILENAME_LOGIN);
        die('Unauthorized');
    }
}

// start output buffering
#ob_start('ob_callback');
ob_start();

// output page header
{'fraction_non_alphanumeric': 0.14781704781704783, 'fraction_numerical': 0.007068607068607069, 'mean_word_length': 3.187119234116623, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3279694', 'n_tokens_mistral': 1428, 'n_tokens_neox': 1366, 'n_words': 362}