Check-in [c931dd7b58]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment: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.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:c931dd7b585ff7453d49872864c59999051fcfe1b669155763f9c7a757fb557d
User & Date: drh 2018-07-12 14:55:51
Context
2018-07-12
15:19
For new subscribers, default all alert options to "on". check-in: 9c38803597 user: drh tags: trunk
14:55
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. check-in: c931dd7b58 user: drh tags: trunk
14:29
Update the documentation on the email-send-method setting. check-in: 83b12c3a78 user: drh tags: trunk
Changes

Changes to src/main.c.

2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744



2745





2746

2747
2748
2749
2750
2751
2752
2753
** the administrator only.
**
**     case=1           Issue a fossil_warning() while generating the page.
**     case=2           Extra db_begin_transaction()
**     case=3           Extra db_end_transaction()
*/
void test_warning_page(void){
  int iCase = atoi(PD("case","1"));
  int i;
  login_check_credentials();
  if( !g.perm.Admin ){ fossil_redirect_home(); return; }



  style_header("Warning Test Page");





  @ <p>This is the test page for case=%d(iCase).  Cases:

  for(i=1; i<=3; i++){
    @ <a href='./test-warning?case=%d(i)'>[%d(i)]</a>
  }
  @ </p>
  @ <p><ol>
  @ <li value='1'> Call fossil_warning()
  if( iCase==1 ){







|


|
>
>
>

>
>
>
>
>
|
>







2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
** the administrator only.
**
**     case=1           Issue a fossil_warning() while generating the page.
**     case=2           Extra db_begin_transaction()
**     case=3           Extra db_end_transaction()
*/
void test_warning_page(void){
  int iCase = atoi(PD("case","0"));
  int i;
  login_check_credentials();
  if( !g.perm.Setup && !g.perm.Admin ){
    login_needed(0);
    return;
  }
  style_header("Warning Test Page");
  style_submenu_element("Error Log","%R/errorlog");
  if( iCase<1 || iCase>3 ){
    @ <p>Generate a message to the <a href="%R/errorlog">error log</a>
    @ by clicking on one of the following cases:
  }else{
    @ <p>This is the test page for case=%d(iCase).  All possible cases:
  }
  for(i=1; i<=3; i++){
    @ <a href='./test-warning?case=%d(i)'>[%d(i)]</a>
  }
  @ </p>
  @ <p><ol>
  @ <li value='1'> Call fossil_warning()
  if( iCase==1 ){

Changes to src/security_audit.c.

430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447

448
449
450
451
452
453
454







455
456
457
458
459
460
461
    @ the "fossil http" or "fossil server" commands then add
    @ a command-line option "--errorlog <i>FILENAME</i>" to that
    @ command.
    @ </ol>
    style_footer();
    return;
  }
  if( P("truncate") && cgi_csrf_safe(1) ){
    fclose(fopen(g.zErrlog,"w"));
  }
  if( P("download") ){
    Blob log;
    blob_read_from_file(&log, g.zErrlog, ExtFILE);
    cgi_set_content_type("text/plain");
    cgi_set_content(&log);
    return;
  }
  szFile = file_size(g.zErrlog, ExtFILE);

  @ <form action="%R/errorlog" method="POST">
  @ <p>The server error log at "%h(g.zErrlog)" is %,lld(szFile) bytes in size.
  if( szFile>1000 ){
    @ <input type="submit" name="download" value="Download">
    @ <input type="submit" name="truncate" value="Truncate">
  }
  @ </form>







  in = fossil_fopen(g.zErrlog, "rb");
  if( in==0 ){
    @ <p class='generalError'>Unable top open that file for reading!</p>
    style_footer();
    return;
  }
  if( szFile>MXSHOWLOG ){







|










>
|
<
|
|
|
<
|
>
>
>
>
>
>
>







430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449

450
451
452

453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
    @ the "fossil http" or "fossil server" commands then add
    @ a command-line option "--errorlog <i>FILENAME</i>" to that
    @ command.
    @ </ol>
    style_footer();
    return;
  }
  if( P("truncate1") && cgi_csrf_safe(1) ){
    fclose(fopen(g.zErrlog,"w"));
  }
  if( P("download") ){
    Blob log;
    blob_read_from_file(&log, g.zErrlog, ExtFILE);
    cgi_set_content_type("text/plain");
    cgi_set_content(&log);
    return;
  }
  szFile = file_size(g.zErrlog, ExtFILE);
  if( P("truncate") ){
    @ <form action="%R/errorlog" method="POST">

    @ <p>Confirm that you want to truncate the %,lld(szFile)-byte error log:
    @ <input type="submit" name="truncate1" value="Confirm">
    @ <input type="submit" name="cancel" value="Cancel">

    @ </form>
    style_footer();
    return;
  }
  @ <p>The server error log at "%h(g.zErrlog)" is %,lld(szFile) bytes in size.
  style_submenu_element("Test", "%R/test-warning");
  style_submenu_element("Download", "%R/errorlog?download");
  style_submenu_element("Truncate", "%R/errorlog?truncate");
  in = fossil_fopen(g.zErrlog, "rb");
  if( in==0 ){
    @ <p class='generalError'>Unable top open that file for reading!</p>
    style_footer();
    return;
  }
  if( szFile>MXSHOWLOG ){