# Copyright (c) 2001 Jeff Keegan (jkeegan@keegan.org) # $Id: # # Logs module by Jeff Keegan, http://www.keegan.org/jeff # # History: # First version, August 27, 2001 # August 27, 2001: Version 1.0 # proc action_logs {chan path envr} { global tzoffset env set TIVO_ROOT $env(TIVO_ROOT) if {[string index $path 0] == "/"} { set path [string range $path 1 end] } if {$path == ""} { puts $chan [html_start "Logs"] puts $chan [html_table_start "" "" ""] foreach vers {Current Old} { set logs "" if {$vers == "Current"} { puts $chan [tr "" [th "COLSPAN=3" "Current Logs"]] set logs [lsort [glob "$TIVO_ROOT/var/log/\[a-z\]*"]] } elseif {$vers == "Old"} { puts $chan [tr "" [th "COLSPAN=3" "Old Logs"]] set logs [lsort [glob "$TIVO_ROOT/var/log/O*"]] } puts $chan [tr "" [th "Filename"] [th "Size"] [th "Date"]] foreach log $logs { regsub "$TIVO_ROOT/var/log/" $log {} logname puts $chan [tr "" [td [html_link "/logs/$logname/" "$logname"]] [td [file size $log]] [td [clock format [expr [file mtime $log] + $tzoffset] -format "%b %d %H:%M:%S"]]] } } puts $chan [html_table_end] puts $chan [html_end] } else { puts $chan [html_start "Logs: $TIVO_ROOT/var/log/$path"] if { [regexp {\.\.} $path]} { puts $chan "please don't do that" puts $chan [html_end] return } puts $chan [html_table_start "" "$TIVO_ROOT/var/log/$path" ""] puts $chan "" set fsize [file size "$TIVO_ROOT/var/log/$path"] set logfile [open "$TIVO_ROOT/var/log/$path" "r"] while { ! [eof $logfile] } { set line [gets $logfile] puts $chan [htmlEncode "$line\n"] } puts $chan "" close $logfile puts $chan [html_table_end] puts $chan [html_end] } } register_module "logs" "Logs" "View TiVo log files"