Fix: Asterisk redirect fails

This commit is contained in:
Laurent Destailleur 2010-07-26 23:50:09 +00:00
parent 2637707760
commit 3fab2d962f
4 changed files with 55 additions and 40 deletions

View File

@ -30,15 +30,23 @@
* write = system,call,log,verbose,command,agent,user
*/
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1');
if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1');
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1');
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
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";
}
require_once("../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/functions.lib.php");
@ -46,13 +54,20 @@ require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
// Security check
// TODO Enable and test if module Asterisk is enabled
if (! $conf->clicktodial->enabled)
{
accessforbidden();
exit;
}
$conf->global->ASTERISK_HOST="127.0.0.1";
$conf->global->ASTERISK_TYPE="SIP/";
$conf->global->ASTERISK_INDICATIF="0";
$conf->global->ASTERISK_PORT=5038;
// Define Asterisk setup
if (! isset($conf->global->ASTERISK_HOST)) $conf->global->ASTERISK_HOST="127.0.0.1";
if (! isset($conf->global->ASTERISK_TYPE)) $conf->global->ASTERISK_TYPE="SIP/";
if (! isset($conf->global->ASTERISK_INDICATIF)) $conf->global->ASTERISK_INDICATIF="0";
if (! isset($conf->global->ASTERISK_HOST)) $conf->global->ASTERISK_PORT=5038;
if ($conf->global->ASTERISK_INDICATIF=='NONE') $conf->global->ASTERISK_INDICATIF='';
$login = $_GET['login'];
$password = $_GET['password'];
@ -61,41 +76,29 @@ $called = $_GET['called'];
# Adresse IP du serveur Asterisk
$strHost = $conf->global->ASTERISK_HOST;
#Context ( generalement from-internal )
$strContext = "from-internal";
#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
$prefix = $conf->global->ASTERISK_INDICATIF;
#Port
$port = $conf->global->ASTERISK_PORT;
#Context ( generalement from-internal )
$strContext = "from-internal";
#Delai d'attente avant de raccrocher
$strWaitTime = "30";
#Priority
$strPriority = "1";
#Nomber of try
$strMaxRetry = "2";
#Indicatif de la ligne sortante
$prefix = $conf->global->ASTERISK_INDICATIF;
#Port
$port = $conf->global->ASTERISK_PORT;
/*
* View
*/
print '<html>'."\n";
print '<head>'."\n";
print '<title>Asterisk redirection from Dolibarr...</title>'."\n";
print '</head>'."\n";
llxHeader();
$number=strtolower($called) ;
$pos=strpos ($number,"local");
@ -141,5 +144,8 @@ if (! empty($number))
}
endif ;
}
else {
print 'Bad parameters in URL. Must be http://MYDOLIBARR/asterisk/wrapper.php?caller=99999&called=99999&login=xxxxx&password=xxxxx';
}
print '</html>'."\n";

View File

@ -81,10 +81,12 @@ class modClickToDial extends DolibarrModules
$this->rights_class = 'clicktodial';
}
/**
* \brief Fonction appel<EFBFBD>e lors de l'activation du module. Ins<EFBFBD>re en base les constantes, boites, permissions du module.
* D<EFBFBD>finit <EFBFBD>galement les r<EFBFBD>pertoires de donn<EFBFBD>es <EFBFBD> cr<EFBFBD>er pour ce module.
*/
/**
* \brief Function called when module is enabled.
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
* It also creates data directories.
* \return int 1 if OK, 0 if KO
*/
function init()
{
global $conf;
@ -94,10 +96,12 @@ class modClickToDial extends DolibarrModules
return $this->_init($sql);
}
/**
* \brief Fonction appel<EFBFBD>e lors de la d<EFBFBD>sactivation d'un module.
* Supprime de la base les constantes, boites et permissions du module.
*/
/**
* \brief Function called when module is disabled.
* Remove from database constants, boxes and permissions from Dolibarr database.
* Data directories are not deleted.
* \return int 1 if OK, 0 if KO
*/
function remove()
{
$sql = array();

View File

@ -27,7 +27,7 @@
/**
* \brief Show Dolibarr default login page
* \param langs Lang object
* \param langs Lang object (must be initialized by a new).
* \param conf Conf object
* \param mysoc Company object
*/
@ -76,7 +76,7 @@ function dol_loginfunction($langs,$conf,$mysoc)
}
}
$conf->css = "/theme/".$conf->theme."/style.css.php?lang=".$langs->defaultlang;
$conf->css = "/theme/".$conf->theme."/style.css.php?lang=".$langs->defaultlang;
$conf_css = DOL_URL_ROOT.$conf->css;
// Set cookie for timeout management

View File

@ -395,6 +395,11 @@ if (! defined('NOLOGIN'))
{
// We show login page
include_once(DOL_DOCUMENT_ROOT."/lib/security.lib.php");
if (! is_object($langs)) // This can occurs when calling page with NOREQUIRETRAN defined
{
include_once(DOL_DOCUMENT_ROOT."/core/class/translate.class.php");
$langs=new Translate("",$conf);
}
dol_loginfunction($langs,$conf,$mysoc);
exit;
}