Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | If the user is not logged in, prompt them to do so before continuing to the forum entry pages. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | forum-v2 |
Files: | files | file ages | folders |
SHA3-256: |
009ca1f74e48b232cd7ac5762ab4b454 |
User & Date: | drh 2018-07-31 01:03:33.110 |
Context
2018-07-31
| ||
03:14 | Enable search over the forum. ... (check-in: b3c1ba37 user: drh tags: forum-v2) | |
01:03 | If the user is not logged in, prompt them to do so before continuing to the forum entry pages. ... (check-in: 009ca1f7 user: drh tags: forum-v2) | |
2018-07-30
| ||
23:29 | Improved login screen with a "Create A New Account" button. ... (check-in: 14335899 user: drh tags: forum-v2) | |
Changes
Changes to src/forum.c.
︙ | ︙ | |||
629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 | mimetype_option_menu(zMimetype); @ <br><textarea name="content" class="wikiedit" cols="80" \ @ rows="25" wrap="virtual">%h(zContent)</textarea><br> } /* ** WEBPAGE: forumnew ** ** Start a new forum thread. */ void forumnew_page(void){ const char *zTitle = PDT("title",""); const char *zMimetype = PD("mimetype","text/x-fossil-wiki"); const char *zContent = PDT("content",""); login_check_credentials(); if( !g.perm.WrForum ){ login_needed(g.anon.WrForum); return; } if( P("submit") ){ if( forum_post(zTitle, 0, 0, 0, zMimetype, zContent) ) return; } if( P("preview") ){ @ <h1>Preview:</h1> forum_render(zTitle, zMimetype, zContent, "forumEdit"); } style_header("New Forum Thread"); | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > | 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 | mimetype_option_menu(zMimetype); @ <br><textarea name="content" class="wikiedit" cols="80" \ @ rows="25" wrap="virtual">%h(zContent)</textarea><br> } /* ** WEBPAGE: forumnew ** WEBPAGE: forumedit ** ** Start a new thread on the forum or reply to an existing thread. ** But first prompt to see if the user would like to log in. */ void forum_page_init(void){ int isEdit; char *zGoto; login_check_credentials(); if( !g.perm.WrForum ){ login_needed(g.anon.WrForum); return; } if( sqlite3_strglob("*edit*", g.zPath)==0 ){ zGoto = mprintf("%R/forume2?fpid=%S",PD("fpid","")); isEdit = 1; }else{ zGoto = mprintf("%R/forume1"); isEdit = 0; } if( login_is_individual() ){ if( isEdit ){ forumedit_page(); }else{ forumnew_page(); } return; } style_header("%h As Anonymous?", isEdit ? "Reply" : "Post"); @ <p>You are not logged in. @ <p><table border="0" cellpadding="10"> @ <tr><td> @ <form action="%s(zGoto)" method="POST"> @ <input type="submit" value="Remain Anonymous"> @ </form> @ <td>Post to the forum anonymously if( login_self_register_available(0) ){ @ <tr><td> @ <form action="%R/register" method="POST"> @ <input type="hidden" name="g" value="%s(zGoto)"> @ <input type="submit" value="Create An Account"> @ </form> @ <td>Create a new account and post using that new account } @ <tr><td> @ <form action="%R/login" method="POST"> @ <input type="hidden" name="g" value="%s(zGoto)"> @ <input type="hidden" name="noanon" value="1"> @ <input type="submit" value="Login"> @ </form> @ <td>Log into an existing account @ </table> style_footer(); fossil_free(zGoto); } /* ** Write the "From: USER" line on the webpage. */ static void forum_from_line(void){ if( login_is_nobody() ){ @ From: anonymous<br> }else{ @ From: %h(login_name())<br> } } /* ** WEBPAGE: forume1 ** ** Start a new forum thread. */ void forumnew_page(void){ const char *zTitle = PDT("title",""); const char *zMimetype = PD("mimetype","text/x-fossil-wiki"); const char *zContent = PDT("content",""); login_check_credentials(); if( !g.perm.WrForum ){ login_needed(g.anon.WrForum); return; } if( P("submit") ){ if( forum_post(zTitle, 0, 0, 0, zMimetype, zContent) ) return; } if( P("preview") ){ @ <h1>Preview:</h1> forum_render(zTitle, zMimetype, zContent, "forumEdit"); } style_header("New Forum Thread"); @ <form action="%R/forume1" method="POST"> @ <h1>New Message:</h1> forum_from_line(); forum_entry_widget(zTitle, zMimetype, zContent); @ <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> } |
︙ | ︙ | |||
673 674 675 676 677 678 679 | @ </div> } @ </form> style_footer(); } /* | | | | 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 | @ </div> } @ </form> style_footer(); } /* ** WEBPAGE: forume2 ** ** Edit an existing forum message. ** Query parameters: ** ** fpid=X Hash of the post to be editted. REQUIRED */ void forumedit_page(void){ int fpid; Manifest *pPost; const char *zMimetype = 0; const char *zContent = 0; const char *zTitle = 0; |
︙ | ︙ | |||
739 740 741 742 743 744 745 | if( pPost->zThreadTitle ) zTitle = ""; style_header("Delete %s", zTitle ? "Post" : "Reply"); @ <h1>Original Post:</h1> forum_render(pPost->zThreadTitle, pPost->zMimetype, pPost->zWiki, "forumEdit"); @ <h1>Change Into:</h1> forum_render(zTitle, zMimetype, zContent,"forumEdit"); | | | 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 | if( pPost->zThreadTitle ) zTitle = ""; style_header("Delete %s", zTitle ? "Post" : "Reply"); @ <h1>Original Post:</h1> forum_render(pPost->zThreadTitle, pPost->zMimetype, pPost->zWiki, "forumEdit"); @ <h1>Change Into:</h1> forum_render(zTitle, zMimetype, zContent,"forumEdit"); @ <form action="%R/forume2" method="POST"> @ <input type="hidden" name="fpid" value="%h(P("fpid"))"> @ <input type="hidden" name="nullout" value="1"> @ <input type="hidden" name="mimetype" value="%h(zMimetype)"> @ <input type="hidden" name="content" value="%h(zContent)"> if( zTitle ){ @ <input type="hidden" name="title" value="%h(zTitle)"> } |
︙ | ︙ | |||
765 766 767 768 769 770 771 | @ <h1>Original Post:</h1> forum_render(pPost->zThreadTitle, pPost->zMimetype, pPost->zWiki, "forumEdit"); if( P("preview") ){ @ <h1>Preview Of Editted Post:</h1> forum_render(zTitle, zMimetype, zContent,"forumEdit"); } | | | > | | > | 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 | @ <h1>Original Post:</h1> forum_render(pPost->zThreadTitle, pPost->zMimetype, pPost->zWiki, "forumEdit"); if( P("preview") ){ @ <h1>Preview Of Editted Post:</h1> forum_render(zTitle, zMimetype, zContent,"forumEdit"); } @ <h1>Revised Message:</h1> @ <form action="%R/forume2" method="POST"> @ <input type="hidden" name="fpid" value="%h(P("fpid"))"> @ <input type="hidden" name="edit" value="1"> forum_from_line(); forum_entry_widget(zTitle, zMimetype, zContent); }else{ /* Reply */ zMimetype = PD("mimetype","text/x-fossil-wiki"); zContent = PDT("content",""); style_header("Reply"); @ <h1>Replying To:</h1> forum_render(0, pPost->zMimetype, pPost->zWiki, "forumEdit"); if( P("preview") ){ @ <h1>Preview:</h1> forum_render(0, zMimetype,zContent, "forumEdit"); } @ <h1>Enter Reply:</h1> @ <form action="%R/forume2" method="POST"> @ <input type="hidden" name="fpid" value="%h(P("fpid"))"> @ <input type="hidden" name="reply" value="1"> forum_from_line(); forum_entry_widget(0, zMimetype, zContent); } if( !isDelete ){ @ <input type="submit" name="preview" value="Preview"> } @ <input type="submit" name="cancel" value="Cancel"> if( P("preview") || isDelete ){ |
︙ | ︙ |
Changes to src/login.c.
︙ | ︙ | |||
514 515 516 517 518 519 520 521 522 523 524 525 526 527 | const char *zGoto = P("g"); int anonFlag; /* Login as "anonymous" would be useful */ char *zErrMsg = ""; int uid; /* User id logged in user */ char *zSha1Pw; const char *zIpAddr; /* IP address of requestor */ const char *zReferer; login_check_credentials(); if( login_wants_https_redirect() ){ const char *zQS = P("QUERY_STRING"); if( P("redir")!=0 ){ style_header("Insecure Connection"); @ <h1>Unable To Establish An Encrypted Connection</h1> | > | 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 | const char *zGoto = P("g"); int anonFlag; /* Login as "anonymous" would be useful */ char *zErrMsg = ""; int uid; /* User id logged in user */ char *zSha1Pw; const char *zIpAddr; /* IP address of requestor */ const char *zReferer; int noAnon = P("noanon")!=0; login_check_credentials(); if( login_wants_https_redirect() ){ const char *zQS = P("QUERY_STRING"); if( P("redir")!=0 ){ style_header("Insecure Connection"); @ <h1>Unable To Establish An Encrypted Connection</h1> |
︙ | ︙ | |||
653 654 655 656 657 658 659 | login_set_user_cookie(zUsername, uid, NULL); redirect_to_g(); } } style_header("Login/Logout"); style_adunit_config(ADUNIT_OFF); @ %s(zErrMsg) | | | 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 | login_set_user_cookie(zUsername, uid, NULL); redirect_to_g(); } } style_header("Login/Logout"); style_adunit_config(ADUNIT_OFF); @ %s(zErrMsg) if( zGoto && !noAnon ){ char *zAbbrev = fossil_strdup(zGoto); int i; for(i=0; zAbbrev[i] && zAbbrev[i]!='?'; i++){} zAbbrev[i] = 0; if( g.zLogin ){ @ <p>Use a different login with greater privilege than <b>%h(g.zLogin)</b> @ to access <b>%h(zAbbrev)</b>. |
︙ | ︙ | |||
725 726 727 728 729 730 731 | } @ <tr> @ <td></td> @ <td><input type="submit" name="in" value="Login"></td> @ <td colspan="2">← Pressing this button grants\ @ permission to store a cookie @ </tr> | | | | 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 | } @ <tr> @ <td></td> @ <td><input type="submit" name="in" value="Login"></td> @ <td colspan="2">← Pressing this button grants\ @ permission to store a cookie @ </tr> if( !noAnon && login_self_register_available(0) ){ @ <tr> @ <td></td> @ <td><input type="submit" name="self" value="Create A New Account"> @ <td colspan="2"> \ @ ← Don't have a login? Click this button to create one. @ </tr> } @ </table> if( zAnonPw && !noAnon ){ unsigned int uSeed = captcha_seed(); const char *zDecoded = captcha_decode(uSeed); int bAutoCaptcha = db_get_boolean("auto-captcha", 0); char *zCaptcha = captcha_render(zDecoded); @ <p><input type="hidden" name="cs" value="%u(uSeed)" /> @ Visitors may enter <b>anonymous</b> as the user-ID with |
︙ | ︙ |