Qual: Removed PHPCodeSniffer errors
This commit is contained in:
parent
340fe42b79
commit
00adb9f05c
@ -38,15 +38,26 @@ if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
|
||||
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
|
||||
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
|
||||
|
||||
// C'est un wrapper, donc header vierge
|
||||
function llxHeader() {
|
||||
print '<html>'."\n";
|
||||
print '<head>'."\n";
|
||||
print '<title>Asterisk redirection from Dolibarr...</title>'."\n";
|
||||
print '</head>'."\n";
|
||||
/**
|
||||
* Empty header
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
function llxHeader()
|
||||
{
|
||||
print '<html>'."\n";
|
||||
print '<head>'."\n";
|
||||
print '<title>Asterisk redirection from Dolibarr...</title>'."\n";
|
||||
print '</head>'."\n";
|
||||
}
|
||||
function llxFooter() {
|
||||
print "\n".'</html>'."\n";
|
||||
/**
|
||||
* Empty footer
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
function llxFooter()
|
||||
{
|
||||
print "\n".'</html>'."\n";
|
||||
}
|
||||
|
||||
require_once("../main.inc.php");
|
||||
@ -75,23 +86,23 @@ $password = $_GET['password'];
|
||||
$caller = $_GET['caller'];
|
||||
$called = $_GET['called'];
|
||||
|
||||
# IP address of Asterisk server
|
||||
// IP address of Asterisk server
|
||||
$strHost = $conf->global->ASTERISK_HOST;
|
||||
#Spécifiez le type d'extension par laquelle vous poste est connecte.
|
||||
#ex: SIP/, IAX2/, ZAP/, etc
|
||||
// Spécifiez le type d'extension par laquelle vous poste est connecte.
|
||||
// ex: SIP/, IAX2/, ZAP/, etc
|
||||
$channel = $conf->global->ASTERISK_TYPE;
|
||||
#Indicatif de la ligne sortante
|
||||
// Indicatif de la ligne sortante
|
||||
$prefix = $conf->global->ASTERISK_INDICATIF;
|
||||
#Port
|
||||
// Port
|
||||
$port = $conf->global->ASTERISK_PORT;
|
||||
#Context ( generalement from-internal )
|
||||
// Context ( generalement from-internal )
|
||||
$strContext = "from-internal";
|
||||
|
||||
#Delai d'attente avant de raccrocher
|
||||
// Delai d'attente avant de raccrocher
|
||||
$strWaitTime = "30";
|
||||
#Priority
|
||||
// Priority
|
||||
$strPriority = "1";
|
||||
#Nomber of try
|
||||
// Nomber of try
|
||||
$strMaxRetry = "2";
|
||||
|
||||
|
||||
@ -101,49 +112,50 @@ $strMaxRetry = "2";
|
||||
|
||||
llxHeader();
|
||||
|
||||
$number=strtolower($called) ;
|
||||
$pos=strpos ($number,"local");
|
||||
$number=strtolower($called);
|
||||
$pos=strpos($number,"local");
|
||||
if (! empty($number))
|
||||
{
|
||||
if ($pos===false) :
|
||||
$errno=0 ;
|
||||
$errstr=0 ;
|
||||
$strCallerId = "Dolibarr <".strtolower($caller).">" ;
|
||||
$oSocket = @fsockopen ($strHost, $port, $errno, $errstr, 10) ;
|
||||
if (!$oSocket)
|
||||
{
|
||||
print '<body>'."\n";
|
||||
$txt="Failed to execute fsockopen($strHost, $port, \$errno, \$errstr, 10)<br>\n";
|
||||
print $txt;
|
||||
dol_syslog($txt,LOG_ERR);
|
||||
$txt=$errstr." (".$errno.")<br>\n";
|
||||
print $txt;
|
||||
dol_syslog($txt,LOG_ERR);
|
||||
print '</body>'."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$txt="Call Asterisk dialer for caller: ".$caller.", called: ".$called." clicktodiallogin: ".$login;
|
||||
dol_syslog($txt);
|
||||
print '<body onload="javascript:history.go(-1);">'."\n";
|
||||
print '<!-- '.$txt.' -->';
|
||||
fputs($oSocket, "Action: login\r\n" ) ;
|
||||
fputs($oSocket, "Events: off\r\n" ) ;
|
||||
fputs($oSocket, "Username: $login\r\n" ) ;
|
||||
fputs($oSocket, "Secret: $password\r\n\r\n" ) ;
|
||||
fputs($oSocket, "Action: originate\r\n" ) ;
|
||||
fputs($oSocket, "Channel: ".$channel.$caller."\r\n" ) ;
|
||||
fputs($oSocket, "WaitTime: $strWaitTime\r\n" ) ;
|
||||
fputs($oSocket, "CallerId: $strCallerId\r\n" ) ;
|
||||
fputs($oSocket, "Exten: ".$prefix.$number."\r\n" ) ;
|
||||
fputs($oSocket, "Context: $strContext\r\n" ) ;
|
||||
fputs($oSocket, "Priority: $strPriority\r\n\r\n" ) ;
|
||||
fputs($oSocket, "Action: Logoff\r\n\r\n" ) ;
|
||||
sleep(2) ;
|
||||
fclose($oSocket) ;
|
||||
print '</body>'."\n";
|
||||
}
|
||||
endif ;
|
||||
if ($pos===false)
|
||||
{
|
||||
$errno=0;
|
||||
$errstr=0;
|
||||
$strCallerId = "Dolibarr <".strtolower($caller).">";
|
||||
$oSocket = @fsockopen($strHost, $port, $errno, $errstr, 10);
|
||||
if (!$oSocket)
|
||||
{
|
||||
print '<body>'."\n";
|
||||
$txt="Failed to execute fsockopen($strHost, $port, \$errno, \$errstr, 10)<br>\n";
|
||||
print $txt;
|
||||
dol_syslog($txt,LOG_ERR);
|
||||
$txt=$errstr." (".$errno.")<br>\n";
|
||||
print $txt;
|
||||
dol_syslog($txt,LOG_ERR);
|
||||
print '</body>'."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$txt="Call Asterisk dialer for caller: ".$caller.", called: ".$called." clicktodiallogin: ".$login;
|
||||
dol_syslog($txt);
|
||||
print '<body onload="javascript:history.go(-1);">'."\n";
|
||||
print '<!-- '.$txt.' -->';
|
||||
fputs($oSocket, "Action: login\r\n");
|
||||
fputs($oSocket, "Events: off\r\n");
|
||||
fputs($oSocket, "Username: $login\r\n");
|
||||
fputs($oSocket, "Secret: $password\r\n\r\n");
|
||||
fputs($oSocket, "Action: originate\r\n");
|
||||
fputs($oSocket, "Channel: ".$channel.$caller."\r\n");
|
||||
fputs($oSocket, "WaitTime: $strWaitTime\r\n");
|
||||
fputs($oSocket, "CallerId: $strCallerId\r\n");
|
||||
fputs($oSocket, "Exten: ".$prefix.$number."\r\n");
|
||||
fputs($oSocket, "Context: $strContext\r\n");
|
||||
fputs($oSocket, "Priority: $strPriority\r\n\r\n");
|
||||
fputs($oSocket, "Action: Logoff\r\n\r\n");
|
||||
sleep(2);
|
||||
fclose($oSocket);
|
||||
print '</body>'."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
print 'Bad parameters in URL. Must be '.$_SERVER['PHP_SELF'].'?caller=99999&called=99999&login=xxxxx&password=xxxxx';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user