Static ip generator :)
This commit is contained in:
parent
9e6968bf6c
commit
7337e3c7d9
2
api.php
2
api.php
@ -189,6 +189,7 @@ if ($values != null || $values != "") {
|
||||
$jsonAnswer = [
|
||||
'device' => [
|
||||
'hostname' => $hostname,
|
||||
'ipAddress' => $device['ip_address'],
|
||||
],
|
||||
'state' => 'succes',
|
||||
];
|
||||
@ -223,6 +224,7 @@ if ($values != null || $values != "") {
|
||||
'device' => [
|
||||
'hostname' => $device['name'],
|
||||
'sleepTime' => $device['sleep_time'],
|
||||
'ipAddress' => $device['ip_address'],
|
||||
],
|
||||
'state' => 'succes',
|
||||
'value' => $subDeviceLastReordValue
|
||||
|
@ -23,9 +23,11 @@ class DeviceManager{
|
||||
}
|
||||
|
||||
public function create ($name, $token) {
|
||||
$defaultRoom = RoomManager::getDefaultRoomId();
|
||||
$device = array (
|
||||
'name' => $name,
|
||||
'token' => $token,
|
||||
'room_id' => $defaultRoom,
|
||||
);
|
||||
try {
|
||||
Db::add ('devices', $device);
|
||||
|
18
app/class/NetworkManager.php
Normal file
18
app/class/NetworkManager.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class NetvorkManager
|
||||
{
|
||||
|
||||
function __construct()
|
||||
{
|
||||
// code...
|
||||
}
|
||||
|
||||
function validateIp($ip = '0.0.0.0'){
|
||||
if (!filter_var($ip, FILTER_VALIDATE_IP)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -2,6 +2,11 @@
|
||||
class RoomManager{
|
||||
public static $rooms;
|
||||
|
||||
function getDefaultRoomId() {
|
||||
$defaultRoom = Db::loadOne("SELECT id FROM rooms WHERE default = 1");
|
||||
return $defaultRoom['id'];
|
||||
}
|
||||
|
||||
function getAllRooms () {
|
||||
$allRoom = Db::loadAll ("SELECT rooms.*, COUNT(devices.device_id) as device_count FROM rooms LEFT JOIN devices ON (devices.room_id=rooms.room_id) GROUP BY rooms.room_id");
|
||||
return $allRoom;
|
||||
|
@ -157,6 +157,7 @@ class Home extends Template
|
||||
'room' => $deviceData['room_id'],
|
||||
'token' => $deviceData['token'],
|
||||
'type' => $deviceData['type'],
|
||||
'ip' => $deviceData['ip_address'],
|
||||
'sleepTime' => $deviceData['sleep_time'],
|
||||
'approved' => $deviceData['approved'],
|
||||
'permission' => $permissionArray,
|
||||
|
Loading…
Reference in New Issue
Block a user