Lockfile check.php, addhit.php, BuLi-Tipp Debugging, Galerie Kommentarfunktion
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1 +1,2 @@
|
||||
copy.sh
|
||||
copy.sh
|
||||
/bulitipp/script.lock
|
||||
|
||||
32
addhit.php
Executable file
32
addhit.php
Executable file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
header("Access-Control-Allow-Origin: *; Content-Type: application/javascript");
|
||||
|
||||
include("../mysqlverbinden.php");
|
||||
# Datenbank aufräumen: Alle Einträge löschen, die nicht von heute sind
|
||||
mysqli_execute_query($db_id, "DELETE FROM `ritzenbergen-hits` WHERE timestamp < NOW() - INTERVAL 24 HOUR;");
|
||||
|
||||
# Prüfen, ob die IP heute schon gesehen wurde
|
||||
$result=mysqli_execute_query($db_id, "SELECT COUNT(*) FROM `ritzenbergen-hits` WHERE ip=?;", [$_SERVER['REMOTE_ADDR']]);
|
||||
$alreadyVisited=mysqli_fetch_row($result)[0];
|
||||
|
||||
# Hits aus der hits.txt Datei lesen
|
||||
$file = fopen("hits.txt","r");
|
||||
$hits = fread($file, filesize("hits.txt"));
|
||||
$hits = intval($hits) + 1;
|
||||
fclose($file);
|
||||
|
||||
if($alreadyVisited==0) {
|
||||
# IP heute noch nicht gesehen, also neuen Eintrag hinzufügen
|
||||
mysqli_execute_query($db_id, "INSERT INTO `ritzenbergen-hits` (`ip`, `timestamp`) VALUES (?, NOW());", [$_SERVER['REMOTE_ADDR']]);
|
||||
|
||||
|
||||
# Hits in der hits.txt Datei aktualisieren
|
||||
$file = fopen("hits.txt","w");
|
||||
fwrite($file, strval($hits));
|
||||
fclose($file);
|
||||
|
||||
}
|
||||
echo "let hits=".$hits; // JS Variable mit der Anzahl der Hits zurückgeben
|
||||
|
||||
|
||||
?>
|
||||
@@ -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 "<script>window.alert(`Fehler beim HTTP-Request(Z.41)! Bitte einen Admin kontaktieren! BuLi-Tipp Daten konnten nicht aktualisiert werden.`);</script>";
|
||||
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 "<script>window.alert(`JSON-Response ungültig (Z.29)! Bitte einen Admin kontaktieren! BuLi-Tipp Daten konnten nicht aktualisiert werden.`);</script>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -1 +1 @@
|
||||
2024
|
||||
2025
|
||||
|
||||
@@ -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);
|
||||
echo json_encode($data,JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);
|
||||
|
||||
25
galerie/get_kommentare.php
Executable file
25
galerie/get_kommentare.php
Executable file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
|
||||
if(!isset($_GET["ev"])) die("GET ev fehlt");
|
||||
$ev=$_GET["ev"];
|
||||
|
||||
if(!isset($_GET["jahr"])) die("GET jahr fehlt");
|
||||
$jahr=$_GET["jahr"];
|
||||
|
||||
if(!isset($_GET["bild"])) die("GET bild fehlt");
|
||||
$bild=$_GET["bild"];
|
||||
|
||||
include("../../mysqlverbinden.php");
|
||||
|
||||
$result=mysqli_execute_query($db_id, "SELECT `username`,`kommentar` FROM `galerie-kommentare` WHERE ev=? AND jahr=? AND bild=?;",[$ev,$jahr,$bild]);
|
||||
|
||||
$kommentare = array();
|
||||
foreach($result as $row) {
|
||||
$kommentare[] = array(
|
||||
"username" => $row["username"],
|
||||
"kommentar" => $row["kommentar"]
|
||||
);
|
||||
}
|
||||
echo json_encode($kommentare, JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
|
||||
?>
|
||||
23
galerie/submit_kommentar.php
Executable file
23
galerie/submit_kommentar.php
Executable file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
|
||||
if(!isset($_GET["ev"])) die("GET ev fehlt");
|
||||
$ev=$_GET["ev"];
|
||||
|
||||
if(!isset($_GET["jahr"])) die("GET jahr fehlt");
|
||||
$jahr=$_GET["jahr"];
|
||||
|
||||
if(!isset($_GET["bild"])) die("GET bild fehlt");
|
||||
$bild=$_GET["bild"];
|
||||
|
||||
if(!isset($_GET["username"])) die("GET username fehlt");
|
||||
$username=$_GET["username"];
|
||||
|
||||
if(!isset($_GET["kommentar"])) die("GET kommentar fehlt");
|
||||
$kommentar=$_GET["kommentar"];
|
||||
if(strlen($kommentar)>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]);
|
||||
?>
|
||||
Reference in New Issue
Block a user