From 7a464f7d36659608b89a65d6af8ad0a6d645dfe3 Mon Sep 17 00:00:00 2001 From: Go Johansson Date: Fri, 16 Dec 2022 22:11:57 +0100 Subject: [PATCH] tests --- Makefile | 20 +++++------- composer.json | 31 ------------------ src/composer.json | 31 ++++++++++++++++++ src/config.json | 1 + src/static/php/grill.php | 70 ++++++++++++++++++++++++++-------------- 5 files changed, 85 insertions(+), 68 deletions(-) delete mode 100644 composer.json create mode 100644 src/composer.json diff --git a/Makefile b/Makefile index f044aac..6c87a9e 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ MODULES="php" pageList = $(shell $(CURDIR)/$(NODEJQ) -r ".pages[]" $(CURDIR)/$(CONF)) noExt = $(shell echo $(i) | cut -d '.' -f1) -all: builddirs npm_dependencies composer ejs minify-all copy-img copy-php +all: builddirs npm_dependencies ejs minify-all copy-img copy-php ejs: $(foreach i,$(pageList), \ @@ -43,12 +43,11 @@ copy-img: copy-php: cp -v $(CURDIR)/src/static/php/*.php $(CURDIR)/build/php/ - cp -v $(CURDIR)/src/Classes/*.php $(CURDIR)/build/php/classes/ + cp -v $(CURDIR)/src/Classes/*.php $(CURDIR)/build/php/includes/Classes/ install: installdirs cp -rv $(CURDIR)/build/* $(DESTDIR)/ - cp -rv $(CURDIR)/vendor $(DESTDIR)/ - cp $(CURDIR)/src/config.json $(DESTDIR)/ + cp $(CURDIR)/src/*.json $(DESTDIR)/ mv $(DESTDIR)/html/min/* $(DESTDIR)/public/ mv $(DESTDIR)/js/* $(DESTDIR)/public/ mv $(DESTDIR)/css/* $(DESTDIR)/public/ @@ -62,6 +61,10 @@ install: installdirs mv $(DESTDIR)/img $(DESTDIR)/public/ mv $(DESTDIR)/grill.php $(DESTDIR)/public/ mv $(DESTDIR)/upload.php $(DESTDIR)/public/ + cd $(DESTDIR)/ && $(CURL) -o composer-setup.php https://raw.githubusercontent.com/composer/getcomposer.org/main/web/installer + cd $(DESTDIR)/ && $(PHP) composer-setup.php --quiet + cd $(DESTDIR)/ && rm composer-setup.php + cd $(DESTDIR)/ && php composer.phar update && php composer.phar install && php composer.phar dump-autoload dist: DESTDIR=$(TMPDIR)/uguu-$(PKGVERSION) @@ -83,13 +86,6 @@ uninstall: npm_dependencies: $(NPM) install -composer: - $(CURL) -o composer-setup.php https://raw.githubusercontent.com/composer/getcomposer.org/main/web/installer - $(PHP) composer-setup.php --quiet - rm composer-setup.php - php composer.phar update - php composer.phar install - build-image: tar --exclude='./uguuForDocker.tar.gz' --exclude='./vendor' --exclude='./node_modules' -czf uguuForDocker.tar.gz . mv uguuForDocker.tar.gz docker/ @@ -104,5 +100,5 @@ purge-container: fi; builddirs: - mkdir -p $(CURDIR)/build $(CURDIR)/build/img $(CURDIR)/build/html $(CURDIR)/build/html/min $(CURDIR)/build/html/unmin $(CURDIR)/build/js $(CURDIR)/build/css $(CURDIR)/build/php $(CURDIR)/build/php/classes $(CURDIR)/build/public + mkdir -p $(CURDIR)/build $(CURDIR)/build/img $(CURDIR)/build/html $(CURDIR)/build/html/min $(CURDIR)/build/html/unmin $(CURDIR)/build/js $(CURDIR)/build/css $(CURDIR)/build/php $(CURDIR)/build/php/includes $(CURDIR)/build/php/includes/Classes $(CURDIR)/build/public diff --git a/composer.json b/composer.json deleted file mode 100644 index 6df3b68..0000000 --- a/composer.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name": "pomf/uguu", - "description": "Uguu is a simple lightweight temporary file host with support for drop, paste, click and API uploading.", - "type": "library", - "license": "GPL-3.0", - "autoload": { - "psr-4": { - "Pomf\\Uguu\\": "src/", - "Pomf\\Uguu\\Classes\\": "src/Classes" - } - }, - "authors": [ - { - "name": "Go Johansson (neku)", - "email": "neku@pomf.se" - } - ], - "minimum-stability": "stable", - "require": { - "ext-fileinfo": "*", - "ext-pdo": "*" - }, - "require-dev": { - "phpunit/phpunit": "^9.5.27", - "squizlabs/php_codesniffer": "^3.7.1", - "phpmd/phpmd": "^2.13.0", - "friendsofphp/php-cs-fixer": "^v2.19.3", - "phpstan/phpstan": "^1.9.3", - "vimeo/psalm": "^5.2.0" - } -} diff --git a/src/composer.json b/src/composer.json new file mode 100644 index 0000000..e54a892 --- /dev/null +++ b/src/composer.json @@ -0,0 +1,31 @@ +{ + "name": "pomf/uguu", + "description": "Uguu is a simple lightweight temporary file host with support for drop, paste, click and API uploading.", + "type": "library", + "license": "GPL-3.0", + "autoload": { + "psr-4": { + "Pomf\\Uguu\\": "/", + "Pomf\\Uguu\\Classes\\": "includes/Classes" + } + }, + "authors": [ + { + "name": "Go Johansson (neku)", + "email": "neku@pomf.se" + } + ], + "minimum-stability": "stable", + "require": { + "ext-fileinfo": "*", + "ext-pdo": "*" + }, + "require-dev": { + "phpunit/phpunit": "^9.5.27", + "squizlabs/php_codesniffer": "^3.7.1", + "phpmd/phpmd": "^2.13.0", + "friendsofphp/php-cs-fixer": "^v2.19.3", + "phpstan/phpstan": "^1.9.3", + "vimeo/psalm": "^5.2.0" + } +} \ No newline at end of file diff --git a/src/config.json b/src/config.json index 5bcea55..d142fcd 100755 --- a/src/config.json +++ b/src/config.json @@ -39,6 +39,7 @@ "FILES_URL": "https://files.domain.com", "NAME_LENGTH": 8, "ID_CHARSET": "abcdefghijklmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ", + "PHP_ERRORS": true, "BLOCKED_EXTENSIONS": [ "exe", "scr", diff --git a/src/static/php/grill.php b/src/static/php/grill.php index b11e1e1..d193949 100644 --- a/src/static/php/grill.php +++ b/src/static/php/grill.php @@ -1,26 +1,46 @@ - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -require_once __DIR__ . '/../vendor/autoload.php'; - -use Pomf\Uguu\GrillLoader; - -new GrillLoader(); + + function checkConfig() + { + if (!file_exists(__DIR__ . '../config.json')) { + throw new Exception('Cant read settings file.', 500); + } + try { + $settings = json_decode( + file_get_contents(__DIR__ . '../config.json'), + true, + ); + if ($settings['PHP_ERRORS']) { + error_reporting(E_ALL); + ini_set('display_errors', 1); + } + } + catch (Exception) { + throw new Exception('Cant populate settings.', 500); + } + } + + checkConfig(); + /** + * Uguu + * + * @copyright Copyright (c) 2022 Go Johansson (nokonoko) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + require_once __DIR__ . '/../vendor/autoload.php'; + + use Pomf\Uguu\GrillLoader; + + new GrillLoader();