Fossil SCM

Add "Download", "Test", and "Truncate" submenu buttons on the /errorlog page. Show a confirmation page prior to truncating the error log. Improvements to the /test-warning page, including a link back to /errorlog through the submenu.

drh 2018-07-12 14:55 trunk
Commit c931dd7b585ff7453d49872864c59999051fcfe1b669155763f9c7a757fb557d
2 files changed +12 -3 +13 -7
+12 -3
--- src/main.c
+++ src/main.c
@@ -2736,16 +2736,25 @@
27362736
** case=1 Issue a fossil_warning() while generating the page.
27372737
** case=2 Extra db_begin_transaction()
27382738
** case=3 Extra db_end_transaction()
27392739
*/
27402740
void test_warning_page(void){
2741
- int iCase = atoi(PD("case","1"));
2741
+ int iCase = atoi(PD("case","0"));
27422742
int i;
27432743
login_check_credentials();
2744
- if( !g.perm.Admin ){ fossil_redirect_home(); return; }
2744
+ if( !g.perm.Setup && !g.perm.Admin ){
2745
+ login_needed(0);
2746
+ return;
2747
+ }
27452748
style_header("Warning Test Page");
2746
- @ <p>This is the test page for case=%d(iCase). Cases:
2749
+ style_submenu_element("Error Log","%R/errorlog");
2750
+ if( iCase<1 || iCase>3 ){
2751
+ @ <p>Generate a message to the <a href="%R/errorlog">error log</a>
2752
+ @ by clicking on one of the following cases:
2753
+ }else{
2754
+ @ <p>This is the test page for case=%d(iCase). All possible cases:
2755
+ }
27472756
for(i=1; i<=3; i++){
27482757
@ <a href='./test-warning?case=%d(i)'>[%d(i)]</a>
27492758
}
27502759
@ </p>
27512760
@ <p><ol>
27522761
--- src/main.c
+++ src/main.c
@@ -2736,16 +2736,25 @@
2736 ** case=1 Issue a fossil_warning() while generating the page.
2737 ** case=2 Extra db_begin_transaction()
2738 ** case=3 Extra db_end_transaction()
2739 */
2740 void test_warning_page(void){
2741 int iCase = atoi(PD("case","1"));
2742 int i;
2743 login_check_credentials();
2744 if( !g.perm.Admin ){ fossil_redirect_home(); return; }
 
 
 
2745 style_header("Warning Test Page");
2746 @ <p>This is the test page for case=%d(iCase). Cases:
 
 
 
 
 
 
2747 for(i=1; i<=3; i++){
2748 @ <a href='./test-warning?case=%d(i)'>[%d(i)]</a>
2749 }
2750 @ </p>
2751 @ <p><ol>
2752
--- src/main.c
+++ src/main.c
@@ -2736,16 +2736,25 @@
2736 ** case=1 Issue a fossil_warning() while generating the page.
2737 ** case=2 Extra db_begin_transaction()
2738 ** case=3 Extra db_end_transaction()
2739 */
2740 void test_warning_page(void){
2741 int iCase = atoi(PD("case","0"));
2742 int i;
2743 login_check_credentials();
2744 if( !g.perm.Setup && !g.perm.Admin ){
2745 login_needed(0);
2746 return;
2747 }
2748 style_header("Warning Test Page");
2749 style_submenu_element("Error Log","%R/errorlog");
2750 if( iCase<1 || iCase>3 ){
2751 @ <p>Generate a message to the <a href="%R/errorlog">error log</a>
2752 @ by clicking on one of the following cases:
2753 }else{
2754 @ <p>This is the test page for case=%d(iCase). All possible cases:
2755 }
2756 for(i=1; i<=3; i++){
2757 @ <a href='./test-warning?case=%d(i)'>[%d(i)]</a>
2758 }
2759 @ </p>
2760 @ <p><ol>
2761
--- src/security_audit.c
+++ src/security_audit.c
@@ -432,11 +432,11 @@
432432
@ command.
433433
@ </ol>
434434
style_footer();
435435
return;
436436
}
437
- if( P("truncate") && cgi_csrf_safe(1) ){
437
+ if( P("truncate1") && cgi_csrf_safe(1) ){
438438
fclose(fopen(g.zErrlog,"w"));
439439
}
440440
if( P("download") ){
441441
Blob log;
442442
blob_read_from_file(&log, g.zErrlog, ExtFILE);
@@ -443,17 +443,23 @@
443443
cgi_set_content_type("text/plain");
444444
cgi_set_content(&log);
445445
return;
446446
}
447447
szFile = file_size(g.zErrlog, ExtFILE);
448
- @ <form action="%R/errorlog" method="POST">
449
- @ <p>The server error log at "%h(g.zErrlog)" is %,lld(szFile) bytes in size.
450
- if( szFile>1000 ){
451
- @ <input type="submit" name="download" value="Download">
452
- @ <input type="submit" name="truncate" value="Truncate">
448
+ if( P("truncate") ){
449
+ @ <form action="%R/errorlog" method="POST">
450
+ @ <p>Confirm that you want to truncate the %,lld(szFile)-byte error log:
451
+ @ <input type="submit" name="truncate1" value="Confirm">
452
+ @ <input type="submit" name="cancel" value="Cancel">
453
+ @ </form>
454
+ style_footer();
455
+ return;
453456
}
454
- @ </form>
457
+ @ <p>The server error log at "%h(g.zErrlog)" is %,lld(szFile) bytes in size.
458
+ style_submenu_element("Test", "%R/test-warning");
459
+ style_submenu_element("Download", "%R/errorlog?download");
460
+ style_submenu_element("Truncate", "%R/errorlog?truncate");
455461
in = fossil_fopen(g.zErrlog, "rb");
456462
if( in==0 ){
457463
@ <p class='generalError'>Unable top open that file for reading!</p>
458464
style_footer();
459465
return;
460466
--- src/security_audit.c
+++ src/security_audit.c
@@ -432,11 +432,11 @@
432 @ command.
433 @ </ol>
434 style_footer();
435 return;
436 }
437 if( P("truncate") && cgi_csrf_safe(1) ){
438 fclose(fopen(g.zErrlog,"w"));
439 }
440 if( P("download") ){
441 Blob log;
442 blob_read_from_file(&log, g.zErrlog, ExtFILE);
@@ -443,17 +443,23 @@
443 cgi_set_content_type("text/plain");
444 cgi_set_content(&log);
445 return;
446 }
447 szFile = file_size(g.zErrlog, ExtFILE);
448 @ <form action="%R/errorlog" method="POST">
449 @ <p>The server error log at "%h(g.zErrlog)" is %,lld(szFile) bytes in size.
450 if( szFile>1000 ){
451 @ <input type="submit" name="download" value="Download">
452 @ <input type="submit" name="truncate" value="Truncate">
 
 
 
453 }
454 @ </form>
 
 
 
455 in = fossil_fopen(g.zErrlog, "rb");
456 if( in==0 ){
457 @ <p class='generalError'>Unable top open that file for reading!</p>
458 style_footer();
459 return;
460
--- src/security_audit.c
+++ src/security_audit.c
@@ -432,11 +432,11 @@
432 @ command.
433 @ </ol>
434 style_footer();
435 return;
436 }
437 if( P("truncate1") && cgi_csrf_safe(1) ){
438 fclose(fopen(g.zErrlog,"w"));
439 }
440 if( P("download") ){
441 Blob log;
442 blob_read_from_file(&log, g.zErrlog, ExtFILE);
@@ -443,17 +443,23 @@
443 cgi_set_content_type("text/plain");
444 cgi_set_content(&log);
445 return;
446 }
447 szFile = file_size(g.zErrlog, ExtFILE);
448 if( P("truncate") ){
449 @ <form action="%R/errorlog" method="POST">
450 @ <p>Confirm that you want to truncate the %,lld(szFile)-byte error log:
451 @ <input type="submit" name="truncate1" value="Confirm">
452 @ <input type="submit" name="cancel" value="Cancel">
453 @ </form>
454 style_footer();
455 return;
456 }
457 @ <p>The server error log at "%h(g.zErrlog)" is %,lld(szFile) bytes in size.
458 style_submenu_element("Test", "%R/test-warning");
459 style_submenu_element("Download", "%R/errorlog?download");
460 style_submenu_element("Truncate", "%R/errorlog?truncate");
461 in = fossil_fopen(g.zErrlog, "rb");
462 if( in==0 ){
463 @ <p class='generalError'>Unable top open that file for reading!</p>
464 style_footer();
465 return;
466

Keyboard Shortcuts

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