<commit_before><?php

include 'base.php';

$q = $_GET['q'];
$t = $_GET['t'];

$_SESSION['Role'] = $q;
$_SESSION['AccessType'] = $t;
$role = $_SESSION['Role'];

echo "<meta http-equiv='refresh' content='0;/$role/Home' />";
?><commit_msg>Security for changing role (safeguard for GET method)<commit_after><?php

include 'base.php';

$params = array($_SESSION['Username']);
$options = array( "Scrollable" => SQLSRV_CURSOR_KEYSET);
$ListRolesQuery = "SELECT DISTINCT R.Role, R.Designation, R.RoleID, R.Type FROM Roles as R, RoleInstances as RI WHERE RI.SiteUsername = ? AND RI.RoleID = R.RoleID ORDER BY R.RoleID, R.Designation, R.Type";
$stmt = sqlsrv_query($con, $ListRolesQuery, $params, $options);
if( $stmt === false ) {
     die( print_r( sqlsrv_errors(), true));
}

// Make the first (and in this case, only) row of the result set available for reading.
$RolesList = [];
$Designations = [];
$AccessPriv = [];
while( sqlsrv_fetch( $stmt ) === true) {
    $RolesList[] = sqlsrv_get_field( $stmt, 0);
    $AccessPriv[] = sqlsrv_get_field( $stmt, 3);
}


$targetRole = $_GET['q'];
$targetAccessType = $_GET['t'];

$index = 0;
$valid = false;
foreach($RolesList as $ListedRole)
{
    if ($ListedRole == $targetRole)
    {
        
        if ($AccessPriv[$index] == $targetAccessType)
        {
            $valid = true;
            $_SESSION['Role'] = $targetRole;
            $_SESSION['AccessType'] = $targetAccessType;
            echo "<meta http-equiv='refresh' content='0;/$targetRole/Home' />";
        }
    }
    $index++;
}
if (!($valid))
{
    echo "<meta http-equiv='refresh' content='0;/Logout.php' />";
}


?>
{'fraction_non_alphanumeric': 0.1922365988909427, 'fraction_numerical': 0.0036968576709796672, 'mean_word_length': 3.804733727810651, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 9, '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': '1945596', 'n_tokens_mistral': 577, 'n_tokens_neox': 566, 'n_words': 134}