Esempio n. 1
0
function setIframePositions()
{
    //Do the widgets first
    $sm = screenMap();
    //TODO HACK ALERT implement screen size feedback
    $screenRect = loadJSON("screenRect", array("width" => 1920, "height" => 1080));
    for ($widx = 0; $widx < count($sm["widgetAppMap"]); $widx++) {
        if (!$sm['widgetAppMap'][$widx]) {
            continue;
        }
        $sm['widgetAppMap'][$widx]['location'] = array("top" => 0, "left" => 0);
        //TODO implement server side nudge
        //var nudge = {
        //top:
        //0, left: 0 };
        $nudge = array("top" => 0, "left" => 0);
        switch ($widx) {
            case 0:
                $sm['widgetAppMap'][$widx]['location']['top'] = floor(0.05 * $screenRect['height']) + $nudge['top'] . 'px';
                $sm['widgetAppMap'][$widx]['location']['left'] = floor(0.03 * $screenRect['width']) + $nudge['left'] . 'px';
                break;
            case 1:
                $sm['widgetAppMap'][$widx]['location']['top'] = floor(0.05 * $screenRect['height']) + $nudge['top'] . 'px';
                $sm['widgetAppMap'][$widx]['location']['left'] = floor(0.85 * $screenRect['width']) + $nudge['left'] . 'px';
                break;
            case 2:
                $sm['widgetAppMap'][$widx]['location']['top'] = floor(0.6 * $screenRect['height']) + $nudge['top'] . 'px';
                $sm['widgetAppMap'][$widx]['location']['left'] = floor(0.85 * $screenRect['width']) + $nudge['left'] . 'px';
                break;
            case 3:
                $sm['widgetAppMap'][$widx]['location']['top'] = floor(0.6 * $screenRect['height']) + $nudge['top'] . 'px';
                $sm['widgetAppMap'][$widx]['location']['left'] = floor(0.03 * $screenRect['width']) + $nudge['left'] . 'px';
                break;
        }
    }
    //Do the crawler next
    for ($cidx = 0; $cidx < count($sm["crawlerAppMap"]); $cidx++) {
        if (!$sm['widgetAppMap'][$cidx]) {
            continue;
        }
        $sm['widgetAppMap'][$cidx]['location'] = array("top" => 0, "left" => 0);
        //TODO implement server side nudge
        //var nudge = {
        //top:
        //0, left: 0 };
        $nudge = array("top" => 0, "left" => 0);
        //HARD CODE for DEMO
        $sm['widgetAppMap'][$cidx]['location']['left'] = '0px';
        switch ($cidx) {
            case 0:
                $sm['widgetAppMap'][$cidx]['location']['top'] = floor(0.89 * $screenRect['height']) . $nudge['top'] . 'px';
                break;
            case 1:
                $sm['widgetAppMap'][$cidx]['location']['top'] = floor(0.03 * $screenRect['height']) . $nudge['top'] . 'px';
                break;
        }
    }
    if (count($sm['fullScreenAppMap']) > 0) {
        $sm['fullScreenAppMap'][0]['location'] = array("top" => 0, "left" => 0);
    }
    saveJSON("screenMap", $sm);
}
Esempio n. 2
0
/**
 * Created by PhpStorm.
 * User: mkahn
 * Date: 1/18/16
 * Time: 3:13 PM
 */
function loadMessages($forDest)
{
    $appMessages = loadJSON("messages/" . $forDest, array());
    return $appMessages;
}
Esempio n. 3
0
    }
} elseif (isDELETE()) {
    if (isset($_REQUEST['appid'])) {
        $rmRes = rmJSON(dpathFor($_REQUEST['appid']));
        if ($rmRes) {
            echo 'deleted';
        } else {
            badReq('No data for that app');
        }
    } 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 {
Esempio n. 4
0
     break;
     //Think this is not used anyway
 //Think this is not used anyway
 case 'ipaddress':
     if (isGET()) {
         $rval = array("ip" => $_SERVER['SERVER_ADDR']);
         jsonOut(json_encode($rval));
     } else {
         badReq('GET only');
     }
     break;
     //TODO implement post to set identity
 //TODO implement post to set identity
 case 'identify':
     if (isGET()) {
         $sysinfo = loadJSON('/system/sysinfo', array("name" => "Not Named", "location" => "Not Set"));
         jsonOut(json_encode($sysinfo));
     } else {
         badReq('GET only');
     }
     break;
 case 'reset':
     if (isPOST()) {
         array_map('unlink', glob("../data/appdata/*.json"));
         array_map('unlink', glob("../data/messages/*.json"));
         array_map('unlink', glob("../data/*.json"));
         jsonOut(json_encode(array("cool" => "beans")));
     } else {
         badReq('POST only');
     }
     break;