From e0f9c0a2abd6c6df04bb969457732a2485248f7d Mon Sep 17 00:00:00 2001 From: Odweta Date: Sun, 7 Jan 2024 17:20:51 +0000 Subject: [PATCH 1/2] update fetch.php remove warnings --- server/fetch.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/server/fetch.php b/server/fetch.php index 024ad4e..9a473bc 100644 --- a/server/fetch.php +++ b/server/fetch.php @@ -44,16 +44,13 @@ function make_login_request($username, $password) { } function parse_teacher($onmouseover) { - $explode_on_teacher = explode("Učitel:", $onmouseover); // [0] => something, [1] => teacher and something, 0 can be ignored - if ($explode_on_teacher == null) { - $explode_on_teacher = "~ ~"; + if ($onmouseover == null) { + $onmouseover = "Učitel:~ ~"; } + $explode_on_teacher = explode("Učitel:", $onmouseover); // [0] => something, [1] => teacher and something, 0 can be ignored $explode_on_first_tilda = explode("~", $explode_on_teacher[1]); $explode_on_second_tilda = explode("~", $explode_on_first_tilda[1]); $teacher = $explode_on_second_tilda[0]; - if ($teacher == " ") { - $teacher = ""; - } if (strstr($teacher, ">")) { $teacher = explode("<", explode(">", $teacher)[1])[0]; @@ -87,7 +84,11 @@ function parse_cell($cell, $cell_counter, $times) { if (!$is_empty && $cell->filter("table")->filter(".KuvSuplovanaHodina")->count() == 0) { $name = $cell->filter(".KuvBunkaRozvrhNadpis")->first()->text(); - $place = explode("
", $cell->filter(".KuvBunkaRozvrhText")->first()->html())[1]; + $maybe_place = $cell->filter(".KuvBunkaRozvrhText")->first()->html(); + if ($maybe_place == null) { + $maybe_place = "
"; + } + $place = explode("
", $maybe_place)[1]; if ($place == null) { $place = ""; } From a004d1a87b77826e745eebbe8a8fbf24a95413e0 Mon Sep 17 00:00:00 2001 From: Odweta Date: Sun, 7 Jan 2024 17:41:55 +0000 Subject: [PATCH 2/2] Update fetch.php --- server/fetch.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/server/fetch.php b/server/fetch.php index 9a473bc..06383bb 100644 --- a/server/fetch.php +++ b/server/fetch.php @@ -44,10 +44,10 @@ function make_login_request($username, $password) { } function parse_teacher($onmouseover) { - if ($onmouseover == null) { - $onmouseover = "Učitel:~ ~"; + if (explode("Učitel:", $onmouseover)[0] == $onmouseover) { // neni ucitel + $onmouseover = " Učitel:~ ~ "; } - $explode_on_teacher = explode("Učitel:", $onmouseover); // [0] => something, [1] => teacher and something, 0 can be ignored + $explode_on_teacher = explode("Učitel:", $onmouseover); // [0] => something, [1] => teacher and something, 0 can be ignored $explode_on_first_tilda = explode("~", $explode_on_teacher[1]); $explode_on_second_tilda = explode("~", $explode_on_first_tilda[1]); $teacher = $explode_on_second_tilda[0]; @@ -85,14 +85,15 @@ function parse_cell($cell, $cell_counter, $times) { if (!$is_empty && $cell->filter("table")->filter(".KuvSuplovanaHodina")->count() == 0) { $name = $cell->filter(".KuvBunkaRozvrhNadpis")->first()->text(); $maybe_place = $cell->filter(".KuvBunkaRozvrhText")->first()->html(); - if ($maybe_place == null) { - $maybe_place = "
"; + if (strstr($maybe_place, "
") == null) { + $maybe_place = "
"; } $place = explode("
", $maybe_place)[1]; - if ($place == null) { + if ($place == " ") { $place = ""; } $teacher = parse_teacher($cell->filter("table")->filter("td")->first()->attr("onmouseover")); + if ($teacher == " ") $teacher = ""; $is_substitute = parse_substitute($cell->filter(".KuvSuplujiciHodina")); $number = $cell_counter; $start = get_time($times, $cell_counter)[0]; // gives [start, end] @@ -233,4 +234,3 @@ if (!isset($_POST["username"]) || !isset($_POST["password"])) { } ?> -