<?

require 'mysqlconnect.inc.php';
require 'tools.php';

if(IsSet($_GET['param1'])) $machineid = $_GET['param1'];
if(IsSet($_GET['param'])) $path = $_GET['param'];
	$machinetable = $GLOBALS['machinetable'];
	$query = "SELECT iplocation from $machinetable where id='$machineid'";
	$result = mysql_fetch_assoc(mysql_query($query));
	$ip = $result['iplocation'];

	$conn = retConnection($ip);
        $command = "cat $path";
        $stream = ssh2_exec($conn, $command);
        //fwrite($stream, $command);
        sleep(1);
	header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
	header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
        while($line = fgets($stream)) {
                flush();
                echo $line."<br />";
        }
        fclose($stream);

//	echo "machine: ".$machineid;
//	echo "ip: ".$ip;
//	echo "path: ".$path;
	

?> 
