Skip to content

Commit

Permalink
Merge branch 'release/13.0' of github.com:POSSA/Caller-ID-Superfecta …
Browse files Browse the repository at this point in the history
…into release/13.0

Conflicts:
	sources/source-GevondenCC_NL.module
	sources/source-Herold_Austria.module
  • Loading branch information
tm1000 committed Mar 30, 2017
2 parents 211a952 + 0211598 commit c465100
Show file tree
Hide file tree
Showing 8 changed files with 207 additions and 46 deletions.
15 changes: 8 additions & 7 deletions Superfecta.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,14 @@ public function execute($scheme='ALL', $request, $debug=0, $keepGoing=false) {
$callerid = preg_replace("/[\";']/", "", $callerid);
//limit caller id to the first 60 char
$callerid = substr($callerid, 0, 60);

// Display issues on phones and CDR with special characters
// convert CNAM to UTF-8 to fix
if (function_exists('mb_convert_encoding')) {
$this->out("Converting result to UTF-8");
$callerid = mb_convert_encoding($callerid, "UTF-8");
}

//send off
$superfecta->send_results($callerid);
}
Expand All @@ -209,13 +217,6 @@ public function execute($scheme='ALL', $request, $debug=0, $keepGoing=false) {
$callerid = $spam_text . " " . $superfecta->get_Prefix() . $callerid;
}

// Display issues on phones and CDR with special characters
// convert CNAM to UTF-8 to fix
if ($found && function_exists('mb_convert_encoding')) {
$this->out("Converting result to UTF-8");
$callerid = mb_convert_encoding($callerid, "UTF-8");
}

//Set Spam Destination
$spam_dest = (!empty($options['scheme_settings']['spam_interceptor']) && ($options['scheme_settings']['spam_interceptor'] == 'Y')) ? $options['scheme_settings']['spam_destination'] : '';
$this->spamCount = $this->spamCount + (int)$superfecta->get_SpamCount();
Expand Down
2 changes: 1 addition & 1 deletion sources/source-Abandon_lookup.module
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Abandon_lookup extends superfecta_base {
if ($run_param['Artificial_CNAM'] == NULL) {
$run_param['Artificial_CNAM'] = $this->source_param['Artificial_CNAM']['default'];
}
if ($run_param['Use_CID'] == 'on') {
if (isset($run_param['Use_CID']) && $run_param['Use_CID'] == 'on') {
$run_param['Artificial_CNAM'] = $thenumber;
}

Expand Down
53 changes: 53 additions & 0 deletions sources/source-DasTelefonBuch_Germany.module
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

/*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
* Developer Notes:
*
* This DasTelefonBuch_Germany Source is looking up for persons companys.
*
* dastelefonbuch.de Terms of Service:
* https://www.dastelefonbuch.de/Datenschutz
* dastelefonbuch.de TOS do not explicitly prohibit automated lookups
* dastelefonbuch.de manages Reverse Number lookups for their customers. Number Search works for all Customers, which dont contradict for this service.
*
* Version History:
* 2017-03-21 Initial Module for DasTelefonBuch_Germany
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***/

class DasTelefonBuch_Germany extends superfecta_base {

public $description;
public $version_requirement = "2.11";

public function __construct() {
$this->description = "https://www.dastelefonbuch.de - "._("These listings include data for dastelefonbuch in Germany.");
}

function get_caller_id($thenumber, $run_param=array()) {
$this->DebugPrint(_("Searching"). "https://www.dastelefonbuch.de ... ");

if (substr($thenumber, 0, 1) ==! '0') {
$thenumber=trim($thenumber,' ');
$thenumber="00" . $thenumber;
}
if (substr($thenumber, 0, 2) === '00') {
$thenumber=trim($thenumber,' ');
}

// Set the url we're searching for
$res_rul = "https://www.dastelefonbuch.de/Suche/" . $thenumber;// url for searching persons

// regex patterns to search for
$regexp = array(
'~<div class="name" title="(.+?)">~',
);
// search for persons match
if ($this->SearchURL($res_rul, $regexp, $match)) {
$caller_id = $this->ExtractMatch($match);
}
$caller_id = isset($caller_id)?$caller_id:'';

return($caller_id);
}

}
10 changes: 4 additions & 6 deletions sources/source-GevondenCC_NL.module
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
*
*
*/
class GevondenCC_NL extends superfecta_base {

Expand All @@ -16,7 +16,7 @@ class GevondenCC_NL extends superfecta_base {
$caller_id = null;
$name = "";

$this->DebugPrint("Searching gevonden.cc - $thenumber ... ");
$this->DebugPrint("Searching gevonden.cc - {$thenumber} ... ");

// Test for NL
$loc_number = $thenumber;
Expand Down Expand Up @@ -45,12 +45,10 @@ class GevondenCC_NL extends superfecta_base {

$expr = '=<title[^>]*>(.*)[0-9]{5,}</title>=siU';
preg_match_all($expr, $result, $name);
if (count($name) > 1 && count($name[1]) > 0)
if (count($name[1]) > 0)
{
$name = trim($name[1][0]);
$name = strip_tags($name);
} else {
$name = "";
}
}
else
Expand All @@ -59,7 +57,7 @@ class GevondenCC_NL extends superfecta_base {
}

// If we found a match, return it
if (strlen($name) > 1)
if (is_string($name) && strlen($name) > 1)
{
$caller_id = $name;
} else {
Expand Down
20 changes: 14 additions & 6 deletions sources/source-Herold_Austria.module
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* 2014-06-28 Initial migration from 2.2.x
* 2014-07-02 Add business lookups and change urls to mobile site
* 2016-05-03 Rewrite Numbers correct for Herold and change Query for new Mobile Web Template
*
* 2017-03-20 Again Herold has a new Theme. We need to change the regexp again
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***/

class Herold_Austria extends superfecta_base {
Expand All @@ -26,11 +26,11 @@ class Herold_Austria extends superfecta_base {
public $version_requirement = "2.11";

public function __construct() {
$this->description = "http://www.herold.at/ - "._("These listings include data for Austria.");
$this->description = "https://www.herold.at/ - "._("These listings include data for Austria.");
}

function get_caller_id($thenumber, $run_param=array()) {
$this->DebugPrint(_("Searching"). "http://www.herold.at/ ... ");
$this->DebugPrint(_("Searching"). "https://www.herold.at/ ... ");

if (substr($thenumber, 0, 1) ==! '0') {
$thenumber=trim($thenumber,' ');
Expand All @@ -41,12 +41,12 @@ class Herold_Austria extends superfecta_base {
}

// Set the url we're searching for
$res_rul = "http://www.herold.mobi/telefonbuch/was_".$thenumber."/";// url for searching residential listings
$bus_url = "http://www.herold.mobi/gelbe-seiten/was_".$thenumber."/";// url for searching business listings
$res_rul = "https://www.herold.at/telefonbuch/was_".$thenumber."/";// url for searching residential listings
$bus_url = "https://www.herold.at/gelbe-seiten/was_".$thenumber."/";// url for searching business listings

// regex patterns to search for
$regexp = array(
'~<a data-clickpos="name" href=".*?">(.+?)</a>~',
'~<h2><a href=".*?" data-clickpos="name"><span itemprop="name">(.+?)</span>~',
);

// first search for Residential match
Expand All @@ -63,4 +63,12 @@ class Herold_Austria extends superfecta_base {
return($caller_id);
}

}

// if no residential match found, search business
if (!$caller_id && $this->SearchURL($bus_url, $regexp, $match)) {
$caller_id = $this->ExtractMatch($match);
}
return($caller_id);
}
}
89 changes: 65 additions & 24 deletions sources/source-LocalTel_CH.module
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ TOS date: December 15, 2009
TOS summary by lgaetz: I have reviewed what is available on this page and can't see anything that prohibits or prevents superfecta from using this as a lookup source. date: 2014-01-06

Version History
2016-04-18 Updated parse method (compatiple php 5.6), formatted code and did a bit of commentary
2015-04-19 Fixed bug if there are multiple results
2015-04-18 Changed method for the request (use tel.search.ch API)
2012-xx-xx Initial migration
Expand All @@ -16,34 +17,74 @@ class LocalTel_CH extends superfecta_base {
public $description = "http://local.ch (tel.search.ch) - These listings include business and residential data for Switzerland.";
public $version_requirement = "2.11";

function get_caller_id($thenumber, $run_param=array()) {

function get_caller_id($thenumber, $run_param=array())
{
//Define vars
$caller_id = null;

if ((!$this->IsValidNumber('CH', $thenumber))) {

//Check the number format
if ((!$this->IsValidNumber('CH', $thenumber)))
{
$this->DebugPrint("Skipping Source - Not a valid Swiss number: {$thenumber}");
} else {
}
else
{
$this->DebugPrint("Searching Local.ch-Swiss ... ");
$request = "http://tel.search.ch/api/?was=$thenumber";
$feed = implode(file($request));
if(!$xml = simplexml_load_string($feed)){
return($caller_id);
}
if(!$json = json_encode($xml)){
return($caller_id);
}
if(!$array = json_decode($json,TRUE)){
return($caller_id);
}else{
//Fix if there are multiple entrys
if(!$caller_id = $array['entry']['title']){
if(!$caller_id = $array['entry'][0]['title']){
$caller_id = null;
$this->DebugPrint('Could not parse xml-response from tel.search.ch');
}
}
}
$request = "http://tel.search.ch/api/?was=$thenumber";
$feed = implode(file($request));
//Load XML
if(!$xml = simplexml_load_string($feed))
{
$this->DebugPrint("not found (xml error)");
return($caller_id);
}
//Parse to json
if(!$json = json_encode($xml))
{
$this->DebugPrint("not found (json encode error)");
return($caller_id);
}
if(!$array = json_decode($json,TRUE))
{
$this->DebugPrint("not found (json decode error)");
return($caller_id);
}
else
{
//Check if a result has been found
if(array_key_exists('entry', $array))
{
//Check if there are multiple results
if(isset($array['entry'][0]))
{
$this->DebugPrint("Multiple results found, I took the first one");
//Set callerid
if(!$caller_id = $array['entry'][0]['title'])
{
$this->DebugPrint('Could not parse xml-response from tel.search.ch');
$caller_id = null;
}
}
else
{
//Single result, set callerid
$this->DebugPrint("Entry found, try to set callerid:");
if(!$caller_id = $array['entry']['title'])
{
$this->DebugPrint('Could not parse xml-response from tel.search.ch');
$caller_id = null;
}
}
}
else
{
//Return empty Callerid
$this->DebugPrint("not found");
return $caller_id = null;
}
}
}
//Return Callerid (success)
return($caller_id);
}

Expand Down
11 changes: 9 additions & 2 deletions sources/source-SFDatabase.module
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Version History:

2014-0-21: Added additional placeholder for :pernumber, which puts % around thenubmer in the query
Finaly fixed bug that prevented quotes in query

2016-06-29: Add the ability to define a port for the database

*** *** *** *** *** *** *** *** *** ***/

Expand All @@ -34,6 +36,11 @@ class SFDatabase extends superfecta_base {
'type' => 'text',
'default' => 'localhost'
),
'DB_Port' => array(
'description' => 'Port of the database. (3306 by default)',
'type' => 'number',
'default' => '3306'
),
'DB_Name' => array(
'description' => 'Name of database',
'type' => 'text',
Expand Down Expand Up @@ -78,7 +85,7 @@ class SFDatabase extends superfecta_base {
$this->DebugPrint("Connecting to database....");

try {
$dbh = new PDO($run_param['DB_Driver'].':dbname='.$run_param['DB_Name'].';host='.$run_param['DB_Host'], $run_param['DB_User'], $run_param['DB_Password']);
$dbh = new PDO($run_param['DB_Driver'].':dbname='.$run_param['DB_Name'].';host='.$run_param['DB_Host'].';port='.$run_param['DB_Port'], $run_param['DB_User'], $run_param['DB_Password']);
} catch (PDOException $e) {
$this->DebugPrint('Connection failed: ' . $e->getMessage());
return null;
Expand Down Expand Up @@ -137,7 +144,7 @@ class SFDatabase extends superfecta_base {
$this->DebugPrint("Connecting to database....");

try {
$dbh = new PDO($run_param['DB_Driver'].':dbname='.$run_param['DB_Name'].';host='.$run_param['DB_Host'], $run_param['DB_User'], $run_param['DB_Password']);
$dbh = new PDO($run_param['DB_Driver'].':dbname='.$run_param['DB_Name'].';host='.$run_param['DB_Host'].';port='.$run_param['DB_Port'], $run_param['DB_User'], $run_param['DB_Password']);
} catch (PDOException $e) {
$this->DebugPrint('Connection failed: ' . $e->getMessage());
return null;
Expand Down
53 changes: 53 additions & 0 deletions sources/source-TelefonABC_Austria.module
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

/*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
* Developer Notes:
*
* This TelefonABC Source is looking up for persons and some companys. Officially this module supports only Persons lookup but sometimes there alre also companys in the results.
*
* TelefonABC.at Terms of Service:
* http://www.telefonabc.at/agb.aspx
* TelefonABC.at TOS do not explicitly prohibit automated lookups
* It is not allowed to save the looked up data into a Database and it is prohibited to use the Data for commercial use and adverts.
*
* Version History:
* 2017-03-21 Initial Module for TelefonABC.at
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***/

class TelefonABC_Austria extends superfecta_base {

public $description;
public $version_requirement = "2.11";

public function __construct() {
$this->description = "http://www.telefonabc.at - "._("These listings include data for TelefonABC in Austria.");
}

function get_caller_id($thenumber, $run_param=array()) {
$this->DebugPrint(_("Searching"). "http://www.telefonabc.at ... ");

if (substr($thenumber, 0, 1) ==! '0') {
$thenumber=trim($thenumber,' ');
$thenumber="00" . $thenumber;
}
if (substr($thenumber, 0, 2) === '00') {
$thenumber=trim($thenumber,' ');
}

// Set the url we're searching for
$res_rul = "http://www.telefonabc.at/result.aspx?what=".$thenumber."&where=&exact=False&firstname=&lastname=&appendix=&branch=&p=0&sid=&did=&cc=";// url for searching persons

// regex patterns to search for
$regexp = array(
'#<h3 itemprop="name" class="card-heading pull-left">(.+?)</h3>#s',
);
// search for persons match
if ($this->SearchURL($res_rul, $regexp, $match)) {
$caller_id = $this->ExtractMatch($match);
}
$caller_id = isset($caller_id)?$caller_id:'';

return($caller_id);
}

}

0 comments on commit c465100

Please sign in to comment.