I've added a custom column in my subscriber table in MySQL - called country_code.
This contains +44 etc. for subscribers.
Is it possible to, if a subscriber has not entered either + or 00, to append the value from country_code of the specific subscriber to the dialled number?
And if the user has dialled 00, to replace it with +.
On Tuesday 01 September 2015 13:45:16 Michael Nielsen wrote:
Is it possible to, if a subscriber has not entered either + or 00, to append the value from country_code of the specific subscriber to the dialled number?
And if the user has dialled 00, to replace it with +.
Offcourse that is possible, in folowwing example src_areacode is taken from usr_preferences and a no country code pattern is hardcoded to the Netherlands prefix.
if($rU=~"^[2-8][0-9]+$") { if($avp(src_areacode)=~"^+?[0-9]+$") { $rU=$avp(src_areacode)+$rU; }
}
if($rU=~"^00[1-9][0-9]+$") { strip(2); prefix("+"); }
if($rU=~"^0[1-9][0-9]+$") { strip(1); prefix("+31"); }
Perfect, thank you. It works - I'm not using your areacode in my code.
If I want to load a user specific country code, using avp, how can I do this?
I've added kamctl avp add MY-SUBSCRIBER countrycode 0 +44, so +44 is added to usr_preferences.
But calling $avp(countrycode) doesn't seem to give me +44?
Thank you once again.
On Tue, Sep 1, 2015 at 3:59 PM, Daniel Tryba d.tryba@pocos.nl wrote:
On Tuesday 01 September 2015 13:45:16 Michael Nielsen wrote:
Is it possible to, if a subscriber has not entered either + or 00, to append the value from country_code of the specific subscriber to the dialled number?
And if the user has dialled 00, to replace it with +.
Offcourse that is possible, in folowwing example src_areacode is taken from usr_preferences and a no country code pattern is hardcoded to the Netherlands prefix.
if($rU=~"^[2-8][0-9]+$") { if($avp(src_areacode)=~"^\+?[0-9]+$") { $rU=$avp(src_areacode)+$rU; } } if($rU=~"^00[1-9][0-9]+$") { strip(2); prefix("+"); } if($rU=~"^0[1-9][0-9]+$") { strip(1); prefix("+31"); }
On Tuesday 01 September 2015 16:43:42 Michael Nielsen wrote:
If I want to load a user specific country code, using avp, how can I do this?
I've added kamctl avp add MY-SUBSCRIBER countrycode 0 +44, so +44 is added to usr_preferences.
But calling $avp(countrycode) doesn't seem to give me +44?
There is more than one way to do it, but I choose to load the usr_preferences into avps after authentication with avp_db_query (to have a fixed number of queries per call at the expense of memory).
//auth if(avp_db_query("SELECT replace(replace(concat('src_',attribute),'.','_'),'-','_'),value FROM usr_preferences WHERE username='$avp(au)' and domain='$fd' and length(value) > 0")) { while($avp(i:1)!=$null) { $avp($avp(i:1)[*])=$null; $avp($avp(i:1))=$avp(i:2);
$avp(i:1)=$null; $avp(i:2)=$null; } }
What if I just want to lookup the country code IF the country code is not set. Then queries to MySQL for this would only be made in the cases where the subscriber do not type in + or 00?
I've tried to look at avpops which apparently uses the usr_preferences as standard - but without any luck...
On Tuesday, September 1, 2015, Daniel Tryba d.tryba@pocos.nl wrote:
On Tuesday 01 September 2015 16:43:42 Michael Nielsen wrote:
If I want to load a user specific country code, using avp, how can I do this?
I've added kamctl avp add MY-SUBSCRIBER countrycode 0 +44, so +44 is
added
to usr_preferences.
But calling $avp(countrycode) doesn't seem to give me +44?
There is more than one way to do it, but I choose to load the usr_preferences into avps after authentication with avp_db_query (to have a fixed number of queries per call at the expense of memory).
//auth if(avp_db_query("SELECT replace(replace(concat('src_',attribute),'.','_'),'-','_'),value FROM usr_preferences WHERE username='$avp(au)' and domain='$fd' and length(value) > 0")) { while($avp(i:1)!=$null) { $avp($avp(i:1)[*])=$null; $avp($avp(i:1))=$avp(i:2);
$avp(i:1)=$null; $avp(i:2)=$null; } }
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org javascript:; http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
On Tuesday 01 September 2015 17:37:36 Michael Nielsen wrote:
What if I just want to lookup the country code IF the country code is not set. Then queries to MySQL for this would only be made in the cases where the subscriber do not type in + or 00?
if(!$rU!="^(+|00)")
I've tried to look at avpops which apparently uses the usr_preferences as standard - but without any luck...
Should work, start by debugging the queries made when you call the avp* functions.
As alternative, if you need the country code for caller only, then look at load_credentials parameter for auth_db module. If you add the country code in the subscriber table, it will be loaded from database whent he authentication is done (i.e., in the same query with the password).
Cheers, Daniel
On 01/09/15 17:37, Michael Nielsen wrote:
What if I just want to lookup the country code IF the country code is not set. Then queries to MySQL for this would only be made in the cases where the subscriber do not type in + or 00?
I've tried to look at avpops which apparently uses the usr_preferences as standard - but without any luck...
On Tuesday, September 1, 2015, Daniel Tryba <d.tryba@pocos.nl mailto:d.tryba@pocos.nl> wrote:
On Tuesday 01 September 2015 16:43:42 Michael Nielsen wrote: > If I want to load a user specific country code, using avp, how can I do > this? > > I've added kamctl avp add MY-SUBSCRIBER countrycode 0 +44, so +44 is added > to usr_preferences. > > But calling $avp(countrycode) doesn't seem to give me +44? There is more than one way to do it, but I choose to load the usr_preferences into avps after authentication with avp_db_query (to have a fixed number of queries per call at the expense of memory). //auth if(avp_db_query("SELECT replace(replace(concat('src_',attribute),'.','_'),'-','_'),value FROM usr_preferences WHERE username='$avp(au)' and domain='$fd' and length(value) > 0")) { while($avp(i:1)!=$null) { $avp($avp(i:1)[*])=$null; $avp($avp(i:1))=$avp(i:2); $avp(i:1)=$null; $avp(i:2)=$null; } } _______________________________________________ SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org <javascript:;> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
Oh, I see... This should be what I was looking for. Thanx
On Wed, Sep 2, 2015 at 9:14 AM, Daniel-Constantin Mierla miconda@gmail.com wrote:
As alternative, if you need the country code for caller only, then look at load_credentials parameter for auth_db module. If you add the country code in the subscriber table, it will be loaded from database whent he authentication is done (i.e., in the same query with the password).
Cheers, Daniel
On 01/09/15 17:37, Michael Nielsen wrote:
What if I just want to lookup the country code IF the country code is not set. Then queries to MySQL for this would only be made in the cases where the subscriber do not type in + or 00?
I've tried to look at avpops which apparently uses the usr_preferences as standard - but without any luck...
On Tuesday, September 1, 2015, Daniel Tryba d.tryba@pocos.nl wrote:
On Tuesday 01 September 2015 16:43:42 Michael Nielsen wrote:
If I want to load a user specific country code, using avp, how can I do this?
I've added kamctl avp add MY-SUBSCRIBER countrycode 0 +44, so +44 is
added
to usr_preferences.
But calling $avp(countrycode) doesn't seem to give me +44?
There is more than one way to do it, but I choose to load the usr_preferences into avps after authentication with avp_db_query (to have a fixed number of queries per call at the expense of memory).
//auth if(avp_db_query("SELECT replace(replace(concat('src_',attribute),'.','_'),'-','_'),value FROM usr_preferences WHERE username='$avp(au)' and domain='$fd' and length(value) > 0")) { while($avp(i:1)!=$null) { $avp($avp(i:1)[*])=$null; $avp($avp(i:1))=$avp(i:2);
$avp(i:1)=$null; $avp(i:2)=$null; } }
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing listsr-users@lists.sip-router.orghttp://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
-- Daniel-Constantin Mierlahttp://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda Book: SIP Routing With Kamailio - http://www.asipto.com
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users