Example #1
0
/**
 * 公共函数
 */
function outputListData($data)
{
    if (is_array($data)) {
        outputData(array('total' => count($data), 'rows' => $data));
    } else {
        outputData($data);
    }
}
Example #2
0
function getVariable($varname)
{
    global $DEVICEID, $ACCESS_TOKEN;
    $url = "https://api.particle.io/v1/devices/" . $DEVICEID . "/" . $varname . "?access_token=" . $ACCESS_TOKEN;
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    $response = curl_exec($ch);
    $sc = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    if ($sc != 200) {
        throw new Exception(sprintf("HTTP CODE: %s", $sc));
    }
    $json = json_decode($response, true);
    outputData(json_encode(array('status' => 1, $json['name'] => $json['result'])));
}
                    }
                } else {
                    bailOut(true);
                }
                exit;
        }
    } else {
        bailOut(false);
    }
}
// standard-action
$action = @trim($_REQUEST["a"]);
switch ($action) {
    case "0":
        // news
        outputData(rewriteNews(getDataFromFile(_FILE_NEWS)));
        exit;
    case "1":
        // changelog
        outputData(getDataFromFile(_FILE_CHANGELOG));
        exit;
    case "2":
        // issues
        outputData(getDataFromFile(_FILE_ISSUES));
        exit;
    default:
        header("Content-Type: text/plain");
        echo trim(getDataFromFile(_FILE_VERSION_CURRENT));
        exit;
}
exit;
Example #4
0
                    while (!@feof($handle) && connection_status() == 0) {
                        print @fread($handle, 8192);
                        @flush();
                    }
                    @fclose($handle);
                } else {
                    bailOut(false);
                }
                exit;
        }
    } else {
        bailOut(false);
    }
}
// standard-action
$action = @trim($_REQUEST["a"]);
switch ($action) {
    case "0":
        // news
        outputData(rewriteNews(getDataFromFile(_FILE_NEWS)));
        exit;
    case "1":
        // changelog
        outputData(getDataFromFile(_FILE_CHANGELOG));
        exit;
    default:
        header("Content-Type: text/plain");
        echo trim(getDataFromFile(_FILE_VERSION_CURRENT));
        exit;
}
exit;