Files
system0-2.0/sys0-code/api/printer_settings.php
2024-06-27 13:51:29 +00:00

64 lines
1.7 KiB
PHP

<?php
session_start();
if(!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] !== true || $_SESSION["role"][9]!=="1"){
header("location: login.php");
exit;
}
include "../config/config.php";
if($_GET['action']=="update_rotation")
{
$printer_id=htmlspecialchars($_GET['id']);
$rotation=htmlspecialchars($_GET["value"]);
$sql="update printer set rotation=$rotation where id=$printer_id";
$stmt = mysqli_prepare($link, $sql);
mysqli_stmt_execute($stmt);
}
if($_GET["action"]=="update_color")
{
$printer_id=htmlspecialchars($_GET['id']);
$color=htmlspecialchars($_GET["value"]);
$sql="update printer set color='$color' where id=$printer_id";
$stmt = mysqli_prepare($link, $sql);
mysqli_stmt_execute($stmt);
}
if($_GET["action"]=="update_filament")
{
$id=htmlspecialchars($_GET['id']);
$color=htmlspecialchars($_GET["value"]);
$sql="update filament set name='$color' where internal_id=$id";
$stmt = mysqli_prepare($link, $sql);
mysqli_stmt_execute($stmt);
}
if($_GET["action"]=="delete_filament")
{
$id=htmlspecialchars($_GET['id']);
$color=htmlspecialchars($_GET["value"]);
$sql="delete from filament where internal_id=$id";
$stmt = mysqli_prepare($link, $sql);
mysqli_stmt_execute($stmt);
}
if($_GET["action"]=="update_class")
{
$id=htmlspecialchars($_GET['id']);
$color=htmlspecialchars($_GET["value"]);
$sql="update class set name='$color' where id=$id";
$stmt = mysqli_prepare($link, $sql);
mysqli_stmt_execute($stmt);
}
if($_GET["action"]=="delete_class")
{
$id=htmlspecialchars($_GET['id']);
$color=htmlspecialchars($_GET["value"]);
$sql="delete from class where id=$id";
$stmt = mysqli_prepare($link, $sql);
mysqli_stmt_execute($stmt);
}
?>