diff options
author | John Ankarström <john@ankarstrom.se> | 2021-09-17 23:47:58 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2021-09-17 23:47:58 +0200 |
commit | 7d65ce8c8e304dc8367f4492948514f2acc07a3b (patch) | |
tree | 1d1e8584ad326cf3ea7701e2a726a0f0ae1cb6cf /ctl.c | |
parent | 56509ab16c8d2225182eb0400e5c6a4900870391 (diff) | |
download | cforum-7d65ce8c8e304dc8367f4492948514f2acc07a3b.tar.gz |
Whatever
Diffstat (limited to 'ctl.c')
-rw-r--r-- | ctl.c | 20 |
1 files changed, 11 insertions, 9 deletions
@@ -22,12 +22,18 @@ void showfront() { char *title; + sqlite3_stmt *stmt; + + if(sqlite3_prepare(db, + "SELECT oid, * from posts ORDER BY created DESC", + -1, &stmt, 0) != SQLITE_OK){ + srverr("Could not retrieve posts"); + return; + } title = site.name; printf("Content-Type: text/html\n\n"); - #include "t/head.tc" #include "t/front.tc" - #include "t/foot.tc" } void @@ -37,21 +43,19 @@ showpost(int id) struct post *post; struct user *user; - if(!(post = getpost(id))){ + if(!(post = getpost(byid("posts", id), 1))){ srverr("Could not retrieve post"); return; } - if(!(user = getuser(post->user))){ + if(!(user = getuser(byid("users", post->user), 1))){ srverr("Could not retrieve post author"); return; } title = site.name; printf("Content-Type: text/html\n\n"); - #include "t/head.tc" #include "t/post.tc" - #include "t/foot.tc" } void @@ -60,15 +64,13 @@ showuser(int id) char s[128], *title; struct user *user; - if(!(user = getuser(id))){ + if(!(user = getuser(byid("users", id), 1))){ srverr("Could not retrieve user"); return; } title = site.name; printf("Content-Type: text/html\n\n"); - #include "t/head.tc" #include "t/user.tc" - #include "t/foot.tc" free(user); }
\ No newline at end of file |