| | @@ -109,10 +109,12 @@ |
| 109 | 109 | "Show artifacts that are shunned by this repository"); |
| 110 | 110 | setup_menu_entry("Log", "rcvfromlist", |
| 111 | 111 | "A record of received artifacts and their sources"); |
| 112 | 112 | setup_menu_entry("User-Log", "access_log", |
| 113 | 113 | "A record of login attempts"); |
| 114 | + setup_menu_entry("Admin-Log", "admin_log", |
| 115 | + "View the admin_log entries"); |
| 114 | 116 | setup_menu_entry("Stats", "stat", |
| 115 | 117 | "Display repository statistics"); |
| 116 | 118 | setup_menu_entry("SQL", "admin_sql", |
| 117 | 119 | "Enter raw SQL commands"); |
| 118 | 120 | setup_menu_entry("TH1", "admin_th1", |
| | @@ -382,11 +384,12 @@ |
| 382 | 384 | db_multi_exec( |
| 383 | 385 | "REPLACE INTO user(uid,login,info,pw,cap,mtime) " |
| 384 | 386 | "VALUES(nullif(%d,0),%Q,%Q,%Q,%Q,now())", |
| 385 | 387 | uid, zLogin, P("info"), zPw, zCap |
| 386 | 388 | ); |
| 387 | | - admin_log( "Updated user %Q with capapbilities [%q].", zLogin, zCap ); |
| 389 | + admin_log( "Updated user [%q] with capabilities [%q].", |
| 390 | + zLogin, zCap ); |
| 388 | 391 | if( atoi(PD("all","0"))>0 ){ |
| 389 | 392 | Blob sql; |
| 390 | 393 | char *zErr = 0; |
| 391 | 394 | blob_zero(&sql); |
| 392 | 395 | if( zOldLogin==0 ){ |
| | @@ -408,11 +411,13 @@ |
| 408 | 411 | zLogin, P("pw"), zLogin, P("info"), zCap, |
| 409 | 412 | zOldLogin |
| 410 | 413 | ); |
| 411 | 414 | login_group_sql(blob_str(&sql), "<li> ", " </li>\n", &zErr); |
| 412 | 415 | blob_reset(&sql); |
| 413 | | - admin_log( "Updated user '%q' with capapbilities.", zLogin, zCap ); |
| 416 | + admin_log( "Updated user [%q] in all login groups " |
| 417 | + "with capabilities [%q].", |
| 418 | + zLogin, zCap ); |
| 414 | 419 | if( zErr ){ |
| 415 | 420 | style_header("User Change Error"); |
| 416 | 421 | admin_log( "Error updating user '%q': %s'.", zLogin, zErr ); |
| 417 | 422 | @ <span class="loginError">%s(zErr)</span> |
| 418 | 423 | @ |
| | @@ -865,10 +870,12 @@ |
| 865 | 870 | if( zQ ){ |
| 866 | 871 | int iQ = fossil_strcmp(zQ,"on")==0 || atoi(zQ); |
| 867 | 872 | if( iQ!=iVal ){ |
| 868 | 873 | login_verify_csrf_secret(); |
| 869 | 874 | db_set(zVar, iQ ? "1" : "0", 0); |
| 875 | + admin_log("Set option [%q] to [%q].", |
| 876 | + zVar, iQ ? "on" : "off"); |
| 870 | 877 | iVal = iQ; |
| 871 | 878 | } |
| 872 | 879 | } |
| 873 | 880 | @ <input type="checkbox" name="%s(zQParm)" |
| 874 | 881 | if( iVal ){ |
| | @@ -2026,5 +2033,59 @@ |
| 2026 | 2033 | @ <pre class="th1error">%h(zR)</pre> |
| 2027 | 2034 | } |
| 2028 | 2035 | } |
| 2029 | 2036 | style_footer(); |
| 2030 | 2037 | } |
| 2038 | + |
| 2039 | +/* |
| 2040 | +** WEBPAGE: admin_log |
| 2041 | +** |
| 2042 | +*/ |
| 2043 | +void page_admin_log(){ |
| 2044 | + Stmt stLog = empty_Stmt; |
| 2045 | + Blob qLog = empty_blob; |
| 2046 | + int limit; |
| 2047 | + int fLogEnabled; |
| 2048 | + int counter = 0; |
| 2049 | + login_check_credentials(); |
| 2050 | + if( !g.perm.Setup && !g.perm.Admin ){ |
| 2051 | + login_needed(); |
| 2052 | + } |
| 2053 | + style_header("Admin Log"); |
| 2054 | + create_admin_log_table(); |
| 2055 | + limit = atoi(PD("n","20")); |
| 2056 | + fLogEnabled = db_get_boolean("admin-log", 0); |
| 2057 | + @ Admin logging is %s(fLogEnabled?"on":"off"). |
| 2058 | + |
| 2059 | + blob_append_sql(&qLog, |
| 2060 | + "SELECT datetime(time,'unixepoch'), who, page, what " |
| 2061 | + "FROM admin_log " |
| 2062 | + "ORDER BY time DESC "); |
| 2063 | + if(limit>0){ |
| 2064 | + @ %d(limit) Most recent entries: |
| 2065 | + blob_append_sql(&qLog, "LIMIT %d", limit); |
| 2066 | + } |
| 2067 | + |
| 2068 | + db_prepare(&stLog, "%s", blob_sql_text(&qLog)); |
| 2069 | + blob_reset(&qLog); |
| 2070 | + @ <table id="adminLogTable" class="adminLogTable" width="100%%"> |
| 2071 | + @ <thead> |
| 2072 | + @ <th>Time</th> |
| 2073 | + @ <th>User</th> |
| 2074 | + @ <th>Page</th> |
| 2075 | + @ <th width="60%%">Message</th> |
| 2076 | + @ </thead><tbody> |
| 2077 | + while( SQLITE_ROW == db_step(&stLog) ){ |
| 2078 | + char const * zTime = db_column_text(&stLog, 0); |
| 2079 | + char const * zUser = db_column_text(&stLog, 1); |
| 2080 | + char const * zPage = db_column_text(&stLog, 2); |
| 2081 | + char const * zMessage = db_column_text(&stLog, 3); |
| 2082 | + @ <tr class="row%d(counter++%2)"> |
| 2083 | + @ <td class="adminTime">%s(zTime)</td> |
| 2084 | + @ <td>%s(zUser)</td> |
| 2085 | + @ <td>%s(zPage)</td> |
| 2086 | + @ <td>%s(zMessage)</td> |
| 2087 | + @ </tr> |
| 2088 | + } |
| 2089 | + @ </tbody></table> |
| 2090 | + style_footer(); |
| 2091 | +} |
| 2031 | 2092 | |