Fossil SCM
Added limit selection to /admin_log.
Commit
8355756fb6419a504045f4ab935a9e4681e253ab
Parent
f63d68d4d32cf1b…
1 file changed
+26
-2
+26
-2
| --- src/setup.c | ||
| +++ src/setup.c | ||
| @@ -2042,14 +2042,31 @@ | ||
| 2042 | 2042 | @ <pre class="th1error">%h(zR)</pre> |
| 2043 | 2043 | } |
| 2044 | 2044 | } |
| 2045 | 2045 | style_footer(); |
| 2046 | 2046 | } |
| 2047 | + | |
| 2048 | +static void admin_log_render_limits(){ | |
| 2049 | + int const count = db_int(0,"SELECT COUNT(*) FROM admin_log"); | |
| 2050 | + int i; | |
| 2051 | + int limits[] = { | |
| 2052 | + 10, 20, 50, 100, 250, 500, 0 | |
| 2053 | + }; | |
| 2054 | + for(i = 0; limits[i]; ++i ){ | |
| 2055 | + cgi_printf("%s<a href='?n=%d'>%d</a>", | |
| 2056 | + i ? " " : "", | |
| 2057 | + limits[i], limits[i]); | |
| 2058 | + if(limits[i]>count) break; | |
| 2059 | + } | |
| 2060 | +} | |
| 2047 | 2061 | |
| 2048 | 2062 | /* |
| 2049 | 2063 | ** WEBPAGE: admin_log |
| 2050 | 2064 | ** |
| 2065 | +** Shows the contents of the admin_log table, which is only created if | |
| 2066 | +** the admin-log setting is enabled. Requires Admin or Setup ('a' or | |
| 2067 | +** 's') permissions. | |
| 2051 | 2068 | */ |
| 2052 | 2069 | void page_admin_log(){ |
| 2053 | 2070 | Stmt stLog = empty_Stmt; |
| 2054 | 2071 | Blob qLog = empty_blob; |
| 2055 | 2072 | int limit; |
| @@ -2061,21 +2078,25 @@ | ||
| 2061 | 2078 | } |
| 2062 | 2079 | style_header("Admin Log"); |
| 2063 | 2080 | create_admin_log_table(); |
| 2064 | 2081 | limit = atoi(PD("n","20")); |
| 2065 | 2082 | fLogEnabled = db_get_boolean("admin-log", 0); |
| 2066 | - @ Admin logging is %s(fLogEnabled?"on":"off"). | |
| 2083 | + @ <div>Admin logging is %s(fLogEnabled?"on":"off").</div> | |
| 2084 | + | |
| 2085 | + | |
| 2086 | + @ <div>Limit results to: <span> | |
| 2087 | + admin_log_render_limits(); | |
| 2088 | + @ </span></div> | |
| 2067 | 2089 | |
| 2068 | 2090 | blob_append_sql(&qLog, |
| 2069 | 2091 | "SELECT datetime(time,'unixepoch'), who, page, what " |
| 2070 | 2092 | "FROM admin_log " |
| 2071 | 2093 | "ORDER BY time DESC "); |
| 2072 | 2094 | if(limit>0){ |
| 2073 | 2095 | @ %d(limit) Most recent entries: |
| 2074 | 2096 | blob_append_sql(&qLog, "LIMIT %d", limit); |
| 2075 | 2097 | } |
| 2076 | - | |
| 2077 | 2098 | db_prepare(&stLog, "%s", blob_sql_text(&qLog)); |
| 2078 | 2099 | blob_reset(&qLog); |
| 2079 | 2100 | @ <table id="adminLogTable" class="adminLogTable" width="100%%"> |
| 2080 | 2101 | @ <thead> |
| 2081 | 2102 | @ <th>Time</th> |
| @@ -2094,7 +2115,10 @@ | ||
| 2094 | 2115 | @ <td>%s(zPage)</td> |
| 2095 | 2116 | @ <td>%h(zMessage)</td> |
| 2096 | 2117 | @ </tr> |
| 2097 | 2118 | } |
| 2098 | 2119 | @ </tbody></table> |
| 2120 | + if(limit>0 && counter<limit){ | |
| 2121 | + @ <div>%d(counter) entries shown.</div> | |
| 2122 | + } | |
| 2099 | 2123 | style_footer(); |
| 2100 | 2124 | } |
| 2101 | 2125 |
| --- src/setup.c | |
| +++ src/setup.c | |
| @@ -2042,14 +2042,31 @@ | |
| 2042 | @ <pre class="th1error">%h(zR)</pre> |
| 2043 | } |
| 2044 | } |
| 2045 | style_footer(); |
| 2046 | } |
| 2047 | |
| 2048 | /* |
| 2049 | ** WEBPAGE: admin_log |
| 2050 | ** |
| 2051 | */ |
| 2052 | void page_admin_log(){ |
| 2053 | Stmt stLog = empty_Stmt; |
| 2054 | Blob qLog = empty_blob; |
| 2055 | int limit; |
| @@ -2061,21 +2078,25 @@ | |
| 2061 | } |
| 2062 | style_header("Admin Log"); |
| 2063 | create_admin_log_table(); |
| 2064 | limit = atoi(PD("n","20")); |
| 2065 | fLogEnabled = db_get_boolean("admin-log", 0); |
| 2066 | @ Admin logging is %s(fLogEnabled?"on":"off"). |
| 2067 | |
| 2068 | blob_append_sql(&qLog, |
| 2069 | "SELECT datetime(time,'unixepoch'), who, page, what " |
| 2070 | "FROM admin_log " |
| 2071 | "ORDER BY time DESC "); |
| 2072 | if(limit>0){ |
| 2073 | @ %d(limit) Most recent entries: |
| 2074 | blob_append_sql(&qLog, "LIMIT %d", limit); |
| 2075 | } |
| 2076 | |
| 2077 | db_prepare(&stLog, "%s", blob_sql_text(&qLog)); |
| 2078 | blob_reset(&qLog); |
| 2079 | @ <table id="adminLogTable" class="adminLogTable" width="100%%"> |
| 2080 | @ <thead> |
| 2081 | @ <th>Time</th> |
| @@ -2094,7 +2115,10 @@ | |
| 2094 | @ <td>%s(zPage)</td> |
| 2095 | @ <td>%h(zMessage)</td> |
| 2096 | @ </tr> |
| 2097 | } |
| 2098 | @ </tbody></table> |
| 2099 | style_footer(); |
| 2100 | } |
| 2101 |
| --- src/setup.c | |
| +++ src/setup.c | |
| @@ -2042,14 +2042,31 @@ | |
| 2042 | @ <pre class="th1error">%h(zR)</pre> |
| 2043 | } |
| 2044 | } |
| 2045 | style_footer(); |
| 2046 | } |
| 2047 | |
| 2048 | static void admin_log_render_limits(){ |
| 2049 | int const count = db_int(0,"SELECT COUNT(*) FROM admin_log"); |
| 2050 | int i; |
| 2051 | int limits[] = { |
| 2052 | 10, 20, 50, 100, 250, 500, 0 |
| 2053 | }; |
| 2054 | for(i = 0; limits[i]; ++i ){ |
| 2055 | cgi_printf("%s<a href='?n=%d'>%d</a>", |
| 2056 | i ? " " : "", |
| 2057 | limits[i], limits[i]); |
| 2058 | if(limits[i]>count) break; |
| 2059 | } |
| 2060 | } |
| 2061 | |
| 2062 | /* |
| 2063 | ** WEBPAGE: admin_log |
| 2064 | ** |
| 2065 | ** Shows the contents of the admin_log table, which is only created if |
| 2066 | ** the admin-log setting is enabled. Requires Admin or Setup ('a' or |
| 2067 | ** 's') permissions. |
| 2068 | */ |
| 2069 | void page_admin_log(){ |
| 2070 | Stmt stLog = empty_Stmt; |
| 2071 | Blob qLog = empty_blob; |
| 2072 | int limit; |
| @@ -2061,21 +2078,25 @@ | |
| 2078 | } |
| 2079 | style_header("Admin Log"); |
| 2080 | create_admin_log_table(); |
| 2081 | limit = atoi(PD("n","20")); |
| 2082 | fLogEnabled = db_get_boolean("admin-log", 0); |
| 2083 | @ <div>Admin logging is %s(fLogEnabled?"on":"off").</div> |
| 2084 | |
| 2085 | |
| 2086 | @ <div>Limit results to: <span> |
| 2087 | admin_log_render_limits(); |
| 2088 | @ </span></div> |
| 2089 | |
| 2090 | blob_append_sql(&qLog, |
| 2091 | "SELECT datetime(time,'unixepoch'), who, page, what " |
| 2092 | "FROM admin_log " |
| 2093 | "ORDER BY time DESC "); |
| 2094 | if(limit>0){ |
| 2095 | @ %d(limit) Most recent entries: |
| 2096 | blob_append_sql(&qLog, "LIMIT %d", limit); |
| 2097 | } |
| 2098 | db_prepare(&stLog, "%s", blob_sql_text(&qLog)); |
| 2099 | blob_reset(&qLog); |
| 2100 | @ <table id="adminLogTable" class="adminLogTable" width="100%%"> |
| 2101 | @ <thead> |
| 2102 | @ <th>Time</th> |
| @@ -2094,7 +2115,10 @@ | |
| 2115 | @ <td>%s(zPage)</td> |
| 2116 | @ <td>%h(zMessage)</td> |
| 2117 | @ </tr> |
| 2118 | } |
| 2119 | @ </tbody></table> |
| 2120 | if(limit>0 && counter<limit){ |
| 2121 | @ <div>%d(counter) entries shown.</div> |
| 2122 | } |
| 2123 | style_footer(); |
| 2124 | } |
| 2125 |