From 00adb9f05c0462ad6eb03b3549c3d9f1c7d10634 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 28 Aug 2011 01:54:20 +0000 Subject: [PATCH] Qual: Removed PHPCodeSniffer errors --- htdocs/asterisk/wrapper.php | 128 ++++++++++++++++++++---------------- 1 file changed, 70 insertions(+), 58 deletions(-) diff --git a/htdocs/asterisk/wrapper.php b/htdocs/asterisk/wrapper.php index 33a9b7dfbe0..8332843f5e7 100644 --- a/htdocs/asterisk/wrapper.php +++ b/htdocs/asterisk/wrapper.php @@ -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 ''."\n"; - print ''."\n"; - print 'Asterisk redirection from Dolibarr...'."\n"; - print ''."\n"; +/** + * Empty header + * + * @return none + */ +function llxHeader() +{ + print ''."\n"; + print ''."\n"; + print 'Asterisk redirection from Dolibarr...'."\n"; + print ''."\n"; } -function llxFooter() { - print "\n".''."\n"; +/** + * Empty footer + * + * @return none + */ +function llxFooter() +{ + print "\n".''."\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 ''."\n"; - $txt="Failed to execute fsockopen($strHost, $port, \$errno, \$errstr, 10)
\n"; - print $txt; - dol_syslog($txt,LOG_ERR); - $txt=$errstr." (".$errno.")
\n"; - print $txt; - dol_syslog($txt,LOG_ERR); - print ''."\n"; - } - else - { - $txt="Call Asterisk dialer for caller: ".$caller.", called: ".$called." clicktodiallogin: ".$login; - dol_syslog($txt); - print ''."\n"; - print ''; - 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 ''."\n"; - } - endif ; + if ($pos===false) + { + $errno=0; + $errstr=0; + $strCallerId = "Dolibarr <".strtolower($caller).">"; + $oSocket = @fsockopen($strHost, $port, $errno, $errstr, 10); + if (!$oSocket) + { + print ''."\n"; + $txt="Failed to execute fsockopen($strHost, $port, \$errno, \$errstr, 10)
\n"; + print $txt; + dol_syslog($txt,LOG_ERR); + $txt=$errstr." (".$errno.")
\n"; + print $txt; + dol_syslog($txt,LOG_ERR); + print ''."\n"; + } + else + { + $txt="Call Asterisk dialer for caller: ".$caller.", called: ".$called." clicktodiallogin: ".$login; + dol_syslog($txt); + print ''."\n"; + print ''; + 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 ''."\n"; + } + } } else { print 'Bad parameters in URL. Must be '.$_SERVER['PHP_SELF'].'?caller=99999&called=99999&login=xxxxx&password=xxxxx';