S
S
SteepNET2019-05-27 16:52:09
PHP
SteepNET, 2019-05-27 16:52:09

Parsing black_list Asterisk?

Good afternoon!
Please help me to parse
the Asterisk database and add the
script
. database queries - $res = myQuery($sql, true);
You can execute commands in Asterisk, from a script and parse the response - exec('asterisk -rx "database show" | grep blacklist', $res);
The task is to parse the numbers and put them into the $black_list variable. It
should turn out something like:
$black_list = array('+79999999999' , '+7888888888');

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2019-05-27
@Rsa97

preg_match_all('/\/([+0-9])+\s:/', `asterisk -rx "database show" | grep blacklist`, $matches);
$black_list = $matches[1];

If the numbers are always 12 characters long, including the plus, then you can
preg_match_all('/[+0-9]{12}/', `asterisk -rx "database show" | grep blacklist`, $black_list);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question