forked from kingarthur2/superfecta-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsource-Any_Who.module
47 lines (39 loc) · 1.6 KB
/
source-Any_Who.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
<?php
class Any_Who extends superfecta_base {
public $description = "http://whitepages.anywho.com - These listings include data from the AnyWho White Pages data source.";
public $version_requirement = "2.11";
function get_caller_id($thenumber, $run_param=array()) {
$caller_id = null;
$npa = "";
$nxx = "";
$station = "";
if (!$this->IsValidNumber(array('US', 'CA'), $thenumber, $npa, $nxx, $station)) {
$this->DebugPrint("Skipping Source - Not a valid US/CAN number: " . $thenumber);
} else {
$this->DebugPrint("Searching Any Who with (${npa})${nxx}-${station} ... ");
$url = "http://whitepages.anywho.com/results.php?&qnpa=$npa&qp=" . $nxx . $station;
$value = $this->get_url_contents($url);
$notfound = strpos($value, "class=\"NoResultBar\"");
$start = strpos($value, "class=\"singleName\"");
if (!$start) {
$start = strpos($value, "class=\"resultName\"");
}
$value = substr($value, $start + 17);
$start = strpos($value, "\">");
$value = substr($value, $start + 2);
$end = strpos($value, "</div>");
$value = substr($value, 0, $end);
$value = strip_tags($value);
if ($notfound) {
$value = "";
}
// If we found a match, return it
if (strlen($value) > 1) {
$caller_id = $value;
} else {
$this->DebugPrint("not found");
}
}
return($caller_id);
}
}