diff --git a/sys0-code/app/print.php b/sys0-code/app/print.php index ff510c6..9320b03 100644 --- a/sys0-code/app/print.php +++ b/sys0-code/app/print.php @@ -1,710 +1,385 @@ 75 or $ex_temp>225){ - return 0; - }else{ - return 1; - } -} - -function find_print_time($file) { - $handle = fopen($file, "r"); - $targetPhrase = "; estimated printing time (normal mode) = "; - $time = null; - - while (($line = fgets($handle)) !== false) { - if (strpos($line, $targetPhrase) !== false) { - // Extract the time after the target phrase - $time = trim(str_replace($targetPhrase, "", $line)); - break; // Stop once the desired line is found - } - } - - fclose($handle); - - return $time; -} - -function check_reservation_conflict($link, $class) { - $reservation_conflict = false; - $today = date("Y-m-d"); - $time_now = date("H:i"); - $for_class = []; - - // Query for reservations that start today or extend into today - $sql = " - SELECT day, time_from, time_to, for_class - FROM reservations - WHERE day <= '$today' AND - (day = '$today' AND time_from <= '$time_now' OR day < '$today'); - "; - $stmt = $link->prepare($sql); - $stmt->execute(); - $result = $stmt->get_result(); - - while ($row = $result->fetch_assoc()) { - // Calculate the actual end time of the reservation - $reservation_end = strtotime($row["day"] . " " . $row["time_to"]); - $current_time = strtotime("$today $time_now"); - - if ($current_time <= $reservation_end) { - $reservation_conflict = true; - $for_class[] = $row["for_class"]; - } - } - - // Default value for for_class if no conflicts are found - if (empty($for_class)) { - $for_class[] = 0; - } - - // Determine the appropriate response based on the conflict status - $response = ['conflict' => $reservation_conflict, 'block' => false, 'message' => '']; - - if ($reservation_conflict && !in_array($class, $for_class) && $class != 0) { - $response['block'] = true; - $response['message'] = " -
Cloudfile: ".$_GET["cloudprint"]."
"); - echo('