Fossil SCM

Add the ability to run TH1 commands from the web interface.

drh 2012-12-27 21:16 trunk merge
Commit e356f18577fea7d8ecad34fcff897895c2bab179
2 files changed +46 +11
+46
--- src/setup.c
+++ src/setup.c
@@ -109,10 +109,12 @@
109109
"A record of login attempts");
110110
setup_menu_entry("Stats", "stat",
111111
"Display repository statistics");
112112
setup_menu_entry("SQL", "admin_sql",
113113
"Enter raw SQL commands");
114
+ setup_menu_entry("TH1", "admin_th1",
115
+ "Enter raw TH1 commands");
114116
@ </table>
115117
116118
style_footer();
117119
}
118120
@@ -1759,8 +1761,52 @@
17591761
@ </tr>
17601762
}
17611763
sqlite3_finalize(pStmt);
17621764
@ </table>
17631765
}
1766
+ }
1767
+ style_footer();
1768
+}
1769
+
1770
+
1771
+/*
1772
+** WEBPAGE: admin_th1
1773
+**
1774
+** Run raw TH1 commands using the web interface. If Tcl integration was
1775
+** enabled at compile-time and the "tcl" setting is enabled, Tcl commands
1776
+** may be run as well.
1777
+*/
1778
+void th1_page(void){
1779
+ const char *zQ = P("q");
1780
+ int go = P("go")!=0;
1781
+ login_check_credentials();
1782
+ if( !g.perm.Setup ){
1783
+ login_needed();
1784
+ }
1785
+ db_begin_transaction();
1786
+ style_header("Raw TH1 Commands");
1787
+ @ <p><b>Caution:</b> There are no restrictions on the TH1 that can be
1788
+ @ run by this page. If Tcl integration was enabled at compile-time and
1789
+ @ the "tcl" setting is enabled, Tcl commands may be run as well.</p>
1790
+ @
1791
+ @ <form method="post" action="%s(g.zTop)/admin_th1">
1792
+ login_insert_csrf_secret();
1793
+ @ TH1:<br />
1794
+ @ <textarea name="q" rows="5" cols="80">%h(zQ)</textarea><br />
1795
+ @ <input type="submit" name="go" value="Run TH1">
1796
+ @ </form>
1797
+ if( go ){
1798
+ const char *zR;
1799
+ int rc;
1800
+ int n;
1801
+ @ <hr />
1802
+ login_verify_csrf_secret();
1803
+ rc = Th_Eval(g.interp, 0, zQ, -1);
1804
+ zR = Th_GetResult(g.interp, &n);
1805
+ if( rc==TH_OK ){
1806
+ @ <pre class="th1result">%h(zR)</pre>
1807
+ }else{
1808
+ @ <pre class="th1error">%h(zR)</pre>
1809
+ }
17641810
}
17651811
style_footer();
17661812
}
17671813
--- src/setup.c
+++ src/setup.c
@@ -109,10 +109,12 @@
109 "A record of login attempts");
110 setup_menu_entry("Stats", "stat",
111 "Display repository statistics");
112 setup_menu_entry("SQL", "admin_sql",
113 "Enter raw SQL commands");
 
 
114 @ </table>
115
116 style_footer();
117 }
118
@@ -1759,8 +1761,52 @@
1759 @ </tr>
1760 }
1761 sqlite3_finalize(pStmt);
1762 @ </table>
1763 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1764 }
1765 style_footer();
1766 }
1767
--- src/setup.c
+++ src/setup.c
@@ -109,10 +109,12 @@
109 "A record of login attempts");
110 setup_menu_entry("Stats", "stat",
111 "Display repository statistics");
112 setup_menu_entry("SQL", "admin_sql",
113 "Enter raw SQL commands");
114 setup_menu_entry("TH1", "admin_th1",
115 "Enter raw TH1 commands");
116 @ </table>
117
118 style_footer();
119 }
120
@@ -1759,8 +1761,52 @@
1761 @ </tr>
1762 }
1763 sqlite3_finalize(pStmt);
1764 @ </table>
1765 }
1766 }
1767 style_footer();
1768 }
1769
1770
1771 /*
1772 ** WEBPAGE: admin_th1
1773 **
1774 ** Run raw TH1 commands using the web interface. If Tcl integration was
1775 ** enabled at compile-time and the "tcl" setting is enabled, Tcl commands
1776 ** may be run as well.
1777 */
1778 void th1_page(void){
1779 const char *zQ = P("q");
1780 int go = P("go")!=0;
1781 login_check_credentials();
1782 if( !g.perm.Setup ){
1783 login_needed();
1784 }
1785 db_begin_transaction();
1786 style_header("Raw TH1 Commands");
1787 @ <p><b>Caution:</b> There are no restrictions on the TH1 that can be
1788 @ run by this page. If Tcl integration was enabled at compile-time and
1789 @ the "tcl" setting is enabled, Tcl commands may be run as well.</p>
1790 @
1791 @ <form method="post" action="%s(g.zTop)/admin_th1">
1792 login_insert_csrf_secret();
1793 @ TH1:<br />
1794 @ <textarea name="q" rows="5" cols="80">%h(zQ)</textarea><br />
1795 @ <input type="submit" name="go" value="Run TH1">
1796 @ </form>
1797 if( go ){
1798 const char *zR;
1799 int rc;
1800 int n;
1801 @ <hr />
1802 login_verify_csrf_secret();
1803 rc = Th_Eval(g.interp, 0, zQ, -1);
1804 zR = Th_GetResult(g.interp, &n);
1805 if( rc==TH_OK ){
1806 @ <pre class="th1result">%h(zR)</pre>
1807 }else{
1808 @ <pre class="th1error">%h(zR)</pre>
1809 }
1810 }
1811 style_footer();
1812 }
1813
+11
--- src/style.c
+++ src/style.c
@@ -994,10 +994,21 @@
994994
},
995995
{ "span.modpending",
996996
"Moderation Pending message on timeline",
997997
@ color: #b03800;
998998
@ font-style: italic;
999
+ },
1000
+ { "pre.th1result",
1001
+ "format for th1 script results",
1002
+ @ white-space: pre-wrap;
1003
+ @ word-wrap: break-word;
1004
+ },
1005
+ { "pre.th1error",
1006
+ "format for th1 script errors",
1007
+ @ white-space: pre-wrap;
1008
+ @ word-wrap: break-word;
1009
+ @ color: red;
9991010
},
10001011
{ 0,
10011012
0,
10021013
0
10031014
}
10041015
--- src/style.c
+++ src/style.c
@@ -994,10 +994,21 @@
994 },
995 { "span.modpending",
996 "Moderation Pending message on timeline",
997 @ color: #b03800;
998 @ font-style: italic;
 
 
 
 
 
 
 
 
 
 
 
999 },
1000 { 0,
1001 0,
1002 0
1003 }
1004
--- src/style.c
+++ src/style.c
@@ -994,10 +994,21 @@
994 },
995 { "span.modpending",
996 "Moderation Pending message on timeline",
997 @ color: #b03800;
998 @ font-style: italic;
999 },
1000 { "pre.th1result",
1001 "format for th1 script results",
1002 @ white-space: pre-wrap;
1003 @ word-wrap: break-word;
1004 },
1005 { "pre.th1error",
1006 "format for th1 script errors",
1007 @ white-space: pre-wrap;
1008 @ word-wrap: break-word;
1009 @ color: red;
1010 },
1011 { 0,
1012 0,
1013 0
1014 }
1015

Keyboard Shortcuts

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