Fossil

Check-in [f274222e]
Login

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

Overview
Comment:Add a primitive display of the access-log history.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:f274222ea7adff9944e29da4e14c534e59abdd92
User & Date: drh 2011-01-19 02:57:28
Context
2011-01-19
15:43
Improvements to the access log. The display is still primitive. check-in: e3b3c5cf user: drh tags: trunk
02:57
Add a primitive display of the access-log history. check-in: f274222e user: drh tags: trunk
02:35
Optionally record successful and failed login attempts in the ACCESSLOG table. This defaults to off. check-in: 6fdf5298 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/setup.c.

82
83
84
85
86
87
88


89
90
91
92
93
94
95
    "Edit HTML text inserted at the bottom of every page");
  setup_menu_entry("Logo", "setup_logo",
    "Change the logo image for the server");
  setup_menu_entry("Shunned", "shun",
    "Show artifacts that are shunned by this repository");
  setup_menu_entry("Log", "rcvfromlist",
    "A record of received artifacts and their sources");


  setup_menu_entry("Stats", "stat",
    "Display repository statistics");
  @ </table>

  style_footer();
}








>
>







82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
    "Edit HTML text inserted at the bottom of every page");
  setup_menu_entry("Logo", "setup_logo",
    "Change the logo image for the server");
  setup_menu_entry("Shunned", "shun",
    "Show artifacts that are shunned by this repository");
  setup_menu_entry("Log", "rcvfromlist",
    "A record of received artifacts and their sources");
  setup_menu_entry("User-Log", "access_log",
    "A record of login attempts");
  setup_menu_entry("Stats", "stat",
    "Display repository statistics");
  @ </table>

  style_footer();
}

Changes to src/user.c.

383
384
385
386
387
388
389













































  sqlite3_create_function(g.db, "sha1_shared_secret", 2, SQLITE_UTF8, 0,
                          user_sha1_shared_secret_func, 0, 0);
  db_multi_exec(
    "UPDATE user SET pw=sha1_shared_secret(pw,login)"
    " WHERE length(pw)>0 AND length(pw)!=40"
  );
}




















































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
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
  sqlite3_create_function(g.db, "sha1_shared_secret", 2, SQLITE_UTF8, 0,
                          user_sha1_shared_secret_func, 0, 0);
  db_multi_exec(
    "UPDATE user SET pw=sha1_shared_secret(pw,login)"
    " WHERE length(pw)>0 AND length(pw)!=40"
  );
}

/*
** WEBPAGE: access_log
**
**    s        Success only
**    f        Failures only
**    n=N      Number of entries to show
**    o=N      Skip this many entries
*/
void access_log_page(void){
  int bSuccessOnly = P("s")!=0;
  int bFailOnly = P("f")!=0;
  int n = atoi(PD("n","50"));
  int skip = atoi(PD("o","0"));
  Stmt q;

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

  style_header("Access Log");
  db_prepare(&q,
    "SELECT uname, ipaddr, datetime(mtime), success"
    "  FROM accesslog ORDER BY mtime DESC"
    " LIMIT %d OFFSET %d", n, skip);
  @ <table border="1" cellpadding="5">
  @ <tr><th>Date</th><th>User</th><th>IP Address</th><th>Success?</th></tr>
  while( db_step(&q)==SQLITE_ROW ){
    const char *zName = db_column_text(&q, 0);
    const char *zIP = db_column_text(&q, 1);
    const char *zDate = db_column_text(&q, 2);
    int bSuccess = db_column_int(&q, 3);
    if( bSuccessOnly && bSuccess==0 ) continue;
    if( bFailOnly && bSuccess!=0 ) continue;
    if( bSuccess ){
      @ <tr>
    }else{
      @ <tr bgcolor="#ffacc0">
    }
    @ <td>%s(zDate)</td><td>%h(zName)</td><td>%h(zIP)</td>
    @ <td>%s(bSuccess?"yes":"no")</td></tr>
  }
  @ </table>
  db_finalize(&q);
  style_footer();
}