コード例 #1
0
foreach ($_POST as $k => $v) {
    if ($k == "dummy") {
        continue;
    }
    //		if ($k == "ow_280cd781040000a4")
    //			$k = "ow_purple";
    if ($rec != "") {
        $rec .= ",";
        $types .= ",";
    }
    $rec .= $k . ":\"" . $v . "\"";
    $types .= $k;
    $transfer .= $k . "=" . $v . "&";
}
$rec = "add({timestamp:" . $ts . ", time:\"" . getTs() . "\", ip:\"" . $ip . "\", args:{" . $rec . "}});\n";
$f = fopen("data/" . getCurrent(), "a");
fwrite($f, $rec);
//echo $rec;
fclose($f);
$f = fopen("devices/" . $mac . ".txt", "w");
fwrite($f, "addDevice({ip:\"" . $ip . "\", mac:\"" . $mac . "\", type:\"" . $type . "\", platform:\"" . $platform . "\", last:" . $ts . ", sensors:\"" . $types . "\"});\n");
fclose($f);
$f = fopen("devices/" . $mac . ".last", "w");
fwrite($f, $rec);
fclose($f);
$relay = "http://agro.valky.eu/sklenik/remote.php";
echo file($relay . "?" . $transfer . "mac=" . $mac);
echo "Ok.";
function getCurrent()
{
    return date("Y-m-d") . ".txt";
コード例 #2
0
ファイル: add.php プロジェクト: keszegrobert/Work-in-progress
<?php

//error_reporting(E_ALL);
$rec = "";
foreach ($_GET as $k => $v) {
    if ($rec != "") {
        $rec .= ",";
    }
    $rec .= $k . ":\"" . $v . "\"";
}
$lhash = calchash($_SERVER["QUERY_STRING"]);
$valid = $lhash == $_GET["hash"] ? "1" : "0";
$rec = "add({ts:" . time() . ", date:\"" . getmDate() . "\", time:\"" . getmTime() . "\", ip:\"" . $_SERVER["REMOTE_ADDR"] . "\", valid:" . $valid . ", args:{" . $rec . "}});\n";
$f = fopen(getCurrent(), "a");
fwrite($f, $rec);
//echo $rec;
fclose($f);
echo "Ok.";
function getCurrent()
{
    return date("Y-m-d") . ".txt";
}
function getTs()
{
    return date("Y-m-d H:i:s");
}
function getmDate()
{
    return date("Y-m-d");
}
function getmTime()
コード例 #3
0
ファイル: index.php プロジェクト: skubij/omxplayer-ui
function getStatus()
{
    $app = Slim\Slim::getInstance();
    $app->contentType('application/json');
    $playing = getCurrent();
    //$log = $app->getLog();
    //$log->info("-> getStatus " + $playing);
    $root_dir = getOption('root');
    exec('pgrep omxplayer.bin', $pids);
    $body = array();
    $body['running'] = empty($pids) ? false : true;
    if ($playing && !empty($pids)) {
        $playing = trim($playing);
        $file = str_replace($root_dir . "/", "", $playing);
        if (getOption("id3")) {
            $au = new AudioInfo();
            $audioinfo = $au->Info($root_dir . "/" . $playing);
            //print_r($audioinfo);
            if (isset($audioinfo['comments']['artist'])) {
                $body['artist'] = $audioinfo['comments']['artist'][0];
            }
            if (isset($audioinfo['comments']['title'])) {
                $body['title'] = $audioinfo['comments']['title'][0];
            }
            if (isset($audioinfo['comments']['album'])) {
                $body['album'] = $audioinfo['comments']['album'][0];
            }
            if (isset($audioinfo['comments']['genre'])) {
                $body['genre'] = $audioinfo['comments']['genre'][0];
            }
            if (isset($audioinfo['comments']['track'])) {
                $body['track'] = $audioinfo['comments']['track'][0];
            }
            if (isset($audioinfo['comments']['year'])) {
                $body['year'] = $audioinfo['comments']['year'][0];
            }
            if (isset($audioinfo["playtime_string"])) {
                $body['playtime'] = $audioinfo["playtime_string"];
            }
            if (isset($audioinfo["format_name"])) {
                $body['format'] = $audioinfo["format_name"];
            }
            if (isset($audioinfo["bitrate_mode"])) {
                $body['bitrate_mode'] = $audioinfo["bitrate_mode"];
            }
            if (isset($audioinfo["bitrate"])) {
                $body['bitrate'] = $audioinfo["bitrate"];
            }
            if (isset($audioinfo['video']['resolution_x']) && isset($audioinfo['video']['resolution_y'])) {
                $body['resolution'] = $audioinfo['video']['resolution_x'] . "x" . $audioinfo['video']['resolution_y'];
            }
        }
        $file = str_replace($root_dir . "/", "", $playing);
        $body['file'] = end(explode("/", $playing));
        $body['link'] = $file;
    }
    echo json_encode($body);
    $response = $app->response();
    $response["Cache-Control"] = "max-age=5";
}