From 94daf8ad98b19afbd4320078b9d1ee25c9fb82f1 Mon Sep 17 00:00:00 2001 From: c+1 Date: Sun, 1 Sep 2024 21:48:56 -0400 Subject: Initial commit. Allows for the uploading of files. --- .gitignore | 2 ++ Makefile | 15 +++++++++++++++ config/config.php | 9 +++++++++ public/.htaccess | 10 ++++++++++ public/admin.php | 0 public/index.php | 47 +++++++++++++++++++++++++++++++++++++++++++++++ public/view.php | 0 util/src/id.c | 40 ++++++++++++++++++++++++++++++++++++++++ 8 files changed, 123 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 config/config.php create mode 100644 public/.htaccess create mode 100644 public/admin.php create mode 100644 public/index.php create mode 100644 public/view.php create mode 100644 util/src/id.c diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..27ae3b6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.out +uploads/* diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2294f74 --- /dev/null +++ b/Makefile @@ -0,0 +1,15 @@ +serve: + cd public && php -S 0.0.0.0:8000 + +CC = gcc +CFLAGS = -Wall -fsanitize=leak + +all: util/id.out + +util/id.out: util/src/id.c + $(CC) $(CFLAGS) $< -o $@ -lssl -lcrypto + +clean: + rm -f util/*.out + +.PHONY: all clean serve diff --git a/config/config.php b/config/config.php new file mode 100644 index 0000000..d6fcba7 --- /dev/null +++ b/config/config.php @@ -0,0 +1,9 @@ + diff --git a/public/.htaccess b/public/.htaccess new file mode 100644 index 0000000..e46b2d9 --- /dev/null +++ b/public/.htaccess @@ -0,0 +1,10 @@ +RewriteEngine On + +RewriteCond %{REQUEST_URI} ^/$ [OR] +RewriteCond %{REQUEST_URI} ^/index\.php$ +RewriteRule ^(.*)$ /index.php [L] + +RewriteCond %{QUERY_STRING} ^v=([a-zA-Z0-9\_\-\~\!\*]{8})$ +RewriteRule ^$ /view.php?v=%1 [L,QSA] + +RewriteRule ^admin\.php$ /admin.php [L] diff --git a/public/admin.php b/public/admin.php new file mode 100644 index 0000000..e69de29 diff --git a/public/index.php b/public/index.php new file mode 100644 index 0000000..f656154 --- /dev/null +++ b/public/index.php @@ -0,0 +1,47 @@ + $UPLOAD_MAX_SZ]) { + echo "File too large."; + } else { + if (move_uploaded_file($f['tmp_name'], $targetf)) { + $cmd = escapeshellcmd( + "$FILE_PROCESSING_CMD " . + escapeshellarg($targetf) + ); + + shell_exec($cmd); + echo "Uploaded."; + } else { + echo "Error uploading."; + } + } +} + +?> + + + +
+ + +