Compare commits
10 Commits
31163088be
...
6b68570e46
| Author | SHA1 | Date | |
|---|---|---|---|
| 6b68570e46 | |||
| f7925e6248 | |||
|
|
3dd2b43cc4 | ||
| 76857b8611 | |||
| e2335fdcf7 | |||
|
|
1948ce58d3 | ||
|
|
be19571e30 | ||
| b9b64f3572 | |||
|
|
1340ae2d0f | ||
|
|
7ff43e7403 |
59
.gitignore
vendored
59
.gitignore
vendored
@@ -1,3 +1,56 @@
|
|||||||
copy.sh
|
# compiled output
|
||||||
/bulitipp/script.lock
|
/dist
|
||||||
/admin/secret.php
|
/node_modules
|
||||||
|
/build
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
pnpm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
# OS
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# Tests
|
||||||
|
/coverage
|
||||||
|
/.nyc_output
|
||||||
|
|
||||||
|
# IDEs and editors
|
||||||
|
/.idea
|
||||||
|
.project
|
||||||
|
.classpath
|
||||||
|
.c9/
|
||||||
|
*.launch
|
||||||
|
.settings/
|
||||||
|
*.sublime-workspace
|
||||||
|
|
||||||
|
# IDE - VSCode
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
||||||
|
|
||||||
|
# dotenv environment variable files
|
||||||
|
.env
|
||||||
|
.env.development.local
|
||||||
|
.env.test.local
|
||||||
|
.env.production.local
|
||||||
|
.env.local
|
||||||
|
|
||||||
|
# temp directory
|
||||||
|
.temp
|
||||||
|
.tmp
|
||||||
|
|
||||||
|
# Runtime data
|
||||||
|
pids
|
||||||
|
*.pid
|
||||||
|
*.seed
|
||||||
|
*.pid.lock
|
||||||
|
|
||||||
|
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||||
|
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||||
|
|||||||
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
[submodule "src/dto"]
|
||||||
|
path = src/dto
|
||||||
|
url = git@github.com:R40fendt/ritzenbergen-dto.git
|
||||||
4
.prettierrc
Normal file
4
.prettierrc
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"singleQuote": true,
|
||||||
|
"trailingComma": "all"
|
||||||
|
}
|
||||||
17
Dockerfile.dev
Normal file
17
Dockerfile.dev
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
FROM node:20-alpine
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# nur package-Dateien zuerst, damit Docker-Cache greift
|
||||||
|
COPY package*.json ./
|
||||||
|
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
# Rest des Codes
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Vite Dev-Server
|
||||||
|
EXPOSE 3000
|
||||||
|
|
||||||
|
CMD ["npm", "run", "start:dev"]
|
||||||
|
|
||||||
100
README.md
Executable file → Normal file
100
README.md
Executable file → Normal file
@@ -1,2 +1,98 @@
|
|||||||
# ritzenbergenapi
|
<p align="center">
|
||||||
API für ritzenbergen.de
|
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
|
||||||
|
[circleci-url]: https://circleci.com/gh/nestjs/nest
|
||||||
|
|
||||||
|
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
||||||
|
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
||||||
|
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
|
||||||
|
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
|
||||||
|
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
|
||||||
|
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
|
||||||
|
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
|
||||||
|
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg" alt="Donate us"/></a>
|
||||||
|
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
|
||||||
|
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow" alt="Follow us on Twitter"></a>
|
||||||
|
</p>
|
||||||
|
<!--[](https://opencollective.com/nest#backer)
|
||||||
|
[](https://opencollective.com/nest#sponsor)-->
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
|
||||||
|
|
||||||
|
## Project setup
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
## Compile and run the project
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# development
|
||||||
|
$ npm run start
|
||||||
|
|
||||||
|
# watch mode
|
||||||
|
$ npm run start:dev
|
||||||
|
|
||||||
|
# production mode
|
||||||
|
$ npm run start:prod
|
||||||
|
```
|
||||||
|
|
||||||
|
## Run tests
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# unit tests
|
||||||
|
$ npm run test
|
||||||
|
|
||||||
|
# e2e tests
|
||||||
|
$ npm run test:e2e
|
||||||
|
|
||||||
|
# test coverage
|
||||||
|
$ npm run test:cov
|
||||||
|
```
|
||||||
|
|
||||||
|
## Deployment
|
||||||
|
|
||||||
|
When you're ready to deploy your NestJS application to production, there are some key steps you can take to ensure it runs as efficiently as possible. Check out the [deployment documentation](https://docs.nestjs.com/deployment) for more information.
|
||||||
|
|
||||||
|
If you are looking for a cloud-based platform to deploy your NestJS application, check out [Mau](https://mau.nestjs.com), our official platform for deploying NestJS applications on AWS. Mau makes deployment straightforward and fast, requiring just a few simple steps:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ npm install -g @nestjs/mau
|
||||||
|
$ mau deploy
|
||||||
|
```
|
||||||
|
|
||||||
|
With Mau, you can deploy your application in just a few clicks, allowing you to focus on building features rather than managing infrastructure.
|
||||||
|
|
||||||
|
## Resources
|
||||||
|
|
||||||
|
Check out a few resources that may come in handy when working with NestJS:
|
||||||
|
|
||||||
|
- Visit the [NestJS Documentation](https://docs.nestjs.com) to learn more about the framework.
|
||||||
|
- For questions and support, please visit our [Discord channel](https://discord.gg/G7Qnnhy).
|
||||||
|
- To dive deeper and get more hands-on experience, check out our official video [courses](https://courses.nestjs.com/).
|
||||||
|
- Deploy your application to AWS with the help of [NestJS Mau](https://mau.nestjs.com) in just a few clicks.
|
||||||
|
- Visualize your application graph and interact with the NestJS application in real-time using [NestJS Devtools](https://devtools.nestjs.com).
|
||||||
|
- Need help with your project (part-time to full-time)? Check out our official [enterprise support](https://enterprise.nestjs.com).
|
||||||
|
- To stay in the loop and get updates, follow us on [X](https://x.com/nestframework) and [LinkedIn](https://linkedin.com/company/nestjs).
|
||||||
|
- Looking for a job, or have a job to offer? Check out our official [Jobs board](https://jobs.nestjs.com).
|
||||||
|
|
||||||
|
## Support
|
||||||
|
|
||||||
|
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
|
||||||
|
|
||||||
|
## Stay in touch
|
||||||
|
|
||||||
|
- Author - [Kamil Myśliwiec](https://twitter.com/kammysliwiec)
|
||||||
|
- Website - [https://nestjs.com](https://nestjs.com/)
|
||||||
|
- Twitter - [@nestframework](https://twitter.com/nestframework)
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
Nest is [MIT licensed](https://github.com/nestjs/nest/blob/master/LICENSE).
|
||||||
|
|||||||
33
addhit.php
33
addhit.php
@@ -1,33 +0,0 @@
|
|||||||
<?php
|
|
||||||
header("Access-Control-Allow-Origin: *");
|
|
||||||
header("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
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
<?php
|
|
||||||
header("Content-Type: application/json");
|
|
||||||
header("Access-Control-Allow-Origin: *");
|
|
||||||
header("Access-Control-Allow-Headers: Authorization, Content-Type");
|
|
||||||
|
|
||||||
|
|
||||||
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"}');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
<?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 `ritzenbergen-events` (`eventname`,`datum`,`type`,`content`,`minitext`) VALUES ('',CURDATE(),'markdown','','');");
|
|
||||||
|
|
||||||
echo '{"success":true}';
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
<?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["id"])) die("GET id fehlt");
|
|
||||||
$eventid=$_GET["id"];
|
|
||||||
|
|
||||||
mysqli_execute_query($db_id,"DELETE FROM `ritzenbergen-events` WHERE `id`=?;",[$eventid]);
|
|
||||||
|
|
||||||
echo '{"success":true}';
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
<?php
|
|
||||||
include("../../../mysqlverbinden.php");
|
|
||||||
include("../secret.php");
|
|
||||||
include("../../vendor/autoload.php");
|
|
||||||
|
|
||||||
include("../check.php");
|
|
||||||
|
|
||||||
$payload=getUserInfo();
|
|
||||||
|
|
||||||
$username=$payload->username;
|
|
||||||
$id=$payload->id;
|
|
||||||
|
|
||||||
$rawBody = file_get_contents('php://input');
|
|
||||||
|
|
||||||
$_POSTBODY = json_decode($rawBody, true);
|
|
||||||
|
|
||||||
if($_POSTBODY===null) die("Kein Body übertragen");
|
|
||||||
|
|
||||||
|
|
||||||
if(!isset($_POSTBODY["eventname"])) die("POSTBODY eventname fehlt");
|
|
||||||
$eventname=$_POSTBODY["eventname"];
|
|
||||||
|
|
||||||
if(!isset($_POSTBODY["datum"])) die("POSTBODY datum fehlt");
|
|
||||||
$datum=$_POSTBODY["datum"];
|
|
||||||
|
|
||||||
if(!isset($_POSTBODY["type"])) die("POSTBODY type fehlt");
|
|
||||||
$type=$_POSTBODY["type"];
|
|
||||||
|
|
||||||
if(!isset($_POSTBODY["content"])) die("POSTBODY content fehlt");
|
|
||||||
$content=$_POSTBODY["content"];
|
|
||||||
|
|
||||||
if(!isset($_POSTBODY["minitext"])) die("POSTBODY minitext fehlt");
|
|
||||||
$minitext=$_POSTBODY["minitext"];
|
|
||||||
|
|
||||||
if(!isset($_POSTBODY["link"])) $link=null;
|
|
||||||
else $link=$_POSTBODY["link"];
|
|
||||||
|
|
||||||
if(!isset($_POSTBODY["foto"])) die("POSTBODY foto fehlt");
|
|
||||||
$foto=$_POSTBODY["foto"];
|
|
||||||
|
|
||||||
if(!isset($_POSTBODY["id"])) die("POSTBODY id fehlt");
|
|
||||||
$eventid=$_POSTBODY["id"];
|
|
||||||
|
|
||||||
if(mysqli_execute_query($db_id,"SELECT COUNT(*) FROM `ritzenbergen-events` WHERE `id`=?;",[$eventid])->fetch_assoc()["COUNT(*)"]!=1) die("Dieses Event gibt es nicht");
|
|
||||||
|
|
||||||
mysqli_execute_query($db_id,"UPDATE `ritzenbergen-events` SET `eventname`=?,`datum`=?,`type`=?,`content`=?,`minitext`=?, `link`=?, `foto`=? WHERE `id`=?;",[$eventname,$datum,$type,$content,$minitext,$link,$foto,$eventid]);
|
|
||||||
|
|
||||||
echo '{"success":true}';
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
<?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["id"])) die("GET id fehlt");
|
|
||||||
$formid=$_GET["id"];
|
|
||||||
|
|
||||||
mysqli_execute_query($db_id,"DELETE FROM `formulare-ergebnisse` WHERE `formular`=?;",[$formid]);
|
|
||||||
|
|
||||||
foreach(mysqli_execute_query($db_id,"SELECT `id` FROM `formulare-ergebnisse` WHERE `formular`=?;",[$formid]) as $row){
|
|
||||||
|
|
||||||
mysqli_execute_query($db_id,"DELETE FROM `formulare-ergebnis` WHERE `ergebnisid`=?;",[$row["id"]]);
|
|
||||||
}
|
|
||||||
|
|
||||||
mysqli_execute_query($db_id,"DELETE FROM `formulare-fields` WHERE `formular`=?;",[$formid]);
|
|
||||||
|
|
||||||
mysqli_execute_query($db_id,"DELETE FROM `formulare` WHERE `id`=?;",[$formid]);
|
|
||||||
|
|
||||||
echo '{"success":true}';
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
<?php
|
|
||||||
include("../../../mysqlverbinden.php");
|
|
||||||
include("../secret.php");
|
|
||||||
include("../../vendor/autoload.php");
|
|
||||||
|
|
||||||
include("../check.php");
|
|
||||||
include("../../formulare/get_results_lib.php");
|
|
||||||
|
|
||||||
$payload=getUserInfo();
|
|
||||||
|
|
||||||
$username=$payload->username;
|
|
||||||
$id=$payload->id;
|
|
||||||
|
|
||||||
if(!isset($_GET["formular"])) die("GET formular fehlt");
|
|
||||||
$formular=$_GET["formular"];
|
|
||||||
|
|
||||||
|
|
||||||
echo json_encode(get_results($formular),JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
<?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}';
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
<?php
|
|
||||||
include("../../../mysqlverbinden.php");
|
|
||||||
include("../secret.php");
|
|
||||||
include("../../vendor/autoload.php");
|
|
||||||
|
|
||||||
include("../check.php");
|
|
||||||
|
|
||||||
$payload=getUserInfo();
|
|
||||||
|
|
||||||
$username=$payload->username;
|
|
||||||
$id=$payload->id;
|
|
||||||
|
|
||||||
$rawBody = file_get_contents('php://input');
|
|
||||||
|
|
||||||
$data = json_decode($rawBody, true);
|
|
||||||
|
|
||||||
if($data===null) die("Kein Body übertragen");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$formexists=mysqli_execute_query($db_id,"SELECT COUNT(*) FROM `formulare` WHERE `id`=?;",[$data["id"]])->fetch_assoc()["COUNT(*)"]==1;
|
|
||||||
|
|
||||||
if(!$formexists) die("Diese Form gibt es nicht");
|
|
||||||
|
|
||||||
|
|
||||||
mysqli_execute_query($db_id,"UPDATE `formulare` SET `name`=?, `minitext`=?, `public`=?, `multiple`=? WHERE `id`=?;",[$data["name"], $data["minitext"],$data["ispublic"]?1:0,$data["multiple"]?1:0,$data["id"]]);
|
|
||||||
|
|
||||||
mysqli_execute_query($db_id,"SET FOREIGN_KEY_CHECKS = 0;");
|
|
||||||
mysqli_execute_query($db_id,"DELETE FROM `formulare-fields` WHERE `formular`=?;",[$data["id"]]);
|
|
||||||
mysqli_execute_query($db_id,"SET FOREIGN_KEY_CHECKS = 1;");
|
|
||||||
|
|
||||||
|
|
||||||
foreach($data["fields"] as $field){
|
|
||||||
mysqli_execute_query($db_id,"INSERT INTO `formulare-fields` (`id`,`formular`,`name`,`displayname`,`value`,`displayvalue`,`placeholder`,`type`,`title`,`required`,`maxlength`,`min`,`max`,`checked`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?);",
|
|
||||||
[isset($field["id"])?$field["id"]:null,isset($field["formular"])?$field["formular"]:$data["id"],$field["name"],$field["displayname"],$field["value"],$field["displayvalue"],$field["placeholder"],$field["type"],$field["title"],$field["required"]?1:0,$field["maxlength"],$field["min"],$field["max"],$field["checked"]?1:0]);
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
<?php
|
|
||||||
header("Content-Type: application/json");
|
|
||||||
header("Access-Control-Allow-Origin: *");
|
|
||||||
|
|
||||||
include("../../mysqlverbinden.php");
|
|
||||||
include("../vendor/autoload.php");
|
|
||||||
|
|
||||||
use Firebase\JWT\JWT;
|
|
||||||
use Firebase\JWT\Key;
|
|
||||||
|
|
||||||
include("secret.php");
|
|
||||||
|
|
||||||
if(!isset($_GET["username"])) die("GET username fehlt");
|
|
||||||
$username=$_GET["username"];
|
|
||||||
|
|
||||||
if(!isset($_GET["password"])) die("GET password fehlt");
|
|
||||||
$password=$_GET["password"];
|
|
||||||
|
|
||||||
$result=mysqli_execute_query($db_id,"SELECT `password`, `id` FROM `adminpanel-users` WHERE `username`=?;",[$username])->fetch_assoc();
|
|
||||||
if(!isset($result["password"]))
|
|
||||||
die('{"error":"Falscher Benutzername","success":false}');
|
|
||||||
|
|
||||||
if(!password_verify($password,$result["password"]))
|
|
||||||
die('{"error":"Falsches Passwort","success":false}');
|
|
||||||
|
|
||||||
$payload=[
|
|
||||||
"id"=>$result["id"],
|
|
||||||
"username"=>$username,
|
|
||||||
"expire"=>time()+3600
|
|
||||||
];
|
|
||||||
|
|
||||||
$token=JWT::encode($payload,$secret,"HS256");
|
|
||||||
|
|
||||||
echo json_encode(["token"=>$token,"success"=>true],JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
|
|
||||||
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
<?php
|
|
||||||
include("../../mysqlverbinden.php");
|
|
||||||
include("secret.php");
|
|
||||||
include("../vendor/autoload.php");
|
|
||||||
|
|
||||||
|
|
||||||
include("check.php");
|
|
||||||
|
|
||||||
$payload=getUserInfo();
|
|
||||||
echo json_encode($payload,JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);
|
|
||||||
@@ -1,141 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>BuLi-Punkte</title>
|
|
||||||
<link rel="stylesheet" href="bulitipp2.css">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<style>
|
|
||||||
h1{
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
include("../../mysqlverbinden.php");
|
|
||||||
include("../rowforeach.php");
|
|
||||||
|
|
||||||
$ansichten=["spiel","user","user-preview"];
|
|
||||||
|
|
||||||
if(!isset($_GET["spieltag"])) die("GET spieltag fehlt");
|
|
||||||
$spieltag=$_GET["spieltag"];
|
|
||||||
|
|
||||||
if(!isset($_GET["paarung"])) die("GET paarung fehlt");
|
|
||||||
$paarungid=$_GET["paarung"];
|
|
||||||
|
|
||||||
if(!isset($_GET["detail"])) die("GET detail fehlt");
|
|
||||||
$detail=$_GET["detail"];
|
|
||||||
|
|
||||||
if(!isset($_GET["name"])) die("GET name fehlt");
|
|
||||||
$name=$_GET["name"];
|
|
||||||
|
|
||||||
if(!in_array($detail,$ansichten)) die("Ungültige Ansicht");
|
|
||||||
|
|
||||||
include("./inc.php");
|
|
||||||
$paarungsql=srowforeach("SELECT heim, gast from `buli-paarungen` where `id`=?;",[$paarungid]);
|
|
||||||
if(count($paarungsql)==0) $paarung=null;
|
|
||||||
else $paarung=$paarungsql[0];
|
|
||||||
if($detail=="spiel") $results=srowforeach("SELECT score1,score2 from `buli-results` where `paarung`=? AND `spieltag`=?;",[$paarungid,$spieltag])[0];
|
|
||||||
if($detail=="spiel"){
|
|
||||||
?>
|
|
||||||
<h1 class="detailansichtSchriftart">Detailansicht, <?php echo $spieltag; ?>. Spieltag</h1>
|
|
||||||
<h2 class="detailansichtSchriftart"><?php echo $paarung[0]; ?> - <?php echo $paarung[1]; ?></h2>
|
|
||||||
<h1><?php echo $results[0]; ?> - <?php echo $results[1]; ?></h1>
|
|
||||||
<table class="detailansichtSchriftart">
|
|
||||||
<tr>
|
|
||||||
<td>Name</td>
|
|
||||||
<td>Tipp</td>
|
|
||||||
<td>Punkte</td>
|
|
||||||
<td>Gesamtpunkte</td>
|
|
||||||
</tr>
|
|
||||||
<?php
|
|
||||||
foreach (rowforeach("SELECT `username` from `buli-user`;") as $key => $value) {
|
|
||||||
$name=$value[0];
|
|
||||||
$punkte=ps($name,$spieltag,$paarungid);
|
|
||||||
$gesamtpunkte=gs($name,$spieltag);
|
|
||||||
$tipp=getTipp($name,$spieltag,$paarungid);
|
|
||||||
$tippstr=($tipp==null)?"-":$tipp[0]." - ".$tipp[1];
|
|
||||||
?>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td><?php echo $name; ?></td>
|
|
||||||
<td><?php echo $tippstr; ?></td>
|
|
||||||
<td><?php echo $punkte; ?></td>
|
|
||||||
<td><?php echo $gesamtpunkte; ?></td>
|
|
||||||
</tr>
|
|
||||||
<?php
|
|
||||||
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
|
||||||
</table>
|
|
||||||
<?php
|
|
||||||
}else if($detail=="user"){
|
|
||||||
?>
|
|
||||||
<h1 class="detailansichtSchriftart">Detailansicht für <?php echo $name; ?>, <?php echo $spieltag; ?>. Spieltag</h1>
|
|
||||||
<table class="detailansichtSchriftart">
|
|
||||||
<tr>
|
|
||||||
<td>Tipp von <?php echo $name; ?></td>
|
|
||||||
<td>Ergebnis</td>
|
|
||||||
<td>Tipp</td>
|
|
||||||
<td>Punkte</td>
|
|
||||||
</tr>
|
|
||||||
<?php
|
|
||||||
foreach(srowforeach("SELECT paarung, score1, score2 from `buli-results` where spieltag=?;",[$spieltag]) as $key=>$value){
|
|
||||||
$id=$value[0];
|
|
||||||
$score1=$value[1];
|
|
||||||
$score2=$value[2];
|
|
||||||
$tipp=getTipp($name,$spieltag,$id);
|
|
||||||
$paarungQuery=srowforeach("SELECT heim, gast from `buli-paarungen` where id=?;",[$id])[0];
|
|
||||||
$heim=$paarungQuery[0];
|
|
||||||
$gast=$paarungQuery[1];
|
|
||||||
$punkte=ps($name,$spieltag,$id);
|
|
||||||
$tippstr=($tipp==null)?"-":$tipp[0]." - ".$tipp[1];
|
|
||||||
?>
|
|
||||||
<tr>
|
|
||||||
<td><?php echo $heim; ?> - <?php echo $gast; ?></td>
|
|
||||||
<td><?php echo $score1; ?> - <?php echo $score2; ?></td>
|
|
||||||
<td><?php echo $tippstr; ?></td>
|
|
||||||
<td><?php echo $punkte; ?></td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
}else if($detail=="user-preview"){
|
|
||||||
?>
|
|
||||||
<h1 class="detailansichtSchriftart">Detailansicht für <?php echo $name; ?>, <?php echo $spieltag; ?>. Spieltag</h1>
|
|
||||||
<table class="detailansichtSchriftart">
|
|
||||||
<tr>
|
|
||||||
<td>Paarung</td>
|
|
||||||
<td>Tipp von <?php echo $name; ?></td>
|
|
||||||
</tr>
|
|
||||||
<?php
|
|
||||||
foreach(srowforeach("SELECT `id`,`heim`,`gast` from `buli-paarungen` where spieltag=?;",[$spieltag]) as $key=>$value){
|
|
||||||
$id=$value[0];
|
|
||||||
$tipp=getTipp($name,$spieltag,$id);
|
|
||||||
$heim=$value[1];
|
|
||||||
$gast=$value[2];
|
|
||||||
$tippstr=($tipp==null)?"-":$tipp[0]." - ".$tipp[1];
|
|
||||||
?>
|
|
||||||
<tr>
|
|
||||||
<td><?php echo $heim; ?> - <?php echo $gast; ?></td>
|
|
||||||
<td><?php echo $tippstr; ?></td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</table>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,350 +0,0 @@
|
|||||||
.buli-container {
|
|
||||||
width: 100%; /* Passe die Breite an deine Bedürfnisse an */
|
|
||||||
margin: 0 auto; /* Zentriert den Container */
|
|
||||||
padding: 20px;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
form {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
input[type="number"],
|
|
||||||
input[type="text"],
|
|
||||||
input[type="password"] {
|
|
||||||
padding: 10px;
|
|
||||||
margin-bottom: 15px;
|
|
||||||
border: 1px solid #ccc;
|
|
||||||
border-radius: 4px;
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
input[type="submit"] {
|
|
||||||
background-color: #4CAF50; /* Grün für einen positiven Button */
|
|
||||||
color: white;
|
|
||||||
padding: 12px 20px;
|
|
||||||
border: none;
|
|
||||||
border-radius: 4px;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: background-color 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
input[type="submit"]:hover {
|
|
||||||
background-color: #3e8e41;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.scroll-x{
|
|
||||||
overflow-x: scroll;
|
|
||||||
}
|
|
||||||
/* Paarungsergebnisse */
|
|
||||||
table {
|
|
||||||
border-collapse: collapse;
|
|
||||||
width: 60%;
|
|
||||||
margin: 0 auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
tr, td {
|
|
||||||
border: 1px solid #ddd;
|
|
||||||
padding: 8px;
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
tr:first-child{
|
|
||||||
background-color: #fafafa;
|
|
||||||
}
|
|
||||||
|
|
||||||
tr:hover{
|
|
||||||
background-color: #f2f2f2;
|
|
||||||
}
|
|
||||||
|
|
||||||
.TippsAnzeigen tr:hover, .TippsAnzeigen tr:first-child {
|
|
||||||
background-color: unset;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.buli-results a:hover {
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
|
|
||||||
.buli-results h2 {
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.buli-results span.team {
|
|
||||||
width: 40%;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
justify-content: baseline;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.buli-results{
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
.teams{
|
|
||||||
display: flex;
|
|
||||||
font-size: 17px;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
flex-direction: row;
|
|
||||||
float: left;
|
|
||||||
width: 100%;
|
|
||||||
max-width: 500px;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
.buli-results span.team:first-child{
|
|
||||||
text-align: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
.buli-results span.team:last-child{
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.buli-results span.team img {
|
|
||||||
|
|
||||||
width: 30px;
|
|
||||||
height: 30px;
|
|
||||||
|
|
||||||
border-radius: 50%; /* Macht das Bild rund */
|
|
||||||
|
|
||||||
}
|
|
||||||
.buli-results span.team p{
|
|
||||||
width: 175px;
|
|
||||||
height: 30px;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
vertical-align: middle;
|
|
||||||
margin-bottom: 0;
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
|
|
||||||
span.vs{
|
|
||||||
width: 20px;
|
|
||||||
/* margin-left: 10%;
|
|
||||||
margin-right: 10%; */
|
|
||||||
height: 3px;
|
|
||||||
background-color: black;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
h2 {
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#spieltagText {
|
|
||||||
margin: 0px;
|
|
||||||
padding: 0px;
|
|
||||||
padding-bottom: 5px;
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* TippenEintragen */
|
|
||||||
|
|
||||||
.tippenEintragen form {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
width: 100vw;
|
|
||||||
}
|
|
||||||
|
|
||||||
.paarung {
|
|
||||||
margin: 10px 0;
|
|
||||||
width: 100vw;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tippenEintragen span.team-name {
|
|
||||||
width: 30%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tippenEintragen input[type="number"] {
|
|
||||||
/* max-width: 150px; */
|
|
||||||
width: 50px;
|
|
||||||
|
|
||||||
border: 1px solid #ccc;
|
|
||||||
border-radius: 5px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
@media (max-width: 512px){
|
|
||||||
.paarung img{
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* Submit-Button */
|
|
||||||
.tippenEintragen input[type="submit"] {
|
|
||||||
background-color: #4CAF50;
|
|
||||||
color: white;
|
|
||||||
padding: 10px 20px;
|
|
||||||
border: none;
|
|
||||||
border-radius: 5px;
|
|
||||||
cursor: pointer;
|
|
||||||
width: 150px;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Meldung für nicht vorbereiteten Spieltag */
|
|
||||||
.tippenEintragen h1 {
|
|
||||||
color: red;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Spieler hat bereits getippt Tabelle */
|
|
||||||
|
|
||||||
.TippsAnzeigen {
|
|
||||||
text-align: center;
|
|
||||||
font-family: "Roboto", sans-serif;
|
|
||||||
}
|
|
||||||
|
|
||||||
.TippsAnzeigen table {
|
|
||||||
border-collapse: collapse;
|
|
||||||
width: 80%;
|
|
||||||
margin: 0 auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.TippsAnzeigen th, .TippsAnzeigen td {
|
|
||||||
border: 1px solid #ddd;
|
|
||||||
padding: 8px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Alternierende Zeilen für bessere Lesbarkeit */
|
|
||||||
.TippsAnzeigen tr:nth-child(even) {
|
|
||||||
background-color: #f2f2f2;
|
|
||||||
}
|
|
||||||
|
|
||||||
#load-table-btn{
|
|
||||||
position: absolute;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
.detailansichtSchriftart {
|
|
||||||
font-family: "Roboto", sans-serif;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
.buli-table{
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
#load-table-btn-container{
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
background: white;
|
|
||||||
opacity: 0.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
#load-table-btn{
|
|
||||||
color: white;
|
|
||||||
border-radius: 5px;
|
|
||||||
background-color: green;
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.as-link{
|
|
||||||
color: #00f;
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.roboto-thin {
|
|
||||||
font-family: "Roboto", sans-serif;
|
|
||||||
font-weight: 100;
|
|
||||||
font-style: normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
.roboto-light {
|
|
||||||
font-family: "Roboto", sans-serif;
|
|
||||||
font-weight: 300;
|
|
||||||
font-style: normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
.roboto-regular {
|
|
||||||
font-family: "Roboto", sans-serif;
|
|
||||||
font-weight: 400;
|
|
||||||
font-style: normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
.roboto-medium {
|
|
||||||
font-family: "Roboto", sans-serif;
|
|
||||||
font-weight: 500;
|
|
||||||
font-style: normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
.roboto-bold {
|
|
||||||
font-family: "Roboto", sans-serif;
|
|
||||||
font-weight: 700;
|
|
||||||
font-style: normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
.roboto-black {
|
|
||||||
font-family: "Roboto", sans-serif;
|
|
||||||
font-weight: 900;
|
|
||||||
font-style: normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
.roboto-thin-italic {
|
|
||||||
font-family: "Roboto", sans-serif;
|
|
||||||
font-weight: 100;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
|
|
||||||
.roboto-light-italic {
|
|
||||||
font-family: "Roboto", sans-serif;
|
|
||||||
font-weight: 300;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
|
|
||||||
.roboto-regular-italic {
|
|
||||||
font-family: "Roboto", sans-serif;
|
|
||||||
font-weight: 400;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
|
|
||||||
.roboto-medium-italic {
|
|
||||||
font-family: "Roboto", sans-serif;
|
|
||||||
font-weight: 500;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
|
|
||||||
.roboto-bold-italic {
|
|
||||||
font-family: "Roboto", sans-serif;
|
|
||||||
font-weight: 700;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
|
|
||||||
.roboto-black-italic {
|
|
||||||
font-family: "Roboto", sans-serif;
|
|
||||||
font-weight: 900;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
@@ -1,135 +0,0 @@
|
|||||||
<?php
|
|
||||||
include("../../mysqlverbinden.php");
|
|
||||||
include("../rowforeach.php");
|
|
||||||
include("inc.php");
|
|
||||||
|
|
||||||
$bundesliga = file_get_contents("liga.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
|
|
||||||
|
|
||||||
$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 "Fehler beim HTTP Request!";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$responseData = json_decode($response, true); // Response auswerten
|
|
||||||
if ($responseData!=null) {
|
|
||||||
// Response-Data ist ok
|
|
||||||
// Wochentag und Uhrzeit überprüfen, also auch überprüfen, ob die Daten schon aktuell sind
|
|
||||||
$aktuell = false;
|
|
||||||
foreach ($responseData as $key => $match) {
|
|
||||||
|
|
||||||
// Datum in UTC einlesen
|
|
||||||
$date = new DateTime($match["matchDateTimeUTC"], new DateTimeZone('UTC'));
|
|
||||||
|
|
||||||
// In die Zeitzone Berlin konvertieren
|
|
||||||
$date->setTimezone(new DateTimeZone('Europe/Berlin'));
|
|
||||||
|
|
||||||
|
|
||||||
$diff = time()-$date->getTimestamp();
|
|
||||||
|
|
||||||
if ($diff >= -60 * 60 * 24 * 21) {
|
|
||||||
$aktuell = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
if ($aktuell) {
|
|
||||||
// Daten sind aktuell genug, Paarungen in die Datenbank einfügen
|
|
||||||
$spieltag=getmaxtippspieltag()+1;
|
|
||||||
foreach ($responseData as $key => $match) {
|
|
||||||
|
|
||||||
$deadline = new DateTime($match["matchDateTimeUTC"], new DateTimeZone('UTC'));
|
|
||||||
|
|
||||||
// In die Zeitzone Berlin konvertieren
|
|
||||||
$deadline->setTimezone(new DateTimeZone('Europe/Berlin'));
|
|
||||||
|
|
||||||
$heim=$match["team1"]["shortName"];
|
|
||||||
$gast=$match["team2"]["shortName"];
|
|
||||||
|
|
||||||
|
|
||||||
mysqli_execute_query($db_id,"INSERT INTO `buli-paarungen` (`heim`,`gast`,`spieltag`,`deadline`) VALUES (?,?,?,?);",[$heim,$gast,$spieltag,$deadline->format('Y-m-d H:i:s')]);
|
|
||||||
$reload=true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Response ist kein JSON
|
|
||||||
// echo "<script>window.alert(`JSON-Response ungültig (Z.84)! Bitte einen Admin kontaktieren! BuLi-Tipp Daten konnten nicht aktualisiert werden.`);</script>";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
$spieltag=getmaxspieltag()+1;
|
|
||||||
|
|
||||||
|
|
||||||
$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.15)! Bitte einen Admin kontaktieren! BuLi-Tipp Daten konnten nicht aktualisiert werden.`);</script>";
|
|
||||||
}
|
|
||||||
|
|
||||||
$responseData = json_decode($response, true); // Response auswerten
|
|
||||||
if ($responseData) {
|
|
||||||
// Response-Data ist ok
|
|
||||||
foreach ($responseData as $key => $match) {
|
|
||||||
if ($match["matchIsFinished"]) {
|
|
||||||
// Spiel beendet, Ergebnisse in die Datenbank eintragen
|
|
||||||
$heim=$match["team1"]["shortName"];
|
|
||||||
$gast=$match["team2"]["shortName"];
|
|
||||||
$paarungsquery=srowforeach("SELECT `id` from `buli-paarungen` where spieltag=? AND heim=? AND gast=?;",[$spieltag,$heim,$gast]);
|
|
||||||
if(count($paarungsquery)==0) continue;
|
|
||||||
|
|
||||||
|
|
||||||
$paarungsid=$paarungsquery[0][0];
|
|
||||||
$score1=$match["matchResults"][1]["pointsTeam1"];
|
|
||||||
$score2=$match["matchResults"][1]["pointsTeam2"];
|
|
||||||
mysqli_execute_query($db_id,"INSERT INTO `buli-results` (paarung, score1,score2, spieltag) VALUES (?,?,?,?);",[$paarungsid,$score1,$score2,$spieltag]);
|
|
||||||
$reload=true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Response ist kein JSON
|
|
||||||
// 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`;",[]);
|
|
||||||
$responseDataTeams=json_decode(file_get_contents("https://api.openligadb.de/getavailableteams/bl".$bundesliga."/".$year, false),true);
|
|
||||||
|
|
||||||
foreach($responseDataTeams as $key => $value){
|
|
||||||
$iconurl=$value["teamIconUrl"];
|
|
||||||
$name=$value["shortName"];
|
|
||||||
$image=file_get_contents($iconurl,false);
|
|
||||||
mysqli_execute_query($db_id,"INSERT INTO `buli-icons` (`team`,`img`) VALUES (?,?);",[$name,$image]);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
flock($lockFile, LOCK_UN);
|
|
||||||
fclose($lockFile);
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
header("Access-Control-Allow-Origin: *");
|
|
||||||
header("Content-Type: application/json; charset=UTF-8");
|
|
||||||
include("../../mysqlverbinden.php");
|
|
||||||
include("../rowforeach.php");
|
|
||||||
|
|
||||||
if(!isset($_GET["spieltag"])) die("GET spieltag fehlt");
|
|
||||||
$spieltag = $_GET["spieltag"];
|
|
||||||
|
|
||||||
$deadline = srowforeach("SELECT deadline from `buli-paarungen` where spieltag=? ORDER BY `deadline` ASC;", [$spieltag])[0][0];
|
|
||||||
date_default_timezone_set('Europe/Berlin');
|
|
||||||
|
|
||||||
$data=[
|
|
||||||
"deadline" => strtotime($deadline),
|
|
||||||
"now" => time(),
|
|
||||||
"deadlinePassed" => strtotime($deadline) < time()
|
|
||||||
];
|
|
||||||
|
|
||||||
echo json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
<?php
|
|
||||||
header("Access-Control-Allow-Origin: *");
|
|
||||||
header("Content-Type: application/json");
|
|
||||||
include("./check.php");
|
|
||||||
|
|
||||||
$data=[];
|
|
||||||
|
|
||||||
$paarungsids=srowforeach("SELECT id from `buli-paarungen` where `spieltag`=?;",[getmaxspieltag()]);
|
|
||||||
foreach ($paarungsids as $key => $value) {
|
|
||||||
$paarungsid=$value[0];
|
|
||||||
array_push($data,getResult($paarungsid, getmaxspieltag()));
|
|
||||||
}
|
|
||||||
|
|
||||||
$result=["reload"=>$reload,"data"=>$data];
|
|
||||||
echo json_encode($result, JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
<?php
|
|
||||||
include("./check.php");
|
|
||||||
|
|
||||||
if(!isset($_GET["team"])) die("GET team fehlt");
|
|
||||||
$team=$_GET["team"];
|
|
||||||
|
|
||||||
header("Content-Type: img/png");
|
|
||||||
|
|
||||||
echo srowforeach("SELECT `img` from `buli-icons` where `team`=?;",[$team])[0][0];
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
<?php
|
|
||||||
header("Access-Control-Allow-Origin: *");
|
|
||||||
include("./check.php");
|
|
||||||
|
|
||||||
$data=[];
|
|
||||||
|
|
||||||
foreach(srowforeach("SELECT `id`, `kuerzel`, `username` from `buli-user`;",[]) as $key=>$value){
|
|
||||||
$data[$key]["id"]=$value[0];
|
|
||||||
$data[$key]["kuerzel"]=$value[1];
|
|
||||||
$data[$key]["name"]=$value[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
$result=["reload"=>$reload,"data"=>$data];
|
|
||||||
|
|
||||||
echo json_encode($result, JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
header("Access-Control-Allow-Origin: *");
|
|
||||||
header("Content-Type: application/json");
|
|
||||||
|
|
||||||
include("./check.php");
|
|
||||||
|
|
||||||
if(!isset($_GET["userid"])) die("GET userid fehlt");
|
|
||||||
$userid = $_GET["userid"];
|
|
||||||
|
|
||||||
// Überprüfen, ob es den Benutzer gibt
|
|
||||||
$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";
|
|
||||||
|
|
||||||
104
bulitipp/inc.php
104
bulitipp/inc.php
@@ -1,104 +0,0 @@
|
|||||||
<?php
|
|
||||||
function getTipp($name, $spieltag, $paarungid)
|
|
||||||
{
|
|
||||||
$userid=srowforeach("SELECT `id` from `buli-user` where username=?;",[$name])[0][0];
|
|
||||||
$tippQueryResult = srowforeach("SELECT `tipp1`,`tipp2`,`tipp3`,`tipp4`,`tipp5`,`tipp6`,`tipp7`,`tipp8`,`tipp9` from `buli-tipps` where user=? AND spieltag=?;", [$userid, $spieltag]);
|
|
||||||
if (count($tippQueryResult) == 0)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
$tippids=$tippQueryResult[0];
|
|
||||||
$paarungen=srowforeach("SELECT `id` from `buli-paarungen` where `spieltag`=?;",[$spieltag]);
|
|
||||||
|
|
||||||
$i=0;
|
|
||||||
foreach($tippids as $key => $value){
|
|
||||||
if($paarungid==$paarungen[$i][0]){
|
|
||||||
// return [0] heim, [1] gast
|
|
||||||
return srowforeach("SELECT `score1`,`score2` from `buli-tipp` where `id`=?;",[$value])[0];
|
|
||||||
}
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function getResult($paarungid,$spieltag){
|
|
||||||
return srowforeach("SELECT score1, score2 from `buli-results` where `paarung`=? AND spieltag=?;", [$paarungid, $spieltag])[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
function ps($name, $spieltag, $paarungid)
|
|
||||||
{
|
|
||||||
$punkte = getResult($paarungid,$spieltag);
|
|
||||||
$punktetipp = getTipp($name, $spieltag, $paarungid);
|
|
||||||
|
|
||||||
if ($punktetipp == null){
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($punkte == $punktetipp)
|
|
||||||
return 3;
|
|
||||||
|
|
||||||
$differenz = $punkte[0] - $punkte[1];
|
|
||||||
|
|
||||||
$differenztipp = $punktetipp[0] - $punktetipp[1];
|
|
||||||
|
|
||||||
if ($differenz == $differenztipp)
|
|
||||||
return 2;
|
|
||||||
|
|
||||||
if ($punktetipp[0] == $punktetipp[1] || $punkte[0] == $punkte[1]) {
|
|
||||||
// Unentschieden
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$siegertipp = $punktetipp[0] > $punktetipp[1]; // true, wenn der Sieger der 1. ist
|
|
||||||
$sieger = $punkte[0] > $punkte[1]; // true, wenn der Sieger der 1. ist
|
|
||||||
|
|
||||||
if ($sieger == $siegertipp)
|
|
||||||
return 1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
function ts($name, $spieltag)
|
|
||||||
{
|
|
||||||
$punkte = 0;
|
|
||||||
|
|
||||||
foreach (srowforeach("SELECT `paarung` from `buli-results` where spieltag=?;", [$spieltag]) as $key => $value) {
|
|
||||||
$punkte += ps($name, $spieltag, $value[0]);
|
|
||||||
}
|
|
||||||
return $punkte;
|
|
||||||
}
|
|
||||||
|
|
||||||
function gs($name, $spieltagmax)
|
|
||||||
{
|
|
||||||
$punkte = 0;
|
|
||||||
|
|
||||||
for ($i = 0; $i < $spieltagmax; $i++) {
|
|
||||||
$punkte += ts($name, $i+1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $punkte;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getmaxspieltag()
|
|
||||||
{
|
|
||||||
$maxspieltag = 0;
|
|
||||||
foreach (srowforeach("SELECT spieltag from `buli-results`;", []) as $key => $value) {
|
|
||||||
if ($value[0] > $maxspieltag)
|
|
||||||
$maxspieltag = $value[0];
|
|
||||||
}
|
|
||||||
return $maxspieltag;
|
|
||||||
}
|
|
||||||
function getmaxtippspieltag()
|
|
||||||
{
|
|
||||||
$maxspieltag = 0;
|
|
||||||
foreach (srowforeach("SELECT spieltag from `buli-paarungen`;", []) as $key => $value) {
|
|
||||||
if ($value[0] > $maxspieltag)
|
|
||||||
$maxspieltag = $value[0];
|
|
||||||
}
|
|
||||||
return $maxspieltag;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function deadline($spieltag)
|
|
||||||
{ // Gibt true zurück, wenn die Deadline überschritten ist.
|
|
||||||
$deadline = srowforeach("SELECT deadline from `buli-paarungen` where spieltag=? ORDER BY `deadline` ASC;", [$spieltag])[0][0];
|
|
||||||
date_default_timezone_set('Europe/Berlin');
|
|
||||||
|
|
||||||
return date_create_from_format('Y-m-d H:i:s', $deadline)->getTimestamp() < time();
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
$secret="secret";
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
1
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
<?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;
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
<?php
|
|
||||||
header("Access-Control-Allow-Origin: *");
|
|
||||||
header("Content-Type: application/json");
|
|
||||||
include("./check.php");
|
|
||||||
|
|
||||||
echo getmaxspieltag();
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
<?php
|
|
||||||
header("Access-Control-Allow-Origin: *");
|
|
||||||
header("Content-Type: application/json");
|
|
||||||
include("./check.php");
|
|
||||||
|
|
||||||
echo getmaxtippspieltag();
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
<?php
|
|
||||||
include("./check.php");
|
|
||||||
header("Access-Control-Allow-Origin: *");
|
|
||||||
header("Content-Type: application/json");
|
|
||||||
|
|
||||||
if(!isset($_GET["spieltag"])) die("GET spieltag fehlt");
|
|
||||||
$spieltag=$_GET["spieltag"];
|
|
||||||
|
|
||||||
$data=[];
|
|
||||||
foreach (srowforeach("SELECT `heim`,`gast`, `id` from `buli-paarungen` where `spieltag`=?;",[$spieltag]) as $key => $value) {
|
|
||||||
array_push($data,[$value[0],$value[1],$value[2]]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$result=["reload"=>$reload,"data"=>$data];
|
|
||||||
echo json_encode($result, JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);
|
|
||||||
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
<?php
|
|
||||||
header("Access-Control-Allow-Origin: *");
|
|
||||||
echo file_get_contents("saison.txt");
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
2025
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
<?php
|
|
||||||
header("Access-Control-Allow-Origin: *");
|
|
||||||
header("Content-Type: application/json");
|
|
||||||
|
|
||||||
include("./check.php");
|
|
||||||
|
|
||||||
if(!isset($_GET["user"])) die("GET user fehlt");
|
|
||||||
$user = $_GET["user"];
|
|
||||||
|
|
||||||
if(!isset($_GET["spieltag"])) die("GET spieltag fehlt");
|
|
||||||
$spieltag = $_GET["spieltag"];
|
|
||||||
|
|
||||||
$userquery=srowforeach("SELECT `username` FROM `buli-user` WHERE id = ?",[$user]);
|
|
||||||
if(count($userquery) == 0) die("User nicht gefunden");
|
|
||||||
|
|
||||||
$username = $userquery[0][0];
|
|
||||||
|
|
||||||
$data=[];
|
|
||||||
|
|
||||||
foreach(srowforeach("SELECT `id`, `heim`, `gast` from `buli-paarungen` where `spieltag`=?;",[$spieltag]) as $key=>$value){
|
|
||||||
$paarungsid = $value[0];
|
|
||||||
$tipp = getTipp($username, $spieltag, $paarungsid);
|
|
||||||
$result = getResult($paarungsid,$spieltag);
|
|
||||||
array_push($data, ["tipp"=>$tipp, "result"=> $result, "paarung"=>["id"=>$paarungsid, "heim"=>$value[1], "gast"=>$value[2]]]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$result=["reload"=>$reload, "data"=>$data];
|
|
||||||
echo json_encode($result, JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
<?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");
|
|
||||||
include("../rowforeach.php");
|
|
||||||
include("inc.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");
|
|
||||||
}
|
|
||||||
|
|
||||||
$payload = JWT::decode($token, new Key($secret, 'HS256'));
|
|
||||||
$userid= $payload->id;
|
|
||||||
|
|
||||||
if($payload->exp < time()){
|
|
||||||
die("Token abgelaufen");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!isset($_GET["spieltag"])) die("GET spieltag fehlt");
|
|
||||||
$spieltag = $_GET["spieltag"];
|
|
||||||
|
|
||||||
if(!isset($_GET["tipps"])) die("GET tipps fehlt");
|
|
||||||
$tipps = json_decode($_GET["tipps"],true);
|
|
||||||
|
|
||||||
if(deadline($spieltag)){
|
|
||||||
die("deadline überschritten");
|
|
||||||
}
|
|
||||||
|
|
||||||
$tippids=[];
|
|
||||||
foreach($tipps as $tipp){
|
|
||||||
$paarungsid = $tipp['paarung']["id"];
|
|
||||||
$score1 = $tipp['heim'];
|
|
||||||
$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]);
|
|
||||||
$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, $payload->id);
|
|
||||||
|
|
||||||
if(!$update) mysqli_execute_query($db_id,"INSERT INTO `buli-tipps` (`tipp1`, `tipp2`, `tipp3`, `tipp4`, `tipp5`, `tipp6`, `tipp7`, `tipp8`, `tipp9`, `spieltag`, `user`) VALUES (?,?,?,?,?,?,?,?,?,?,?);",$tippids);
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
<?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"];
|
|
||||||
if($spieltag==""||$spieltag=="null") die('{"error":"GET spieltag leer"}');
|
|
||||||
|
|
||||||
$data=[];
|
|
||||||
|
|
||||||
|
|
||||||
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];
|
|
||||||
$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);
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
<?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);
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
<?php
|
|
||||||
header("Access-Control-Allow-Origin: *");
|
|
||||||
include("./check.php");
|
|
||||||
|
|
||||||
$users=srowforeach("SELECT `username`, `id` FROM `buli-user`;",[]);
|
|
||||||
|
|
||||||
$data=[];
|
|
||||||
for($i=0;$i<getmaxspieltag();$i++){
|
|
||||||
$spieltag=$i+1;
|
|
||||||
$data[$i]=[];
|
|
||||||
foreach ($users as $key => $value) {
|
|
||||||
$user=$value[0];
|
|
||||||
$userid=$value[1];
|
|
||||||
$data[$i][]=["points"=>ts($user,$spieltag),"user"=>["id"=>$userid,"name"=>$user]];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$result=["reload"=>$reload, "data"=>$data];
|
|
||||||
echo json_encode($result, JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<?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);
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
<?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;
|
|
||||||
}
|
|
||||||
|
|
||||||
$data=[
|
|
||||||
"spieltag" => getmaxspieltag()+1,
|
|
||||||
"deadline" => $query[0][0],
|
|
||||||
"unixtime" => $unixtime,
|
|
||||||
"hours" => $hours,
|
|
||||||
"days" => $days
|
|
||||||
];
|
|
||||||
|
|
||||||
echo json_encode($data,JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);
|
|
||||||
@@ -1,161 +0,0 @@
|
|||||||
<?php
|
|
||||||
function color_name_to_hex($color_name)
|
|
||||||
{
|
|
||||||
// standard 147 HTML color names
|
|
||||||
$colors = array(
|
|
||||||
'aliceblue' => 'F0F8FF',
|
|
||||||
'antiquewhite' => 'FAEBD7',
|
|
||||||
'aqua' => '00FFFF',
|
|
||||||
'aquamarine' => '7FFFD4',
|
|
||||||
'azure' => 'F0FFFF',
|
|
||||||
'beige' => 'F5F5DC',
|
|
||||||
'bisque' => 'FFE4C4',
|
|
||||||
'black' => '000000',
|
|
||||||
'blanchedalmond ' => 'FFEBCD',
|
|
||||||
'blue' => '0000FF',
|
|
||||||
'blueviolet' => '8A2BE2',
|
|
||||||
'brown' => 'A52A2A',
|
|
||||||
'burlywood' => 'DEB887',
|
|
||||||
'cadetblue' => '5F9EA0',
|
|
||||||
'chartreuse' => '7FFF00',
|
|
||||||
'chocolate' => 'D2691E',
|
|
||||||
'coral' => 'FF7F50',
|
|
||||||
'cornflowerblue' => '6495ED',
|
|
||||||
'cornsilk' => 'FFF8DC',
|
|
||||||
'crimson' => 'DC143C',
|
|
||||||
'cyan' => '00FFFF',
|
|
||||||
'darkblue' => '00008B',
|
|
||||||
'darkcyan' => '008B8B',
|
|
||||||
'darkgoldenrod' => 'B8860B',
|
|
||||||
'darkgray' => 'A9A9A9',
|
|
||||||
'darkgreen' => '006400',
|
|
||||||
'darkgrey' => 'A9A9A9',
|
|
||||||
'darkkhaki' => 'BDB76B',
|
|
||||||
'darkmagenta' => '8B008B',
|
|
||||||
'darkolivegreen' => '556B2F',
|
|
||||||
'darkorange' => 'FF8C00',
|
|
||||||
'darkorchid' => '9932CC',
|
|
||||||
'darkred' => '8B0000',
|
|
||||||
'darksalmon' => 'E9967A',
|
|
||||||
'darkseagreen' => '8FBC8F',
|
|
||||||
'darkslateblue' => '483D8B',
|
|
||||||
'darkslategray' => '2F4F4F',
|
|
||||||
'darkslategrey' => '2F4F4F',
|
|
||||||
'darkturquoise' => '00CED1',
|
|
||||||
'darkviolet' => '9400D3',
|
|
||||||
'deeppink' => 'FF1493',
|
|
||||||
'deepskyblue' => '00BFFF',
|
|
||||||
'dimgray' => '696969',
|
|
||||||
'dimgrey' => '696969',
|
|
||||||
'dodgerblue' => '1E90FF',
|
|
||||||
'firebrick' => 'B22222',
|
|
||||||
'floralwhite' => 'FFFAF0',
|
|
||||||
'forestgreen' => '228B22',
|
|
||||||
'fuchsia' => 'FF00FF',
|
|
||||||
'gainsboro' => 'DCDCDC',
|
|
||||||
'ghostwhite' => 'F8F8FF',
|
|
||||||
'gold' => 'FFD700',
|
|
||||||
'goldenrod' => 'DAA520',
|
|
||||||
'gray' => '808080',
|
|
||||||
'green' => '008000',
|
|
||||||
'greenyellow' => 'ADFF2F',
|
|
||||||
'grey' => '808080',
|
|
||||||
'honeydew' => 'F0FFF0',
|
|
||||||
'hotpink' => 'FF69B4',
|
|
||||||
'indianred' => 'CD5C5C',
|
|
||||||
'indigo' => '4B0082',
|
|
||||||
'ivory' => 'FFFFF0',
|
|
||||||
'khaki' => 'F0E68C',
|
|
||||||
'lavender' => 'E6E6FA',
|
|
||||||
'lavenderblush' => 'FFF0F5',
|
|
||||||
'lawngreen' => '7CFC00',
|
|
||||||
'lemonchiffon' => 'FFFACD',
|
|
||||||
'lightblue' => 'ADD8E6',
|
|
||||||
'lightcoral' => 'F08080',
|
|
||||||
'lightcyan' => 'E0FFFF',
|
|
||||||
'lightgoldenrodyellow' => 'FAFAD2',
|
|
||||||
'lightgray' => 'D3D3D3',
|
|
||||||
'lightgreen' => '90EE90',
|
|
||||||
'lightgrey' => 'D3D3D3',
|
|
||||||
'lightpink' => 'FFB6C1',
|
|
||||||
'lightsalmon' => 'FFA07A',
|
|
||||||
'lightseagreen' => '20B2AA',
|
|
||||||
'lightskyblue' => '87CEFA',
|
|
||||||
'lightslategray' => '778899',
|
|
||||||
'lightslategrey' => '778899',
|
|
||||||
'lightsteelblue' => 'B0C4DE',
|
|
||||||
'lightyellow' => 'FFFFE0',
|
|
||||||
'lime' => '00FF00',
|
|
||||||
'limegreen' => '32CD32',
|
|
||||||
'linen' => 'FAF0E6',
|
|
||||||
'magenta' => 'FF00FF',
|
|
||||||
'maroon' => '800000',
|
|
||||||
'mediumaquamarine' => '66CDAA',
|
|
||||||
'mediumblue' => '0000CD',
|
|
||||||
'mediumorchid' => 'BA55D3',
|
|
||||||
'mediumpurple' => '9370D0',
|
|
||||||
'mediumseagreen' => '3CB371',
|
|
||||||
'mediumslateblue' => '7B68EE',
|
|
||||||
'mediumspringgreen' => '00FA9A',
|
|
||||||
'mediumturquoise' => '48D1CC',
|
|
||||||
'mediumvioletred' => 'C71585',
|
|
||||||
'midnightblue' => '191970',
|
|
||||||
'mintcream' => 'F5FFFA',
|
|
||||||
'mistyrose' => 'FFE4E1',
|
|
||||||
'moccasin' => 'FFE4B5',
|
|
||||||
'navajowhite' => 'FFDEAD',
|
|
||||||
'navy' => '000080',
|
|
||||||
'oldlace' => 'FDF5E6',
|
|
||||||
'olive' => '808000',
|
|
||||||
'olivedrab' => '6B8E23',
|
|
||||||
'orange' => 'FFA500',
|
|
||||||
'orangered' => 'FF4500',
|
|
||||||
'orchid' => 'DA70D6',
|
|
||||||
'palegoldenrod' => 'EEE8AA',
|
|
||||||
'palegreen' => '98FB98',
|
|
||||||
'paleturquoise' => 'AFEEEE',
|
|
||||||
'palevioletred' => 'DB7093',
|
|
||||||
'papayawhip' => 'FFEFD5',
|
|
||||||
'peachpuff' => 'FFDAB9',
|
|
||||||
'peru' => 'CD853F',
|
|
||||||
'pink' => 'FFC0CB',
|
|
||||||
'plum' => 'DDA0DD',
|
|
||||||
'powderblue' => 'B0E0E6',
|
|
||||||
'purple' => '800080',
|
|
||||||
'red' => 'FF0000',
|
|
||||||
'rosybrown' => 'BC8F8F',
|
|
||||||
'royalblue' => '4169E1',
|
|
||||||
'saddlebrown' => '8B4513',
|
|
||||||
'salmon' => 'FA8072',
|
|
||||||
'sandybrown' => 'F4A460',
|
|
||||||
'seagreen' => '2E8B57',
|
|
||||||
'seashell' => 'FFF5EE',
|
|
||||||
'sienna' => 'A0522D',
|
|
||||||
'silver' => 'C0C0C0',
|
|
||||||
'skyblue' => '87CEEB',
|
|
||||||
'slateblue' => '6A5ACD',
|
|
||||||
'slategray' => '708090',
|
|
||||||
'slategrey' => '708090',
|
|
||||||
'snow' => 'FFFAFA',
|
|
||||||
'springgreen' => '00FF7F',
|
|
||||||
'steelblue' => '4682B4',
|
|
||||||
'tan' => 'D2B48C',
|
|
||||||
'teal' => '008080',
|
|
||||||
'thistle' => 'D8BFD8',
|
|
||||||
'tomato' => 'FF6347',
|
|
||||||
'turquoise' => '40E0D0',
|
|
||||||
'violet' => 'EE82EE',
|
|
||||||
'wheat' => 'F5DEB3',
|
|
||||||
'white' => 'FFFFFF',
|
|
||||||
'whitesmoke' => 'F5F5F5',
|
|
||||||
'yellow' => 'FFFF00',
|
|
||||||
'yellowgreen' => '9ACD32'
|
|
||||||
);
|
|
||||||
|
|
||||||
$color_name = strtolower($color_name);
|
|
||||||
if (isset($colors[$color_name])) {
|
|
||||||
return('0x' . $colors[$color_name]);
|
|
||||||
} else {
|
|
||||||
return($color_name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"require": {
|
|
||||||
"firebase/php-jwt": "^6.11"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
35
eslint.config.mjs
Normal file
35
eslint.config.mjs
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
// @ts-check
|
||||||
|
import eslint from '@eslint/js';
|
||||||
|
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
|
||||||
|
import globals from 'globals';
|
||||||
|
import tseslint from 'typescript-eslint';
|
||||||
|
|
||||||
|
export default tseslint.config(
|
||||||
|
{
|
||||||
|
ignores: ['eslint.config.mjs'],
|
||||||
|
},
|
||||||
|
eslint.configs.recommended,
|
||||||
|
...tseslint.configs.recommendedTypeChecked,
|
||||||
|
eslintPluginPrettierRecommended,
|
||||||
|
{
|
||||||
|
languageOptions: {
|
||||||
|
globals: {
|
||||||
|
...globals.node,
|
||||||
|
...globals.jest,
|
||||||
|
},
|
||||||
|
sourceType: 'commonjs',
|
||||||
|
parserOptions: {
|
||||||
|
projectService: true,
|
||||||
|
tsconfigRootDir: import.meta.dirname,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
rules: {
|
||||||
|
'@typescript-eslint/no-explicit-any': 'off',
|
||||||
|
'@typescript-eslint/no-floating-promises': 'warn',
|
||||||
|
'@typescript-eslint/no-unsafe-argument': 'warn',
|
||||||
|
"prettier/prettier": ["error", { endOfLine: "auto" }],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
<?php
|
|
||||||
header("Access-Control-Allow-Origin: *");
|
|
||||||
if(!isset($_GET["formular"])) die("GET formular fehlt");
|
|
||||||
$formular=$_GET["formular"];
|
|
||||||
|
|
||||||
include("../../mysqlverbinden.php");
|
|
||||||
|
|
||||||
$data=[];
|
|
||||||
foreach(mysqli_execute_query($db_id,"SELECT `id`,`formular`, `name`, `displayname`, `value`, `displayvalue`, `placeholder`, `type`, `title`, `required`, `maxlength`, `min`,`max`, `checked` FROM `formulare-fields` WHERE `formular`=? ORDER BY `id` ASC;",[$formular]) as $row){
|
|
||||||
|
|
||||||
$data[]=[
|
|
||||||
"id"=>$row["id"],
|
|
||||||
"formular"=>$row["formular"],
|
|
||||||
"name"=>$row["name"],
|
|
||||||
"displayname"=>$row["displayname"],
|
|
||||||
"value"=>$row["value"],
|
|
||||||
"displayvalue"=>$row["displayvalue"],
|
|
||||||
"placeholder"=>$row["placeholder"],
|
|
||||||
"type"=>$row["type"],
|
|
||||||
"title"=>$row["title"],
|
|
||||||
"required"=>$row["required"],
|
|
||||||
"maxlength"=>$row["maxlength"],
|
|
||||||
"min"=>$row["min"],
|
|
||||||
"max"=>$row["max"],
|
|
||||||
"checked"=>$row["checked"],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
echo json_encode($data,JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
<?php
|
|
||||||
header("Access-Control-Allow-Origin: *");
|
|
||||||
include("../../mysqlverbinden.php");
|
|
||||||
|
|
||||||
$data=[];
|
|
||||||
foreach(mysqli_execute_query($db_id,"SELECT `id`,`name`,`minitext`,`public`,`multiple` FROM formulare;",[]) as $row){
|
|
||||||
|
|
||||||
$data[]=[
|
|
||||||
"id"=>$row["id"],
|
|
||||||
"name"=>$row["name"],
|
|
||||||
"minitext"=>$row["minitext"],
|
|
||||||
"public"=>$row["public"],
|
|
||||||
"multiple"=>$row["multiple"],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
echo json_encode($data,JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
<?php
|
|
||||||
header("Access-Control-Allow-Origin: *");
|
|
||||||
|
|
||||||
include("../../mysqlverbinden.php");
|
|
||||||
include("./get_results_lib.php");
|
|
||||||
|
|
||||||
if(!isset($_GET["id"])) die("GET id fehlt");
|
|
||||||
$formularid=$_GET["id"];
|
|
||||||
|
|
||||||
if(!mysqli_execute_query($db_id,"SELECT `public` FROM `formulare` WHERE `id`=?;",[$formularid])->fetch_assoc()["public"]){
|
|
||||||
die('{"error":"not_public"}');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
echo json_encode(get_results($formularid),JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
|
|
||||||
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
function get_type_by_name($name,$formularid){
|
|
||||||
global $db_id;
|
|
||||||
return mysqli_fetch_assoc(mysqli_execute_query($db_id,"SELECT `type` FROM `formulare-fields` WHERE `name`=? AND `formular`=?;",[$name,$formularid]))["type"];
|
|
||||||
}
|
|
||||||
function get_results($formularid){
|
|
||||||
global $db_id;
|
|
||||||
|
|
||||||
$data=[];
|
|
||||||
foreach(mysqli_execute_query($db_id,"SELECT `id`,`timestamp` FROM `formulare-ergebnisse` WHERE `formular`=?;",[$formularid]) as $ergebnis){
|
|
||||||
foreach(mysqli_execute_query($db_id,"SELECT `id`,`name`,`value` FROM `formulare-ergebnis` WHERE `ergebnisid`=?;",[$ergebnis["id"]]) as $row){
|
|
||||||
$type=get_type_by_name($row["name"],$formularid);
|
|
||||||
if(str_ends_with($row["name"],'[]')){
|
|
||||||
$row["name"]=substr($row["name"], 0, -2);
|
|
||||||
$row["value"]=json_decode($row["value"]);
|
|
||||||
}
|
|
||||||
$ergebnis["data"][]=[
|
|
||||||
"id"=>$row["id"],
|
|
||||||
"name"=>$row["name"],
|
|
||||||
"value"=>$row["value"],
|
|
||||||
"type"=>$type
|
|
||||||
];
|
|
||||||
|
|
||||||
}
|
|
||||||
$data[]=$ergebnis;
|
|
||||||
}
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
<?php
|
|
||||||
header("Access-Control-Allow-Origin: *");
|
|
||||||
include("../../mysqlverbinden.php");
|
|
||||||
|
|
||||||
if(!isset($_POST["internalformid"])) die("POST internalformid fehlt");
|
|
||||||
$formid=$_POST["internalformid"];
|
|
||||||
|
|
||||||
if(mysqli_execute_query($db_id,"SELECT * FROM `formulare` WHERE `id`=?;",[$formid])->fetch_assoc()["multiple"]==0) {
|
|
||||||
foreach(mysqli_execute_query($db_id,"SELECT `id` FROM `formulare-ergebnisse`;") as $row){
|
|
||||||
$same=true;
|
|
||||||
$checkedKeys=[];
|
|
||||||
foreach(mysqli_execute_query($db_id,"SELECT `name` FROM `formulare-fields` WHERE `formular`=?;",[$formid]) as $fieldName){
|
|
||||||
$name=$fieldName["name"];
|
|
||||||
$nameStripped=$name;
|
|
||||||
if(substr($name,-2)=="[]"){
|
|
||||||
$nameStripped=substr($name,0,-2);
|
|
||||||
}
|
|
||||||
$row2=mysqli_execute_query($db_id,"SELECT `name`,`value` FROM `formulare-ergebnis` WHERE `ergebnisid`=? AND `name`=?;",[$row["id"],$name])->fetch_assoc();
|
|
||||||
if(isset($row2["value"])!=isset($_POST[$nameStripped])){
|
|
||||||
$same=false;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$value=$_POST[$nameStripped];
|
|
||||||
if(is_array($value)){
|
|
||||||
$value=json_encode($value,JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
|
|
||||||
}
|
|
||||||
if(!is_string($value)) $value=strval($value);
|
|
||||||
if($value!=$row2["value"]){
|
|
||||||
$same=false;
|
|
||||||
}
|
|
||||||
$checkedKeys[]=$name;
|
|
||||||
|
|
||||||
}
|
|
||||||
if($same) die("Fehler: Doppelte Einträge sind nicht erlaubt");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
mysqli_execute_query($db_id,"INSERT INTO `formulare-ergebnisse` (`formular`) VALUES (?);",[$formid]);
|
|
||||||
$id = mysqli_insert_id($db_id);
|
|
||||||
|
|
||||||
|
|
||||||
foreach($_POST as $key => $value){
|
|
||||||
if($key=="internalformid") continue;
|
|
||||||
if(is_array($value)){
|
|
||||||
$value=json_encode($value,JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
|
|
||||||
$key.="[]";
|
|
||||||
}
|
|
||||||
mysqli_execute_query($db_id,"INSERT INTO `formulare-ergebnis` (`name`, `value`,`ergebnisid`) VALUES (?,?,?);",[$key,$value,$id]);
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
<?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(str_contains($ev, "/")) die("GET ev ungültig");
|
|
||||||
if(str_contains($jahr, "/")) die("GET jahr ungültig");
|
|
||||||
|
|
||||||
$path="../../bilder/".$ev."/".$jahr;
|
|
||||||
|
|
||||||
$bilder=scandir($path);
|
|
||||||
|
|
||||||
$file_extension_whitelist=["jpg","jpeg","png","gif"];
|
|
||||||
|
|
||||||
$result=[];
|
|
||||||
|
|
||||||
|
|
||||||
foreach ($bilder as $key => $value) {
|
|
||||||
if (is_dir($path."/".$value)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if(in_array(pathinfo($path."/".$value,PATHINFO_EXTENSION),$file_extension_whitelist)) $result[] = "/".$ev."/".$jahr."/".$value;
|
|
||||||
}
|
|
||||||
|
|
||||||
echo json_encode($result,JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
<?php
|
|
||||||
header("Access-Control-Allow-Origin: *");
|
|
||||||
if(!isset($_GET["event"])) die("GET event fehlt");
|
|
||||||
$event=$_GET["event"];
|
|
||||||
|
|
||||||
if(str_contains($event,"/")||str_contains($event,"\\")) die("Du kannst keine / im Event verwenden.");
|
|
||||||
|
|
||||||
$blacklist=["@eaDir",".",".."];
|
|
||||||
|
|
||||||
$bilderdir="../../bilder/";
|
|
||||||
|
|
||||||
$scan=scandir($bilderdir.$event);
|
|
||||||
|
|
||||||
$result=[];
|
|
||||||
|
|
||||||
foreach ($scan as $key => $value) {
|
|
||||||
if(in_array($value,$blacklist)) continue;
|
|
||||||
if(is_dir($bilderdir.$event."/".$value)) array_push($result,$value);
|
|
||||||
}
|
|
||||||
|
|
||||||
echo json_encode($result,JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
<?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);
|
|
||||||
?>
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
<?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]);
|
|
||||||
?>
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
<?php
|
|
||||||
header("Access-Control-Allow-Origin: *");
|
|
||||||
include("../mysqlverbinden.php");
|
|
||||||
include("rowforeach.php");
|
|
||||||
|
|
||||||
|
|
||||||
$result=[];
|
|
||||||
|
|
||||||
foreach(srowforeach("SELECT * from `ritzenbergen-events`",[]) as $key => $value){
|
|
||||||
$id=$value[0];
|
|
||||||
$eventname=$value[1];
|
|
||||||
$datum=$value[2];
|
|
||||||
$type=$value[3];
|
|
||||||
$content=$value[4];
|
|
||||||
$minitext=$value[5];
|
|
||||||
$link=$value[6];
|
|
||||||
$foto=$value[7];
|
|
||||||
$formular=$value[8];
|
|
||||||
array_push($result,[
|
|
||||||
"id" => $id,
|
|
||||||
"eventname" => $eventname,
|
|
||||||
"datum" => $datum,
|
|
||||||
"type" => $type,
|
|
||||||
"content" => $content,
|
|
||||||
"link" => $link,
|
|
||||||
"foto" => $foto,
|
|
||||||
"minitext" => $minitext,
|
|
||||||
"formular" => $formular
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
echo json_encode($result,JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
<?php
|
|
||||||
header("Access-Control-Allow-Origin: *");
|
|
||||||
|
|
||||||
include("../mysqlverbinden.php");
|
|
||||||
|
|
||||||
$messages=[];
|
|
||||||
foreach(mysqli_execute_query($db_id,"SELECT `name`, `message`, `email`, `timestamp` FROM `ritzenbergen-kloenkasten`;",[]) as $row){
|
|
||||||
$messages[]=array(
|
|
||||||
"name"=>$row['name'],
|
|
||||||
"message"=>$row['message'],
|
|
||||||
"email"=>$row['email'],
|
|
||||||
"timestamp"=>$row['timestamp']
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
echo json_encode($messages, JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
<?php
|
|
||||||
header("Access-Control-Allow-Origin: *");
|
|
||||||
|
|
||||||
if(!isset($_GET["sender"])) die("GET sender fehlt");
|
|
||||||
$sender=$_GET["sender"];
|
|
||||||
|
|
||||||
if(!isset($_GET["message"])) die("GET message fehlt");
|
|
||||||
$message=$_GET["message"];
|
|
||||||
|
|
||||||
if(!isset($_GET["email"])) $email=null;
|
|
||||||
else $email=$_GET["email"];
|
|
||||||
|
|
||||||
include("../mysqlverbinden.php");
|
|
||||||
|
|
||||||
mysqli_execute_query($db_id,"INSERT INTO `ritzenbergen-kloenkasten` (`name`,`email`,`message`) VALUES (?,?,?);",[$sender,$email,$message]);
|
|
||||||
8
nest-cli.json
Normal file
8
nest-cli.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://json.schemastore.org/nest-cli",
|
||||||
|
"collection": "@nestjs/schematics",
|
||||||
|
"sourceRoot": "src",
|
||||||
|
"compilerOptions": {
|
||||||
|
"deleteOutDir": true
|
||||||
|
}
|
||||||
|
}
|
||||||
12820
package-lock.json
generated
Normal file
12820
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
80
package.json
Normal file
80
package.json
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
{
|
||||||
|
"name": "backend",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"description": "",
|
||||||
|
"author": "",
|
||||||
|
"private": true,
|
||||||
|
"license": "UNLICENSED",
|
||||||
|
"scripts": {
|
||||||
|
"build": "nest build",
|
||||||
|
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||||
|
"start": "nest start",
|
||||||
|
"start:dev": "nest start --watch",
|
||||||
|
"start:debug": "nest start --debug --watch",
|
||||||
|
"start:prod": "node dist/main",
|
||||||
|
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
||||||
|
"test": "jest",
|
||||||
|
"test:watch": "jest --watch",
|
||||||
|
"test:cov": "jest --coverage",
|
||||||
|
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
|
||||||
|
"test:e2e": "jest --config ./test/jest-e2e.json"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@nestjs/common": "^11.0.1",
|
||||||
|
"@nestjs/core": "^11.0.1",
|
||||||
|
"@nestjs/graphql": "^13.2.3",
|
||||||
|
"@nestjs/mercurius": "^13.2.3",
|
||||||
|
"@nestjs/platform-fastify": "^11.1.12",
|
||||||
|
"@nestjs/swagger": "^11.2.5",
|
||||||
|
"@nestjs/typeorm": "^11.0.0",
|
||||||
|
"fastify": "^5.7.2",
|
||||||
|
"graphiql": "^5.2.2",
|
||||||
|
"graphql": "^16.12.0",
|
||||||
|
"mercurius": "^16.7.0",
|
||||||
|
"mysql2": "^3.16.2",
|
||||||
|
"reflect-metadata": "^0.2.2",
|
||||||
|
"rxjs": "^7.8.1",
|
||||||
|
"typeorm": "^0.3.28"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@eslint/eslintrc": "^3.2.0",
|
||||||
|
"@eslint/js": "^9.18.0",
|
||||||
|
"@nestjs/cli": "^11.0.0",
|
||||||
|
"@nestjs/schematics": "^11.0.0",
|
||||||
|
"@nestjs/testing": "^11.0.1",
|
||||||
|
"@types/jest": "^30.0.0",
|
||||||
|
"@types/node": "^22.10.7",
|
||||||
|
"@types/supertest": "^6.0.2",
|
||||||
|
"eslint": "^9.18.0",
|
||||||
|
"eslint-config-prettier": "^10.0.1",
|
||||||
|
"eslint-plugin-prettier": "^5.2.2",
|
||||||
|
"globals": "^16.0.0",
|
||||||
|
"jest": "^30.0.0",
|
||||||
|
"prettier": "^3.4.2",
|
||||||
|
"source-map-support": "^0.5.21",
|
||||||
|
"supertest": "^7.0.0",
|
||||||
|
"ts-jest": "^29.2.5",
|
||||||
|
"ts-loader": "^9.5.2",
|
||||||
|
"ts-node": "^10.9.2",
|
||||||
|
"tsconfig-paths": "^4.2.0",
|
||||||
|
"typescript": "^5.7.3",
|
||||||
|
"typescript-eslint": "^8.20.0"
|
||||||
|
},
|
||||||
|
"jest": {
|
||||||
|
"moduleFileExtensions": [
|
||||||
|
"js",
|
||||||
|
"json",
|
||||||
|
"ts"
|
||||||
|
],
|
||||||
|
"rootDir": "src",
|
||||||
|
"testRegex": ".*\\.spec\\.ts$",
|
||||||
|
"transform": {
|
||||||
|
"^.+\\.(t|j)s$": "ts-jest"
|
||||||
|
},
|
||||||
|
"collectCoverageFrom": [
|
||||||
|
"**/*.(t|j)s"
|
||||||
|
],
|
||||||
|
"coverageDirectory": "../coverage",
|
||||||
|
"testEnvironment": "node"
|
||||||
|
}
|
||||||
|
}
|
||||||
105
randomimage.php
105
randomimage.php
@@ -1,105 +0,0 @@
|
|||||||
<?php
|
|
||||||
header('Content-Type: image/png');
|
|
||||||
header('Access-Control-Allow-Origin: *');
|
|
||||||
error_reporting(-1);
|
|
||||||
/**
|
|
||||||
* GET
|
|
||||||
* Argumente:
|
|
||||||
* path: Der Pfad zu den Bildern
|
|
||||||
* recursive: Bool: Soll Rekursiv nach Bildern gesucht werden?
|
|
||||||
* tn: Thumbnail: Soll eine Beschriftung rauf?
|
|
||||||
* text: Welcher Text soll auf das Thumbnail?
|
|
||||||
* color: Welche Farbe soll der Text haben?
|
|
||||||
* whitelist: Pfad zur Whitelist-Datei
|
|
||||||
* size: Die Schriftgröße
|
|
||||||
*/
|
|
||||||
function lineEnding($str) {
|
|
||||||
if (strpos($str, "\r\n") !== false) return "\r\n";
|
|
||||||
if (strpos($str, "\n") !== false) return "\n";
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
include("colorstringconvert.php");
|
|
||||||
$whitelist=[];
|
|
||||||
if (!isset($_GET["path"]))
|
|
||||||
die("Bitte gebe path an!");
|
|
||||||
|
|
||||||
$path = "../bilder".$_GET["path"];
|
|
||||||
if (!isset($_GET["recursive"]))
|
|
||||||
die("Bitte gebe recursive an!");
|
|
||||||
|
|
||||||
if (!isset($_GET["whitelist"]))
|
|
||||||
$whitelistpath = $path."/whitelist.txt";
|
|
||||||
|
|
||||||
$lineEnding=lineEnding(file_get_contents($whitelistpath));
|
|
||||||
|
|
||||||
if($lineEnding==null) $whitelist=[file_get_contents($whitelistpath)];
|
|
||||||
if(empty(file_get_contents($whitelistpath))) $whitelist=[];
|
|
||||||
else if(count($whitelist)==0) $whitelist = explode($lineEnding, file_get_contents($whitelistpath));
|
|
||||||
|
|
||||||
if (isset($_GET["tn"])) {
|
|
||||||
if (!isset($_GET["text"]))
|
|
||||||
die("Bitte gebe text an!");
|
|
||||||
else
|
|
||||||
$text = $_GET["text"];
|
|
||||||
|
|
||||||
if (!isset($_GET["color"]))
|
|
||||||
$color = 0xFFFFFF;
|
|
||||||
else
|
|
||||||
$color = hexdec(color_name_to_hex($_GET["color"]));
|
|
||||||
}
|
|
||||||
if (isset($_GET["size"])) {
|
|
||||||
$size = $_GET["size"];
|
|
||||||
} else {
|
|
||||||
$size = 10;
|
|
||||||
}
|
|
||||||
$blacklist = ["@eaDir"];
|
|
||||||
$file_ext = ["jpg", "png", "gif"];
|
|
||||||
$tn = isset($_GET["tn"]);
|
|
||||||
$font = "./tnfont.ttf";
|
|
||||||
|
|
||||||
function getImages($path)
|
|
||||||
{
|
|
||||||
global $blacklist, $file_ext, $whitelist;
|
|
||||||
$images = [];
|
|
||||||
foreach (scandir($path) as $value) {
|
|
||||||
if (in_array($value, $blacklist))
|
|
||||||
continue;
|
|
||||||
if (is_dir($path . "/" . $value)) {
|
|
||||||
if (!$_GET["recursive"] || $value == "." || $value == "..")
|
|
||||||
continue;
|
|
||||||
else
|
|
||||||
$images=array_merge($images,getImages($path . "/" . $value));
|
|
||||||
}
|
|
||||||
if (!in_array(pathinfo($path . "/" . $value, PATHINFO_EXTENSION), $file_ext))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if ($whitelist != []) { // Whitelist angegeben: Prüfen, ob Element in der Whitelist ist
|
|
||||||
if (in_array($path . "/" . $value, $whitelist)) { // Element ist in der Whitelist
|
|
||||||
array_push($images, $path . "/" . $value); // Bild zur Auswahl hinzufügen
|
|
||||||
}
|
|
||||||
} else { // Keine Whitelist angegeben -> alles wird mit in die Auswahl gepackt
|
|
||||||
|
|
||||||
$images[] = $path . "/" . $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $images;
|
|
||||||
|
|
||||||
}
|
|
||||||
$images = getImages($path);
|
|
||||||
$imagekey = array_rand($images);
|
|
||||||
$imagepath = $images[$imagekey];
|
|
||||||
if (pathinfo($imagepath, PATHINFO_EXTENSION) == "jpg")
|
|
||||||
$image = imagecreatefromjpeg($imagepath);
|
|
||||||
if (pathinfo($imagepath, PATHINFO_EXTENSION) == "png")
|
|
||||||
$image = imagecreatefrompng($imagepath);
|
|
||||||
if (pathinfo($imagepath, PATHINFO_EXTENSION) == "gif")
|
|
||||||
$image = imagecreatefromgif($imagepath);
|
|
||||||
if ($tn) {
|
|
||||||
$newsize = 0.02 * $size * imagesx($image);
|
|
||||||
$tb = imagettfbbox($newsize, 0, $font, $text);
|
|
||||||
$x = ceil((imagesx($image) - $tb[2]) / 2);
|
|
||||||
$y = ceil((imagesy($image) - $tb[5]) / 2);
|
|
||||||
imagettftext($image, $newsize, 0, $x, $y, $color, $font, $text);
|
|
||||||
}
|
|
||||||
imagepng($image);
|
|
||||||
imagedestroy($image);
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
function rowforeach($query){
|
|
||||||
global $db_id;
|
|
||||||
$result=mysqli_query($db_id, $query);
|
|
||||||
$rows = array();
|
|
||||||
while ($row = $result->fetch_row()) {
|
|
||||||
array_push($rows,$row);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $rows;
|
|
||||||
}
|
|
||||||
function srowforeach($query, array $args){
|
|
||||||
global $db_id;
|
|
||||||
$result=mysqli_execute_query($db_id, $query, $args);
|
|
||||||
$rows = array();
|
|
||||||
while ($row = $result->fetch_row()) {
|
|
||||||
array_push($rows,$row);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $rows;
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
22
src/app.controller.spec.ts
Normal file
22
src/app.controller.spec.ts
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { AppController } from './app.controller';
|
||||||
|
import { AppService } from './app.service';
|
||||||
|
|
||||||
|
describe('AppController', () => {
|
||||||
|
let appController: AppController;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const app: TestingModule = await Test.createTestingModule({
|
||||||
|
controllers: [AppController],
|
||||||
|
providers: [AppService],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
appController = app.get<AppController>(AppController);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('root', () => {
|
||||||
|
it('should return "Hello World!"', () => {
|
||||||
|
expect(appController.getHello()).toBe('Hello World!');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
15
src/app.controller.ts
Normal file
15
src/app.controller.ts
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import { Controller, Get } from '@nestjs/common';
|
||||||
|
import { AppService } from './app.service';
|
||||||
|
import { Query, Resolver } from '@nestjs/graphql';
|
||||||
|
|
||||||
|
@Controller()
|
||||||
|
@Resolver()
|
||||||
|
export class AppController {
|
||||||
|
constructor(private readonly appService: AppService) {}
|
||||||
|
|
||||||
|
@Query(()=>String)
|
||||||
|
@Get("/")
|
||||||
|
hello(): string {
|
||||||
|
return this.appService.getHello();
|
||||||
|
}
|
||||||
|
}
|
||||||
40
src/app.module.ts
Normal file
40
src/app.module.ts
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { AppController } from './app.controller';
|
||||||
|
import { AppService } from './app.service';
|
||||||
|
import { GraphQLModule } from '@nestjs/graphql';
|
||||||
|
import { MercuriusDriver, MercuriusDriverConfig } from '@nestjs/mercurius';
|
||||||
|
import { EventsModule } from './events/events.module';
|
||||||
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||||
|
import { EventEntity } from './events/events.entity';
|
||||||
|
import { FormularModule } from './formular/formular.module';
|
||||||
|
import { FormularEntity } from './formular/formular.entity';
|
||||||
|
import { FieldEntity } from './formular/fields.entity';
|
||||||
|
import { FormResultEntity } from './formular/result.entity';
|
||||||
|
import { FormResultsEntity } from './formular/results.entity';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
imports: [
|
||||||
|
GraphQLModule.forRoot<MercuriusDriverConfig>({
|
||||||
|
driver: MercuriusDriver,
|
||||||
|
graphiql: true,
|
||||||
|
autoSchemaFile: true,
|
||||||
|
} as MercuriusDriverConfig),
|
||||||
|
EventsModule,
|
||||||
|
TypeOrmModule.forRoot({
|
||||||
|
type: 'mysql',
|
||||||
|
host: process.env.DB_HOST || 'database',
|
||||||
|
port: parseInt(process.env.DB_PORT || "3306"),
|
||||||
|
username: process.env.DB_USER || 'root',
|
||||||
|
password: process.env.DB_PASSWORD || 'root',
|
||||||
|
database: process.env.DB_NAME || 'ritzenbergen',
|
||||||
|
synchronize: true,
|
||||||
|
entities: [EventEntity, FormularEntity,FieldEntity,FormResultEntity,FormResultsEntity]
|
||||||
|
}),
|
||||||
|
FormularModule,
|
||||||
|
|
||||||
|
],
|
||||||
|
controllers: [AppController],
|
||||||
|
providers: [AppService, AppController],
|
||||||
|
|
||||||
|
})
|
||||||
|
export class AppModule {}
|
||||||
8
src/app.service.ts
Normal file
8
src/app.service.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class AppService {
|
||||||
|
getHello(): string {
|
||||||
|
return 'Hello World!';
|
||||||
|
}
|
||||||
|
}
|
||||||
1
src/dto
Submodule
1
src/dto
Submodule
Submodule src/dto added at 12938c8125
23
src/events/events.controller.ts
Normal file
23
src/events/events.controller.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { Controller, Get } from '@nestjs/common';
|
||||||
|
import { Query } from '@nestjs/graphql';
|
||||||
|
import { EventsService } from './events.service';
|
||||||
|
import { EventEntity } from './events.entity';
|
||||||
|
|
||||||
|
@Controller('/api/events')
|
||||||
|
export class EventsController {
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
|
||||||
|
private readonly eventsService: EventsService
|
||||||
|
|
||||||
|
|
||||||
|
){}
|
||||||
|
|
||||||
|
@Get("/")
|
||||||
|
@Query(()=>[EventEntity])
|
||||||
|
async events(): Promise<EventEntity[]>{
|
||||||
|
|
||||||
|
return await this.eventsService.getEvents();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
45
src/events/events.entity.ts
Normal file
45
src/events/events.entity.ts
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
import { Field, ObjectType } from "@nestjs/graphql";
|
||||||
|
import { EventType, MyEvent } from "src/dto/event.dto";
|
||||||
|
import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";
|
||||||
|
|
||||||
|
|
||||||
|
@ObjectType()
|
||||||
|
@Entity()
|
||||||
|
export class EventEntity implements MyEvent{
|
||||||
|
|
||||||
|
@Field()
|
||||||
|
@PrimaryGeneratedColumn()
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Field()
|
||||||
|
@Column()
|
||||||
|
eventname: string;
|
||||||
|
|
||||||
|
@Field()
|
||||||
|
@Column({ type: "datetime", default: "1970-01-01 00:00:00" })
|
||||||
|
datum: Date;
|
||||||
|
|
||||||
|
@Field()
|
||||||
|
@Column({ type: "enum", enum: [EventType.fotos, EventType.html, EventType.markdown, EventType.link] })
|
||||||
|
type: EventType;
|
||||||
|
|
||||||
|
@Field()
|
||||||
|
@Column()
|
||||||
|
content: string;
|
||||||
|
|
||||||
|
@Field()
|
||||||
|
@Column()
|
||||||
|
minitext: string;
|
||||||
|
|
||||||
|
@Field({nullable: true})
|
||||||
|
@Column({ nullable: true })
|
||||||
|
link:string;
|
||||||
|
|
||||||
|
@Field()
|
||||||
|
@Column()
|
||||||
|
foto: string;
|
||||||
|
|
||||||
|
@Field({nullable: true})
|
||||||
|
@Column({ nullable: true })
|
||||||
|
formular: number;
|
||||||
|
}
|
||||||
14
src/events/events.module.ts
Normal file
14
src/events/events.module.ts
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { EventsController } from './events.controller';
|
||||||
|
import { EventsService } from './events.service';
|
||||||
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||||
|
import { EventEntity } from './events.entity';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
imports: [
|
||||||
|
TypeOrmModule.forFeature([EventEntity])
|
||||||
|
],
|
||||||
|
controllers: [EventsController],
|
||||||
|
providers: [EventsService, EventsController],
|
||||||
|
})
|
||||||
|
export class EventsModule {}
|
||||||
21
src/events/events.service.ts
Normal file
21
src/events/events.service.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
|
import { Repository } from 'typeorm';
|
||||||
|
import { EventEntity } from './events.entity';
|
||||||
|
import { InjectRepository } from '@nestjs/typeorm';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class EventsService {
|
||||||
|
constructor(
|
||||||
|
@InjectRepository(EventEntity)
|
||||||
|
private readonly eventRepository: Repository<EventEntity>
|
||||||
|
|
||||||
|
){}
|
||||||
|
|
||||||
|
async getEvents(): Promise<EventEntity[]> {
|
||||||
|
|
||||||
|
return (await this.eventRepository.find());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
74
src/formular/fields.entity.ts
Normal file
74
src/formular/fields.entity.ts
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
import { Field, ObjectType } from "@nestjs/graphql";
|
||||||
|
import { FieldType, MyField } from "src/dto/formular.dto";
|
||||||
|
import { Column, Entity, ForeignKey, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from "typeorm";
|
||||||
|
import { FormularEntity } from "./formular.entity";
|
||||||
|
|
||||||
|
|
||||||
|
@ObjectType()
|
||||||
|
@Entity()
|
||||||
|
export class FieldEntity implements MyField {
|
||||||
|
@Field()
|
||||||
|
@PrimaryGeneratedColumn()
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Field()
|
||||||
|
@Column()
|
||||||
|
formular: number;
|
||||||
|
|
||||||
|
@Field(()=>FormularEntity)
|
||||||
|
@ManyToOne(()=>FormularEntity,entity=>entity.id)
|
||||||
|
@JoinColumn({name:'formular'})
|
||||||
|
formularObject: FormularEntity;
|
||||||
|
|
||||||
|
@Field()
|
||||||
|
@Column()
|
||||||
|
name: string;
|
||||||
|
|
||||||
|
@Field({nullable:true})
|
||||||
|
@Column({nullable:true})
|
||||||
|
displayname: string;
|
||||||
|
|
||||||
|
@Field()
|
||||||
|
@Column()
|
||||||
|
value: string;
|
||||||
|
|
||||||
|
@Field({nullable:true})
|
||||||
|
@Column({nullable: true})
|
||||||
|
displayvalue: string;
|
||||||
|
|
||||||
|
@Field({nullable:true})
|
||||||
|
@Column({nullable: true})
|
||||||
|
placeholder: string;
|
||||||
|
|
||||||
|
@Field()
|
||||||
|
@Column("enum",{
|
||||||
|
enum: FieldType
|
||||||
|
})
|
||||||
|
type: FieldType;
|
||||||
|
|
||||||
|
@Field({nullable:true})
|
||||||
|
@Column({nullable: true})
|
||||||
|
title: string;
|
||||||
|
|
||||||
|
@Field()
|
||||||
|
@Column({default: false})
|
||||||
|
required: boolean;
|
||||||
|
|
||||||
|
@Field({nullable:true})
|
||||||
|
@Column({nullable: true})
|
||||||
|
maxlength: number;
|
||||||
|
|
||||||
|
@Field({nullable:true})
|
||||||
|
@Column({nullable: true})
|
||||||
|
min: number;
|
||||||
|
|
||||||
|
@Field({nullable:true})
|
||||||
|
@Column({nullable: true})
|
||||||
|
max: number;
|
||||||
|
|
||||||
|
@Field({nullable:true})
|
||||||
|
@Column({nullable: true})
|
||||||
|
checked?: boolean;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
38
src/formular/formular.controller.ts
Normal file
38
src/formular/formular.controller.ts
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
import { Controller, Get, Inject, Param } from '@nestjs/common';
|
||||||
|
import { FormularService } from './formular.service';
|
||||||
|
import { Query } from '@nestjs/graphql';
|
||||||
|
import { Formular, MyField } from 'src/dto/formular.dto';
|
||||||
|
import { FormularEntity } from './formular.entity';
|
||||||
|
import { FieldEntity } from './fields.entity';
|
||||||
|
|
||||||
|
@Controller('/api/formulare')
|
||||||
|
export class FormularController {
|
||||||
|
constructor(
|
||||||
|
@Inject()
|
||||||
|
private readonly formularService: FormularService
|
||||||
|
){}
|
||||||
|
|
||||||
|
@Get("/")
|
||||||
|
@Query(()=>[FormularEntity])
|
||||||
|
async formulare(): Promise<Formular[]>{
|
||||||
|
return await this.formularService.getFormulare();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get("/:formularid")
|
||||||
|
@Query(()=>[FieldEntity])
|
||||||
|
async fields(
|
||||||
|
@Param("formularid")
|
||||||
|
formularid:number
|
||||||
|
): Promise<MyField[]>{
|
||||||
|
return await this.formularService.getFields(formularid);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get("/submit/:formularid")
|
||||||
|
async submit(
|
||||||
|
@Param("formularid")
|
||||||
|
formularid:number
|
||||||
|
){
|
||||||
|
return await this.formularService.submit(formularid);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
38
src/formular/formular.entity.ts
Normal file
38
src/formular/formular.entity.ts
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
import { Field, ObjectType } from "@nestjs/graphql";
|
||||||
|
import { Formular, FormularResults, MyField } from "src/dto/formular.dto";
|
||||||
|
import { Column, Entity, ManyToOne, OneToMany, PrimaryColumn, PrimaryGeneratedColumn } from "typeorm";
|
||||||
|
import { FieldEntity } from "./fields.entity";
|
||||||
|
import { FormResultsEntity } from "./results.entity";
|
||||||
|
|
||||||
|
|
||||||
|
@ObjectType()
|
||||||
|
@Entity()
|
||||||
|
export class FormularEntity implements Formular{
|
||||||
|
@Field()
|
||||||
|
@PrimaryGeneratedColumn()
|
||||||
|
public id: number;
|
||||||
|
|
||||||
|
@Field()
|
||||||
|
@Column()
|
||||||
|
public name: string;
|
||||||
|
|
||||||
|
@Field()
|
||||||
|
@Column()
|
||||||
|
public minitext: string;
|
||||||
|
|
||||||
|
@Field()
|
||||||
|
@Column()
|
||||||
|
public ispublic: boolean;
|
||||||
|
|
||||||
|
@Field()
|
||||||
|
@Column()
|
||||||
|
public multiple: boolean;
|
||||||
|
|
||||||
|
@Field(()=>[FieldEntity])
|
||||||
|
@OneToMany(()=>FieldEntity,field=>field.formularObject)
|
||||||
|
public fields: FieldEntity[];
|
||||||
|
|
||||||
|
@Field(()=>[FormResultsEntity])
|
||||||
|
@OneToMany(()=>FormResultsEntity,entity=>entity.formular)
|
||||||
|
public results: FormResultsEntity[];
|
||||||
|
}
|
||||||
21
src/formular/formular.module.ts
Normal file
21
src/formular/formular.module.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||||
|
import { FormularEntity } from './formular.entity';
|
||||||
|
import { FormularController } from './formular.controller';
|
||||||
|
import { FormularService } from './formular.service';
|
||||||
|
import { FieldEntity } from './fields.entity';
|
||||||
|
import { FormResultEntity } from './result.entity';
|
||||||
|
import { FormResultsEntity } from './results.entity';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
imports:[
|
||||||
|
TypeOrmModule.forFeature([FormularEntity,FieldEntity,FormResultEntity,FormResultsEntity])
|
||||||
|
],
|
||||||
|
controllers: [
|
||||||
|
FormularController
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
FormularService, FormularController
|
||||||
|
]
|
||||||
|
})
|
||||||
|
export class FormularModule {}
|
||||||
31
src/formular/formular.service.ts
Normal file
31
src/formular/formular.service.ts
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { InjectRepository } from '@nestjs/typeorm';
|
||||||
|
import { FormularEntity } from './formular.entity';
|
||||||
|
import { FormResultsEntity } from './results.entity';
|
||||||
|
import { Repository } from 'typeorm';
|
||||||
|
import { Formular, MyField } from 'src/dto/formular.dto';
|
||||||
|
import { FieldEntity } from './fields.entity';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class FormularService {
|
||||||
|
constructor(
|
||||||
|
@InjectRepository(FormularEntity)
|
||||||
|
private readonly formularRepository: Repository<FormularEntity>,
|
||||||
|
@InjectRepository(FieldEntity)
|
||||||
|
private readonly fieldRepository: Repository<FieldEntity>,
|
||||||
|
){}
|
||||||
|
|
||||||
|
async getFormulare(): Promise<Formular[]>{
|
||||||
|
return await this.formularRepository.find({relations: ['fields',"results","results.results"]});
|
||||||
|
}
|
||||||
|
async getFields(
|
||||||
|
formularid:number
|
||||||
|
): Promise<MyField[]>{
|
||||||
|
return await this.fieldRepository.findBy({formular: formularid});
|
||||||
|
}
|
||||||
|
async submit(
|
||||||
|
formularid:number
|
||||||
|
){
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
32
src/formular/result.entity.ts
Normal file
32
src/formular/result.entity.ts
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import { Field, ObjectType } from "@nestjs/graphql";
|
||||||
|
import { FormularResult, FormularResults } from "src/dto/formular.dto";
|
||||||
|
import { Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from "typeorm";
|
||||||
|
import { FormResultsEntity } from "./results.entity";
|
||||||
|
|
||||||
|
|
||||||
|
@ObjectType()
|
||||||
|
@Entity()
|
||||||
|
export class FormResultEntity implements FormularResult{
|
||||||
|
|
||||||
|
@PrimaryGeneratedColumn()
|
||||||
|
@Field()
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
@Field()
|
||||||
|
parentid: number;
|
||||||
|
|
||||||
|
@Field(()=>FormResultsEntity)
|
||||||
|
@ManyToOne(()=>FormResultsEntity,entity=>entity.id)
|
||||||
|
@JoinColumn({"name":"parentid"})
|
||||||
|
parentobj: FormResultsEntity;
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
@Field()
|
||||||
|
name: string;
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
@Field()
|
||||||
|
value: string;
|
||||||
|
|
||||||
|
}
|
||||||
28
src/formular/results.entity.ts
Normal file
28
src/formular/results.entity.ts
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import { Field, ObjectType } from "@nestjs/graphql";
|
||||||
|
import { Formular, FormularResult, FormularResults } from "src/dto/formular.dto";
|
||||||
|
import { Column, Entity, JoinColumn, ManyToOne, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
||||||
|
import { FormularEntity } from "./formular.entity";
|
||||||
|
import { FormResultEntity } from "./result.entity";
|
||||||
|
|
||||||
|
|
||||||
|
@ObjectType()
|
||||||
|
@Entity()
|
||||||
|
export class FormResultsEntity implements FormularResults{
|
||||||
|
@PrimaryGeneratedColumn()
|
||||||
|
@Field()
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
@ManyToOne(()=>FormularEntity,entity=>entity.id)
|
||||||
|
@Field(()=>FormularEntity)
|
||||||
|
@JoinColumn({name:"formularid"})
|
||||||
|
formular: FormularEntity;
|
||||||
|
|
||||||
|
@Field()
|
||||||
|
@Column()
|
||||||
|
formularid: number;
|
||||||
|
|
||||||
|
@Field(()=>[FormResultEntity])
|
||||||
|
@OneToMany(()=>FormResultEntity,entity=>entity.parentobj)
|
||||||
|
results: FormResultEntity[];
|
||||||
|
|
||||||
|
}
|
||||||
29
src/main.ts
Normal file
29
src/main.ts
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import { NestFactory } from '@nestjs/core';
|
||||||
|
import { AppModule } from './app.module';
|
||||||
|
import { NestFastifyApplication, FastifyAdapter } from '@nestjs/platform-fastify';
|
||||||
|
import { FastifyContextConfig } from 'fastify';
|
||||||
|
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
|
||||||
|
|
||||||
|
async function bootstrap() {
|
||||||
|
const fastifyAdapter=new FastifyAdapter({
|
||||||
|
listeningOrigin: "0.0.0.0",
|
||||||
|
crossOriginIsolated: true
|
||||||
|
|
||||||
|
} as FastifyContextConfig);
|
||||||
|
|
||||||
|
const app = await NestFactory.create<NestFastifyApplication>(AppModule, fastifyAdapter);
|
||||||
|
|
||||||
|
app.enableCors();
|
||||||
|
|
||||||
|
const config = new DocumentBuilder()
|
||||||
|
.setTitle('Ritzenbergen API')
|
||||||
|
.setDescription('The Ritzenbergen API description')
|
||||||
|
.setVersion('1.0')
|
||||||
|
.addTag('ritzenbergen')
|
||||||
|
.build();
|
||||||
|
const document = SwaggerModule.createDocument(app, config);
|
||||||
|
SwaggerModule.setup('/api/docs', app, document);
|
||||||
|
|
||||||
|
await app.listen(process.env.PORT ?? 3000, "0.0.0.0");
|
||||||
|
}
|
||||||
|
bootstrap();
|
||||||
25
test/app.e2e-spec.ts
Normal file
25
test/app.e2e-spec.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { INestApplication } from '@nestjs/common';
|
||||||
|
import request from 'supertest';
|
||||||
|
import { App } from 'supertest/types';
|
||||||
|
import { AppModule } from './../src/app.module';
|
||||||
|
|
||||||
|
describe('AppController (e2e)', () => {
|
||||||
|
let app: INestApplication<App>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const moduleFixture: TestingModule = await Test.createTestingModule({
|
||||||
|
imports: [AppModule],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
app = moduleFixture.createNestApplication();
|
||||||
|
await app.init();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('/ (GET)', () => {
|
||||||
|
return request(app.getHttpServer())
|
||||||
|
.get('/')
|
||||||
|
.expect(200)
|
||||||
|
.expect('Hello World!');
|
||||||
|
});
|
||||||
|
});
|
||||||
9
test/jest-e2e.json
Normal file
9
test/jest-e2e.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"moduleFileExtensions": ["js", "json", "ts"],
|
||||||
|
"rootDir": ".",
|
||||||
|
"testEnvironment": "node",
|
||||||
|
"testRegex": ".e2e-spec.ts$",
|
||||||
|
"transform": {
|
||||||
|
"^.+\\.(t|j)s$": "ts-jest"
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
tnfont.ttf
BIN
tnfont.ttf
Binary file not shown.
4
tsconfig.build.json
Normal file
4
tsconfig.build.json
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"extends": "./tsconfig.json",
|
||||||
|
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
|
||||||
|
}
|
||||||
25
tsconfig.json
Normal file
25
tsconfig.json
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"module": "nodenext",
|
||||||
|
"moduleResolution": "nodenext",
|
||||||
|
"resolvePackageJsonExports": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"isolatedModules": true,
|
||||||
|
"declaration": true,
|
||||||
|
"removeComments": true,
|
||||||
|
"emitDecoratorMetadata": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
|
"target": "ES2023",
|
||||||
|
"sourceMap": true,
|
||||||
|
"outDir": "./dist",
|
||||||
|
"baseUrl": "./",
|
||||||
|
"incremental": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"strictNullChecks": true,
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"noImplicitAny": false,
|
||||||
|
"strictBindCallApply": false,
|
||||||
|
"noFallthroughCasesInSwitch": false
|
||||||
|
}
|
||||||
|
}
|
||||||
22
vendor/autoload.php
vendored
22
vendor/autoload.php
vendored
@@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
// autoload.php @generated by Composer
|
|
||||||
|
|
||||||
if (PHP_VERSION_ID < 50600) {
|
|
||||||
if (!headers_sent()) {
|
|
||||||
header('HTTP/1.1 500 Internal Server Error');
|
|
||||||
}
|
|
||||||
$err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
|
|
||||||
if (!ini_get('display_errors')) {
|
|
||||||
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
|
|
||||||
fwrite(STDERR, $err);
|
|
||||||
} elseif (!headers_sent()) {
|
|
||||||
echo $err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new RuntimeException($err);
|
|
||||||
}
|
|
||||||
|
|
||||||
require_once __DIR__ . '/composer/autoload_real.php';
|
|
||||||
|
|
||||||
return ComposerAutoloaderInit20fad51902f91e7fd3039e016a6556b5::getLoader();
|
|
||||||
579
vendor/composer/ClassLoader.php
vendored
579
vendor/composer/ClassLoader.php
vendored
@@ -1,579 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of Composer.
|
|
||||||
*
|
|
||||||
* (c) Nils Adermann <naderman@naderman.de>
|
|
||||||
* Jordi Boggiano <j.boggiano@seld.be>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Composer\Autoload;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
|
|
||||||
*
|
|
||||||
* $loader = new \Composer\Autoload\ClassLoader();
|
|
||||||
*
|
|
||||||
* // register classes with namespaces
|
|
||||||
* $loader->add('Symfony\Component', __DIR__.'/component');
|
|
||||||
* $loader->add('Symfony', __DIR__.'/framework');
|
|
||||||
*
|
|
||||||
* // activate the autoloader
|
|
||||||
* $loader->register();
|
|
||||||
*
|
|
||||||
* // to enable searching the include path (eg. for PEAR packages)
|
|
||||||
* $loader->setUseIncludePath(true);
|
|
||||||
*
|
|
||||||
* In this example, if you try to use a class in the Symfony\Component
|
|
||||||
* namespace or one of its children (Symfony\Component\Console for instance),
|
|
||||||
* the autoloader will first look for the class under the component/
|
|
||||||
* directory, and it will then fallback to the framework/ directory if not
|
|
||||||
* found before giving up.
|
|
||||||
*
|
|
||||||
* This class is loosely based on the Symfony UniversalClassLoader.
|
|
||||||
*
|
|
||||||
* @author Fabien Potencier <fabien@symfony.com>
|
|
||||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
|
||||||
* @see https://www.php-fig.org/psr/psr-0/
|
|
||||||
* @see https://www.php-fig.org/psr/psr-4/
|
|
||||||
*/
|
|
||||||
class ClassLoader
|
|
||||||
{
|
|
||||||
/** @var \Closure(string):void */
|
|
||||||
private static $includeFile;
|
|
||||||
|
|
||||||
/** @var string|null */
|
|
||||||
private $vendorDir;
|
|
||||||
|
|
||||||
// PSR-4
|
|
||||||
/**
|
|
||||||
* @var array<string, array<string, int>>
|
|
||||||
*/
|
|
||||||
private $prefixLengthsPsr4 = array();
|
|
||||||
/**
|
|
||||||
* @var array<string, list<string>>
|
|
||||||
*/
|
|
||||||
private $prefixDirsPsr4 = array();
|
|
||||||
/**
|
|
||||||
* @var list<string>
|
|
||||||
*/
|
|
||||||
private $fallbackDirsPsr4 = array();
|
|
||||||
|
|
||||||
// PSR-0
|
|
||||||
/**
|
|
||||||
* List of PSR-0 prefixes
|
|
||||||
*
|
|
||||||
* Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2')))
|
|
||||||
*
|
|
||||||
* @var array<string, array<string, list<string>>>
|
|
||||||
*/
|
|
||||||
private $prefixesPsr0 = array();
|
|
||||||
/**
|
|
||||||
* @var list<string>
|
|
||||||
*/
|
|
||||||
private $fallbackDirsPsr0 = array();
|
|
||||||
|
|
||||||
/** @var bool */
|
|
||||||
private $useIncludePath = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array<string, string>
|
|
||||||
*/
|
|
||||||
private $classMap = array();
|
|
||||||
|
|
||||||
/** @var bool */
|
|
||||||
private $classMapAuthoritative = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array<string, bool>
|
|
||||||
*/
|
|
||||||
private $missingClasses = array();
|
|
||||||
|
|
||||||
/** @var string|null */
|
|
||||||
private $apcuPrefix;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array<string, self>
|
|
||||||
*/
|
|
||||||
private static $registeredLoaders = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string|null $vendorDir
|
|
||||||
*/
|
|
||||||
public function __construct($vendorDir = null)
|
|
||||||
{
|
|
||||||
$this->vendorDir = $vendorDir;
|
|
||||||
self::initializeIncludeClosure();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string, list<string>>
|
|
||||||
*/
|
|
||||||
public function getPrefixes()
|
|
||||||
{
|
|
||||||
if (!empty($this->prefixesPsr0)) {
|
|
||||||
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
|
|
||||||
}
|
|
||||||
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string, list<string>>
|
|
||||||
*/
|
|
||||||
public function getPrefixesPsr4()
|
|
||||||
{
|
|
||||||
return $this->prefixDirsPsr4;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return list<string>
|
|
||||||
*/
|
|
||||||
public function getFallbackDirs()
|
|
||||||
{
|
|
||||||
return $this->fallbackDirsPsr0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return list<string>
|
|
||||||
*/
|
|
||||||
public function getFallbackDirsPsr4()
|
|
||||||
{
|
|
||||||
return $this->fallbackDirsPsr4;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string, string> Array of classname => path
|
|
||||||
*/
|
|
||||||
public function getClassMap()
|
|
||||||
{
|
|
||||||
return $this->classMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array<string, string> $classMap Class to filename map
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function addClassMap(array $classMap)
|
|
||||||
{
|
|
||||||
if ($this->classMap) {
|
|
||||||
$this->classMap = array_merge($this->classMap, $classMap);
|
|
||||||
} else {
|
|
||||||
$this->classMap = $classMap;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers a set of PSR-0 directories for a given prefix, either
|
|
||||||
* appending or prepending to the ones previously set for this prefix.
|
|
||||||
*
|
|
||||||
* @param string $prefix The prefix
|
|
||||||
* @param list<string>|string $paths The PSR-0 root directories
|
|
||||||
* @param bool $prepend Whether to prepend the directories
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function add($prefix, $paths, $prepend = false)
|
|
||||||
{
|
|
||||||
$paths = (array) $paths;
|
|
||||||
if (!$prefix) {
|
|
||||||
if ($prepend) {
|
|
||||||
$this->fallbackDirsPsr0 = array_merge(
|
|
||||||
$paths,
|
|
||||||
$this->fallbackDirsPsr0
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$this->fallbackDirsPsr0 = array_merge(
|
|
||||||
$this->fallbackDirsPsr0,
|
|
||||||
$paths
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$first = $prefix[0];
|
|
||||||
if (!isset($this->prefixesPsr0[$first][$prefix])) {
|
|
||||||
$this->prefixesPsr0[$first][$prefix] = $paths;
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ($prepend) {
|
|
||||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
|
||||||
$paths,
|
|
||||||
$this->prefixesPsr0[$first][$prefix]
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
|
||||||
$this->prefixesPsr0[$first][$prefix],
|
|
||||||
$paths
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers a set of PSR-4 directories for a given namespace, either
|
|
||||||
* appending or prepending to the ones previously set for this namespace.
|
|
||||||
*
|
|
||||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
|
||||||
* @param list<string>|string $paths The PSR-4 base directories
|
|
||||||
* @param bool $prepend Whether to prepend the directories
|
|
||||||
*
|
|
||||||
* @throws \InvalidArgumentException
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function addPsr4($prefix, $paths, $prepend = false)
|
|
||||||
{
|
|
||||||
$paths = (array) $paths;
|
|
||||||
if (!$prefix) {
|
|
||||||
// Register directories for the root namespace.
|
|
||||||
if ($prepend) {
|
|
||||||
$this->fallbackDirsPsr4 = array_merge(
|
|
||||||
$paths,
|
|
||||||
$this->fallbackDirsPsr4
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$this->fallbackDirsPsr4 = array_merge(
|
|
||||||
$this->fallbackDirsPsr4,
|
|
||||||
$paths
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
|
||||||
// Register directories for a new namespace.
|
|
||||||
$length = strlen($prefix);
|
|
||||||
if ('\\' !== $prefix[$length - 1]) {
|
|
||||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
|
||||||
}
|
|
||||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
|
||||||
$this->prefixDirsPsr4[$prefix] = $paths;
|
|
||||||
} elseif ($prepend) {
|
|
||||||
// Prepend directories for an already registered namespace.
|
|
||||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
|
||||||
$paths,
|
|
||||||
$this->prefixDirsPsr4[$prefix]
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
// Append directories for an already registered namespace.
|
|
||||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
|
||||||
$this->prefixDirsPsr4[$prefix],
|
|
||||||
$paths
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers a set of PSR-0 directories for a given prefix,
|
|
||||||
* replacing any others previously set for this prefix.
|
|
||||||
*
|
|
||||||
* @param string $prefix The prefix
|
|
||||||
* @param list<string>|string $paths The PSR-0 base directories
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function set($prefix, $paths)
|
|
||||||
{
|
|
||||||
if (!$prefix) {
|
|
||||||
$this->fallbackDirsPsr0 = (array) $paths;
|
|
||||||
} else {
|
|
||||||
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers a set of PSR-4 directories for a given namespace,
|
|
||||||
* replacing any others previously set for this namespace.
|
|
||||||
*
|
|
||||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
|
||||||
* @param list<string>|string $paths The PSR-4 base directories
|
|
||||||
*
|
|
||||||
* @throws \InvalidArgumentException
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function setPsr4($prefix, $paths)
|
|
||||||
{
|
|
||||||
if (!$prefix) {
|
|
||||||
$this->fallbackDirsPsr4 = (array) $paths;
|
|
||||||
} else {
|
|
||||||
$length = strlen($prefix);
|
|
||||||
if ('\\' !== $prefix[$length - 1]) {
|
|
||||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
|
||||||
}
|
|
||||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
|
||||||
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Turns on searching the include path for class files.
|
|
||||||
*
|
|
||||||
* @param bool $useIncludePath
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function setUseIncludePath($useIncludePath)
|
|
||||||
{
|
|
||||||
$this->useIncludePath = $useIncludePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Can be used to check if the autoloader uses the include path to check
|
|
||||||
* for classes.
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function getUseIncludePath()
|
|
||||||
{
|
|
||||||
return $this->useIncludePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Turns off searching the prefix and fallback directories for classes
|
|
||||||
* that have not been registered with the class map.
|
|
||||||
*
|
|
||||||
* @param bool $classMapAuthoritative
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function setClassMapAuthoritative($classMapAuthoritative)
|
|
||||||
{
|
|
||||||
$this->classMapAuthoritative = $classMapAuthoritative;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Should class lookup fail if not found in the current class map?
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function isClassMapAuthoritative()
|
|
||||||
{
|
|
||||||
return $this->classMapAuthoritative;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
|
|
||||||
*
|
|
||||||
* @param string|null $apcuPrefix
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function setApcuPrefix($apcuPrefix)
|
|
||||||
{
|
|
||||||
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The APCu prefix in use, or null if APCu caching is not enabled.
|
|
||||||
*
|
|
||||||
* @return string|null
|
|
||||||
*/
|
|
||||||
public function getApcuPrefix()
|
|
||||||
{
|
|
||||||
return $this->apcuPrefix;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers this instance as an autoloader.
|
|
||||||
*
|
|
||||||
* @param bool $prepend Whether to prepend the autoloader or not
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function register($prepend = false)
|
|
||||||
{
|
|
||||||
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
|
||||||
|
|
||||||
if (null === $this->vendorDir) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($prepend) {
|
|
||||||
self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
|
|
||||||
} else {
|
|
||||||
unset(self::$registeredLoaders[$this->vendorDir]);
|
|
||||||
self::$registeredLoaders[$this->vendorDir] = $this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unregisters this instance as an autoloader.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function unregister()
|
|
||||||
{
|
|
||||||
spl_autoload_unregister(array($this, 'loadClass'));
|
|
||||||
|
|
||||||
if (null !== $this->vendorDir) {
|
|
||||||
unset(self::$registeredLoaders[$this->vendorDir]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads the given class or interface.
|
|
||||||
*
|
|
||||||
* @param string $class The name of the class
|
|
||||||
* @return true|null True if loaded, null otherwise
|
|
||||||
*/
|
|
||||||
public function loadClass($class)
|
|
||||||
{
|
|
||||||
if ($file = $this->findFile($class)) {
|
|
||||||
$includeFile = self::$includeFile;
|
|
||||||
$includeFile($file);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds the path to the file where the class is defined.
|
|
||||||
*
|
|
||||||
* @param string $class The name of the class
|
|
||||||
*
|
|
||||||
* @return string|false The path if found, false otherwise
|
|
||||||
*/
|
|
||||||
public function findFile($class)
|
|
||||||
{
|
|
||||||
// class map lookup
|
|
||||||
if (isset($this->classMap[$class])) {
|
|
||||||
return $this->classMap[$class];
|
|
||||||
}
|
|
||||||
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (null !== $this->apcuPrefix) {
|
|
||||||
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
|
|
||||||
if ($hit) {
|
|
||||||
return $file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$file = $this->findFileWithExtension($class, '.php');
|
|
||||||
|
|
||||||
// Search for Hack files if we are running on HHVM
|
|
||||||
if (false === $file && defined('HHVM_VERSION')) {
|
|
||||||
$file = $this->findFileWithExtension($class, '.hh');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (null !== $this->apcuPrefix) {
|
|
||||||
apcu_add($this->apcuPrefix.$class, $file);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (false === $file) {
|
|
||||||
// Remember that this class does not exist.
|
|
||||||
$this->missingClasses[$class] = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $file;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the currently registered loaders keyed by their corresponding vendor directories.
|
|
||||||
*
|
|
||||||
* @return array<string, self>
|
|
||||||
*/
|
|
||||||
public static function getRegisteredLoaders()
|
|
||||||
{
|
|
||||||
return self::$registeredLoaders;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $class
|
|
||||||
* @param string $ext
|
|
||||||
* @return string|false
|
|
||||||
*/
|
|
||||||
private function findFileWithExtension($class, $ext)
|
|
||||||
{
|
|
||||||
// PSR-4 lookup
|
|
||||||
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
|
|
||||||
|
|
||||||
$first = $class[0];
|
|
||||||
if (isset($this->prefixLengthsPsr4[$first])) {
|
|
||||||
$subPath = $class;
|
|
||||||
while (false !== $lastPos = strrpos($subPath, '\\')) {
|
|
||||||
$subPath = substr($subPath, 0, $lastPos);
|
|
||||||
$search = $subPath . '\\';
|
|
||||||
if (isset($this->prefixDirsPsr4[$search])) {
|
|
||||||
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
|
|
||||||
foreach ($this->prefixDirsPsr4[$search] as $dir) {
|
|
||||||
if (file_exists($file = $dir . $pathEnd)) {
|
|
||||||
return $file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// PSR-4 fallback dirs
|
|
||||||
foreach ($this->fallbackDirsPsr4 as $dir) {
|
|
||||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
|
|
||||||
return $file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// PSR-0 lookup
|
|
||||||
if (false !== $pos = strrpos($class, '\\')) {
|
|
||||||
// namespaced class name
|
|
||||||
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
|
|
||||||
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
|
|
||||||
} else {
|
|
||||||
// PEAR-like class name
|
|
||||||
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($this->prefixesPsr0[$first])) {
|
|
||||||
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
|
|
||||||
if (0 === strpos($class, $prefix)) {
|
|
||||||
foreach ($dirs as $dir) {
|
|
||||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
|
||||||
return $file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// PSR-0 fallback dirs
|
|
||||||
foreach ($this->fallbackDirsPsr0 as $dir) {
|
|
||||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
|
||||||
return $file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// PSR-0 include paths.
|
|
||||||
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
|
|
||||||
return $file;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
private static function initializeIncludeClosure()
|
|
||||||
{
|
|
||||||
if (self::$includeFile !== null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Scope isolated include.
|
|
||||||
*
|
|
||||||
* Prevents access to $this/self from included files.
|
|
||||||
*
|
|
||||||
* @param string $file
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
self::$includeFile = \Closure::bind(static function($file) {
|
|
||||||
include $file;
|
|
||||||
}, null, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
396
vendor/composer/InstalledVersions.php
vendored
396
vendor/composer/InstalledVersions.php
vendored
@@ -1,396 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of Composer.
|
|
||||||
*
|
|
||||||
* (c) Nils Adermann <naderman@naderman.de>
|
|
||||||
* Jordi Boggiano <j.boggiano@seld.be>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Composer;
|
|
||||||
|
|
||||||
use Composer\Autoload\ClassLoader;
|
|
||||||
use Composer\Semver\VersionParser;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class is copied in every Composer installed project and available to all
|
|
||||||
*
|
|
||||||
* See also https://getcomposer.org/doc/07-runtime.md#installed-versions
|
|
||||||
*
|
|
||||||
* To require its presence, you can require `composer-runtime-api ^2.0`
|
|
||||||
*
|
|
||||||
* @final
|
|
||||||
*/
|
|
||||||
class InstalledVersions
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var string|null if set (by reflection by Composer), this should be set to the path where this class is being copied to
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
private static $selfDir = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var mixed[]|null
|
|
||||||
* @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null
|
|
||||||
*/
|
|
||||||
private static $installed;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
private static $installedIsLocalDir;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var bool|null
|
|
||||||
*/
|
|
||||||
private static $canGetVendors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array[]
|
|
||||||
* @psalm-var array<string, array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
|
||||||
*/
|
|
||||||
private static $installedByVendor = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a list of all package names which are present, either by being installed, replaced or provided
|
|
||||||
*
|
|
||||||
* @return string[]
|
|
||||||
* @psalm-return list<string>
|
|
||||||
*/
|
|
||||||
public static function getInstalledPackages()
|
|
||||||
{
|
|
||||||
$packages = array();
|
|
||||||
foreach (self::getInstalled() as $installed) {
|
|
||||||
$packages[] = array_keys($installed['versions']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (1 === \count($packages)) {
|
|
||||||
return $packages[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a list of all package names with a specific type e.g. 'library'
|
|
||||||
*
|
|
||||||
* @param string $type
|
|
||||||
* @return string[]
|
|
||||||
* @psalm-return list<string>
|
|
||||||
*/
|
|
||||||
public static function getInstalledPackagesByType($type)
|
|
||||||
{
|
|
||||||
$packagesByType = array();
|
|
||||||
|
|
||||||
foreach (self::getInstalled() as $installed) {
|
|
||||||
foreach ($installed['versions'] as $name => $package) {
|
|
||||||
if (isset($package['type']) && $package['type'] === $type) {
|
|
||||||
$packagesByType[] = $name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $packagesByType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks whether the given package is installed
|
|
||||||
*
|
|
||||||
* This also returns true if the package name is provided or replaced by another package
|
|
||||||
*
|
|
||||||
* @param string $packageName
|
|
||||||
* @param bool $includeDevRequirements
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public static function isInstalled($packageName, $includeDevRequirements = true)
|
|
||||||
{
|
|
||||||
foreach (self::getInstalled() as $installed) {
|
|
||||||
if (isset($installed['versions'][$packageName])) {
|
|
||||||
return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks whether the given package satisfies a version constraint
|
|
||||||
*
|
|
||||||
* e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:
|
|
||||||
*
|
|
||||||
* Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')
|
|
||||||
*
|
|
||||||
* @param VersionParser $parser Install composer/semver to have access to this class and functionality
|
|
||||||
* @param string $packageName
|
|
||||||
* @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public static function satisfies(VersionParser $parser, $packageName, $constraint)
|
|
||||||
{
|
|
||||||
$constraint = $parser->parseConstraints((string) $constraint);
|
|
||||||
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
|
|
||||||
|
|
||||||
return $provided->matches($constraint);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a version constraint representing all the range(s) which are installed for a given package
|
|
||||||
*
|
|
||||||
* It is easier to use this via isInstalled() with the $constraint argument if you need to check
|
|
||||||
* whether a given version of a package is installed, and not just whether it exists
|
|
||||||
*
|
|
||||||
* @param string $packageName
|
|
||||||
* @return string Version constraint usable with composer/semver
|
|
||||||
*/
|
|
||||||
public static function getVersionRanges($packageName)
|
|
||||||
{
|
|
||||||
foreach (self::getInstalled() as $installed) {
|
|
||||||
if (!isset($installed['versions'][$packageName])) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$ranges = array();
|
|
||||||
if (isset($installed['versions'][$packageName]['pretty_version'])) {
|
|
||||||
$ranges[] = $installed['versions'][$packageName]['pretty_version'];
|
|
||||||
}
|
|
||||||
if (array_key_exists('aliases', $installed['versions'][$packageName])) {
|
|
||||||
$ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
|
|
||||||
}
|
|
||||||
if (array_key_exists('replaced', $installed['versions'][$packageName])) {
|
|
||||||
$ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
|
|
||||||
}
|
|
||||||
if (array_key_exists('provided', $installed['versions'][$packageName])) {
|
|
||||||
$ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
|
|
||||||
}
|
|
||||||
|
|
||||||
return implode(' || ', $ranges);
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $packageName
|
|
||||||
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
|
|
||||||
*/
|
|
||||||
public static function getVersion($packageName)
|
|
||||||
{
|
|
||||||
foreach (self::getInstalled() as $installed) {
|
|
||||||
if (!isset($installed['versions'][$packageName])) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isset($installed['versions'][$packageName]['version'])) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $installed['versions'][$packageName]['version'];
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $packageName
|
|
||||||
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
|
|
||||||
*/
|
|
||||||
public static function getPrettyVersion($packageName)
|
|
||||||
{
|
|
||||||
foreach (self::getInstalled() as $installed) {
|
|
||||||
if (!isset($installed['versions'][$packageName])) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isset($installed['versions'][$packageName]['pretty_version'])) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $installed['versions'][$packageName]['pretty_version'];
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $packageName
|
|
||||||
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference
|
|
||||||
*/
|
|
||||||
public static function getReference($packageName)
|
|
||||||
{
|
|
||||||
foreach (self::getInstalled() as $installed) {
|
|
||||||
if (!isset($installed['versions'][$packageName])) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isset($installed['versions'][$packageName]['reference'])) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $installed['versions'][$packageName]['reference'];
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $packageName
|
|
||||||
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path.
|
|
||||||
*/
|
|
||||||
public static function getInstallPath($packageName)
|
|
||||||
{
|
|
||||||
foreach (self::getInstalled() as $installed) {
|
|
||||||
if (!isset($installed['versions'][$packageName])) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
* @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}
|
|
||||||
*/
|
|
||||||
public static function getRootPackage()
|
|
||||||
{
|
|
||||||
$installed = self::getInstalled();
|
|
||||||
|
|
||||||
return $installed[0]['root'];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the raw installed.php data for custom implementations
|
|
||||||
*
|
|
||||||
* @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
|
|
||||||
* @return array[]
|
|
||||||
* @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}
|
|
||||||
*/
|
|
||||||
public static function getRawData()
|
|
||||||
{
|
|
||||||
@trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
|
|
||||||
|
|
||||||
if (null === self::$installed) {
|
|
||||||
// only require the installed.php file if this file is loaded from its dumped location,
|
|
||||||
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
|
|
||||||
if (substr(__DIR__, -8, 1) !== 'C') {
|
|
||||||
self::$installed = include __DIR__ . '/installed.php';
|
|
||||||
} else {
|
|
||||||
self::$installed = array();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return self::$installed;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the raw data of all installed.php which are currently loaded for custom implementations
|
|
||||||
*
|
|
||||||
* @return array[]
|
|
||||||
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
|
||||||
*/
|
|
||||||
public static function getAllRawData()
|
|
||||||
{
|
|
||||||
return self::getInstalled();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Lets you reload the static array from another file
|
|
||||||
*
|
|
||||||
* This is only useful for complex integrations in which a project needs to use
|
|
||||||
* this class but then also needs to execute another project's autoloader in process,
|
|
||||||
* and wants to ensure both projects have access to their version of installed.php.
|
|
||||||
*
|
|
||||||
* A typical case would be PHPUnit, where it would need to make sure it reads all
|
|
||||||
* the data it needs from this class, then call reload() with
|
|
||||||
* `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure
|
|
||||||
* the project in which it runs can then also use this class safely, without
|
|
||||||
* interference between PHPUnit's dependencies and the project's dependencies.
|
|
||||||
*
|
|
||||||
* @param array[] $data A vendor/composer/installed.php data set
|
|
||||||
* @return void
|
|
||||||
*
|
|
||||||
* @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $data
|
|
||||||
*/
|
|
||||||
public static function reload($data)
|
|
||||||
{
|
|
||||||
self::$installed = $data;
|
|
||||||
self::$installedByVendor = array();
|
|
||||||
|
|
||||||
// when using reload, we disable the duplicate protection to ensure that self::$installed data is
|
|
||||||
// always returned, but we cannot know whether it comes from the installed.php in __DIR__ or not,
|
|
||||||
// so we have to assume it does not, and that may result in duplicate data being returned when listing
|
|
||||||
// all installed packages for example
|
|
||||||
self::$installedIsLocalDir = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
private static function getSelfDir()
|
|
||||||
{
|
|
||||||
if (self::$selfDir === null) {
|
|
||||||
self::$selfDir = strtr(__DIR__, '\\', '/');
|
|
||||||
}
|
|
||||||
|
|
||||||
return self::$selfDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array[]
|
|
||||||
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
|
||||||
*/
|
|
||||||
private static function getInstalled()
|
|
||||||
{
|
|
||||||
if (null === self::$canGetVendors) {
|
|
||||||
self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
|
|
||||||
}
|
|
||||||
|
|
||||||
$installed = array();
|
|
||||||
$copiedLocalDir = false;
|
|
||||||
|
|
||||||
if (self::$canGetVendors) {
|
|
||||||
$selfDir = self::getSelfDir();
|
|
||||||
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
|
|
||||||
$vendorDir = strtr($vendorDir, '\\', '/');
|
|
||||||
if (isset(self::$installedByVendor[$vendorDir])) {
|
|
||||||
$installed[] = self::$installedByVendor[$vendorDir];
|
|
||||||
} elseif (is_file($vendorDir.'/composer/installed.php')) {
|
|
||||||
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
|
|
||||||
$required = require $vendorDir.'/composer/installed.php';
|
|
||||||
self::$installedByVendor[$vendorDir] = $required;
|
|
||||||
$installed[] = $required;
|
|
||||||
if (self::$installed === null && $vendorDir.'/composer' === $selfDir) {
|
|
||||||
self::$installed = $required;
|
|
||||||
self::$installedIsLocalDir = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (self::$installedIsLocalDir && $vendorDir.'/composer' === $selfDir) {
|
|
||||||
$copiedLocalDir = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (null === self::$installed) {
|
|
||||||
// only require the installed.php file if this file is loaded from its dumped location,
|
|
||||||
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
|
|
||||||
if (substr(__DIR__, -8, 1) !== 'C') {
|
|
||||||
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
|
|
||||||
$required = require __DIR__ . '/installed.php';
|
|
||||||
self::$installed = $required;
|
|
||||||
} else {
|
|
||||||
self::$installed = array();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (self::$installed !== array() && !$copiedLocalDir) {
|
|
||||||
$installed[] = self::$installed;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $installed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
21
vendor/composer/LICENSE
vendored
21
vendor/composer/LICENSE
vendored
@@ -1,21 +0,0 @@
|
|||||||
|
|
||||||
Copyright (c) Nils Adermann, Jordi Boggiano
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is furnished
|
|
||||||
to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
|
|
||||||
10
vendor/composer/autoload_classmap.php
vendored
10
vendor/composer/autoload_classmap.php
vendored
@@ -1,10 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
// autoload_classmap.php @generated by Composer
|
|
||||||
|
|
||||||
$vendorDir = dirname(__DIR__);
|
|
||||||
$baseDir = dirname($vendorDir);
|
|
||||||
|
|
||||||
return array(
|
|
||||||
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
|
|
||||||
);
|
|
||||||
9
vendor/composer/autoload_namespaces.php
vendored
9
vendor/composer/autoload_namespaces.php
vendored
@@ -1,9 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
// autoload_namespaces.php @generated by Composer
|
|
||||||
|
|
||||||
$vendorDir = dirname(__DIR__);
|
|
||||||
$baseDir = dirname($vendorDir);
|
|
||||||
|
|
||||||
return array(
|
|
||||||
);
|
|
||||||
10
vendor/composer/autoload_psr4.php
vendored
10
vendor/composer/autoload_psr4.php
vendored
@@ -1,10 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
// autoload_psr4.php @generated by Composer
|
|
||||||
|
|
||||||
$vendorDir = dirname(__DIR__);
|
|
||||||
$baseDir = dirname($vendorDir);
|
|
||||||
|
|
||||||
return array(
|
|
||||||
'Firebase\\JWT\\' => array($vendorDir . '/firebase/php-jwt/src'),
|
|
||||||
);
|
|
||||||
38
vendor/composer/autoload_real.php
vendored
38
vendor/composer/autoload_real.php
vendored
@@ -1,38 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
// autoload_real.php @generated by Composer
|
|
||||||
|
|
||||||
class ComposerAutoloaderInit20fad51902f91e7fd3039e016a6556b5
|
|
||||||
{
|
|
||||||
private static $loader;
|
|
||||||
|
|
||||||
public static function loadClassLoader($class)
|
|
||||||
{
|
|
||||||
if ('Composer\Autoload\ClassLoader' === $class) {
|
|
||||||
require __DIR__ . '/ClassLoader.php';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return \Composer\Autoload\ClassLoader
|
|
||||||
*/
|
|
||||||
public static function getLoader()
|
|
||||||
{
|
|
||||||
if (null !== self::$loader) {
|
|
||||||
return self::$loader;
|
|
||||||
}
|
|
||||||
|
|
||||||
require __DIR__ . '/platform_check.php';
|
|
||||||
|
|
||||||
spl_autoload_register(array('ComposerAutoloaderInit20fad51902f91e7fd3039e016a6556b5', 'loadClassLoader'), true, true);
|
|
||||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
|
||||||
spl_autoload_unregister(array('ComposerAutoloaderInit20fad51902f91e7fd3039e016a6556b5', 'loadClassLoader'));
|
|
||||||
|
|
||||||
require __DIR__ . '/autoload_static.php';
|
|
||||||
call_user_func(\Composer\Autoload\ComposerStaticInit20fad51902f91e7fd3039e016a6556b5::getInitializer($loader));
|
|
||||||
|
|
||||||
$loader->register(true);
|
|
||||||
|
|
||||||
return $loader;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
36
vendor/composer/autoload_static.php
vendored
36
vendor/composer/autoload_static.php
vendored
@@ -1,36 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
// autoload_static.php @generated by Composer
|
|
||||||
|
|
||||||
namespace Composer\Autoload;
|
|
||||||
|
|
||||||
class ComposerStaticInit20fad51902f91e7fd3039e016a6556b5
|
|
||||||
{
|
|
||||||
public static $prefixLengthsPsr4 = array (
|
|
||||||
'F' =>
|
|
||||||
array (
|
|
||||||
'Firebase\\JWT\\' => 13,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
public static $prefixDirsPsr4 = array (
|
|
||||||
'Firebase\\JWT\\' =>
|
|
||||||
array (
|
|
||||||
0 => __DIR__ . '/..' . '/firebase/php-jwt/src',
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
public static $classMap = array (
|
|
||||||
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
|
|
||||||
);
|
|
||||||
|
|
||||||
public static function getInitializer(ClassLoader $loader)
|
|
||||||
{
|
|
||||||
return \Closure::bind(function () use ($loader) {
|
|
||||||
$loader->prefixLengthsPsr4 = ComposerStaticInit20fad51902f91e7fd3039e016a6556b5::$prefixLengthsPsr4;
|
|
||||||
$loader->prefixDirsPsr4 = ComposerStaticInit20fad51902f91e7fd3039e016a6556b5::$prefixDirsPsr4;
|
|
||||||
$loader->classMap = ComposerStaticInit20fad51902f91e7fd3039e016a6556b5::$classMap;
|
|
||||||
|
|
||||||
}, null, ClassLoader::class);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
72
vendor/composer/installed.json
vendored
72
vendor/composer/installed.json
vendored
@@ -1,72 +0,0 @@
|
|||||||
{
|
|
||||||
"packages": [
|
|
||||||
{
|
|
||||||
"name": "firebase/php-jwt",
|
|
||||||
"version": "v6.11.1",
|
|
||||||
"version_normalized": "6.11.1.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/firebase/php-jwt.git",
|
|
||||||
"reference": "d1e91ecf8c598d073d0995afa8cd5c75c6e19e66"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/firebase/php-jwt/zipball/d1e91ecf8c598d073d0995afa8cd5c75c6e19e66",
|
|
||||||
"reference": "d1e91ecf8c598d073d0995afa8cd5c75c6e19e66",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": "^8.0"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"guzzlehttp/guzzle": "^7.4",
|
|
||||||
"phpspec/prophecy-phpunit": "^2.0",
|
|
||||||
"phpunit/phpunit": "^9.5",
|
|
||||||
"psr/cache": "^2.0||^3.0",
|
|
||||||
"psr/http-client": "^1.0",
|
|
||||||
"psr/http-factory": "^1.0"
|
|
||||||
},
|
|
||||||
"suggest": {
|
|
||||||
"ext-sodium": "Support EdDSA (Ed25519) signatures",
|
|
||||||
"paragonie/sodium_compat": "Support EdDSA (Ed25519) signatures when libsodium is not present"
|
|
||||||
},
|
|
||||||
"time": "2025-04-09T20:32:01+00:00",
|
|
||||||
"type": "library",
|
|
||||||
"installation-source": "dist",
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Firebase\\JWT\\": "src"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"BSD-3-Clause"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Neuman Vong",
|
|
||||||
"email": "neuman+pear@twilio.com",
|
|
||||||
"role": "Developer"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Anant Narayanan",
|
|
||||||
"email": "anant@php.net",
|
|
||||||
"role": "Developer"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.",
|
|
||||||
"homepage": "https://github.com/firebase/php-jwt",
|
|
||||||
"keywords": [
|
|
||||||
"jwt",
|
|
||||||
"php"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"issues": "https://github.com/firebase/php-jwt/issues",
|
|
||||||
"source": "https://github.com/firebase/php-jwt/tree/v6.11.1"
|
|
||||||
},
|
|
||||||
"install-path": "../firebase/php-jwt"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"dev": true,
|
|
||||||
"dev-package-names": []
|
|
||||||
}
|
|
||||||
32
vendor/composer/installed.php
vendored
32
vendor/composer/installed.php
vendored
@@ -1,32 +0,0 @@
|
|||||||
<?php return array(
|
|
||||||
'root' => array(
|
|
||||||
'name' => '__root__',
|
|
||||||
'pretty_version' => '1.0.0+no-version-set',
|
|
||||||
'version' => '1.0.0.0',
|
|
||||||
'reference' => null,
|
|
||||||
'type' => 'library',
|
|
||||||
'install_path' => __DIR__ . '/../../',
|
|
||||||
'aliases' => array(),
|
|
||||||
'dev' => true,
|
|
||||||
),
|
|
||||||
'versions' => array(
|
|
||||||
'__root__' => array(
|
|
||||||
'pretty_version' => '1.0.0+no-version-set',
|
|
||||||
'version' => '1.0.0.0',
|
|
||||||
'reference' => null,
|
|
||||||
'type' => 'library',
|
|
||||||
'install_path' => __DIR__ . '/../../',
|
|
||||||
'aliases' => array(),
|
|
||||||
'dev_requirement' => false,
|
|
||||||
),
|
|
||||||
'firebase/php-jwt' => array(
|
|
||||||
'pretty_version' => 'v6.11.1',
|
|
||||||
'version' => '6.11.1.0',
|
|
||||||
'reference' => 'd1e91ecf8c598d073d0995afa8cd5c75c6e19e66',
|
|
||||||
'type' => 'library',
|
|
||||||
'install_path' => __DIR__ . '/../firebase/php-jwt',
|
|
||||||
'aliases' => array(),
|
|
||||||
'dev_requirement' => false,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
26
vendor/composer/platform_check.php
vendored
26
vendor/composer/platform_check.php
vendored
@@ -1,26 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
// platform_check.php @generated by Composer
|
|
||||||
|
|
||||||
$issues = array();
|
|
||||||
|
|
||||||
if (!(PHP_VERSION_ID >= 80000)) {
|
|
||||||
$issues[] = 'Your Composer dependencies require a PHP version ">= 8.0.0". You are running ' . PHP_VERSION . '.';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($issues) {
|
|
||||||
if (!headers_sent()) {
|
|
||||||
header('HTTP/1.1 500 Internal Server Error');
|
|
||||||
}
|
|
||||||
if (!ini_get('display_errors')) {
|
|
||||||
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
|
|
||||||
fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL);
|
|
||||||
} elseif (!headers_sent()) {
|
|
||||||
echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
trigger_error(
|
|
||||||
'Composer detected issues in your platform: ' . implode(' ', $issues),
|
|
||||||
E_USER_ERROR
|
|
||||||
);
|
|
||||||
}
|
|
||||||
205
vendor/firebase/php-jwt/CHANGELOG.md
vendored
205
vendor/firebase/php-jwt/CHANGELOG.md
vendored
@@ -1,205 +0,0 @@
|
|||||||
# Changelog
|
|
||||||
|
|
||||||
## [6.11.1](https://github.com/firebase/php-jwt/compare/v6.11.0...v6.11.1) (2025-04-09)
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* update error text for consistency ([#528](https://github.com/firebase/php-jwt/issues/528)) ([c11113a](https://github.com/firebase/php-jwt/commit/c11113afa13265e016a669e75494b9203b8a7775))
|
|
||||||
|
|
||||||
## [6.11.0](https://github.com/firebase/php-jwt/compare/v6.10.2...v6.11.0) (2025-01-23)
|
|
||||||
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* support octet typed JWK ([#587](https://github.com/firebase/php-jwt/issues/587)) ([7cb8a26](https://github.com/firebase/php-jwt/commit/7cb8a265fa81edf2fa6ef8098f5bc5ae573c33ad))
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* refactor constructor Key to use PHP 8.0 syntax ([#577](https://github.com/firebase/php-jwt/issues/577)) ([29fa2ce](https://github.com/firebase/php-jwt/commit/29fa2ce9e0582cd397711eec1e80c05ce20fabca))
|
|
||||||
|
|
||||||
## [6.10.2](https://github.com/firebase/php-jwt/compare/v6.10.1...v6.10.2) (2024-11-24)
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* Mitigate PHP8.4 deprecation warnings ([#570](https://github.com/firebase/php-jwt/issues/570)) ([76808fa](https://github.com/firebase/php-jwt/commit/76808fa227f3811aa5cdb3bf81233714b799a5b5))
|
|
||||||
* support php 8.4 ([#583](https://github.com/firebase/php-jwt/issues/583)) ([e3d68b0](https://github.com/firebase/php-jwt/commit/e3d68b044421339443c74199edd020e03fb1887e))
|
|
||||||
|
|
||||||
## [6.10.1](https://github.com/firebase/php-jwt/compare/v6.10.0...v6.10.1) (2024-05-18)
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* ensure ratelimit expiry is set every time ([#556](https://github.com/firebase/php-jwt/issues/556)) ([09cb208](https://github.com/firebase/php-jwt/commit/09cb2081c2c3bc0f61e2f2a5fbea5741f7498648))
|
|
||||||
* ratelimit cache expiration ([#550](https://github.com/firebase/php-jwt/issues/550)) ([dda7250](https://github.com/firebase/php-jwt/commit/dda725033585ece30ff8cae8937320d7e9f18bae))
|
|
||||||
|
|
||||||
## [6.10.0](https://github.com/firebase/php-jwt/compare/v6.9.0...v6.10.0) (2023-11-28)
|
|
||||||
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* allow typ header override ([#546](https://github.com/firebase/php-jwt/issues/546)) ([79cb30b](https://github.com/firebase/php-jwt/commit/79cb30b729a22931b2fbd6b53f20629a83031ba9))
|
|
||||||
|
|
||||||
## [6.9.0](https://github.com/firebase/php-jwt/compare/v6.8.1...v6.9.0) (2023-10-04)
|
|
||||||
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* add payload to jwt exception ([#521](https://github.com/firebase/php-jwt/issues/521)) ([175edf9](https://github.com/firebase/php-jwt/commit/175edf958bb61922ec135b2333acf5622f2238a2))
|
|
||||||
|
|
||||||
## [6.8.1](https://github.com/firebase/php-jwt/compare/v6.8.0...v6.8.1) (2023-07-14)
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* accept float claims but round down to ignore them ([#492](https://github.com/firebase/php-jwt/issues/492)) ([3936842](https://github.com/firebase/php-jwt/commit/39368423beeaacb3002afa7dcb75baebf204fe7e))
|
|
||||||
* different BeforeValidException messages for nbf and iat ([#526](https://github.com/firebase/php-jwt/issues/526)) ([0a53cf2](https://github.com/firebase/php-jwt/commit/0a53cf2986e45c2bcbf1a269f313ebf56a154ee4))
|
|
||||||
|
|
||||||
## [6.8.0](https://github.com/firebase/php-jwt/compare/v6.7.0...v6.8.0) (2023-06-14)
|
|
||||||
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* add support for P-384 curve ([#515](https://github.com/firebase/php-jwt/issues/515)) ([5de4323](https://github.com/firebase/php-jwt/commit/5de4323f4baf4d70bca8663bd87682a69c656c3d))
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* handle invalid http responses ([#508](https://github.com/firebase/php-jwt/issues/508)) ([91c39c7](https://github.com/firebase/php-jwt/commit/91c39c72b22fc3e1191e574089552c1f2041c718))
|
|
||||||
|
|
||||||
## [6.7.0](https://github.com/firebase/php-jwt/compare/v6.6.0...v6.7.0) (2023-06-14)
|
|
||||||
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* add ed25519 support to JWK (public keys) ([#452](https://github.com/firebase/php-jwt/issues/452)) ([e53979a](https://github.com/firebase/php-jwt/commit/e53979abae927de916a75b9d239cfda8ce32be2a))
|
|
||||||
|
|
||||||
## [6.6.0](https://github.com/firebase/php-jwt/compare/v6.5.0...v6.6.0) (2023-06-13)
|
|
||||||
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* allow get headers when decoding token ([#442](https://github.com/firebase/php-jwt/issues/442)) ([fb85f47](https://github.com/firebase/php-jwt/commit/fb85f47cfaeffdd94faf8defdf07164abcdad6c3))
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* only check iat if nbf is not used ([#493](https://github.com/firebase/php-jwt/issues/493)) ([398ccd2](https://github.com/firebase/php-jwt/commit/398ccd25ea12fa84b9e4f1085d5ff448c21ec797))
|
|
||||||
|
|
||||||
## [6.5.0](https://github.com/firebase/php-jwt/compare/v6.4.0...v6.5.0) (2023-05-12)
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* allow KID of '0' ([#505](https://github.com/firebase/php-jwt/issues/505)) ([9dc46a9](https://github.com/firebase/php-jwt/commit/9dc46a9c3e5801294249cfd2554c5363c9f9326a))
|
|
||||||
|
|
||||||
|
|
||||||
### Miscellaneous Chores
|
|
||||||
|
|
||||||
* drop support for PHP 7.3 ([#495](https://github.com/firebase/php-jwt/issues/495))
|
|
||||||
|
|
||||||
## [6.4.0](https://github.com/firebase/php-jwt/compare/v6.3.2...v6.4.0) (2023-02-08)
|
|
||||||
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* add support for W3C ES256K ([#462](https://github.com/firebase/php-jwt/issues/462)) ([213924f](https://github.com/firebase/php-jwt/commit/213924f51936291fbbca99158b11bd4ae56c2c95))
|
|
||||||
* improve caching by only decoding jwks when necessary ([#486](https://github.com/firebase/php-jwt/issues/486)) ([78d3ed1](https://github.com/firebase/php-jwt/commit/78d3ed1073553f7d0bbffa6c2010009a0d483d5c))
|
|
||||||
|
|
||||||
## [6.3.2](https://github.com/firebase/php-jwt/compare/v6.3.1...v6.3.2) (2022-11-01)
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* check kid before using as array index ([bad1b04](https://github.com/firebase/php-jwt/commit/bad1b040d0c736bbf86814c6b5ae614f517cf7bd))
|
|
||||||
|
|
||||||
## [6.3.1](https://github.com/firebase/php-jwt/compare/v6.3.0...v6.3.1) (2022-11-01)
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* casing of GET for PSR compat ([#451](https://github.com/firebase/php-jwt/issues/451)) ([60b52b7](https://github.com/firebase/php-jwt/commit/60b52b71978790eafcf3b95cfbd83db0439e8d22))
|
|
||||||
* string interpolation format for php 8.2 ([#446](https://github.com/firebase/php-jwt/issues/446)) ([2e07d8a](https://github.com/firebase/php-jwt/commit/2e07d8a1524d12b69b110ad649f17461d068b8f2))
|
|
||||||
|
|
||||||
## 6.3.0 / 2022-07-15
|
|
||||||
|
|
||||||
- Added ES256 support to JWK parsing ([#399](https://github.com/firebase/php-jwt/pull/399))
|
|
||||||
- Fixed potential caching error in `CachedKeySet` by caching jwks as strings ([#435](https://github.com/firebase/php-jwt/pull/435))
|
|
||||||
|
|
||||||
## 6.2.0 / 2022-05-14
|
|
||||||
|
|
||||||
- Added `CachedKeySet` ([#397](https://github.com/firebase/php-jwt/pull/397))
|
|
||||||
- Added `$defaultAlg` parameter to `JWT::parseKey` and `JWT::parseKeySet` ([#426](https://github.com/firebase/php-jwt/pull/426)).
|
|
||||||
|
|
||||||
## 6.1.0 / 2022-03-23
|
|
||||||
|
|
||||||
- Drop support for PHP 5.3, 5.4, 5.5, 5.6, and 7.0
|
|
||||||
- Add parameter typing and return types where possible
|
|
||||||
|
|
||||||
## 6.0.0 / 2022-01-24
|
|
||||||
|
|
||||||
- **Backwards-Compatibility Breaking Changes**: See the [Release Notes](https://github.com/firebase/php-jwt/releases/tag/v6.0.0) for more information.
|
|
||||||
- New Key object to prevent key/algorithm type confusion (#365)
|
|
||||||
- Add JWK support (#273)
|
|
||||||
- Add ES256 support (#256)
|
|
||||||
- Add ES384 support (#324)
|
|
||||||
- Add Ed25519 support (#343)
|
|
||||||
|
|
||||||
## 5.0.0 / 2017-06-26
|
|
||||||
- Support RS384 and RS512.
|
|
||||||
See [#117](https://github.com/firebase/php-jwt/pull/117). Thanks [@joostfaassen](https://github.com/joostfaassen)!
|
|
||||||
- Add an example for RS256 openssl.
|
|
||||||
See [#125](https://github.com/firebase/php-jwt/pull/125). Thanks [@akeeman](https://github.com/akeeman)!
|
|
||||||
- Detect invalid Base64 encoding in signature.
|
|
||||||
See [#162](https://github.com/firebase/php-jwt/pull/162). Thanks [@psignoret](https://github.com/psignoret)!
|
|
||||||
- Update `JWT::verify` to handle OpenSSL errors.
|
|
||||||
See [#159](https://github.com/firebase/php-jwt/pull/159). Thanks [@bshaffer](https://github.com/bshaffer)!
|
|
||||||
- Add `array` type hinting to `decode` method
|
|
||||||
See [#101](https://github.com/firebase/php-jwt/pull/101). Thanks [@hywak](https://github.com/hywak)!
|
|
||||||
- Add all JSON error types.
|
|
||||||
See [#110](https://github.com/firebase/php-jwt/pull/110). Thanks [@gbalduzzi](https://github.com/gbalduzzi)!
|
|
||||||
- Bugfix 'kid' not in given key list.
|
|
||||||
See [#129](https://github.com/firebase/php-jwt/pull/129). Thanks [@stampycode](https://github.com/stampycode)!
|
|
||||||
- Miscellaneous cleanup, documentation and test fixes.
|
|
||||||
See [#107](https://github.com/firebase/php-jwt/pull/107), [#115](https://github.com/firebase/php-jwt/pull/115),
|
|
||||||
[#160](https://github.com/firebase/php-jwt/pull/160), [#161](https://github.com/firebase/php-jwt/pull/161), and
|
|
||||||
[#165](https://github.com/firebase/php-jwt/pull/165). Thanks [@akeeman](https://github.com/akeeman),
|
|
||||||
[@chinedufn](https://github.com/chinedufn), and [@bshaffer](https://github.com/bshaffer)!
|
|
||||||
|
|
||||||
## 4.0.0 / 2016-07-17
|
|
||||||
- Add support for late static binding. See [#88](https://github.com/firebase/php-jwt/pull/88) for details. Thanks to [@chappy84](https://github.com/chappy84)!
|
|
||||||
- Use static `$timestamp` instead of `time()` to improve unit testing. See [#93](https://github.com/firebase/php-jwt/pull/93) for details. Thanks to [@josephmcdermott](https://github.com/josephmcdermott)!
|
|
||||||
- Fixes to exceptions classes. See [#81](https://github.com/firebase/php-jwt/pull/81) for details. Thanks to [@Maks3w](https://github.com/Maks3w)!
|
|
||||||
- Fixes to PHPDoc. See [#76](https://github.com/firebase/php-jwt/pull/76) for details. Thanks to [@akeeman](https://github.com/akeeman)!
|
|
||||||
|
|
||||||
## 3.0.0 / 2015-07-22
|
|
||||||
- Minimum PHP version updated from `5.2.0` to `5.3.0`.
|
|
||||||
- Add `\Firebase\JWT` namespace. See
|
|
||||||
[#59](https://github.com/firebase/php-jwt/pull/59) for details. Thanks to
|
|
||||||
[@Dashron](https://github.com/Dashron)!
|
|
||||||
- Require a non-empty key to decode and verify a JWT. See
|
|
||||||
[#60](https://github.com/firebase/php-jwt/pull/60) for details. Thanks to
|
|
||||||
[@sjones608](https://github.com/sjones608)!
|
|
||||||
- Cleaner documentation blocks in the code. See
|
|
||||||
[#62](https://github.com/firebase/php-jwt/pull/62) for details. Thanks to
|
|
||||||
[@johanderuijter](https://github.com/johanderuijter)!
|
|
||||||
|
|
||||||
## 2.2.0 / 2015-06-22
|
|
||||||
- Add support for adding custom, optional JWT headers to `JWT::encode()`. See
|
|
||||||
[#53](https://github.com/firebase/php-jwt/pull/53/files) for details. Thanks to
|
|
||||||
[@mcocaro](https://github.com/mcocaro)!
|
|
||||||
|
|
||||||
## 2.1.0 / 2015-05-20
|
|
||||||
- Add support for adding a leeway to `JWT:decode()` that accounts for clock skew
|
|
||||||
between signing and verifying entities. Thanks to [@lcabral](https://github.com/lcabral)!
|
|
||||||
- Add support for passing an object implementing the `ArrayAccess` interface for
|
|
||||||
`$keys` argument in `JWT::decode()`. Thanks to [@aztech-dev](https://github.com/aztech-dev)!
|
|
||||||
|
|
||||||
## 2.0.0 / 2015-04-01
|
|
||||||
- **Note**: It is strongly recommended that you update to > v2.0.0 to address
|
|
||||||
known security vulnerabilities in prior versions when both symmetric and
|
|
||||||
asymmetric keys are used together.
|
|
||||||
- Update signature for `JWT::decode(...)` to require an array of supported
|
|
||||||
algorithms to use when verifying token signatures.
|
|
||||||
30
vendor/firebase/php-jwt/LICENSE
vendored
30
vendor/firebase/php-jwt/LICENSE
vendored
@@ -1,30 +0,0 @@
|
|||||||
Copyright (c) 2011, Neuman Vong
|
|
||||||
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
copyright notice, this list of conditions and the following
|
|
||||||
disclaimer in the documentation and/or other materials provided
|
|
||||||
with the distribution.
|
|
||||||
|
|
||||||
* Neither the name of the copyright holder nor the names of other
|
|
||||||
contributors may be used to endorse or promote products derived
|
|
||||||
from this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
425
vendor/firebase/php-jwt/README.md
vendored
425
vendor/firebase/php-jwt/README.md
vendored
@@ -1,425 +0,0 @@
|
|||||||

|
|
||||||
[](https://packagist.org/packages/firebase/php-jwt)
|
|
||||||
[](https://packagist.org/packages/firebase/php-jwt)
|
|
||||||
[](https://packagist.org/packages/firebase/php-jwt)
|
|
||||||
|
|
||||||
PHP-JWT
|
|
||||||
=======
|
|
||||||
A simple library to encode and decode JSON Web Tokens (JWT) in PHP, conforming to [RFC 7519](https://tools.ietf.org/html/rfc7519).
|
|
||||||
|
|
||||||
Installation
|
|
||||||
------------
|
|
||||||
|
|
||||||
Use composer to manage your dependencies and download PHP-JWT:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
composer require firebase/php-jwt
|
|
||||||
```
|
|
||||||
|
|
||||||
Optionally, install the `paragonie/sodium_compat` package from composer if your
|
|
||||||
php env does not have libsodium installed:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
composer require paragonie/sodium_compat
|
|
||||||
```
|
|
||||||
|
|
||||||
Example
|
|
||||||
-------
|
|
||||||
```php
|
|
||||||
use Firebase\JWT\JWT;
|
|
||||||
use Firebase\JWT\Key;
|
|
||||||
|
|
||||||
$key = 'example_key';
|
|
||||||
$payload = [
|
|
||||||
'iss' => 'http://example.org',
|
|
||||||
'aud' => 'http://example.com',
|
|
||||||
'iat' => 1356999524,
|
|
||||||
'nbf' => 1357000000
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* IMPORTANT:
|
|
||||||
* You must specify supported algorithms for your application. See
|
|
||||||
* https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40
|
|
||||||
* for a list of spec-compliant algorithms.
|
|
||||||
*/
|
|
||||||
$jwt = JWT::encode($payload, $key, 'HS256');
|
|
||||||
$decoded = JWT::decode($jwt, new Key($key, 'HS256'));
|
|
||||||
print_r($decoded);
|
|
||||||
|
|
||||||
// Pass a stdClass in as the third parameter to get the decoded header values
|
|
||||||
$headers = new stdClass();
|
|
||||||
$decoded = JWT::decode($jwt, new Key($key, 'HS256'), $headers);
|
|
||||||
print_r($headers);
|
|
||||||
|
|
||||||
/*
|
|
||||||
NOTE: This will now be an object instead of an associative array. To get
|
|
||||||
an associative array, you will need to cast it as such:
|
|
||||||
*/
|
|
||||||
|
|
||||||
$decoded_array = (array) $decoded;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* You can add a leeway to account for when there is a clock skew times between
|
|
||||||
* the signing and verifying servers. It is recommended that this leeway should
|
|
||||||
* not be bigger than a few minutes.
|
|
||||||
*
|
|
||||||
* Source: http://self-issued.info/docs/draft-ietf-oauth-json-web-token.html#nbfDef
|
|
||||||
*/
|
|
||||||
JWT::$leeway = 60; // $leeway in seconds
|
|
||||||
$decoded = JWT::decode($jwt, new Key($key, 'HS256'));
|
|
||||||
```
|
|
||||||
Example encode/decode headers
|
|
||||||
-------
|
|
||||||
Decoding the JWT headers without verifying the JWT first is NOT recommended, and is not supported by
|
|
||||||
this library. This is because without verifying the JWT, the header values could have been tampered with.
|
|
||||||
Any value pulled from an unverified header should be treated as if it could be any string sent in from an
|
|
||||||
attacker. If this is something you still want to do in your application for whatever reason, it's possible to
|
|
||||||
decode the header values manually simply by calling `json_decode` and `base64_decode` on the JWT
|
|
||||||
header part:
|
|
||||||
```php
|
|
||||||
use Firebase\JWT\JWT;
|
|
||||||
|
|
||||||
$key = 'example_key';
|
|
||||||
$payload = [
|
|
||||||
'iss' => 'http://example.org',
|
|
||||||
'aud' => 'http://example.com',
|
|
||||||
'iat' => 1356999524,
|
|
||||||
'nbf' => 1357000000
|
|
||||||
];
|
|
||||||
|
|
||||||
$headers = [
|
|
||||||
'x-forwarded-for' => 'www.google.com'
|
|
||||||
];
|
|
||||||
|
|
||||||
// Encode headers in the JWT string
|
|
||||||
$jwt = JWT::encode($payload, $key, 'HS256', null, $headers);
|
|
||||||
|
|
||||||
// Decode headers from the JWT string WITHOUT validation
|
|
||||||
// **IMPORTANT**: This operation is vulnerable to attacks, as the JWT has not yet been verified.
|
|
||||||
// These headers could be any value sent by an attacker.
|
|
||||||
list($headersB64, $payloadB64, $sig) = explode('.', $jwt);
|
|
||||||
$decoded = json_decode(base64_decode($headersB64), true);
|
|
||||||
|
|
||||||
print_r($decoded);
|
|
||||||
```
|
|
||||||
Example with RS256 (openssl)
|
|
||||||
----------------------------
|
|
||||||
```php
|
|
||||||
use Firebase\JWT\JWT;
|
|
||||||
use Firebase\JWT\Key;
|
|
||||||
|
|
||||||
$privateKey = <<<EOD
|
|
||||||
-----BEGIN RSA PRIVATE KEY-----
|
|
||||||
MIIEowIBAAKCAQEAuzWHNM5f+amCjQztc5QTfJfzCC5J4nuW+L/aOxZ4f8J3Frew
|
|
||||||
M2c/dufrnmedsApb0By7WhaHlcqCh/ScAPyJhzkPYLae7bTVro3hok0zDITR8F6S
|
|
||||||
JGL42JAEUk+ILkPI+DONM0+3vzk6Kvfe548tu4czCuqU8BGVOlnp6IqBHhAswNMM
|
|
||||||
78pos/2z0CjPM4tbeXqSTTbNkXRboxjU29vSopcT51koWOgiTf3C7nJUoMWZHZI5
|
|
||||||
HqnIhPAG9yv8HAgNk6CMk2CadVHDo4IxjxTzTTqo1SCSH2pooJl9O8at6kkRYsrZ
|
|
||||||
WwsKlOFE2LUce7ObnXsYihStBUDoeBQlGG/BwQIDAQABAoIBAFtGaOqNKGwggn9k
|
|
||||||
6yzr6GhZ6Wt2rh1Xpq8XUz514UBhPxD7dFRLpbzCrLVpzY80LbmVGJ9+1pJozyWc
|
|
||||||
VKeCeUdNwbqkr240Oe7GTFmGjDoxU+5/HX/SJYPpC8JZ9oqgEA87iz+WQX9hVoP2
|
|
||||||
oF6EB4ckDvXmk8FMwVZW2l2/kd5mrEVbDaXKxhvUDf52iVD+sGIlTif7mBgR99/b
|
|
||||||
c3qiCnxCMmfYUnT2eh7Vv2LhCR/G9S6C3R4lA71rEyiU3KgsGfg0d82/XWXbegJW
|
|
||||||
h3QbWNtQLxTuIvLq5aAryV3PfaHlPgdgK0ft6ocU2de2FagFka3nfVEyC7IUsNTK
|
|
||||||
bq6nhAECgYEA7d/0DPOIaItl/8BWKyCuAHMss47j0wlGbBSHdJIiS55akMvnAG0M
|
|
||||||
39y22Qqfzh1at9kBFeYeFIIU82ZLF3xOcE3z6pJZ4Dyvx4BYdXH77odo9uVK9s1l
|
|
||||||
3T3BlMcqd1hvZLMS7dviyH79jZo4CXSHiKzc7pQ2YfK5eKxKqONeXuECgYEAyXlG
|
|
||||||
vonaus/YTb1IBei9HwaccnQ/1HRn6MvfDjb7JJDIBhNClGPt6xRlzBbSZ73c2QEC
|
|
||||||
6Fu9h36K/HZ2qcLd2bXiNyhIV7b6tVKk+0Psoj0dL9EbhsD1OsmE1nTPyAc9XZbb
|
|
||||||
OPYxy+dpBCUA8/1U9+uiFoCa7mIbWcSQ+39gHuECgYAz82pQfct30aH4JiBrkNqP
|
|
||||||
nJfRq05UY70uk5k1u0ikLTRoVS/hJu/d4E1Kv4hBMqYCavFSwAwnvHUo51lVCr/y
|
|
||||||
xQOVYlsgnwBg2MX4+GjmIkqpSVCC8D7j/73MaWb746OIYZervQ8dbKahi2HbpsiG
|
|
||||||
8AHcVSA/agxZr38qvWV54QKBgCD5TlDE8x18AuTGQ9FjxAAd7uD0kbXNz2vUYg9L
|
|
||||||
hFL5tyL3aAAtUrUUw4xhd9IuysRhW/53dU+FsG2dXdJu6CxHjlyEpUJl2iZu/j15
|
|
||||||
YnMzGWHIEX8+eWRDsw/+Ujtko/B7TinGcWPz3cYl4EAOiCeDUyXnqnO1btCEUU44
|
|
||||||
DJ1BAoGBAJuPD27ErTSVtId90+M4zFPNibFP50KprVdc8CR37BE7r8vuGgNYXmnI
|
|
||||||
RLnGP9p3pVgFCktORuYS2J/6t84I3+A17nEoB4xvhTLeAinAW/uTQOUmNicOP4Ek
|
|
||||||
2MsLL2kHgL8bLTmvXV4FX+PXphrDKg1XxzOYn0otuoqdAQrkK4og
|
|
||||||
-----END RSA PRIVATE KEY-----
|
|
||||||
EOD;
|
|
||||||
|
|
||||||
$publicKey = <<<EOD
|
|
||||||
-----BEGIN PUBLIC KEY-----
|
|
||||||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuzWHNM5f+amCjQztc5QT
|
|
||||||
fJfzCC5J4nuW+L/aOxZ4f8J3FrewM2c/dufrnmedsApb0By7WhaHlcqCh/ScAPyJ
|
|
||||||
hzkPYLae7bTVro3hok0zDITR8F6SJGL42JAEUk+ILkPI+DONM0+3vzk6Kvfe548t
|
|
||||||
u4czCuqU8BGVOlnp6IqBHhAswNMM78pos/2z0CjPM4tbeXqSTTbNkXRboxjU29vS
|
|
||||||
opcT51koWOgiTf3C7nJUoMWZHZI5HqnIhPAG9yv8HAgNk6CMk2CadVHDo4IxjxTz
|
|
||||||
TTqo1SCSH2pooJl9O8at6kkRYsrZWwsKlOFE2LUce7ObnXsYihStBUDoeBQlGG/B
|
|
||||||
wQIDAQAB
|
|
||||||
-----END PUBLIC KEY-----
|
|
||||||
EOD;
|
|
||||||
|
|
||||||
$payload = [
|
|
||||||
'iss' => 'example.org',
|
|
||||||
'aud' => 'example.com',
|
|
||||||
'iat' => 1356999524,
|
|
||||||
'nbf' => 1357000000
|
|
||||||
];
|
|
||||||
|
|
||||||
$jwt = JWT::encode($payload, $privateKey, 'RS256');
|
|
||||||
echo "Encode:\n" . print_r($jwt, true) . "\n";
|
|
||||||
|
|
||||||
$decoded = JWT::decode($jwt, new Key($publicKey, 'RS256'));
|
|
||||||
|
|
||||||
/*
|
|
||||||
NOTE: This will now be an object instead of an associative array. To get
|
|
||||||
an associative array, you will need to cast it as such:
|
|
||||||
*/
|
|
||||||
|
|
||||||
$decoded_array = (array) $decoded;
|
|
||||||
echo "Decode:\n" . print_r($decoded_array, true) . "\n";
|
|
||||||
```
|
|
||||||
|
|
||||||
Example with a passphrase
|
|
||||||
-------------------------
|
|
||||||
|
|
||||||
```php
|
|
||||||
use Firebase\JWT\JWT;
|
|
||||||
use Firebase\JWT\Key;
|
|
||||||
|
|
||||||
// Your passphrase
|
|
||||||
$passphrase = '[YOUR_PASSPHRASE]';
|
|
||||||
|
|
||||||
// Your private key file with passphrase
|
|
||||||
// Can be generated with "ssh-keygen -t rsa -m pem"
|
|
||||||
$privateKeyFile = '/path/to/key-with-passphrase.pem';
|
|
||||||
|
|
||||||
// Create a private key of type "resource"
|
|
||||||
$privateKey = openssl_pkey_get_private(
|
|
||||||
file_get_contents($privateKeyFile),
|
|
||||||
$passphrase
|
|
||||||
);
|
|
||||||
|
|
||||||
$payload = [
|
|
||||||
'iss' => 'example.org',
|
|
||||||
'aud' => 'example.com',
|
|
||||||
'iat' => 1356999524,
|
|
||||||
'nbf' => 1357000000
|
|
||||||
];
|
|
||||||
|
|
||||||
$jwt = JWT::encode($payload, $privateKey, 'RS256');
|
|
||||||
echo "Encode:\n" . print_r($jwt, true) . "\n";
|
|
||||||
|
|
||||||
// Get public key from the private key, or pull from from a file.
|
|
||||||
$publicKey = openssl_pkey_get_details($privateKey)['key'];
|
|
||||||
|
|
||||||
$decoded = JWT::decode($jwt, new Key($publicKey, 'RS256'));
|
|
||||||
echo "Decode:\n" . print_r((array) $decoded, true) . "\n";
|
|
||||||
```
|
|
||||||
|
|
||||||
Example with EdDSA (libsodium and Ed25519 signature)
|
|
||||||
----------------------------
|
|
||||||
```php
|
|
||||||
use Firebase\JWT\JWT;
|
|
||||||
use Firebase\JWT\Key;
|
|
||||||
|
|
||||||
// Public and private keys are expected to be Base64 encoded. The last
|
|
||||||
// non-empty line is used so that keys can be generated with
|
|
||||||
// sodium_crypto_sign_keypair(). The secret keys generated by other tools may
|
|
||||||
// need to be adjusted to match the input expected by libsodium.
|
|
||||||
|
|
||||||
$keyPair = sodium_crypto_sign_keypair();
|
|
||||||
|
|
||||||
$privateKey = base64_encode(sodium_crypto_sign_secretkey($keyPair));
|
|
||||||
|
|
||||||
$publicKey = base64_encode(sodium_crypto_sign_publickey($keyPair));
|
|
||||||
|
|
||||||
$payload = [
|
|
||||||
'iss' => 'example.org',
|
|
||||||
'aud' => 'example.com',
|
|
||||||
'iat' => 1356999524,
|
|
||||||
'nbf' => 1357000000
|
|
||||||
];
|
|
||||||
|
|
||||||
$jwt = JWT::encode($payload, $privateKey, 'EdDSA');
|
|
||||||
echo "Encode:\n" . print_r($jwt, true) . "\n";
|
|
||||||
|
|
||||||
$decoded = JWT::decode($jwt, new Key($publicKey, 'EdDSA'));
|
|
||||||
echo "Decode:\n" . print_r((array) $decoded, true) . "\n";
|
|
||||||
````
|
|
||||||
|
|
||||||
Example with multiple keys
|
|
||||||
--------------------------
|
|
||||||
```php
|
|
||||||
use Firebase\JWT\JWT;
|
|
||||||
use Firebase\JWT\Key;
|
|
||||||
|
|
||||||
// Example RSA keys from previous example
|
|
||||||
// $privateKey1 = '...';
|
|
||||||
// $publicKey1 = '...';
|
|
||||||
|
|
||||||
// Example EdDSA keys from previous example
|
|
||||||
// $privateKey2 = '...';
|
|
||||||
// $publicKey2 = '...';
|
|
||||||
|
|
||||||
$payload = [
|
|
||||||
'iss' => 'example.org',
|
|
||||||
'aud' => 'example.com',
|
|
||||||
'iat' => 1356999524,
|
|
||||||
'nbf' => 1357000000
|
|
||||||
];
|
|
||||||
|
|
||||||
$jwt1 = JWT::encode($payload, $privateKey1, 'RS256', 'kid1');
|
|
||||||
$jwt2 = JWT::encode($payload, $privateKey2, 'EdDSA', 'kid2');
|
|
||||||
echo "Encode 1:\n" . print_r($jwt1, true) . "\n";
|
|
||||||
echo "Encode 2:\n" . print_r($jwt2, true) . "\n";
|
|
||||||
|
|
||||||
$keys = [
|
|
||||||
'kid1' => new Key($publicKey1, 'RS256'),
|
|
||||||
'kid2' => new Key($publicKey2, 'EdDSA'),
|
|
||||||
];
|
|
||||||
|
|
||||||
$decoded1 = JWT::decode($jwt1, $keys);
|
|
||||||
$decoded2 = JWT::decode($jwt2, $keys);
|
|
||||||
|
|
||||||
echo "Decode 1:\n" . print_r((array) $decoded1, true) . "\n";
|
|
||||||
echo "Decode 2:\n" . print_r((array) $decoded2, true) . "\n";
|
|
||||||
```
|
|
||||||
|
|
||||||
Using JWKs
|
|
||||||
----------
|
|
||||||
|
|
||||||
```php
|
|
||||||
use Firebase\JWT\JWK;
|
|
||||||
use Firebase\JWT\JWT;
|
|
||||||
|
|
||||||
// Set of keys. The "keys" key is required. For example, the JSON response to
|
|
||||||
// this endpoint: https://www.gstatic.com/iap/verify/public_key-jwk
|
|
||||||
$jwks = ['keys' => []];
|
|
||||||
|
|
||||||
// JWK::parseKeySet($jwks) returns an associative array of **kid** to Firebase\JWT\Key
|
|
||||||
// objects. Pass this as the second parameter to JWT::decode.
|
|
||||||
JWT::decode($jwt, JWK::parseKeySet($jwks));
|
|
||||||
```
|
|
||||||
|
|
||||||
Using Cached Key Sets
|
|
||||||
---------------------
|
|
||||||
|
|
||||||
The `CachedKeySet` class can be used to fetch and cache JWKS (JSON Web Key Sets) from a public URI.
|
|
||||||
This has the following advantages:
|
|
||||||
|
|
||||||
1. The results are cached for performance.
|
|
||||||
2. If an unrecognized key is requested, the cache is refreshed, to accomodate for key rotation.
|
|
||||||
3. If rate limiting is enabled, the JWKS URI will not make more than 10 requests a second.
|
|
||||||
|
|
||||||
```php
|
|
||||||
use Firebase\JWT\CachedKeySet;
|
|
||||||
use Firebase\JWT\JWT;
|
|
||||||
|
|
||||||
// The URI for the JWKS you wish to cache the results from
|
|
||||||
$jwksUri = 'https://www.gstatic.com/iap/verify/public_key-jwk';
|
|
||||||
|
|
||||||
// Create an HTTP client (can be any PSR-7 compatible HTTP client)
|
|
||||||
$httpClient = new GuzzleHttp\Client();
|
|
||||||
|
|
||||||
// Create an HTTP request factory (can be any PSR-17 compatible HTTP request factory)
|
|
||||||
$httpFactory = new GuzzleHttp\Psr\HttpFactory();
|
|
||||||
|
|
||||||
// Create a cache item pool (can be any PSR-6 compatible cache item pool)
|
|
||||||
$cacheItemPool = Phpfastcache\CacheManager::getInstance('files');
|
|
||||||
|
|
||||||
$keySet = new CachedKeySet(
|
|
||||||
$jwksUri,
|
|
||||||
$httpClient,
|
|
||||||
$httpFactory,
|
|
||||||
$cacheItemPool,
|
|
||||||
null, // $expiresAfter int seconds to set the JWKS to expire
|
|
||||||
true // $rateLimit true to enable rate limit of 10 RPS on lookup of invalid keys
|
|
||||||
);
|
|
||||||
|
|
||||||
$jwt = 'eyJhbGci...'; // Some JWT signed by a key from the $jwkUri above
|
|
||||||
$decoded = JWT::decode($jwt, $keySet);
|
|
||||||
```
|
|
||||||
|
|
||||||
Miscellaneous
|
|
||||||
-------------
|
|
||||||
|
|
||||||
#### Exception Handling
|
|
||||||
|
|
||||||
When a call to `JWT::decode` is invalid, it will throw one of the following exceptions:
|
|
||||||
|
|
||||||
```php
|
|
||||||
use Firebase\JWT\JWT;
|
|
||||||
use Firebase\JWT\SignatureInvalidException;
|
|
||||||
use Firebase\JWT\BeforeValidException;
|
|
||||||
use Firebase\JWT\ExpiredException;
|
|
||||||
use DomainException;
|
|
||||||
use InvalidArgumentException;
|
|
||||||
use UnexpectedValueException;
|
|
||||||
|
|
||||||
try {
|
|
||||||
$decoded = JWT::decode($jwt, $keys);
|
|
||||||
} catch (InvalidArgumentException $e) {
|
|
||||||
// provided key/key-array is empty or malformed.
|
|
||||||
} catch (DomainException $e) {
|
|
||||||
// provided algorithm is unsupported OR
|
|
||||||
// provided key is invalid OR
|
|
||||||
// unknown error thrown in openSSL or libsodium OR
|
|
||||||
// libsodium is required but not available.
|
|
||||||
} catch (SignatureInvalidException $e) {
|
|
||||||
// provided JWT signature verification failed.
|
|
||||||
} catch (BeforeValidException $e) {
|
|
||||||
// provided JWT is trying to be used before "nbf" claim OR
|
|
||||||
// provided JWT is trying to be used before "iat" claim.
|
|
||||||
} catch (ExpiredException $e) {
|
|
||||||
// provided JWT is trying to be used after "exp" claim.
|
|
||||||
} catch (UnexpectedValueException $e) {
|
|
||||||
// provided JWT is malformed OR
|
|
||||||
// provided JWT is missing an algorithm / using an unsupported algorithm OR
|
|
||||||
// provided JWT algorithm does not match provided key OR
|
|
||||||
// provided key ID in key/key-array is empty or invalid.
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
All exceptions in the `Firebase\JWT` namespace extend `UnexpectedValueException`, and can be simplified
|
|
||||||
like this:
|
|
||||||
|
|
||||||
```php
|
|
||||||
use Firebase\JWT\JWT;
|
|
||||||
use UnexpectedValueException;
|
|
||||||
try {
|
|
||||||
$decoded = JWT::decode($jwt, $keys);
|
|
||||||
} catch (LogicException $e) {
|
|
||||||
// errors having to do with environmental setup or malformed JWT Keys
|
|
||||||
} catch (UnexpectedValueException $e) {
|
|
||||||
// errors having to do with JWT signature and claims
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Casting to array
|
|
||||||
|
|
||||||
The return value of `JWT::decode` is the generic PHP object `stdClass`. If you'd like to handle with arrays
|
|
||||||
instead, you can do the following:
|
|
||||||
|
|
||||||
```php
|
|
||||||
// return type is stdClass
|
|
||||||
$decoded = JWT::decode($jwt, $keys);
|
|
||||||
|
|
||||||
// cast to array
|
|
||||||
$decoded = json_decode(json_encode($decoded), true);
|
|
||||||
```
|
|
||||||
|
|
||||||
Tests
|
|
||||||
-----
|
|
||||||
Run the tests using phpunit:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ pear install PHPUnit
|
|
||||||
$ phpunit --configuration phpunit.xml.dist
|
|
||||||
PHPUnit 3.7.10 by Sebastian Bergmann.
|
|
||||||
.....
|
|
||||||
Time: 0 seconds, Memory: 2.50Mb
|
|
||||||
OK (5 tests, 5 assertions)
|
|
||||||
```
|
|
||||||
|
|
||||||
New Lines in private keys
|
|
||||||
-----
|
|
||||||
|
|
||||||
If your private key contains `\n` characters, be sure to wrap it in double quotes `""`
|
|
||||||
and not single quotes `''` in order to properly interpret the escaped characters.
|
|
||||||
|
|
||||||
License
|
|
||||||
-------
|
|
||||||
[3-Clause BSD](http://opensource.org/licenses/BSD-3-Clause).
|
|
||||||
42
vendor/firebase/php-jwt/composer.json
vendored
42
vendor/firebase/php-jwt/composer.json
vendored
@@ -1,42 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "firebase/php-jwt",
|
|
||||||
"description": "A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.",
|
|
||||||
"homepage": "https://github.com/firebase/php-jwt",
|
|
||||||
"keywords": [
|
|
||||||
"php",
|
|
||||||
"jwt"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Neuman Vong",
|
|
||||||
"email": "neuman+pear@twilio.com",
|
|
||||||
"role": "Developer"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Anant Narayanan",
|
|
||||||
"email": "anant@php.net",
|
|
||||||
"role": "Developer"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"license": "BSD-3-Clause",
|
|
||||||
"require": {
|
|
||||||
"php": "^8.0"
|
|
||||||
},
|
|
||||||
"suggest": {
|
|
||||||
"paragonie/sodium_compat": "Support EdDSA (Ed25519) signatures when libsodium is not present",
|
|
||||||
"ext-sodium": "Support EdDSA (Ed25519) signatures"
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Firebase\\JWT\\": "src"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"guzzlehttp/guzzle": "^7.4",
|
|
||||||
"phpspec/prophecy-phpunit": "^2.0",
|
|
||||||
"phpunit/phpunit": "^9.5",
|
|
||||||
"psr/cache": "^2.0||^3.0",
|
|
||||||
"psr/http-client": "^1.0",
|
|
||||||
"psr/http-factory": "^1.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Firebase\JWT;
|
|
||||||
|
|
||||||
class BeforeValidException extends \UnexpectedValueException implements JWTExceptionWithPayloadInterface
|
|
||||||
{
|
|
||||||
private object $payload;
|
|
||||||
|
|
||||||
public function setPayload(object $payload): void
|
|
||||||
{
|
|
||||||
$this->payload = $payload;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getPayload(): object
|
|
||||||
{
|
|
||||||
return $this->payload;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user