Commit | Line | Data |
---|---|---|
cd757b9e | 1 | <html> |
a7fc328e JC |
2 | <head> |
3 | <link rel="stylesheet" href="style.css"> | |
4 | </head> | |
5 | ||
6 | <body> | |
7 | <main> | |
cd757b9e JC |
8 | <a href='upload.php'>Upload</a> |
9 | <?php | |
10 | ||
11 | require_once __DIR__ . '/db.php'; | |
12 | ||
13 | $db = get_db(); | |
80f2f42a JC |
14 | $posts = $db->query('SELECT |
15 | p.ID, p.TIMESTAMP, pi.MIME_TYPE, pi.PIC_B64, c.BODY | |
16 | FROM posts p | |
17 | JOIN pics pi on p.id = pi.post_id | |
18 | JOIN comments c on p.id = c.post_id | |
19 | ORDER BY p.TIMESTAMP DESC'); | |
20 | while ($post = $posts->fetchArray()) { | |
21 | $mime_type = $post['MIME_TYPE']; | |
22 | $file_b64 = $post['PIC_B64']; | |
23 | $post_id = $post['ID']; | |
24 | $comment_text = $post['BODY']; | |
25 | $img = new Imagick(); | |
26 | $img->readImageBlob(base64_decode($file_b64)); | |
27 | $img->setImageCompressionQuality(85); | |
28 | $img->adaptiveResizeImage(480, 0); | |
29 | $compressed_b64 = base64_encode($img->getImageBlob()); | |
cd757b9e | 30 | |
80f2f42a JC |
31 | echo "<div id='post-{$post_id}'>"; |
32 | ||
33 | echo "<img src='data:{$mime_type};base64,{$compressed_b64}' alt='$'/>"; | |
34 | echo "<p>{$comment_text}</p>"; | |
35 | echo '</div>'; | |
cd757b9e | 36 | } |
cd757b9e | 37 | ?> |
a7fc328e JC |
38 | </main> |
39 | </body> | |
cd757b9e | 40 | </html> |