update
This commit is contained in:
@@ -74,10 +74,10 @@ async function update_percentage() {
|
|||||||
setInterval(update_percentage, 5000);
|
setInterval(update_percentage, 5000);
|
||||||
|
|
||||||
//update an entry
|
//update an entry
|
||||||
function update_textfield(id,name,itemid){
|
function update_textfield(db,id,name,itemid){
|
||||||
var element = document.getElementById(id);
|
var element = document.getElementById(id);
|
||||||
var value = element.value;
|
var value = element.value;
|
||||||
fetch('database_settings.php?update='+name+'&value='+value+'&id='+itemid);
|
fetch('database_settings.php?update='+name+'&value='+value+'&id='+itemid+'&db='+db);
|
||||||
}
|
}
|
||||||
//delete an entry
|
//delete an entry
|
||||||
async function delete_item(db,id){
|
async function delete_item(db,id){
|
||||||
@@ -98,7 +98,7 @@ async function add_item(db,element_id1,field1,element_id2,field2){ //we have two
|
|||||||
//we store all the functions like update,safe,load etc in this file, because else "database_settings.php" will get way to big
|
//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";
|
include "database_settings_functions.php";
|
||||||
if(isset($_GET["update"])){
|
if(isset($_GET["update"])){
|
||||||
safe_settings();
|
safe_settings($_GET["db"]);
|
||||||
}
|
}
|
||||||
if(isset($_GET["delete"])){
|
if(isset($_GET["delete"])){
|
||||||
delete_item($_GET["db"],$_GET["delete"]);
|
delete_item($_GET["db"],$_GET["delete"]);
|
||||||
@@ -170,8 +170,8 @@ async function add_item(db,element_id1,field1,element_id2,field2){ //we have two
|
|||||||
while($row = $result->fetch_assoc()) {
|
while($row = $result->fetch_assoc()) {
|
||||||
echo '<tr>';
|
echo '<tr>';
|
||||||
echo("<th scope=\"row\">".$row["id"]."</th>");
|
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".$row["id"]."\" class=\"form-control\" name=\"name\" value=\"".$row["signature"]."\" oninput=\"update_textfield('sig_ex','sig_ex".$row["id"]."','sig','".$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><input type=\"text\" id=\"sig_ex_desc".$row["id"]."\" class=\"form-control\" name=\"name\" value=\"".$row["description"]."\" oninput=\"update_textfield('sig_ex','sig_ex_desc".$row["id"]."','sig_ex','".$row["id"]."');\"></td>");
|
||||||
echo("<td><button type=\"button\" class=\"btn btn-danger\" onclick=\"delete_item('sig_ex',".$row["id"].");\">Delete</button></td>");
|
echo("<td><button type=\"button\" class=\"btn btn-danger\" onclick=\"delete_item('sig_ex',".$row["id"].");\">Delete</button></td>");
|
||||||
echo '</tr>';
|
echo '</tr>';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ function add_item($db,$value1,$field1,$value2,$field2){
|
|||||||
$stmt->close();
|
$stmt->close();
|
||||||
$conn -> close();
|
$conn -> close();
|
||||||
}
|
}
|
||||||
function safe_settings(){//load settings
|
function safe_settings($db){//load settings
|
||||||
include "../../../config.php";
|
include "../../../config.php";
|
||||||
$conn = new mysqli($DB_SERVERNAME, $DB_USERNAME, $DB_PASSWORD,$DB_DATABASE);
|
$conn = new mysqli($DB_SERVERNAME, $DB_USERNAME, $DB_PASSWORD,$DB_DATABASE);
|
||||||
if ($conn->connect_error) {
|
if ($conn->connect_error) {
|
||||||
@@ -38,18 +38,19 @@ function safe_settings(){//load settings
|
|||||||
}
|
}
|
||||||
$value=htmlspecialchars($_GET["value"]);
|
$value=htmlspecialchars($_GET["value"]);
|
||||||
$name=htmlspecialchars($_GET["update"]);
|
$name=htmlspecialchars($_GET["update"]);
|
||||||
//update excluded signature
|
$db=htmlspecialchars($db);
|
||||||
if($_GET["update"]=="sig_ex"){
|
//update signature
|
||||||
|
if($_GET["update"]=="sig"){
|
||||||
$id=htmlspecialchars($_GET["id"]);
|
$id=htmlspecialchars($_GET["id"]);
|
||||||
$stmt = $conn->prepare("UPDATE sig_ex set signature= ? WHERE id=$id");
|
$stmt = $conn->prepare("UPDATE $db set signature= ? WHERE id=$id");
|
||||||
$stmt->bind_param("s",$value);
|
$stmt->bind_param("s",$value);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$stmt->close();
|
$stmt->close();
|
||||||
}
|
}
|
||||||
//update excluded signature description
|
//update signature description
|
||||||
if($_GET["update"]=="sig_ex_desc"){
|
if($_GET["update"]=="sig_desc"){
|
||||||
$id=htmlspecialchars($_GET["id"]);
|
$id=htmlspecialchars($_GET["id"]);
|
||||||
$stmt = $conn->prepare("UPDATE sig_ex set description= ? WHERE id=$id");
|
$stmt = $conn->prepare("UPDATE $db set description= ? WHERE id=$id");
|
||||||
$stmt->bind_param("s",$value);
|
$stmt->bind_param("s",$value);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$stmt->close();
|
$stmt->close();
|
||||||
|
|||||||
Reference in New Issue
Block a user