Superfecta Herold Austria

Hi Matthias,

as I wrote before I have the latest module online but when my Perfecta (Herold) is not working:

Debug is on and set at level: 3
The Original Number: 0463596453
The Scheme: Default
Scheme Type: SINGLEFECTA
Debugging Enabled, will not stop after first result

Scheme Asked is: Default
The DID is: 5555555555
The CNUM is: 0463596453
The CNAME is: CID Superfecta!

Starting scheme Default
Executing Herold Austria
Searchinghttps://www.herold.at/ ...
Search URL=https://www.herold.at/telefonbuch/was_0463596453/
name lookup timed out
Orignal Raw Returned Data:


Returned Content (w/Stripped \n\r\t):

Testing pattern=~<h2><a href=".*?" data-clickpos="name"><span itemprop="name">(.+?)</span>~
Dumping Matches

array(0) {
}


Search URL=https://www.herold.at/gelbe-seiten/was_0463596453/
name lookup timed out
Orignal Raw Returned Data:


Returned Content (w/Stripped \n\r\t):

Testing pattern=~<h2><a href=".*?" data-clickpos="name"><span itemprop="name">(.+?)</span>~
Dumping Matches

array(0) {
}


result took 6.0016 seconds.

This scheme would set the caller id to:

Returned Result would be:
result took 6.005068063736 seconds

Interesting thing is - when I copy that link into a browser, the name is resolved properly - do you have any idea on fixing this?

thanks, Hubert

Which Version do you use?
Testing pattern should be
Testing pattern=~<h2><a href=".*?" data-clickpos="name"><span itemprop="name">(.+?)</span>~

Starting scheme Default
Executing Herold Austria
Searchinghttps://www.herold.at/ …
'Kapsch Brigitte’
result took 0.6379 seconds.

Converting result to UTF-8
Post CID retrieval processing
Done
This scheme would set the caller id to: Kapsch Brigitte

Returned Result would be: Kapsch Brigitte
result took 0,64443492889404 seconds

But Superfecta said “Name lookup timed out.” Check your dns settings and internet connection inside your pbx.
There is maybe a problem that freepbx cannot load this url.

hi Matthias,

yes I also was suspiciious about that timed out. But I have complete access to the internet and also dns is resolving properly…

I have the newest version of superperfecta reinstalled…do I have to do anything else?

thx, Bernhard

PS: do you have also knowledge about certificates for freepbx?

No, it should work. You can try to open the url from the pbx with curl and check the output. I tried superfecta with a few customer pbx systems and all work with your number.

We use letsencrypt with the cert manager and provision the phones with tls/srtp.
What do you want to know?

hi Matthias,

I did the following: curl https://www.herold.at/telefonbuch/was_0463596453/ > test.html and in the html I find Kapsch Brigitte…:frowning: so this seems to work properly?

because of the certificates - I wanted to apply for letsencrypt. the problem is that my freepbx has a public ip which is natted through another public ip (German Hetzner provider). so letsencrypt always gets the wrong IP for my FQDN…

and I am not sure if this is a problem of my provider or my firewall? :frowning: btw: my freepbx runs as a vm on ESXi

thanks, Hubert

LetsEncrypt requires the following hosts to be permitted for inbound http access:
outbound1.letsencrypt.org, outbound2.letsencrypt.org, mirror1.freepbx.org, mirror2.freepbx.org
These entries are correctly set up in the Firewall module. However, it’s possible that other external firewalls may block access. If you are having problems validating your certificate, this could be the issue.

@jfinstrom. Maybe the lookup takes too long? Can we increase the lookup time in the module for testing?

hi Matthias and jfinstrom,

you won’t believe it - accidentally I deleted the current Scheme for superfecta - so I added a new one… and wanted to reproduce the error again - no chance.

with the new scheme its running again without any problem…?!

thanks for the help

HeroldAustria changed the html code on their website again, I had to edit the

source-Herold_Austria.module (already updated on line 52)

<?php

/*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
 * Developer Notes:
 *
 * There are two separate URLS for reverse searching, one for yellowpages one for ppl:
 *	http://www.herold.at/en/telefonbuch/telefon_$thenumber		- people
 *	http://www.herold.at/en/gelbe-seiten/telefon_$thenumber	 - business
 *  I could only get reverse searches to work for ppl
 *
 * herold.at Terms of Service:
 * As summarized in the post here on 2014-06-27
 * https://github.com/POSSA/Caller-ID-Superfecta/issues/131#issuecomment-47354154
 * herold.at TOS do not explicitly prohibit automated lookups
 *
 * Version History:
 * 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
 * 2017-11-09	If the Caller ID is 'unknown', 'anonymous' or empty then skip the check
 *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***/

class Herold_Austria extends superfecta_base {

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

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

	function get_caller_id($thenumber, $run_param=array()) {
		$this->DebugPrint(_("Searching"). "https://www.herold.at/ ... ");
		
		if($thenumber !== 'anonymous' && $thenumber !== 'unknown' && $thenumber !== ''){

		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.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(
			'~<h2><span itemprop="name">(.+?)</span>~',
		);

		// first search for Residential match
		if ($this->SearchURL($res_rul, $regexp, $match)) {
			$caller_id = $this->ExtractMatch($match);
		}

		// if no residential match found, search business
		if ($this->SearchURL($bus_url, $regexp, $match)) {
			$caller_id = $this->ExtractMatch($match);
		}
		$caller_id = isset($caller_id)?$caller_id:'';
		


		return($caller_id);
	}
	}
}

line 52 I changed to '~<h2><span itemprop="name">(.+?)</span>~', originally it was
'~<h2><a href=".*?" data-clickpos="name"><span itemprop="name">(.+?)</span>~',

@Charles_Darwin, thanks for the report. I’ve opened ticket:
https://issues.freepbx.org/browse/FREEPBX-21861

and resolved with commit:
https://git.freepbx.org/projects/FREEPBX/repos/superfecta/raw/sources/source-Herold_Austria.module?at=refs%2Fheads%2Fbugfix%2FFREEPBX-21861

I did a few business and personal lookups and it appears okay. It would be great if you can QA and confirm all is okay as well.

I already installed my edited herold-source-file and it works. Should I test the git-file too? Thanks by the way…as you know, I am a fan of superfecta! it is super useful!!!

Yes please. That’s the version that will be published.

Ok, I will…and report back…later in the evening (European time). Thanks!

1 Like

Seems to work…I get good results…
Rarely, I get the wrong name…e.g. when the number is very long (including the extension) and not listed in Herold, then it truncates the number to 9 digits and just displays the first hit, which is completely wrong…but again, it is very rare…
And there is still a problem with german umlaute with the Herold template, I edited the superfecta.class.php…but it is just a workaround…and it might only work for me!

the relevant code starts with line 204:

			$callerid = trim($callerid);

			$found = false;
			if (!empty($callerid)) {
				$found = true;
				$callerid = strtr($callerid, array("ü" => "ue", "ö" => "oe", "ä" => "ae", "Ü" => "Ue", "Ö" => "Oe", "Ä" => "Ae", "ß" => "ss"));
				$callerid = trim(strip_tags($callerid));
				if ($superfecta->isCharSetIA5()) {
					$callerid = $superfecta->stripAccents($callerid);
				}
				//Why?
				$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 = iconv('ISO-8859-15//TRANSLIT', 'UTF-8', $callerid);
				}

				//send off

If you can come up with the logic to trim numbers to a certain length that works in all cases, it should be easy to add to the .module file.

I am afraid there is no logic…in Austria the length of the number can vary extensively. Actually, superfecta does a great job. Sometimes extensions are added to the main number, sometimes not…how should Superfecta know where to stop? I think the current success rate is >95%…just guessing…

Just checked…it seems the minimum length of phone numbers in Austria is 9 digits…so Superfecta does it right. There is no other solution to it, it seems…and I dont know of any other (even paid) service, which does a better job than Superfecta :wink:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.