echo "INVALID ROOM"; $smarty->assign("error", "<p>Try again, that room is invalid."); $smarty->display('error.tpl'); die; } $sql = "SELECT roomname,floorid FROM rooms WHERE roomid='{$roomid}' limit 1"; $result2 = $conn->query($sql); $num_rows = mysqli_num_rows($result2); if ($num_rows < 1) { $smarty->assign("error", "<p>That Room does not exist, mayby another manager removed it?"); $smarty->display('error.tpl'); die; } $row2 = $result2->fetch_assoc(); $roomname = $row2['roomname']; $floorid = $row2['floorid']; $sql = "DELETE FROM rooms WHERE roomid='{$roomid}' LIMIT 1"; if ($conn->query($sql) === TRUE) { log2db("ROOM", "DELETE", $roomid, $roomname); $deleteroom['id'] = $roomid; $pubnub->setAuthKey($key); print_r($pubnub->publish('room_delete', $deleteroom)); $url = "manager_floor.php?id={$floorid}"; header("Location: {$url}"); die; } else { echo "Error deleting record: " . $conn->error; $smarty->assign("error", "<p>Something went wrong, mayby you refreshed and tried to delete twice?, or did someone else delete this room? <p>Please also check that there are no devices in this room."); $smarty->display('error.tpl'); die; }
if (empty($floorid)) { echo "INVALID FLOOR"; $smarty->assign("error", "<p>Try again, that floor is invalid."); $smarty->display('error.tpl'); die; } $sql = "SELECT floor FROM floors WHERE floorid='{$floorid}' limit 1"; $result2 = $conn->query($sql); $num_rows = mysqli_num_rows($result2); if ($num_rows < 1) { $smarty->assign("error", "<p>That floor does not exist, mayby another manager removed it?"); $smarty->display('error.tpl'); die; } $row2 = $result2->fetch_assoc(); $floorname = $row2['floor']; $sql = "DELETE FROM floors WHERE floorid='{$floorid}'"; if ($conn->query($sql) === TRUE) { log2db("FLOOR", "DELETE", $floorid, $floorname); $deletefloor['id'] = $floorid; $pubnub->setAuthKey($key); print_r($pubnub->publish('floor_delete', $deletefloor)); $url = "managerfunctions.php"; header("Location: {$url}"); die; } else { echo "Error deleting record: " . $conn->error; $smarty->assign("error", "<p>Something went wrong, mayby you refreshed and tried to delete twice?, or did someone else delete this floor? <p>Please also check that there are no rooms on this floor."); $smarty->display('error.tpl'); die; }
<?php require_once 'config.php'; require_once 'loginneeded.php'; require_once 'manageronly.php'; $assignid = $_GET['id']; if (empty($assignid)) { echo "INVALID assign"; $smarty->assign("error", "<p>Try again, that user assign pair is invalid."); $smarty->display('error.tpl'); die; } $sql = "DELETE FROM room_assigns WHERE room_assign_id='{$assignid}' LIMIT 1"; $floorid = $_GET['floorid']; if ($conn->query($sql) === TRUE) { log2db("ASSIGN", "DELETE", $assignid, ''); $deleteassign['id'] = $assignid; $pubnub->setAuthKey($key); print_r($pubnub->publish('assign_delete', $deleteassign)); $url = "manager_floor.php?id={$floorid}"; header("Location: {$url}"); die; } else { echo "Error deleting record: " . $conn->error; $smarty->assign("error", "<p>Something went wrong, mayby you refreshed and tried to delete twice?, or did someone else delete this assign? <p>Please also check that there are no devices in this assign."); $smarty->display('error.tpl'); die; }
<?php /** * PC Audit * (C) Gregory Oakley-Stevenson * @package pcaudit */ require_once 'config.php'; require_once 'loginneeded.php'; $floorid = $_GET['floorid']; $roomid = $_POST['room_id']; $a_userid = $_POST['userform']; if (empty($a_userid)) { $smarty->assign("error", "<p>Please select a user before clicking add.</p>"); $smarty->display('error.tpl'); die; } else { $sql = "INSERT INTO room_assigns (roomid,userid) VALUES ('{$roomid}','{$a_userid}')"; if (mysqli_query($conn, $sql)) { $assignid = mysqli_insert_id($conn); log2db("ASSIGN", "ADD", $assignid, ''); $url = "manager_floor.php?id={$floorid}"; header("Location: {$url}"); die; } else { echo "Error: " . $sql . "<br>" . mysqli_error($conn); $smarty->assign("error", "<p>Could not assign user, please check if user is allready assigned to this room.</p>"); $smarty->display('error.tpl'); die; } }
/** * PC Audit * (C) Gregory Oakley-Stevenson * @package pcaudit */ require_once 'config.php'; require_once 'loginneeded.php'; if ($_SERVER['REQUEST_METHOD'] == 'POST') { $floor_name = $_POST['floor_name']; if (empty($floor_name)) { $smarty->assign("error", "<p>Floor name cannot be empty</p>"); $smarty->display('error.tpl'); die; } else { $sql = "INSERT INTO floors (floor) VALUES ('{$floor_name}')"; if (mysqli_query($conn, $sql)) { $floorid = mysqli_insert_id($conn); log2db("FLOOR", "ADD", $floorid, $floor_name); $url = "manager_floor.php?id={$floorid}"; header("Location: {$url}"); die; } else { echo "Error: " . $sql . "<br>" . mysqli_error($conn); $smarty->assign("error", "<p>Could not add floor, please check if it exists(someone may have only just this second added it)</p>"); $smarty->display('error.tpl'); die; } } die; }
/** * PC Audit * (C) Gregory Oakley-Stevenson * @package pcaudit */ require_once 'config.php'; require_once 'loginneeded.php'; if ($_SERVER['REQUEST_METHOD'] == 'POST') { $room_name = $_POST['room_name']; $floor_id = $_POST['floor_id']; if (empty($room_name)) { $smarty->assign("error", "<p>Room name cannot be empty</p>"); $smarty->display('error.tpl'); die; } else { $sql = "INSERT INTO rooms (roomname,floorid) VALUES ('{$room_name}','{$floor_id}')"; if (mysqli_query($conn, $sql)) { $roomid = mysqli_insert_id($conn); log2db("ROOM", "ADD", $roomid, $room_name); $url = "manager_room.php?id={$roomid}"; header("Location: {$url}"); die; } else { echo "Error: " . $sql . "<br>" . mysqli_error($conn); $smarty->assign("error", "<p>Could not add floor, please check if it exists(someone may have only just this second added it)</p>"); $smarty->display('error.tpl'); die; } } die; }