//if the user is editting or viewing a device ID, check if there is an update being made. If there are no updates then show them the client information form. if ($_GET['action'] == edit && $_SESSION['access'] >= 50 || $_GET['action'] == showID) { //get the new device corresponding to the ID $devices = new Device($_GET['ID']); $id = $devices->get_device_id(); //if this is a port we're editting get that ID instead if (isset($_POST['portID'])) { $ports = new ControlPort($_POST['portID']); } //checks to see if this is a valid ID or not if ($devices->get_device_id() == "") { $deviceForm->error("Warning: Failed to load. Reason: " . $devices->get_error(), $_GET['ID']); } //if this is an update then update the device or port if (isset($_POST['updateInfo']) && $_SESSION['access'] >= 50) { updateDevice($devices); } else { if (isset($_POST['updatePort'])) { updatePort($ports, $id); } else { if (isset($_POST['addPort']) && $_SESSION['access'] >= 50) { addPort($id); } else { displayDevice($devices); } } } } else { if ($_GET['action'] == "list_device_types") { displayDeviceTypes(); } else {
<?php $json_signin_data = file_get_contents('php://input'); $user_data = json_decode($json_signin_data); require '../connection.php'; require 'functions.php'; if ($user_data->User != '' && $user_data->IMEI != '' && $user_data->Type != '') { $updateDeviceKey = updateDevice($user_data, $conn); if ($updateDeviceKey == 10012) { $response = array('ResponseCode' => 10012, 'ResponseText' => 'Device updated successfully'); echo json_encode($response); } elseif ($updateDeviceKey == 10005) { $response = array('ResponseCode' => 10005, 'ResponseText' => 'Database error'); echo json_encode($response); } } else { $response = array('ResponseCode' => 10000, 'ResponseText' => 'Empty fields'); echo json_encode($response); }
*/ require_once "../database/database.php"; require_once "../database/devices.php"; require_once "../model/device.php"; if (!isset($_POST['txtDeviceId']) || !isset($_POST['txtDeviceName']) || !isset($_POST['txtDeviceHostname']) || !isset($_POST['txtDevicePort'])) { //Exit if a list of devices wasn't provided exit; } //Get the device ID $id = $_POST['txtDeviceId']; //Get the device name $name = $_POST['txtDeviceName']; //Get the device $hostname = $_POST['txtDeviceHostname']; //Get the list of devices that the user wants to add to the database $port = $_POST['txtDevicePort']; //Check to see if the user included a description. If not, create an empty string if (isset($_POST['txtDeviceDesc']) && !empty($_POST['txtDeviceDesc'])) { $description = $_POST['txtDeviceDesc']; } else { $description = ""; } //Check to see if the user included a roomId. If not, place the device in the unknown room if (isset($_POST['txtDeviceRoomId']) && !empty($_POST['txtDeviceRoomId'])) { $roomId = $_POST['txtDeviceRoomId']; } else { $roomId = "1"; } //Update the devices in the database echo updateDevice($id, $roomId, $name, $description, $hostname, $port);