Althttpd

Check-in [2fbe3ab673]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Updates to the logview scripts.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 2fbe3ab673eb24d14189df127262f4fd51e777a03c312e3053132d18d56eb9f8
User & Date: drh 2024-08-05 10:35:55.468
Context
2024-08-14
11:03
Minor doc typo fix. ... (check-in: 3603e5f623 user: stephan tags: trunk)
2024-08-05
10:35
Updates to the logview scripts. ... (check-in: 2fbe3ab673 user: drh tags: trunk)
2024-07-30
11:48
Show change log for a successful captcha completion in logview. ... (check-in: 5af635d802 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to logview.
75
76
77
78
79
80
81








82
83
84
85
86
87
88
         SELECT ip FROM log WHERE lineno=2
         EXCEPT
         SELECT ip FROM log WHERE lineno=1
       );
    }
  }
}









# Show the WAPP environment, for debugging.
#
proc wapp-page-env {} {
  check-perms
  wapp-allow-xorigin-params
  wapp-trim {







>
>
>
>
>
>
>
>







75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
         SELECT ip FROM log WHERE lineno=2
         EXCEPT
         SELECT ip FROM log WHERE lineno=1
       );
    }
  }
}

# Output an IP address as a hyperlink.
#
proc iplink {ip} {
  wapp-trim {
    <a href='https://www.geolocation.com/en_us?ip=%html($ip)'>%html($ip)</a>
  }
}

# Show the WAPP environment, for debugging.
#
proc wapp-page-env {} {
  check-perms
  wapp-allow-xorigin-params
  wapp-trim {
381
382
383
384
385
386
387

388
389
390
391
392
393
394
395
396
397




398
399
400
401
402
403
404
405

406
407
408
409
410
411
412
413
  wapp-trim {
    <div class='fossil-doc' data-title='Successful Captchas'>
    <p>
    <table border="1" cellpadding="3" cellspacing="0">
  }
  set previp {}
  set prevagent {}


  db eval {
    SELECT substr(date,-8) AS tm, ip, code, lineno, url, agent
      FROM log
     WHERE (ip,agent) IN (SELECT ip, agent FROM log WHERE lineno=1)
     ORDER BY ip, date
  } {
    if {$ip!=$previp || $agent!=$prevagent} {
      wapp-trim {
        <tr><td colspan="4" align="center">




            <b>%html($ip)</b><br><small>%html($agent)</small>
        </td></tr>
        <tr><th>Time <th>Code <th>Ln <th>URL</tr>
      }
      set previp $ip
      set prevagent $agent
    }
    wapp-trim {

      <tr><td>%html($tm)<td>%html($code)<td>%html($lineno)
          <td>%html($url)</tr>
    }
  }
  wapp-trim {
    </table>
    </div>
  }







>


|







>
>
>
>
|







>
|







389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
  wapp-trim {
    <div class='fossil-doc' data-title='Successful Captchas'>
    <p>
    <table border="1" cellpadding="3" cellspacing="0">
  }
  set previp {}
  set prevagent {}
  set atx [wapp-param BASE_URL]/attime

  db eval {
    SELECT date, substr(date,-8) AS tm, ip, code, lineno, url, agent
      FROM log
     WHERE (ip,agent) IN (SELECT ip, agent FROM log WHERE lineno=1)
     ORDER BY ip, date
  } {
    if {$ip!=$previp || $agent!=$prevagent} {
      wapp-trim {
        <tr><td colspan="4" align="center">
            <b>
      }
      iplink $ip
      wapp-trim {
        </b><br><small>%html($agent)</small>
        </td></tr>
        <tr><th>Time <th>Code <th>Ln <th>URL</tr>
      }
      set previp $ip
      set prevagent $agent
    }
    wapp-trim {
      <tr><td><a href='%html($atx)?d=%qp($date)&ip=%qp($ip)'>%html($tm)</a>
          <td>%html($code)<td>%html($lineno)
          <td>%html($url)</tr>
    }
  }
  wapp-trim {
    </table>
    </div>
  }
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
    <div class='fossil-doc' data-title='Recent Server Activity'>
    <h2>Log Of Requests For http://%html($d)%html%($s)%</h2>
    <p>
    <table border="1" cellpadding="3" cellspacing="0">
    <tr>
    <th>Time <th>IP <th>URL tail <th>Robot
  }
  set ipx [wapp-param BASE_URL]/byip
























  db eval {
    SELECT
        substr(date,12) AS time,
        ip,
        substr(url,uriofst+length(scriptname)) AS url,
        robot
      FROM log
      WHERE domain=$d AND scriptname=$s


  } {











     if {$robot} {
       set r {&#x2713;}
     } else {
       set r {}
     }
     wapp-trim {
       <tr>
       <td>%html($time)
       <td><a href='%html($ipx)?ip=%qp($ip)'>%html($ip)</a>
       <td>%html($url)
       <td align="center">%unsafe($r)
    }

  }
  wapp-trim {
    </table>
  }
  db close
}

proc wapp-page-byip {} {
  check-perms
  set ip [wapp-param ip]
  open-database
  wapp-trim {
    <div class='fossil-doc' data-title='Recent Server Activity'>
    <h2>Log Of Requests For IP address %html($ip)</h2>



    <p>
    <table border="1" cellpadding="3" cellspacing="0">
    <tr>
    <th>Time <th>Result Code <th>URL
  }
  set atx [wapp-param BASE_URL]/attime






















  db eval {
    SELECT
        substr(date,12) AS time,
        code,
        format('%s%s',domain,substr(url,uriofst)) AS url,
        date
      FROM log
      WHERE ip=$ip


  } {


     wapp-trim {









       <tr>
       <td><a href='%html($atx)?d=%qp($date)&ip=%qp($ip)'>%html($time)</a>
       <td>%html($code)
       <td>%html($url)
    }

  }
  wapp-trim {
    </table>
    <h2>User Agents For IP address %html($ip)</h2>
    <p>
    <table border="1" cellpadding="3" cellspacing="0">
    <tr>







|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>








>
>

>
>
>
>
>
>
>
>
>
>
>
|
|
|
|
|
|






>













|
>
>
>





|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>








>
>

>
>
|
>
>
>
>
>
>
>
>
>
|
|
|
|

>







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
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
    <div class='fossil-doc' data-title='Recent Server Activity'>
    <h2>Log Of Requests For http://%html($d)%html%($s)%</h2>
    <p>
    <table border="1" cellpadding="3" cellspacing="0">
    <tr>
    <th>Time <th>IP <th>URL tail <th>Robot
  }
  set base [wapp-param BASE_URL]
  set ipx $base/byip
  set atx $base/attime
  set self $base/byuri
  set n 0
  if {[wapp-param-exists all]} {
    set limit 1000000000
    set offset 0
  } else {
    set limit 200
    set offset [wapp-param offset]
    if {![string is integer -strict $offset] || $offset<=0} {
      set offset 0
    } else {
      set p [expr {$offset-$limit}]
      if {$p<0} {$p=0}
      wapp-trim {
        <tr><td colspan="4" align="center">
        <a href='%html($self)?d=%html($d)&s=%html($s)&offset=%html($p)'>
        Earlier entries</a>&nbsp;&nbsp;|&nbsp;&nbsp;
        <a href='%html($self)?d=%html($d)&s=%html($s)&all'>All Entries</a>
      }
    }
  }

  db eval {
    SELECT
        substr(date,12) AS time,
        ip,
        substr(url,uriofst+length(scriptname)) AS url,
        robot
      FROM log
      WHERE domain=$d AND scriptname=$s
      ORDER BY time
      LIMIT -1 OFFSET $offset
  } {
    if {$n>=$limit} {
      set nx [expr {$offset+$limit}]
      wapp-trim {
        <tr><td colspan="4" align="center">
        <a href='%html($self)?d=%html($d)&s=%html($s)&offset=%html($nx)'>
        Later entries</a> &nbsp;&nbsp; | &nbsp;&nbsp;
        <a href='%html($self)?ip=%html($ip)&all'>
        All entries</a>
      }
      break;
    }
    if {$robot} {
      set r {&#x2713;}
    } else {
      set r {}
    }
    wapp-trim {
       <tr>
       <td>%html($time)
       <td><a href='%html($ipx)?ip=%qp($ip)'>%html($ip)</a>
       <td>%html($url)
       <td align="center">%unsafe($r)
    }
    incr n
  }
  wapp-trim {
    </table>
  }
  db close
}

proc wapp-page-byip {} {
  check-perms
  set ip [wapp-param ip]
  open-database
  wapp-trim {
    <div class='fossil-doc' data-title='Recent Server Activity'>
    <h2>Log Of Requests For IP address&#32;
  }
  iplink $ip
  wapp-trim {</h2>
    <p>
    <table border="1" cellpadding="3" cellspacing="0">
    <tr>
    <th>Time <th>Result Code <th>URL
  }
  set base [wapp-param BASE_URL]
  set atx $base/attime
  set self $base/byip
  set n 0
  if {[wapp-param-exists all]} {
    set limit 1000000000
    set offset 0
  } else {
    set limit 200
    set offset [wapp-param offset]
    if {![string is integer -strict $offset] || $offset<=0} {
      set offset 0
    } else {
      set p [expr {$offset-$limit}]
      if {$p<0} {$p=0}
      wapp-trim {
        <tr><td colspan="3" align="center">
        <a href='%html($self)?ip=%html($ip)&offset=%html($p)'>
        Earlier entries</a>&nbsp;&nbsp;|&nbsp;&nbsp;
        <a href='%html($self)?ip=%html($ip)&all'>All Entries</a>
      }
    }
  }
  db eval {
    SELECT
        substr(date,12) AS time,
        code,
        format('%s%s',domain,substr(url,uriofst)) AS url,
        date
      FROM log
      WHERE ip=$ip
      ORDER BY time
      LIMIT -1 OFFSET $offset
  } {
    if {$n>=$limit} {
      set nx [expr {$offset+$limit}]
      wapp-trim {
        <tr><td colspan="3" align="center">
        <a href='%html($self)?ip=%html($ip)&offset=%html($nx)'>
        Later entries</a> &nbsp;&nbsp; | &nbsp;&nbsp;
        <a href='%html($self)?ip=%html($ip)&all'>
        All entries</a>
      }
      break;
    }
    wapp-trim {
      <tr>
      <td><a href='%html($atx)?d=%qp($date)&ip=%qp($ip)'>%html($time)</a>
      <td>%html($code)
      <td>%html($url)
    }
    incr n
  }
  wapp-trim {
    </table>
    <h2>User Agents For IP address %html($ip)</h2>
    <p>
    <table border="1" cellpadding="3" cellspacing="0">
    <tr>
550
551
552
553
554
555
556
557




558
559
560
561
562
563
564
proc wapp-page-attime {} {
  check-perms
  set d [wapp-param d]
  set ip [wapp-param ip]
  open-database
  wapp-trim {
    <div class='fossil-doc' data-title='Recent Server Activity'>
    <h2>Requests from %html($ip) occurring at %html($d)</h2>




    <p>
    <table border="0" cellpadding="0" cellspacing="0">
  }
  set ipx [wapp-param BASE_URL]/byip
  set cnt 0
  db eval {
    SELECT * FROM log WHERE date=$d AND ip=$ip







|
>
>
>
>







641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
proc wapp-page-attime {} {
  check-perms
  set d [wapp-param d]
  set ip [wapp-param ip]
  open-database
  wapp-trim {
    <div class='fossil-doc' data-title='Recent Server Activity'>
    <h2>Requests from&#32;
  }
  iplink $ip
  wapp-trim {
    &#32;occurring at %html($d)</h2>
    <p>
    <table border="0" cellpadding="0" cellspacing="0">
  }
  set ipx [wapp-param BASE_URL]/byip
  set cnt 0
  db eval {
    SELECT * FROM log WHERE date=$d AND ip=$ip