<? 
if (array_key_exists("SCRIPT_FILENAME",$_SERVER))
{ $FilePath=str_replace("\\\\","/",$_SERVER["SCRIPT_FILENAME"]); }
else
{ $FilePath=str_replace("\\\\","/",$_SERVER["PATH_TRANSLATED"]); }

if (!(strrpos($FilePath,"/")===false))
{ $FilePath=substr($FilePath,0,strrpos($FilePath,"/")+1)."data/"; }

$AbsURL=$_SERVER["SCRIPT_NAME"];
if (!(strrpos($AbsURL,"/")===false))
{ $AbsURL="http://".$_SERVER["SERVER_NAME"].substr($AbsURL,0,strrpos($AbsURL,"/")+1); }

//---------------------------------------------------Load result file

$loaded=false;
if (file_exists($FilePath.$Pollname."_result.txt"))
{
 $loaded=true;
 $Opened=!(($fp=fopen($FilePath.$Pollname."_result.txt","r"))===false);
 $BlankLines=0;
 $Lines="";
 while($Opened && !feof($fp) && $BlankLines<20)
 {
  $Line=fgets($fp,1000);
  if (strlen($Line)<5 && strlen(trim($Line))<1)
  { $BlankLines++; continue; }
  else
  { $Lines.=$Line; $BlankLines=0; }
 }
 fclose($fp);
 if (strlen($Lines)>0) $result=json_decode($Lines, true);
 else $loaded=false;
}
else $loaded=false;
?>
