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.
Commit
c931dd7b585ff7453d49872864c59999051fcfe1b669155763f9c7a757fb557d
Parent
83b12c3a780d027…
2 files changed
+12
-3
+13
-7
+12
-3
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -2736,16 +2736,25 @@ | ||
| 2736 | 2736 | ** case=1 Issue a fossil_warning() while generating the page. |
| 2737 | 2737 | ** case=2 Extra db_begin_transaction() |
| 2738 | 2738 | ** case=3 Extra db_end_transaction() |
| 2739 | 2739 | */ |
| 2740 | 2740 | void test_warning_page(void){ |
| 2741 | - int iCase = atoi(PD("case","1")); | |
| 2741 | + int iCase = atoi(PD("case","0")); | |
| 2742 | 2742 | int i; |
| 2743 | 2743 | 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 | + } | |
| 2745 | 2748 | 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 | + } | |
| 2747 | 2756 | for(i=1; i<=3; i++){ |
| 2748 | 2757 | @ <a href='./test-warning?case=%d(i)'>[%d(i)]</a> |
| 2749 | 2758 | } |
| 2750 | 2759 | @ </p> |
| 2751 | 2760 | @ <p><ol> |
| 2752 | 2761 |
| --- 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 |
+13
-7
| --- src/security_audit.c | ||
| +++ src/security_audit.c | ||
| @@ -432,11 +432,11 @@ | ||
| 432 | 432 | @ command. |
| 433 | 433 | @ </ol> |
| 434 | 434 | style_footer(); |
| 435 | 435 | return; |
| 436 | 436 | } |
| 437 | - if( P("truncate") && cgi_csrf_safe(1) ){ | |
| 437 | + if( P("truncate1") && cgi_csrf_safe(1) ){ | |
| 438 | 438 | fclose(fopen(g.zErrlog,"w")); |
| 439 | 439 | } |
| 440 | 440 | if( P("download") ){ |
| 441 | 441 | Blob log; |
| 442 | 442 | blob_read_from_file(&log, g.zErrlog, ExtFILE); |
| @@ -443,17 +443,23 @@ | ||
| 443 | 443 | cgi_set_content_type("text/plain"); |
| 444 | 444 | cgi_set_content(&log); |
| 445 | 445 | return; |
| 446 | 446 | } |
| 447 | 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"> | |
| 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; | |
| 453 | 456 | } |
| 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"); | |
| 455 | 461 | in = fossil_fopen(g.zErrlog, "rb"); |
| 456 | 462 | if( in==0 ){ |
| 457 | 463 | @ <p class='generalError'>Unable top open that file for reading!</p> |
| 458 | 464 | style_footer(); |
| 459 | 465 | return; |
| 460 | 466 |
| --- 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 |