forked from kingarthur2/superfecta-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsource-Hitta_SE.module
98 lines (85 loc) · 3.65 KB
/
source-Hitta_SE.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
/**** **** **** **** **** **** **** **** **** **** **** **** **** **** **** ****
* Developer Notes:
* User report on 2014-03-25 that this module is broken
*
*
*
* Version history:
* 2009-10-02 2.2 version by Nixi (Jonathan)
* 2011-xx-xx migrated to version 2.11.x by ukstevef
*
**** **** **** **** **** **** **** **** **** **** **** **** **** **** **** ****/
class Hitta_SE extends superfecta_base {
public $description = "http://www.hitta.se - This listing includes data from the Swedish Hitta.se directory.";
public $version_requirement = "2.11";
public $source_param = array(
'Search_Type' => array(
'description' => 'Select which sources you want to search',
'type' => 'select',
'option' => array(
1 => 'Residential',
2 => 'Business',
3 => 'Residential & Business'
),
'default' => 3
)
);
function get_caller_id($thenumber, $run_param=array()) {
$caller_id = null;
if (!$this->IsValidNumber('SE', $this->thenumber)) {
$this->DebugPrint("Skipping Source - Non Swedish number: {$this->thenumber}");
} else {
if ($run_param['Search_Type'] != 2) {
$this->DebugPrint("Searching Hitta.se residential ... {$this->thenumber}");
$url = "http://wap.hitta.se/default.aspx?Who=$this->thenumber&Where=&PageAction=White";
$value = $this->get_url_contents($url);
$notfound = strpos($value, "<a href=\"/Details"); //No information found
$notfound = ($notfound < 1);
if ($notfound) {
$value = "";
} else {
$start = strpos($value, "<a href=\"/Details");
$value = substr($value, $start + 17);
$start = strpos($value, ">");
$value = substr($value, $start + 3);
$end = strpos($value, "</a>");
$value = substr($value, 0, $end);
}
if (strlen($value) > 1) {
$caller_id = strip_tags($value);
} else {
$this->DebugPrint("not found");
}
}
if ($run_param['Search_Type'] >= 2) {
$this->DebugPrint("Searching Hitta.se business ... {$this->thenumber}");
$url = "http://wap.hitta.se/default.aspx?Who=$this->thenumber&Where=&PageAction=Pink";
$value = $this->get_url_contents($url);
$notfound = strpos($value, "Ingen exakt"); //No direct match. Ignore suggestions.
$notfound = ($notfound < 1) ? strpos($value, "Ingen exakt") : $notfound;
if ($notfound) {
$value = "";
} else {
$start = strpos($value, "<a href=\"/Details");
$value = substr($value, $start + 17);
$start = strpos($value, ">");
$value = substr($value, $start + 3);
$end = strpos($value, "</a>");
$value = substr($value, 0, $end);
}
$notfound = strpos($value, "tta.se"); //nothing found.
$notfound = ($notfound < 1) ? strpos($value, "tta.se") : $notfound;
if ($notfound) {
$value = "";
}
if (strlen($value) > 1) {
$caller_id = strip_tags($value);
} else {
$this->DebugPrint("not found");
}
}
}
return $caller_id;
}
}