';
+
+global $dolibarr_main_url_root;
+
+// Define $urlwithroot
+$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
+$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
+//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
+
+// Url for CIDLookup
+//print '
';
@@ -156,6 +188,23 @@ if (!empty($conf->global->CLICKTODIAL_URL)) {
}
}
+if (!empty($conf->use_javascript_ajax)) {
+ print "\n".'';
+}
+
// End of page
llxFooter();
$db->close();
diff --git a/htdocs/cron/admin/cron.php b/htdocs/cron/admin/cron.php
index 28078242dc6..ff413a8a1c2 100644
--- a/htdocs/cron/admin/cron.php
+++ b/htdocs/cron/admin/cron.php
@@ -133,15 +133,16 @@ if (!empty($conf->use_javascript_ajax)) {
print "\n".'';
}
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index 698ade8b8d1..fa6fa693bb0 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -2278,3 +2278,4 @@ INVOICE_ADD_SWISS_QR_CODE=Show the swiss QR-Bill code on invoices
UrlSocialNetworksDesc=Url link of social network. Use {socialid} for the variable part that contains the social network ID.
IfThisCategoryIsChildOfAnother=If this category is a child of another one
NoName=No name
+CIDLookupURL=The module brings an URL that can be used by an external tool to get the name of a thirdparty or contact from its phone number. URL to use is:
\ No newline at end of file
diff --git a/htdocs/asterisk/cidlookup.php b/htdocs/public/clicktodial/cidlookup.php
similarity index 71%
rename from htdocs/asterisk/cidlookup.php
rename to htdocs/public/clicktodial/cidlookup.php
index 716057198f8..3ec7024855d 100644
--- a/htdocs/asterisk/cidlookup.php
+++ b/htdocs/public/clicktodial/cidlookup.php
@@ -16,20 +16,45 @@
*/
/**
- * \file htdocs/asterisk/cidlookup.php
+ * \file htdocs/public/clicktodial/cidlookup.php
* \brief Script to search companies names based on incoming calls, from caller phone number
- * \remarks To use this script, your Asterisk must be compiled with CURL,
- * and your dialplan must be something like this:
+ * \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)})})
+ * exten => s,1,Set(CALLERID(name)=${CURL(http://IP-DOLIBARR:80/asterisk/cidlookup.php?phone=${CALLERID(num)}&securitykey=SECURITYKEY)})
*
* Change IP-DOLIBARR to the IP address of your dolibarr server
+ * Change SECURITYKEY to the value defined into your setup of module ClickToDial
*/
+if (!defined('NOTOKENRENEWAL')) {
+ define('NOTOKENRENEWAL', '1'); // Disables token renewal
+}
+if (!defined('NOREQUIREMENU')) {
+ define('NOREQUIREMENU', '1');
+}
+if (!defined('NOREQUIREHTML')) {
+ define('NOREQUIREHTML', '1');
+}
+if (!defined('NOREQUIREAJAX')) {
+ define('NOREQUIREAJAX', '1');
+}
+if (!defined('NOLOGIN')) {
+ define('NOLOGIN', '1');
+}
+if (!defined('NOIPCHECK')) {
+ define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
+}
-include '../master.inc.php';
+// So log file will have a suffix
+if (!defined('USESUFFIXINLOG')) {
+ define('USESUFFIXINLOG', '_cidlookup');
+}
+
+include '../../main.inc.php';
$phone = GETPOST('phone');
+$securitykey = GETPOST('securitykey');
+
$notfound = $langs->trans("Unknown");
// Security check
@@ -38,12 +63,27 @@ if (empty($conf->clicktodial->enabled)) {
exit;
}
+
+/*
+ * View
+ */
+
+if (empty($securitykey)) {
+ echo 'Securitykey is required. Check setup of clicktodial module.';
+ exit;
+}
+if ($securitykey != getDolGlobalString('CLICKTODIAL_KEY_FOR_CIDLOOKUP')) {
+ echo 'Securitykey is wrong.';
+ exit;
+}
+
// Check parameters
if (empty($phone)) {
print "Error: Url must be called with parameter phone=phone to search\n";
exit;
}
+
$sql = "SELECT s.nom as name FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON sp.fk_soc = s.rowid";
$sql .= " WHERE s.entity IN (".getEntity('societe').")";
diff --git a/htdocs/public/cron/cron_run_jobs_by_url.php b/htdocs/public/cron/cron_run_jobs_by_url.php
index 8aa910a2d4f..fea2a2d7f82 100644
--- a/htdocs/public/cron/cron_run_jobs_by_url.php
+++ b/htdocs/public/cron/cron_run_jobs_by_url.php
@@ -93,7 +93,7 @@ if (empty($key)) {
echo 'Securitykey is required. Check setup of cron jobs module.';
exit;
}
-if ($key != $conf->global->CRON_KEY) {
+if ($key != getDolGlobalString('CRON_KEY')) {
echo 'Securitykey is wrong.';
exit;
}