<?php
include('../includes/common.inc.php');
checkReferrer() or die();
$toReturn = array();

exec("sudo timeout 6 moonlight list", $cmd);
$i=0;
foreach( $cmd as $item ){
    if( is_numeric(substr($item,0,1)) ){
		$i++;
		$game = substr( $item, 3, strlen($item) );
		$toReturn[] = array(
			'id'	=> $i,
			'name'	=> $game
		);
	}
}
die(json_encode($toReturn));
?>