Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Work toward pages to enter forum posts. This is an incremental check-in to save state and definitely does not work. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | forum-v2 |
Files: | files | file ages | folders |
SHA3-256: |
7b5099ea44a5b03e3bfc72e22f2c8690 |
User & Date: | drh 2018-07-24 19:44:30.767 |
Context
2018-07-24
| ||
22:01 | Always unlink prepared statements from the Stmt list prior to finalizing them. This prevents an error in db_finalize() from triggering a rollback and hence a recursive call to sqlite3_finalize(). ... (check-in: 42d821a7 user: drh tags: forum-v2) | |
19:44 | Work toward pages to enter forum posts. This is an incremental check-in to save state and definitely does not work. ... (check-in: 7b5099ea user: drh tags: forum-v2) | |
13:30 | Revamp the /register page for added security. Require entry of a display name and email address. Validate the email address format and check for duplicate email addresses. ... (check-in: d8b20a55 user: drh tags: forum-v2) | |
Changes
Changes to src/cgi.c.
︙ | ︙ | |||
1109 1110 1111 1112 1113 1114 1115 | } CGIDEBUG(("no-match [%s]\n", zName)); return zDefault; } /* ** Return the value of a CGI parameter with leading and trailing | | | | > > > > | | | 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 | } CGIDEBUG(("no-match [%s]\n", zName)); return zDefault; } /* ** Return the value of a CGI parameter with leading and trailing ** spaces removed and with internal \r\n changed to just \n */ char *cgi_parameter_trimmed(const char *zName, const char *zDefault){ const char *zIn; char *zOut, c; int i, j; zIn = cgi_parameter(zName, 0); if( zIn==0 ) zIn = zDefault; if( zIn==0 ) return 0; while( fossil_isspace(zIn[0]) ) zIn++; zOut = fossil_strdup(zIn); for(i=j=0; (c = zOut[i])!=0; i++){ if( c=='\r' && zOut[i+1]=='\n' ) continue; zOut[j++] = c; } zOut[j] = 0; while( i>0 && fossil_isspace(zOut[j-1]) ) zOut[--j] = 0; return zOut; } /* ** Return true if the CGI parameter zName exists and is not equal to 0, ** or "no" or "off". */ |
︙ | ︙ |
Changes to src/forum.c.
︙ | ︙ | |||
74 75 76 77 78 79 80 81 82 83 84 | @ query parameter</p> style_footer(); return; } forum_thread_chronological(froot); style_footer(); } /* ** WEBPAGE: forumnew ** | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > | | 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | @ query parameter</p> style_footer(); return; } forum_thread_chronological(froot); style_footer(); } /* ** Return true if a forum post should be moderated. */ static int forum_need_moderation(void){ return !g.perm.WrTForum && !g.perm.ModForum && P("domod")==0; } /* ** Add a new Forum Post artifact to the repository. */ static void forum_post( const char *zTitle, /* Title. NULL for replies */ int iInReplyTo, /* Post replying to. 0 for new threads */ int iEdit, /* Post being edited, or zero for a new post */ const char *zUser, /* Username. NULL means use login name */ const char *zMimetype, /* Mimetype of content. */ const char *zContent /* Content */ ){ Blob x, cksum; char *zDate; schema_forum(); blob_init(&x, 0, 0); zDate = date_in_standard_format("now"); blob_appendf(&x, "D %s\n", zDate); fossil_free(zDate); if( zTitle ){ blob_appendf(&x, "H %F\n", zTitle); }else{ char *zG = db_text(0, "SELECT uuid FROM blob, forumpost" " WHERE blob.rid==forumpost.froot" " AND forumpost.fpid=%d", iInReplyTo); char *zI; if( zG==0 ) goto forum_post_error; blob_appendf(&x, "G %s\n", zG); fossil_free(zG); zI = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", iInReplyTo); if( zI==0 ) goto forum_post_error; blob_appendf(&x, "I %s\n", zI); fossil_free(zI); } if( fossil_strcmp(zMimetype,"text/x-fossil-wiki")!=0 ){ blob_appendf(&x, "N %s\n", zMimetype); } if( iEdit>0 ){ char *zP = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", iEdit); if( zP==0 ) goto forum_post_error; blob_appendf(&x, "P %s\n", zP); fossil_free(zP); } if( zUser==0 ){ if( login_is_nobody() ){ zUser = "anonymous"; }else{ zUser = login_name(); } } blob_appendf(&x, "U %F\n", zUser); blob_appendf(&x, "W %d\n%s\n", strlen(zContent), zContent); md5sum_blob(&x, &cksum); blob_appendf(&x, "Z %b\n", &cksum); blob_reset(&cksum); if( P("dryrun") ){ @ <pre>%h(blob_str(&x))</pre><hr> }else{ wiki_put(&x, 0, forum_need_moderation()); return; } forum_post_error: blob_reset(&x); } /* ** Render a forum post for display */ void forum_render(const char *zMimetype, const char *zContent){ Blob x; blob_init(&x, zContent, -1); wiki_render_by_mimetype(&x, zMimetype); blob_reset(&x); } /* ** WEBPAGE: forumnew ** WEBPAGE: test-forumnew ** ** Start a new forum thread. The /test-forumnew works just like ** /forumnew except that it provides additional controls for testing ** and debugging. */ void forumnew_page(void){ const char *zTitle = PDT("t",""); const char *zMimetype = PD("mt","text/x-fossil-wiki"); const char *zContent = PDT("x",""); login_check_credentials(); if( !g.perm.WrForum ){ login_needed(g.anon.WrForum); return; } if( P("submit") ){ forum_post(zTitle, 0, 0, 0, zMimetype, zContent); } if( P("preview") ){ @ <h1>%h(zTitle)</h1> forum_render(zMimetype, zContent); @ <hr> } style_header("New Forum Thread"); @ <form action="%R/%s(g.zPath)" method="POST"> @ Title: <input type="input" name="t" value="%h(zTitle)" size="50"><br> @ Markup style: mimetype_option_menu(zMimetype); @ <br><textarea name="x" class="wikiedit" cols="80" \ @ rows="25" wrap="virtual">%h(zContent)</textarea><br> @ <input type="submit" name="preview" value="Preview"> if( P("preview") ){ @ <input type="submit" name="submit" value="Submit"> }else{ @ <input type="submit" name="submit" value="Submit" disabled> } if( g.zPath[0]=='t' ){ /* For the test-forumnew page add these extra debugging controls */ @ <br><label><input type="checkbox" name="dryrun" %s(PCK("dryrun"))> \ @ Dry run</label> @ <br><label><input type="checkbox" name="domod" %s(PCK("domod"))> \ @ Require moderator approval</label> } @ </form> style_footer(); } /* ** WEBPAGE: forumreply ** ** Reply to a forum message. |
︙ | ︙ |
Changes to src/manifest.c.
︙ | ︙ | |||
2464 2465 2466 2467 2468 2469 2470 | p->rDate, rid, p->zUser, blob_str(&comment)+1 ); blob_reset(&comment); } if( p->type==CFTYPE_FORUM ){ int froot, fprev, firt; schema_forum(); | | | 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 | p->rDate, rid, p->zUser, blob_str(&comment)+1 ); blob_reset(&comment); } if( p->type==CFTYPE_FORUM ){ int froot, fprev, firt; schema_forum(); froot = p->zThreadRoot ? uuid_to_rid(p->zThreadRoot, 1) : p->rid; fprev = p->nParent ? uuid_to_rid(p->azParent[0],1) : 0; firt = p->zInReplyTo ? uuid_to_rid(p->zInReplyTo,1) : 0; db_multi_exec( "INSERT INTO forumpost(fpid,froot,fprev,firt,fmtime)" "VALUES(%d,%d,nullif(%d,0),nullif(%d,0),%.17g)", p->rid, froot, fprev, firt, p->rDate ); |
︙ | ︙ |
Changes to src/schema.c.
︙ | ︙ | |||
554 555 556 557 558 559 560 | /* ** The following table holds information about forum posts. It ** is created on-demand whenever the manifest parser encounters ** a forum-post artifact. */ static const char zForumSchema[] = @ CREATE TABLE repository.forumpost( | | | | | | | 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 | /* ** The following table holds information about forum posts. It ** is created on-demand whenever the manifest parser encounters ** a forum-post artifact. */ static const char zForumSchema[] = @ CREATE TABLE repository.forumpost( @ fpid INTEGER PRIMARY KEY, -- BLOB.rid for the artifact @ froot INT, -- fpid of the thread root @ fprev INT, -- Previous version of this same post @ firt INT, -- This post is in-reply-to @ fmtime REAL -- When posted. Julian day @ ); @ CREATE INDEX repository.forumthread ON forumpost(froot); ; /* Create the forum-post schema if it does not already exist */ void schema_forum(void){ if( !db_table_exists("repository","forumpost") ){ |
︙ | ︙ |
Changes to src/wiki.c.
︙ | ︙ | |||
424 425 426 427 428 429 430 | manifest_destroy(pWiki); style_footer(); } /* ** Write a wiki artifact into the repository */ | | | 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 | manifest_destroy(pWiki); style_footer(); } /* ** Write a wiki artifact into the repository */ void wiki_put(Blob *pWiki, int parent, int needMod){ int nrid; if( !needMod ){ nrid = content_put_ex(pWiki, 0, 0, 0, 0); if( parent) content_deltify(parent, &nrid, 1, 0); }else{ nrid = content_put_ex(pWiki, 0, 0, 0, 1); moderation_table_create(); |
︙ | ︙ |