Register active: Difference between revisions
Jump to navigation
Jump to search
(Created page with "=How to list all active registrations from single IP using the API= == Usage == Following register_active.php script will print detail about all registrations done from single...") |
No edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
=How to list all active registrations from single IP using the API= | =How to list all active registrations from single IP using the API= | ||
following example requires to have managerip and managerport set to 127.0.0.1 5029 (by default) | |||
==example for searching using username== | |||
username is abcdefg | |||
echo 'listregisters {"zip":"no","limit":30,"states":"OK","filter":{"digestusername":"abcdefg"},"sort_field":"calldate","sort_dir":"desc"}'|nc 127.0.0.1 5029 | |||
==example for searching using callerIP and username== | |||
usernamce is abcdefg, ip is 1.2.3.4 | |||
echo 'listregisters {"zip":"no","limit":30,"states":"OK","filter":{"sipcallerip":"192.168.88.209","sipcallerdip_type":1,"numFTC_type":0,"domainFTC_type":0,"domainFTC_group_id_type":0,"digestusername":"11"},"sort_field":"calldate","sort_dir":"desc"}'|nc 127.0.0.1 5029 | |||
== Usage of listregister manager command without arguments == | |||
Following register_active.php script will get detail about all ACTIVE registrations done via managerapi, and then its filtered for records from single IP. | |||
example for use: | example for use: | ||
active_register.php "192.168.43.212" | active_register.php "192.168.43.212" | ||
== Script == | === Script active_register.php === | ||
<?php | <?php | ||
if (!array_key_exists ("1",$argv)) exit; #ensure argument passed | if (!array_key_exists ("1",$argv)) exit; #ensure argument passed | ||
Line 14: | Line 25: | ||
exec("echo 'listregisters' | nc 127.0.0.1 5029",$retstr,$rt); | exec("echo 'listregisters' | nc 127.0.0.1 5029",$retstr,$rt); | ||
$data=json_decode($retstr[0]); | $data=json_decode($retstr[0]); | ||
if (!array_key_exists (" | if (!array_key_exists ("2",$data)) exit; #ensure some active register(s) in list | ||
$regkeys=$data[0]; | $regkeys=$data[0]; | ||
Line 21: | Line 32: | ||
foreach ($reglist as $n=>$item) { | foreach ($reglist as $n=>$item) { | ||
if ($item[$sipcallerip_key] == $searchVal) var_dump($item); | if ($item[$sipcallerip_key] == $searchVal) var_dump($item); | ||
} | } | ||
?> | ?> |
Latest revision as of 15:32, 25 August 2021
How to list all active registrations from single IP using the API
following example requires to have managerip and managerport set to 127.0.0.1 5029 (by default)
example for searching using username
username is abcdefg
echo 'listregisters {"zip":"no","limit":30,"states":"OK","filter":{"digestusername":"abcdefg"},"sort_field":"calldate","sort_dir":"desc"}'|nc 127.0.0.1 5029
example for searching using callerIP and username
usernamce is abcdefg, ip is 1.2.3.4
echo 'listregisters {"zip":"no","limit":30,"states":"OK","filter":{"sipcallerip":"192.168.88.209","sipcallerdip_type":1,"numFTC_type":0,"domainFTC_type":0,"domainFTC_group_id_type":0,"digestusername":"11"},"sort_field":"calldate","sort_dir":"desc"}'|nc 127.0.0.1 5029
Usage of listregister manager command without arguments
Following register_active.php script will get detail about all ACTIVE registrations done via managerapi, and then its filtered for records from single IP. example for use:
active_register.php "192.168.43.212"
Script active_register.php
<?php if (!array_key_exists ("1",$argv)) exit; #ensure argument passed $searchVal=ip2long($argv[1]); exec("echo 'listregisters' | nc 127.0.0.1 5029",$retstr,$rt); $data=json_decode($retstr[0]); if (!array_key_exists ("2",$data)) exit; #ensure some active register(s) in list $regkeys=$data[0]; $sipcallerip_key=(array_search("sipcallerip",$regkeys)); $reglist=$data; array_shift($reglist); array_shift($reglist); #skip two items at begin foreach ($reglist as $n=>$item) { if ($item[$sipcallerip_key] == $searchVal) var_dump($item); } ?>