From 8cb08c85bb93b4695bf5d22f0c3ee26d3f82559e Mon Sep 17 00:00:00 2001 From: hypax Date: Sat, 26 Apr 2025 20:48:54 +0200 Subject: [PATCH 01/48] test --- admin/login.php | 27 +- auth/callback.php | 39 +++ auth/discord.php | 20 ++ composer.json | 3 +- composer.lock | 663 +++++++++++++++++++++++++++++++++++++++++++++- 5 files changed, 734 insertions(+), 18 deletions(-) create mode 100644 auth/callback.php create mode 100644 auth/discord.php diff --git a/admin/login.php b/admin/login.php index afd9a23a..5aace0eb 100644 --- a/admin/login.php +++ b/admin/login.php @@ -50,24 +50,19 @@ $result = $statement->execute(array('username' => $username)); $user = $statement->fetch(); - if ($user !== false && password_verify($passwort, $user['passwort'])) { - $_SESSION['userid'] = $user['id']; - $_SESSION['cirs_user'] = $user['fullname']; - $_SESSION['cirs_username'] = $user['username']; - $_SESSION['aktenid'] = $user['aktenid']; - $permissions = json_decode($user['permissions'], true) ?? []; - $_SESSION['permissions'] = $permissions; - - if (isset($_SESSION['redirect_url'])) { - $redirect_url = $_SESSION['redirect_url']; - unset($_SESSION['redirect_url']); // Remove the stored URL - header("Location: $redirect_url"); - exit(); - } else { + if (isset($_SESSION['userid'])) { + $stmt = $pdo->prepare("SELECT * FROM intra_users WHERE discord_id = :discord_id"); + $stmt->execute(['discord_id' => $_SESSION['userid']]); + $user = $stmt->fetch(); + + if ($user) { + $_SESSION['userid'] = $user['id']; + $_SESSION['username'] = $user['username']; header('Location: /admin/index.php'); + exit; + } else { + echo "User not found."; } - } else { - $errorMessage = "Benutzername oder Passwort ungültig.
"; } } ?> diff --git a/auth/callback.php b/auth/callback.php new file mode 100644 index 00000000..9d18dbc3 --- /dev/null +++ b/auth/callback.php @@ -0,0 +1,39 @@ + 'YOUR_CLIENT_ID', + 'clientSecret' => 'YOUR_CLIENT_SECRET', + 'redirectUri' => 'https://yourdomain.com/auth/discord/callback', + 'urlAuthorize' => 'https://discord.com/api/oauth2/authorize', + 'urlAccessToken' => 'https://discord.com/api/oauth2/token', + 'urlResourceOwnerDetails' => 'https://discord.com/api/users/@me', +]); + +if (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) { + unset($_SESSION['oauth2state']); + exit('Invalid state'); +} + +try { + $accessToken = $provider->getAccessToken('authorization_code', [ + 'code' => $_GET['code'] + ]); + + $resourceOwner = $provider->getResourceOwner($accessToken); + $discordUser = $resourceOwner->toArray(); + + // Example: Save user to the database or start a session + $_SESSION['userid'] = $discordUser['id']; + $_SESSION['username'] = $discordUser['username']; + $_SESSION['avatar'] = $discordUser['avatar']; + + header('Location: /admin/index.php'); + exit; +} catch (Exception $e) { + exit('Failed to get access token: ' . $e->getMessage()); +} diff --git a/auth/discord.php b/auth/discord.php new file mode 100644 index 00000000..ed23ae98 --- /dev/null +++ b/auth/discord.php @@ -0,0 +1,20 @@ + '1365759297841004564', + 'clientSecret' => 'KFQ_tB_Jq7m4Q5b_s0LeOJ1UTmTA5EF6', + 'redirectUri' => 'https://dev.intrarp.de/auth/discord/callback', + 'urlAuthorize' => 'https://discord.com/api/oauth2/authorize', + 'urlAccessToken' => 'https://discord.com/api/oauth2/token', + 'urlResourceOwnerDetails' => 'https://discord.com/api/users/@me', +]); + +$authorizationUrl = $provider->getAuthorizationUrl(); +session_start(); +$_SESSION['oauth2state'] = $provider->getState(); + +header('Location: ' . $authorizationUrl); +exit; diff --git a/composer.json b/composer.json index 3238e90b..c45caee0 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,8 @@ "enyo/dropzone": "^5.9", "components/jquery": "^3.7", "datatables.net/datatables.net-bs5": "^2.2", - "twbs/bootstrap": "^5.3" + "twbs/bootstrap": "^5.3", + "league/oauth2-client": "^2.8" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index 072837bf..489625f4 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e1b45304e3ad1304989a9abee523577f", + "content-hash": "47a152e3814c82cf58aa9047541c7b68", "packages": [ { "name": "components/jquery", @@ -243,6 +243,396 @@ ], "time": "2024-07-20T21:45:45+00:00" }, + { + "name": "guzzlehttp/guzzle", + "version": "7.9.3", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle.git", + "reference": "7b2f29fe81dc4da0ca0ea7d42107a0845946ea77" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/7b2f29fe81dc4da0ca0ea7d42107a0845946ea77", + "reference": "7b2f29fe81dc4da0ca0ea7d42107a0845946ea77", + "shasum": "" + }, + "require": { + "ext-json": "*", + "guzzlehttp/promises": "^1.5.3 || ^2.0.3", + "guzzlehttp/psr7": "^2.7.0", + "php": "^7.2.5 || ^8.0", + "psr/http-client": "^1.0", + "symfony/deprecation-contracts": "^2.2 || ^3.0" + }, + "provide": { + "psr/http-client-implementation": "1.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "ext-curl": "*", + "guzzle/client-integration-tests": "3.0.2", + "php-http/message-factory": "^1.1", + "phpunit/phpunit": "^8.5.39 || ^9.6.20", + "psr/log": "^1.1 || ^2.0 || ^3.0" + }, + "suggest": { + "ext-curl": "Required for CURL handler support", + "ext-intl": "Required for Internationalized Domain Name (IDN) support", + "psr/log": "Required for using the Log middleware" + }, + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "GuzzleHttp\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Jeremy Lindblom", + "email": "jeremeamia@gmail.com", + "homepage": "https://github.com/jeremeamia" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + } + ], + "description": "Guzzle is a PHP HTTP client library", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "psr-18", + "psr-7", + "rest", + "web service" + ], + "support": { + "issues": "https://github.com/guzzle/guzzle/issues", + "source": "https://github.com/guzzle/guzzle/tree/7.9.3" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle", + "type": "tidelift" + } + ], + "time": "2025-03-27T13:37:11+00:00" + }, + { + "name": "guzzlehttp/promises", + "version": "2.2.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/promises.git", + "reference": "7c69f28996b0a6920945dd20b3857e499d9ca96c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/promises/zipball/7c69f28996b0a6920945dd20b3857e499d9ca96c", + "reference": "7c69f28996b0a6920945dd20b3857e499d9ca96c", + "shasum": "" + }, + "require": { + "php": "^7.2.5 || ^8.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "phpunit/phpunit": "^8.5.39 || ^9.6.20" + }, + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Promise\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + } + ], + "description": "Guzzle promises library", + "keywords": [ + "promise" + ], + "support": { + "issues": "https://github.com/guzzle/promises/issues", + "source": "https://github.com/guzzle/promises/tree/2.2.0" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/promises", + "type": "tidelift" + } + ], + "time": "2025-03-27T13:27:01+00:00" + }, + { + "name": "guzzlehttp/psr7", + "version": "2.7.1", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "c2270caaabe631b3b44c85f99e5a04bbb8060d16" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/c2270caaabe631b3b44c85f99e5a04bbb8060d16", + "reference": "c2270caaabe631b3b44c85f99e5a04bbb8060d16", + "shasum": "" + }, + "require": { + "php": "^7.2.5 || ^8.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.1 || ^2.0", + "ralouphie/getallheaders": "^3.0" + }, + "provide": { + "psr/http-factory-implementation": "1.0", + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "http-interop/http-factory-tests": "0.9.0", + "phpunit/phpunit": "^8.5.39 || ^9.6.20" + }, + "suggest": { + "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" + }, + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" + } + ], + "description": "PSR-7 message implementation that also provides common utility methods", + "keywords": [ + "http", + "message", + "psr-7", + "request", + "response", + "stream", + "uri", + "url" + ], + "support": { + "issues": "https://github.com/guzzle/psr7/issues", + "source": "https://github.com/guzzle/psr7/tree/2.7.1" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7", + "type": "tidelift" + } + ], + "time": "2025-03-27T12:30:47+00:00" + }, + { + "name": "league/oauth2-client", + "version": "2.8.1", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/oauth2-client.git", + "reference": "9df2924ca644736c835fc60466a3a60390d334f9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/oauth2-client/zipball/9df2924ca644736c835fc60466a3a60390d334f9", + "reference": "9df2924ca644736c835fc60466a3a60390d334f9", + "shasum": "" + }, + "require": { + "ext-json": "*", + "guzzlehttp/guzzle": "^6.5.8 || ^7.4.5", + "php": "^7.1 || >=8.0.0 <8.5.0" + }, + "require-dev": { + "mockery/mockery": "^1.3.5", + "php-parallel-lint/php-parallel-lint": "^1.4", + "phpunit/phpunit": "^7 || ^8 || ^9 || ^10 || ^11", + "squizlabs/php_codesniffer": "^3.11" + }, + "type": "library", + "autoload": { + "psr-4": { + "League\\OAuth2\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Alex Bilbie", + "email": "hello@alexbilbie.com", + "homepage": "http://www.alexbilbie.com", + "role": "Developer" + }, + { + "name": "Woody Gilk", + "homepage": "https://github.com/shadowhand", + "role": "Contributor" + } + ], + "description": "OAuth 2.0 Client Library", + "keywords": [ + "Authentication", + "SSO", + "authorization", + "identity", + "idp", + "oauth", + "oauth2", + "single sign on" + ], + "support": { + "issues": "https://github.com/thephpleague/oauth2-client/issues", + "source": "https://github.com/thephpleague/oauth2-client/tree/2.8.1" + }, + "time": "2025-02-26T04:37:30+00:00" + }, { "name": "phpoption/phpoption", "version": "1.9.3", @@ -318,6 +708,277 @@ ], "time": "2024-07-20T21:41:07+00:00" }, + { + "name": "psr/http-client", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-client.git", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90", + "shasum": "" + }, + "require": { + "php": "^7.0 || ^8.0", + "psr/http-message": "^1.0 || ^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP clients", + "homepage": "https://github.com/php-fig/http-client", + "keywords": [ + "http", + "http-client", + "psr", + "psr-18" + ], + "support": { + "source": "https://github.com/php-fig/http-client" + }, + "time": "2023-09-23T14:17:50+00:00" + }, + { + "name": "psr/http-factory", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-factory.git", + "reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-factory/zipball/2b4765fddfe3b508ac62f829e852b1501d3f6e8a", + "reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a", + "shasum": "" + }, + "require": { + "php": ">=7.1", + "psr/http-message": "^1.0 || ^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "PSR-17: Common interfaces for PSR-7 HTTP message factories", + "keywords": [ + "factory", + "http", + "message", + "psr", + "psr-17", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-factory" + }, + "time": "2024-04-15T12:06:14+00:00" + }, + { + "name": "psr/http-message", + "version": "2.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71", + "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-message/tree/2.0" + }, + "time": "2023-04-04T09:54:51+00:00" + }, + { + "name": "ralouphie/getallheaders", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/ralouphie/getallheaders.git", + "reference": "120b605dfeb996808c31b6477290a714d356e822" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", + "reference": "120b605dfeb996808c31b6477290a714d356e822", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.1", + "phpunit/phpunit": "^5 || ^6.5" + }, + "type": "library", + "autoload": { + "files": [ + "src/getallheaders.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ralph Khattar", + "email": "ralph.khattar@gmail.com" + } + ], + "description": "A polyfill for getallheaders.", + "support": { + "issues": "https://github.com/ralouphie/getallheaders/issues", + "source": "https://github.com/ralouphie/getallheaders/tree/develop" + }, + "time": "2019-03-08T08:55:37+00:00" + }, + { + "name": "symfony/deprecation-contracts", + "version": "v3.5.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6", + "reference": "74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, + "branch-alias": { + "dev-main": "3.5-dev" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.1" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-09-25T14:20:29+00:00" + }, { "name": "symfony/polyfill-ctype", "version": "v1.31.0", From 556ff5593196536fe6123efeb71a10869c51a824 Mon Sep 17 00:00:00 2001 From: hypax Date: Sat, 26 Apr 2025 20:52:35 +0200 Subject: [PATCH 02/48] Update discord.php --- auth/discord.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/auth/discord.php b/auth/discord.php index ed23ae98..567454b1 100644 --- a/auth/discord.php +++ b/auth/discord.php @@ -12,7 +12,11 @@ 'urlResourceOwnerDetails' => 'https://discord.com/api/users/@me', ]); -$authorizationUrl = $provider->getAuthorizationUrl(); +// Add the required scopes (e.g., 'identify' to get basic user info) +$authorizationUrl = $provider->getAuthorizationUrl([ + 'scope' => ['identify'] // Add other scopes if needed, e.g., 'email', 'guilds' +]); + session_start(); $_SESSION['oauth2state'] = $provider->getState(); From 4302f32d3167a4e146e8f6b1422e1acf3ecc1aa0 Mon Sep 17 00:00:00 2001 From: hypax Date: Sat, 26 Apr 2025 20:53:05 +0200 Subject: [PATCH 03/48] Update discord.php --- auth/discord.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auth/discord.php b/auth/discord.php index 567454b1..4521a0f7 100644 --- a/auth/discord.php +++ b/auth/discord.php @@ -6,7 +6,7 @@ $provider = new GenericProvider([ 'clientId' => '1365759297841004564', 'clientSecret' => 'KFQ_tB_Jq7m4Q5b_s0LeOJ1UTmTA5EF6', - 'redirectUri' => 'https://dev.intrarp.de/auth/discord/callback', + 'redirectUri' => 'https://dev.intrarp.de/auth/callback', 'urlAuthorize' => 'https://discord.com/api/oauth2/authorize', 'urlAccessToken' => 'https://discord.com/api/oauth2/token', 'urlResourceOwnerDetails' => 'https://discord.com/api/users/@me', From 4a809892733cce76e4b15204e4d5885d8c6a6520 Mon Sep 17 00:00:00 2001 From: hypax Date: Sat, 26 Apr 2025 20:54:51 +0200 Subject: [PATCH 04/48] Update callback.php --- auth/callback.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/auth/callback.php b/auth/callback.php index 9d18dbc3..6d3e422b 100644 --- a/auth/callback.php +++ b/auth/callback.php @@ -3,12 +3,16 @@ use League\OAuth2\Client\Provider\GenericProvider; +ini_set('display_errors', 1); +ini_set('display_startup_errors', 1); +error_reporting(E_ALL); + session_start(); $provider = new GenericProvider([ - 'clientId' => 'YOUR_CLIENT_ID', - 'clientSecret' => 'YOUR_CLIENT_SECRET', - 'redirectUri' => 'https://yourdomain.com/auth/discord/callback', + 'clientId' => '1365759297841004564', + 'clientSecret' => 'KFQ_tB_Jq7m4Q5b_s0LeOJ1UTmTA5EF6', + 'redirectUri' => 'https://dev.intrarp.de/auth/callback', 'urlAuthorize' => 'https://discord.com/api/oauth2/authorize', 'urlAccessToken' => 'https://discord.com/api/oauth2/token', 'urlResourceOwnerDetails' => 'https://discord.com/api/users/@me', @@ -19,11 +23,16 @@ exit('Invalid state'); } +if (!isset($_GET['code'])) { + exit('Authorization code not provided.'); +} + try { $accessToken = $provider->getAccessToken('authorization_code', [ 'code' => $_GET['code'] ]); + echo 'Access Token: ' . $accessToken->getToken(); // Debugging $resourceOwner = $provider->getResourceOwner($accessToken); $discordUser = $resourceOwner->toArray(); @@ -35,5 +44,6 @@ header('Location: /admin/index.php'); exit; } catch (Exception $e) { - exit('Failed to get access token: ' . $e->getMessage()); + echo 'Failed to get access token: ' . $e->getMessage(); + exit; } From 5f0750b3e8e59e427f37ccfcc45b8bcfb60c0e02 Mon Sep 17 00:00:00 2001 From: hypax Date: Sat, 26 Apr 2025 20:59:05 +0200 Subject: [PATCH 05/48] Update callback.php --- auth/callback.php | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/auth/callback.php b/auth/callback.php index 6d3e422b..a8d8081f 100644 --- a/auth/callback.php +++ b/auth/callback.php @@ -1,5 +1,7 @@ $_GET['code'] ]); - echo 'Access Token: ' . $accessToken->getToken(); // Debugging $resourceOwner = $provider->getResourceOwner($accessToken); $discordUser = $resourceOwner->toArray(); - // Example: Save user to the database or start a session + // Save user to the database or start a session $_SESSION['userid'] = $discordUser['id']; $_SESSION['username'] = $discordUser['username']; $_SESSION['avatar'] = $discordUser['avatar']; + // Check if the Discord ID already exists in the database + $stmt = $pdo->prepare("SELECT * FROM intra_users WHERE discord_id = :discord_id"); + $stmt->execute(['discord_id' => $_SESSION['userid']]); + $user = $stmt->fetch(); + + if ($user) { + // Discord ID exists, log the user in + $_SESSION['userid'] = $user['id']; + $_SESSION['permissions'] = $user['permissions']; // Assuming permissions are stored in the database + } else { + // Discord ID does not exist, handle linking or creating a new user + // Example: Redirect to a page to link Discord to an existing account + header('Location: /auth/link_account.php'); + exit; + } + header('Location: /admin/index.php'); exit; } catch (Exception $e) { From afb2e8c7a040decd4b62b4cf7c518fbab95addfc Mon Sep 17 00:00:00 2001 From: hypax Date: Sat, 26 Apr 2025 21:00:10 +0200 Subject: [PATCH 06/48] Update callback.php --- auth/callback.php | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/auth/callback.php b/auth/callback.php index a8d8081f..1362edfd 100644 --- a/auth/callback.php +++ b/auth/callback.php @@ -52,10 +52,25 @@ $_SESSION['userid'] = $user['id']; $_SESSION['permissions'] = $user['permissions']; // Assuming permissions are stored in the database } else { - // Discord ID does not exist, handle linking or creating a new user - // Example: Redirect to a page to link Discord to an existing account - header('Location: /auth/link_account.php'); - exit; + // Discord ID does not exist, create a new user + $insertStmt = $pdo->prepare(" + INSERT INTO intra_users (discord_id, username, avatar, permissions) + VALUES (:discord_id, :username, :avatar, :permissions) + "); + $insertStmt->execute([ + 'discord_id' => $_SESSION['userid'], + 'username' => $_SESSION['username'], + 'avatar' => $_SESSION['avatar'], + 'permissions' => 'user' // Default permissions for new users + ]); + + // Fetch the newly created user to set session variables + $stmt = $pdo->prepare("SELECT * FROM intra_users WHERE discord_id = :discord_id"); + $stmt->execute(['discord_id' => $_SESSION['userid']]); + $user = $stmt->fetch(); + + $_SESSION['userid'] = $user['id']; + $_SESSION['permissions'] = $user['permissions']; } header('Location: /admin/index.php'); From 4f271b5c2e32e0c5acc4959167d4141e27b51c58 Mon Sep 17 00:00:00 2001 From: hypax Date: Sat, 26 Apr 2025 21:03:55 +0200 Subject: [PATCH 07/48] Update callback.php --- auth/callback.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/auth/callback.php b/auth/callback.php index 1362edfd..4a0e1e57 100644 --- a/auth/callback.php +++ b/auth/callback.php @@ -54,13 +54,13 @@ } else { // Discord ID does not exist, create a new user $insertStmt = $pdo->prepare(" - INSERT INTO intra_users (discord_id, username, avatar, permissions) - VALUES (:discord_id, :username, :avatar, :permissions) + INSERT INTO intra_users (discord_id, username, fullname, role, permissions) + VALUES (:discord_id, :username, NULL, :role, :permissions) "); $insertStmt->execute([ 'discord_id' => $_SESSION['userid'], 'username' => $_SESSION['username'], - 'avatar' => $_SESSION['avatar'], + 'role' => 7, // Default role for new users 'permissions' => 'user' // Default permissions for new users ]); From b449fcddf59b50dc114b9697e1368d410eff373b Mon Sep 17 00:00:00 2001 From: hypax Date: Sat, 26 Apr 2025 21:05:15 +0200 Subject: [PATCH 08/48] Update callback.php --- auth/callback.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/auth/callback.php b/auth/callback.php index 4a0e1e57..62b85a9f 100644 --- a/auth/callback.php +++ b/auth/callback.php @@ -50,18 +50,16 @@ if ($user) { // Discord ID exists, log the user in $_SESSION['userid'] = $user['id']; - $_SESSION['permissions'] = $user['permissions']; // Assuming permissions are stored in the database } else { // Discord ID does not exist, create a new user $insertStmt = $pdo->prepare(" - INSERT INTO intra_users (discord_id, username, fullname, role, permissions) - VALUES (:discord_id, :username, NULL, :role, :permissions) + INSERT INTO intra_users (discord_id, username, fullname, role) + VALUES (:discord_id, :username, NULL, :role) "); $insertStmt->execute([ 'discord_id' => $_SESSION['userid'], 'username' => $_SESSION['username'], - 'role' => 7, // Default role for new users - 'permissions' => 'user' // Default permissions for new users + 'role' => 7 // Default role for new users ]); // Fetch the newly created user to set session variables @@ -70,7 +68,6 @@ $user = $stmt->fetch(); $_SESSION['userid'] = $user['id']; - $_SESSION['permissions'] = $user['permissions']; } header('Location: /admin/index.php'); From 6eb392ec184f247e95a557cfe18c00459dde4ef7 Mon Sep 17 00:00:00 2001 From: hypax Date: Sat, 26 Apr 2025 21:09:02 +0200 Subject: [PATCH 09/48] Update callback.php --- auth/callback.php | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/auth/callback.php b/auth/callback.php index 62b85a9f..ab789fd9 100644 --- a/auth/callback.php +++ b/auth/callback.php @@ -38,39 +38,49 @@ $discordUser = $resourceOwner->toArray(); // Save user to the database or start a session - $_SESSION['userid'] = $discordUser['id']; - $_SESSION['username'] = $discordUser['username']; - $_SESSION['avatar'] = $discordUser['avatar']; + $discordId = $discordUser['id']; + $username = $discordUser['username']; + $avatar = $discordUser['avatar']; // Check if the Discord ID already exists in the database $stmt = $pdo->prepare("SELECT * FROM intra_users WHERE discord_id = :discord_id"); - $stmt->execute(['discord_id' => $_SESSION['userid']]); + $stmt->execute(['discord_id' => $discordId]); $user = $stmt->fetch(); if ($user) { // Discord ID exists, log the user in $_SESSION['userid'] = $user['id']; + $_SESSION['username'] = $user['username']; + $_SESSION['role'] = $user['role']; + $_SESSION['full_admin'] = $user['full_admin']; } else { // Discord ID does not exist, create a new user $insertStmt = $pdo->prepare(" - INSERT INTO intra_users (discord_id, username, fullname, role) - VALUES (:discord_id, :username, NULL, :role) + INSERT INTO intra_users (discord_id, username, fullname, role, full_admin) + VALUES (:discord_id, :username, NULL, :role, :full_admin) "); $insertStmt->execute([ - 'discord_id' => $_SESSION['userid'], - 'username' => $_SESSION['username'], - 'role' => 7 // Default role for new users + 'discord_id' => $discordId, + 'username' => $username, + 'role' => 7, // Default role for new users + 'full_admin' => 0 // Default full_admin value ]); // Fetch the newly created user to set session variables $stmt = $pdo->prepare("SELECT * FROM intra_users WHERE discord_id = :discord_id"); - $stmt->execute(['discord_id' => $_SESSION['userid']]); + $stmt->execute(['discord_id' => $discordId]); $user = $stmt->fetch(); $_SESSION['userid'] = $user['id']; + $_SESSION['username'] = $user['username']; + $_SESSION['role'] = $user['role']; + $_SESSION['full_admin'] = $user['full_admin']; } - header('Location: /admin/index.php'); + // Redirect to the admin dashboard or the originally requested page + $redirectUrl = $_SESSION['redirect_url'] ?? '/admin/index.php'; + unset($_SESSION['redirect_url']); + header("Location: $redirectUrl"); exit; } catch (Exception $e) { echo 'Failed to get access token: ' . $e->getMessage(); From 89efb8f11c08fe23cbd9e20d0dcaa4236551dc76 Mon Sep 17 00:00:00 2001 From: hypax Date: Sat, 26 Apr 2025 21:11:45 +0200 Subject: [PATCH 10/48] Update callback.php --- auth/callback.php | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/auth/callback.php b/auth/callback.php index ab789fd9..3d861dfa 100644 --- a/auth/callback.php +++ b/auth/callback.php @@ -42,6 +42,24 @@ $username = $discordUser['username']; $avatar = $discordUser['avatar']; + // Check if any users exist in the database + $checkStmt = $pdo->query("SELECT COUNT(*) FROM intra_users"); + $userCount = $checkStmt->fetchColumn(); + + if ($userCount == 0) { + // No users exist, create the first admin user + $stmt = $pdo->prepare(" + INSERT INTO intra_users (discord_id, username, fullname, passwort, role, full_admin) + VALUES (:discord_id, :username, NULL, NULL, :role, :full_admin) + "); + $stmt->execute([ + 'discord_id' => $discordId, + 'username' => $username, + 'role' => 0, // Admin role + 'full_admin' => 1 // Full admin privileges + ]); + } + // Check if the Discord ID already exists in the database $stmt = $pdo->prepare("SELECT * FROM intra_users WHERE discord_id = :discord_id"); $stmt->execute(['discord_id' => $discordId]); @@ -50,7 +68,9 @@ if ($user) { // Discord ID exists, log the user in $_SESSION['userid'] = $user['id']; - $_SESSION['username'] = $user['username']; + $_SESSION['cirs_user'] = $user['fullname']; + $_SESSION['cirs_username'] = $user['username']; + $_SESSION['aktenid'] = $user['aktenid']; $_SESSION['role'] = $user['role']; $_SESSION['full_admin'] = $user['full_admin']; } else { @@ -72,7 +92,9 @@ $user = $stmt->fetch(); $_SESSION['userid'] = $user['id']; - $_SESSION['username'] = $user['username']; + $_SESSION['cirs_user'] = $user['fullname']; + $_SESSION['cirs_username'] = $user['username']; + $_SESSION['aktenid'] = $user['aktenid']; $_SESSION['role'] = $user['role']; $_SESSION['full_admin'] = $user['full_admin']; } From 87acf70f64be43557842c74c035f41077c0ec1bd Mon Sep 17 00:00:00 2001 From: hypax Date: Sat, 26 Apr 2025 21:13:25 +0200 Subject: [PATCH 11/48] Update callback.php --- auth/callback.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/auth/callback.php b/auth/callback.php index 3d861dfa..24c2350c 100644 --- a/auth/callback.php +++ b/auth/callback.php @@ -102,6 +102,9 @@ // Redirect to the admin dashboard or the originally requested page $redirectUrl = $_SESSION['redirect_url'] ?? '/admin/index.php'; unset($_SESSION['redirect_url']); + // Debugging: Check if session variables are set + var_dump($_SESSION); + exit; header("Location: $redirectUrl"); exit; } catch (Exception $e) { From 91ff1fc02b4ace0a2865c5f3af96ffa285f068cd Mon Sep 17 00:00:00 2001 From: hypax Date: Sat, 26 Apr 2025 21:17:51 +0200 Subject: [PATCH 12/48] Added env var --- .env.example | 5 ++++- auth/callback.php | 24 +++++++++++++++++++----- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/.env.example b/.env.example index 3bf3d26b..e5f3a79c 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,7 @@ DB_HOST=localhost DB_USER=root DB_PASS= -DB_NAME=intrarp \ No newline at end of file +DB_NAME=intrarp + +DISCORD_CLIENT_ID= +DISCORD_CLIENT_SECRET= \ No newline at end of file diff --git a/auth/callback.php b/auth/callback.php index 24c2350c..10b757b9 100644 --- a/auth/callback.php +++ b/auth/callback.php @@ -12,8 +12,8 @@ session_start(); $provider = new GenericProvider([ - 'clientId' => '1365759297841004564', - 'clientSecret' => 'KFQ_tB_Jq7m4Q5b_s0LeOJ1UTmTA5EF6', + 'clientId' => $_ENV['DISCORD_CLIENT_ID'], + 'clientSecret' => $_ENV['DISCORD_CLIENT_SECRET'], 'redirectUri' => 'https://dev.intrarp.de/auth/callback', 'urlAuthorize' => 'https://discord.com/api/oauth2/authorize', 'urlAccessToken' => 'https://discord.com/api/oauth2/token', @@ -73,6 +73,22 @@ $_SESSION['aktenid'] = $user['aktenid']; $_SESSION['role'] = $user['role']; $_SESSION['full_admin'] = $user['full_admin']; + + // Set permissions based on the user's role + if ($user['full_admin'] == 1) { + $_SESSION['permissions'] = ['full_admin']; // Full admin permissions + } else { + // Retrieve permissions for the user's role + $roleStmt = $pdo->prepare("SELECT permissions FROM intra_users_roles WHERE id = :role_id"); + $roleStmt->execute(['role_id' => $user['role']]); + $role = $roleStmt->fetch(); + + if ($role && isset($role['permissions'])) { + $_SESSION['permissions'] = json_decode($role['permissions'], true) ?? []; + } else { + $_SESSION['permissions'] = []; // Default to no permissions + } + } } else { // Discord ID does not exist, create a new user $insertStmt = $pdo->prepare(" @@ -97,14 +113,12 @@ $_SESSION['aktenid'] = $user['aktenid']; $_SESSION['role'] = $user['role']; $_SESSION['full_admin'] = $user['full_admin']; + $_SESSION['permissions'] = []; // Default to no permissions for new users } // Redirect to the admin dashboard or the originally requested page $redirectUrl = $_SESSION['redirect_url'] ?? '/admin/index.php'; unset($_SESSION['redirect_url']); - // Debugging: Check if session variables are set - var_dump($_SESSION); - exit; header("Location: $redirectUrl"); exit; } catch (Exception $e) { From 1b9bc359859af02fff716b5f0f8c5ed2a3a5f189 Mon Sep 17 00:00:00 2001 From: hypax Date: Sat, 26 Apr 2025 21:20:26 +0200 Subject: [PATCH 13/48] Update login.php --- admin/login.php | 93 ++----------------------------------------------- 1 file changed, 3 insertions(+), 90 deletions(-) diff --git a/admin/login.php b/admin/login.php index 5aace0eb..9a7834db 100644 --- a/admin/login.php +++ b/admin/login.php @@ -1,7 +1,4 @@ query("SELECT COUNT(*) FROM intra_users"); -$userCount = $checkStmt->fetchColumn(); - -if ($userCount == 0 && $_SERVER['REQUEST_METHOD'] === 'POST') { - $username = trim($_POST['username']); - $fullname = trim($_POST['fullname']); - $passwort = $_POST['passwort']; - $passwortConfirm = $_POST['passwort_confirm']; - - if ($passwort !== $passwortConfirm) { - $errorMessage = "Passwörter stimmen nicht überein."; - } else { - $hashedPassword = password_hash($passwort, PASSWORD_BCRYPT); - - $stmt = $pdo->prepare("INSERT INTO intra_users (username, fullname, passwort, role, full_admin) VALUES (:username, :fullname, :passwort, :role, :full_admin)"); - $stmt->execute([ - 'username' => $username, - 'fullname' => $fullname, - 'passwort' => $hashedPassword, - 'role' => 0, - 'full_admin' => 1 - ]); - - header("Refresh: 0"); - exit(); - } -} - -if (isset($_GET['login'])) { - $username = $_POST['username']; - $passwort = $_POST['passwort']; - - $statement = $pdo->prepare("SELECT * FROM intra_users WHERE username = :username"); - $result = $statement->execute(array('username' => $username)); - $user = $statement->fetch(); - - if (isset($_SESSION['userid'])) { - $stmt = $pdo->prepare("SELECT * FROM intra_users WHERE discord_id = :discord_id"); - $stmt->execute(['discord_id' => $_SESSION['userid']]); - $user = $stmt->fetch(); - - if ($user) { - $_SESSION['userid'] = $user['id']; - $_SESSION['username'] = $user['username']; - header('Location: /admin/index.php'); - exit; - } else { - echo "User not found."; - } - } -} ?> @@ -104,42 +49,10 @@

Das Intranet der Stadt !

- '; - echo $errorMessage; - echo '
'; - } - ?> - - -
Kein Benutzer gefunden. Du erstellst jetzt den ersten Administrator-Account.
-
- Benutzername:
-

- - Vor- und Zuname (RP):
-

- - Passwort:
-
- - Passwort wiederholen:
-
- - -
- -
- Benutzername:
-

- - Passwort:
-
- -
- + From 6b17a96d618f8bc5e7d6b6cb8d03970d4dba9127 Mon Sep 17 00:00:00 2001 From: hypax Date: Sat, 26 Apr 2025 21:21:05 +0200 Subject: [PATCH 14/48] Update login.php --- admin/login.php | 1 + 1 file changed, 1 insertion(+) diff --git a/admin/login.php b/admin/login.php index 9a7834db..dff779d8 100644 --- a/admin/login.php +++ b/admin/login.php @@ -1,4 +1,5 @@ Date: Sat, 26 Apr 2025 21:23:40 +0200 Subject: [PATCH 15/48] Update callback.php --- auth/callback.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/auth/callback.php b/auth/callback.php index 10b757b9..5f3ecc4a 100644 --- a/auth/callback.php +++ b/auth/callback.php @@ -49,8 +49,8 @@ if ($userCount == 0) { // No users exist, create the first admin user $stmt = $pdo->prepare(" - INSERT INTO intra_users (discord_id, username, fullname, passwort, role, full_admin) - VALUES (:discord_id, :username, NULL, NULL, :role, :full_admin) + INSERT INTO intra_users (discord_id, username, fullname, role, full_admin) + VALUES (:discord_id, :username, NULL, :role, :full_admin) "); $stmt->execute([ 'discord_id' => $discordId, From 5cea4ca2a64bec64f3db5f21412f4a2fca663745 Mon Sep 17 00:00:00 2001 From: hypax Date: Sat, 26 Apr 2025 21:24:12 +0200 Subject: [PATCH 16/48] Update callback.php --- auth/callback.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auth/callback.php b/auth/callback.php index 5f3ecc4a..81a5c624 100644 --- a/auth/callback.php +++ b/auth/callback.php @@ -55,7 +55,7 @@ $stmt->execute([ 'discord_id' => $discordId, 'username' => $username, - 'role' => 0, // Admin role + 'role' => 3, // Admin role 'full_admin' => 1 // Full admin privileges ]); } From 198e3736cb8a63c4a9cda80a4dd33d8da9f5f9fc Mon Sep 17 00:00:00 2001 From: hypax Date: Sat, 26 Apr 2025 21:28:01 +0200 Subject: [PATCH 17/48] Update callback.php --- auth/callback.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/auth/callback.php b/auth/callback.php index 81a5c624..aa394f7b 100644 --- a/auth/callback.php +++ b/auth/callback.php @@ -42,6 +42,24 @@ $username = $discordUser['username']; $avatar = $discordUser['avatar']; + // Fetch the role for the first admin user (admin = 1) + $adminRoleStmt = $pdo->prepare("SELECT id FROM intra_users_roles WHERE admin = 1 LIMIT 1"); + $adminRoleStmt->execute(); + $adminRole = $adminRoleStmt->fetch(); + + if (!$adminRole) { + exit('Admin role not configured in intra_users_roles table.'); + } + + // Fetch the role for default users (default = 1) + $defaultRoleStmt = $pdo->prepare("SELECT id FROM intra_users_roles WHERE `default` = 1 LIMIT 1"); + $defaultRoleStmt->execute(); + $defaultRole = $defaultRoleStmt->fetch(); + + if (!$defaultRole) { + exit('Default role not configured in intra_users_roles table.'); + } + // Check if any users exist in the database $checkStmt = $pdo->query("SELECT COUNT(*) FROM intra_users"); $userCount = $checkStmt->fetchColumn(); @@ -55,7 +73,7 @@ $stmt->execute([ 'discord_id' => $discordId, 'username' => $username, - 'role' => 3, // Admin role + 'role' => $adminRole['id'], // Use the admin role ID 'full_admin' => 1 // Full admin privileges ]); } @@ -98,7 +116,7 @@ $insertStmt->execute([ 'discord_id' => $discordId, 'username' => $username, - 'role' => 7, // Default role for new users + 'role' => $defaultRole['id'], // Use the default role ID 'full_admin' => 0 // Default full_admin value ]); From 49af09ed725e9a405ef3e390017654ba48cd8494 Mon Sep 17 00:00:00 2001 From: hypax Date: Sat, 26 Apr 2025 21:33:29 +0200 Subject: [PATCH 18/48] Add warning on missing fullname --- admin/index.php | 4 ++++ auth/callback.php | 26 +++++++------------------- src/Helpers/Flash.php | 3 +++ 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/admin/index.php b/admin/index.php index 14e60311..f0d662e4 100644 --- a/admin/index.php +++ b/admin/index.php @@ -11,6 +11,10 @@ use App\Helpers\Flash; +if (!isset($_SESSION['cirs_user']) || empty($_SESSION['cirs_user'])) { + Flash::set('warning', 'no-fullname'); +} + ?> diff --git a/auth/callback.php b/auth/callback.php index aa394f7b..e37c8e51 100644 --- a/auth/callback.php +++ b/auth/callback.php @@ -37,12 +37,10 @@ $resourceOwner = $provider->getResourceOwner($accessToken); $discordUser = $resourceOwner->toArray(); - // Save user to the database or start a session $discordId = $discordUser['id']; $username = $discordUser['username']; $avatar = $discordUser['avatar']; - // Fetch the role for the first admin user (admin = 1) $adminRoleStmt = $pdo->prepare("SELECT id FROM intra_users_roles WHERE admin = 1 LIMIT 1"); $adminRoleStmt->execute(); $adminRole = $adminRoleStmt->fetch(); @@ -51,7 +49,6 @@ exit('Admin role not configured in intra_users_roles table.'); } - // Fetch the role for default users (default = 1) $defaultRoleStmt = $pdo->prepare("SELECT id FROM intra_users_roles WHERE `default` = 1 LIMIT 1"); $defaultRoleStmt->execute(); $defaultRole = $defaultRoleStmt->fetch(); @@ -60,12 +57,10 @@ exit('Default role not configured in intra_users_roles table.'); } - // Check if any users exist in the database $checkStmt = $pdo->query("SELECT COUNT(*) FROM intra_users"); $userCount = $checkStmt->fetchColumn(); if ($userCount == 0) { - // No users exist, create the first admin user $stmt = $pdo->prepare(" INSERT INTO intra_users (discord_id, username, fullname, role, full_admin) VALUES (:discord_id, :username, NULL, :role, :full_admin) @@ -73,18 +68,16 @@ $stmt->execute([ 'discord_id' => $discordId, 'username' => $username, - 'role' => $adminRole['id'], // Use the admin role ID - 'full_admin' => 1 // Full admin privileges + 'role' => $adminRole['id'], + 'full_admin' => 1 ]); } - // Check if the Discord ID already exists in the database $stmt = $pdo->prepare("SELECT * FROM intra_users WHERE discord_id = :discord_id"); $stmt->execute(['discord_id' => $discordId]); $user = $stmt->fetch(); if ($user) { - // Discord ID exists, log the user in $_SESSION['userid'] = $user['id']; $_SESSION['cirs_user'] = $user['fullname']; $_SESSION['cirs_username'] = $user['username']; @@ -92,11 +85,9 @@ $_SESSION['role'] = $user['role']; $_SESSION['full_admin'] = $user['full_admin']; - // Set permissions based on the user's role if ($user['full_admin'] == 1) { - $_SESSION['permissions'] = ['full_admin']; // Full admin permissions + $_SESSION['permissions'] = ['full_admin']; } else { - // Retrieve permissions for the user's role $roleStmt = $pdo->prepare("SELECT permissions FROM intra_users_roles WHERE id = :role_id"); $roleStmt->execute(['role_id' => $user['role']]); $role = $roleStmt->fetch(); @@ -104,11 +95,10 @@ if ($role && isset($role['permissions'])) { $_SESSION['permissions'] = json_decode($role['permissions'], true) ?? []; } else { - $_SESSION['permissions'] = []; // Default to no permissions + $_SESSION['permissions'] = []; } } } else { - // Discord ID does not exist, create a new user $insertStmt = $pdo->prepare(" INSERT INTO intra_users (discord_id, username, fullname, role, full_admin) VALUES (:discord_id, :username, NULL, :role, :full_admin) @@ -116,11 +106,10 @@ $insertStmt->execute([ 'discord_id' => $discordId, 'username' => $username, - 'role' => $defaultRole['id'], // Use the default role ID - 'full_admin' => 0 // Default full_admin value + 'role' => $defaultRole['id'], + 'full_admin' => 0 ]); - // Fetch the newly created user to set session variables $stmt = $pdo->prepare("SELECT * FROM intra_users WHERE discord_id = :discord_id"); $stmt->execute(['discord_id' => $discordId]); $user = $stmt->fetch(); @@ -131,10 +120,9 @@ $_SESSION['aktenid'] = $user['aktenid']; $_SESSION['role'] = $user['role']; $_SESSION['full_admin'] = $user['full_admin']; - $_SESSION['permissions'] = []; // Default to no permissions for new users + $_SESSION['permissions'] = []; } - // Redirect to the admin dashboard or the originally requested page $redirectUrl = $_SESSION['redirect_url'] ?? '/admin/index.php'; unset($_SESSION['redirect_url']); header("Location: $redirectUrl"); diff --git a/src/Helpers/Flash.php b/src/Helpers/Flash.php index b40738e8..e93cb4d8 100644 --- a/src/Helpers/Flash.php +++ b/src/Helpers/Flash.php @@ -62,6 +62,9 @@ class Flash 'no-permissions' => ['type' => 'danger', 'title' => 'Fehler!', 'text' => 'Dazu hast du nicht die richtigen Berechtigungen!'], 'missing-fields' => ['type' => 'danger', 'title' => 'Fehler!', 'text' => 'Es wurden nicht alle Pflichtfelder ausgefüllt.'], ], + 'warning' => [ + 'no-fullname' => ['type' => 'warning', 'title' => 'Achtung!', 'text' => 'Dein Name ist nicht vollständig. Bitte aktualisiere deine Daten!'], + ], 'dashboard.tile' => [ 'created' => ['type' => 'success', 'title' => 'Erfolg!', 'text' => 'Die Verlinkung wurde erfolgreich erstellt.'], 'deleted' => ['type' => 'success', 'title' => 'Erfolg!', 'text' => 'Die Verlinkung wurde erfolgreich gelöscht.'], From 087bceb84b6c5c19e54ce95547f7c7d6ac36bfe4 Mon Sep 17 00:00:00 2001 From: hypax Date: Sat, 26 Apr 2025 21:34:25 +0200 Subject: [PATCH 19/48] Update Flash.php --- src/Helpers/Flash.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Helpers/Flash.php b/src/Helpers/Flash.php index e93cb4d8..5635fd7c 100644 --- a/src/Helpers/Flash.php +++ b/src/Helpers/Flash.php @@ -63,7 +63,7 @@ class Flash 'missing-fields' => ['type' => 'danger', 'title' => 'Fehler!', 'text' => 'Es wurden nicht alle Pflichtfelder ausgefüllt.'], ], 'warning' => [ - 'no-fullname' => ['type' => 'warning', 'title' => 'Achtung!', 'text' => 'Dein Name ist nicht vollständig. Bitte aktualisiere deine Daten!'], + 'no-fullname' => ['type' => 'warning', 'title' => 'Achtung!', 'text' => 'Du hast noch keinen Namen hinterlegt. Bitte hinterlege deinen Namen jetzt!
Bei fehlendem Namen kann es zu technischen Problemen kommen.'], ], 'dashboard.tile' => [ 'created' => ['type' => 'success', 'title' => 'Erfolg!', 'text' => 'Die Verlinkung wurde erfolgreich erstellt.'], From cae62bf30e4e79d032ae72a3e5b526abbbd3ee02 Mon Sep 17 00:00:00 2001 From: hypax Date: Sat, 26 Apr 2025 21:36:26 +0200 Subject: [PATCH 20/48] Added warning on missing name --- admin/index.php | 1 + src/Helpers/Flash.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/admin/index.php b/admin/index.php index f0d662e4..ea37a921 100644 --- a/admin/index.php +++ b/admin/index.php @@ -13,6 +13,7 @@ if (!isset($_SESSION['cirs_user']) || empty($_SESSION['cirs_user'])) { Flash::set('warning', 'no-fullname'); + header("Location: /admin/users/editprofile.php"); } ?> diff --git a/src/Helpers/Flash.php b/src/Helpers/Flash.php index 5635fd7c..ee87f4b2 100644 --- a/src/Helpers/Flash.php +++ b/src/Helpers/Flash.php @@ -63,7 +63,7 @@ class Flash 'missing-fields' => ['type' => 'danger', 'title' => 'Fehler!', 'text' => 'Es wurden nicht alle Pflichtfelder ausgefüllt.'], ], 'warning' => [ - 'no-fullname' => ['type' => 'warning', 'title' => 'Achtung!', 'text' => 'Du hast noch keinen Namen hinterlegt. Bitte hinterlege deinen Namen jetzt!
Bei fehlendem Namen kann es zu technischen Problemen kommen.'], + 'no-fullname' => ['type' => 'warning', 'title' => 'Achtung!', 'text' => 'Du hast noch keinen Namen hinterlegt. Bitte hinterlege deinen Namen jetzt!
Bei fehlendem Namen kann es zu technischen Problemen kommen.'], ], 'dashboard.tile' => [ 'created' => ['type' => 'success', 'title' => 'Erfolg!', 'text' => 'Die Verlinkung wurde erfolgreich erstellt.'], From 8c7d77772d0c516bedea40fbfc3905c3eddd512e Mon Sep 17 00:00:00 2001 From: hypax Date: Sat, 26 Apr 2025 21:42:46 +0200 Subject: [PATCH 21/48] Update editprofile.php --- admin/users/editprofile.php | 64 ++++++++++++------------------------- 1 file changed, 21 insertions(+), 43 deletions(-) diff --git a/admin/users/editprofile.php b/admin/users/editprofile.php index c347f9fc..65cd7aff 100644 --- a/admin/users/editprofile.php +++ b/admin/users/editprofile.php @@ -25,39 +25,18 @@ $aktenid = $_REQUEST['aktenid']; $fullname = $_REQUEST['fullname']; - $new_password = $_REQUEST['passwort']; - $new_password_2 = $_REQUEST['passwort2']; - - if (!empty($new_password) && !empty($new_password_2) && $new_password === $new_password_2) { - $new_password_hash = password_hash($new_password, PASSWORD_DEFAULT); - - $stmt = $pdo->prepare("UPDATE intra_users SET passwort = :password, fullname = :fullname, aktenid = :aktenid WHERE id = :id"); - $stmt->execute([ - 'password' => $new_password_hash, - 'fullname' => $fullname, - 'aktenid' => $aktenid, - 'id' => $id - ]); - - Flash::set('own', 'pw-changed'); - $auditLogger = new AuditLogger($pdo); - $auditLogger->log($userid, 'Passwort & Daten geändert [ID: ' . $id . ']', NULL, 'Selbst', 0); - header("Refresh:0"); - exit(); - } else { - $stmt = $pdo->prepare("UPDATE intra_users SET fullname = :fullname, aktenid = :aktenid WHERE id = :id"); - $stmt->execute([ - 'fullname' => $fullname, - 'aktenid' => $aktenid, - 'id' => $id - ]); - - Flash::set('own', 'data-changed'); - $auditLogger = new AuditLogger($pdo); - $auditLogger->log($userid, 'Daten geändert [ID: ' . $id . ']', NULL, 'Selbst', 0); - header("Refresh:0"); - exit(); - } + $stmt = $pdo->prepare("UPDATE intra_users SET fullname = :fullname, aktenid = :aktenid WHERE id = :id"); + $stmt->execute([ + 'fullname' => $fullname, + 'aktenid' => $aktenid, + 'id' => $id + ]); + + Flash::set('own', 'data-changed'); + $auditLogger = new AuditLogger($pdo); + $auditLogger->log($userid, 'Daten geändert [ID: ' . $id . ']', NULL, 'Selbst', 0); + header("Refresh:0"); + exit(); } ?> @@ -107,6 +86,15 @@

Eigene Daten bearbeiten

'; + echo '

Achtung!

'; + echo 'Du hast noch keinen Namen hinterlegt. Bitte hinterlege deinen Namen jetzt!
Bei fehlendem Namen kann es zu technischen Problemen kommen.'; + echo ''; + echo ''; + } + Flash::render(); ?>
@@ -123,16 +111,6 @@ -
-
- - -
-
- - -
-
From 920902a385a72b4741033367cf8b38ea372e7af9 Mon Sep 17 00:00:00 2001 From: hypax Date: Sat, 26 Apr 2025 22:05:19 +0200 Subject: [PATCH 22/48] Updated Readme --- README.md | 5 +++++ admin/index.php | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 30a3b58b..7cd38a06 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,10 @@ ![intraRP Logo](/.github/intrarp_banner.png) +[![PHP Composer](https://github.com/intraRP/intraRP/actions/workflows/php.yml/badge.svg)](https://github.com/intraRP/intraRP/actions/workflows/php.yml) ![GitHub Downloads (all assets, all releases)](https://img.shields.io/github/downloads/intraRP/intraRP/total) ![GitHub commits since latest release](https://img.shields.io/github/commits-since/intraRP/intraRP/latest) ![GitHub Release](https://img.shields.io/github/v/release/intraRP/intraRP) + + + + # intraRP - Roleplay Intranet für fiktive Fraktionen Das Ziel von **intraRP** ist es eine Allround-Lösung für die Fraktionsverwaltung fiktiver Feuerwehren & Rettungsdienste vor allem für FiveM und andere ähnliche Settings anzubieten. Das System ist grundsätzlich zur Verwaltung eines deutschen Systems ausgelegt, kann aber mit eigenen Veränderungen durchaus auch an ein amerikanisches oder anderes Setting angepasst werden. Es handelt sich hierbei um eine Weiterentwicklung bzw. den Nachfolger von [intra.stettbeck.de](https://github.com/itshypax/intra.stettbeck.de). Das System befindet sich in aktuell in Entwicklung und wird stetig verändert. diff --git a/admin/index.php b/admin/index.php index ea37a921..df59912a 100644 --- a/admin/index.php +++ b/admin/index.php @@ -12,7 +12,6 @@ use App\Helpers\Flash; if (!isset($_SESSION['cirs_user']) || empty($_SESSION['cirs_user'])) { - Flash::set('warning', 'no-fullname'); header("Location: /admin/users/editprofile.php"); } From 68737d66a7fbe4c33f33dc0ab7b17152866888c1 Mon Sep 17 00:00:00 2001 From: hypax Date: Sat, 26 Apr 2025 22:07:13 +0200 Subject: [PATCH 23/48] Update README.md --- README.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/README.md b/README.md index 7cd38a06..652fc98b 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,6 @@ ![intraRP Logo](/.github/intrarp_banner.png) -[![PHP Composer](https://github.com/intraRP/intraRP/actions/workflows/php.yml/badge.svg)](https://github.com/intraRP/intraRP/actions/workflows/php.yml) ![GitHub Downloads (all assets, all releases)](https://img.shields.io/github/downloads/intraRP/intraRP/total) ![GitHub commits since latest release](https://img.shields.io/github/commits-since/intraRP/intraRP/latest) ![GitHub Release](https://img.shields.io/github/v/release/intraRP/intraRP) - - - +![GitHub Release](https://img.shields.io/github/v/release/intraRP/intraRP) [![PHP Composer](https://github.com/intraRP/intraRP/actions/workflows/php.yml/badge.svg)](https://github.com/intraRP/intraRP/actions/workflows/php.yml) ![GitHub Downloads (all assets, all releases)](https://img.shields.io/github/downloads/intraRP/intraRP/total) ![GitHub commit activity](https://img.shields.io/github/commit-activity/m/intraRP/intraRP) # intraRP - Roleplay Intranet für fiktive Fraktionen From 76f662935f025642767e9d07032af27b000ac3c7 Mon Sep 17 00:00:00 2001 From: hypax Date: Thu, 1 May 2025 19:30:14 +0200 Subject: [PATCH 24/48] Update editprofile.php --- admin/users/editprofile.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/users/editprofile.php b/admin/users/editprofile.php index 65cd7aff..61d802f3 100644 --- a/admin/users/editprofile.php +++ b/admin/users/editprofile.php @@ -22,7 +22,7 @@ if (isset($_POST['new']) && $_POST['new'] == 1) { $id = $_REQUEST['id']; - $aktenid = $_REQUEST['aktenid']; + $aktenid = $_REQUEST['aktenid'] ?? NULL; $fullname = $_REQUEST['fullname']; $stmt = $pdo->prepare("UPDATE intra_users SET fullname = :fullname, aktenid = :aktenid WHERE id = :id"); From 67d2703f301257301e4eb86d839cd3954ccc2600 Mon Sep 17 00:00:00 2001 From: hypax Date: Thu, 1 May 2025 19:31:57 +0200 Subject: [PATCH 25/48] Update editprofile.php --- admin/users/editprofile.php | 50 ++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/admin/users/editprofile.php b/admin/users/editprofile.php index 61d802f3..5284119a 100644 --- a/admin/users/editprofile.php +++ b/admin/users/editprofile.php @@ -22,21 +22,41 @@ if (isset($_POST['new']) && $_POST['new'] == 1) { $id = $_REQUEST['id']; - $aktenid = $_REQUEST['aktenid'] ?? NULL; - $fullname = $_REQUEST['fullname']; - - $stmt = $pdo->prepare("UPDATE intra_users SET fullname = :fullname, aktenid = :aktenid WHERE id = :id"); - $stmt->execute([ - 'fullname' => $fullname, - 'aktenid' => $aktenid, - 'id' => $id - ]); - - Flash::set('own', 'data-changed'); - $auditLogger = new AuditLogger($pdo); - $auditLogger->log($userid, 'Daten geändert [ID: ' . $id . ']', NULL, 'Selbst', 0); - header("Refresh:0"); - exit(); + $aktenid = isset($_REQUEST['aktenid']) && $_REQUEST['aktenid'] !== '' ? (int)$_REQUEST['aktenid'] : null; + $fullname = trim($_REQUEST['fullname']); + + // Validate inputs + if (empty($fullname)) { + Flash::set('error', 'Der Name darf nicht leer sein.'); + header("Location: /admin/users/editprofile.php"); + exit(); + } + + if ($aktenid === null) { + Flash::set('error', 'Die Mitarbeiterakten-ID darf nicht leer sein.'); + header("Location: /admin/users/editprofile.php"); + exit(); + } + + try { + $stmt = $pdo->prepare("UPDATE intra_users SET fullname = :fullname, aktenid = :aktenid WHERE id = :id"); + $stmt->execute([ + 'fullname' => $fullname, + 'aktenid' => $aktenid, + 'id' => $id + ]); + + Flash::set('own', 'data-changed'); + $auditLogger = new AuditLogger($pdo); + $auditLogger->log($userid, 'Daten geändert [ID: ' . $id . ']', null, 'Selbst', 0); + header("Refresh:0"); + exit(); + } catch (PDOException $e) { + error_log($e->getMessage()); + Flash::set('error', 'Ein Fehler ist beim Speichern der Daten aufgetreten.'); + header("Location: /admin/users/editprofile.php"); + exit(); + } } ?> From 67941e558e65bf2e8f41e4fe29c89ee57ae419e7 Mon Sep 17 00:00:00 2001 From: hypax Date: Thu, 1 May 2025 19:35:35 +0200 Subject: [PATCH 26/48] Update editprofile.php --- admin/users/editprofile.php | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/admin/users/editprofile.php b/admin/users/editprofile.php index 5284119a..767dc16f 100644 --- a/admin/users/editprofile.php +++ b/admin/users/editprofile.php @@ -25,26 +25,12 @@ $aktenid = isset($_REQUEST['aktenid']) && $_REQUEST['aktenid'] !== '' ? (int)$_REQUEST['aktenid'] : null; $fullname = trim($_REQUEST['fullname']); - // Validate inputs - if (empty($fullname)) { - Flash::set('error', 'Der Name darf nicht leer sein.'); - header("Location: /admin/users/editprofile.php"); - exit(); - } - - if ($aktenid === null) { - Flash::set('error', 'Die Mitarbeiterakten-ID darf nicht leer sein.'); - header("Location: /admin/users/editprofile.php"); - exit(); - } - try { $stmt = $pdo->prepare("UPDATE intra_users SET fullname = :fullname, aktenid = :aktenid WHERE id = :id"); - $stmt->execute([ - 'fullname' => $fullname, - 'aktenid' => $aktenid, - 'id' => $id - ]); + $stmt->bindValue(':fullname', $fullname, PDO::PARAM_STR); + $stmt->bindValue(':aktenid', $aktenid, $aktenid === null ? PDO::PARAM_NULL : PDO::PARAM_INT); + $stmt->bindValue(':id', $id, PDO::PARAM_INT); + $stmt->execute(); Flash::set('own', 'data-changed'); $auditLogger = new AuditLogger($pdo); @@ -53,7 +39,7 @@ exit(); } catch (PDOException $e) { error_log($e->getMessage()); - Flash::set('error', 'Ein Fehler ist beim Speichern der Daten aufgetreten.'); + Flash::set('error', 'exception'); header("Location: /admin/users/editprofile.php"); exit(); } From 06616a82f1ab38bc4c26a76332214df52f849d24 Mon Sep 17 00:00:00 2001 From: hypax Date: Thu, 1 May 2025 19:48:44 +0200 Subject: [PATCH 27/48] Certificates not working properly --- admin/personal/profile.php | 6 ++++-- admin/users/editprofile.php | 3 +++ dokumente/zertifikate/fachlehrgang.php | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/admin/personal/profile.php b/admin/personal/profile.php index 2baf7c8d..e783efdd 100644 --- a/admin/personal/profile.php +++ b/admin/personal/profile.php @@ -326,6 +326,7 @@ $erhalter_gebdat = $_POST['erhalter_gebdat']; $erhalter_rang = $_POST['erhalter_rang'] ?? NULL; $erhalter_rang_rd = $_POST['erhalter_rang_rd'] ?? NULL; + $erhalter_quali = $_POST['erhalter_quali'] ?? NULL; $ausstellerid = $_POST['ausstellerid']; $aussteller_name = $_POST['aussteller_name']; $aussteller_rang = $_POST['aussteller_rang']; @@ -347,8 +348,8 @@ $new_number = $random_number; $docStmt = $pdo->prepare("INSERT INTO intra_mitarbeiter_dokumente - (docid, type, anrede, erhalter, inhalt, suspendtime, erhalter_gebdat, erhalter_rang, erhalter_rang_rd, ausstellungsdatum, ausstellerid, profileid, aussteller_name, aussteller_rang) - VALUES (:docid, :type, :anrede, :erhalter, :inhalt, :suspendtime, :erhalter_gebdat, :erhalter_rang, :erhalter_rang_rd, :ausstellungsdatum, :ausstellerid, :profileid, :aussteller_name, :aussteller_rang)"); + (docid, type, anrede, erhalter, inhalt, suspendtime, erhalter_gebdat, erhalter_rang, erhalter_rang_rd, erhalter_quali, ausstellungsdatum, ausstellerid, profileid, aussteller_name, aussteller_rang) + VALUES (:docid, :type, :anrede, :erhalter, :inhalt, :suspendtime, :erhalter_gebdat, :erhalter_rang, :erhalter_rang_rd, :erhalter_quali, :ausstellungsdatum, :ausstellerid, :profileid, :aussteller_name, :aussteller_rang)"); $docStmt->execute([ 'docid' => $new_number, @@ -360,6 +361,7 @@ 'erhalter_gebdat' => $erhalter_gebdat, 'erhalter_rang' => $erhalter_rang, 'erhalter_rang_rd' => $erhalter_rang_rd, + 'erhalter_quali' => $erhalter_quali, 'ausstellungsdatum' => $ausstellungsdatum, 'ausstellerid' => $ausstellerid, 'profileid' => $profileid, diff --git a/admin/users/editprofile.php b/admin/users/editprofile.php index 767dc16f..1a9251a5 100644 --- a/admin/users/editprofile.php +++ b/admin/users/editprofile.php @@ -32,6 +32,9 @@ $stmt->bindValue(':id', $id, PDO::PARAM_INT); $stmt->execute(); + $_SESSION['cirs_user'] = $fullname; + $_SESSION['aktenid'] = $aktenid; + Flash::set('own', 'data-changed'); $auditLogger = new AuditLogger($pdo); $auditLogger->log($userid, 'Daten geändert [ID: ' . $id . ']', null, 'Selbst', 0); diff --git a/dokumente/zertifikate/fachlehrgang.php b/dokumente/zertifikate/fachlehrgang.php index 20e4c637..d6bc66e2 100644 --- a/dokumente/zertifikate/fachlehrgang.php +++ b/dokumente/zertifikate/fachlehrgang.php @@ -73,7 +73,7 @@ 0 => 'Brandmeister', 1 => 'Gruppenführer', 2 => 'Zugführer', - 3 => 'ILS Disponent', + 3 => 'Leitstellen-Disponent', 4 => 'Sonderfahrzeug-Maschinist', 8 => 'HEMS-TC', 9 => 'Luftrettungspilot', From d07f3c983ab2056f9acf9376976c2e9d7b468b6f Mon Sep 17 00:00:00 2001 From: hypax Date: Thu, 1 May 2025 19:55:16 +0200 Subject: [PATCH 28/48] Update dokument-delete.php --- admin/personal/dokument-delete.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/personal/dokument-delete.php b/admin/personal/dokument-delete.php index 47b9db39..05d2bd80 100644 --- a/admin/personal/dokument-delete.php +++ b/admin/personal/dokument-delete.php @@ -25,7 +25,7 @@ $id = $_GET['id']; $pid = $_GET['pid']; -$stmt = $pdo->prepare("DELETE FROM intra_mitarbeiter_dokumente WHERE id = :id"); +$stmt = $pdo->prepare("DELETE FROM intra_mitarbeiter_dokumente WHERE docid = :id"); $stmt->bindParam(':id', $id); $stmt->execute(); From 171d73cbbeb210f027155f129f5281ab892e3463 Mon Sep 17 00:00:00 2001 From: hypax Date: Sat, 3 May 2025 21:26:20 +0200 Subject: [PATCH 29/48] Anpassung login.php Styling --- admin/login.php | 2 +- edivi/index.php | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/admin/login.php b/admin/login.php index dff779d8..2a6746eb 100644 --- a/admin/login.php +++ b/admin/login.php @@ -52,7 +52,7 @@

Das Intranet der Stadt !

diff --git a/edivi/index.php b/edivi/index.php index 59c16de0..81fc480b 100644 --- a/edivi/index.php +++ b/edivi/index.php @@ -46,17 +46,12 @@
-
-
- hypax - © 2023- intraRP | Version -
-
+ - - - - - - - - - - - - - - - " /> - - - - - -
- - - -
-
-
-
-

Benutzer anlegen

-
-
- -
-
- - -
-
- - -
-
- -
- - - -
-
-
-
-
- - -
-
- - -
-
-
-
-
- -
-
-
-
-
-
-
- - - - - - - \ No newline at end of file From 90180fe1a635f8e5bfbab291edc3ebaace16c8c0 Mon Sep 17 00:00:00 2001 From: hypax Date: Sat, 3 May 2025 21:46:16 +0200 Subject: [PATCH 32/48] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 652fc98b..a7cf7299 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ Das Projekt wird hobbymäßig weiterentwickelt und ist für jegliche Unterstütz ### Wiki & Informationen +- [Setup - Discord-Applikation erstellen](https://github.com/intraRP/intraRP/wiki/Setup-%E2%80%90-Discord%E2%80%90Applikation-erstellen) + - [Discord-Applikation erstellen & konfigurieren](https://github.com/intraRP/intraRP/wiki/Setup-%E2%80%90-Discord%E2%80%90Applikation-erstellen#discord-applikation-erstellen--konfigurieren) - [Setup ‐ intraRP aufsetzen & einrichten](https://github.com/itshypax/intraRP/wiki/Setup-%E2%80%90-intraRP-aufsetzen-&-einrichten) - [Was wird benötigt?](https://github.com/itshypax/intraRP/wiki/Setup-%E2%80%90-intraRP-aufsetzen-&-einrichten#was-wird-ben%C3%B6tigt) - [intraRP aufsetzen](https://github.com/itshypax/intraRP/wiki/Setup-%E2%80%90-intraRP-aufsetzen-&-einrichten#intrarp-aufsetzen) From 57e23adf428add32276f4c4d8a86494c7c68f273 Mon Sep 17 00:00:00 2001 From: hypax Date: Sat, 3 May 2025 21:48:53 +0200 Subject: [PATCH 33/48] Update footer.php --- assets/components/footer.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/assets/components/footer.php b/assets/components/footer.php index ead39e61..546670d6 100644 --- a/assets/components/footer.php +++ b/assets/components/footer.php @@ -10,7 +10,8 @@

© intraRP | Alle Rechte vorbehalten

-

Version

+

Version


+ Fehler melden
From f59ecdd62d20147ba89b47b4f6a90acc24505829 Mon Sep 17 00:00:00 2001 From: hypax Date: Sat, 3 May 2025 21:49:29 +0200 Subject: [PATCH 34/48] Update footer.php --- assets/components/footer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/components/footer.php b/assets/components/footer.php index 546670d6..b09ffb70 100644 --- a/assets/components/footer.php +++ b/assets/components/footer.php @@ -10,8 +10,8 @@

© intraRP | Alle Rechte vorbehalten

-

Version


- Fehler melden +

Version

+

Fehler melden

From 3adc54281b12ac507983d05cc80af1963ddedc49 Mon Sep 17 00:00:00 2001 From: hypax Date: Sat, 3 May 2025 21:49:58 +0200 Subject: [PATCH 35/48] Update footer.php --- assets/components/footer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/components/footer.php b/assets/components/footer.php index b09ffb70..30c5ebbc 100644 --- a/assets/components/footer.php +++ b/assets/components/footer.php @@ -10,7 +10,7 @@

© intraRP | Alle Rechte vorbehalten

-

Version

+
Version

Fehler melden

From c4b3eb33476996c9f162a9885cba9b2b69b9169d Mon Sep 17 00:00:00 2001 From: hypax Date: Sat, 3 May 2025 21:51:46 +0200 Subject: [PATCH 36/48] Versionsnummer des Updates angepasst --- assets/config/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/config/config.php b/assets/config/config.php index aac737e1..b114db77 100644 --- a/assets/config/config.php +++ b/assets/config/config.php @@ -1,7 +1,7 @@ Date: Sun, 4 May 2025 20:07:14 +0200 Subject: [PATCH 37/48] Dokumente speichern jetzt Discord-ID des Benutzers --- admin/personal/create.php | 4 ++-- admin/personal/profile.php | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/admin/personal/create.php b/admin/personal/create.php index a075e52e..314f6dd5 100644 --- a/admin/personal/create.php +++ b/admin/personal/create.php @@ -228,8 +228,8 @@ - Discord - + Discord-ID + Telefonnummer diff --git a/admin/personal/profile.php b/admin/personal/profile.php index e783efdd..7ee519de 100644 --- a/admin/personal/profile.php +++ b/admin/personal/profile.php @@ -333,6 +333,7 @@ $profileid = $_POST['profileid']; $docType = $_POST['docType']; $anrede = $_POST['anrede']; + $discordtag = $row['discordtag']; $ausstDtNr = in_array($docType, ['10', '11', '12', '13']) ? '10' : $docType; @@ -348,8 +349,8 @@ $new_number = $random_number; $docStmt = $pdo->prepare("INSERT INTO intra_mitarbeiter_dokumente - (docid, type, anrede, erhalter, inhalt, suspendtime, erhalter_gebdat, erhalter_rang, erhalter_rang_rd, erhalter_quali, ausstellungsdatum, ausstellerid, profileid, aussteller_name, aussteller_rang) - VALUES (:docid, :type, :anrede, :erhalter, :inhalt, :suspendtime, :erhalter_gebdat, :erhalter_rang, :erhalter_rang_rd, :erhalter_quali, :ausstellungsdatum, :ausstellerid, :profileid, :aussteller_name, :aussteller_rang)"); + (docid, type, anrede, erhalter, inhalt, suspendtime, erhalter_gebdat, erhalter_rang, erhalter_rang_rd, erhalter_quali, ausstellungsdatum, ausstellerid, profileid, aussteller_name, aussteller_rang, discordid) + VALUES (:docid, :type, :anrede, :erhalter, :inhalt, :suspendtime, :erhalter_gebdat, :erhalter_rang, :erhalter_rang_rd, :erhalter_quali, :ausstellungsdatum, :ausstellerid, :profileid, :aussteller_name, :aussteller_rang, :discordtag)"); $docStmt->execute([ 'docid' => $new_number, @@ -366,7 +367,8 @@ 'ausstellerid' => $ausstellerid, 'profileid' => $profileid, 'aussteller_name' => $aussteller_name, - 'aussteller_rang' => $aussteller_rang + 'aussteller_rang' => $aussteller_rang, + 'discordtag' => $discordtag ]); $logContent = 'Ein neues Dokument (#' . $new_number . ') wurde erstellt.'; @@ -537,7 +539,7 @@ function removeEditParamFromURL() - Discord + Discord-ID @@ -592,8 +594,8 @@ function removeEditParamFromURL() - Discord - + Discord-ID + Telefonnummer From 01dd2e25cc970e02cc116def122330d969dffdb9 Mon Sep 17 00:00:00 2001 From: hypax Date: Sun, 4 May 2025 20:09:16 +0200 Subject: [PATCH 38/48] Discord-ID kann jetzt nur noch eine Nummer sein --- admin/personal/create.php | 2 +- admin/personal/profile.php | 2 +- assets/components/navbar.php | 3 --- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/admin/personal/create.php b/admin/personal/create.php index 314f6dd5..b7de6ae8 100644 --- a/admin/personal/create.php +++ b/admin/personal/create.php @@ -229,7 +229,7 @@ Discord-ID - + Telefonnummer diff --git a/admin/personal/profile.php b/admin/personal/profile.php index 7ee519de..7e7905e6 100644 --- a/admin/personal/profile.php +++ b/admin/personal/profile.php @@ -595,7 +595,7 @@ function removeEditParamFromURL() Discord-ID - + Telefonnummer diff --git a/assets/components/navbar.php b/assets/components/navbar.php index 008e6239..cda36007 100644 --- a/assets/components/navbar.php +++ b/assets/components/navbar.php @@ -17,9 +17,6 @@