| 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.telekom.rs/WhitePages - These listings will return both residential and business listings.";
|
| 10 |
|
| 11 | include_once "functions-TelekomRs_White_Pages.php";
|
| 12 |
|
| 13 | //run this if the script is running in the "get caller id" usage mode.
|
| 14 | if($usage_mode == 'get caller id')
|
| 15 | {
|
| 16 | $number_error = false;
|
| 17 | if($debug)
|
| 18 | {
|
| 19 | print "Searching Telkom.RS White Pages ... ";
|
| 20 | }
|
| 21 |
|
| 22 | // international dialing prefix + country code + number
|
| 23 | if (strlen($thenumber) > 11)
|
| 24 | {
|
| 25 | if (substr($thenumber,0,2) == '00')
|
| 26 | {
|
| 27 | $thenumber = substr($thenumber, 2);
|
| 28 | }
|
| 29 | else
|
| 30 | {
|
| 31 | if (substr($thenumber,0,3) == '011')
|
| 32 | {
|
| 33 | $thenumber = substr($thenumber,3);
|
| 34 | }
|
| 35 | else
|
| 36 | {
|
| 37 | $number_error = true;
|
| 38 | }
|
| 39 | }
|
| 40 |
|
| 41 | }
|
| 42 |
|
| 43 | //check for the correct 10/11 digits in russia phone numbers in international format.
|
| 44 | // country code + number
|
| 45 | if (strlen($thenumber) == 11)
|
| 46 | {
|
| 47 | if (substr($thenumber,0,1) == 7)
|
| 48 | {
|
| 49 | $thenumber = substr($thenumber,1);
|
| 50 | }
|
| 51 | else
|
| 52 | {
|
| 53 | $number_error = true;
|
| 54 | }
|
| 55 |
|
| 56 | }
|
| 57 |
|
| 58 |
|
| 59 | // number
|
| 60 | if(strlen($thenumber) < 10)
|
| 61 | {
|
| 62 | //$number_error = true;
|
| 63 |
|
| 64 | }
|
| 65 | if($number_error===false){
|
| 66 | $npalist_RS = array(
|
| 67 | "Beograd" => "011",
|
| 68 | "Bor" => "030",
|
| 69 | ".a.ak" => "032",
|
| 70 | ".akovica" => "0390",
|
| 71 | "Gnjilane" => "0280",
|
| 72 | "Jagodina" => "035",
|
| 73 | "Kikinda" => "0230",
|
| 74 | "Kosovska Mitrovica" => "028",
|
| 75 | "Kragujevac" => "034",
|
| 76 | "Kraljevo" => "036",
|
| 77 | "Kru.evac" => "037",
|
| 78 | "Leskovac" => "016",
|
| 79 | "Ni." => "018",
|
| 80 | "Novi Pazar" => "020",
|
| 81 | "Novi Sad" => "021",
|
| 82 | "Pan.evo" => "013",
|
| 83 | "Pe." => "039",
|
| 84 | "Pirot" => "010",
|
| 85 | "Po.arevac" => "012",
|
| 86 | "Prijepolje" => "033",
|
| 87 | "Pri.tina" => "038",
|
| 88 | "Prizren" => "029",
|
| 89 | "Prokuplje" => "027",
|
| 90 | ".abac" => "015",
|
| 91 | "Smederevo" => "026",
|
| 92 | "Sombor" => "025",
|
| 93 | "Sremska Mitrovica" => "022",
|
| 94 | "Subotica" => "024",
|
| 95 | "Uro.evac" => "0290",
|
| 96 | "U.ice" => "031",
|
| 97 | "Valjevo" => "014",
|
| 98 | "Vranje" => "017",
|
| 99 | "Zaje.ar" => "019",
|
| 100 | "Zrenjanin" => "023"
|
| 101 | );
|
| 102 |
|
| 103 | // Check for supported npa
|
| 104 |
|
| 105 | $validnpaRS = cisf_find_area($npalist_RS, $thenumber);
|
| 106 | }
|
| 107 |
|
| 108 | if($validnpaRS===false)
|
| 109 | {
|
| 110 | $number_error = true;
|
| 111 | }
|
| 112 |
|
| 113 | if($number_error===true)
|
| 114 | {
|
| 115 | if($debug)
|
| 116 | {
|
| 117 | print "Skipping Source - Not a valid or supported number: ".$thenumber."<br>\n";
|
| 118 | }
|
| 119 | }
|
| 120 | else
|
| 121 | {
|
| 122 | $referer="http://www.telekom.rs/WhitePages/SearchPage.asp?Mg=" . $validnpaRS['area_code'];
|
| 123 | $url="http://www.telekom.rs/WhitePages/ResultPage.asp";
|
| 124 | $post_data = array(
|
| 125 | 'Telefon'=>$validnpaRS['number'],
|
| 126 | 'Ulica'=>'',
|
| 127 | 'MG'=>$validnpaRS['area_code'],
|
| 128 | 'Ime'=>'',
|
| 129 | 'Broj'=>'',
|
| 130 | 'Mesto'=>'',
|
| 131 | 'Prezime'=>'',
|
| 132 | 'submit.x'=>'58',
|
| 133 | 'submit.y'=>'10'
|
| 134 | );
|
| 135 | $temp_cookie_file = tempnam("/tmp", "CURLCOOKIE");
|
| 136 |
|
| 137 | // Load the results page once to get some cookies set
|
| 138 | $temp = cisf_do_post_request($url,$post_data,$referer,$temp_cookie_file);
|
| 139 | // Load the results page again
|
| 140 | $value = cisf_do_post_request($url,$post_data,$referer,$temp_cookie_file);
|
| 141 | // Clean up the temp cookie file
|
| 142 | @unlink($temp_cookie_file);
|
| 143 |
|
| 144 | // Pull the name from the result
|
| 145 | $patternName = "/<img src='images\/linea\.jpg'><\/td><\/tr><TR><TD align='left'><b>(.*?)<\/b>/";
|
| 146 |
|
| 147 | // Look at named results first
|
| 148 | preg_match($patternName, $value, $names);
|
| 149 | $name = trim(strip_tags($names[1]));
|
| 150 |
|
| 151 | $notfound=false;
|
| 152 | if($name == '')
|
| 153 | {
|
| 154 | $notfound = true;
|
| 155 | }
|
| 156 |
|
| 157 | if($notfound)
|
| 158 | {
|
| 159 | $name="";
|
| 160 | }
|
| 161 |
|
| 162 | if(strlen($name) > 1)
|
| 163 | {
|
| 164 | $caller_id = strip_tags($name);
|
| 165 | }
|
| 166 | else if($debug)
|
| 167 | {
|
| 168 | print "not found<br>\n";
|
| 169 | }
|
| 170 | }
|
| 171 | }
|
| 172 |
|
| 173 | ?>
|
| 174 | |