Specifications

PA-001011-03-04 Aastra July 2014
305
# Connect to AGI
$as = new AGI_AsteriskManager();
$res = $as->connect();
# Get value in the database
$res = $as->Command('database get AMPUSER '.$user.'\/cidname');
$line=split("\n", $res['data']);
$cid=split(" ", $line[1]);
$callerid= $cid[1].' '.$cid[2];
# Disconnect properly
$as->disconnect();
}
else
{
# Retrieve the value
$value=explode(" <",$sip_array[$user]['callerid'],2);
$callerid=$value[0];
}
}
# Return Caller ID
return($callerid);
}
#####################################################################
# get_username(user)
#
# This function retrieves the username of a user in the Asterisk
# registry (FreePBX 2.3)
#
# Parameters
# @user user ID
#
# Returns
# username as a string
#####################################################################
function get_username($user)
{
Global $ASTERISK_LOCATION;
# Get all the user data
$sip_array = @parse_ini_file($ASTERISK_LOCATION."sip_additional.conf", true);
# Collect data
if($sip_array[$user]['username']!='') $username=$sip_array[$user]['username'];
else
{
# Connect to AGI
$as = new AGI_AsteriskManager();
$res = $as->connect();
# Get value in the database
$res = $as->Command('database get DEVICE '.$user.'\/user');
$line=split("\n", $res['data']);
$cid=split(" ", $line[1]);
$username= $cid[1];
# Disconnect properly
$as->disconnect();
}
# Return answer
return($username);
}
#####################################################################
# get_secret(user)
#
# This function retrieves the SIP password (secret) of a user in the
# Asterisk configuration