Added editor for system meta data
This commit is contained in:
@@ -123,4 +123,42 @@ a#nav-sysinfo-tab{
|
|||||||
}
|
}
|
||||||
th.meta {
|
th.meta {
|
||||||
padding-left: 0px;
|
padding-left: 0px;
|
||||||
|
}
|
||||||
|
.form-group>label {
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
.split {
|
||||||
|
padding: 25px 16px;
|
||||||
|
}
|
||||||
|
.line.split {
|
||||||
|
padding: 0px;
|
||||||
|
border: 0px;
|
||||||
|
border-bottom: 1px;
|
||||||
|
border-bottom-color: #949494;
|
||||||
|
border-style: solid;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-inline {
|
||||||
|
display: flex;
|
||||||
|
flex-flow: row wrap;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-inline label {
|
||||||
|
margin: 5px 10px 5px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-inline input {
|
||||||
|
vertical-align: middle;
|
||||||
|
margin: 0px 10px 0px 0;
|
||||||
|
background-color: #fff;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 800px) {
|
||||||
|
|
||||||
|
.form-inline {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: stretch;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -77,8 +77,6 @@ if(isset($_POST["id"]) && !empty($_POST["id"])){
|
|||||||
mysqli_stmt_close($stmt);
|
mysqli_stmt_close($stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close connection
|
|
||||||
mysqli_close($link);
|
|
||||||
} else{
|
} else{
|
||||||
// Check existence of id parameter before processing further
|
// Check existence of id parameter before processing further
|
||||||
if(isset($_GET["id"]) && !empty(trim($_GET["id"]))){
|
if(isset($_GET["id"]) && !empty(trim($_GET["id"]))){
|
||||||
@@ -109,6 +107,7 @@ if(isset($_POST["id"]) && !empty($_POST["id"])){
|
|||||||
$Winkey = $row["WinKey"];
|
$Winkey = $row["WinKey"];
|
||||||
$EthMac = $row["EthMac"];
|
$EthMac = $row["EthMac"];
|
||||||
$id = $row['id'];
|
$id = $row['id'];
|
||||||
|
$string = $row["sysMeta"];
|
||||||
} else{
|
} else{
|
||||||
// URL doesn't contain valid id. Redirect to error page
|
// URL doesn't contain valid id. Redirect to error page
|
||||||
header("location: error.php");
|
header("location: error.php");
|
||||||
@@ -119,18 +118,62 @@ if(isset($_POST["id"]) && !empty($_POST["id"])){
|
|||||||
echo "Oops! Something went wrong. Please try again later.";
|
echo "Oops! Something went wrong. Please try again later.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close statement
|
// Close statement
|
||||||
mysqli_stmt_close($stmt);
|
mysqli_stmt_close($stmt);
|
||||||
|
|
||||||
// Close connection
|
|
||||||
mysqli_close($link);
|
|
||||||
} else{
|
} else{
|
||||||
// URL doesn't contain id parameter. Redirect to error page
|
// URL doesn't contain id parameter. Redirect to error page
|
||||||
header("location: error.php");
|
header("location: error.php");
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// System meta Functions
|
||||||
|
function updateDB() {
|
||||||
|
global $link, $string, $id, $row;
|
||||||
|
$sql1 = "UPDATE systems SET sysMeta=? WHERE id=?";
|
||||||
|
if($stmt1 = mysqli_prepare($link, $sql1)){
|
||||||
|
// Bind variables to the prepared statement as parameters
|
||||||
|
mysqli_stmt_bind_param($stmt1, "si", $param_string, $param_id);
|
||||||
|
|
||||||
|
// Set parameters
|
||||||
|
$param_string = $string;
|
||||||
|
$param_id = $id;
|
||||||
|
|
||||||
|
// Attempt to execute the prepared statement
|
||||||
|
if(mysqli_stmt_execute($stmt1)){
|
||||||
|
// Records updated successfully. Redirect to landing page
|
||||||
|
} else{
|
||||||
|
echo "Something went wrong. Please try again later.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close statement
|
||||||
|
mysqli_stmt_close($stmt1);
|
||||||
|
header("location: ?id=$id");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Adding entry to sting
|
||||||
|
if(isset($_POST['typedata']))
|
||||||
|
{
|
||||||
|
$string = $string."\n".$_POST['typedata']."*".$_POST['metadata'];
|
||||||
|
updateDB();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($_GET['deldata']))
|
||||||
|
{
|
||||||
|
$string = str_replace("\n".$_GET['deldata'], '', $string);
|
||||||
|
//Removing string witout "\n" incase there is one entry
|
||||||
|
$string = str_replace($_GET['deldata'], '', $string);
|
||||||
|
updateDB();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close connection
|
||||||
|
mysqli_close($link);
|
||||||
|
|
||||||
|
$trimmedString = trim($string);
|
||||||
|
$lines = explode("\n", $trimmedString);
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
@@ -167,7 +210,7 @@ if(isset($_POST["id"]) && !empty($_POST["id"])){
|
|||||||
<!-- Custom CSS -->
|
<!-- Custom CSS -->
|
||||||
<link type="text/css" rel="stylesheet" href="../assets/css/custom.css">
|
<link type="text/css" rel="stylesheet" href="../assets/css/custom.css">
|
||||||
<!-- / STYLESHEETS -->
|
<!-- / STYLESHEETS -->
|
||||||
|
|
||||||
<!-- JAVASCRIPT -->
|
<!-- JAVASCRIPT -->
|
||||||
<!-- jQuery -->
|
<!-- jQuery -->
|
||||||
<script type="text/javascript" src="../assets/node_modules/jquery/dist/jquery.min.js"></script>
|
<script type="text/javascript" src="../assets/node_modules/jquery/dist/jquery.min.js"></script>
|
||||||
@@ -179,22 +222,9 @@ if(isset($_POST["id"]) && !empty($_POST["id"])){
|
|||||||
<script type="text/javascript" src="../assets/node_modules/popper.js/dist/umd/popper.min.js"></script>
|
<script type="text/javascript" src="../assets/node_modules/popper.js/dist/umd/popper.min.js"></script>
|
||||||
<!-- Bootstrap -->
|
<!-- Bootstrap -->
|
||||||
<script type="text/javascript" src="../assets/node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
|
<script type="text/javascript" src="../assets/node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Data tables -->
|
<!-- Data tables -->
|
||||||
<script type="text/javascript" src="../assets/node_modules/datatables.net/js/jquery.dataTables.js"></script>
|
<script type="text/javascript" src="../assets/node_modules/datatables.net/js/jquery.dataTables.js"></script>
|
||||||
<script type="text/javascript" src="../assets/node_modules/datatables-responsive/js/dataTables.responsive.js"></script>
|
<script type="text/javascript" src="../assets/node_modules/datatables-responsive/js/dataTables.responsive.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Bootstrap Select -->
|
<!-- Bootstrap Select -->
|
||||||
<script src="../assets/js/bootstrap-select.js" type="text/javascript"></script>
|
<script src="../assets/js/bootstrap-select.js" type="text/javascript"></script>
|
||||||
<!-- Fuse Html -->
|
<!-- Fuse Html -->
|
||||||
@@ -303,7 +333,8 @@ if(isset($_POST["id"]) && !empty($_POST["id"])){
|
|||||||
<a href="systems.php" class="btn btn-secondary btn-fab pull-left"><i class="icon-arrow-left"></i></a>
|
<a href="systems.php" class="btn btn-secondary btn-fab pull-left"><i class="icon-arrow-left"></i></a>
|
||||||
<h2 class="pull-right">system ID: <?php echo $sysID; ?></h2>
|
<h2 class="pull-right">system ID: <?php echo $sysID; ?></h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-wrapper md-elevation-8 p-4">
|
<div class="form-wrapper md-elevation-8 p-4">
|
||||||
|
<h3>System Information</h3>
|
||||||
<form action="<?php echo htmlspecialchars(basename($_SERVER['REQUEST_URI'])); ?>" method="post">
|
<form action="<?php echo htmlspecialchars(basename($_SERVER['REQUEST_URI'])); ?>" method="post">
|
||||||
<div class="form-group col-md-4 col-md-4 <?php echo (!empty($sysID_err)) ? 'has-error' : ''; ?>">
|
<div class="form-group col-md-4 col-md-4 <?php echo (!empty($sysID_err)) ? 'has-error' : ''; ?>">
|
||||||
<label>sysID</label>
|
<label>sysID</label>
|
||||||
@@ -333,6 +364,42 @@ if(isset($_POST["id"]) && !empty($_POST["id"])){
|
|||||||
<input type="hidden" name="id" value="<?php echo $id; ?>"/>
|
<input type="hidden" name="id" value="<?php echo $id; ?>"/>
|
||||||
<input type="submit" class="btn btn-secondary" value="Submit">
|
<input type="submit" class="btn btn-secondary" value="Submit">
|
||||||
</form>
|
</form>
|
||||||
|
<div class="split"><div class="line split"></div></div>
|
||||||
|
<div class="col-md12">
|
||||||
|
<h3>System Meta</h3>
|
||||||
|
<br>
|
||||||
|
<form class="form-inline" method="post">
|
||||||
|
<label for="meta">Meta Tag:</label>
|
||||||
|
<input id="meta" type="text" name="typedata">
|
||||||
|
<label for="value">Value:</label>
|
||||||
|
<input id="value" type="text" name="metadata"><br>
|
||||||
|
<input type="submit" class="btn btn-secondary" name="submit" value="ADD">
|
||||||
|
</form>
|
||||||
|
<br>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Meta Tag</th>
|
||||||
|
<th>Value</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<?php
|
||||||
|
foreach($lines as $line) {
|
||||||
|
echo "<tr>";
|
||||||
|
$elements = explode("*", $line);
|
||||||
|
foreach($elements as $element) {
|
||||||
|
echo "<td>" . $element . "</td>";
|
||||||
|
}
|
||||||
|
echo "<td><a class='crud' href='?id=". $row["id"] ."&deldata=". $line ."' title='Delete' data-toggle='tooltip'><span class='icons icon-trash'></span></a></td>";
|
||||||
|
echo "</tr>";
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- / CONTENT -->
|
<!-- / CONTENT -->
|
||||||
|
|
||||||
@@ -344,5 +411,4 @@ if(isset($_POST["id"]) && !empty($_POST["id"])){
|
|||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user