-
Notifications
You must be signed in to change notification settings - Fork 3
/
kabook-ipaddress.php
55 lines (39 loc) · 1.82 KB
/
kabook-ipaddress.php
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/php -q
<?php
require('libs/config/defines.php');
require('libs/phpagi/phpagi.php');
//Create a new AGI Class
$agi = new AGI();
//Username Details Catcher
$uniqueid = $agi->request['agi_uniqueid'];
$userURI = $agi->get_variable("SIPURI",true);
$userURI = explode("@", $userURI);
$userURI = explode(":", $userURI[1]);
$userIPURI = $userURI[0];
$sipusercontact = $agi->get_variable("SIP_HEADER(Contact)",true);
$sipusercontact = explode("@", $sipusercontact);
$sipusercontact = explode(":", $sipusercontact[1]);
$sipusercontact = $sipusercontact[0];
$sipusername = $agi->get_variable("SIP_HEADER(From)",true);
$sipusername = explode(":",$sipusername);
$sipusername = explode("@",$sipusername[1]);
$trunkUsername = $sipusername[0];
$trunkIPAddress = explode(">",$sipusername[1]);
$trunkIPAddress = $trunkIPAddress[0];
//Get account code
$callerid = $agi->request['agi_accountcode'];
if($callerid == ''){ $callerid = $agi->request['agi_rdnis']; }
if($callerid == 'BY_CALLER_ID'){ $callerid = $agi->request['agi_callerid']; }
sendLog("############################################################################################", $agi);
sendLog("########## [$uniqueid] <$trunkUsername> URI IP <$userIPURI>", $agi);
sendLog("########## [$uniqueid] <$trunkUsername> IP FROM CONTACT HEADER <$sipusercontact>", $agi);
sendLog("########## [$uniqueid] <$trunkUsername> IP FROM FROM HEADER: $trunkIPAddress", $agi);
$agi->exec("SIPAddHeader","X-Client-Address:$userIPURI");
sendLog("############################################################################################", $agi);
exit();
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function sendLog($message, $agi) {
if(DEBUG) syslog(LOG_INFO, "< KABOOK - AUTH > - $message");
if(DEBUG) $agi->noop($message);
}
?>