Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Change the name of the admin-log table to "admin_log". Only write to it if the "admin-log" setting is enabled (off by default). Make sure the admin_log table is created in the repository and not in the local or config databases. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | admin-logging |
| Files: | files | file ages | folders |
| SHA1: |
5e0514a607f0fc5ed57099a42832cf95 |
| User & Date: | drh 2014-11-28 15:05:10.146 |
Context
|
2014-11-28
| ||
| 17:38 | Added basic /admin_log page, added settings change logging through onoff_attribute(). check-in: 8f1fc45581 user: stephan tags: admin-logging | |
| 15:05 | Change the name of the admin-log table to "admin_log". Only write to it if the "admin-log" setting is enabled (off by default). Make sure the admin_log table is created in the repository and not in the local or config databases. check-in: 5e0514a607 user: drh tags: admin-logging | |
|
2014-11-27
| ||
| 16:59 | Added admin_log(), for (informally) recording changes made by admins. check-in: ee666c46fb user: stephan tags: admin-logging | |
Changes
Changes to src/db.c.
| ︙ | ︙ | |||
2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 |
int versionable; /* Is this setting versionable? */
int forceTextArea; /* Force using a text area for display? */
const char *def; /* Default value */
};
#endif /* INTERFACE */
struct stControlSettings const ctrlSettings[] = {
{ "access-log", 0, 0, 0, 0, "off" },
{ "allow-symlinks", 0, 0, 1, 0, "off" },
{ "auto-captcha", "autocaptcha", 0, 0, 0, "on" },
{ "auto-hyperlink", 0, 0, 0, 0, "on", },
{ "auto-shun", 0, 0, 0, 0, "on" },
{ "autosync", 0, 0, 0, 0, "on" },
{ "autosync-tries", 0, 16, 0, 0, "1" },
{ "binary-glob", 0, 40, 1, 0, "" },
| > | 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 |
int versionable; /* Is this setting versionable? */
int forceTextArea; /* Force using a text area for display? */
const char *def; /* Default value */
};
#endif /* INTERFACE */
struct stControlSettings const ctrlSettings[] = {
{ "access-log", 0, 0, 0, 0, "off" },
{ "admin-log", 0, 0, 0, 0, "off" },
{ "allow-symlinks", 0, 0, 1, 0, "off" },
{ "auto-captcha", "autocaptcha", 0, 0, 0, "on" },
{ "auto-hyperlink", 0, 0, 0, 0, "on", },
{ "auto-shun", 0, 0, 0, 0, "on" },
{ "autosync", 0, 0, 0, 0, "on" },
{ "autosync-tries", 0, 16, 0, 0, "1" },
{ "binary-glob", 0, 40, 1, 0, "" },
|
| ︙ | ︙ | |||
2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 | ** file exists. ** ** The "unset" command clears a property setting. ** ** ** access-log If enabled, record successful and failed login attempts ** in the "accesslog" table. Default: off ** ** allow-symlinks If enabled, don't follow symlinks, and instead treat ** (versionable) them as symlinks on Unix. Has no effect on Windows ** (existing links in repository created on Unix become ** plain-text files with link destination path inside). ** Default: off ** | > > > | 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 | ** file exists. ** ** The "unset" command clears a property setting. ** ** ** access-log If enabled, record successful and failed login attempts ** in the "accesslog" table. Default: off ** ** admin-log If enabled, record configuration changes in the ** "admin_log" table. Default: off ** ** allow-symlinks If enabled, don't follow symlinks, and instead treat ** (versionable) them as symlinks on Unix. Has no effect on Windows ** (existing links in repository created on Unix become ** plain-text files with link destination path inside). ** Default: off ** |
| ︙ | ︙ | |||
2658 2659 2660 2661 2662 2663 2664 |
blob_append_sql(&allSql,
"ALTER TABLE \"%w\" RENAME TO \"x_%w\";\n"
"%s WITHOUT ROWID;\n"
"INSERT INTO \"%w\" SELECT * FROM \"x_%w\";\n"
"DROP TABLE \"x_%w\";\n",
zTName, zTName, blob_sql_text(&newSql), zTName, zTName, zTName
);
| | > | | > > | < < < < < < | | > | | | | | | > | < | > > > > > > > > > > > < | | | < | 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 |
blob_append_sql(&allSql,
"ALTER TABLE \"%w\" RENAME TO \"x_%w\";\n"
"%s WITHOUT ROWID;\n"
"INSERT INTO \"%w\" SELECT * FROM \"x_%w\";\n"
"DROP TABLE \"x_%w\";\n",
zTName, zTName, blob_sql_text(&newSql), zTName, zTName, zTName
);
fossil_print("Converting table %s of %s to WITHOUT ROWID.\n",
zTName, g.argv[i]);
blob_reset(&newSql);
}
blob_append_sql(&allSql, "COMMIT;\n");
db_finalize(&q);
if( dryRun ){
fossil_print("SQL that would have been evaluated:\n");
fossil_print("%.78c\n", '-');
fossil_print("%s", blob_sql_text(&allSql));
}else{
db_multi_exec("%s", blob_sql_text(&allSql));
}
blob_reset(&allSql);
db_close(1);
}
}
/*
** Make sure the adminlog table exists. Create it if it does not
*/
void create_admin_log_table(void){
static int once = 0;
if( once ) return;
once = 1;
db_multi_exec(
"CREATE TABLE IF NOT EXISTS \"%w\".admin_log(\n"
" id INTEGER PRIMARY KEY,\n"
" time FLOAT, -- Seconds since 1970\n"
" page TEXT, -- path of page\n"
" who TEXT, -- User who made the change\n "
" what TEXT -- What changed\n"
")", db_name("repository")
);
}
/*
** Write a message into the admin_event table, if admin logging is
** enabled
*/
void admin_log(const char *zFormat, ...){
Blob what = empty_blob;
va_list ap;
int rc;
if( !db_get_boolean("admin-log", 0) ) return;
create_admin_log_table();
va_start(ap,zFormat);
blob_vappendf( &what, zFormat, ap );
va_end(ap);
db_multi_exec("INSERT INTO admin_log(time,page,who,what)"
" VALUES(now(), %Q, %Q, %B)",
g.zPath, g.zLogin, &what);
blob_reset(&what);
}
|