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

Overview
Comment:Add some primitive clean-up buttons on the access log.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:a37abeca655ec69154a0db5827f4a5259765f64c
User & Date: drh 2011-01-19 16:16:37
Context
2011-01-19
16:28
Do not drop the accesslog table on a rebuild. If the accesslog table does not exist, do not generate and error on the User-Log report. check-in: f1efc905 user: drh tags: trunk
16:16
Add some primitive clean-up buttons on the access log. check-in: a37abeca user: drh tags: trunk
15:43
Improvements to the access log. The display is still primitive. check-in: e3b3c5cf user: drh tags: trunk
Changes

Changes to src/user.c.

403
404
405
406
407
408
409

















410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
...
449
450
451
452
453
454
455
















456
457
  Blob sql;
  Stmt q;
  int cnt = 0;

  login_check_credentials();
  if( !g.okAdmin ){ login_needed(); return; }


















  style_header("Access Log");
  blob_zero(&sql);
  blob_append(&sql, 
    "SELECT uname, ipaddr, datetime(mtime, 'localtime'), success"
    "  FROM accesslog", -1
  );
  if( y==1 ){
    blob_append(&sql, "  WHERE success", -1);
  }else if( y==2 ){
    blob_append(&sql, "  WHERE NOT success", -1);
  }
  blob_appendf(&sql,"  ORDER BY mtime DESC LIMIT %d OFFSET %d", n+1, skip);
  if( skip ){
    style_submenu_element("Newer", "Newer entries",
              "%s/access_log?o=%d&n=%d&y=%d", g.zTop, skip>=n ? skip-n : 0,
              n, y);
  }
  db_prepare(&q, blob_str(&sql));
  zNow = db_text(0, "SELECT datetime('now','localtime');");
................................................................................
  }
  if( skip>0 || cnt>n ){
    style_submenu_element("All", "All entries",
          "%s/access_log?n=10000000", g.zTop);
  }
  @ </table></center>
  db_finalize(&q);
















  style_footer();
}







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>











|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
...
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
  Blob sql;
  Stmt q;
  int cnt = 0;

  login_check_credentials();
  if( !g.okAdmin ){ login_needed(); return; }

  if( P("delall") && P("delallbtn") ){
    db_multi_exec("DELETE FROM accesslog");
    cgi_redirectf("%s/access_log?y=%d&n=%d&o=%o", g.zTop, y, n, skip);
    return;
  }
  if( P("delanon") && P("delanonbtn") ){
    db_multi_exec("DELETE FROM accesslog WHERE uname='anonymous'");
    cgi_redirectf("%s/access_log?y=%d&n=%d&o=%o", g.zTop, y, n, skip);
    return;
  }
  if( P("delold") && P("deloldbtn") ){
    db_multi_exec("DELETE FROM accesslog WHERE rowid in"
                  "(SELECT rowid FROM accesslog ORDER BY rowid DESC"
                  " LIMIT -1 OFFSET 200)");
    cgi_redirectf("%s/access_log?y=%d&n=%d", g.zTop, y, n);
    return;
  }
  style_header("Access Log");
  blob_zero(&sql);
  blob_append(&sql, 
    "SELECT uname, ipaddr, datetime(mtime, 'localtime'), success"
    "  FROM accesslog", -1
  );
  if( y==1 ){
    blob_append(&sql, "  WHERE success", -1);
  }else if( y==2 ){
    blob_append(&sql, "  WHERE NOT success", -1);
  }
  blob_appendf(&sql,"  ORDER BY rowid DESC LIMIT %d OFFSET %d", n+1, skip);
  if( skip ){
    style_submenu_element("Newer", "Newer entries",
              "%s/access_log?o=%d&n=%d&y=%d", g.zTop, skip>=n ? skip-n : 0,
              n, y);
  }
  db_prepare(&q, blob_str(&sql));
  zNow = db_text(0, "SELECT datetime('now','localtime');");
................................................................................
  }
  if( skip>0 || cnt>n ){
    style_submenu_element("All", "All entries",
          "%s/access_log?n=10000000", g.zTop);
  }
  @ </table></center>
  db_finalize(&q);
  @ <hr>
  @ <form method="post" action="%s(g.zTop)/access_log">
  @ <input type="checkbox" name="delold">
  @ Delete all but the most recent 200 entries</input>
  @ <input type="submit" name="deloldbtn" value="Delete"></input>
  @ </form>
  @ <form method="post" action="%s(g.zTop)/access_log">
  @ <input type="checkbox" name="delanon">
  @ Delete all entries for user "anonymous"</input>
  @ <input type="submit" name="delanonbtn" value="Delete"></input>
  @ </form>
  @ <form method="post" action="%s(g.zTop)/access_log">
  @ <input type="checkbox" name="delall">
  @ Delete all entries</input>
  @ <input type="submit" name="delallbtn" value="Delete"></input>
  @ </form>
  style_footer();
}