Warning: Cannot modify header information - headers already sent by (output started at /home/icechat2/public_html/site/icechat.php:65) in /home/icechat2/public_html/site/_pages/downloads.php on line 57

Warning: Cannot modify header information - headers already sent by (output started at /home/icechat2/public_html/site/icechat.php:65) in /home/icechat2/public_html/site/_pages/downloads.php on line 58

Warning: Cannot modify header information - headers already sent by (output started at /home/icechat2/public_html/site/icechat.php:65) in /home/icechat2/public_html/site/_pages/downloads.php on line 59

Warning: Cannot modify header information - headers already sent by (output started at /home/icechat2/public_html/site/icechat.php:65) in /home/icechat2/public_html/site/_pages/downloads.php on line 61
'##################### '# Seen script v 3.1 # '# Author: Morio # '##################### ' This is the third version of my "seen" script ' This is also the first version of the script that I have published ' The major change in this version is that all the info is saved in a ' separate folder in the scripts directory, and each channel has it's ' own file, and besides that, every network has one more file. ' IMPORTANT: When you load this script for the first time, you immediately ' need to run the scan command to create the files necessary for storing ' the information. Also whenever you join a new channel, scan it, and everytime ' you connect, scan all channels to update the database. Dim SeenDirectory 'This is the directory where all the data will be saved SeenDirectory = GetIdentifier("$scriptdir") & "seen\" Sub Scan(Channel) StartScan = GetIdentifier("$monthnum") & "/" & GetIdentifier("$day") & "/" & GetIdentifier("$year") & " " & GetIdentifier("$time") Dim FSO, ChannelFile, NewText Set FSO = CreateObject("Scripting.FileSystemObject") 'If the directory doesn't exist, it is created here If Not FSO.FolderExists(SeenDirectory) then FSO.CreateFolder(SeenDirectory) End If 'If no channel is specified the script will scan all channels for all networks If Channel = ("$1") then For i = 1 to GetIdentifier("$totalservers") 'get the network name NW = GetIdentifier("$network",i) 'Delete the network specific file to reset online data If FSO.FileExists(SeenDirectory & NW & ".ini") Then FSO.DeleteFile(SeenDirectory & NW & ".ini") 'get all the channels ChanList = Split(GetIdentifier("$channels",i)," ") For j = 0 to UBound(Chanlist) 'if the channel has been scanned before, the ini file needs to fixed in case someone has quit while you have been offline If FSO.FileExists(SeenDirectory & NW & "_" & ChanList(j) & ".ini") then Set ChannelFile = FSO.OpenTextFile(SeenDirectory & NW & "_" & ChanList(j) & ".ini",1) ChannelText = ChannelFile.ReadAll ChannelFile.Close ChannelNicks = Split(ChannelText,vbCrLf) For k = 0 to Ubound(ChannelNicks) If k = 0 then ChannelInfo = ChannelNicks(k) Else 'change all the joins to parts and add a marker that shows that they have quit while you were offline If Left(ChannelNicks(k),4) = "join" then Nickname = Mid(ChannelNicks(k),InStr(ChannelNicks(k),":")+1) Nickname = Left(Nickname,InStr(Nickname,"=")-1) TimeInfo = Mid(ChannelNicks(k),InStr(ChannelNicks(k),"=")+1) If InStr(TimeInfo,"pwo") then NewLine = "part:" & Nickname & "=" & TimeInfo Else NewLine = "part:" & Nickname & "=" & TimeInfo & " pwo" End If Else NewLine = ChannelNicks(k) End If 'rebuild the contents of the file If NewText = "" then NewText = ChannelInfo Else NewText = NewText & vbCrLf & NewLine End If End If Next 'save the new file Set ChannelFile = FSO.OpenTextFile(SeenDirectory & NW & "_" & ChanList(j) & ".ini",2) ChannelFile.Write(NewText) ChannelFile.Close set ChannelFile = nothing NewText = "" End If 'get all the nicknames on the channel and out them in an array Nicknames = Split(Nicks(Chanlist(j),i)," ") For l = 0 to UBound(Nicknames) 'store the nicknames with current time writeinifile SeenDirectory & NW & "_" & ChanList(j) & ".ini","channel","part:" & Nicknames(l),"" writeinifile SeenDirectory & NW & "_" & ChanList(j) & ".ini","channel","join:" & Nicknames(l),GetIdentifier("$monthnum") & "/" & GetIdentifier("$day") & "/" & GetIdentifier("$year") & " " & GetIdentifier("$time") 'store the online data Previous = GetIniFile(SeenDirectory & NW & ".ini","nicknames", "online:" & Nicknames(l),"") Change = Changes(Previous,Chanlist(j),"add",Nicknames(l),NW) WriteIniFile SeenDirectory & NW & ".ini","nicknames","online:" & Nicknames(l),Change Next Next Next Else 'scanning a specific channel NW = GetIdentifier("$currentnetwork") If FSO.FileExists(SeenDirectory & NW & "_" & Channel & ".ini") then Set ChannelFile = FSO.OpenTextFile(SeenDirectory & NW & "_" & Channel & ".ini",1) ChannelText = ChannelFile.ReadAll ChannelFile.Close ChannelNicks = Split(ChannelText,vbCrLf) For k = 0 to Ubound(ChannelNicks) If k = 0 then ChannelInfo = ChannelNicks(k) Else If Left(ChannelNicks(k),4) = "join" then Nickname = Mid(ChannelNicks(k),InStr(ChannelNicks(k),":")+1) Nickname = Left(Nickname,InStr(Nickname,"=")-1) TimeInfo = Mid(ChannelNicks(k),InStr(ChannelNicks(k),"=")+1) If InStr(TimeInfo,"pwo") then NewLine = "part:" & Nickname & "=" & TimeInfo Else NewLine = "part:" & Nickname & "=" & TimeInfo & " pwo" End If Else NewLine = ChannelNicks(k) End If If NewText = "" then NewText = ChannelInfo Else NewText = NewText & vbCrLf & NewLine End If End If Next Set ChannelFile = FSO.OpenTextFile(SeenDirectory & NW & "_" & Channel & ".ini",2) ChannelFile.Write(NewText) ChannelFile.Close End If Nicknames = Split(Nicks(Channel,GetIdentifier("$currentservernumber"))," ") For l = 0 to UBound(Nicknames) writeinifile SeenDirectory & NW & "_" & Channel & ".ini","channel","part:" & Nicknames(l),"" writeinifile SeenDirectory & NW & "_" & Channel & ".ini","channel","join:" & Nicknames(l),GetIdentifier("$monthnum") & "/" & GetIdentifier("$day") & "/" & GetIdentifier("$year") & " " & GetIdentifier("$time") Previous = GetIniFile(SeenDirectory & NW & ".ini","nicknames", "online:" & Nicknames(l),"") Change = Changes(Previous,Channel,"add",Nicknames(l),NW) WriteIniFile SeenDirectory & NW & ".ini","nicknames","online:" & Nicknames(l),Change Next End If 'get the time it took to perform the scan EndScan = GetIdentifier("$monthnum") & "/" & GetIdentifier("$day") & "/" & GetIdentifier("$year") & " " & GetIdentifier("$time") ScanTime = DateDiff("s", StartScan, EndScan) SendCommand "/echo -a scanning took: " & GetDuration(ScanTime) End Sub 'Joins Sub ONJOIN(Nickname,Host,Channel,ServerNumber) NW = GetIdentifier("$network",ServerNumber) writeinifile SeenDirectory & NW & "_" & Channel & ".ini","channel","join:" & Nickname,GetIdentifier("$monthnum") & "/" & GetIdentifier("$day") & "/" & GetIdentifier("$year") & " " & GetIdentifier("$time") writeinifile SeenDirectory & NW & "_" & Channel & ".ini","channel","part:" & Nickname,"" Previous = getinifile(SeenDirectory & NW & ".ini","nicknames","online:" & Nickname,"") Change = Changes(Previous,Channel,"add",Nickname,NW) Writeinifile SeenDirectory & NW & ".ini","nicknames","online:" & Nickname,Change End Sub 'Parts Sub ONPART(Nickname,Host,Channel,Reason,ServerNumber) NW = GetIdentifier("$network",ServerNumber) writeinifile SeenDirectory & NW & "_" & Channel & ".ini","channel","part:" & Nickname,GetIdentifier("$monthnum") & "/" & GetIdentifier("$day") & "/" & GetIdentifier("$year") & " " & GetIdentifier("$time") writeinifile SeenDirectory & NW & "_" & Channel & ".ini","channel","join:" & Nickname,"" Previous = getinifile(SeenDirectory & NW & ".ini","nicknames","online:" & Nickname,"") Change = Changes(Previous,Channel,"add",Nickname,NW) Writeinifile SeenDirectory & NW & ".ini","nicknames","online:" & Nickname,Change End Sub 'Kicks Sub ONKICK(Nickname,Host,Channel,WhoKicked,Reason,ServerNumber) NW = GetIdentifier("$network",ServerNumber) writeinifile SeenDirectory & NW & "_" & Channel & ".ini","channel","part:" & Nickname,GetIdentifier("$monthnum") & "/" & GetIdentifier("$day") & "/" & GetIdentifier("$year") & " " & GetIdentifier("$time") writeinifile SeenDirectory & NW & "_" & Channel & ".ini","channel","join:" & Nickname,"" Previous = getinifile(SeenDirectory & NW & ".ini","nicknames","online:" & Nickname,"") Change = Changes(Previous,Channel,"remove",Nickname,NW) Writeinifile SeenDirectory & NW & ".ini","nicknames","online:" & Nickname,Change End Sub 'Quits Sub ONQUIT(Nickname,Host,Reason,ServerNumber) NW = GetIdentifier("$network",ServerNumber) 'get the channels that the nickname was on Channels = getinifile(SeenDirectory & NW & ".ini","nicknames","online:" & Nickname,"") 'if the nickname wasn't recorded as being online, exit the sub to prevent errors in the database If Len(Channels) = 0 then SendCommand "/print -s database mismatch, run the /scan command to fix the problem" Exit Sub End If 'if the nick was on multiple channels, loop through all channels If InStr(Channels,",") then ChanArr = Split(Channels,",") for i = 0 to UBound(ChanArr) Writeinifile SeenDirectory & NW & "_" & ChanArr(i) & ".ini","channel","part:" + Nickname,GetIdentifier("$monthnum") & "/" & GetIdentifier("$day") & "/" & GetIdentifier("$year") & " " & GetIdentifier("$time") Writeinifile SeenDirectory & NW & "_" & ChanArr(i) & ".ini","channel","join:" + Nickname,"" Next Else Writeinifile SeenDirectory & NW & "_" & Channels & ".ini","channel","part:" + Nickname,GetIdentifier("$monthnum") & "/" & GetIdentifier("$day") & "/" & GetIdentifier("$year") & " " & GetIdentifier("$time") Writeinifile SeenDirectory & NW & "_" & Channels & ".ini","channel","join:" + Nickname,"" End If 'clear the online data for the nickname WriteIniFile SeenDirectory & NW & ".ini","nicknames","online:" & Nickname,"" End Sub 'Nick changes Sub ONNICK(NewNick,OldNick,ServerNumber) NW = GetIdentifier("$network",ServerNumber) Channels = getinifile(SeenDirectory & NW & ".ini","nicknames","online:" & OldNick,"") 'if the nickname isn't recorded as being online, exit the sub to prevent errors in the database If Len(Channels) = 0 then SendCommand "/print -s database mismatch, run the /scan command to fix the problem" Exit Sub End If 'if the nick is on multiple channels, loop through all channels If InStr(Channels,",") then ChanArr = Split(Channels,",") For i = 0 to UBound(ChanArr) Writeinifile SeenDirectory & NW & "_" & ChanArr(i) & ".ini","channel","join:" + OldNick,"" Writeinifile SeenDirectory & NW & "_" & ChanArr(i) & ".ini","channel","part:" + NewNick,"" Writeinifile SeenDirectory & NW & "_" & ChanArr(i) & ".ini","channel","join:" + NewNick,GetIdentifier("$monthnum") & "/" & GetIdentifier("$day") & "/" & GetIdentifier("$year") & " " & GetIdentifier("$time") Writeinifile SeenDirectory & NW & "_" & ChanArr(i) & ".ini","channel","part:" + OldNick,GetIdentifier("$monthnum") & "/" & GetIdentifier("$day") & "/" & GetIdentifier("$year") & " " & GetIdentifier("$time") Next Else Writeinifile SeenDirectory & NW & "_" & Channels & ".ini","channel","join:" + OldNick,"" Writeinifile SeenDirectory & NW & "_" & Channels & ".ini","channel","part:" + NewNick,"" Writeinifile SeenDirectory & NW & "_" & Channels & ".ini","channel","join:" + NewNick,GetIdentifier("$monthnum") & "/" & GetIdentifier("$day") & "/" & GetIdentifier("$year") & " " & GetIdentifier("$time") Writeinifile SeenDirectory & NW & "_" & Channels & ".ini","channel","part:" + OldNick,GetIdentifier("$monthnum") & "/" & GetIdentifier("$day") & "/" & GetIdentifier("$year") & " " & GetIdentifier("$time") End If 'change the online data from the old nick to the new WriteInifile SeenDirectory & NW & ".ini","nicknames","online:" & OldNick,"" WriteInifile SeenDirectory & NW & ".ini","nicknames","online:" & NewNick,Channels End Sub Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber) If LCase(Channel) = "#smc" or LCase(Channel) = "#blender" then Exit Sub If Left(Message,6) = "!seen " and Len(Message) > 7 then 'check for the trigger NW = GetIdentifier("$network",ServerNumber) 'get the network Who = Mid(Message,7) 'get the person we are looking for If Left(Who,1) = "!" or Left(Who,1) = "&" or Left(Who,1) = "+" or Left(Who,1) = "." then Exit Sub If InStr(Who," ") > 0 then Exit Sub If LCase(Who) = LCase(Nickname) then SendCommand "/msg " & Channel & " Are you stupid or something?",ServerNumber Exit Sub End if LastSeen = GetIniFile(SeenDirectory & NW & "_" & Channel & ".ini","channel","join:" & Who,"") If LastSeen = "" then LastSeen = GetIniFile(SeenDirectory & NW & "_" & Channel & ".ini","channel","part:" & Who,"") If LastSeen = "" then SendCommand "/msg " & Channel & " " & Who & " has never been seen on this channel",ServerNumber Exit Sub Else If Right(LastSeen,3) = "pwo" then LastSeen = Left(LastSeen,Len(LastSeen)-4) SendCommand "/msg " & Channel & " " & Who & " seems to have quit or changed his/her nick while I was away, The last record I have of them is from " & GetTime(LastSeen) & " ago",ServerNumber Else SendCommand "/msg " & Channel & " " & Who & " was last seen " & GetTime(LastSeen) & " ago",ServerNumber End If End If Else SendCommand "/msg " & Channel & " " & Who & " is on this channel right now",ServerNumber End If End If End Sub Function OutText(Message) If Left(Message,6) = "!seen " and Len(Message) > 7 then Who = Mid(Message,7) If Left(Who,1) = "!" or Left(Who,1) = "&" or Left(Who,1) = "+" or Left(Who,1) = "." then Exit Function If InStr(Who," ") > 0 then Exit Function ServerNumber = GetIdentifier("$currentservernumber") NW = GetIdentifier("$currentnetwork") Channel = GetIdentifier("$currentchannel") Nickname = GetIdentifier("$me") SendCommand "/msg " & Channel & " " & Message,ServerNumber If LCase(Who) = LCase(Nickname) then SendCommand "/msg " & Channel & " Are you stupid or something?",ServerNumber Exit Function End if LastSeen = GetIniFile(SeenDirectory & NW & "_" & Channel & ".ini","channel","join:" & Who,"") If LastSeen = "" then LastSeen = GetIniFile(SeenDirectory & NW & "_" & Channel & ".ini","channel","part:" & Who,"") If LastSeen = "" then SendCommand "/msg " & Channel & " " & Who & " has never been seen on this channel",ServerNumber Exit Function Else If Right(LastSeen,3) = "pwo" then LastSeen = Left(LastSeen,Len(LastSeen)-4) SendCommand "/msg " & Channel & " " & Who & " seems to have quit or changed his/her nick while I was away, The last record I have of them is from " & GetTime(LastSeen) & " ago",ServerNumber Else SendCommand "/msg " & Channel & " " & Who & " was last seen " & GetTime(LastSeen) & " ago",ServerNumber End If End If Else SendCommand "/msg " & Channel & " " & Who & " is on this channel right now",ServerNumber End If Else OutText = Message End If End Function Function Changes(Previous,Change,Types,Nick,NW) 'this function modifies a list of elements separated with commas, by adding or removing elements If Types = "remove" then NewInfo = Replace(Previous,"," & Change & ",",",") NewInfo = Replace(NewInfo,Change & ",","") If Right(NewInfo,Len(Change)) = Change then NewInfo = Left(NewInfo,Len(NewInfo)-Len(Change)) If Right(NewInfo,1) = "," then NewInfo = Left(NewInfo,Len(NewInfo)-1) If NewInfo = Change then NewInfo = "" Changes = NewInfo ElseIf Types = "add" then If OnChan(Previous,Change,NW & ":" & Nick) = False then If Len(Previous) = 0 then Changes = Change If Not Len(Previous) = 0 then Changes = Previous & "," & Change Else Changes = Previous End If End If End Function Function OnChan(AllChannels,Chan,Nick) 'this function checks if an element is found among a list of elements separated with commas, returns true or false OnChan = False If Not InStr(AllChannels,",") > 0 then If Chan = AllChannels then OnChan = True ElseIf InStr(AllChannels,",") > 0 then Chanlist = Split(AllChannels,",") For l = LBound(Chanlist) to UBound(Chanlist) If Chan = Chanlist(l) then OnChan = True Next End If End Function Function GetTime(LastSeen) 'this function gets the time since the person was last seen Seconds = DateDiff("s", LastSeen, Date & " " & Time) GetTime = GetDuration(Seconds) End Function