# 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 # # Revision: Dec 23, 2003 by Splitsec # Dec 23, 2003: Version 1.01 - Added ability to clear logs # # Revision: Dec 23, 2003 by MrBlack51 # Dec 23, 2003: Version 1.02 - Bugfixes, prevented errors when no logs are found proc action_logs {chan path envr} { global env set TIVO_ROOT $env(TIVO_ROOT) if {[string index $path 1] == "*"} { set path [string range $path 3 end] set logfile [open "$TIVO_ROOT/var/log/$path" "w"] puts $logfile "Log cleared on [ftime [clock seconds] "%a %b %d, %Y"] by TivoWebPlus" close $logfile set path "" } 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=4" "Current Logs"]] catch { set logs [lsort [glob "$TIVO_ROOT/var/log/\[a-z\]*"]] } } elseif {$vers == "Old"} { puts $chan [tr "" [th "COLSPAN=4" "Old Logs"]] catch { set logs [lsort [glob "$TIVO_ROOT/var/log/O*"]] } } puts $chan [tr "" [th "Filename"] [th "Size"] [th "Date"][th "Clear log"]] foreach log $logs { regsub "$TIVO_ROOT/var/log/" $log {} logname puts $chan [tr "" [td [html_link "/logs/$logname/" "$logname"]] [td [file size $log]] [td [ftime [expr [file mtime $log]] "%b %d %H:%M:%S %Y"]][td [html_link "/logs/*/$logname/" "Clear"]]] } } 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 "