diff --git a/css/style.css b/css/style.css index 24ccde7..c8955f9 100644 --- a/css/style.css +++ b/css/style.css @@ -16,12 +16,18 @@ header, main, footer { margin: 0 auto; } +section { + border: 1px solid #666; + padding: 15px; + margin: 10px 0; +} +.height-100-75 { + height: calc(100% - 75px); +} + #bookmark { background-color: #333; } -.zfont { - font-size: 0; -} #img { z-index: -1; diff --git a/favicon.png b/favicon.ico similarity index 100% rename from favicon.png rename to favicon.ico diff --git a/index.php b/index.php index 13a505a..3841d2c 100644 --- a/index.php +++ b/index.php @@ -21,79 +21,87 @@ $alerts = [ 'danger' => [] ]; -$data = ['img' => '', 'name' => '', 'url' => '', 'desc' => '']; - try { $data = Storage::get($id); } catch(Exception $ex) { $alerts['danger'][] = '❌ Error reading database'; } +if (empty($data)) { + $data = [ + 'img' => '', + 'name' => '', + 'url' => '', + 'desc' => '' + ]; +} -$img = $data['img']; -// echo '
'; print_r($img); echo '
'; -$name = $data['name']; -$url = $data['url']; -$desc = $data['desc']; +$gallery = []; +if (file_exists("uppies/$id/gallery")) { + foreach(scandir("uppies/$id/gallery") as $g) { + if (in_array($g, ['.', '..', '.thumbs', '.DS_Store'])) + continue; + $gallery[] = $g; + } +} if ($_SERVER["REQUEST_METHOD"] === 'POST' && isset($_GET['upload'])) { - http_response_code(202); + $upload = htmlspecialchars($_GET['upload']); + http_response_code(202); # 202 is abused for errors, because uikit requires 2xx responses - $targetDir = "uppies/"; + $targetDir = "uppies/${id}/${upload}/"; $file = $_FILES["files"]; - $targetFile = $targetDir . basename($file["name"][0]); - $imageFileType = strtolower(pathinfo($targetFile, PATHINFO_EXTENSION)); + $fileName = basename($file["name"][0]); // Create the uploads directory if it doesn't exist if (!is_dir($targetDir)) { mkdir($targetDir, 0775, true); } - // Check if the file is actually an image - $check = getimagesize($file["tmp_name"][0]); - if ($check === false) { + // check if the file is actually an image + if (getimagesize($file["tmp_name"][0]) === false) { exit("❌ Error: File is not a valid image."); } - // Allow only specific image file formats - $allowedTypes = ["jpg", "jpeg", "png", "gif"]; - if (!in_array($imageFileType, $allowedTypes)) { + // allow only specific image extensions + if (!in_array(strtolower(pathinfo($fileName, PATHINFO_EXTENSION)), ["psd", "tiff", "jpg", "jpeg", "png", "gif"])) { exit("❌ Error: Only JPG, JPEG, PNG and GIF files allowed."); } - // Limit file size (e.g., 5MB) - if ($file["size"][0] > 100 * 1024 * 1024) { - exit("❌ Error: File too large (max. 100 MB)"); + // limit file size + if ($file["size"][0] > 200 * 1024 * 1024) { + exit("❌ Error: File too large (max. 200 MB)"); } - // generate destination file name - $finalPath = $targetDir . $id . '.' . $imageFileType; - // Move uploaded file to the target directory - if (move_uploaded_file($file["tmp_name"][0], $finalPath)) { + if (move_uploaded_file($file["tmp_name"][0], $targetDir . $fileName)) { + $data['img'] = $targetDir . $fileName; try { - Storage::set_img($id, $id . '.' . $imageFileType); + Storage::set($id, $data); } catch(Exception $ex) { exit("❌ Database error."); } http_response_code(200); - exit($finalPath); + exit(($upload === 'avatar'? $targetDir : '') . $fileName); + } + else { + exit("❌ Write Error."); } - exit("❌ General error saving the file."); + exit("❌ General error."); } else if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['desc']) && isset($_POST['name']) && isset($_POST['url'])) { - $name = htmlspecialchars(trim($_POST['name'])); - $url = htmlspecialchars(trim($_POST['url'])); - $desc = htmlspecialchars(trim($_POST['desc'])); + $data['name'] = htmlspecialchars(trim($_POST['name'])); + $data['url'] = htmlspecialchars(trim($_POST['url'])); + $data['desc'] = htmlspecialchars(trim($_POST['desc'])); - if (!empty($name) && !empty($desc) && !empty($url)) { + if (!empty($data['name']) && !empty($data['desc']) && !empty($data['url'])) { try { - Storage::set_data($id, $name, $url, $desc); - Telegram::report("EF Conbook Artist Credits Submission\nname: $name\nurl: $url\ntext:\n$desc"); + Storage::set($id, $data); + Telegram::report("EF Conbook Artist Credits Submission\nname: ". $data['name'] ."\nurl: ". $data['url'] ."\ntext:\n". $data['desc']); $alerts['success'][] = '✅ Entry saved'; } catch(Exception $ex) { @@ -116,14 +124,14 @@ else if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['desc']) && isset - + - + @@ -143,55 +151,75 @@ else if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['desc']) && isset
-

Conbook Artist Credit Form

+

Conbook Art Submission Form

- Thank you for submitting art to the Eurofurence Conbook. In the event of your art making an appearance in the book, your are eligible to an entry in the artist credits.
- Edit your entry below before the end of July to make sure you are credited appropriately. + A place for you to submit art to the Eurofurence Conbook and provide crediting information.
+ Deadline: End of July!

- -

Bookmark this page or save the following url to be able to edit your entry later:

-
-
- -
-
- -
-
+

Please make sure your images are large enough for DIN A4 printing. Don't worry about cropping or aspect ratio, we will adjust them into the layout ourselves.

-
-
-

Please make sure your profile image is large enough for print. Don't worry about cropping or aspect ratio, it will be adjusted into the layout by us.

-
-
-
-
- - - Upload Your Profile Image
PNG, JPG or GIF
min. 500 x 500 @ 300 dpi
-
- - SELECT FILE +
+
+

Personal Link

+

Bookmark or save it to edit your entry at a later time. Do not share it, unless with people you want to enable editing your information:

+
+
+ +
+
+ +
+
+
+ +
+ +
+
+

Your Credits Entry

+
+
+ + Upload Your Profile Image
PNG, JPG or GIF
min. 500 x 500 @ 300 dpi
+
+ + SELECT FILE +
+
+ +
+ + + + +
+
+ +
+

Your Contribution

+
- -
- -
-
- - - - -
- + \ No newline at end of file diff --git a/src/storage.php b/src/storage.php index 0064349..33fd5a1 100644 --- a/src/storage.php +++ b/src/storage.php @@ -21,10 +21,7 @@ class Storage { $db->exec("CREATE TABLE cache ( id TEXT NOT NULL UNIQUE, mod DATATIME DEFAULT (DATETIME('now', 'localtime')), - img TEXT, - name TEXT, - url TEXT, - desc TEXT, + data TEXT, PRIMARY KEY(id) );"); } @@ -38,7 +35,7 @@ class Storage { */ static public function get(string $id): array | bool { $db = Storage::init(); - $stmt = $db->prepare("SELECT name, url, desc, img FROM cache WHERE id=?;"); + $stmt = $db->prepare("SELECT data FROM cache WHERE id=?;"); if (!$stmt || !$stmt->bindValue(1, $id, SQLITE3_TEXT)) { throw new Exception($db->lastErrorMsg()); return false; @@ -49,9 +46,9 @@ class Storage { return false; } while ($row = $cur->fetchArray()) { - return ['img' => $row['img'], 'name' => $row['name'], 'url' => $row['url'], 'desc' => $row['desc']]; + return json_decode($row['data'], true); } - return ['img' => '', 'name' => '', 'url' => '', 'desc' => '']; + return []; } /** @@ -61,7 +58,7 @@ class Storage { static public function getAll(): array { $db = Storage::init(); $ret = []; - $stmt = $db->prepare("SELECT id, img, name, url, desc FROM cache;"); + $stmt = $db->prepare("SELECT id, data FROM cache;"); if (!$stmt) { throw new Exception($db->lastErrorMsg()); return $ret; @@ -72,7 +69,7 @@ class Storage { return $ret; } while ($row = $cur->fetchArray()) { - $ret[$row['id']] = [$row['img'], $row['name'], $row['url'], $row['desc']]; + $ret[$row['id']] = json_decode($row['data'], true); } return $ret; } @@ -83,20 +80,15 @@ class Storage { * @param array $data JSON-serializable data array to write to database. * @return bool Success indicator. */ - static public function set_data(string $id, string $name, string $url, string $desc): bool { - $db = Storage::init(); - $stmt = $db->prepare("INSERT INTO cache (id, name, url, desc) VALUES(?, ?, ?, ?) ON CONFLICT(id) DO UPDATE SET name=excluded.name, url=excluded.url, desc=excluded.desc, mod=excluded.mod;"); - if (!$stmt || !$stmt->bindValue(1, $id, SQLITE3_TEXT) || !$stmt->bindValue(2, $name, SQLITE3_TEXT) || !$stmt->bindValue(3, $url, SQLITE3_TEXT)|| !$stmt->bindValue(4, $desc, SQLITE3_TEXT) || !$stmt->execute()) { - throw new Exception($db->lastErrorMsg()); + static public function set(string $id, array $data): bool { + $db = Storage::init(); + $jdata = json_encode($data); + if ($jdata === false) { + throw new Exception(json_last_error_msg()); return false; } - return true; - } - - static public function set_img(string $id, string $img): bool { - $db = Storage::init(); - $stmt = $db->prepare("INSERT INTO cache (id, img) VALUES(?, ?) ON CONFLICT(id) DO UPDATE SET img=excluded.img, mod=excluded.mod;"); - if (!$stmt || !$stmt->bindValue(1, $id, SQLITE3_TEXT) || !$stmt->bindValue(2, $img, SQLITE3_TEXT) || !$stmt->execute()) { + $stmt = $db->prepare("INSERT INTO cache (id, data) VALUES(?, ?) ON CONFLICT(id) DO UPDATE SET data=excluded.data, mod=excluded.mod;"); + if (!$stmt || !$stmt->bindValue(1, $id, SQLITE3_TEXT) || !$stmt->bindValue(2, $jdata, SQLITE3_TEXT) || !$stmt->execute()) { throw new Exception($db->lastErrorMsg()); return false; }