//The complete free software package may be dowloaded from http://tyaga.org/kit/.
<?php
          
        $param 
$record['param']; //print_r($record);
        
$sub_param $record['sub_param'];
        
$param_value $record['param_value'];     
        
        if (
$param=="lastReport") {         
          if (
$sub_param==".period"  AND !$last_report) {
            
$period rtrim($param_value,".");
           
            if (!
$reporter) { //echo " uo ";
              
list($search_q,$reporter) = get_reporter($main_icb,$native_units);
            }
            
            if (
$reporter) {
              
$report_url "http://"$reporter ."/?prowl=get+"$main_icb ."+"$native_units ."+report+for+"$period//echo "report_url: ". $report_url;
              
$timeout stream_context_create(array('http' => array('timeout'=>2)));        
              
$last_report = @file_get_contents($report_url,0,$timeout); //echo "last report: ". $last_report;
              
              
if (!$last_report) {
                
$set_verify "The reporter did not return any matching reports.";
              }
              else {
                list(
$last_mssg,$last_version,$last_model_indicator,$last_model_name,$last_main_icb,$last_year,$last_units,$last_status,$last_content) = prowl_content($last_report,$main_icb,$native_units,$period);
                                   
                if (
$last_mssg) {
                  
$set_verify $last_mssg;
                }
                else {
                  
$set_verify "Verified";                  
                }
              }            
            }
            else {
              
$set_verify "The last report can not be located. Missing or malformed reporter declaration string on "$main_icb ." home page.";
            }
          }
          else if (
$sub_param==".SHA1") {
            
$set_sha1 rtrim($param_value,".");          
            
$report_sha1 sha1($last_report);
              
            if (
$report_sha1==$set_sha1) {
              
$set_verify "<a href='"$report_url ."'>Verified</a>";                        
            }
            else {
              
$set_verify "The set-sha1 did not match the calculated sha1 digest of the <a href='"$report_url ."'>last report</a>. ("$report_sha1 .")";
              
$create=0$revert=0$outflow=0$inflow=0$cr_bal=0$db_bal=0$headcount=0;   
            }
                       
          }
          else if (
$sub_param==".filesize") {
            
$set_filesize rtrim($param_value,".");
            
$units trim(substr(next($record),0,-1));
            
$report_filesize strlen($last_report);
            
            if (
$report_filesize==$param_value) {
              
$set_verify "<a href='"$report_url ."'>Verified</a>";
            }
            else {
              
$set_verify "The set-filesize did not match the calculated filesize of the <a href='"$report_url ."'>last report</a>. ("$report_filesize .")";
            }
          }       
        }        
        else if (
$param=="unusedBudget") {          
          
$tally_record explode("-12-31 tally unusedBudget"$sub_param ." ",$last_report);
          
$tally_record explode(" ",end($tally_record)); //echo "<br />tally_record[0] = ". $tally_record[0];
          
          
if ($tally_record[0] == $param_value) { 
            
$set_verify "<a href='"$report_url ."'>Verified</a>";
          }
          else {
            
$set_verify "The unusedBudget"$sub_param ." should be set to the last tallied value of <a href='"$report_url ."'>"number_format($tally_record[0],2) ."</a>.";
          }  
            
          if (
$sub_param==".revenueBal") {
            
$db_bal=$tally_record[0];
            
$start_db=$tally_record[0];
          }
          else if (
$sub_param==".expenseBal") {
            
$cr_bal=$tally_record[0];
            
$start_cr=$tally_record[0];
          }         
        }        
        else if (
$param=="headCount") {  
          
$tally_record explode("-12-31 tally headCount ",$last_report);
          
$tally_record explode(" ",trim(end($tally_record))); 
            
          if (
$param_value==$tally_record[0]) {
            
$headcount $param_value;
            
$set_verify "<a href='"$report_url ."'>Verified</a>";  
          }
          else { 
            
$set_verify "The headCount should be set to the last tallied value of <a href='"$report_url ."'>"$tally['headcount'] ."</a>.";            
          }
        }
        else if (
$param=="netBalance") { 
          
$tally_record explode("-12-31 tally netBalance ",$last_report);
          
$tally_record explode(" ",trim(end($tally_record)));
                    
          if (
$tally_record[0] == $param_value) { 
            
$set_verify "<a href='"$ref_link ."'>Verified</a>";
            
$net_bal $param_value;  
            
$start_net_bal=$param_value;
          }
          else {
            
$set_verify "The netBalance should be set to the last tallied value of <a href='"$report_url ."'>"number_format($tally_record[0],2) ."</a>.";
          }
        } 
      
?>
1