Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Do not drop the accesslog table on a rebuild. If the accesslog table does not exist, do not generate and error on the User-Log report. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
f1efc9059545e0caaffb619eda6586a2 |
| User & Date: | drh 2011-01-19 16:28:30.214 |
Context
|
2011-01-20
| ||
| 17:49 | Change the DOCTYPE to html5. Ticket [9cb4a4d74b2eca66b5f]. Tested on FF, Chrome, Safari, Opera, and IE and seems to work fine. ... (check-in: a2a5e2948b user: drh tags: trunk) | |
|
2011-01-19
| ||
| 16:28 | Do not drop the accesslog table on a rebuild. If the accesslog table does not exist, do not generate and error on the User-Log report. ... (check-in: f1efc90595 user: drh tags: trunk) | |
| 16:16 | Add some primitive clean-up buttons on the access log. ... (check-in: a37abeca65 user: drh tags: trunk) | |
Changes
Changes to src/db.c.
| ︙ | ︙ | |||
189 190 191 192 193 194 195 | } /* ** Prepare a Stmt. Assume that the Stmt is previously uninitialized. ** If the input string contains multiple SQL statements, only the first ** one is processed. All statements beyond the first are silently ignored. */ | | > | > | | > > > > > > > > | | 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
}
/*
** Prepare a Stmt. Assume that the Stmt is previously uninitialized.
** If the input string contains multiple SQL statements, only the first
** one is processed. All statements beyond the first are silently ignored.
*/
int db_vprepare(Stmt *pStmt, int errOk, const char *zFormat, va_list ap){
int rc;
char *zSql;
blob_zero(&pStmt->sql);
blob_vappendf(&pStmt->sql, zFormat, ap);
va_end(ap);
zSql = blob_str(&pStmt->sql);
rc = sqlite3_prepare_v2(g.db, zSql, -1, &pStmt->pStmt, 0);
if( rc!=0 && !errOk ){
db_err("%s\n%s", sqlite3_errmsg(g.db), zSql);
}
pStmt->pNext = pStmt->pPrev = 0;
pStmt->nStep = 0;
return rc;
}
int db_prepare(Stmt *pStmt, const char *zFormat, ...){
int rc;
va_list ap;
va_start(ap, zFormat);
rc = db_vprepare(pStmt, 0, zFormat, ap);
va_end(ap);
return rc;
}
int db_prepare_ignore_error(Stmt *pStmt, const char *zFormat, ...){
int rc;
va_list ap;
va_start(ap, zFormat);
rc = db_vprepare(pStmt, 1, zFormat, ap);
va_end(ap);
return rc;
}
int db_static_prepare(Stmt *pStmt, const char *zFormat, ...){
int rc = SQLITE_OK;
if( blob_size(&pStmt->sql)==0 ){
va_list ap;
va_start(ap, zFormat);
rc = db_vprepare(pStmt, 0, zFormat, ap);
pStmt->pNext = pAllStmt;
pStmt->pPrev = 0;
if( pAllStmt ) pAllStmt->pPrev = pStmt;
pAllStmt = pStmt;
va_end(ap);
}
return rc;
|
| ︙ | ︙ | |||
442 443 444 445 446 447 448 |
** Execute a query and return a single integer value.
*/
i64 db_int64(i64 iDflt, const char *zSql, ...){
va_list ap;
Stmt s;
i64 rc;
va_start(ap, zSql);
| | | | | | | | 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 |
** Execute a query and return a single integer value.
*/
i64 db_int64(i64 iDflt, const char *zSql, ...){
va_list ap;
Stmt s;
i64 rc;
va_start(ap, zSql);
db_vprepare(&s, 0, zSql, ap);
va_end(ap);
if( db_step(&s)!=SQLITE_ROW ){
rc = iDflt;
}else{
rc = db_column_int64(&s, 0);
}
db_finalize(&s);
return rc;
}
int db_int(int iDflt, const char *zSql, ...){
va_list ap;
Stmt s;
int rc;
va_start(ap, zSql);
db_vprepare(&s, 0, zSql, ap);
va_end(ap);
if( db_step(&s)!=SQLITE_ROW ){
rc = iDflt;
}else{
rc = db_column_int(&s, 0);
}
db_finalize(&s);
return rc;
}
/*
** Return TRUE if the query would return 1 or more rows. Return
** FALSE if the query result would be an empty set.
*/
int db_exists(const char *zSql, ...){
va_list ap;
Stmt s;
int rc;
va_start(ap, zSql);
db_vprepare(&s, 0, zSql, ap);
va_end(ap);
if( db_step(&s)!=SQLITE_ROW ){
rc = 0;
}else{
rc = 1;
}
db_finalize(&s);
return rc;
}
/*
** Execute a query and return a floating-point value.
*/
double db_double(double rDflt, const char *zSql, ...){
va_list ap;
Stmt s;
double r;
va_start(ap, zSql);
db_vprepare(&s, 0, zSql, ap);
va_end(ap);
if( db_step(&s)!=SQLITE_ROW ){
r = rDflt;
}else{
r = db_column_double(&s, 0);
}
db_finalize(&s);
return r;
}
/*
** Execute a query and append the first column of the first row
** of the result set to blob given in the first argument.
*/
void db_blob(Blob *pResult, const char *zSql, ...){
va_list ap;
Stmt s;
va_start(ap, zSql);
db_vprepare(&s, 0, zSql, ap);
va_end(ap);
if( db_step(&s)==SQLITE_ROW ){
blob_append(pResult, sqlite3_column_blob(s.pStmt, 0),
sqlite3_column_bytes(s.pStmt, 0));
}
db_finalize(&s);
}
/*
** Execute a query. Return the first column of the first row
** of the result set as a string. Space to hold the string is
** obtained from malloc(). If the result set is empty, return
** zDefault instead.
*/
char *db_text(char *zDefault, const char *zSql, ...){
va_list ap;
Stmt s;
char *z;
va_start(ap, zSql);
db_vprepare(&s, 0, zSql, ap);
va_end(ap);
if( db_step(&s)==SQLITE_ROW ){
z = mprintf("%s", sqlite3_column_text(s.pStmt, 0));
}else if( zDefault ){
z = mprintf("%s", zDefault);
}else{
z = 0;
|
| ︙ | ︙ |
Changes to src/rebuild.c.
| ︙ | ︙ | |||
260 261 262 263 264 265 266 |
db_multi_exec(zSchemaUpdates);
for(;;){
zTable = db_text(0,
"SELECT name FROM sqlite_master /*scan*/"
" WHERE type='table'"
" AND name NOT IN ('blob','delta','rcvfrom','user',"
"'config','shun','private','reportfmt',"
| | | 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
db_multi_exec(zSchemaUpdates);
for(;;){
zTable = db_text(0,
"SELECT name FROM sqlite_master /*scan*/"
" WHERE type='table'"
" AND name NOT IN ('blob','delta','rcvfrom','user',"
"'config','shun','private','reportfmt',"
"'concealed','accesslog')"
" AND name NOT GLOB 'sqlite_*'"
);
if( zTable==0 ) break;
db_multi_exec("DROP TABLE %Q", zTable);
free(zTable);
}
db_multi_exec(zRepositorySchema2);
|
| ︙ | ︙ |
Changes to src/user.c.
| ︙ | ︙ | |||
395 396 397 398 399 400 401 |
** n=N Number of entries to show
** o=N Skip this many entries
*/
void access_log_page(void){
int y = atoi(PD("y","3"));
int n = atoi(PD("n","50"));
int skip = atoi(PD("o","0"));
| < > | 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 |
** n=N Number of entries to show
** o=N Skip this many entries
*/
void access_log_page(void){
int y = atoi(PD("y","3"));
int n = atoi(PD("n","50"));
int skip = atoi(PD("o","0"));
Blob sql;
Stmt q;
int cnt = 0;
int rc;
login_check_credentials();
if( !g.okAdmin ){ login_needed(); return; }
if( P("delall") && P("delallbtn") ){
db_multi_exec("DELETE FROM accesslog");
cgi_redirectf("%s/access_log?y=%d&n=%d&o=%o", g.zTop, y, n, skip);
|
| ︙ | ︙ | |||
437 438 439 440 441 442 443 |
}
blob_appendf(&sql," ORDER BY rowid DESC LIMIT %d OFFSET %d", n+1, skip);
if( skip ){
style_submenu_element("Newer", "Newer entries",
"%s/access_log?o=%d&n=%d&y=%d", g.zTop, skip>=n ? skip-n : 0,
n, y);
}
| | < | | 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 |
}
blob_appendf(&sql," ORDER BY rowid DESC LIMIT %d OFFSET %d", n+1, skip);
if( skip ){
style_submenu_element("Newer", "Newer entries",
"%s/access_log?o=%d&n=%d&y=%d", g.zTop, skip>=n ? skip-n : 0,
n, y);
}
rc = db_prepare_ignore_error(&q, blob_str(&sql));
@ <center><table border="1" cellpadding="5">
@ <tr><th width="33%%">Date</th><th width="34%%">User</th>
@ <th width="33%%">IP Address</th></tr>
while( rc==SQLITE_OK && 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);
cnt++;
if( cnt>n ){
style_submenu_element("Older", "Older entries",
|
| ︙ | ︙ |