<?php
//
// Copyright 2014 - 2018 x-odos GmbH
//

$get 	= $_GET['get'];
$code 	= 0;
$found 	= 0;

function report_error($code){

	if ( $code == 0 ) {
		$com = "Ich kann so nicht arbeiten... ";
	}
	if ( $code == 5) {
		$com = "wrong call!";
	}
	$comment = array (
		'return' => $com,
	);
	echo json_encode($comment);
}

function get_serial($search){
	$filename	= 'info.data';
	// Read from file
	$lines = file($filename);
	foreach($lines as $line) {
  		// Check if the line contains the string we're looking for, and print if it does
  		if(strpos($line, $search) !== false) {
  			echo $line;
  			$found = 1;
    		//$array = explode("\t", $line);
    		//echo json_encode($array);	
    	}
	}
	if ( $found == 0 ) {
    	echo $search."\t"."0"."\t"."0"."\t"."0"."\t"."0"."\t"."0";
    }
}
$arr = explode("-", $get);
if ( $get == null 	) {
	report_error($code);
} else {
	if (count($arr) == 5 ) {
		get_serial($get);
	} else {
		report_error(5);
	}
}
?>