Menu

[r13]: / trunk / examples / my_ip.php  Maximize  Restore  History

Download this file

33 lines (29 with data), 721 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
function my_ip(&$agi, $peer)
{
$ip = 'unknown';
$asm = $agi->new_AsteriskManager();
if($asm->connect())
{
$peer = $asm->command("sip show peer $peer");
$asm->disconnect();
if(!strpos($peer['data'], ':'))
echo $peer['data'];
else
{
$data = array();
foreach(explode("\n", $peer['data']) as $line)
{
$a = strpos('z'.$line, ':') - 1;
if($a >= 0) $data[trim(substr($line, 0, $a))] = trim(substr($line, $a + 1));
}
}
if(isset($data['Addr->IP']))
{
$ip = explode(' ', trim($data['Addr->IP']));
$ip = $ip[0];
}
}
$agi->text2wav("Your IP address is $ip");
}
?>
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.