diff --git a/sys0-code/test/fetch_printer_data.php b/sys0-code/test/fetch_printer_data.php new file mode 100644 index 0000000..7762efb --- /dev/null +++ b/sys0-code/test/fetch_printer_data.php @@ -0,0 +1,67 @@ += $firstCharsCount + $lastCharsCount + 3) { + $firstChars = substr($filePath, 0, $firstCharsCount); + $lastChars = substr($filePath, -$lastCharsCount); + return $firstChars . "..." . $lastChars; + } else { + return $filePath; + } +} + +$printers = []; +$sql = "SELECT rotation, free, id, printer_url, apikey, cancel, used_by_userid, system_status, color FROM printer"; +$stmt = mysqli_prepare($link, $sql); +mysqli_stmt_execute($stmt); +mysqli_stmt_store_result($stmt); +mysqli_stmt_bind_result($stmt, $rotation, $is_free, $printer_id, $url, $apikey, $cancel, $userid, $system_status, $filament_color); + +while (mysqli_stmt_fetch($stmt)) { + $printer = [ + "rotation" => $rotation, + "is_free" => $is_free, + "printer_id" => $printer_id, + "url" => $url, + "apikey" => $apikey, + "cancel" => $cancel, + "userid" => $userid, + "system_status" => $system_status, + "filament_color" => $filament_color, + ]; + + if ($is_free == 0 && $system_status == 0) { + exec("curl --max-time 10 $url/api/job?apikey=$apikey > /var/www/html/user_files/" . $_SESSION["username"] . "/json.json"); + $fg = file_get_contents("/var/www/html/user_files/" . $_SESSION["username"] . "/json.json"); + $json = json_decode($fg, true); + $printer["progress"] = (int) $json['progress']['completion']; + $printer["file"] = short_path($json["job"]["file"]["name"], 10, 10); + $printer["print_time_total"] = seconds_to_time(intval($json["job"]["estimatedPrintTime"])); + $printer["print_time_left"] = seconds_to_time(intval($json["progress"]["printTimeLeft"])); + $printer["print_time"] = seconds_to_time(intval($json["progress"]["printTime"])); + } + + $printers[] = $printer; +} + +mysqli_stmt_close($stmt); +echo json_encode($printers); +?> diff --git a/sys0-code/test/overview.php b/sys0-code/test/overview.php new file mode 100644 index 0000000..5ff15dd --- /dev/null +++ b/sys0-code/test/overview.php @@ -0,0 +1,609 @@ + + +
+ + + + + + + +load_user()"; +?> + +=$firstCharsCount+$lastCharsCount+3){ + $firstChars = substr($filePath, 0, $firstCharsCount); + + // Get the last few characters of the path + $lastChars = substr($filePath, -$lastCharsCount); + + // Return the shortened path + return $firstChars . "..." . $lastChars; + } + else{ + return $filePath; + } + } + $color=$_SESSION["color"]; + include "../assets/components.php"; + if(!isset($_SESSION["rid"])) + $_SESSION["rid"]=0; + $_SESSION["rid"]++; + + if(isset($_GET["set_class"]) && isset($_POST["class"])){ + $class_id=htmlspecialchars($_POST["class"]); + $sql="update users set class_id=$class_id where username='$username'"; + $stmt = mysqli_prepare($link, $sql); + mysqli_stmt_execute($stmt); + $stmt->close(); + $sql="select name from class where id=$class_id"; + $stmt = mysqli_prepare($link, $sql); + mysqli_stmt_execute($stmt); + $class_name=""; + mysqli_stmt_bind_result($stmt, $class_name); + $stmt->close(); + $_SESSION["class"]=$class_name; + $_SESSION["class_id"]=$class_id; + } +?> + +| Status | Fertig |
| Genutzt von | ".$username2[0]." |
| Filamentfarbe | $filament_color |
| Erwartete Druckzeit | $print_time_total |
| Verbleibende Druckzeit | $print_time_left |
| Vergangene Druckzeit | $print_time |
| Datei | ".short_path($json["job"]["file"]["name"],10,10)." ".$json["job"]["file"]["name"]." |
| Freigeben |
| Status | Druck Abgebrochen |
| Genutzt von | ".$username2[0]." |
| Filamentfarbe | $filament_color |
| Erwartete Druckzeit | $print_time_total |
| Verbleibende Druckzeit | $print_time_left |
| Vergangene Druckzeit | $print_time |
| Datei | ".short_path($json["job"]["file"]["name"],10,10)." ".$json["job"]["file"]["name"]." |
| Freigeben |
| Status | |
| Genutzt von | ".$username2[0]." |
| Filamentfarbe | $filament_color |
| Erwartete Druckzeit | $print_time_total |
| Verbleibende Druckzeit | $print_time_left |
| Vergangene Druckzeit | $print_time |
| Datei | ".short_path($json["job"]["file"]["name"],10,10)." ".$json["job"]["file"]["name"]." |
| Abbrechen | |
| Status | Bereit |
| Filamentfarbe | $filament_color |
| Status | Problem / nicht Betriebsbereit |
| Datei | Drucken auf Drucker | aus der Warteschlange entfernen | |
|---|---|---|---|
| $filepath | "); + if($print_on==-1) + echo("Erster verfügbarer Drucker | "); + else + echo("$print_on | "); + if($_SESSION["role"][3]==="1" or $_SESSION["id"]==$from_userid) + echo("