BuLi-Tipp Login hinzugefügt und Rangliste angefangen
This commit is contained in:
3
bulitipp/jwtsecret.php
Executable file
3
bulitipp/jwtsecret.php
Executable file
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
$secret="secret";
|
||||
36
bulitipp/login.php
Executable file
36
bulitipp/login.php
Executable file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
include("../../mysqlverbinden.php");
|
||||
include("../rowforeach.php");
|
||||
include("jwtsecret.php");
|
||||
|
||||
require '../vendor/autoload.php';
|
||||
use Firebase\JWT\JWT;
|
||||
|
||||
|
||||
if(!isset($_GET["kuerzel"])) die("GET kuerzel fehlt");
|
||||
$kuerzel = $_GET['kuerzel'];
|
||||
|
||||
if(!isset($_GET["password"])) die("GET password fehlt");
|
||||
$password=$_GET["password"];
|
||||
|
||||
$userquery = srowforeach("SELECT `username`,`id`,`password` FROM `buli-user` WHERE `kuerzel`=?;", [$kuerzel]);
|
||||
if(count($userquery) == 0) {
|
||||
die("Benutzer nicht gefunden");
|
||||
}
|
||||
|
||||
if($password == $userquery[0][2]){
|
||||
// Passwort ist korrekt, weitermachen
|
||||
} else {
|
||||
die("Falsches Passwort");
|
||||
}
|
||||
|
||||
$payload = [
|
||||
"kuerzel" => $kuerzel,
|
||||
"exp" => time() + 3600,
|
||||
"username" => $userquery[0][0],
|
||||
"id" => $userquery[0][1]
|
||||
];
|
||||
$jwt = JWT::encode($payload, $secret, 'HS256');
|
||||
|
||||
echo $jwt;
|
||||
18
bulitipp/tippeintragen.php
Executable file
18
bulitipp/tippeintragen.php
Executable file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
require '../vendor/autoload.php';
|
||||
use Firebase\JWT\JWT;
|
||||
use Firebase\JWT\Key;
|
||||
|
||||
include("jwtsecret.php");
|
||||
|
||||
if(!isset($_GET["token"])) die("GET token fehlt");
|
||||
$token=$_GET["token"];
|
||||
|
||||
$payload = JWT::decode($token, new Key($secret, 'HS256'));
|
||||
|
||||
if($payload->exp < time()){
|
||||
die("Token abgelaufen");
|
||||
}
|
||||
|
||||
print_r($payload);
|
||||
|
||||
34
bulitipp/tipps.php
Executable file
34
bulitipp/tipps.php
Executable file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
header("Content-Type: application/json");
|
||||
|
||||
include("./check.php");
|
||||
|
||||
if(!isset($_GET["spieltag"])) die("GET spieltag fehlt");
|
||||
$spieltag = $_GET["spieltag"];
|
||||
|
||||
$data=[];
|
||||
|
||||
|
||||
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];
|
||||
$tippids=[$tippquery[1],$tippquery[2],$tippquery[3],$tippquery[4],$tippquery[5],$tippquery[6],$tippquery[7],$tippquery[8],$tippquery[9]];
|
||||
foreach($tippids as $tippid){
|
||||
$tipp=srowforeach("SELECT `paarung`, `score1`, `score2` FROM `buli-tipp` WHERE `id` = ?",[$tippid]);
|
||||
|
||||
array_push($data, [
|
||||
"user" => $userid,
|
||||
"tipp" => [
|
||||
"paarungsid" => $tipp[0][0],
|
||||
"heim" => $tipp[0][1],
|
||||
"gast" => $tipp[0][2]
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$result=["reload"=>$reload, "data"=>$data];
|
||||
echo json_encode($result, JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);
|
||||
20
bulitipp/userinfo.php
Executable file
20
bulitipp/userinfo.php
Executable file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
include("../../mysqlverbinden.php");
|
||||
include("../rowforeach.php");
|
||||
include("jwtsecret.php");
|
||||
|
||||
require '../vendor/autoload.php';
|
||||
use Firebase\JWT\JWT;
|
||||
use Firebase\JWT\Key;
|
||||
|
||||
if(!isset($_GET["token"])) die("GET token fehlt");
|
||||
$token=$_GET["token"];
|
||||
|
||||
$payload = JWT::decode($token, new Key($secret, 'HS256'));
|
||||
|
||||
if($payload->exp < time()){
|
||||
die("Token abgelaufen");
|
||||
}
|
||||
|
||||
echo json_encode((array) $payload, JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);
|
||||
Reference in New Issue
Block a user