]> jfr.im git - uguu.git/commitdiff
tests
authorGo Johansson <redacted>
Fri, 16 Dec 2022 21:11:57 +0000 (22:11 +0100)
committerGo Johansson <redacted>
Fri, 16 Dec 2022 21:11:57 +0000 (22:11 +0100)
Makefile
composer.json [deleted file]
src/composer.json [new file with mode: 0644]
src/config.json
src/static/php/grill.php

index f044aac5b7f181963eeea75ca1768549a2a1f9a2..6c87a9ee3450dd33eb5f7466a6447fd46cf8edb7 100644 (file)
--- 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 (file)
index 6df3b68..0000000
+++ /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 (file)
index 0000000..e54a892
--- /dev/null
@@ -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
index 5bcea55f0e561b3e9eb4e7a5344d24e7b175ca4b..d142fcd631136a9ce91f3b0fc94d4fec792799b6 100755 (executable)
@@ -39,6 +39,7 @@
   "FILES_URL": "https://files.domain.com",
   "NAME_LENGTH": 8,
   "ID_CHARSET": "abcdefghijklmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ",
+  "PHP_ERRORS": true,
   "BLOCKED_EXTENSIONS": [
     "exe",
     "scr",
index b11e1e1fe2b1cde7b0af5fea067d6e536a312686..d193949355f18f231a358b61aabe74df83c8dc05 100644 (file)
@@ -1,26 +1,46 @@
 <?php
-
-/**
- * Uguu
- *
- * @copyright Copyright (c) 2022 Go Johansson (nokonoko) <neku@pomf.se>
- *
- * 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 <https://www.gnu.org/licenses/>.
- */
-
-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) <neku@pomf.se>
+     *
+     * 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 <https://www.gnu.org/licenses/>.
+     */
+    require_once __DIR__ . '/../vendor/autoload.php';
+    
+    use Pomf\Uguu\GrillLoader;
+    
+    new GrillLoader();