<commit_before><?php 

include_once( "header.php" );
include_once( "methods.php" );
include_once( "database.php" );
include_once( "ldap.php" );

$conf = $_SESSION['conf'];
$login = $_POST['username'];

// If user use @instem.ncbs.res.in or @ncbs.res.in, ignore it.
$ldap = explode( '@', $login);
$ldap = $ldap[0];

$pass = $_POST['pass'];

$_SESSION['AUTHENTICATED'] = FALSE;

/* continue */
$type = 'ncbs';
$email = <EMAIL>";
$conn = imap_open( "{imap.ncbs.res.in:993/ssl/readonly}INBOX", $ldap, $pass, OP_HALFOPEN );
if( ! $conn )
{
   $conn = imap_open( "{mail.instem.res.in:993/ssl/readonly}INBOX", $ldap, $pass, OP_HALFOPEN );
   $type = 'instem';
   $email = <EMAIL>";
}


if(!$conn) 
{
    echo printErrorSevere("FATAL : Username or password is incorrect.");
    goToPage( 'index.php', 2 );
}
else 
{
    echo printInfo( "Login successful" );
    imap_close( $conn );

    $_SESSION['AUTHENTICATED'] = TRUE;
    $_SESSION['user'] = $ldap;
    $_SESSION['email'] = $email;

    $ldapInfo = getUserInfoFromLdap( $ldap );

    // In any case, create a entry in database.
    createUserOrUpdateLogin( $ldap, $ldapInfo, $type );

    // Update email id.
    $res = updateTable( 'logins', 'login', 'email', array( 'email' => $email ));

    // If user title is unspecified then redirect him/her to edit user info
    $userInfo = getUserInfo( $ldap );
    if( $userInfo['title'] == 'UNSPECIFIED' )
    {
       echo printInfo( "Please review your details " );
       goToPage( "user_info.php", 1 );
       exit;
    }

    goToPage( "user.php", 0 );
    exit;
}
?><commit_msg>Update email from session.<commit_after><?php 

include_once( "header.php" );
include_once( "methods.php" );
include_once( "database.php" );
include_once( "ldap.php" );

$conf = $_SESSION['conf'];
$login = $_POST['username'];

// If user use @instem.ncbs.res.in or @ncbs.res.in, ignore it.
$ldap = explode( '@', $login);
$ldap = $ldap[0];

$pass = $_POST['pass'];

$_SESSION['AUTHENTICATED'] = FALSE;

/* continue */
$type = 'ncbs';
$email = <EMAIL>";
$conn = imap_open( "{imap.ncbs.res.in:993/ssl/readonly}INBOX", $ldap, $pass, OP_HALFOPEN );
if( ! $conn )
{
   $conn = imap_open( "{mail.instem.res.in:993/ssl/readonly}INBOX", $ldap, $pass, OP_HALFOPEN );
   $type = 'instem';
   $email = <EMAIL>";
}


if(!$conn) 
{
    echo printErrorSevere("FATAL : Username or password is incorrect.");
    goToPage( 'index.php', 2 );
}
else 
{
    echo printInfo( "Login successful" );
    imap_close( $conn );

    $_SESSION['AUTHENTICATED'] = TRUE;
    $_SESSION['user'] = $ldap;
    $_SESSION['email'] = $email;

    $ldapInfo = getUserInfoFromLdap( $ldap );

    // In any case, create a entry in database.
    createUserOrUpdateLogin( $ldap, $ldapInfo, $type );

    // Update email id.
    $res = updateTable( 'logins', 'login', 'email'
                , array( 'login' => $ldap, 'email' => $email )
            );

    // If user title is unspecified then redirect him/her to edit user info
    $userInfo = getUserInfo( $ldap );
    if( $userInfo['title'] == 'UNSPECIFIED' )
    {
       echo printInfo( "Please review your details " );
       goToPage( "user_info.php", 1 );
       exit;
    }

    goToPage( "user.php", 0 );
    exit;
}
?>
{'fraction_non_alphanumeric': 0.18892001244942422, 'fraction_numerical': 0.006224712107065048, 'mean_word_length': 3.343243243243243, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 12, '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': '4835498', 'n_tokens_mistral': 1224, 'n_tokens_neox': 1184, 'n_words': 275}