31if (!defined(
'NOREQUIRESOC')) {
32 define(
'NOREQUIRESOC',
'1');
34if (!defined(
'NOREQUIRETRAN')) {
35 define(
'NOREQUIRETRAN',
'1');
37if (!defined(
'NOTOKENRENEWAL')) {
38 define(
'NOTOKENRENEWAL',
'1');
40if (!defined(
'NOREQUIREMENU')) {
41 define(
'NOREQUIREMENU',
'1');
43if (!defined(
'NOREQUIREHTML')) {
44 define(
'NOREQUIREHTML',
'1');
46if (!defined(
'NOREQUIREAJAX')) {
47 define(
'NOREQUIREAJAX',
'1');
70function llxHeader($head =
'', $title =
'', $help_url =
'', $target =
'', $disablejs = 0, $disablehead = 0, $arrayofjs =
'', $arrayofcss =
'', $morequerystring =
'', $morecssonbody =
'', $replacemainareaby =
'', $disablenofollow = 0, $disablenoindex = 0)
74 print
'<title>Asterisk redirection from Dolibarr...</title>'.
"\n";
86function llxFooter($comment =
'', $zone =
'private', $disabledoutputofmessages = 0)
88 print
"\n".
'</html>'.
"\n";
91require_once
'../main.inc.php';
92require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions.lib.php';
93require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
97if (!isModEnabled(
'clicktodial')) {
105 $conf->global->ASTERISK_HOST =
"127.0.0.1";
108 $conf->global->ASTERISK_TYPE =
"SIP/";
111 $conf->global->ASTERISK_INDICATIF =
"0";
114 $conf->global->ASTERISK_PORT = 5038;
117 $conf->global->ASTERISK_INDICATIF =
'';
120 $conf->global->ASTERISK_CONTEXT =
"from-internal";
123 $conf->global->ASTERISK_WAIT_TIME =
"30";
126 $conf->global->ASTERISK_PRIORITY =
"1";
129 $conf->global->ASTERISK_MAX_RETRY =
"2";
133$login =
GETPOST(
'login',
'alphanohtml');
134$password =
GETPOST(
'password',
'password');
135$caller =
GETPOST(
'caller',
'alphanohtml');
136$called =
GETPOST(
'called',
'alphanohtml');
139$login = preg_replace(
'/[\n\r]/',
'', $login);
140$password = preg_replace(
'/[\n\r]/',
'', $password);
141$caller = preg_replace(
'/[\n\r]/',
'', $caller);
142$called = preg_replace(
'/[\n\r]/',
'', $called);
174llxHeader(
'',
'',
'',
'', 0, 0,
'',
'',
'',
'mod-asterisk page-wrapper');
176$sql =
"SELECT s.nom as name FROM ".MAIN_DB_PREFIX.
"societe as s";
177$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"socpeople as sp ON sp.fk_soc = s.rowid";
178$sql .=
" WHERE s.entity IN (".getEntity(
'societe').
")";
179$sql .=
" AND (s.phone='".$db->escape($called).
"'";
180$sql .=
" OR sp.phone='".$db->escape($called).
"'";
181$sql .=
" OR sp.phone_perso='".$db->escape($called).
"'";
182$sql .=
" OR sp.phone_mobile='".$db->escape($called).
"')";
183$sql .= $db->plimit(1);
185dol_syslog(
'click to dial search information with phone '.$called, LOG_DEBUG);
186$resql = $db->query($sql);
188 $obj = $db->fetch_object($resql);
192 $found =
'Not found';
200$number = strtolower($called);
201$pos = strpos($number,
"local");
202if (!empty($number)) {
203 if ($pos ===
false) {
206 $strCallerId =
"Dolibarr caller $found <".strtolower($number).
">";
207 $oSocket = @fsockopen($strHost, (
int) $port, $errno, $errstr, 10);
210 $txt =
"Failed to execute fsockopen($strHost, $port, \$errno, \$errstr, 10)<br>\n";
213 $txt = $errstr.
" (".$errno.
")<br>\n";
216 print
'</body>'.
"\n";
218 $txt =
"Call Asterisk dialer for caller: ".$caller.
", called: ".$called.
" clicktodiallogin: ".$login;
220 print
'<body onload="history.go(-1);">'.
"\n";
221 print
'<!-- '.$txt.
' -->';
222 fwrite($oSocket,
"Action: login\r\n");
223 fwrite($oSocket,
"Events: off\r\n");
224 fwrite($oSocket,
"Username: $login\r\n");
225 fwrite($oSocket,
"Secret: $password\r\n\r\n");
226 fwrite($oSocket,
"Action: originate\r\n");
227 fwrite($oSocket,
"Channel: ".$channel.$caller.
"\r\n");
228 fwrite($oSocket,
"WaitTime: $strWaitTime\r\n");
229 fwrite($oSocket,
"CallerId: $strCallerId\r\n");
230 fwrite($oSocket,
"Exten: ".$prefix.$number.
"\r\n");
231 fwrite($oSocket,
"Context: $strContext\r\n");
232 fwrite($oSocket,
"Priority: $strPriority\r\n\r\n");
233 fwrite($oSocket,
"Action: Logoff\r\n\r\n");
236 print
'</body>'.
"\n";
240 print
'Bad parameters in URL. Must be '.dol_escape_htmltag($_SERVER[
'PHP_SELF']).
'?caller=99999&called=99999&login=xxxxx&password=xxxxx';
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.