iLog Viewer — File Browser
iLogViewerv2.0 / iLogViewerv2.0 / iLog.mrc
iLog.mrc — 35.91 KB — Download this file
; Read the help file: iLog.hlp for more information
; *****************************************
; iLog Viewer v2.0 2010-NOV-30
; � Copyright 2007-2010 http://ilog.the-i.org
; 'thei' /server irc.austnet.org
; *****************************************
; To load the script type in a mIRC channel:
; /load -rs iLog.mrc
; where 'iLog.mrc' is where the file 'iLog.mrc' is,
; for example it may be '/downloads/iLog.mrc'
;Once the script is loaded, type
; /ilog
; to start iLog Viewer.
; You may change the word 'ilog' below to another word to change the alias used to invoke iLog Viewer
; for example:
; alias mylogviewer {
alias ilog {
; //// !WARNING! !WARNING! \\\\
; \\\\ DO NOT EDIT BELOW HERE ////
iLog2 $1-
}
alias iLog2 {
; Check version and ini file
if ($version < 5.91) {
echo 4 -a ERROR: You are using version $version of mIRC. iLog2 Viewer requires mIRC 5.91 or better. Please upgrade from www.mirc.com now.
unload -rs $script
}
if ( ($exists(thei.ini)) && $&
($exists($readini(thei.ini, ILOG, Editor))) && $&
($readini(thei.ini, ILOG, DateType) isnum 1-3) && $&
($exists($readini(thei.ini, ILOG, Logdir))) && $&
($exists($readini(thei.ini, ILOG, Logdir2))) && $&
($exists($readini(thei.ini, ILOG, Logdir3))) && $&
($readini(thei.ini, 112, n1)) && $&
($readini(thei.ini, 116, n1)) && $&
($readini(thei.ini, 122, n1)) && $&
($readini(thei.ini, 126, n1)) && $&
($readini(thei.ini, ILOG, ViewOpen)) && $&
($readini(thei.ini, ILOG, ViewStrip)) ) {
if ($dialog(ilog2)) {
; if iLog main window already made, show
dialog -v ilog2
}
else {
; make iLog main window
dialog -mdv ilog2 ilog2
}
}
; Make defaults if ini faulty/not found
else {
_MakeIni
if ($exists($scriptdir\ilog.hlp)) run $scriptdir\ilog.hlp
}
; Check for updated version
_CheckUpdate
; Parse command line
if ($1) _iLogCommand $1-
}
; Basic command line support /iLog2 [-t] SearchString
alias -l _iLogCommand {
; Set the dialog back to its original state
_ShowTab 1
_ShowSearchBox 113,117,123,127,133,137,141 112,114,116,118,122,124,126,128,132,134,136,138,140,142
; if -t today, else normal command
if ($1 == -t) {
_ShowSearchBox 132,134,136,138,140,142 133,137,141
did -c iLog2 132 $asctime(d)
did -c iLog2 136 $asctime(m)
; 2011 date must be updated to current year + 1
did -c iLog2 140 $calc(2011 - $asctime(yyyy) )
if ($2) {
_ShowSearchBox 112,114 113
did -i iLog2 112 0 $2
}
}
else {
_ShowSearchBox 112,114 113
did -i iLog2 112 0 $1
}
_DoSearch
}
; Menu
menu menubar,channel,nicklist,query {
�� Log
.Search for logs...: iLog2
; .$iif($menu == nicklist,): iLog2 $lala
.$iif($menu == channel,...matching #): iLog2 #
.$iif($menu == query,...matching $1): iLog2 $1
.-
.$iif($readini(thei.ini, ILOG, DateType) == 2,...modified,...created) today $date(dd mmm yyyy): iLog2 -t
.$iif($menu == channel,...and matching #): iLog2 -t #
.$iif($menu == query,...and matching $1): iLog2 -t $1
.-
.Help: if ($exists($scriptdir\ilog.hlp)) run $scriptdir\ilog.hlp
}
; New version available dialog
dialog -l iLogUpdate {
title "iLog2 - New Version Available"
icon $scriptdir\i.ico
option dbu
size -1 -1 150 80
text "A new, improved, version of iLog is available for download.", 1, 25 5 125 15
text "", 2, 25 20 125 40
button "Download...", 3, 105 65 40 10, ok default flat
button "Cancel", 4, 70 65 30 10, cancel flat
icon 5, 5 5 16 16, $scriptdir\info.ico
}
; Download clicked on iLogUpdate dialog
on *:dialog:iLogUpdate:sclick:3: {
url -n http://ilog.the-i.org/
}
dialog -l iLogPop {
title "iLog2 - No Matches Found"
icon $scriptdir\i.ico
option dbu
size -1 -1 150 25
button "Ok", 1, 115 13 30 10, ok default flat
text "No matches found. Please refine your search.", 2, 25 5 90 25
icon 3, 5 5 16 16, $scriptdir\info.ico
}
dialog -l iLogStrip {
title "iLog2 Log Stripper Warning - Large Log"
icon $scriptdir\i.ico
option dbu
size -1 -1 180 25
button "Strip", 1, 145 2 30 10, ok flat
button "Cancel", 2, 145 13 30 10, cancel default flat result
text %iLogPop, 3, 25 3 120 20
icon 4, 5 5 16 16, $scriptdir\info.ico
}
;
; Main iLog Dialog
;
dialog iLog2 {
title "iLog Viewer"
icon $scriptdir\i.ico
option dbu
size -1 -1 250 175
; Hidden tabs for sections
tab "", 1, -25 -25 1 1, disable hide
tab "", 2, -25 -25 1 1, disable hide
tab "", 3, -25 -25 1 1, disable hide
; Common
text "", 5, 1 1 1 1
button "Close", 900, 190 160 50 12, cancel flat
link "Help", 901, 214 7 13 9
link "WWW", 903, 227 7 15 9
list 902, 1 1 1 1, hide
;tab 1 Search
box "iLog Search", 100, 5 2 240 155, disabled tab 1
button "Search", 101, 10 160 50 12, flat disable default tab 1
button "New Search", 102, 70 160 50 12, flat hide tab 1
button "Options", 103, 160 160 25 12, flat tab 1
; Filename 11x
box "Log filename:", 110, 5 13 240 30, tab 1
text "Contains:", 111, 10 20 50 9, tab 1
combo 112, 8 28 90 50, size edit drop hide tab 1
button "Enable", 113, 8 28 115 10, flat tab 1
button "Disable", 114, 98 28 25 10, flat hide tab 1
text "Does Not Contain:", 115, 127 20 50 9, tab 1
combo 116, 125 28 90 50, size edit drop hide tab 1
button "Enable", 117, 125 28 115 10, flat tab 1
button "Disable", 118, 215 28 25 10, flat hide tab 1
; Log text 12x
box "Log text:", 120, 5 53 240 30, tab 1
text "Contains:", 121, 10 60 50 9, tab 1
combo 122, 8 68 90 50, size edit drop hide tab 1
button "Enable", 123, 8 68 115 10, flat tab 1
button "Disable", 124, 98 68 25 10, flat hide tab 1
text "Does Not Contain:", 125, 127 60 50 9, tab 1
combo 126, 125 68 90 50, size edit drop hide tab 1
button "Enable", 127, 125 68 115 10, flat tab 1
button "Disable", 128, 215 68 25 10, flat hide tab 1
; Log date 13x, 14x
box "Log date:", 130, 5 93 240 30, tab 1
text "Day:", 131, 10 100 50 9, tab 1
combo 132, 10 108 25 100, drop hide tab 1
button "Enable", 133, 10 108 49 10, flat tab 1
button "Disable", 134, 35 108 24 10, flat hide tab 1
text "Month:", 135, 60 100 50 9, tab 1
combo 136, 60 108 25 100, drop hide tab 1
button "Enable", 137, 60 108 49 10, flat tab 1
button "Disable", 138, 85 108 24 10, flat hide tab 1
text "Year:", 139, 110 100 50 9, tab 1
combo 140, 110 108 25 100, drop hide tab 1
button "Enable", 141, 110 108 49 10, flat tab 1
button "Disable", 142, 135 108 24 10, flat hide tab 1
text $date(dd mmm yyyy), 143, 180 100 50 9, tab 1
button "Today", 144, 180 108 50 10, flat tab 1
; Status 15x
box "Status:", 150, 5 133 240 24, tab 1
text "Waiting for search criteria...", 151, 10 140 200 9, tab 1
;tab 2 Options
box "Configuration - iLog Viewer 2.0 - 'thei' - /server irc.austnet.org", 200, 5 2 240 155, disabled tab 2
button "Save", 201, 160 160 25 12, flat tab 2
button "Search", 202, 10 160 50 12, flat disable tab 2
; Log editor
text "Application to open log files with:" 211, 8 45 100 10, tab 2
button "Select a log editing or viewing application..." 212, 8 53 200 10, flat tab 2
check "Default", 235, 210 53 30 10, push flat tab 2
; Log directories
text "Custom log directories:" 213, 8 68 100 10, tab 2
button "Select the log directory..." 214, 8 76 200 10, flat tab 2
check "Default", 215, 210 76 30 10, push flat tab 2
button "Select the log directory..." 216, 8 87 200 10, flat hide tab 2
button "Enable secondary log directory..." 236, 8 87 232 10, flat tab 2
button "Disable", 217, 210 87 30 10, flat hide tab 2
button "Select the log directory..." 218, 8 98 200 10, flat hide tab 2
button "Enable third log directory..." 238, 8 98 232 10, flat tab 2
button "Disable", 219, 210 98 30 10, flat hide tab 2
; Date search format
text "Select the date search format, start with the first and use the others if that fails:", 220, 8 113 210 10, tab 2
radio "Use date in log filename", 221, 8 121 200 10, push flat group tab 2
radio "Use date file was modified", 222, 8 132 200 10, push flat tab 2
radio "Use date file was created", 223, 8 143 200 10, push flat tab 2
; Version link/icon
text "Latest News", 224, 10 15 232 27, tab 2
link "2010-NOV-30", 225, 210 150 33 10, right tab 2
icon 226, 218 128 15 15, $scriptdir\i.ico, tab 2
text "", 299, 1 1 1 1
;tab 3 Results
box "iLog Search Results", 300, 5 2 240 155, disabled tab 3
button "New Search", 301, 10 160 50 12, flat tab 3
button "Search in Found", 302, 70 160 50 12, flat tab 3
; Top text "xx lines - xx bytes..."
text "", 312, 10 9 220 8, tab 3
; Search results list
list 310, 5 18 240 106, tab 3
; Log Preview
box "Log preview:", 311, 5 120 240 37, tab 3
text "", 313, 10 127 225 28, tab 3
link "<-", 314, 236 127 8 10, hide tab 3
link "->", 315, 236 147 8 10, hide tab 3
; view/open etc. logs 32x
text "Double clicking log will", 320, 93 115 54 9, tab 3
link "view", 321, 148 115 12 9, tab 3
link "open", 322, 148 115 12 9, hide tab 3
text "it with the colour codes", 323, 162 115 56 9, tab 3
link "stripped ", 324, 219 115 20 9, tab 3
link "included", 325, 219 115 20 9, hide tab 3
; "xx/xx found" button
button "", 326, 200 25 32 10, tab 3
text "", 399, 1 1 1 1
}
;
; Dialog events
;
; On Click events
; in case tab is selected, shift focus to null object
on *:dialog:iLog2:*:1,2,3: did -f iLog2 902
; init. the dialog
on *:dialog:iLog2:init:0: {
did -f iLog2 902
_ReadSearchBoxItems
_AddDateBoxItems
}
; View log on double click
on *:dialog:ilog2:dclick:310: {
if ($readini(thei.ini, ILOG, ViewOpen) == open) _OpenLog
else _ViewLog
}
; Single click events
on *:dialog:iLog2:sclick:*: {
; Cancel
if ($did == 900) {
unset iLog*
hfree -w iLog*
}
; "?" Help
if ($did == 901) {
if ($exists($scriptdir\iLog.hlp)) run $scriptdir\iLog.hlp
}
;tab 1 Search
; Buttons Search/Clear Search/Options
if ($did == 101) _LogSearch
if ($did == 102) _NewSearch StartNew
if ($did == 103) _StartOptions
;Log filename Contains/Does not contain (Enable/Disable)
if ($did == 113) _ShowSearchBox 112,114 113
if ($did == 114) _ShowSearchBox 113 112,114
if ($did == 117) _ShowSearchBox 116,118 117
if ($did == 118) _ShowSearchBox 117 116,118
;Log text Contains/Does not contain (Enable/Disable)
if ($did == 123) _ShowSearchBox 122,124 123
if ($did == 124) _ShowSearchBox 123 122,124
if ($did == 127) _ShowSearchBox 126,128 127
if ($did == 128) _ShowSearchBox 127 126,128
; Day (Enable/Disable)
if ($did == 133) _ShowSearchBox 132,134 133
if ($did == 134) _ShowSearchBox 133 132,134
; Month (Enable/Disable)
if ($did == 137) _ShowSearchBox 136,138 137
if ($did == 138) _ShowSearchBox 137 136,138
; Year (Enable/Disable)
if ($did == 141) _ShowSearchBox 140,142 141
if ($did == 142) _ShowSearchBox 141 140,142
; Today
if ($did == 144) {
_ShowSearchBox 132,134,136,138,140,142 133,137,141
did -c iLog2 132 $asctime(d)
did -c iLog2 136 $asctime(m)
; 2011 date must be updated to current year + 1
did -c iLog2 140 $calc(2011 - $asctime(yyyy) )
}
;tab 2 Options
; Save
if ($did == 201) _SaveOptions
; Show/hide secondary/third log dir
if ($did == 236) _ShowSearchBox 216,217 236
if ($did == 217) _ShowSearchBox 236 216,217
if ($did == 238) _ShowSearchBox 218,219 238
if ($did == 219) _ShowSearchBox 238 218,219
; Select editor/Log Dirs 1/2/3
if ($did == 212) did -o iLog2 212 1 $sfile($readini(thei.ini, ILOG, Editor), Select Text Editing Application, Select)
if ($did == 214) did -o iLog2 214 1 $shortfn($sdir($readini(thei.ini, ILOG, LogDir), Select the Log Directory))
if ($did == 216) did -o iLog2 216 1 $shortfn($sdir($readini(thei.ini, ILOG, LogDir2), Select the Log Directory))
if ($did == 218) did -o iLog2 218 1 $shortfn($sdir($readini(thei.ini, ILOG, LogDir3), Select the Log Directory))
; Use default editor/log dir
if ($did == 235) {
if ($did(235).state) did -bo iLog2 212 1 $_DefaultEditor
else did -eo iLog2 212 1 $readini(thei.ini, ILOG, Editor)
}
if ($did == 215) {
if ($did(215).state) did -bo iLog2 214 1 $logdir
else did -eo iLog2 214 1 $shortfn($readini(thei.ini, ILOG, LogDir))
}
; WWW link, Version link and icon
if ( ($did == 903) || ($did == 225) || ($did == 226) ) url -n http://ilog.the-i.org/
;tab 3 Results
; New Search/Search in results
if ($did == 301) _NewSearch StartNew
if ($did == 302) _NewSearch
; Show log info and <- -> buttons
if ($did == 310) _ShowLogInfo top
if ($did == 314) _ShowLogInfo prev
if ($did == 315) _ShowLogInfo next
; Toggle view/open and stripped/included
if ($did == 321) _ViewSettings open strip
if ($did == 322) _ViewSettings view either
if ($did == 324) _ViewSettings view incl
if ($did == 325) _ViewSettings either strip
}
;
; Dialog aliases
;
; Common dialog
; Show tabs
; /ShowTab tabnumber
alias -l _ShowTab {
;show 1
if ($1 == 1) {
did -h iLog2 2,3
did -vf iLog2 1
}
;show 2
if ($1 == 2) {
did -h iLog2 1,3
did -vf iLog2 2
}
;show 3
if ($1 == 3) {
did -h iLog2 1,2
did -vf iLog2 3
}
; set focus off tabs/enable disable default search button
did -f iLog2 902
_EnableSearch
}
; Show/hide search buttons
; /_ShowSearchBox show,show hide,hide
alias -l _ShowSearchBox {
did -cv iLog2 $1 1
; set focus on first id
did -f iLog2 $gettok($1,1,44)
did -h iLog2 $2
; Enable search if combo box is visible
_EnableSearch
}
; Search dialog
; When search is clicked
alias -l _LogSearch {
; Filename Contains 112 - Does not contain 116
; Log Text Contains 122 - Does not contain 126
if ($did(iLog2,112) != $null) { _AddSearch 112 $ifmatch }
if ($did(iLog2,116) != $null) { _AddSearch 116 $ifmatch }
if ($did(iLog2,122) != $null) { _AddSearch 122 $ifmatch }
if ($did(iLog2,126) != $null) { _AddSearch 126 $ifmatch }
_DoSearch
}
; Recall previous searches
alias -l _ReadSearchBoxItems {
; Load previous searches into Filename contains
var %i = 1
while ($readini(thei.ini,n,112,$+(n,%i)) != $null) {
did -a iLog2 112 $ifmatch
inc %i
}
; Load previous searches into Filename does not contain
var %i = 1
while ($readini(thei.ini,n,116,$+(n,%i)) != $null) {
did -a iLog2 116 $ifmatch
inc %i
}
; Load previous searches into Text contains
var %i = 1
while ($readini(thei.ini,n,122,$+(n,%i)) != $null) {
did -a iLog2 122 $ifmatch
inc %i
}
; Load previous searches into Text does not contain
var %i = 1
while ($readini(thei.ini,n,126,$+(n,%i)) != $null) {
did -a iLog2 126 $ifmatch
inc %i
}
}
; Add search items to combo boxes
; /_AddSearch id text
alias -l _AddSearch {
var %i = 10
while (%i > 0) {
if ($2- == $did(iLog2,$1,%i).text ) { did -d iLog2 $1 %i }
dec %i
}
did -i iLog2 $1 1 $2-
while ($did(iLog2,$1).lines > 10 ) { did -d iLog2 $1 11 }
var %i = 1
while ((%i < 11) && ($did(iLog2,$1,%i)) ) {
writeini thei.ini $1 $+(n,%i) $did(iLog2,$1,%i)
inc %i
}
did -c iLog2 $1 1
}
alias -l _AddDateBoxItems {
; Days
var %i 1
while (%i < 32) {
did -a iLog2 132 %i
inc %i
}
; Months
didtok iLog2 136 32 Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
; Years (Note: adding year 2011 will break script - do a find/replace "2011" with "2012")
didtok iLog2 140 32 2010 2009 2008 2007 2006 2005 2004 2003 2002 2001 2000 1999 1998 1997 1996 1995
}
; Enable search if a criteria is visible
alias -l _EnableSearch {
if ( ($did(iLog2,112).visible) || ($did(iLog2,116).visible) || ($did(iLog2,122).visible) || ($did(iLog2,126).visible) || ($did(iLog2,132).visible) || ($did(iLog2,136).visible) || ($did(iLog2,140).visible) ) {
did -e iLog2 101
did -o iLog2 151 1 Ready to search...
}
else {
did -b iLog2 101
did -o iLog2 151 1 Waiting for search criteria...
}
}
; Options dialog
; Load settings for options
alias -l _StartOptions {
; Buttons
did -o iLog2 212 1 $readini(thei.ini, ILOG, Editor)
did -o iLog2 214 1 $readini(thei.ini, ILOG, LogDir)
did -o iLog2 216 1 $readini(thei.ini, ILOG, LogDir2)
did -o iLog2 218 1 $readini(thei.ini, ILOG, LogDir3)
; Editor/Log directories enabled/disabled
if ($readini(thei.ini, ILOG, UseDefEditor)) { did -c iLog2 235 | did -b iLog2 212 }
if ($readini(thei.ini, ILOG, UseDefLogDir)) { did -c iLog2 215 | did -b iLog2 214 }
if ($readini(thei.ini, ILOG, UseLogDir2)) _ShowSearchBox 216,217 236
if ($readini(thei.ini, ILOG, UseLogDir3)) _ShowSearchBox 218,219 238
; Checkboxes - Log type - dated daily/monthly/not dated
if ($readini(thei.ini, ILOG, DateType) == 1) did -c iLog2 221
if ($readini(thei.ini, ILOG, DateType) == 2) did -c iLog2 222
if ($readini(thei.ini, ILOG, DateType) == 3) did -c iLog2 223
did -c iLog2 201
; Check for update messages
_WebUpdate
_ShowTab 2
}
; Save options
alias -l _SaveOptions {
if ($did(212)) writeini thei.ini ILOG Editor $ifmatch
writeini thei.ini ILOG UseDefEditor $did(235).state
if ($did(214)) writeini thei.ini ILOG LogDir $ifmatch
writeini thei.ini ILOG UseDefLogDir $did(215).state
if ($did(216)) writeini thei.ini ILOG LogDir2 $ifmatch
writeini thei.ini ILOG UseLogDir2 $did(216).visible
if ($did(218)) writeini thei.ini ILOG LogDir3 $ifmatch
writeini thei.ini ILOG UseLogDir3 $did(218).visible
if ($did(221).state) writeini thei.ini ILOG DateType 1
if ($did(222).state) writeini thei.ini ILOG DateType 2
if ($did(223).state) writeini thei.ini ILOG DateType 3
; close the update socket
_CloseUpdateSocket
_ShowTab 1
}
alias -l _DefaultEditor {
return $findfile(C:\,notepad.exe,1,2)
}
; Search results dialog
; Save view/open strip/incl settings
alias -l _ViewSettings {
if (view isin $1-) _ShowSearchBox 321 322
if (open isin $1-) _ShowSearchBox 322 321
if (strip isin $1-) _ShowSearchBox 324 325
if (incl isin $1-) _ShowSearchBox 325 324
if ($1 != either) writeini thei.ini ILOG ViewOpen $1
if ($2 != either) writeini thei.ini ILOG ViewStrip $2
}
; Search the found results
alias -l _NewSearch {
if ($1) {
; start a new search
did -h iLog2 102
did -o iLog2 101 1 Search
did -o iLog2 110 1 Log filename:
did -o iLog2 120 1 Log text:
did -o iLog2 130 1 Log date:
did -o iLog2 150 1 Status:
did -o iLog2 311 1 Log preview:
_ShowTab 1
}
else {
; search in found
did -v iLog2 102
did -o iLog2 101 1 Search in Found
did -o iLog2 110 1 Log filename: (Searching in found)
did -o iLog2 120 1 Log text: (Searching in found)
did -o iLog2 130 1 Log date: (Searching in found)
did -o iLog2 150 1 Status: (Searching in found)
did -o iLog2 311 1 Log preview: (Searched in found)
_ShowTab 1
}
}
; Show the log preview and information
alias -l _ShowLogInfo {
; bring number found button to top and add numbers
did -vo iLog2 326 1 $did(iLog2,310).sel $+ / $+ $did(iLog2,310).lines
var %file = $gettok($hget(iLog2,$did(iLog2,310).sel),1,124)
; when log is selected
if ($1 == top) {
if ($gettok($hget(iLog2,$did(iLog2,310).sel),2,124)) set %iLogLine $ifmatch
else set %iLogLine 2
set %iLogTotalLines $lines(%file)
; show log information
did -oe iLog2 312 1 $lines(%file) lines - $bytes($file(%file).size,3) $remove($bytes($file(%file).size,3).suf,1,2,3,4,5,6,7,8,9,0,.,$chr(44)) $+ ytes - Created $date($file(%file).ctime,ddd mmm d yyyy) - Modified $date($file(%file).mtime,ddd mmm d yyyy)
; enable next
if (%iLogTotalLines > 4) did -e iLog2 315
else did -h iLog2 315
if (%iLogLine > 2) did -e iLog2 314
else did -h iLog2 314
}
; if <- clicked
if ($1 == prev) dec %iLogLine 3
; if -> clicked
if ($1 == next) inc %iLogLine 3
; show log preview
did -o iLog2 313 1 %iLogLine $+ : $strip($read(%file,%iLogLine)) $crlf $+ $calc(%iLogLine + 1) $+ : $strip($read(%file,$calc(%iLogLine + 1))) $crlf $+ $calc(%iLogLine + 2) $+ : $strip($read(%file,$calc(%iLogLine + 2))) $crlf $+ $calc(%iLogLine + 3) $+ : $strip($read(%file,$calc(%iLogLine + 3)))
; show -> if needed, else hide
if (%iLogLine > 2) did -v iLog2 314
else did -h iLog2 314
; hide -> when reached end of log
if (%iLogLine > $calc(%iLogTotalLines - 4) ) did -h iLog2 315
else did -v iLog2 315
}
;
; Main aliases
;
; Log Search aliases
; Do the search when "Search" is clicked
alias -l _DoSearch {
; Filename Contains 112 - Does not contain 116
; Log Text Contains 122 - Does not contain 126
did -o iLog2 151 1 Searching...
; Clear previous searches
did -r iLog2 310,313
did -ob iLog2 312 1 Select from one of the logs below:
; Clear/make hash table
if ($did(iLog2,102).visible) var %SearchFound = iLog
else {
if ($hget(iLog2)) hfree iLog2
hmake iLog2 100
}
; Set the date variables
; Day 132, Month 136, Year 140
if ($did(iLog2,132).visible) var %LogDay = $base($did(iLog2,132).sel,10,10,2)
if ($did(iLog2,136).visible) var %LogMonth = $base($did(iLog2,136).sel,10,10,2)
if ($did(iLog2,140).visible) var %LogYear = $did(iLog2,140)
if ((%Logday) || (%LogMonth) || (%LogYear) ) {
set %iLogDate $iif(%LogYear,%LogYear,????) $+ $iif(%LogMonth,%LogMonth,??) $+ $iif(%LogDay,%LogDay,??)
; if search by modified date/ created date
if ($readini(thei.ini, ILOG, DateType) == 2) set %iLogDate2 iLog
if ($readini(thei.ini, ILOG, DateType) == 3) set %iLogDate3 iLog
}
if ($did(iLog2,112).visible) { var %LogText = * $+ $replace($did(iLog2,112),$chr(32),*) $+ * }
else var %LogText = *
; set log filename if searching with date else without date
if ($readini(thei.ini, ILOG, DateType) == 1) var %FileNameContains = %LogText $+ %iLogDate $+ .log
else var %FileNameContains = %LogText $+ .log
; Set Log filename doesn't contain/Log contains text/Log doesn't contain text
if ($did(iLog2,116).visible) set %iLogNameNotContains * $+ $replace($did(iLog2,116),$chr(32),*) $+ *
else unset %iLogNameNotContains
if ($did(iLog2,122).visible) set %iLogContains * $+ $replace($did(iLog2,122),$chr(32),*) $+ *
else unset %iLogContains
if ($did(iLog2,126).visible) set %iLogNotContains * $+ $replace($did(iLog2,126),$chr(32),*) $+ *
else unset %iLogNotContains
; if searching in found, else normal search
if (%SearchFound) {
; get iLog2 hastable into iLogFound hashtable
if ($hget(iLog2,1)) hsave -o iLog2 iLog2hash.tmp
if ($hget(iLogFound)) hfree iLogFound
hmake iLogFound 500
hload iLogFound iLog2hash.tmp
.remove iLog2hash.tmp
hfree iLog2
hmake iLog2 100
; search the hashtable
var %iLogTok = 1
while ($gettok($hget(iLogFound,$hmatch(iLogFound,%FileNameContains $+ *,%iLogTok).data),1,124) ) {
_ParseSearch $ifmatch
inc %iLogTok
}
}
; normal search
else {
; if filename matches text
; search logdir 1
var %LogDir = $readini(thei.ini, ILOG, LogDir)
var %Logdir1 = $findfile(%LogDir,%FileNameContains,0, _ParseSearch $1- )
; if logdir 2 is used, search
if ($readini(thei.ini, ILOG, UseLogDir2)) {
var %LogDir = $readini(thei.ini, ILOG, LogDir2)
var %LogDir2 = $findfile(%LogDir,%FileNameContains,0, _ParseSearch $1- )
}
; if logdir 3 is used search
if ($readini(thei.ini, ILOG, UseLogDir3)) {
var %LogDir = $readini(thei.ini, ILOG, LogDir3)
var %LogDir3 = $findfile(%LogDir,%FileNameContains,0, _ParseSearch $1- )
}
}
; if results are found, else if none
if ($did(iLog2,310).lines ) {
; show amount found/amount filtered
did -o iLog2 326 1 $ifmatch found
did -o iLog2 313 1 $iif($calc(%LogDir1 + %LogDir2 + %LogDir3 + $iif(%iLogTok,%iLogTok - 1) - %iLogDated) != 1,$ifmatch logs,1 log) matched $iif(%LogText != *,$ifmatch,<any log>) $iif(%iLogDate2,last modified,created) on $iif(%LogDay,the $ord($did(iLog2,132).seltext) of,any day in) $iif(%LogMonth,$did(iLog2,136).seltext,any month) $iif(%LogYear,$did(iLog2,140).seltext,of any year) $iif(%iLogBadFile,$crlf $+ %iLogBadFile matched %iLogNameNotContains and $iif(%iLogBadFile == 1,was,were) excluded) $iif(%iLogGoodText,$crlf $+ %iLogGoodText didn't contain %iLogContains and $iif(%iLogGoodText == 1,was,were) excluded) $iif(%iLogBadText,$crlf $+ %iLogBadText contained %iLogNotContains and $iif(%iLogBadText == 1,was,were) excluded)
; set view/open strip/include
_ViewSettings $readini(thei.ini, ILOG, ViewOpen) $readini(thei.ini, ILOG, ViewStrip)
; hide <- and ->
did -h iLog2 314,315
_ShowTab 3
}
else {
did -o iLog2 151 1 No matches found. Please refine your search.
; .timer 1 2 _EnableSearch
$dialog(iLogPop,iLogPop,-4) _EnableSearch
}
unset %iLog*
}
; Filter the found logs
alias -l _ParseSearch {
did -o iLog2 151 1 Searching... $1-
; if log modified date matches search date
if (%iLogDate2) {
if (%iLogDate !iswm $asctime($file($1-).mtime,yyyymmdd) ) { inc %iLogDated | return }
}
; if log created date matches search date
if (%iLogDate3) {
if (%iLogDate !iswm $asctime($file($1-).ctime,yyyymmdd) ) { inc %iLogDated | return }
}
; return if filename matches bad-text
if (%iLogNameNotContains) {
if (%iLogNameNotContains iswm $1-) { inc %iLogBadFile | return }
}
; return if log contains bad-text
if (%iLogNotContains) {
if ($read($1-, ntw, %iLogNotContains) ) { inc %iLogBadText | return }
}
; if log contains text
if (%iLogContains) {
if ($read($1-, ntw, %iLogContains) ) var %readn = $readn
else { inc %iLogGoodText | return }
}
; add found logs to dialog and hash table
did -a iLog2 310 $nopath($1-)
inc %iLogInc
hadd iLog2 %iLogInc $1- $+ $chr(124) $+ %readn
}
; First Run aliases
; Splash screen
alias -l _SplashScreen {
if ($window(@Error)) window -c @Error
window -haodrp +n @Error $int($calc(($window(-1).w - 302) / 2)) $int($calc(($window(-1).h - 82) / 2)) 302 82
drawfill -fr @Error $rgb(face) 1 0 0
drawtext -o @Error 1 SansSerif 14 70 10 Welcome to iLog Viewer
drawtext -orb @Error $rgb(159, 201, 63) 1 SansSerif 64 10 0 �i�
}
; Set defaults on no ini file or error in file
alias -l _MakeIni {
_SplashScreen
drawtext -o @Error 1 SansSerif 14 70 30 Finding Log editor
writeini thei.ini ILOG Editor $findfile(C:\,notepad.exe,1,2)
writeini thei.ini ILOG UseDefEditor 1
drawtext -o @Error 1 SansSerif 14 70 30 Finding Log editor - Found
drawtext -o @Error 1 SansSerif 14 70 50 Initialising
writeini thei.ini ILOG LogDir $logdir
writeini thei.ini ILOG UseDefLogDir 1
writeini thei.ini ILOG LogDir2 $logdir
writeini thei.ini ILOG UseLogDir2 $false
writeini thei.ini ILOG LogDir3 $logdir
writeini thei.ini ILOG UseLogDir3 $false
if ( $mid($mklogfn(x),-12,8) isnum) writeini thei.ini ILOG DateType 1
else writeini thei.ini ILOG DateType 2
writeini thei.ini ILOG ViewOpen view
writeini thei.ini ILOG ViewStrip incl
writeini thei.ini 112 n1 #peace
writeini thei.ini 116 n1 #war
writeini thei.ini 122 n1 love
writeini thei.ini 126 n1 hate
%i = 1
.timer.SplashDots -m 30 25 _SplashDots
ilog2
}
; Draw dots in Init window
alias -l _SplashDots {
drawtext -o @Error 1 SansSerif 14 70 50 Initialising $+ $str(.,%i)
inc %i
.timer.SplashClose 1 1 window -c @Error
}
; View/Open/Strip Log aliases
; Open and strip the log
alias -l _OpenLog {
var %file = $gettok($hget(iLog2,$did(iLog2,310).sel),1,124)
; Make hidden window
window -hn @iLogTemp
; Add 'iLog header'
iline @iLogTemp 1 $lines(%file) lines %file
iline @iLogTemp 2 Stripped: $asctime(dddd mmm dd yyyy hh:nn tt)
iline @iLogTemp 3 Last modified: $asctime($file(%file).mtime,dddd mmm dd yyyy hh:nn tt)
iline @iLogTemp 4 iLog Viewer - 'thei' - irc.austnet.org
; Load log into window
loadbuf @iLogTemp %file
; Strip log
_StripLog @iLogTemp
; Save window to file
savebuf @iLogTemp iLog.txt
window -c @iLogTemp
; Open file in editor
run $readini(thei.ini, ILOG, Editor) ilog.txt
}
; View the log
alias -l _ViewLog {
var %file = $gettok($hget(iLog2,$did(iLog2,310).sel),1,124)
if ($window(@iLog2)) window -c @iLog2
; if using mdi windows, make window mdi, else make desktop window
if ($window(status window).mdi) var %WinVar = -aCkzl
else var %WinVar = -adCkzl
window %WinVar @iLog2 -1 -1 640 480
; Set titlebar
titlebar @iLog2 Please wait... Loading log...
set %LogViewWindow $ticks
; Add 'iLog header'
iline @iLog2 1 $lines(%file) lines %file
iline @iLog2 2 Viewed: $asctime(dddd mmm dd yyyy hh:nn tt)
iline @iLog2 3 Last modified: $asctime($file(%file).mtime,dddd mmm dd yyyy hh:nn tt)
iline 4 @iLog2 4 iLog Viewer - 'thei' - irc.austnet.org
; Load log into window
loadbuf @iLog2 %file
; Make horizontal scrollbar
window -b @iLog2
; if 'strip' then strip log
if ($readini(thei.ini, ILOG, ViewStrip) == strip) {
titlebar @iLog2 Please wait... Stripping log...
_StripLog @iLog2
}
; Select the text-found line
sline 4 @iLog2 $calc($gettok($hget(iLog2,$did(iLog2,310).sel),2,124) + 4)
cline 4 @iLog2 $calc($gettok($hget(iLog2,$did(iLog2,310).sel),2,124) + 4)
titlebar @iLog2 Viewing - $lines(%file) lines - $bytes($file(%file).size,3) $remove($bytes($file(%file).size,3).suf,1,2,3,4,5,6,7,8,9,0,.,$chr(44)) $+ ytes - $did(iLog2,310).seltext
}
; Strips colour codes from window
; /_StripLog @window.name
alias -l _StripLog {
var %i = 1
var %lines = $line($1,0)
set %max $line($1,0)
; Warning if log exceeds number of lines
if (%max > 10000) {
set %iLogPop This log contains %max lines and may take some time to strip, especially on older computers. $crlf $+ It is recommended you do not continue.
if ($dialog(iLogStrip,iLogStrip,-3)) $null
else return
}
iWait Please wait... Stripping log...
; Save log
savebuf $1 iLogStrip.tmp
clear $1
; Make hash table
if ($hget(iLogStrip)) { hfree iLogStrip }
hmake iLogStrip 100
; Load log into hash table
hload -n iLogStrip iLogStrip.tmp
; Strip the hash table
var %inc = 1
while ($hget(iLogStrip,%inc)) {
if ($hget(iLogStrip,%inc) != $chr(32)) aline $1 $strip($ifmatch)
else aline $1 -
inc %inc
drawrect -f @iWait 2 1 22 51 $int($calc($calc(%inc / %max) * 250))) 6
}
; if called from the strip menu, select the previously selected line
if ($2) sline $1 $2
; Clean up
hfree iLogStrip
.remove iLogStrip.tmp
set %iLogStripped %LogViewWindow
window -c @iWait
}
; Menu for log view window
menu @iLog2 {
iLog Viewer: iLog2
-
Copy $chr(40) $+ $iif($sline(@iLog2,0) > 1, $ifmatch lines, 1 line) $+ $chr(41) {
clipboard $sline(@iLog2,1)
var %sline = 2
while ($sline(@iLog2,%sline)) {
clipboard -a $crlf $+ $ifmatch
inc %sline
}
}
$iif(%iLogStripped == %LogViewWindow,$style(2)) Strip and Copy {
clipboard $strip($sline(@iLog2,1))
var %sline = 2
while ($strip($sline(@iLog2,%sline))) {
clipboard -a $crlf $+ $ifmatch
inc %sline
}
}
$iif(%iLogStripped == %LogViewWindow,$style(2)) Strip $chr(40) $+ $line(@iLog2,0) lines $+ $chr(41) {
_StripLog @iLog2 $sline(@iLog2,1).ln
}
Edit... {
rline @iLog2 2 Stripped: $asctime(dddd mmm dd yyyy hh:nn tt)
if (%iLogStripped != %LogViewWindow) _StripLog @iLog2
savebuf @iLog2 iLog.txt
run $readini(thei.ini, ILOG, Editor) ilog.txt
window -c @iLog2
}
-
Send... {
rline @iLog2 2 Stripped: $asctime(dddd mmm dd yyyy hh:nn tt)
if (%iLogStripped != %LogViewWindow) _StripLog @iLog2
savebuf @iLog2 iLog.txt
dcc send $$?="Nickname to send log to:" ilog.txt
window -c @iLog2
}
-
Close Window { window -c @iLog2 }
}
; Progress Bar window
; /iWait window.text
alias -l iWait {
if ($window(@iWait)) window -c @iWait
window -haodrp +n @iWait $int($calc(($window(-1).w - 302) / 2)) $int($calc(($window(-1).h - 82) / 2)) 302 82
drawfill -fr @iWait $rgb(face) 1 0 0
drawrect -f @iWait 0 1 9 43 276 21
drawrect -f @iWait 1 1 10 44 276 21
drawrect -fr @iWait $rgb(face) 1 10 44 275 20
drawtext -o @iWait 1 SansSerif 14 9 10 $1-
drawrect -f @iWait 15 1 22 51 250 6
}
; Check for updated version
alias -l _CheckUpdate {
sockclose webUpdateCheck
sockopen webUpdateCheck ilog.the-i.org 80
}
; check results of a web check
alias -l _CheckUpdateResults {
if (%latestVersion != 2010-NOV-30) {
; $dialog(iLogUpdate,iLogUpdate,-4)
dialog -madv iLogUpdate iLogUpdate
did -o iLogUpdate 2 1 %versionMessage
}
}
on *:sockopen:webUpdateCheck:{
; This is telling the socket to connect to the specific page, using "GET".
sockwrite -n $sockname GET /update?version=2010-NOV-30 HTTP/1.1
; This states the host once again.
sockwrite -n $sockname Host: ilog.the-i.org $+ $crlf $+ $crlf
}
on *:sockread:webUpdateCheck:{
if ($sockerr) {
; did -o iLog2 224 1 Error: $sockerr
return Error: $sockerr
}
else {
var %readAttempts = 1
set %latestVersion = $null
set %versionMessage = $null
:nextread
; get data from socket
sockread %temp
if (*<latestVer>*</latestVer>* iswm %temp) {
; get the <msg>message</msg> part
var %leftMsg = $pos(%temp, <latestVer>, 1) + 11
var %lengthMsg = $pos(%temp, </latestVer>, 1) - %leftMsg
set %latestVersion $mid(%temp, %leftMsg, %lengthMsg)
%leftMsg = $pos(%temp, <msg>, 1) + 5
%lengthMsg = $pos(%temp, </msg>, 1) - %leftMsg
set %versionMessage $mid(%temp, %leftMsg, %lengthMsg)
sockclose webUpdateCheck
_CheckUpdateResults
return
}
if (%readAttempts > 50) {
; have tried too many times
; did -o iLog2 224 1 An error occurred updating...
unset %readAttempts
sockclose webUpdateCheck
return
}
if ($sockbr == 0) {
; no more data to read
unset %readAttempts
sockclose webUpdateCheck
return
}
inc %readAttempts
goto nextread
}
}
; Auto-Update from site
; 224
; /_WebUpdate
alias -l _WebUpdate {
; set the text while updating
did -o iLog2 224 1 Connecting to http://ilog.the-i.org/ for up to date information %updateFailed $+ ...
; open socket
sockclose webUpdate
sockopen webUpdate ilog.the-i.org 80
}
on *:sockopen:webUpdate:{
; This is telling the socket to connect to the specific page, using "GET".
sockwrite -n $sockname GET /update?version=2010-NOV-30 HTTP/1.1
; This states the host once again.
sockwrite -n $sockname Host: ilog.the-i.org $+ $crlf $+ $crlf
}
on *:sockread:webUpdate:{
if ($sockerr) {
did -o iLog2 224 1 Error: $sockerr
return Error: $sockerr
}
else {
var %readAttempts = 1
:nextread
; get data from socket
sockread %temp
if (*<msg>*</msg>* iswm %temp) {
; get the <msg>message</msg> part
var %leftMsg = $pos(%temp, <msg>, 1) + 5
var %lengthMsg = $pos(%temp, </msg>, 1) - %leftMsg
var %strippedMsg = $mid(%temp, %leftMsg, %lengthMsg)
did -o iLog2 224 1 %strippedMsg
sockclose webUpdate
return
}
if (%readAttempts > 50) {
; have tried too many times
did -o iLog2 224 1 An error occurred updating...
unset %readAttempts
sockclose webUpdate
return
}
if ($sockbr == 0) {
; no more data to read
unset %readAttempts
sockclose webUpdate
return
}
inc %readAttempts
goto nextread
}
}
; Close the update socket
alias -l _CloseUpdateSocket {
; unset %readAttempts
sockclose webUpdate
}
; On loading script
on *:load: {
if ($version > 5.9) iLog2
else {
echo 4 -a ERROR: You are using version $version of mIRC. iLog2 Viewer requires mIRC 5.91 or better. Please upgrade from www.mirc.com now.
unload -rs $script
}
}
; Copyright 2006 ilog.the-i.org