check.php auf 30 Spieltage begrenzt zum Debuggen, Tippen optimiert mit ein paar QoL Features, updaten von Tipps hinzugefügt
This commit is contained in:
@@ -67,7 +67,7 @@ if ($responseData!=null) {
|
|||||||
|
|
||||||
$spieltag=getmaxspieltag()+1;
|
$spieltag=getmaxspieltag()+1;
|
||||||
|
|
||||||
if($spieltag<=34){
|
if($spieltag<=29){
|
||||||
|
|
||||||
$response = file_get_contents("https://api.openligadb.de/getmatchdata/bl".$bundesliga."/".$year."/".$spieltag, false);
|
$response = file_get_contents("https://api.openligadb.de/getmatchdata/bl".$bundesliga."/".$year."/".$spieltag, false);
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ if(isset($headers['Authorization'])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$payload = JWT::decode($token, new Key($secret, 'HS256'));
|
$payload = JWT::decode($token, new Key($secret, 'HS256'));
|
||||||
|
$userid= $payload->id;
|
||||||
|
|
||||||
if($payload->exp < time()){
|
if($payload->exp < time()){
|
||||||
die("Token abgelaufen");
|
die("Token abgelaufen");
|
||||||
@@ -51,10 +52,15 @@ foreach($tipps as $tipp){
|
|||||||
$paarungsid = $tipp['paarung']["id"];
|
$paarungsid = $tipp['paarung']["id"];
|
||||||
$score1 = $tipp['heim'];
|
$score1 = $tipp['heim'];
|
||||||
$score2 = $tipp['gast'];
|
$score2 = $tipp['gast'];
|
||||||
|
$update=!mysqli_execute_query($db_id,"SELECT COUNT(*) AS anzahl FROM `buli-tipps` WHERE `spieltag`=? AND user=?;",[$spieltag,$userid])->fetch_assoc()["anzahl"]==0;
|
||||||
|
if(!$update){
|
||||||
mysqli_execute_query($db_id,"INSERT INTO `buli-tipp` (`spieltag`,`paarung`,`score1`,`score2`) VALUES (?,?,?,?);",[$spieltag,$paarungsid,$score1,$score2]);
|
mysqli_execute_query($db_id,"INSERT INTO `buli-tipp` (`spieltag`,`paarung`,`score1`,`score2`) VALUES (?,?,?,?);",[$spieltag,$paarungsid,$score1,$score2]);
|
||||||
$tippids[] = mysqli_insert_id($db_id);
|
$tippids[] = mysqli_insert_id($db_id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
mysqli_execute_query($db_id,"UPDATE `buli-tipp` AS bt JOIN `buli-tipps` AS bts ON bt.id IN (bts.tipp1, bts.tipp2, bts.tipp3, bts.tipp4, bts.tipp5, bts.tipp6, bts.tipp7, bts.tipp8, bts.tipp9) SET bt.score1=?, bt.score2=? WHERE bt.spieltag=? AND bt.paarung=? AND bts.user=?;",[$score1,$score2,$spieltag,$paarungsid,$userid]);
|
||||||
}
|
}
|
||||||
array_push($tippids, $spieltag);
|
array_push($tippids, $spieltag);
|
||||||
array_push($tippids, $payload->id);
|
array_push($tippids, $payload->id);
|
||||||
|
|
||||||
mysqli_execute_query($db_id,"INSERT INTO `buli-tipps` (`tipp1`, `tipp2`, `tipp3`, `tipp4`, `tipp5`, `tipp6`, `tipp7`, `tipp8`, `tipp9`, `spieltag`, `user`) VALUES (?,?,?,?,?,?,?,?,?,?,?);",$tippids);
|
if(!$update) mysqli_execute_query($db_id,"INSERT INTO `buli-tipps` (`tipp1`, `tipp2`, `tipp3`, `tipp4`, `tipp5`, `tipp6`, `tipp7`, `tipp8`, `tipp9`, `spieltag`, `user`) VALUES (?,?,?,?,?,?,?,?,?,?,?);",$tippids);
|
||||||
|
|||||||
@@ -6,11 +6,13 @@ include("./check.php");
|
|||||||
|
|
||||||
if(!isset($_GET["spieltag"])) die("GET spieltag fehlt");
|
if(!isset($_GET["spieltag"])) die("GET spieltag fehlt");
|
||||||
$spieltag = $_GET["spieltag"];
|
$spieltag = $_GET["spieltag"];
|
||||||
|
if($spieltag==""||$spieltag=="null") die('{"error":"GET spieltag leer"}');
|
||||||
|
|
||||||
$data=[];
|
$data=[];
|
||||||
|
|
||||||
|
|
||||||
foreach(srowforeach("SELECT `user`, `tipp1`, `tipp2`, `tipp3`, `tipp4`, `tipp5`, `tipp6`, `tipp7`, `tipp8`, `tipp9` from `buli-tipps` where `spieltag`=?;",[$spieltag]) as $key=>$tippquery){
|
if(deadline($spieltag))
|
||||||
|
foreach(srowforeach("SELECT `user`, `tipp1`, `tipp2`, `tipp3`, `tipp4`, `tipp5`, `tipp6`, `tipp7`, `tipp8`, `tipp9` from `buli-tipps` where `spieltag`=?;",[$spieltag]) as $key=>$tippquery){
|
||||||
$userid=$tippquery[0];
|
$userid=$tippquery[0];
|
||||||
$tippids=[$tippquery[1],$tippquery[2],$tippquery[3],$tippquery[4],$tippquery[5],$tippquery[6],$tippquery[7],$tippquery[8],$tippquery[9]];
|
$tippids=[$tippquery[1],$tippquery[2],$tippquery[3],$tippquery[4],$tippquery[5],$tippquery[6],$tippquery[7],$tippquery[8],$tippquery[9]];
|
||||||
foreach($tippids as $tippid){
|
foreach($tippids as $tippid){
|
||||||
@@ -25,7 +27,7 @@ foreach(srowforeach("SELECT `user`, `tipp1`, `tipp2`, `tipp3`, `tipp4`, `tipp5`,
|
|||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
53
bulitipp/tippsuser.php
Executable file
53
bulitipp/tippsuser.php
Executable file
@@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
header("Access-Control-Allow-Origin: *");
|
||||||
|
header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
|
||||||
|
header("Access-Control-Allow-Headers: Authorization");
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
|
||||||
|
http_response_code(200);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
require '../vendor/autoload.php';
|
||||||
|
use Firebase\JWT\JWT;
|
||||||
|
use Firebase\JWT\Key;
|
||||||
|
|
||||||
|
include("jwtsecret.php");
|
||||||
|
include("../../mysqlverbinden.php");
|
||||||
|
|
||||||
|
$headers = getallheaders();
|
||||||
|
if(isset($headers['Authorization'])) {
|
||||||
|
$authHeader = $headers['Authorization'];
|
||||||
|
if (preg_match('/Bearer\s(\S+)/', $authHeader, $matches)) {
|
||||||
|
$token = $matches[1];
|
||||||
|
} else {
|
||||||
|
die("Invalid Authorization header format");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
die("Authorization header not found");
|
||||||
|
}
|
||||||
|
try{
|
||||||
|
$payload = JWT::decode($token, new Key($secret, 'HS256'));
|
||||||
|
}catch (Exception $e) {
|
||||||
|
die("{}");
|
||||||
|
}
|
||||||
|
|
||||||
|
$userid= $payload->id;
|
||||||
|
|
||||||
|
if($payload->exp < time()){
|
||||||
|
die("Token abgelaufen");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isset($_GET["spieltag"])) die("GET spieltag fehlt");
|
||||||
|
$spieltag = $_GET["spieltag"];
|
||||||
|
|
||||||
|
|
||||||
|
$data=[];
|
||||||
|
|
||||||
|
for($i=0;$i<9;$i++){
|
||||||
|
$tipp=mysqli_execute_query($db_id,"SELECT `paarung`, `score1`, `score2` FROM `buli-tipp` AS bt JOIN `buli-tipps` AS bts ON bts.tipp".($i+1)."=bt.id WHERE bt.`spieltag`=? AND bts.user=?;",[$spieltag,$userid])->fetch_assoc();
|
||||||
|
array_push($data,$tipp);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo json_encode($data, JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);
|
||||||
24
bulitipp/zeitzutippen.php
Executable file
24
bulitipp/zeitzutippen.php
Executable file
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
header("Access-Control-Allow-Origin: *");
|
||||||
|
|
||||||
|
include("../../mysqlverbinden.php");
|
||||||
|
include("../rowforeach.php");
|
||||||
|
include("inc.php");
|
||||||
|
|
||||||
|
$query=srowforeach("SELECT deadline from `buli-paarungen` where spieltag=? ORDER BY `deadline` ASC;", [getmaxspieltag()+1]);
|
||||||
|
if(count($query)>0){
|
||||||
|
$unixtime = date_create_from_format('Y-m-d H:i:s', $query[0][0])->getTimestamp()-time();
|
||||||
|
$hours=(int) date("H", $unixtime);
|
||||||
|
$days=date("d", $unixtime)-1;
|
||||||
|
}
|
||||||
|
$days=0;
|
||||||
|
|
||||||
|
$data=[
|
||||||
|
"spieltag" => getmaxspieltag()+1,
|
||||||
|
"deadline" => $query[0][0],
|
||||||
|
"unixtime" => $unixtime,
|
||||||
|
"hours" => $hours,
|
||||||
|
"days" => $days
|
||||||
|
];
|
||||||
|
|
||||||
|
echo json_encode($data,JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);
|
||||||
Reference in New Issue
Block a user