Skip to content

Commit

Permalink
FREEPBX-12210 more script cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mitterhuemer authored and tm1000 committed May 11, 2016
1 parent 9bf2e0e commit a8e8383
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions sources/source-Herold_Austria.module
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* 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
* 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
Expand All @@ -16,11 +16,10 @@
* 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 Fix code for new Herold mobile site template / Rewrite Number if cid is not correctly given from trunk for herold.
* 2016-05-03 Rewrite Numbers correct for Herold and change Query for new Mobile Web Template
*
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***/


class Herold_Austria extends superfecta_base {

public $description;
Expand All @@ -33,29 +32,35 @@ class Herold_Austria extends superfecta_base {
function get_caller_id($thenumber, $run_param=array()) {
$this->DebugPrint(_("Searching"). "http://www.herold.at/ ... ");

// 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
if(strpos($thenumber, '+') === 0){
$thenumber=trim($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 = "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

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

$caller_id="";
// 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 (!$caller_id && $this->SearchURL($bus_url, $regexp, $match)) {
if ($this->SearchURL($bus_url, $regexp, $match)) {
$caller_id = $this->ExtractMatch($match);
}
$caller_id = isset($caller_id)?$caller_id:'';

return($caller_id);
}

}

0 comments on commit a8e8383

Please sign in to comment.