Fossil SCM
Add the /msgadmin page.
Commit
0c4d3c128ae0df31c619f6b2ea04be19b0ee369661cf287e8f17c272d96c1900
Parent
d4e9df1729ced90…
1 file changed
+95
+95
| --- src/email.c | ||
| +++ src/email.c | ||
| @@ -1788,5 +1788,100 @@ | ||
| 1788 | 1788 | } |
| 1789 | 1789 | |
| 1790 | 1790 | autoexec_done: |
| 1791 | 1791 | db_end_transaction(0); |
| 1792 | 1792 | } |
| 1793 | + | |
| 1794 | +/* | |
| 1795 | +** WEBPAGE: msgadmin | |
| 1796 | +** | |
| 1797 | +** A web-form to send a message to the repository administrator. | |
| 1798 | +*/ | |
| 1799 | +void msgadmin_page(void){ | |
| 1800 | + const char *zAdminEmail = db_get("email-admin",0); | |
| 1801 | + unsigned int uSeed; | |
| 1802 | + const char *zDecoded; | |
| 1803 | + char *zCaptcha = 0; | |
| 1804 | + | |
| 1805 | + if( zAdminEmail==0 || zAdminEmail[0]==0 ){ | |
| 1806 | + style_header("Admin Messaging Disabled"); | |
| 1807 | + @ <p>Messages to the administrator are disabled on this repository | |
| 1808 | + style_footer(); | |
| 1809 | + return; | |
| 1810 | + } | |
| 1811 | + if( P("submit")!=0 | |
| 1812 | + && P("subject")!=0 | |
| 1813 | + && P("msg")!=0 | |
| 1814 | + && P("from")!=0 | |
| 1815 | + && cgi_csrf_safe(1) | |
| 1816 | + && captcha_is_correct(0) | |
| 1817 | + ){ | |
| 1818 | + Blob hdr, body; | |
| 1819 | + EmailSender *pSender = email_sender_new(0,0); | |
| 1820 | + blob_init(&hdr, 0, 0); | |
| 1821 | + blob_appendf(&hdr, "To: %s\nSubject: %s administrator message\n", | |
| 1822 | + zAdminEmail, db_get("email-subname","Fossil Repo")); | |
| 1823 | + blob_init(&body, 0, 0); | |
| 1824 | + blob_appendf(&body, "Message from [%s]\n", PT("from")/*safe-for-%s*/); | |
| 1825 | + blob_appendf(&body, "Subject: [%s]\n\n", PT("subject")/*safe-for-%s*/); | |
| 1826 | + blob_appendf(&body, "%s", PT("msg")/*safe-for-%s*/); | |
| 1827 | + email_send(pSender, &hdr, &body); | |
| 1828 | + style_header("Message Sent"); | |
| 1829 | + if( pSender->zErr ){ | |
| 1830 | + @ <h1>Internal Error</h1> | |
| 1831 | + @ <p>The following error was reported by the system: | |
| 1832 | + @ <blockquote><pre> | |
| 1833 | + @ %h(pSender->zErr) | |
| 1834 | + @ </pre></blockquote> | |
| 1835 | + }else{ | |
| 1836 | + @ <p>Your message has been sent to the repository administrator. | |
| 1837 | + @ Thank you for your input.</p> | |
| 1838 | + } | |
| 1839 | + email_sender_free(pSender); | |
| 1840 | + style_footer(); | |
| 1841 | + return; | |
| 1842 | + } | |
| 1843 | + if( captcha_needed() ){ | |
| 1844 | + uSeed = captcha_seed(); | |
| 1845 | + zDecoded = captcha_decode(uSeed); | |
| 1846 | + zCaptcha = captcha_render(zDecoded); | |
| 1847 | + } | |
| 1848 | + style_header("Message To Administrator"); | |
| 1849 | + form_begin(0, "%R/msgadmin"); | |
| 1850 | + @ <p>Enter a message for the repository administrator below:</p> | |
| 1851 | + @ <table class="subscribe"> | |
| 1852 | + if( zCaptcha ){ | |
| 1853 | + @ <tr> | |
| 1854 | + @ <td class="form_label">Security Code:</td> | |
| 1855 | + @ <td><input type="text" name="captcha" value="" size="10"> | |
| 1856 | + @ <input type="hidden" name="captchaseed" value="%u(uSeed)"></td> | |
| 1857 | + @ </tr> | |
| 1858 | + } | |
| 1859 | + @ <tr> | |
| 1860 | + @ <td class="form_label">Your Email Address:</td> | |
| 1861 | + @ <td><input type="text" name="from" value="%h(PT("from"))" size="30"></td> | |
| 1862 | + @ </tr> | |
| 1863 | + @ <tr> | |
| 1864 | + @ <td class="form_label">Subject:</td> | |
| 1865 | + @ <td><input type="text" name="subject" value="%h(PT("subject"))"\ | |
| 1866 | + @ size="80"></td> | |
| 1867 | + @ </tr> | |
| 1868 | + @ <tr> | |
| 1869 | + @ <td class="form_label">Message:</td> | |
| 1870 | + @ <td><textarea name="msg" cols="80" rows="10" wrap="virtual">\ | |
| 1871 | + @ %h(PT("msg"))</textarea> | |
| 1872 | + @ </tr> | |
| 1873 | + @ <tr> | |
| 1874 | + @ <td></td> | |
| 1875 | + @ <td><input type="submit" name="submit" value="Send Message"> | |
| 1876 | + @ </tr> | |
| 1877 | + @ </table> | |
| 1878 | + if( zCaptcha ){ | |
| 1879 | + @ <div class="captcha"><table class="captcha"><tr><td><pre> | |
| 1880 | + @ %h(zCaptcha) | |
| 1881 | + @ </pre> | |
| 1882 | + @ Enter the 8 characters above in the "Security Code" box | |
| 1883 | + @ </td></tr></table></div> | |
| 1884 | + } | |
| 1885 | + @ </form> | |
| 1886 | + style_footer(); | |
| 1887 | +} | |
| 1793 | 1888 |
| --- src/email.c | |
| +++ src/email.c | |
| @@ -1788,5 +1788,100 @@ | |
| 1788 | } |
| 1789 | |
| 1790 | autoexec_done: |
| 1791 | db_end_transaction(0); |
| 1792 | } |
| 1793 |
| --- src/email.c | |
| +++ src/email.c | |
| @@ -1788,5 +1788,100 @@ | |
| 1788 | } |
| 1789 | |
| 1790 | autoexec_done: |
| 1791 | db_end_transaction(0); |
| 1792 | } |
| 1793 | |
| 1794 | /* |
| 1795 | ** WEBPAGE: msgadmin |
| 1796 | ** |
| 1797 | ** A web-form to send a message to the repository administrator. |
| 1798 | */ |
| 1799 | void msgadmin_page(void){ |
| 1800 | const char *zAdminEmail = db_get("email-admin",0); |
| 1801 | unsigned int uSeed; |
| 1802 | const char *zDecoded; |
| 1803 | char *zCaptcha = 0; |
| 1804 | |
| 1805 | if( zAdminEmail==0 || zAdminEmail[0]==0 ){ |
| 1806 | style_header("Admin Messaging Disabled"); |
| 1807 | @ <p>Messages to the administrator are disabled on this repository |
| 1808 | style_footer(); |
| 1809 | return; |
| 1810 | } |
| 1811 | if( P("submit")!=0 |
| 1812 | && P("subject")!=0 |
| 1813 | && P("msg")!=0 |
| 1814 | && P("from")!=0 |
| 1815 | && cgi_csrf_safe(1) |
| 1816 | && captcha_is_correct(0) |
| 1817 | ){ |
| 1818 | Blob hdr, body; |
| 1819 | EmailSender *pSender = email_sender_new(0,0); |
| 1820 | blob_init(&hdr, 0, 0); |
| 1821 | blob_appendf(&hdr, "To: %s\nSubject: %s administrator message\n", |
| 1822 | zAdminEmail, db_get("email-subname","Fossil Repo")); |
| 1823 | blob_init(&body, 0, 0); |
| 1824 | blob_appendf(&body, "Message from [%s]\n", PT("from")/*safe-for-%s*/); |
| 1825 | blob_appendf(&body, "Subject: [%s]\n\n", PT("subject")/*safe-for-%s*/); |
| 1826 | blob_appendf(&body, "%s", PT("msg")/*safe-for-%s*/); |
| 1827 | email_send(pSender, &hdr, &body); |
| 1828 | style_header("Message Sent"); |
| 1829 | if( pSender->zErr ){ |
| 1830 | @ <h1>Internal Error</h1> |
| 1831 | @ <p>The following error was reported by the system: |
| 1832 | @ <blockquote><pre> |
| 1833 | @ %h(pSender->zErr) |
| 1834 | @ </pre></blockquote> |
| 1835 | }else{ |
| 1836 | @ <p>Your message has been sent to the repository administrator. |
| 1837 | @ Thank you for your input.</p> |
| 1838 | } |
| 1839 | email_sender_free(pSender); |
| 1840 | style_footer(); |
| 1841 | return; |
| 1842 | } |
| 1843 | if( captcha_needed() ){ |
| 1844 | uSeed = captcha_seed(); |
| 1845 | zDecoded = captcha_decode(uSeed); |
| 1846 | zCaptcha = captcha_render(zDecoded); |
| 1847 | } |
| 1848 | style_header("Message To Administrator"); |
| 1849 | form_begin(0, "%R/msgadmin"); |
| 1850 | @ <p>Enter a message for the repository administrator below:</p> |
| 1851 | @ <table class="subscribe"> |
| 1852 | if( zCaptcha ){ |
| 1853 | @ <tr> |
| 1854 | @ <td class="form_label">Security Code:</td> |
| 1855 | @ <td><input type="text" name="captcha" value="" size="10"> |
| 1856 | @ <input type="hidden" name="captchaseed" value="%u(uSeed)"></td> |
| 1857 | @ </tr> |
| 1858 | } |
| 1859 | @ <tr> |
| 1860 | @ <td class="form_label">Your Email Address:</td> |
| 1861 | @ <td><input type="text" name="from" value="%h(PT("from"))" size="30"></td> |
| 1862 | @ </tr> |
| 1863 | @ <tr> |
| 1864 | @ <td class="form_label">Subject:</td> |
| 1865 | @ <td><input type="text" name="subject" value="%h(PT("subject"))"\ |
| 1866 | @ size="80"></td> |
| 1867 | @ </tr> |
| 1868 | @ <tr> |
| 1869 | @ <td class="form_label">Message:</td> |
| 1870 | @ <td><textarea name="msg" cols="80" rows="10" wrap="virtual">\ |
| 1871 | @ %h(PT("msg"))</textarea> |
| 1872 | @ </tr> |
| 1873 | @ <tr> |
| 1874 | @ <td></td> |
| 1875 | @ <td><input type="submit" name="submit" value="Send Message"> |
| 1876 | @ </tr> |
| 1877 | @ </table> |
| 1878 | if( zCaptcha ){ |
| 1879 | @ <div class="captcha"><table class="captcha"><tr><td><pre> |
| 1880 | @ %h(zCaptcha) |
| 1881 | @ </pre> |
| 1882 | @ Enter the 8 characters above in the "Security Code" box |
| 1883 | @ </td></tr></table></div> |
| 1884 | } |
| 1885 | @ </form> |
| 1886 | style_footer(); |
| 1887 | } |
| 1888 |