| 1 | <?php
|
| 2 | //this file is designed to be used as an include that is part of a loop.
|
| 3 | //If a valid match is found, it should give $caller_id a value
|
| 4 | //available variables for use are: $thenumber
|
| 5 | //retreive website contents using get_url_contents($url);
|
| 6 |
|
| 7 | //configuration / display parameters
|
| 8 | //The description cannot contain "a" tags, but can contain limited HTML. Some HTML (like the a tags) will break the UI.
|
| 9 | $source_desc = "http://www.ukphoneinfo.com - The UK Telephone Code Locator will return the exchange or service area location. No names are returned by this source.";
|
| 10 | $source_param = array();
|
| 11 |
|
| 12 | // Only UK supported here
|
| 13 | // if you have time to help us, we will welcome your debug for these sources.
|
| 14 |
|
| 15 | //run this if the script is running in the "get caller id" usage mode.
|
| 16 | if($usage_mode == 'get caller id')
|
| 17 | {
|
| 18 | if($debug)
|
| 19 | {
|
| 20 | print 'Searching UKPhoneInfo...<br> ';
|
| 21 | }
|
| 22 |
|
| 23 | // Test for UK
|
| 24 | if (strlen($thenumber) > 11)
|
| 25 | {
|
| 26 | if (substr($thenumber,0,2) == '44')
|
| 27 | {
|
| 28 | $thenumber = '0'.substr($thenumber,2);
|
| 29 | }
|
| 30 | else if (substr($thenumber,0,4) == '0044')
|
| 31 | {
|
| 32 | $thenumber = '0'.substr($thenumber,4);
|
| 33 | }
|
| 34 | else if (substr($thenumber,0,5) == '01144')
|
| 35 | {
|
| 36 | $thenumber = '0'.substr($thenumber,5);
|
| 37 | }
|
| 38 | }
|
| 39 |
|
| 40 | $url = "http://www.ukphoneinfo.com/search.php?Submit=Submit&d=nl";
|
| 41 |
|
| 42 | $url = $url . "&GNG=" . $thenumber;
|
| 43 | $sresult = get_url_contents($url);
|
| 44 |
|
| 45 | preg_match_all('=<h2[^>]*>(.*)</h2>=siU', $sresult, $sname);
|
| 46 |
|
| 47 | if (count($sname[1]) > 0)
|
| 48 | {
|
| 49 | $sname = $sname[1][0];
|
| 50 | //$sname = str_replace(chr(160), ' ', $sname[1][0]);
|
| 51 | }
|
| 52 | else
|
| 53 | {
|
| 54 | $sname = "";
|
| 55 | }
|
| 56 |
|
| 57 | if ($sname != "")
|
| 58 | {
|
| 59 | $caller_id = strip_tags($sname);
|
| 60 | }
|
| 61 | else if($debug)
|
| 62 | {
|
| 63 | print "not found<br>\n";
|
| 64 | }
|
| 65 | }
|
| 66 | ?> |