Added editor for system meta data
This commit is contained in:
@@ -77,8 +77,6 @@ if(isset($_POST["id"]) && !empty($_POST["id"])){
|
||||
mysqli_stmt_close($stmt);
|
||||
}
|
||||
|
||||
// Close connection
|
||||
mysqli_close($link);
|
||||
} else{
|
||||
// Check existence of id parameter before processing further
|
||||
if(isset($_GET["id"]) && !empty(trim($_GET["id"]))){
|
||||
@@ -109,6 +107,7 @@ if(isset($_POST["id"]) && !empty($_POST["id"])){
|
||||
$Winkey = $row["WinKey"];
|
||||
$EthMac = $row["EthMac"];
|
||||
$id = $row['id'];
|
||||
$string = $row["sysMeta"];
|
||||
} else{
|
||||
// URL doesn't contain valid id. Redirect to error page
|
||||
header("location: error.php");
|
||||
@@ -119,18 +118,62 @@ if(isset($_POST["id"]) && !empty($_POST["id"])){
|
||||
echo "Oops! Something went wrong. Please try again later.";
|
||||
}
|
||||
}
|
||||
|
||||
// Close statement
|
||||
mysqli_stmt_close($stmt);
|
||||
|
||||
// Close connection
|
||||
mysqli_close($link);
|
||||
|
||||
} else{
|
||||
// URL doesn't contain id parameter. Redirect to error page
|
||||
header("location: error.php");
|
||||
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>
|
||||
@@ -167,7 +210,7 @@ if(isset($_POST["id"]) && !empty($_POST["id"])){
|
||||
<!-- Custom CSS -->
|
||||
<link type="text/css" rel="stylesheet" href="../assets/css/custom.css">
|
||||
<!-- / STYLESHEETS -->
|
||||
|
||||
|
||||
<!-- JAVASCRIPT -->
|
||||
<!-- jQuery -->
|
||||
<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>
|
||||
<!-- Bootstrap -->
|
||||
<script type="text/javascript" src="../assets/node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
|
||||
|
||||
|
||||
|
||||
<!-- 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-responsive/js/dataTables.responsive.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Bootstrap Select -->
|
||||
<script src="../assets/js/bootstrap-select.js" type="text/javascript"></script>
|
||||
<!-- 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>
|
||||
<h2 class="pull-right">system ID: <?php echo $sysID; ?></h2>
|
||||
</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">
|
||||
<div class="form-group col-md-4 col-md-4 <?php echo (!empty($sysID_err)) ? 'has-error' : ''; ?>">
|
||||
<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="submit" class="btn btn-secondary" value="Submit">
|
||||
</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>
|
||||
<!-- / CONTENT -->
|
||||
|
||||
@@ -344,5 +411,4 @@ if(isset($_POST["id"]) && !empty($_POST["id"])){
|
||||
</div>
|
||||
</main>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user