} else { badReq('missing appid'); } } else { if (isset($_REQUEST['appid'])) { //If the file does not exist, we will get FALSE as the $rval $rval = loadJSON(dpathFor($_REQUEST['appid']), false); if ($rval) { if (count($rval['payload']) == 0) { //empty object which PHP will incorrectly send down ad an array echo jsonOut(json_encode($rval, JSON_FORCE_OBJECT)); } else { echo jsonOut(json_encode($rval)); } } else { //Of course the below does not work in PHP 5.2! //http_response_code(404); //THIS f*****g hack should work on Chumbster $sapi_type = php_sapi_name(); if (substr($sapi_type, 0, 3) == 'cgi') { header("Status: 404 Not Found"); } else { header("HTTP/1.1 404 Not Found"); } //TODO CHumby F**K, of course JSON_FORCE_OBJECT is not PHP 5.2 echo json_encode(array('error' => 'no data for that app'), JSON_FORCE_OBJECT); } } else { badReq('missing appid'); } }
<?php /** * OVERPLAY APPS OS ENDPOINT * Port of NodeJS version */ ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); require '../shared/shared.php'; require '../shared/messaging.php'; require '../shared/apps.php'; if (isset($_REQUEST['command'])) { $cmd = $_REQUEST['command']; switch ($cmd) { //In place of "isMain" in Node case 'getlauncher': $launcher = array("name" => "App Picker", "appType" => "fullscreen", "reverseDomainName" => "io.overplay.apppicker", "buildNumber" => 1, "onLauncher" => false, "isMain" => true, "size" => array("width" => 100, "height" => 100), "publisher" => "overplay.io"); echo json_encode($launcher); break; case 'userapps': $rval = array(); foreach (installedApps() as $key => $value) { array_push($rval, $value); } echo json_encode($rval); break; } } else { badReq('no test parameter'); }
} } else { badReq('Wrong verb or no appid'); } break; case 'move': if (isPOST() && isset($_REQUEST['appid'])) { $res = moveApp($_REQUEST['appid']); header('Content-Type: application/json'); jsonOut(json_encode($res)); } else { badReq('Wrong verb or no appid'); } break; case 'moveToSlot': if (isPOST() && isset($_REQUEST['appid']) && isset($_REQUEST['slot'])) { $res = moveAppToSlot($_REQUEST['appid'], $_REQUEST['slot']); header('Content-Type: application/json'); jsonOut(json_encode($res)); } else { badReq('Wrong verb or no appid or no slot, dick ' . $_REQUEST['appid']); } break; case 'appsbystate': header('Content-Type: application/json'); jsonOut(json_encode(appsByState())); break; } } else { badReq('no command parameter, dipshit'); }