require_once '../BoxeeBoxPHPJSONRPC.class.php';
# Handle specified action
if (isset($_REQUEST['action']) && isset($_REQUEST['hostname']) && isset($_REQUEST['deviceid'])) {
    # Catch Exceptions
    try {
        # Connect to BoxeeBox
        $bb = new BoxeeBoxPHPJSONRPC($_REQUEST['hostname']);
        $bb->Device('Connect', $_REQUEST['deviceid']);
        # Extract action
        $action = $_REQUEST['action'];
        # Extract url (if set)
        $value = isset($_REQUEST['value']) ? $_REQUEST['value'] : '';
        # Call appropriate API method
        switch ($action) {
            case 'Home':
                $bb->Input('Home');
                break;
            case 'MouseClick':
                $bb->Input('MouseClick');
                break;
            case 'Back':
                $bb->Input('Back');
                break;
            case 'Up':
                $bb->Input('Up');
                break;
            case 'Down':
                $bb->Input('Down');
                break;
            case 'Left':
                $bb->Input('Left');