Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Merge 2.2.5 into master #67

Merged
merged 17 commits into from

3 participants

@tm1000
Owner

Mainly moving connectwise.

All in favor say 'I'

@ukstevef

Why not wrap the result with trim e.g. value = trim($row["name"]);
Then lower down strlen and trim would be consistent.

@ukstevef
Collaborator

Added to list for v3.x source migrations - see #42

lgaetz Checks status of 'cache results' in Caller ID Lookup sources and warn…
…s if enabled. Permits 'cache results' to be changed from within the scheme config. This commit has a text box in scheme config but it needs to be changed to a checkbox.
43ea99e
@ukstevef
Collaborator

To set a check box you could use
<input type="checkbox" name="cache" value="Use Cache" checked>

If conf was a check box control, you could test document.forms.Superfecta.conf.checked

@lgaetz

The problem is in this line (262), I have tried every which way, but the only thing I can get a checkbox to do is reflect the status of 'cache results', I can't get changes to the checkbox to save.

Collaborator

The form is doing a post back to itself.
If you add the checkbox you should see cache=off in the post variables inside function Ht_Generate_List

Owner

With javascript, I am way out of my comfort zone and I my efforts are not working. Can someone spruce up line 262 to make this work then it should be good for testing.

Collaborator

OK, after a bit of debugging it looks like checkbox values are not posted if they are empty.
You can prove this by putting

{
print("<h2>Posted data - start</h2>");
var_dump($_POST);
print("<h2>Posted data - end</h2>");
}```

This will dump all the post variables, try saving the form with the checkbox set, and you will see it.

I added the checkbox locally with
```<td><input type="checkbox" name="cache" onclick="toggleCache(this);" value="off"></td>

You can then check isset($_POST['cache']) and then issue your SQL.

the javascript function toggleCache has
function toggleCache(ctlCache)
{
if(ctlCache.checked)
{
ctlCache.value = 'on';
}
else
{
ctlCache.value = 'off';
}
}

Collaborator

Having slept on this, the solution is easier.
Add the checkbox with a default value of on and if the cache is on set the checked attribute of the checkbox.
You do not need the javascript, when looking at the post data the value will only be there if it is on.

@tm1000
Owner

Nevermind I was wrong

@lgaetz
Owner

I did a bit of last minute testing and it looks good to me. I vote AYE!

@tm1000 tm1000 merged commit a6d7676 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 28, 2011
  1. Fixed regexp's. Works for residential and business doesn't work well …

    lgaetz authored
    …for multiple business results.
Commits on Sep 1, 2011
Commits on Oct 28, 2011
  1. Updated to include leads in search

    lgaetz authored
  2. Use DID as CNAM - preliminary 80% complete

    Lorne Gaetz authored
  3. Ready for testing. Not sure if it is a good idea to set the $prefix v…

    Lorne Gaetz authored
    …ariable, comments?
Commits on Nov 7, 2011
  1. New lookup source for Dominican Republic

    lgaetz authored
Commits on Nov 8, 2011
  1. Revised to include Dominican NPA codes

    Lorne Gaetz authored
Commits on Nov 23, 2011
  1. Incorporates Mageminds' changes.

    Lorne Gaetz authored
Commits on Dec 7, 2011
  1. Reverse lookup for Austria, needs testing

    Lorne Gaetz authored
Commits on Jan 10, 2012
  1. Checks status of 'cache results' in Caller ID Lookup sources and warn…

    lgaetz authored
    …s if enabled. Permits 'cache results' to be changed from within the scheme config. This commit has a text box in scheme config but it needs to be changed to a checkbox.
Commits on Feb 2, 2012
Commits on Mar 8, 2012
  1. Add user checkbox to discard CNAM if it is_numeric

    Lorne Gaetz authored
Commits on Mar 14, 2012
  1. Initial commit

    Lorne Gaetz authored
  2. Minor cleanup and bug fix

    Lorne Gaetz authored
Commits on Mar 21, 2012
  1. Added revision note for earlier fixes

    Lorne Gaetz authored
This page is out of date. Refresh to see the latest.
View
46 bin/source-AsteriDex.php
@@ -1,10 +1,9 @@
<?php
//this file is designed to be used as an include that is part of a loop.
-//If a valid match is found, it should give $caller_id a value
+//If a valid match is found, it will give $caller_id a value
//available variables for use are: $thenumber
//retreive website contents using get_url_contents($url);
-//configuration / display parameters
//The description cannot contain "a" tags, but can contain limited HTML. Some HTML (like the a tags) will break the UI.
$source_desc = "Searches an AsteriDex Database - local or remote.";
$source_param['DB_Host']['desc'] = 'Host address of the Asteridex database. (localhost if the database is on the same server as FreePBX)';
@@ -16,15 +15,12 @@
$source_param['DB_User']['desc'] = 'Username used to connect to the Asteridex database';
$source_param['DB_User']['type'] = 'text';
$source_param['DB_User']['default'] = 'root';
-//$source_param['DB_User']['default'] = $dsn[username];
$source_param['DB_Password']['desc'] = 'Password used to connect to the Asteridex database';
$source_param['DB_Password']['type'] = 'password';
$source_param['DB_Password']['default'] = 'passw0rd';
-//$source_param['DB_Password']['default'] = $dsn[password];
-$source_param['Filter_Length']['desc'] = 'The number of rightmost digits to check for a match';
+$source_param['Filter_Length']['desc'] = 'The number of rightmost digits to check for a match. Enter the word false to disable this setting';
$source_param['Filter_Length']['type'] = 'number';
$source_param['Filter_Length']['default'] = 10;
-//$dbname = "asteridex";
//run this if the script is running in the "get caller id" usage mode.
if($usage_mode == 'get caller id')
@@ -34,31 +30,47 @@
print "Searching AsteriDex ... ";
}
+ // Initialize variables
$value = "";
- $wquery_input = preg_replace("/\D/","",$thenumber); // strip non-digits
- if(strlen($wquery_input) == 0) exit; // abandon search if no number is passed
- if (strlen($wquery_input) > $run_param['Filter_Length']) $wquery_input = substr($wquery_input, -$run_param['Filter_Length']); // keep only the filter_length rightmost digits
-//include_once("/var/www/html/asteridex4/config.inc.php");
+ $wquery_input = $thenumber;
+
+ // check if user wants to use filter length
+ if ($run_param['Filter_Length'] != false)
+ {
+ // keep only the filter_length rightmost digits
+ if (strlen($wquery_input) > $run_param['Filter_Length']) $wquery_input = substr($wquery_input, -$run_param['Filter_Length']);
+ }
+
$link = mysql_connect($run_param['DB_Host'], $run_param['DB_User'], $run_param['DB_Password'])or die("AsteriDex connection failed:". $run_param['DB_Host']);
-// $link = mysql_connect($dsn[hostspec], "root", "passw0rd")or die("AsteriDex connection failed");
mysql_select_db($run_param['DB_Name']) or die("AsteriDex data base open failed");
-// mysql_select_db($dbname) or die("AsteriDex data base open failed");
- $query = "SELECT * FROM `user1` where RIGHT(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(`out`,' ',''),'+',''),'-',''),'(',''),')','')," . $run_param['Filter_Length'] . ") LIKE ".$wquery_input;
-// $query = "SELECT * FROM `user1` where RIGHT(`out`,".$run_param['Filter_Length'] . ") LIKE ".$wquery_input;
+
+ // Build regular expression from the number to avoid non-digit characters stored in database
+ $wquery = "'[^0-9]*";
+ for( $x=0; $x < ((strlen($wquery_input))-1); $x++ )
+ {
+ $wquery .= substr($wquery_input,$x,1)."[^0-9]*" ;
+ }
+ $wquery = $wquery.(substr($wquery_input,-1))."([^0-9]+|$)'";
+
+ // query database
+ $query = "SELECT * FROM `user1` where `out` REGEXP ".$wquery;
$result = mysql_query($query) or die("AsteriDex query failed: $query");
+
+ // Get first name if any results are returned from query
if (mysql_num_rows($result)>0)
{
$row = mysql_fetch_array($result);
$value = $row["name"];
}
- mysql_close($link);
+
+ mysql_close($link); // close link to database
+
if(strlen($value) > 0)
{
- $caller_id = $value;
+ $caller_id = trim($value);
}
else if($debug)
{
print "not found<br>\n";
}
}
-?>
View
33 bin/source-CanPagesCa.php
@@ -1,9 +1,9 @@
<?php
//this file is designed to be used as an include that is part of a loop.
-//If a valid match is found, it should give $caller_id a value
+//If a valid match is found, it will give $caller_id a value
//available variables for use are: $thenumber
//retreive website contents using get_url_contents($url);
-// This data sourcescript provided by Francois Allard (francois.allard@mageminds.com) 5/11/09
+//Revised November 23, 2011
//configuration / display parameters
//The description cannot contain "a" tags, but can contain limited HTML. Some HTML (like the a tags) will break the UI.
@@ -48,14 +48,14 @@
if (substr($thenumber,0,4) == '0111')
{
$thenumber = substr($thenumber,4);
- }
+ }
else
{
$number_error = true;
}
}
- }
+ }
// number
if(strlen($thenumber) < 10)
{
@@ -67,10 +67,12 @@
{
$thenumber = (substr($thenumber,0,1) == 1) ? substr($thenumber,1) : $thenumber;
$npa = substr($thenumber,0,3);
+ $nxx = substr($thenumber,3,3);
+ $station = substr($thenumber,6,4);
// Check for valid CAN NPA
$npalistCAN = array(
- "204", "226", "249", "250", "289", "306", "343", "365", "403", "416", "418", "438",
+ "204", "226", "249", "250", "289", "306", "343", "365", "403", "416", "418", "438",
"450", "506", "514", "519", "579", "581", "587", "604", "613", "647",
"705", "709", "778", "780", "807", "819", "867", "873", "902", "905",
"800", "866", "877", "888"
@@ -99,7 +101,7 @@
// Set the url we're searching for
$url="http://www.canpages.ca/rl/index.jsp?fi=Search&lang=0&val=$thenumber";
$value = get_url_contents($url);
-
+
// Patterns to search for
$regexp = array(
"/class=\"header_listing\">(.+)<\/a>/", // Residential match
@@ -121,7 +123,23 @@
// If we found a match, return it
if(strlen($name) > 1)
{
- $caller_id = $name;
+ if($pattern == "/style=\"font-size: 13px\">(.+)<\/a>/")
+ {
+ $caller_id = $name;
+ }
+ else // we are testing the residential result further
+ {
+ $pattern = "/res\/".$thenumber."\/(.+)\//";
+ preg_match($pattern, $value, $match);
+ if(isset($match[1]))
+ {
+ $caller_id = $name;
+ }
+ else if($debug)
+ {
+ print "not found<br>\n";
+ }
+ }
}
else if($debug)
{
@@ -129,4 +147,3 @@
}
}
}
-?>
View
213 bin/source-ConnectWise.php
@@ -0,0 +1,213 @@
+<?php
+//this file is designed to be used as an include that is part of a loop.
+//If a valid match is found, it will give $caller_id a value
+//available variables for use are: $thenumber
+
+/* Revision History */
+// v0.1.0: Initial Release Version by myitguy
+// v0.1.1: Minor bug fix by bushbomb
+// v0.1.2: More bug fixes id'd by bushbomb
+
+//configuration / display parameters
+//The description cannot contain "a" tags, but can contain limited HTML. Some HTML (like the a tags) will break the UI.
+$source_desc = "Look up data in your ConnectWise CRM, local or remote.<br>Fill in the appropriate ConnectWise configuration information to make the connection to the ConnectWise database.";
+$source_param = array();
+$source_param['DB_Site']['desc'] = 'ConnectWise Site URL not including the initial https://';
+$source_param['DB_Site']['type'] = 'text';
+
+$source_param['DB_Company']['desc'] = 'ConnectWise Company ID';
+$source_param['DB_Company']['type'] = 'text';
+
+$source_param['DB_User']['desc'] = 'Integration Username to connect to ConnectWise. This ID should have access to the Company, Contact and Reporting APIs';
+$source_param['DB_User']['type'] = 'text';
+
+$source_param['DB_Password']['desc'] = 'Integration Password to connect to ConnectWise';
+$source_param['DB_Password']['type'] = 'password';
+
+$source_param['Search_Type']['desc'] = 'The ConnectWise type of entries that should be used to match the number';
+$source_param['Search_Type']['type'] = 'select';
+$source_param['Search_Type']['option'][1] = 'Companies Only';
+$source_param['Search_Type']['option'][2] = 'Contacts Only';
+$source_param['Search_Type']['option'][3] = 'Companies --> Contacts';
+$source_param['Search_Type']['default'] = 3;
+$source_param['Filter_Length']['desc'] = 'The number of rightmost digits to check for a match. Enter false to disable this setting';
+$source_param['Filter_Length']['type']='number';
+$source_param['Filter_Length']['default']= 10;
+
+
+//run this if the script is running in the "get caller id" usage mode.
+if($usage_mode == 'get caller id')
+{
+$integration_site = $run_param['DB_Site'];
+$integration_company = $run_param['DB_Company'];
+$integration_user = $run_param['DB_User'];
+$integration_password = $run_param['DB_Password'];
+$varSearchType = $run_param['Search_Type'];
+
+ if($debug)
+ {
+ print "Searching ConnectWise ... <br>";
+ }
+
+ $wquery_input = "";
+ $wquery_string = "";
+ $wquery_result = "";
+ $wresult_caller_name = "";
+
+ if ($run_param['Filter_Length'] != false)
+ {
+ if (strlen($wquery_input) > $run_param['Filter_Length']) $wquery_input = substr($wquery_input, -$run_param['Filter_Length']); // keep only the filter_length rightmost digits
+ }
+
+
+ // Search Companies
+ if($run_param['Search_Type'] == 1 || $run_param['Search_Type'] == 3)
+ {
+ if($debug)
+ {
+ print "Searching Companies ... ";
+ }
+
+ $integration_xml = <<<EOT
+ <FindPartnerCompaniesAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <CompanyName>$integration_company</CompanyName>
+ <IntegrationLoginId>$integration_user</IntegrationLoginId>
+ <IntegrationPassword>$integration_password</IntegrationPassword>
+ <Conditions>PhoneNumber like "$thenumber"</Conditions>
+ <OrderBy>CompanyID</OrderBy>
+ <Limit>1</Limit>
+ </FindPartnerCompaniesAction>
+EOT;
+
+ // Order of replacement
+ $order = array("\r\n", "\n", "\r");
+ $replace = '';
+
+ // Processes \r\n's first so they aren't converted twice.
+ $integration_xml = str_replace($order, $replace, $integration_xml);
+
+ $url="https://$integration_site/v4_6_release/services/system_io/integration_io.asmx/ProcessClientAction?actionString=".urlencode($integration_xml);
+ //$value = get_url_contents($url);
+ $ch = curl_init();
+ $timeout = 5; // set to zero for no timeout
+ curl_setopt ($ch, CURLOPT_URL, $url);
+ curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
+ $value = htmlspecialchars_decode(curl_exec($ch));
+ curl_close($ch);
+
+ $pattern = "/<CompanyName>(.*?)<\/CompanyName>/";
+ preg_match_all($pattern, $value, $matches);
+ if (count($matches[0])>1) {
+ $wresult_caller_name = $matches[0][1];
+// print $wresult_caller_name;
+ }
+ else if($debug)
+ {
+ print "not found<br>\n";
+ }
+ }
+
+
+
+
+
+
+ // Search Contacts
+
+ if($run_param['Search_Type'] == 2 || $run_param['Search_Type'] == 3 && $wresult_caller_name =="")
+ {
+ if($debug)
+ {
+ print "Searching Contacts ... ";
+ }
+
+ $integration_xml = <<<EOT
+ <RunReportQueryAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <CompanyName>$integration_company</CompanyName>
+ <IntegrationLoginId>$integration_user</IntegrationLoginId>
+ <IntegrationPassword>$integration_password</IntegrationPassword>
+ <ReportName>ContactCommunication</ReportName>
+ <Conditions>Contact_Communication_Desc like "$thenumber"</Conditions>
+ <Limit>1</Limit>
+ </RunReportQueryAction>
+EOT;
+
+ // Order of replacement
+ $order = array("\r\n", "\n", "\r");
+ $replace = '';
+
+ // Processes \r\n's first so they aren't converted twice.
+ $integration_xml = str_replace($order, $replace, $integration_xml);
+
+ $url="https://$integration_site/v4_6_release/services/system_io/integration_io.asmx/ProcessClientAction?actionString=".urlencode($integration_xml);
+ //$value = get_url_contents($url);
+ $ch = curl_init();
+ $timeout = 5; // set to zero for no timeout
+ curl_setopt ($ch, CURLOPT_URL, $url);
+ curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
+ $value = htmlspecialchars_decode(curl_exec($ch));
+ curl_close($ch);
+
+ $pattern = '/<Value Name="Contact_RecID" Type="Numeric" IsNullable="false">(.*?)<\/Value>/';
+ preg_match($pattern, $value, $match_ContactID);
+ if (count($match_ContactID)>0){
+ $integration_xml = <<<EOT
+ <FindPartnerContactsAction xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <CompanyName>$integration_company</CompanyName>
+ <IntegrationLoginId>$integration_user</IntegrationLoginId>
+ <IntegrationPassword>$integration_password</IntegrationPassword>
+ <Conditions>ContactRecID = $match_ContactID[1]</Conditions>
+ <OrderBy>LastName</OrderBy>
+ <Limit>10</Limit>
+ </FindPartnerContactsAction>
+EOT;
+ // Order of replacement
+ $order = array("\r\n", "\n", "\r");
+ $replace = '';
+
+ // Processes \r\n's first so they aren't converted twice.
+ $integration_xml = str_replace($order, $replace, $integration_xml);
+
+ $url="https://$integration_site/v4_6_release/services/system_io/integration_io.asmx/ProcessClientAction?actionString=".urlencode($integration_xml);
+ //$value = get_url_contents($url);
+ $ch = curl_init();
+ $timeout = 5; // set to zero for no timeout
+ curl_setopt ($ch, CURLOPT_URL, $url);
+ curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
+ $value = htmlspecialchars_decode(curl_exec($ch));
+ curl_close($ch);
+
+ $pattern = "/<LastName>(.*?)<\/LastName>/";
+ preg_match($pattern, $value, $match_LastName);
+
+ $pattern = "/<FirstName>(.*?)<\/FirstName>/";
+ preg_match($pattern, $value, $match_FirstName);
+ if (count($match_LastName)>0 && count($match_FirstName)>0) {
+ $wresult_caller_name = $match_FirstName[1]." ".$match_LastName[1];
+// print $wresult_caller_name;
+ }
+ else if($debug)
+ {
+ print "not found<br>\n";
+ }
+ }
+ }
+
+ if($debug)
+ {
+ print "<br>Result: ";
+ }
+
+
+ if(strlen($wresult_caller_name) > 0)
+ {
+ $caller_id = strip_tags($wresult_caller_name);
+ }
+ else if($debug)
+ {
+ print "not found<br>\n";
+ }
+}
View
97 bin/source-DID_Prefix.php
@@ -0,0 +1,97 @@
+<?php
+//this file is designed to be used as an include that is part of a loop.
+//If a valid match is found, it will give $caller_id a value
+//available variables for use are: $thenumber, $thenumber_orig
+//Based largely on trunk provided lookup source
+//Created, October 28, 2011
+
+//configuration / display parameters
+//The description cannot contain "a" tags, but can contain limited HTML. Some HTML (like the a tags) will break the UI.
+$source_desc = "Locates the DID provided by the trunk, and then uses all or some of those digits as a prefix for the Caller ID Name. This lookup source requires Superfecta Module version 2.2.1 or higher.";
+$source_param = array();
+$source_param['Filter_Length']['desc'] = 'Number of rightmost digits of returned DID to use for the Caller ID Name or Prefix. Enter false to disable';
+$source_param['Filter_Length']['type'] = 'number';
+$source_param['Filter_Length']['default'] = 10;
+$source_param['Use_Prefix']['desc'] = 'If enabled, the returned DID digits will be used as a prefix to the Caller ID name.';
+$source_param['Use_Prefix']['type'] = 'checkbox';
+$source_param['Use_Prefix']['default'] = "on";
+
+//run this if the script is running in the "get caller id" usage mode.
+if($usage_mode == 'get caller id')
+{
+ if($debug)
+ {
+ print "Looking for Trunk Provided DID ... ";
+ }
+
+ $provided_did = '';
+
+ //get the DID for this call using the PHP Asterisk Manager
+ //first get a list of the active channels and return the first one that matches the caller id value set.
+ $value = $astman->command('core show channels concise');
+ $chan_array = preg_split("/\n/",$value['data']);
+ foreach($chan_array as $val)
+ {
+ $this_chan_array = explode("!",$val);
+ if(isset($this_chan_array[7]))
+ {
+ if ($thenumber_orig == $this_chan_array[7])
+ {
+ $value = $astman->command('core show channel '.$this_chan_array[0]);
+ $this_array = preg_split("/\n/",$value['data']);
+ foreach($this_array as $val2)
+ {
+ if(strpos($val2,'DNID Digits: ') !== false)
+ {
+ $provided_did = trim(str_replace('DNID Digits: ','',$val2));
+ break;
+ }
+ }
+
+ //break out if the value is set.
+ if($provided_did != '')
+ {
+ break;
+ }
+ }
+ }
+ }
+
+ // if there is no DID for the call, asterisk will return (N/A) check for this case and reset
+ if ($provided_did == '(N/A)')
+ {
+ $provided_did = '';
+ }
+
+ if($debug && ($provided_did == ''))
+ {
+ print "not found<br>\n";
+ }
+ else if($provided_did != '')
+ {
+ if($debug)
+ {
+ print "found DID of $provided_did ... ";
+ }
+
+ // check if user wants has set the filter length
+ if ($run_param['Filter_Length'] != false)
+ {
+ // keep only the filter_length rightmost digits
+ if (strlen($provided_did) > $run_param['Filter_Length']) $provided_did = substr($provided_did, -$run_param['Filter_Length']);
+ }
+
+
+ // neet to set $caller_id or CNAM prefix depending on user input
+ if ($run_param['Use_Prefix'] == "on")
+ {
+ // Not sure the following line is a good idea, it works but may interfere with superfecta operation
+ $prefix = $provided_did;
+ }
+ else
+ {
+ $caller_id = $provided_did;
+ }
+
+ }
+}
View
71 bin/source-Gevonden_NL.php
@@ -0,0 +1,71 @@
+<?php
+//this file is designed to be used as an include that is part of a loop.
+//If a valid match is found, it should give $caller_id a value
+//available variables for use are: $thenumber
+//retreive website contents using get_url_contents($url);
+
+//configuration / display parameters
+//The description cannot contain "a" tags, but can contain limited HTML. Some HTML (like the a tags) will break the UI.
+$source_desc = "http://www.gevonden.cc - This source includes business and residential data for The Netherlands<br><br>This data source requires Superfecta Module version 2.2.3 or higher.";
+$source_param = array();
+
+
+//run this if the script is running in the "get caller id" usage mode.
+if($usage_mode == 'get caller id')
+{
+ if($debug)
+ {
+ print 'Searching Gevonden.cc...<br> ';
+ }
+ //NL 10
+
+ $loc_number = $thenumber;
+ $adddecode= false;
+
+ // Test for NL
+ if (strlen($loc_number) > 10)
+ {
+ if (substr($loc_number,0,2)=='31')
+ {
+ $loc_number = '0'.substr($loc_number,2);
+ }
+ else if (substr($loc_number,0,4)=='0031')
+ {
+ $loc_number = '0'.substr($loc_number,4);
+ }
+ else if (substr($loc_number,0,5)=='01131')
+ {
+ $loc_number = '0'.substr($loc_number,5);
+ }
+
+ }
+
+ if (strlen($loc_number) == 10)
+ {
+ $url = "http://www.gevonden.cc/telefoonnummer/" . $thenumber . "/lastname/";
+ $sresult = get_url_contents($url);
+
+ $expr = '=<title[^>]*>(.*)[0-9]{5,}</title>=siU';
+ preg_match_all($expr, $sresult, $sname);
+ if (count($sname[1]) > 0)
+ {
+ $sname = trim($sname[1][0]);
+ }
+ else
+ {
+ $sname = "";
+ }
+
+ if ($sname != "")
+ {
+ $caller_id = strip_tags($sname);
+ }
+ else if($debug)
+ {
+ print "not found<br>\n";
+ }
+ } else if($debug)
+ {
+ print "only for the netherlands !!<br>\n";
+ }
+}
View
61 bin/source-Herold_Austria.php
@@ -0,0 +1,61 @@
+<?php
+//this file is designed to be used as an include that is part of a loop.
+//If a valid match is found, it will give $caller_id a value
+//available variables for use are: $thenumber
+//retreive website contents using get_url_contents($url);
+//Created December 7,2011 by lgaetz
+
+//configuration / display parameters
+//The description cannot contain "a" tags, but can contain limited HTML. Some HTML (like the a tags) will break the UI.
+$source_desc = "http://www.herold.at/ - These listings include data for Austriaa.<br><br>This data source requires Superfecta Module version 2.2.1 or higher.";
+
+
+//run this if the script is running in the "get caller id" usage mode.
+if($usage_mode == 'get caller id')
+{
+ $value = "";
+ $number_error = false;
+
+ if($debug)
+ {
+ print "Searching http://www.herold.at/ ... ";
+ }
+
+ //all number checking removed, Austria numbering conventions are not straightforward,
+
+ // Set the url we're searching for valid as of December 7, 2011
+ $url="http://www.herold.at/en/gelbe-seiten/telefon_".$thenumber."/";
+
+ $value = get_url_contents($url);
+
+ // Patterns to search for
+ $regexp = array(
+// "/<span title=\"Siehe Karte Position A\">A<\/span><\/div><\/td><td><h2><a href=.*\/\">(.*)<\/a><\/h2>/",
+ "/<span title=\"Siehe Karte Position A\">A.*\">(.*)<\/a><\/h2>/",
+ );
+
+ // By default, there is no match
+ $name = "";
+
+ // Look through each pattern to see if we find a match -- take the first match
+ foreach ($regexp as $pattern)
+ {
+ preg_match($pattern, $value, $match);
+ if(isset($match[1]) && (strlen(trim(strip_tags($match[1])))))
+ {
+ $name = trim(strip_tags($match[1]));
+ break;
+ }
+ }
+
+ // If we found a match, return it
+ if(strlen($name) > 1)
+ {
+ $caller_id = $name;
+ }
+ else if($debug)
+ {
+ print "not found<br>\n";
+ }
+
+}
View
100 bin/source-Paginasamarillas_DO.php
@@ -0,0 +1,100 @@
+<?php
+//this file is designed to be used as an include that is part of a loop.
+//If a valid match is found, it will give $caller_id a value
+//available variables for use are: $thenumber
+//retreive website contents using get_url_contents($url);
+//version date: November 8, 2011
+
+//configuration / display parameters
+//The description cannot contain "a" tags, but can contain limited HTML. Some HTML (like the a tags) will break the UI.
+$source_desc = "http://www.paginasamarillas.com.do - Business listings for the Dominican Republic.<br><br>This data source requires Superfecta Module version 2.2.1 or higher.";
+
+
+//run this if the script is running in the "get caller id" usage mode.
+if($usage_mode == 'get caller id')
+{
+ $value = "";
+ $number_error = false;
+ $validnpa = false;
+
+ if($debug)
+ {
+ print "Searching http://www.paginasamarillas.com.do ... ";
+ }
+
+ //check for the correct 10 digit phone number.
+ if (strlen($thenumber) != 10)
+ {
+ $number_error = true;
+
+ }
+
+ // check for Dominican area code
+ if(!$number_error)
+ {
+ $npa = substr($thenumber,0,3);
+ $nxx = substr($thenumber,3,3);
+ $station = substr($thenumber,6,4);
+
+ // List of all valid Dominican NPAs
+ $npalist = array(
+ "809", "829", "849"
+ );
+
+ if(in_array($npa, $npalist))
+ {
+ $validnpa = true;
+ }
+ }
+
+ if(!$validnpa)
+ {
+ $number_error = true;
+ }
+
+
+ if($number_error)
+ {
+ if($debug)
+ {
+ print "Skipping - Not a 10 digit Dominican number: ".$thenumber."<br>\n";
+ }
+ }
+ else
+ {
+ // Set the url we're searching for
+ $url="http://www.paginasamarillas.com.do/Searchpg.aspx?SearchType=neg&telefono=$thenumber&searchAction=adv&ciudad=ALL";
+ $value = get_url_contents($url);
+
+ // Patterns to search for
+ $regexp = array
+ (
+
+ "/<div class=\"anunciantesover2\" id=\"div.*\" title=\"(.+)\">/",
+ "/\" title=\"url:(.+)\" rel=\"nofollow/",
+
+ );
+
+ // By default, there is no match
+ $name = "";
+
+ // Look through each pattern to see if we find a match -- take the first match
+ foreach ($regexp as $pattern){
+ preg_match($pattern, $value, $match);
+ if(isset($match[1]) && (strlen(trim(strip_tags($match[1]))))){
+ $name = trim(strip_tags($match[1]));
+ break;
+ }
+ }
+
+ // If we found a match, return it
+ if(strlen($name) > 1)
+ {
+ $caller_id = $name;
+ }
+ else if($debug)
+ {
+ print "not found<br>\n";
+ }
+ }
+}
View
33 bin/source-SugarCRM.php
@@ -1,6 +1,6 @@
<?php
//this file is designed to be used as an include that is part of a loop.
-//If a valid match is found, it should give $caller_id a value
+//If a valid match is found, it will give $caller_id a value
//available variables for use are: $thenumber
//retreive website contents using get_url_contents($url);
@@ -8,6 +8,7 @@
// v0.9.5 Fixed PHP/MYSQL closing problem 3/30/2009 jpeterman
// v0.9.3: Fixed contacts query to also lookup phone_home entry
// v0.9.2: Initial Release Version
+// 27 October 2011 added MySQL query for searching leads
//configuration / display parameters
@@ -32,14 +33,9 @@
$source_param['Search_Contacts']['desc'] = 'Include Contacts records in search';
$source_param['Search_Contacts']['type'] = 'checkbox';
$source_param['Search_Contacts']['default'] = "on";
-
-
-// $source_param['Search_Type']['desc'] = 'The SugarCRM type of entries that should be used to match the number';
-// $source_param['Search_Type']['type'] = 'select';
-// $source_param['Search_Type']['option'][1] = 'accounts';
-// $source_param['Search_Type']['option'][2] = 'accounts and users';
-// $source_param['Search_Type']['option'][3] = 'accounts, users and contacts';
-// $source_param['Search_Type']['default'] = 3;
+$source_param['Search_Leads']['desc'] = 'Include Leads records in search';
+$source_param['Search_Leads']['type'] = 'checkbox';
+$source_param['Search_Leads']['default'] = "on";
$source_param['Filter_Length']['desc']='The number of rightmost digits to check for a match';
$source_param['Filter_Length']['type']='number';
@@ -58,15 +54,12 @@
$wquery_result = "";
$wresult_caller_name = "";
- $wquery_input = preg_replace("/\D/","",$thenumber); // strip non-digits
- if (strlen($wquery_input) == 0) exit; // abandon search if no number is passed
if (strlen($wquery_input) > $run_param['Filter_Length']) $wquery_input = substr($wquery_input, -$run_param['Filter_Length']); // keep only the filter_length rightmost digits
$wdb_handle = mysql_connect($run_param['DB_Host'], $run_param['DB_User'], $run_param['DB_Password']) or die("SugarCRM connection failed" . mysql_error());
mysql_select_db($run_param['DB_Name']) or die("SugarCRM db open error: " . mysql_error());
mysql_query("SET NAMES 'utf8'") or die("UTF8 set query failed: " . mysql_error());
// search accounts
-
if ($run_param['Search_Accounts'] == "on")
{
$wquery_string = "SELECT * FROM accounts WHERE deleted = '0' AND (RIGHT(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(accounts.phone_office,' ',''),'+',''),'-',''),'(',''),')','')," . $run_param['Filter_Length'] . ") LIKE '" . $wquery_input . "' OR RIGHT(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(accounts.phone_alternate,' ',''),'+',''),'-',''),'(',''),')','')," . $run_param['Filter_Length'] . ") LIKE '" . $wquery_input . "' OR RIGHT(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(accounts.phone_fax,' ',''),'+',''),'-',''),'(',''),')','')," . $run_param['Filter_Length'] . ") LIKE '" . $wquery_input . "') LIMIT 1";
@@ -101,7 +94,20 @@
$wresult_caller_name = $wquery_row["last_name"] . ' ' . $wquery_row["first_name"];
}
}
-
+
+ // search also leads if no results from previous searches
+ if($run_param['Search_Leads'] == "on" && strlen($wresult_caller_name) == 0)
+ {
+ $wquery_string = "SELECT * FROM leads WHERE deleted = '0' AND (RIGHT(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(leads.phone_work,' ',''),'+',''),'-',''),'(',''),')','')," . $run_param['Filter_Length'] . ") LIKE '" . $wquery_input . "' OR RIGHT(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(leads.phone_mobile,' ',''),'+',''),'-',''),'(',''),')','')," . $run_param['Filter_Length'] . ") LIKE '". $wquery_input ."' OR RIGHT(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(leads.phone_home,' ',''),'+',''),'-',''),'(',''),')','')," . $run_param['Filter_Length'] . ") LIKE '" . $wquery_input . "' OR RIGHT(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(leads.phone_other,' ',''),'+',''),'-',''),'(',''),')','')," . $run_param['Filter_Length'] . ") LIKE '" . $wquery_input . "' OR RIGHT(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(leads.phone_fax,' ',''),'+',''),'-',''),'(',''),')','')," . $run_param['Filter_Length'] . ") LIKE '" . $wquery_input . "') LIMIT 1";
+ $wquery_result = mysql_query($wquery_string) or die("SugarCRM contacts query failed" . mysql_error());
+ if(mysql_num_rows($wquery_result)>0)
+ {
+ $wquery_row = mysql_fetch_array($wquery_result);
+ $wresult_caller_name = $wquery_row["last_name"] . ' ' . $wquery_row["first_name"];
+ }
+ }
+
+
mysql_close($wdb_handle);
if(strlen($wresult_caller_name) > 0)
@@ -113,4 +119,3 @@
print "not found<br>\n";
}
}
-?>
View
15 bin/source-Trunk_Provided.php
@@ -12,7 +12,9 @@
Seperate keywords with commas.';
$source_param['Ignore_Keywords']['type'] = 'textarea';
$source_param['Ignore_Keywords']['default'] = 'unknown, toll free, unlisted, (N/A)';
-
+$source_param['Discard_Numeric']['desc'] = 'Enable this setting to discard trunk provided CNAM that is all digits.';
+$source_param['Discard_Numeric']['type'] = 'checkbox';
+$source_param['Discard_Numeric']['default'] = 'on';
//run this if the script is running in the "get caller id" usage mode.
if($usage_mode == 'get caller id')
@@ -61,6 +63,7 @@
}
}
+ // Check to see if the CNAM is the same as the CID and discard
if ($provided_caller_id == $thenumber_orig)
{
$provided_caller_id='';
@@ -70,6 +73,15 @@
}
}
+ // Check to see if the CNAM is all numeric and discard if user enables
+ if (($run_param['Discard_Numeric'] == 'on') && (is_numeric($provided_caller_id)))
+ {
+ $provided_caller_id='';
+ if($debug)
+ {
+ print "CID is all numeric - discarded<br>\n";
+ }
+ }
if($debug && ($provided_caller_id == ''))
{
print "not found<br>\n";
@@ -95,4 +107,3 @@
}
}
}
-?>
View
12 functions.inc.php
@@ -11,6 +11,7 @@ function setConfig()
$Curl_Timeout = mysql_real_escape_string($_POST['Curl_Timeout']);
$http_password = mysql_real_escape_string(utf8_decode($_POST['http_password']));
$http_username = mysql_real_escape_string(utf8_decode($_POST['http_username']));
+ $cacheresults = mysql_real_escape_string($_POST['cache']);
$SPAM_Text = mysql_real_escape_string($_POST['SPAM_Text']);
$SPAM_Text_Substitute = (isset($_POST['SPAM_Text_Substitute'])) ? mysql_real_escape_string($_POST['SPAM_Text_Substitute']) : 'N';
$error = false;
@@ -80,13 +81,13 @@ function setConfig()
//check the previous username and password from the cidlookup table
- $sql = "SELECT http_username, http_password FROM cidlookup WHERE description = 'Caller ID Superfecta' LIMIT 1";
+ $sql = "SELECT http_username, http_password, cache FROM cidlookup WHERE description = 'Caller ID Superfecta' LIMIT 1";
$results= sql($sql, "getAll");
//update the HTTP Auth username and password if needed
- if (($results[0][0] != $http_username) or ($results[0][1] != $http_password))
+ if (($results[0][0] != $http_username) or ($results[0][1] != $http_password) or ($results[0][2] != $cacheresults))
{
- $sql = "UPDATE cidlookup SET http_username = '$http_username', http_password = '$http_password' WHERE description = 'Caller ID Superfecta' LIMIT 1";
+ $sql = "UPDATE cidlookup SET http_username = '$http_username', http_password = '$http_password', cache = '$cacheresults' WHERE description = 'Caller ID Superfecta' LIMIT 1";
sql($sql);
//$fcc->update();
needreload();
@@ -111,10 +112,11 @@ function getConfig($scheme)
}
//get the username and password from the cidlookup table
- $sql = "SELECT http_username, http_password FROM cidlookup WHERE description = 'Caller ID Superfecta' LIMIT 1";
+ $sql = "SELECT http_username, http_password, cache FROM cidlookup WHERE description = 'Caller ID Superfecta' LIMIT 1";
$results= sql($sql, "getAll");
$return['http_username'] = $results[0][0];
$return['http_password'] = $results[0][1];
+ $return['cache'] = $results[0][2];
return $return;
}
@@ -268,4 +270,4 @@ function xml2array($url, $get_attributes = 1, $priority = 'tag')
}
return ($xml_array);
}
-?>
+?>
View
13 page.superfecta.php
@@ -256,6 +256,12 @@
<td><a href="javascript:return(false);" class="info">Password:<span>The HTTP Authentication password (you probably used it to get to this page.)</span></a></td>
<td><input type="password" name="http_password" size="23" maxlength="20" value="'.utf8_encode($conf['http_password']).'"></td>
</tr>
+
+ <tr>
+ <td><a href="javascript:return(false);" class="info">Cache results to Asterisk Address Book:<span>This option should be disabled for proper Superfecta operation</span></a></td>
+ <td><input type="text" name="cache" size="23" maxlength="20" value="'.utf8_encode($conf['cache']).'"></td>
+ </tr>
+
<tr>
<td><a href="javascript:return(false);" class="info">Lookup Timeout<span>Specify a timeout in seconds for each source. If the source fails to return a result within the alloted time, the script will move on.</span></a></td>
<td><input type="text" name="Curl_Timeout" size="4" maxlength="5" value="'.$conf['Curl_Timeout'].'"></td>
@@ -313,6 +319,13 @@
print 'document.forms.Superfecta.http_password.focus();';
print 'alert("The form has a value entered for the username (In the General Options section), but the password is blank. You should probably fill in the password portion of this form to ensure proper operation of Caller ID Superfecta.");';
}
+ else if(($conf['http_username'] != '') && ($conf['cache'] == '1'))
+ {
+ //javascript alert the user that they have a caller ID cache results enabled
+ //also focus on the password form element.
+ // print 'document.forms.Superfecta.http_password.focus();';
+ print 'alert("The form has cache results enabled which is not recommended for superfecta operation.");';
+ }
}
print '
Something went wrong with that request. Please try again.