From 93faf2bcf455591a06aa8a95a96e82142b2770d0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 1 Jul 2010 22:54:09 +0000 Subject: [PATCH] Add Asterisk lookup callerid --- htdocs/asterisk/cidlookup.php | 44 +++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 htdocs/asterisk/cidlookup.php diff --git a/htdocs/asterisk/cidlookup.php b/htdocs/asterisk/cidlookup.php new file mode 100644 index 00000000000..e64b061c89f --- /dev/null +++ b/htdocs/asterisk/cidlookup.php @@ -0,0 +1,44 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** + * \file htdocs/asterisk/cidlookup.php + * \brief Script to search companies names based on incoming calls + * \remarks To use this script, your Asterisk must be compiled with CURL, + * and your dialplan must be something like this: + * + * exten => s,1,Set(CALLERID(name)=${CURL(http://IP-DOLIBARR:80/asterisk/cidlookup.php?phone=${CALLERID(num)})}) + * + * Change IP-DOLIBARR to the IP address of your dolibarr + * server + * + */ + +// TODO Use dolibarr database driver instead of hard coded mysql functions +$phone = $_GET['phone']; +include("../conf/conf.php"); +$link = mysql_connect($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass); +$base = mysql_select_db($dolibarr_main_db_name,$link); +$sql = "select nom from llx_societe s left join llx_socpeople sp on sp.fk_soc=s.rowid where s.tel='$phone' or phone='$phone' or phone_perso='$phone' or phone_mobile='$phone' limit 1"; +$result = mysql_query($sql); +$row = mysql_fetch_assoc($result); +$found = $row['nom']; +mysql_free_result($result); +echo $found; + +?>