Welcome to mDir's Readme File! This document's purpose is to tell you how to use the basics of mDir. I hope you enjoy using mDir.
Scripter of mDir,
Zach (Aether Gray)
Beta Tester:
Falcor - Thanks
Modified Version of Loading Bar from KTE/Fractal? I don't remember where I got it but it looks similar to them
========================================
What is mDir?
mDir is a Directory Monitor! Great for Localized FTP Servers and File Servers. It bascially just scans through directories you want it to scan through and it will check if files have been added or deleted or even changed. It also works with sub directories too. Though to scan inside of those you have to add them. mDir uses a INI file to store settings for each folder you want it to scan. It checks to see if the file has been changed by checking the CRC of that file.
========================================
Using mDir:
To access the main Dialog and setup window type "/mdir" (without quotes) or use the popups found in the Menu Bar and or Status Window.
AFTER CHANGING THINGS MAKE SURE YOU PRESS "SAVE"
To add a folder to scan, click on "ADD" at the top of the window. It will bring up a folder selection box and select the folder you want. A loadbar will popup, just showing you how much time you might have to wait before the file information is fully added. The more files you have (and how big they are) will determine how much time it will take before all information is recorded.
To delete, highlight the folder in the list of folders and press the Delete button.
Checkbox: New File. If this is checked, then it will alert the channel that a new file has been added
Checkbox: Changed File. If this is checked then it will alert the channel that a file has been changed.
Checkbox: Deleted File. If this is chcked then it will alert the channel that a file has been changed.
Checkbox: New Directory. If this is checked then it will alert the channel that a subdirectory has been added.
Checkbox: Deleted Directory. If this is checked then it will alert the channel that a subdirectory has been deleted.
Checkbox: Echo all msgs to Status. If this is checked, then all messages will be echoed to the status window.
If you read what each checkbo does, then you get the idea of what each textbox does.
Channel: This is the channel where messages are sent to
Allow Scanning of this directory: This allows the scanning of the directory to take place.
Scan Every (X) Minutes: Will automate the timer. Put 0 for disabling.
Allow Scanning: Turn off mDIR if unchecked
========================================
OTHER:
; mDir2
; -------------------------
; Just type /createrandomini and it will create a test ini you can use.
alias cndir {
var %seed = $ticks
if ($1 == $null && $isdir($1-) != $true) { halt }
var %filename = $scriptdir $+ $md5($lower($1-)) $+ .mdl
var %nomd5 = $lower($1-)
var %files = $findfile(%nomd5,*,0,0))
var %folders = $finddir(%nomd5,*,0,0)
var %lbi = $calc(90 / (%files + %folders)), %lbx = 0
write $+(",%filename,")
loadbar open
loadbar title Adding Files
while (%files) {
%afile = $replace($findfile(%nomd5,*,%files,0),$chr(32),$chr(21))
writeini $+(",%filename,") files $nopath(%afile) $crc(%afile)
inc %lbx %lbi | loadbar pos %lbx | loadbar title Adding File: $left(%afile,35) $+ $iif($len(%afile) < 35,...)
dec %files
}
loadbar Title Adding Folders
while (%folders) {
%afile = $replace($finddir(%nomd5,*,%folders,0),$chr(32),$chr(21))
writeini $+(",%filename,") folders $nopath(%afile) $true
inc %lbx %lbi | loadbar pos %lbx | loadbar title Adding Folder: $left(%afile,35) $+ $iif($len(%afile) < 35,...)
dec %folders
}
loadbar Title Adding Information
writeini $+(",%filename,") info directory %nomd5
writeini $+(",%filename,") info echo 1
writeini $+(",%filename,") allow newfile 1
writeini $+(",%filename,") allow chgfile 1
writeini $+(",%filename,") allow delfile 1
writeini $+(",%filename,") allow newdir 1
writeini $+(",%filename,") allow deldir 1
inc %lbx 5 | loadbar pos %lbx
writeini $+(",%filename,") messages newfile New File Added in !dir (!file)
writeini $+(",%filename,") Messages delfile Deleted File in !dir (!file)
writeini $+(",%filename,") messages chgfile File Modified in !dir (!file)
writeini $+(",%filename,") messages newdir New Subdirectory Added in !dir (!file)
writeini $+(",%filename,") messages deldir Subdirectory Deleted in !dir (!file)
writeini $+(",%filename,") info scan 1
writeini $+(",%filename,") info chan #scripting
inc %lbx 5 | loadbar pos %lbx
loadbar title Completed in $calc(($ticks - %seed) / 1000) secs
.timer 1 2 loadbar close
;echo -a INI: $+(",%filename,") CREATED!
}
alias loadbar {
if ($0 && !$isid) {
var %window.width = 300
var %window.height = 40
var %bar.width = $calc(%window.width - 10)
var %bar.height = $calc(%window.height * .3)
if ($1 == open) {
if ($window(@prog)) { window -c @prog }
window -pfhkdCiB +fL @prog -1 -1 %window.width %window.height
drawrect -fr @prog $color(background) 0 0 0 %window.width %window.height
drawrect @prog $color(background) 0 5 23 %bar.width %bar.height
window -a @prog
}
elseif ($window(@prog)) {
if ($1 == title) {
drawrect -rf @prog $color(background) 0 0 0 502 22
drawtext @prog $color(info) Verdana -7 $calc(((%window.width - $width($2-, Verdana, -7, 1, 1)) / 2) +3) 4 $2-
window -a @prog
}
if ($1 == pos) {
drawrect -f @prog $color(info) 0 6 25 $calc($$2 * (%bar.width / 100)) 8
window -a @prog
}
if ($1 == close) $iif($window(@prog),.timer -m 1 50 close -@ @prog)
}
}
else {
if ($isid) {
if ($window(@prog)) { return $true }
else { return $false }
}
}
}
dialog mdir {
title "mDir - Directory Monitor v2.0"
size -1 -1 160 167
option dbu notheme
list 100, 1 10 157 42, size
box "Messages", 3, 2 54 157 68
check "New File", 200, 6 62 33 10
check "Changed File", 201, 6 72 47 10
check "Deleted File", 202, 6 82 49 10
check "New Directory", 203, 6 92 47 10
check "Deleted Directory", 204, 6 102 56 10
text "New File Message:", 8, 64 63 46 8, right
edit "", 206, 110 62 48 10, autohs
edit "", 207, 110 72 48 10, autohs
text "Chg File Message:", 11, 64 73 46 8, right
edit "", 208, 110 82 48 10, autohs
text "Del File Message:", 13, 64 83 46 8, right
edit "", 209, 110 92 48 10, autohs
text "New Dir Message:", 15, 64 93 46 8, right
edit "", 210, 110 102 48 10, autohs
text "Del Dir Message:", 17, 64 103 46 8, right
check "Echo All Msgs to Status", 205, 6 112 67 7
box "Other Directory Settings:", 19, 2 121 157 19
edit "", 300, 34 128 50 10, autohs
text "Channel:", 21, 10 129 24 8
check "Allow Scanning of This Dir", 301, 87 128 69 10, left
box "Settings:", 23, 2 141 62 25
text "Scan every ", 24, 6 148 30 7
edit "", 400, 35 147 14 10, autohs
text "mins", 26, 49 148 13 8
check "Enable Scans", 401, 6 155 42 10
button "Save ", 500, 68 144 37 12
button "Exit", 29, 106 157 37 10, ok cancel
button "Scan", 600, 68 157 37 10
text "Directories", 1, 2 2 32 8
button "Add", 101, 114 2 20 7
button "Delete", 102, 136 2 20 7
text "Invalid Directory! ", 2, 108 144 50 11
}
alias x6f { if ($1 == $null) { return S_NOOK } | else { return $replace($1-,,<b>,,<u>,,<k>,,<r>,,<o>) } }
alias y10a { return $replace($1-,<b>,,<o>,,<r>,,<k>,,<u>,) }
alias mdir { dialog $iif($dialog(mdir),-v,-md) mdir mdir }
on *:DIALOG:mdir:*:* {
if ($devent == init && !$did) {
var %i = 1
did -ri $dname 100 1 Select a Directory
while (%i <= $findfile($scriptdir,*.mdl,0,0)) {
var %d = $replace($readini($findfile($scriptdir,*.mdl,%i,0),info,directory),$chr(21),$chr(32))
did -i $dname 100 $calc(%i + 1) %d
inc %i
}
did -c $dname 100 1
if (%mdir.scan) { did -c $dname 401 }
if (%mdir.time != $null) { did -ra $dname 400 %mdir.time }
}
if ($devent == sclick) {
; Clears Error Messages
if ($did != $null) { did -r $dname 2 }
if ($did == 101) {
var %path = $lower($sdir($scriptdir,Select Directory))
if (!$isdir(%path)) { did -ra $dname 2 Invalid Directory }
else {
if ($isfile($scriptdir $+ $md5(%path) $+ mdl) == $true) { did -ra $dname 2 Already Monitoring }
else {
cndir %path
did -ra $dname 2 Directory Added
var %i = 1
did -ri $dname 100 1 Select a Directory
while (%i <= $findfile($scriptdir,*.mdl,0,0)) {
var %d = $readini($findfile($scriptdir,*.mdl,%i,0),info,directory)
did -i $dname 100 $calc(%i + 1) %d
inc %i
}
did -c $dname 100 1
}
}
}
if ($did == 102) {
var %path = $lower($did($dname,100).seltext)
if ($isdir(%path)) {
if ($isfile($scriptdir $+ $md5(%path) $+ .mdl)) { .remove $+(",$scriptdir,$md5(%path),.mdl,") }
var %i = 1
did -ri $dname 100 1 Select a Directory
while (%i <= $findfile($scriptdir,*.mdl,0,0)) {
var %d = $replace($readini($findfile($scriptdir,*.mdl,%i,0),info,directory),$chr(21),$chr(32))
did -i $dname 100 $calc(%i + 1) %d
inc %i
}
did -c $dname 100 1
}
}
if ($did == 600) {
if (!$timer(-mdirscan) && %mdir.time > 0) {
did -ra $dname 2 Already Scanning
}
else {
mdirx
}
}
if ($did == 500) {
var %sel = $lower($did($dname,100).seltext)
var %dir = $scriptdir $+ $md5(%sel) $+ .mdl
if ($isdir(%sel) == $false) {
did -ra $dname 2 Not a Directory
}
else {
writeini $+(",%dir,") allow newfile $did($dname,200).state
writeini $+(",%dir,") allow chgfile $did($dname,201).state
writeini $+(",%dir,") allow delfile $did($dname,202).state
writeini $+(",%dir,") allow newdir $did($dname,203).state
writeini $+(",%dir,") allow deldir $did($dname,204).state
writeini $+(",%dir,") info echo $did($dname,205).state
writeini $+(",%dir,") info scan $did($dname,301).state
writeini $+(",%dir,") messages newfile $x6f($did($dname,206).text)
writeini $+(",%dir,") messages chgfile $x6f($did($dname,207).text)
writeini $+(",%dir,") messages delfile $x6f($did($dname,208).text)
writeini $+(",%dir,") messages newdir $x6f($did($dname,209).text)
writeini $+(",%dir,") messages deldir $x6f($did($dname,210).text)
writeini $+(",%dir,") info chan $x6f($did($dname,300).text)
did -ra $dname 2 Settings Saved
}
set %mdir.time $did($dname,400).text
set %mdir.scan $did($dname,401).state
}
if ($did == 100) {
var %sel = $lower($did($dname,$did).seltext)
var %dir = $scriptdir $+ $md5(%sel) $+ .mdl
if ($isdir(%sel) == $false) {
did -ra $dname 2 Not a Directory
did -b $dname 200,201,202,203,204,205,301,206,207,208,209,210,300,500
}
else { did -e $dname 200,201,202,203,204,205,301,206,207,208,209,210,300,500 }
did -u $dname 200,201,202,203,204,205,301
did -r $dname 206,207,208,209,210,300
if ($readini(%dir,allow,newfile)) { did -c $dname 200 }
if ($readini(%dir,allow,chgfile)) { did -c $dname 201 }
if ($readini(%dir,allow,delfile)) { did -c $dname 202 }
if ($readini(%dir,allow,newdir)) { did -c $dname 203 }
if ($readini(%dir,allow,deldir)) { did -c $dname 204 }
if ($readini(%dir,messages,newfile)) { did -ra $dname 206 $y10a($replace($iif($ifmatch != $null,$ifmatch,$v1),S_NOOK,$null)) }
if ($readini(%dir,messages,chgfile)) { did -ra $dname 207 $y10a($replace($iif($ifmatch != $null,$ifmatch,$v1),S_NOOK,$null)) }
if ($readini(%dir,messages,delfile)) { did -ra $dname 208 $y10a($replace($iif($ifmatch != $null,$ifmatch,$v1),S_NOOK,$null)) }
if ($readini(%dir,messages,newdir)) { did -ra $dname 209 $y10a($replace($iif($ifmatch != $null,$ifmatch,$v1),S_NOOK,$null)) }
if ($readini(%dir,messages,deldir)) { did -ra $dname 210 $y10a($replace($iif($ifmatch != $null,$ifmatch,$v1),S_NOOK,$null)) }
if ($readini(%dir,info,echo)) { did -c $dname 205 1 }
if ($readini(%dir,info,chan)) { did -ra $dname 300 $y10a($replace($iif($ifmatch != $null,$ifmatch,$v1),S_NOOK,$null)) }
if ($readini(%dir,info,scan)) { did -c $dname 301 1 }
}
}
}
alias msgconvert { if ($1 == S_NOOK) { halt } | else { return $replace($1-,!dir,%dir,!file,%file,!filename,%full.file) } }
alias mdirx {
var %i = 1, %stime = $ticks
while (%i <= $findfile($scriptdir,*.mdl,0,0)) {
var %a = 1, %a2 = 1, %b = 1, %list = $findfile($scriptdir,*.mdl,%i,0), %dir = $readini(%list,info,directory)
var %b2 = 1
inc %i
if (!%mdir.scan) { halt }
if ($isdir(%dir)) {
; Checks if the directory is in scan mode
if ($readini(%list,info,scan)) {
; Loop to check if files have been added/changed and some deletions
while (%a <= $findfile(%dir,*,0,0)) {
var %full.file = $findfile(%dir,*,%a,0), %file = $nopath(%full.file), %altfile = $replace(%file,$chr(32),$chr(21))
; New Files?
if ($readini(%list,files,%altfile) == $null) {
; Message Channel
if ($readini(%list,allow,newfile)) {
var %1msg = $readini(%list,messages,newfile)
if ($me ison $readini(%list,info,chan) && (%1msg != $null || %1msg != S_NOOK)) { msg $readini(%list,info,chan) $y10a($replace(%1msg,!dir,%dir,!file,%file,!filename,%full.file)) }
if ($readini(%list,info,echo) && (%1msg != $null || %1msg != S_NOOK)) { echo $color(info) -s $y10a($replace(%1msg,!dir,%dir,!file,%file,!filename,%full.file)) }
}
writeini $+(",%list,") files %altfile $crc(%full.file)
}
if ($isfile(%full.file) == $true) {
; Message Channel
if ($crc(%full.file) != $readini(%list,files,%altfile)) {
if ($readini(%list,allow,chgfile)) {
var %1msg = $readini(%list,messages,chgfile)
if ($me ison $readini(%list,info,chan) && (%1msg != $null || %1msg != S_NOOK)) { msg $readini(%list,info,chan) $y10a($replace(%1msg,!dir,%dir,!file,%file,!filename,%full.file)) }
if ($readini(%list,info,echo) && (%1msg != $null || %1msg != S_NOOK)) { echo $color(info) -s $y10a($replace(%1msg,!dir,%dir,!file,%file,!filename,%full.file)) }
}
writeini $+(",%list,") files %altfile $crc(%full.file)
}
}
else {
if ($readini(%list,allow,delfile)) {
echo -a This is my dog
var %1msg = $readini(%list,messages,delfile)
if ($me ison $readini(%list,info,chan) && (%1msg != $null || %1msg != S_NOOK)) { msg $readini(%list,info,chan) $y10a($replace(%1msg,!dir,%dir,!file,%file,!filename,%full.file)) }
if ($readini(%list,info,echo) && (%1msg != $null || %1msg != S_NOOK)) { echo $color(info) -s $y10a($replace(%1msg,!dir,%dir,!file,%file,!filename,%full.file)) }
}
remini $+(",%list,") files %altfile
}
inc %a
}
while (%a2 <= $finddir(%dir,*,0,0)) {
var %full.df = $finddir(%dir,*,%a2,0), %df = $nopath(%full.df), %adf = $replace(%df,$chr(32),$chr(21))
; New Directory?
if ($readini(%list,folders,%adf) == $null) {
; Message Channel
if ($readini(%list,allow,newdir)) {
var %1msg = $readini(%list,messages,newdir)
if ($me ison $readini(%list,info,chan) && (%1msg != $null || %1msg != S_NOOK)) { msg $readini(%list,info,chan) $msgconvert(%list) }
if ($readini(%list,info,echo) && (%1msg != $null || %1msg != S_NOOK)) { echo $color(info) -s $msgconvert(%list) }
}
writeini $+(",%list,") folders %adf $true
}
; No Directory on List
if (!$isdir(%full.df)) {
if ($readini(%list,allow,deldir)) {
var %1msg = $readini(%list,messages,deldir)
if ($me ison $readini(%list,info,chan) && (%1msg != $null || %1msg != S_NOOK)) { msg $readini(%list,info,chan) $y10a($replace(%1msg,!dir,%dir,!file,%file,!filename,%full.file)) }
if ($readini(%list,info,echo) && (%1msg != $null || %1msg != S_NOOK)) { echo $color(info) -s $y10a($replace(%1msg,!dir,%dir,!file,%file,!filename,%full.file)) }
}
remini $+(",%list,") folders %adf
}
inc %a2
}
WHILE (%b <= $ini(%list,files,0)) {
var %full.file = $readini(%list,info,directory) $+ $replace($ini(%list,files,%b),$chr(21),$chr(32))
var %file = $nopath(%full.file), %altfile = $replace(%file,$chr(32),$chr(21))
if ($isfile(%full.file) == $false) {
if ($readini(%list,allow,delfile)) {
echo -a %full.file
var %1msg = $readini(%list,messages,delfile)
if ($me ison $readini(%list,info,chan) && (%1msg != $null || %1msg != S_NOOK)) { msg $readini(%list,info,chan) $y10a($replace(%1msg,!dir,%dir,!file,%file,!filename,%full.file)) }
if ($readini(%list,info,echo) && (%1msg != $null || %1msg != S_NOOK)) { echo $color(info) -s $y10a($replace(%1msg,!dir,%dir,!file,%file,!filename,%full.file)) }
}
remini $+(",%list,") files %altfile
}
inc %b
}
WHILE (%b2 <= $ini(%list,folders,0)) {
var %full.file = $readin(%list,info,directory) $+ $replace($ini(%list,folders,%b2),$chr(21),$chr(32)), %file = $nopath(%full.file), %altfile = $replace(%file,$chr(32),$chr(21))
if (!$isdir(%full.file)) {
if ($readini(%list,allow,deldir)) {
var %1msg = $readini(%list,messages,deldir)
if ($me ison $readini(%list,info,chan) && (%1msg != $null || %1msg != S_NOOK)) { msg $readini(%list,info,chan) $y10a($replace(%1msg,!dir,%dir,!file,%file,!filename,%full.file)) }
if ($readini(%list,info,echo) && (%1msg != $null || %1msg != S_NOOK)) { echo $color(info) -s $y10a($replace(%1msg,!dir,%dir,!file,%file,!filename,%full.file)) }
}
remini $+(",%list,") folders %altfile
}
inc %b2
}
}
}
}
var %ctime12 = $calc(($ticks - %stime) / 1000)
echo $color(info) -s *** mDir: Finish Scanning in %ctime12 seconds.
}
on *:UNLOAD {
.timer-mdirscan off
unset %mdir.*
echo $color(info) -s mDir - Directory Monitor v2.0 unloaded. All variables unset. Please manually delete the .mdl files in $scriptdir
}
on *:LOAD: {
if ($version < 6.03) { echo mDir - Directory Monitor requires you to use mIRC Version 6.03 or higher. Your current version is $version }
else {
echo $color(info) -a --------------------------
echo $color(info) -a mDir - Directory Monitor by Aether (Version 2.0)
echo $color(info) -a Now Loaded! Type /mdir to setup.
autoscan /n
}
}
menu status,menubar {
-
mDir
.Setup: mdir
.Scan Now: mdirx
.-
.Unload
..Unload by Clicking Here: .unload -rs $+(",$script,")
-
}
on *:START {
autoscan /n
}
; Alias for Timer and Auto Scanning.
alias -l autoscan { .timer-mdirscan off | if (%mdir.time > 0 && %mdir.scan && $1 != /n) { mdirx } | .timer-mdirscan 1 $calc(60 * $iif(%mdir.time isnum 1-,%mdir.time,5)) autoscan }