Exemplo n.º 1
0
<?php

require_once dirname(__FILE__) . '/config.php';
$user = getUser();
$password = getPassword();
$url = "https://{$user}:{$password}@sugtao4423.xyz/ServerStatus/receive.php";
$name = $argv[1];
switch ($name) {
    case xeon:
        $jsonArr = array("name" => $name, "sensors" => sensors(3, 6), "memory" => memory(3, 4), "process" => process());
        break;
    case git:
        $jsonArr = array("name" => $name, "sensors" => sensors(3, 6), "memory" => memory(2, 3), "process" => process());
        break;
    case micro:
    case raspi:
        $jsonArr = array("name" => $name, "memory" => memory(3, 4), "process" => process());
        break;
    case serverRoom:
        $result = serverRoom();
        $jsonArr = array("name" => $name, "temp" => $result[0], "hum" => $result[1], "pres" => $result[2]);
        break;
    case serverRoomPower:
        $jsonArr = array("name" => $name, "status" => serverRoomPower());
        break;
    default:
        die;
}
$json = json_encode($jsonArr);
$options = array('http' => array('method' => 'POST', 'content' => http_build_query(array($json))));
file_get_contents($url, false, stream_context_create($options));
Exemplo n.º 2
0
    die('<html lang="ja"><meta charset="utf-8">ログインが必要です。');
} else {
    if ($_SERVER['PHP_AUTH_USER'] != $user || $_SERVER['PHP_AUTH_PW'] != $password) {
        header('WWW-Authenticate: Basic realm="ServerStatusReceive Page."');
        header('HTTP/1.0 401 Unauthorized');
        die('<html lang="ja"><meta charset="utf-8">ログインが必要です。');
    }
}
$json = json_decode($_POST[0], true);
$name = $json['name'];
$date = date('Y-m-d H:i');
$db = new SQLite3(dirname(__FILE__) . "/database/" . $name . ".db");
switch ($name) {
    case xeon:
    case git:
        sensors();
        memory();
        process();
        break;
    case micro:
    case raspi:
        memory();
        process();
        break;
    case serverRoom:
        serverRoom();
        break;
    case serverRoomPower:
        serverRoomPower();
        break;
}
Exemplo n.º 3
0
    $results = mysql_query($query);
    if (mysql_num_rows($results) > 0) {
        $i = 1;
        echo "</br></br><h2>Sensors available</h2>";
        while ($row = mysql_fetch_assoc($results)) {
            //$id=$row['id'];
            $sensor = $row['name'];
            echo "<span style='color:#3B5998;font-weight:normal;'><b>" . $i . ".</b>&nbsp; &nbsp; <b>{$sensor} </b>&nbsp; &nbsp;<a href=" . "javascript:dels('{$sensor}')" . ">delete</a></span><hr>";
            $i++;
        }
    } else {
        echo "</br><div class='notice'><b>No Sensors added yet.</b></div>";
    }
}
if ($macid != null) {
    echo "<span id='{$macid}' style='color:#3B5998;font-weight:normal;'>&nbsp;<b>Allot group and sensor type</b>  </br><b>&nbsp; &nbsp;</b><input type='text' name='dname' id='dname'> <b>Name </b></br><b>MAC id:</b> {$macid} &nbsp; &nbsp; " . groups() . "&nbsp;" . sensors() . "<button id='{$macid}' type='button' onclick=" . "update('{$macid}')" . ">Update</button></span><hr>";
}
if ($update != null) {
    mysql_select_db($dbname) or die(mysql_error());
    $query = "SELECT name FROM groups WHERE id='{$gid}'";
    $grps = mysql_query($query);
    $grp = mysql_fetch_assoc($grps);
    $name = $grp['name'];
    if ($name == '') {
        $name = "<span style='color: #0088FF;'><b>New Device Found</b></span>";
    }
    $query = "UPDATE devices SET devices.group = '{$gid}', devices.status='1', devices.name='{$dname}', devices.type='{$sentyp}' WHERE devices.macid = '{$update}'";
    //updating item with group id
    if (!mysql_query($query, mysql_connect($dbhost, $dbuser, $dbpass))) {
        echo "UPDATE failed: {$query}<br/>" . mysql_error() . "<br/><br/>";
    }