commit 28cdf2d54a134510be3f2fec63ca83c1c7209649 Author: root Date: Wed Mar 22 22:10:33 2023 +0000 Init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d4a0307 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +i/* diff --git a/config.php b/config.php new file mode 100644 index 0000000..63ffab9 --- /dev/null +++ b/config.php @@ -0,0 +1,15 @@ + +$title = "imgpaste by gideonstar"; + +// Displayed text +$text = "Drop image here..."; + +// Writable data directory for images +$datadir = "i"; + +// Length of filenames +$hashlen = 8; + +?> diff --git a/index.php b/index.php new file mode 100644 index 0000000..06b9212 --- /dev/null +++ b/index.php @@ -0,0 +1,18 @@ + + + + + + + <?php echo $title; ?> + + + +
+
+

+
+
+ + + diff --git a/robots.txt b/robots.txt new file mode 100644 index 0000000..1f53798 --- /dev/null +++ b/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: / diff --git a/script.js b/script.js new file mode 100644 index 0000000..67d2d3a --- /dev/null +++ b/script.js @@ -0,0 +1,61 @@ +dropzone = document.getElementById('dropzone'); + +dropzone.addEventListener('dragover', function(e) +{ + e.preventDefault(); + this.classList.remove('nodrop'); + this.classList.add('drop'); +}); + +dropzone.addEventListener('dragleave', function(e) +{ + e.preventDefault(); + this.classList.remove('drop'); + this.classList.add('nodrop'); +}); + +/*dropzone.addEventListener('click', function(e) +{ + e.preventDefault(); + + input = document.createElement('input'); + input.type = 'file'; + input.click(); +});*/ + +dropzone.addEventListener('drop', function(e) +{ + e.preventDefault(); + this.classList.remove('drop'); + this.classList.add('nodrop'); + + file = e.dataTransfer.files[0]; + if( + file.type == 'image/png' || + file.type == 'image/jpeg' ) + { + upload(e.dataTransfer.files[0]); + } +}); + +function upload(file) { + const data = new FormData(); + data.append('upload', file) + + fetch('upload.php', + { + method: 'POST', + body: data + }).then(response => + { + response.json().then(parsedValue => { + filename = parsedValue['filename']; + datadir = parsedValue['datadir']; + openUploadedFile(datadir, filename); + }) + }); +}; + +function openUploadedFile(datadir, filename) { + window.open(window.location.href + datadir + '/' + filename, '_self'); +}; diff --git a/sora.ttf b/sora.ttf new file mode 100644 index 0000000..0960fb4 Binary files /dev/null and b/sora.ttf differ diff --git a/style.css b/style.css new file mode 100644 index 0000000..0786f1b --- /dev/null +++ b/style.css @@ -0,0 +1,47 @@ +:root { + --round: 20px; + --border: 100px; +} + +@font-face { + font-family: 'Sora'; + src: url('sora.ttf'); +} + +* { + margin: 0; + padding: 0; +} + +body { + background-color: #101010; + font-family: 'Sora'; + font-size: 14px; +} + +#wrapper { + width: 100vw; + height: 100vh; + display: flex; + align-items: center; + justify-content: center; +} + +#dropzone { + width: calc(100vw - var(--border)); + height: calc(100vh - var(--border)); + border-radius: var(--round); + display: flex; + align-items: center; + justify-content: center; +} + +.nodrop { + background-color: #f5f5f5; + outline: 2px dashed #d5d5d5; +} + +.drop { + background-color: #ffb703; + outline: 2px dashed #fb8500; +} diff --git a/upload.php b/upload.php new file mode 100644 index 0000000..3d4170f --- /dev/null +++ b/upload.php @@ -0,0 +1,23 @@ + $datadir, 'filename' => $filename]); +} + +function generate_hash(int $length) { + $hash = ""; + for($i = 0; $i < $length; $i++) { + $chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + $random_char = $chars[rand(0, strlen($chars) - 1)]; + $hash = $hash . $random_char; + } + return $hash; +} + +?>