From ec2b62f68eeeae745bf5566f434972437857be2f Mon Sep 17 00:00:00 2001 From: Till Schnegelsberg Date: Fri, 25 Aug 2023 14:37:50 +0200 Subject: [PATCH] add: gd / case rework --- .gitignore | 3 + Dockerfile | 15 +++ assets/css/styles.css | 91 +++++++++++++- case.php | 11 ++ composer.json | 4 +- composer.lock | 272 +++++++++++++++++++++++++++++++++--------- docker-compose.yaml | 2 +- opcache.ini | 9 ++ php/login.inc.php | 1 - user.new.php | 212 ++++++++++++++++++++++++++++++++ 10 files changed, 559 insertions(+), 61 deletions(-) create mode 100644 opcache.ini create mode 100644 user.new.php diff --git a/.gitignore b/.gitignore index 6383c38e..fda88116 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,6 @@ debug.sh composer.phar buildpush.sh /archive/ +html/install-php-extensions +composer.lock +info.php diff --git a/Dockerfile b/Dockerfile index 821b337e..971383b3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,6 +10,21 @@ RUN apt-get install -y \ RUN /usr/local/bin/docker-php-ext-install mysqli pdo pdo_mysql RUN apt-get install libssl-dev -y +ENV PHP_OPCACHE_VALIDATE_TIMESTAMPS="0" + +ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ + +RUN chmod +x /usr/local/bin/install-php-extensions && \ + install-php-extensions gd + +RUN apt-get update && apt-get install -y \ + libfreetype-dev \ + libjpeg62-turbo-dev \ + libpng-dev \ + && docker-php-ext-configure gd --with-freetype --with-jpeg \ + && docker-php-ext-install -j$(nproc) gd + +COPY opcache.ini /usr/local/etc/php/conf.d/opcache.ini COPY docker/000-default.conf /etc/apache2/sites-available/000-default.conf RUN a2enmod rewrite diff --git a/assets/css/styles.css b/assets/css/styles.css index 48992756..640103c5 100644 --- a/assets/css/styles.css +++ b/assets/css/styles.css @@ -137,7 +137,7 @@ body { margin-top: 20px; } -.accept-button, .reject-button, .delete-button { +.accept-button, .reject-button, .delete-button, .neutral-button { font-size: 16px; border: none; border-radius: 5px; @@ -223,6 +223,92 @@ body { color: red; } +.user-requests { + margin-top: 20px; +} + +.request { + background-color: #36393f; + border-radius: 5px; + padding: 10px; + margin-top: 10px; + display: flex; + justify-content: space-between; + align-items: center; +} + +.request-info { + display: flex; + flex-direction: column; + align-items: flex-start; +} + +.request-date, .request-status { + font-size: 14px; + color: #e3eaf7; + margin-bottom: 5px; +} + +.request-title { + font-size: 18px; + font-weight: bold; + color: #e3eaf7; + flex: 1; + margin-left: 10px; +} + +.request-status.angenommen { + color: #43b581; +} + +.request-status.abgelehnt { + color: #f04747; +} + +.request-status.unprocessed { + color: #e7effd; +} + +.request { + position: relative; +} + +.expand-button { + font-size: 20px; + cursor: pointer; + margin-right: 10px; + transition: transform 0.3s ease; +} + +.request-details { + display: none; + padding: 10px; + background-color: #292b2f; + color: #e3eaf7; + border-radius: 5px; + margin-top: 10px; +} + +.expanded .expand-button { + transform: rotate(45deg); +} + +.expanded .request-details { + display: block; +} + +.request-details p { + margin: 0; + margin-top: 10px; +} + +.request-details a { + color: #0e53dd; + text-decoration: none; + display: inline-block; + margin-top: 10px; +} + @media (max-width: 600px) { .container { padding: 10px; @@ -250,4 +336,5 @@ body { .accept-button, .reject-button, .delete-button, .submit-button { margin: 5px 0; } -} \ No newline at end of file +} + diff --git a/case.php b/case.php index fc06e080..1b5476a1 100644 --- a/case.php +++ b/case.php @@ -93,6 +93,17 @@ function getContrastColor($hexColor) + + + + + + + + + Case <?php echo testInput($_GET['req_id']); ?> =5.5" + "php": "^7.2.5 || ^8.0" }, "require-dev": { - "symfony/phpunit-bridge": "^4.4 || ^5.1" + "bamarni/composer-bin-plugin": "^1.8.1", + "phpunit/phpunit": "^8.5.29 || ^9.5.23" }, "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, "autoload": { - "files": [ - "src/functions_include.php" - ], "psr-4": { "GuzzleHttp\\Promise\\": "src/" } @@ -191,7 +197,7 @@ ], "support": { "issues": "https://github.com/guzzle/promises/issues", - "source": "https://github.com/guzzle/promises/tree/1.5.3" + "source": "https://github.com/guzzle/promises/tree/2.0.1" }, "funding": [ { @@ -207,20 +213,20 @@ "type": "tidelift" } ], - "time": "2023-05-21T12:31:43+00:00" + "time": "2023-08-03T15:11:55+00:00" }, { "name": "guzzlehttp/psr7", - "version": "2.5.0", + "version": "2.6.0", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "b635f279edd83fc275f822a1188157ffea568ff6" + "reference": "8bd7c33a0734ae1c5d074360512beb716bef3f77" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/b635f279edd83fc275f822a1188157ffea568ff6", - "reference": "b635f279edd83fc275f822a1188157ffea568ff6", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/8bd7c33a0734ae1c5d074360512beb716bef3f77", + "reference": "8bd7c33a0734ae1c5d074360512beb716bef3f77", "shasum": "" }, "require": { @@ -307,7 +313,7 @@ ], "support": { "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/2.5.0" + "source": "https://github.com/guzzle/psr7/tree/2.6.0" }, "funding": [ { @@ -323,20 +329,20 @@ "type": "tidelift" } ], - "time": "2023-04-17T16:11:26+00:00" + "time": "2023-08-03T15:06:02+00:00" }, { "name": "league/oauth2-client", - "version": "2.6.0", + "version": "2.7.0", "source": { "type": "git", "url": "https://github.com/thephpleague/oauth2-client.git", - "reference": "badb01e62383430706433191b82506b6df24ad98" + "reference": "160d6274b03562ebeb55ed18399281d8118b76c8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/oauth2-client/zipball/badb01e62383430706433191b82506b6df24ad98", - "reference": "badb01e62383430706433191b82506b6df24ad98", + "url": "https://api.github.com/repos/thephpleague/oauth2-client/zipball/160d6274b03562ebeb55ed18399281d8118b76c8", + "reference": "160d6274b03562ebeb55ed18399281d8118b76c8", "shasum": "" }, "require": { @@ -345,9 +351,9 @@ "php": "^5.6 || ^7.0 || ^8.0" }, "require-dev": { - "mockery/mockery": "^1.3", - "php-parallel-lint/php-parallel-lint": "^1.2", - "phpunit/phpunit": "^5.7 || ^6.0 || ^9.3", + "mockery/mockery": "^1.3.5", + "php-parallel-lint/php-parallel-lint": "^1.3.1", + "phpunit/phpunit": "^5.7 || ^6.0 || ^9.5", "squizlabs/php_codesniffer": "^2.3 || ^3.0" }, "type": "library", @@ -391,9 +397,110 @@ ], "support": { "issues": "https://github.com/thephpleague/oauth2-client/issues", - "source": "https://github.com/thephpleague/oauth2-client/tree/2.6.0" + "source": "https://github.com/thephpleague/oauth2-client/tree/2.7.0" }, - "time": "2020-10-28T02:03:40+00:00" + "time": "2023-04-16T18:19:15+00:00" + }, + { + "name": "monolog/monolog", + "version": "3.4.0", + "source": { + "type": "git", + "url": "https://github.com/Seldaek/monolog.git", + "reference": "e2392369686d420ca32df3803de28b5d6f76867d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/e2392369686d420ca32df3803de28b5d6f76867d", + "reference": "e2392369686d420ca32df3803de28b5d6f76867d", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "psr/log": "^2.0 || ^3.0" + }, + "provide": { + "psr/log-implementation": "3.0.0" + }, + "require-dev": { + "aws/aws-sdk-php": "^3.0", + "doctrine/couchdb": "~1.0@dev", + "elasticsearch/elasticsearch": "^7 || ^8", + "ext-json": "*", + "graylog2/gelf-php": "^1.4.2 || ^2.0", + "guzzlehttp/guzzle": "^7.4.5", + "guzzlehttp/psr7": "^2.2", + "mongodb/mongodb": "^1.8", + "php-amqplib/php-amqplib": "~2.4 || ^3", + "phpstan/phpstan": "^1.9", + "phpstan/phpstan-deprecation-rules": "^1.0", + "phpstan/phpstan-strict-rules": "^1.4", + "phpunit/phpunit": "^10.1", + "predis/predis": "^1.1 || ^2", + "ruflin/elastica": "^7", + "symfony/mailer": "^5.4 || ^6", + "symfony/mime": "^5.4 || ^6" + }, + "suggest": { + "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB", + "doctrine/couchdb": "Allow sending log messages to a CouchDB server", + "elasticsearch/elasticsearch": "Allow sending log messages to an Elasticsearch server via official client", + "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)", + "ext-curl": "Required to send log messages using the IFTTTHandler, the LogglyHandler, the SendGridHandler, the SlackWebhookHandler or the TelegramBotHandler", + "ext-mbstring": "Allow to work properly with unicode symbols", + "ext-mongodb": "Allow sending log messages to a MongoDB server (via driver)", + "ext-openssl": "Required to send log messages using SSL", + "ext-sockets": "Allow sending log messages to a Syslog server (via UDP driver)", + "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server", + "mongodb/mongodb": "Allow sending log messages to a MongoDB server (via library)", + "php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib", + "rollbar/rollbar": "Allow sending log messages to Rollbar", + "ruflin/elastica": "Allow sending log messages to an Elastic Search server" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Monolog\\": "src/Monolog" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "https://seld.be" + } + ], + "description": "Sends your logs to files, sockets, inboxes, databases and various web services", + "homepage": "https://github.com/Seldaek/monolog", + "keywords": [ + "log", + "logging", + "psr-3" + ], + "support": { + "issues": "https://github.com/Seldaek/monolog/issues", + "source": "https://github.com/Seldaek/monolog/tree/3.4.0" + }, + "funding": [ + { + "url": "https://github.com/Seldaek", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/monolog/monolog", + "type": "tidelift" + } + ], + "time": "2023-06-21T08:46:11+00:00" }, { "name": "paragonie/random_compat", @@ -605,6 +712,56 @@ }, "time": "2023-04-04T09:54:51+00:00" }, + { + "name": "psr/log", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/fe5ea303b0887d5caefd3d431c3e61ad47037001", + "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "support": { + "source": "https://github.com/php-fig/log/tree/3.0.0" + }, + "time": "2021-07-14T16:46:02+00:00" + }, { "name": "ralouphie/getallheaders", "version": "3.0.3", @@ -651,25 +808,25 @@ }, { "name": "symfony/deprecation-contracts", - "version": "v2.5.2", + "version": "v3.3.0", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66" + "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e8b495ea28c1d97b5e0c121748d6f9b53d075c66", - "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/7c3aff79d10325257a001fcf92d991f24fc967cf", + "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=8.1" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "2.5-dev" + "dev-main": "3.4-dev" }, "thanks": { "name": "symfony/contracts", @@ -698,7 +855,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.2" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.3.0" }, "funding": [ { @@ -714,24 +871,26 @@ "type": "tidelift" } ], - "time": "2022-01-02T09:53:40+00:00" + "time": "2023-05-23T14:45:45+00:00" }, { "name": "wohali/oauth2-discord-new", - "version": "1.1.0", + "version": "1.2.1", "source": { "type": "git", "url": "https://github.com/wohali/oauth2-discord-new.git", - "reference": "0dcb5059cded358f55ae566de9621652cf8542c6" + "reference": "2df4d2a882e04c749880797704e4bde8f00ea1d9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/wohali/oauth2-discord-new/zipball/0dcb5059cded358f55ae566de9621652cf8542c6", - "reference": "0dcb5059cded358f55ae566de9621652cf8542c6", + "url": "https://api.github.com/repos/wohali/oauth2-discord-new/zipball/2df4d2a882e04c749880797704e4bde8f00ea1d9", + "reference": "2df4d2a882e04c749880797704e4bde8f00ea1d9", "shasum": "" }, "require": { - "league/oauth2-client": "^2.0" + "ext-json": "*", + "league/oauth2-client": "^2.0", + "php": "^7.2|^8.0" }, "conflict": { "team-reflex/oauth2-discord": ">=1.0" @@ -775,9 +934,9 @@ ], "support": { "issues": "https://github.com/wohali/oauth2-discord-new/issues", - "source": "https://github.com/wohali/oauth2-discord-new/tree/master" + "source": "https://github.com/wohali/oauth2-discord-new/tree/1.2.1" }, - "time": "2020-06-12T07:27:09+00:00" + "time": "2022-12-29T18:45:10+00:00" } ], "packages-dev": [], @@ -787,7 +946,8 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "ext-pdo": "*" + "ext-pdo": "*", + "ext-gd": "*" }, "platform-dev": [], "plugin-api-version": "2.3.0" diff --git a/docker-compose.yaml b/docker-compose.yaml index 522d0e24..b7742f7d 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -5,7 +5,7 @@ services: container_name: bivieh_devmarkt build: context: . - dockerfile: Dockerfile.debug + dockerfile: Dockerfile volumes: - ./:/var/www/ ports: diff --git a/opcache.ini b/opcache.ini new file mode 100644 index 00000000..6eba8b23 --- /dev/null +++ b/opcache.ini @@ -0,0 +1,9 @@ +[opcache] +opcache.enable=1 +opcache.revalidate_freq=0 +opcache.validate_timestamps=0 +opcache.max_accelerated_files=10000 +opcache.memory_consumption=192 +opcache.max_wasted_percentage=10 +opcache.interned_strings_buffer=16 +opcache.fast_shutdown=1 \ No newline at end of file diff --git a/php/login.inc.php b/php/login.inc.php index 279742cb..05d05c57 100644 --- a/php/login.inc.php +++ b/php/login.inc.php @@ -5,7 +5,6 @@ use GuzzleHttp\Client; use GuzzleHttp\Exception\GuzzleException; - class User { diff --git a/user.new.php b/user.new.php new file mode 100644 index 00000000..68161dee --- /dev/null +++ b/user.new.php @@ -0,0 +1,212 @@ +getDiscordID()); + +if (isset($_GET['block_user'])) { + + if ($login->isModerator()) { + + $blockID = testInput($_GET['block_user']); + $blockUser = new User($blockID); + + $blockUser->switchBlockState(); + + if (isset($_GET['from'])) { + + header('Location: case.php?req_id=' . $_GET['from']); + return; + + } + + } + +} + +if (!isset($_GET['user_id']) || !$login->isModerator()) { + header('Location: index.php'); +} + +$idUser = new User(($_GET['user_id'])); + +$accent_color = getAverage($idUser->getAvatarURL()); + +?> + + + + + + DevCord - Devmarkt + + + + + + + + + + + + + /assets/img/favicon.png"> + + + + + + + +
+ +
+ + getPDO(); + $stmt = 'SELECT * FROM `anfragen` WHERE `by_discord_id`=:user ORDER BY `id` DESC'; + $qry = $pdo->prepare($stmt); + $qry->bindParam(":user", $discordId, PDO::PARAM_STR); + $qry->execute(); + + $st = $qry->fetchAll(); + + foreach ($st as $request) { + + ?> + +
+
+
Datum:
+
Status:
+
+
+
+
+ + +
+
+ + + + $L2) { + $contrastRatio = (int)(($L1 + 0.05) / ($L2 + 0.05)); + } else { + $contrastRatio = (int)(($L2 + 0.05) / ($L1 + 0.05)); + } + + // If contrast is more than 5, return black color + if ($contrastRatio > 5) { + return '#000000'; + } else { + // if not, return white color. + return '#FFFFFF'; + } +} \ No newline at end of file