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