<commit_before><?php

function findGroup( $laboffice )
{
    if( strcasecmp( $laboffice, "faculty" ) == 0 )
        return "FACULTY";
    if( strcasecmp( $laboffice, "instem" ) == 0 )
        return "FACULTY";
    return $laboffice;
}

function serviceping($host, $port=389, $timeout=1)
{
    $op = fsockopen($host, $port, $errno, $errstr, $timeout);
    if (!$op) return 0; //DC is N/A
    else {
        fclose($op); //explicitly close open socket connection
        return 1; //DC is up & running, we can safely connect with ldap_connect
    }
}

function getUserInfoFromLdap( $ldap, $ldap_ip="ldap.ncbs.res.in" )
{
    $base_dn = 'dc=ncbs,dc=res,dc=in';
    if( 0 == serviceping( $ldap_ip, 389, 2 ) )
    {
        echo "Could not connect to LDAP server. Timeout ... ";
        return NULL;
    }

    $ds = ldap_connect($ldap_ip) or die( "Could not connect to $ldap_ip" );
    $r = ldap_bind($ds); // or die( "Can't bind to $ldap_ip" );
    if( ! $r )
    {
        echo printWarning( "LDAP binding failed. TODO: Ask user to edit details " );
        return Array( );
    }

    $sr = ldap_search($ds, $base_dn, "uid=$ldap");
    $info = ldap_get_entries($ds, $sr);

    $result = array();

    for( $s=0; $s < $info['count']; $s++)
    {
        $i = $info[$s];

        $laboffice = $i['profilelaboffice'][0];
        array_push($result
            , array(
                "fname" => $i['givenname'][0]
                , "lname" => $i['sn'][0]
                , "uid" => $i['profileidentification'][0]
                , "email" => $i['mail'][0]
                , "laboffice" => $laboffice
                //, "joined_on" => $i['profiletenureend'][0]
            )
        );
    }
    return $result[0];
}

?><commit_msg>Get joining date from ldap server.<commit_after><?php

function findGroup( $laboffice )
{
    if( strcasecmp( $laboffice, "faculty" ) == 0 )
        return "FACULTY";
    if( strcasecmp( $laboffice, "instem" ) == 0 )
        return "FACULTY";
    return $laboffice;
}

function serviceping($host, $port=389, $timeout=1)
{
    $op = fsockopen($host, $port, $errno, $errstr, $timeout);
    if (!$op) return 0; //DC is N/A
    else {
        fclose($op); //explicitly close open socket connection
        return 1; //DC is up & running, we can safely connect with ldap_connect
    }
}

function getUserInfoFromLdap( $ldap, $ldap_ip="ldap.ncbs.res.in" )
{
    $base_dn = 'dc=ncbs,dc=res,dc=in';
    if( 0 == serviceping( $ldap_ip, 389, 2 ) )
    {
        echo "Could not connect to LDAP server. Timeout ... ";
        return NULL;
    }

    $ds = ldap_connect($ldap_ip) or die( "Could not connect to $ldap_ip" );
    $r = ldap_bind($ds); // or die( "Can't bind to $ldap_ip" );
    if( ! $r )
    {
        echo printWarning( "LDAP binding failed. TODO: Ask user to edit details " );
        return Array( );
    }

    $sr = ldap_search($ds, $base_dn, "uid=$ldap");
    $info = ldap_get_entries($ds, $sr);

    $result = array();

    for( $s=0; $s < $info['count']; $s++)
    {
        $i = $info[$s];

        //var_dump( $i );
        $laboffice = $i['profilelaboffice'][0];
        array_push($result
            , array(
                "fname" => $i['givenname'][0]
                , "lname" => $i['sn'][0]
                , "uid" => $i['profileidentification'][0]
                , "email" => $i['mail'][0]
                , "laboffice" => $laboffice
                , "joined_on" => $i['profiledateofjoin'][0]
            )
        );
    }
    return $result[0];
}

?>
{'fraction_non_alphanumeric': 0.17779680365296804, 'fraction_numerical': 0.011986301369863013, 'mean_word_length': 2.1921675774134792, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, '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': '3237380', 'n_tokens_mistral': 1308, 'n_tokens_neox': 1260, 'n_words': 295}