AdminPanel Formulare hinzugefügt, .gitignore aktualisiert
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
|||||||
copy.sh
|
copy.sh
|
||||||
/bulitipp/script.lock
|
/bulitipp/script.lock
|
||||||
|
/admin/secret.php
|
||||||
|
|||||||
26
admin/check.php
Executable file
26
admin/check.php
Executable file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
header("Content-Type: application/json");
|
||||||
|
header("Access-Control-Allow-Origin: *");
|
||||||
|
header("Access-Control-Allow-Headers: Authorization");
|
||||||
|
|
||||||
|
|
||||||
|
use Firebase\JWT\JWT;
|
||||||
|
use Firebase\JWT\Key;
|
||||||
|
|
||||||
|
function getUserInfo(){
|
||||||
|
global $secret;
|
||||||
|
$token = $_SERVER['HTTP_AUTHORIZATION'] ?? '';
|
||||||
|
|
||||||
|
// "Bearer " entfernen
|
||||||
|
$token = str_replace('Bearer ', '', $token);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$payload=JWT::decode($token, new Key($secret,"HS256"));
|
||||||
|
if($payload->expire<time()) die('{"error":"Token expired"}');
|
||||||
|
return $payload;
|
||||||
|
}catch(Exception $e){
|
||||||
|
die('{"error":"Invalid Token"}');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
33
admin/formulare/ergebnisse.php
Executable file
33
admin/formulare/ergebnisse.php
Executable file
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
include("../../../mysqlverbinden.php");
|
||||||
|
include("../secret.php");
|
||||||
|
include("../../vendor/autoload.php");
|
||||||
|
|
||||||
|
include("../check.php");
|
||||||
|
|
||||||
|
$payload=getUserInfo();
|
||||||
|
|
||||||
|
$username=$payload->username;
|
||||||
|
$id=$payload->id;
|
||||||
|
|
||||||
|
if(!isset($_GET["formular"])) die("GET formular fehlt");
|
||||||
|
$formular=$_GET["formular"];
|
||||||
|
|
||||||
|
$data=[];
|
||||||
|
|
||||||
|
foreach(mysqli_execute_query($db_id,"SELECT `id` FROM `formulare-ergebnisse` WHERE `formular`=?;",[$formular]) as $ergebnisidrow){
|
||||||
|
$ergebnisid=$ergebnisidrow["id"];
|
||||||
|
$ergebnis=[];
|
||||||
|
|
||||||
|
foreach(mysqli_execute_query($db_id,"SELECT `name`, `value` FROM `formulare-ergebnis` WHERE ergebnisid=?;",[$ergebnisid]) as $row){
|
||||||
|
|
||||||
|
$ergebnis[$row["name"]]=$row["value"];
|
||||||
|
|
||||||
|
}
|
||||||
|
$data[]=$ergebnis;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
echo json_encode($data,JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);
|
||||||
|
|
||||||
|
|
||||||
15
admin/formulare/newForm.php
Executable file
15
admin/formulare/newForm.php
Executable file
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
include("../../../mysqlverbinden.php");
|
||||||
|
include("../secret.php");
|
||||||
|
include("../../vendor/autoload.php");
|
||||||
|
|
||||||
|
include("../check.php");
|
||||||
|
|
||||||
|
$payload=getUserInfo();
|
||||||
|
|
||||||
|
$username=$payload->username;
|
||||||
|
$id=$payload->id;
|
||||||
|
|
||||||
|
mysqli_execute_query($db_id,"INSERT INTO `formulare` (`name`,`minitext`,`public`,`multiple`) VALUES ('','',1,1);");
|
||||||
|
|
||||||
|
echo '{"success":true}';
|
||||||
@@ -16,7 +16,7 @@ $username=$_GET["username"];
|
|||||||
if(!isset($_GET["password"])) die("GET password fehlt");
|
if(!isset($_GET["password"])) die("GET password fehlt");
|
||||||
$password=$_GET["password"];
|
$password=$_GET["password"];
|
||||||
|
|
||||||
$result=mysqli_execute_query($db_id,"SELECT `password` FROM `adminpanel-users` WHERE `username`=?;",[$username])->fetch_assoc();
|
$result=mysqli_execute_query($db_id,"SELECT `password`, `id` FROM `adminpanel-users` WHERE `username`=?;",[$username])->fetch_assoc();
|
||||||
if(!isset($result["password"]))
|
if(!isset($result["password"]))
|
||||||
die('{"error":"Falscher Benutzername","success":false}');
|
die('{"error":"Falscher Benutzername","success":false}');
|
||||||
|
|
||||||
@@ -24,6 +24,7 @@ if(!password_verify($password,$result["password"]))
|
|||||||
die('{"error":"Falsches Passwort","success":false}');
|
die('{"error":"Falsches Passwort","success":false}');
|
||||||
|
|
||||||
$payload=[
|
$payload=[
|
||||||
|
"id"=>$result["id"],
|
||||||
"username"=>$username,
|
"username"=>$username,
|
||||||
"expire"=>time()+3600
|
"expire"=>time()+3600
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,25 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
header("Content-Type: application/json");
|
|
||||||
header("Access-Control-Allow-Origin: *");
|
|
||||||
header("Access-Control-Allow-Headers: Authorization");
|
|
||||||
|
|
||||||
|
|
||||||
include("../../mysqlverbinden.php");
|
include("../../mysqlverbinden.php");
|
||||||
include("secret.php");
|
include("secret.php");
|
||||||
include("../vendor/autoload.php");
|
include("../vendor/autoload.php");
|
||||||
|
|
||||||
use Firebase\JWT\JWT;
|
|
||||||
use Firebase\JWT\Key;
|
|
||||||
|
|
||||||
$token = $_SERVER['HTTP_AUTHORIZATION'] ?? '';
|
include("check.php");
|
||||||
|
|
||||||
// "Bearer " entfernen
|
$payload=getUserInfo();
|
||||||
$token = str_replace('Bearer ', '', $token);
|
echo json_encode($payload,JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);
|
||||||
|
|
||||||
try {
|
|
||||||
$payload=JWT::decode($token, new Key($secret,"HS256"));
|
|
||||||
if($payload->expire<time()) die('{"error":"Token expired"}');
|
|
||||||
echo json_encode($payload,JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
|
|
||||||
}catch(Exception $e){
|
|
||||||
die('{"error":"Invalid Token"}');
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,6 +6,10 @@ include("../../mysqlverbinden.php");
|
|||||||
if(!isset($_GET["id"])) die("GET id fehlt");
|
if(!isset($_GET["id"])) die("GET id fehlt");
|
||||||
$formularid=$_GET["id"];
|
$formularid=$_GET["id"];
|
||||||
|
|
||||||
|
if(!mysqli_execute_query($db_id,"SELECT `public` FROM `formulare` WHERE `id`=?;",[$formularid])->fetch_assoc()["public"]){
|
||||||
|
die('{"error":"not_public"}');
|
||||||
|
}
|
||||||
|
|
||||||
function get_type_by_name($name){
|
function get_type_by_name($name){
|
||||||
global $db_id;
|
global $db_id;
|
||||||
return mysqli_fetch_assoc(mysqli_execute_query($db_id,"SELECT `type` FROM `formulare-fields` WHERE `name`=?;",[$name]))["type"];
|
return mysqli_fetch_assoc(mysqli_execute_query($db_id,"SELECT `type` FROM `formulare-fields` WHERE `name`=?;",[$name]))["type"];
|
||||||
|
|||||||
Reference in New Issue
Block a user