Fossil SCM

Add the test-emailblob page.

drh 2018-07-17 14:47 UTC webmail
Commit 8ac5bbbdb0107e61e0873b3ce34f0c9a51ec481ea848cc433485b7ec6cb60a5b
1 file changed +83
--- src/webmail.c
+++ src/webmail.c
@@ -725,5 +725,88 @@
725725
@ </table>
726726
@ </form>
727727
style_footer();
728728
db_end_transaction(0);
729729
}
730
+
731
+/*
732
+** WEBPAGE: test-emailblob
733
+**
734
+** This page, accessible only to administrators, allows easy viewing of
735
+** the emailblob table - the table that contains the text of email messages
736
+** both inbound and outbound, and transcripts of SMTP sessions.
737
+**
738
+** id=N Show the text of emailblob with emailid==N
739
+**
740
+*/
741
+void webmail_emailblob_page(void){
742
+ int id = atoi(PD("id","0"));
743
+ Stmt q;
744
+ login_check_credentials();
745
+ if( !g.perm.Setup ){
746
+ login_needed(0);
747
+ return;
748
+ }
749
+ add_content_sql_commands(g.db);
750
+ style_header("emailblob table");
751
+ if( id>0 ){
752
+ style_submenu_element("Index", "%R/test-emailblob");
753
+ @ <ul>
754
+ db_prepare(&q, "SELECT emailid FROM emailblob WHERE ets=%d", id);
755
+ while( db_step(&q)==SQLITE_ROW ){
756
+ int id = db_column_int(&q, 0);
757
+ @ <li> <a href="%R/test-emailblob?id=%d(id)">emailblob entry %d(id)</a>
758
+ }
759
+ db_finalize(&q);
760
+ db_prepare(&q, "SELECT euser, estate FROM emailbox WHERE emsgid=%d", id);
761
+ while( db_step(&q)==SQLITE_ROW ){
762
+ const char *zUser = db_column_text(&q, 0);
763
+ int e = db_column_int(&q, 1);
764
+ @ <li> emailbox for %h(zUser) state %d(e)
765
+ }
766
+ db_finalize(&q);
767
+ db_prepare(&q, "SELECT efrom, eto FROM emailoutq WHERE emsgid=%d", id);
768
+ while( db_step(&q)==SQLITE_ROW ){
769
+ const char *zFrom = db_column_text(&q, 0);
770
+ const char *zTo = db_column_text(&q, 1);
771
+ @ <li> emailoutq message body from %h(zFrom) to %h(zTo)
772
+ }
773
+ db_finalize(&q);
774
+ db_prepare(&q, "SELECT efrom, eto FROM emailoutq WHERE ets=%d", id);
775
+ while( db_step(&q)==SQLITE_ROW ){
776
+ const char *zFrom = db_column_text(&q, 0);
777
+ const char *zTo = db_column_text(&q, 1);
778
+ @ <li> emailoutq transcript from %h(zFrom) to %h(zTo)
779
+ }
780
+ db_finalize(&q);
781
+ @ </ul>
782
+ @ <hr>
783
+ db_prepare(&q, "SELECT decompress(etxt) FROM emailblob WHERE emailid=%d",
784
+ id);
785
+ while( db_step(&q)==SQLITE_ROW ){
786
+ const char *zContent = db_column_text(&q, 0);
787
+ @ <pre>%h(zContent)</pre>
788
+ }
789
+ db_finalize(&q);
790
+ }else{
791
+ db_prepare(&q,
792
+ "SELECT emailid, enref, ets, datetime(etime,'unixepoch')"
793
+ " FROM emailblob ORDER BY etime DESC, emailid DESC");
794
+ @ <table border="1" cellpadding="5" cellspacing="0">
795
+ @ <tr><th> emailid <th> enref <th> ets <th> etime</tr>
796
+ while( db_step(&q)==SQLITE_ROW ){
797
+ int id = db_column_int(&q, 0);
798
+ int nref = db_column_int(&q, 1);
799
+ int ets = db_column_int(&q, 2);
800
+ const char *zDate = db_column_text(&q, 3);
801
+ @ <tr>
802
+ @ <td><a href="%R/test-emailblob?id=%d(id)">%d(id)</a>
803
+ @ <td>%d(nref)</td>
804
+ @ <td>%d(ets)</td>
805
+ @ <td>%h(zDate)</td>
806
+ @ </tr>
807
+ }
808
+ @ </table>
809
+ db_finalize(&q);
810
+ }
811
+ style_footer();
812
+}
730813
--- src/webmail.c
+++ src/webmail.c
@@ -725,5 +725,88 @@
725 @ </table>
726 @ </form>
727 style_footer();
728 db_end_transaction(0);
729 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
730
--- src/webmail.c
+++ src/webmail.c
@@ -725,5 +725,88 @@
725 @ </table>
726 @ </form>
727 style_footer();
728 db_end_transaction(0);
729 }
730
731 /*
732 ** WEBPAGE: test-emailblob
733 **
734 ** This page, accessible only to administrators, allows easy viewing of
735 ** the emailblob table - the table that contains the text of email messages
736 ** both inbound and outbound, and transcripts of SMTP sessions.
737 **
738 ** id=N Show the text of emailblob with emailid==N
739 **
740 */
741 void webmail_emailblob_page(void){
742 int id = atoi(PD("id","0"));
743 Stmt q;
744 login_check_credentials();
745 if( !g.perm.Setup ){
746 login_needed(0);
747 return;
748 }
749 add_content_sql_commands(g.db);
750 style_header("emailblob table");
751 if( id>0 ){
752 style_submenu_element("Index", "%R/test-emailblob");
753 @ <ul>
754 db_prepare(&q, "SELECT emailid FROM emailblob WHERE ets=%d", id);
755 while( db_step(&q)==SQLITE_ROW ){
756 int id = db_column_int(&q, 0);
757 @ <li> <a href="%R/test-emailblob?id=%d(id)">emailblob entry %d(id)</a>
758 }
759 db_finalize(&q);
760 db_prepare(&q, "SELECT euser, estate FROM emailbox WHERE emsgid=%d", id);
761 while( db_step(&q)==SQLITE_ROW ){
762 const char *zUser = db_column_text(&q, 0);
763 int e = db_column_int(&q, 1);
764 @ <li> emailbox for %h(zUser) state %d(e)
765 }
766 db_finalize(&q);
767 db_prepare(&q, "SELECT efrom, eto FROM emailoutq WHERE emsgid=%d", id);
768 while( db_step(&q)==SQLITE_ROW ){
769 const char *zFrom = db_column_text(&q, 0);
770 const char *zTo = db_column_text(&q, 1);
771 @ <li> emailoutq message body from %h(zFrom) to %h(zTo)
772 }
773 db_finalize(&q);
774 db_prepare(&q, "SELECT efrom, eto FROM emailoutq WHERE ets=%d", id);
775 while( db_step(&q)==SQLITE_ROW ){
776 const char *zFrom = db_column_text(&q, 0);
777 const char *zTo = db_column_text(&q, 1);
778 @ <li> emailoutq transcript from %h(zFrom) to %h(zTo)
779 }
780 db_finalize(&q);
781 @ </ul>
782 @ <hr>
783 db_prepare(&q, "SELECT decompress(etxt) FROM emailblob WHERE emailid=%d",
784 id);
785 while( db_step(&q)==SQLITE_ROW ){
786 const char *zContent = db_column_text(&q, 0);
787 @ <pre>%h(zContent)</pre>
788 }
789 db_finalize(&q);
790 }else{
791 db_prepare(&q,
792 "SELECT emailid, enref, ets, datetime(etime,'unixepoch')"
793 " FROM emailblob ORDER BY etime DESC, emailid DESC");
794 @ <table border="1" cellpadding="5" cellspacing="0">
795 @ <tr><th> emailid <th> enref <th> ets <th> etime</tr>
796 while( db_step(&q)==SQLITE_ROW ){
797 int id = db_column_int(&q, 0);
798 int nref = db_column_int(&q, 1);
799 int ets = db_column_int(&q, 2);
800 const char *zDate = db_column_text(&q, 3);
801 @ <tr>
802 @ <td><a href="%R/test-emailblob?id=%d(id)">%d(id)</a>
803 @ <td>%d(nref)</td>
804 @ <td>%d(ets)</td>
805 @ <td>%h(zDate)</td>
806 @ </tr>
807 }
808 @ </table>
809 db_finalize(&q);
810 }
811 style_footer();
812 }
813

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button