From 5977d5e96abbf72bba7a6805507d01e3ae659e69 Mon Sep 17 00:00:00 2001 From: R40fendt Date: Mon, 22 Dec 2025 22:07:18 +0100 Subject: [PATCH] Lockfile check.php, addhit.php, BuLi-Tipp Debugging, Galerie Kommentarfunktion --- .gitignore | 3 ++- addhit.php | 32 ++++++++++++++++++++++++++++++++ bulitipp/check.php | 29 ++++++++++++++++++++++++----- bulitipp/hatgetippt.php | 1 + bulitipp/saison.txt | 2 +- bulitipp/zeitzutippen.php | 3 +-- galerie/get_kommentare.php | 25 +++++++++++++++++++++++++ galerie/submit_kommentar.php | 23 +++++++++++++++++++++++ hits.txt | 1 + 9 files changed, 110 insertions(+), 9 deletions(-) create mode 100755 addhit.php create mode 100755 galerie/get_kommentare.php create mode 100755 galerie/submit_kommentar.php create mode 100755 hits.txt diff --git a/.gitignore b/.gitignore index 77394b7..fe042c2 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -copy.sh \ No newline at end of file +copy.sh +/bulitipp/script.lock diff --git a/addhit.php b/addhit.php new file mode 100755 index 0000000..7bc7389 --- /dev/null +++ b/addhit.php @@ -0,0 +1,32 @@ + diff --git a/bulitipp/check.php b/bulitipp/check.php index 1d370c1..c900ec1 100755 --- a/bulitipp/check.php +++ b/bulitipp/check.php @@ -4,18 +4,35 @@ include("../rowforeach.php"); include("inc.php"); $bundesliga = file_get_contents("liga.txt"); -$year = file_get_contents("saison.txt"); +$year = intval(file_get_contents("saison.txt")); $reload=false; +$lockFile = fopen(__DIR__ . '/script.lock', 'c'); + +if (!$lockFile) { + die('Lockdatei konnte nicht geöffnet werden'); +} + +if (flock($lockFile, LOCK_EX | LOCK_NB)) { + // Skript läuft noch nicht // Paarungen holen // HTTP-Request ausführen -$spieltag=getmaxtippspieltag()+1; + +$result=mysqli_execute_query($db_id,"SELECT COUNT(*) FROM `buli-paarungen`;",[]); +$row=mysqli_fetch_row($result); +if($row[0]==0){ + echo "Keine Paarungen in der Datenbank, starte mit Spieltag 1"; + $spieltag=1; +}else{ + $spieltag=getmaxtippspieltag()+1; + +} if($spieltag<=34){ $response = file_get_contents("https://api.openligadb.de/getmatchdata/bl".$bundesliga."/".$year."/".$spieltag, false); if ($response === false) { - echo ""; + echo "Fehler beim HTTP Request!"; } @@ -67,7 +84,6 @@ if ($responseData!=null) { $spieltag=getmaxspieltag()+1; -if($spieltag<=3){ $response = file_get_contents("https://api.openligadb.de/getmatchdata/bl".$bundesliga."/".$year."/".$spieltag, false); @@ -100,7 +116,6 @@ if ($responseData) { // echo ""; } -} if(srowforeach("SELECT COUNT(`id`) from `buli-icons`;",[])[0][0]<9){ mysqli_execute_query($db_id,"TRUNCATE `buli-icons`;",[]); @@ -114,3 +129,7 @@ if(srowforeach("SELECT COUNT(`id`) from `buli-icons`;",[])[0][0]<9){ } } + +flock($lockFile, LOCK_UN); +fclose($lockFile); +} diff --git a/bulitipp/hatgetippt.php b/bulitipp/hatgetippt.php index 90c5cfa..c548a9f 100755 --- a/bulitipp/hatgetippt.php +++ b/bulitipp/hatgetippt.php @@ -12,6 +12,7 @@ $userquery=srowforeach("SELECT id FROM `buli-user` WHERE id = ?",[$userid]); if(count($userquery) == 0) die("User nicht gefunden"); $userid = $userquery[0][0]; +$spieltag=getmaxspieltag()+1; if(count(srowforeach("SELECT id FROM `buli-tipps` WHERE user = ? AND spieltag=?",[$userid,$spieltag])) == 0) echo "0"; else echo "1"; diff --git a/bulitipp/saison.txt b/bulitipp/saison.txt index dba6080..661b0f2 100755 --- a/bulitipp/saison.txt +++ b/bulitipp/saison.txt @@ -1 +1 @@ -2024 \ No newline at end of file +2025 diff --git a/bulitipp/zeitzutippen.php b/bulitipp/zeitzutippen.php index b4926d9..1794edb 100755 --- a/bulitipp/zeitzutippen.php +++ b/bulitipp/zeitzutippen.php @@ -11,7 +11,6 @@ if(count($query)>0){ $hours=(int) date("H", $unixtime); $days=date("d", $unixtime)-1; } -$days=0; $data=[ "spieltag" => getmaxspieltag()+1, @@ -21,4 +20,4 @@ $data=[ "days" => $days ]; -echo json_encode($data,JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE); \ No newline at end of file +echo json_encode($data,JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE); diff --git a/galerie/get_kommentare.php b/galerie/get_kommentare.php new file mode 100755 index 0000000..6b74899 --- /dev/null +++ b/galerie/get_kommentare.php @@ -0,0 +1,25 @@ + $row["username"], + "kommentar" => $row["kommentar"] + ); +} +echo json_encode($kommentare, JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES); +?> diff --git a/galerie/submit_kommentar.php b/galerie/submit_kommentar.php new file mode 100755 index 0000000..879e3f9 --- /dev/null +++ b/galerie/submit_kommentar.php @@ -0,0 +1,23 @@ +1024) die("Kommentar zu lang"); + +include("../../mysqlverbinden.php"); + +mysqli_execute_query($db_id, "INSERT INTO `galerie-kommentare` (`ev`,`jahr`,`bild`,`username`,`kommentar`) VALUES (?,?,?,?,?)",[$ev,$jahr,$bild,$username,$kommentar]); +?> diff --git a/hits.txt b/hits.txt new file mode 100755 index 0000000..e440e5c --- /dev/null +++ b/hits.txt @@ -0,0 +1 @@ +3 \ No newline at end of file