Revize 8d0578dc
Přidáno uživatelem Filip Miškařík před více než 4 roky(ů)
application/controllers/web_interface.php | ||
---|---|---|
echo implode("\n", $items)."\n";
|
||
}
|
||
|
||
/**
|
||
* Function is used for VoIP callback.
|
||
*
|
||
* @see http://www.voip-info.org/wiki/index.php?page=Asterisk+Manager+API+Action+Originate
|
||
* @param integer $user
|
||
* @param string $pass
|
||
* @param integer $number
|
||
*/
|
||
public function voip_callback($user = null, $pass = null, $number = null)
|
||
{
|
||
// only enabled if IP address that requested for this page is from
|
||
// one of allowed ranges in the FreenetIS
|
||
if (!network::ip_address_in_ranges(server::remote_addr()))
|
||
{
|
||
@header('HTTP/1.0 403 Forbidden');
|
||
die();
|
||
}
|
||
|
||
// VoIP is not enabled, quit
|
||
if (!Settings::get('voip_enabled'))
|
||
return;
|
||
|
||
if ($user == null || $pass == null || $number == null)
|
||
{
|
||
die('No input data');
|
||
}
|
||
|
||
if (!valid::digit($user) || !valid::digit($number))
|
||
{
|
||
die('Not valid input data');
|
||
}
|
||
|
||
$voip = ORM::factory('voip_sip')->get_voip_sip_by_name($user);
|
||
|
||
if (count($voip) == 0 || $voip->current()->secret != $pass)
|
||
{
|
||
die('Bad user or password');
|
||
}
|
||
else
|
||
{
|
||
$asm = new AsteriskManager();
|
||
|
||
$ahostname = Settings::get('voip_asterisk_hostname');
|
||
$auser = Settings::get('voip_asterisk_user');
|
||
$apass = Settings::get('voip_asterisk_pass');
|
||
|
||
if (empty($ahostname) || empty($auser) || empty($apass))
|
||
{
|
||
die('Error. Check FreenetIS settings.');
|
||
}
|
||
|
||
if ($asm->connect($ahostname, $auser, $apass))
|
||
{
|
||
$asm->Originate(
|
||
'SIP/' . $user, $number, 'internal', 1,
|
||
NULL, NULL, 30000, $user, NULL, NULL, 'Async', NULL
|
||
);
|
||
$asm->disconnect();
|
||
echo 'Success';
|
||
}
|
||
else
|
||
{
|
||
die('Error. Could not connect to server.');
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Generates authorized keys to device
|
||
*
|
Také k dispozici: Unified diff
refs #1135: lBilling, voip, voip sip deleted. All relations for this controllers and models deleted.