update
This commit is contained in:
@@ -25,10 +25,11 @@ $setting_rtp_folder_scan_status=0;
|
||||
$setting_rtp_process_scan_status=0;
|
||||
include "../../../config.php";
|
||||
$conn = new mysqli($DB_SERVERNAME, $DB_USERNAME, $DB_PASSWORD,$DB_DATABASE);
|
||||
if ($conn->connect_error) {
|
||||
if ($conn->connect_error) {
|
||||
$success=0;
|
||||
die("Connection failed: " . $conn->connect_error);
|
||||
}
|
||||
}
|
||||
//we store all the functions like update,safe,load etc in this file, because else "client_settings.php" will get way to big
|
||||
include "client_settings_functions.php";
|
||||
if(isset($_GET["update"])){
|
||||
safe_settings();
|
||||
|
||||
@@ -85,16 +85,25 @@ async function delete_item(db,id){
|
||||
location.reload();
|
||||
}
|
||||
//add an entry
|
||||
async function add_item(db,element_id,field){
|
||||
async function add_item(db,element_id1,field1,element_id2,field2){ //we have two valus, two dbs and so on, becuase we have the signature and the description
|
||||
var element = document.getElementById(element_id);
|
||||
var value = element.value;
|
||||
await fetch('database_settings.php?add='+db+'&value='+value+'&field='+field);
|
||||
await fetch('database_settings.php?add='+db+'&value1='+value1+'&field1='+field1+'&value2='+value2+'&field2='+field2);
|
||||
location.reload();
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
//the code to update / delete and add items:
|
||||
|
||||
//we store all the functions like update,safe,load etc in this file, because else "database_settings.php" will get way to big
|
||||
include "database_settings_functions.php";
|
||||
if(isset($_GET["update"])){
|
||||
safe_settings();
|
||||
}
|
||||
if(isset($_GET["delete"])){
|
||||
delete_item($_GET["db"],$_GET["delete"]);
|
||||
}
|
||||
if(isset($_GET["add"])){
|
||||
add_item($_GET["add"],$_GET["value1"],$_GET["field1"],$_GET["value2"],$_GET["field2"]);
|
||||
}
|
||||
?>
|
||||
<div class="container mt-5">
|
||||
<div class="row justify-content-center">
|
||||
@@ -147,19 +156,21 @@ async function add_item(db,element_id,field){
|
||||
echo '<table class="table" style="overflow-x:auto">';
|
||||
echo '<thead>';
|
||||
echo '<tr>';
|
||||
echo '<th>#</th><th>Signature</th><th>Add / Delete</th>';
|
||||
echo '<th>#</th><th>Signature</th><th>Description</th><th>Add / Delete</th>';
|
||||
echo '</tr>';
|
||||
echo '</thead>';
|
||||
echo '<tbody>';
|
||||
echo('<tr>');
|
||||
echo('<th scope="row">000</th>');
|
||||
echo('<td><input type="text" id="sig_ex" class="form-control" name="name"></td>');
|
||||
echo('<td><button type="button" class="btn btn-primary" onclick="add_item(\'sig_ex\',\'sig_ex\',\'signature\');">Add</button></td>');
|
||||
echo('<td><input type="text" id="sig_ex_desc" class="form-control" name="name"></td>');
|
||||
echo('<td><button type="button" class="btn btn-primary" onclick="add_item(\'sig_ex\',\'sig_ex\',\'signature\',\'sig_ex_desc\',\'sig_ex_desc\',\'description\');">Add</button></td>');
|
||||
echo('</tr>');
|
||||
while($row = $result->fetch_assoc()) {
|
||||
echo '<tr>';
|
||||
echo("<th scope=\"row\">".$row["id"]."</th>");
|
||||
echo("<td><input type=\"text\" id=\"sig_ex".$row["id"]."\" class=\"form-control\" name=\"name\" value=\"".$row["signature"]."\" oninput=\"update_textfield('sig_ex".$row["id"]."','sig_ex','".$row["id"]."');\"></td>");
|
||||
echo("<td><input type=\"text\" id=\"sig_ex_desc".$row["id"]."\" class=\"form-control\" name=\"name\" value=\"".$row["description"]."\" oninput=\"update_textfield('sig_ex_desc".$row["id"]."','sig_ex_desc','".$row["id"]."');\"></td>");
|
||||
echo("<td><button type=\"button\" class=\"btn btn-danger\" onclick=\"delete_item('sig_ex',".$row["id"].");\">Delete</button></td>");
|
||||
echo '</tr>';
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
function delete_item($db,$id){
|
||||
include "../../../config.php";
|
||||
$conn = new mysqli($DB_SERVERNAME, $DB_USERNAME, $DB_PASSWORD,$DB_DATABASE);
|
||||
if ($conn->connect_error) {
|
||||
$success=0;
|
||||
die("Connection failed: " . $conn->connect_error);
|
||||
}
|
||||
$db=htmlspecialchars($db);
|
||||
$id=htmlspecialchars($id);
|
||||
$stmt = $conn->prepare("delete from $db where id=$id;");
|
||||
$stmt->execute();
|
||||
$stmt->close();
|
||||
$conn -> close();
|
||||
}
|
||||
function add_item($db,$value1,$field1,$value2,$field2){
|
||||
include "../../../config.php";
|
||||
$conn = new mysqli($DB_SERVERNAME, $DB_USERNAME, $DB_PASSWORD,$DB_DATABASE);
|
||||
if ($conn->connect_error) {
|
||||
$success=0;
|
||||
die("Connection failed: " . $conn->connect_error);
|
||||
}
|
||||
$db=htmlspecialchars($db);
|
||||
$field1=htmlspecialchars($field1);
|
||||
$field2=htmlspecialchars($field2);
|
||||
$stmt = $conn->prepare("INSERT INTO $db ($field1,$field2) VALUES(?,?);");
|
||||
$stmt->bind_param("ss",$value1,$value2);
|
||||
$stmt->execute();
|
||||
$stmt->close();
|
||||
$conn -> close();
|
||||
}
|
||||
function safe_settings(){//load settings
|
||||
include "../../../config.php";
|
||||
$conn = new mysqli($DB_SERVERNAME, $DB_USERNAME, $DB_PASSWORD,$DB_DATABASE);
|
||||
if ($conn->connect_error) {
|
||||
$success=0;
|
||||
die("Connection failed: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
//update excluded signature
|
||||
if($_GET["update"]=="sig_ex"){
|
||||
$id=htmlspecialchars($_GET["id"]);
|
||||
$stmt = $conn->prepare("UPDATE sig_ex set signature= ? WHERE id=$id");
|
||||
$stmt->bind_param("s",$value);
|
||||
$stmt->execute();
|
||||
$stmt->close();
|
||||
}
|
||||
//update excluded signature description
|
||||
if($_GET["update"]=="sig_ex_desc"){
|
||||
$id=htmlspecialchars($_GET["id"]);
|
||||
$stmt = $conn->prepare("UPDATE sig_ex set description= ? WHERE id=$id");
|
||||
$stmt->bind_param("s",$value);
|
||||
$stmt->execute();
|
||||
$stmt->close();
|
||||
}
|
||||
$conn->close();
|
||||
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user