Fossil SCM

Added limit selection to /admin_log.

stephan 2014-11-30 14:11 UTC admin-logging
Commit 8355756fb6419a504045f4ab935a9e4681e253ab
1 file changed +26 -2
+26 -2
--- src/setup.c
+++ src/setup.c
@@ -2042,14 +2042,31 @@
20422042
@ <pre class="th1error">%h(zR)</pre>
20432043
}
20442044
}
20452045
style_footer();
20462046
}
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
+}
20472061
20482062
/*
20492063
** WEBPAGE: admin_log
20502064
**
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.
20512068
*/
20522069
void page_admin_log(){
20532070
Stmt stLog = empty_Stmt;
20542071
Blob qLog = empty_blob;
20552072
int limit;
@@ -2061,21 +2078,25 @@
20612078
}
20622079
style_header("Admin Log");
20632080
create_admin_log_table();
20642081
limit = atoi(PD("n","20"));
20652082
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>
20672089
20682090
blob_append_sql(&qLog,
20692091
"SELECT datetime(time,'unixepoch'), who, page, what "
20702092
"FROM admin_log "
20712093
"ORDER BY time DESC ");
20722094
if(limit>0){
20732095
@ %d(limit) Most recent entries:
20742096
blob_append_sql(&qLog, "LIMIT %d", limit);
20752097
}
2076
-
20772098
db_prepare(&stLog, "%s", blob_sql_text(&qLog));
20782099
blob_reset(&qLog);
20792100
@ <table id="adminLogTable" class="adminLogTable" width="100%%">
20802101
@ <thead>
20812102
@ <th>Time</th>
@@ -2094,7 +2115,10 @@
20942115
@ <td>%s(zPage)</td>
20952116
@ <td>%h(zMessage)</td>
20962117
@ </tr>
20972118
}
20982119
@ </tbody></table>
2120
+ if(limit>0 && counter<limit){
2121
+ @ <div>%d(counter) entries shown.</div>
2122
+ }
20992123
style_footer();
21002124
}
21012125
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button