//The complete free software package may be dowloaded from http://tyaga.org/kit/.
<?php
//header('Content-type: text/plain');

//returns search query convention and reporter
function get_reporter($icb,$units,$request_content="") { 
  
$timeout stream_context_create(array('http' => array('timeout'=>2))); 
  
$home_page file_get_contents("http://"$icb ."/",0,$timeout);   
  
$splitter urlencode("set "$icb ." reporter."$units ." to "); //echo "splitter: ". $splitter ."<br >";
  
$contents explode($splitter,$home_page); //echo $splitter ."<br />". $home_page;
    
  
if (count($contents)==2) {
    
$gt_pos=strpos($contents[1],">");
    
$reporter=substr($contents[1],0,$gt_pos-1); //echo "rep: ". $reporter ." ";
      
    //get search query convention
    
$contents=explode("http://"$icb ."/",$contents[0]);
    if (
count($contents)>1) {
      
$search_q=end($contents);
    } 
//echo "search_q, reporter: ". $search_q .",", $reporter ."!!<br>";
  

  
  if (
$request_content==1) {
    return array(
$search_q,$reporter,$home_page);
  }
  else {
    return array(
$search_q,$reporter);
  }
}

function 
verify_record($icb,$units,$record,$icb_list) { 
  if (!
$icb_list[$icb]) {
    list(
$search_q,$reporter,$contents) = get_reporter($icb,$units,1);
    
$icb_list array_merge($icb_list,array($icb=>$search_q .","$reporter));
  }
   
  if (
strpos($contents,$record)!==false) {
    return array(
true,$icb_list);
  }
  else {
    list(
$search_q,$reporter) = explode(",",$icb_list[$icb]);  
    
    if (
$search_q) {
      
$encoded_record urlencode($record);
    }
  
    
$timeout stream_context_create(array('http' => array('timeout'=>2)));
    
$contents file_get_contents("http://"$icb ."/"$search_q $encoded_record,0,$timeout);
    
    if (
strpos($contents,$record)===false) {
      return array(
false,$icb_list);
    }
    else {
      return array(
true,$icb_list);
    }
  }
}
?>
1