Log Server for mIRC

Platform:  mIRC
Published  Oct 15, 2010
Updated  Oct 15, 2010
This script will Create a channel log in html format for each of the channels you select.
You can also use this script to act as a server and display the pages on the web for others to view.



First: If your not familiar with port forwarding and you have never added a firewall exception, this is not going to be very easy.
Take a few deep breaths before you start and if you have too much trouble just come to irc.geekshed.net #Script-Help and I will do my best to help you get this going.
Getting Started:

  • Copy this code, Paste it to a new remote and save it with a unique file name.
  • Select a port number (default is 1337) and forward it from your router to your computer. For help with this look here --> http://portforward.com/
  • Create an exception in your Firewall for the port you selected in step 2.
  • Create an exception in your Firewall for mIRC.exe (To create this exception you must know the location of mIRC.exe. Type //echo -a $mircexe
  • Goto http://www.no-ip.com/ , http://www.dyndns.com/ or a similar site and get a free host name. (you can optionally use your ipaddress)
  • Right click channel or status and set up logging and turn on the server for the channels you want to make pages for. (Make sure you turn on the master switches)


Explaining the Dialog:

  • Network: Network
  • Channel: Channel
  • Colors: Will change the colors for the selected event on the web page.
  • Headers:
  • Text: The text that will be placed in the header portion of the page.
  • Color: Header Color
  • Size: Header size
  • Style: b=bold i=italics u=underlined
  • Logging: Turns logging on/off for the selected channel.
  • Server Information:
  • Host: hostname you get from no-ip or ddns. Default is http://127.0.0.1 (Please do not omit the http:// , as I have yet to add a check for this.)
    **Note** that the Host is currently only used for the link that is generated at the bottom of the dialog.
  • Port: This is the port that you selected and forwarded from your router to your pc. (Default is 1337)
    **Note** Any time you change any of the Server Information you must click the Save button!!
  • Master Switch:
  • Logging On: Turns all Logging on/off
  • Server On: Turns all Server functions on/off
  • Link -- Will open a browser window based on the information currently showing on the dialog.
    The basic format of a link for a channels log page is like this:
    http://yourhost.com:1337/Network/%23Channel
    **Note** You cannot use # in most browsers because it will be considered an anchor. You must use %23 instead!!
  • Save: Will save all changes - Including Server Information.
  • Quit: Exits and saves all changes to the hashtable.

Extra::
You may add a favicon.icon by placing it in the LogServer directory.
The LogServer directory can be found in the $mircdir.


Tip::
Try setting this script up with http://127.0.0.1 and then work your way up to opening ports and adding exceptions so others can use it.
**Note** All of the log files can be found in $mircdir + LogServer/Network Under the #ChannelName.html . You can also open them from there.

Additional info:
All logs are reset at the first entry of each new day. The old file will be saved under #channelmm-dd-yyyy.html . I will be writing an index pages for this at some point but you can access them with the log server the same as the current page. (ie. http://yourhost.com:1337/Network/%23Channelmm-dd-yyyy.html )

That's all for now :)
;LogServer by Ford_Lawnmower irc.geekshed.net #Script-Help
menu channel,status,menubar {
LogServer: dialog $iif($dialog(LogServer),-v,-m LogServer) LogServer
}
#LogServerServer On
On *:Socklisten:LogServer: sockaccept $+(Chanlogs.,$network,$chan,$ticks)
On *:Sockread:Chanlogs.*: {
var %Chanlogs | sockread %Chanlogs
if ($regex(%Chanlogs,/GET\s\/(.*)\sHTTP\//)) {
var %filename $+(LogServer/,$recode($regml(1)))
hinc LogServer AccessCount
if ($file(%filename).size) {
var %filelen $v1, %maxsend 1024
sockwrite -n $sockname HTTP/1.1 200 OK
sockwrite -n $sockname Content-Type: text/html
sockwrite -n $sockname Content-Length: $file(%filename).size
sockwrite -n $sockname
sockmark $sockname %filename 0 %maxsend $iif($ceil($calc(%filelen / %maxsend)),$v1,1)
}
else {
sockwrite -n $sockname HTTP/1.0 400 Bad Request
sockwrite -n $sockname Connection: close
sockclose $sockname
}
}
}
On *:Sockwrite:Chanlogs.*: {
tokenize 32 $sock($sockname).mark
if ($4) {
bread $1-3 &binvar
sockwrite -n $sockname &binvar
sockmark $sockname $1 $calc($2 + $3) $3 $calc($4 - 1)
bunset &binvar
}
else {
sockwrite -n $sockname
sockwrite -n $sockname Connection: close
sockclose $sockname
}
}
#LogServerServer End
#LogServerLogging On
On *:Text:*:#: WriteLogs $event $chan $nick $1-
On *:Action:*:#: WriteLogs $event $chan * $nick $1-
On *:Join:#: WriteLogs $event $chan * $nick Joins $chan
On *:Part:#: WriteLogs $event $chan * $nick Parts $chan $+($chr(40),$1-,$chr(41))
On *:Kick:#: WriteLogs $event $chan * $nick Kicked $knick Out of $chan $+($chr(40),$1-,$chr(41))
On *:RawMode:#: WriteLogs $event $chan * $nick Sets Mode(s) $1-
On *:Nick: WriteAllLogs $event <chan> $newnick * $nick Changes Nick to $newnick
On *:Quit: WriteAllLogs $event <chan> $nick * $nick Quits $network $+($chr(40),$1-,$chr(41))
On *:Topic:#: WriteLogs $event $chan * $nick Changes Topic to: $1-
On *:Input:#: {
if ($left($1,1) != / && !$ctrlenter) { WriteLogs me $chan $nick $1- }
}
On *:Start: {
if (!$hget(LogServer)) hmake LogServer 5
if ($file(LogServer.hsh).size) hload LogServer LogServer.hsh
}
On *:Unload: hfree LogServer
#LogServerLogging End
On *:Dialog:LogServer:init:*: LogServerInit $dname
On *:Dialog:LogServer:close:*: {
if ($hget(LogServer)) hsave $v1 $+($v1,.hsh)
}
On *:Dialog:LogServer:Sclick:*: {
if ($did == 1) {
didtok -ra $dname 2 32 $chans($did(1))
did -c $dname 2 1
LogServerWriteDialog
}
elseif ($did == 2) LogServerWriteDialog
elseif ($did < 25) {
LogServerWriteHash
if (($findtok(23 24,$did,32)) && ($did(23).state)) LogServerStart $did(21)
elseif ($did == 22) $iif($did(22).state,.enable,.disable) #LogServerLogging
}
elseif ($did == 50) url -a $+($did(20),:,$did(21),/,$did(1),/,$urlencode($did(2)),.html)
}
dialog LogServer {
title "Log Server"
size -1 -1 234 253
option dbu
combo 1, 8 22 100 10, drop
combo 2, 125 22 100 10, drop
combo 3, 8 50 69 10, drop
combo 4, 82 50 69 10, drop
combo 5, 157 50 69 10, drop
combo 6, 8 69 69 10, drop
combo 7, 82 69 69 10, drop
combo 8, 157 69 69 10, drop
combo 9, 8 88 69 10, drop
combo 10, 82 88 69 10, drop
combo 11, 157 88 69 10, drop
combo 12, 8 107 69 10, drop
combo 13, 82 107 69 10, drop
edit "", 14, 31 132 196 10, autohs
combo 15, 31 144 62 11, drop
combo 16, 120 144 41 11, drop
combo 17, 185 144 41 11, drop
radio "On", 18, 18 171 26 10, group push
radio "Off", 19, 18 186 26 10, push
edit "", 20, 132 171 83 10, autohs
edit "", 21, 132 186 83 10, autohs
check "Logging On", 22, 33 213 50 10
check "Server On", 23, 126 213 50 10
button "Save", 24, 146 239 37 12
button "Quit", 25, 194 239 37 12, Cancel
text "Network:", 26, 8 13 27 8
text "Channel:", 27, 125 13 25 8
text "Join:", 28, 8 42 25 8
text "Part:", 29, 82 42 25 8
text "Quit:", 30, 157 42 25 8
text "Kick:", 31, 8 61 25 8
text "RawMode:", 32, 82 61 29 8
text "Nick:", 33, 157 61 25 8
text "Text:", 34, 8 80 25 8
text "Action:", 35, 82 80 25 8
text "Input:", 36, 157 80 25 8
text "Topic:", 37, 8 99 25 8
text "Host Name:", 38, 85 171 31 8
text "Server Port:", 39, 85 186 31 8
text "Text:", 40, 4 132 25 8, right
text "Color:", 41, 4 144 25 8, right
text "Size:", 42, 94 144 25 8, right
text "Style:", 43, 162 144 22 8, right
text "", 44, 2 242 141 8
box "Colors", 45, 3 33 228 91
box "Logging", 46, 3 160 56 40
box "Server Information", 47, 69 160 162 40
box "Master Switch", 48, 3 202 229 25
box "Headers", 49, 3 124 228 34
link "", 50, 3 229 228 8
text "Background:", 51, 82 99 33 8
}
alias -l LogServerStart {
.enable #LogServerServer
if ($1 != $sock(LogServer).port) {
if ($sock(LogServer)) sockclose LogServer
if ($portfree($1)) {
socklisten LogServer $1
.enable #LogServerServer
}
else {
if ($dialog(LogServer)) {
did -u LogServer 23
hadd LogServer server 0
.disable #LogServerServer
}
var %noop $input(Port $1 is already in use! Server status is Off!,o,LogServer)
}
}
}
alias -l urlencode return $regsubex($1-,/([^a-z0-9])/ig,% $+ $base($asc(\t),10,16,2))
alias -l recode return $regsubex($1-,/%([0-9a-f]{2})/gi,$chr($base(\t,16,10)))
alias -l tag return <a $+(class=",$1,">)
alias -l WriteLogs {
if ($gettok($hget(LogServer,$+($network,$2)),2,32)) {
var %timestamp $+($tag(c1),[,</a>,$tag(c2),$time(hh),</a>,$tag(c1),:,</a>,$tag(c2),$time(nnTT),</a>,$tag(c1),]</a>)
var %nickstamp $+($tag(c1),$chr(40),</a>,$tag(c2),$symbol($2,$3),$3,</a>,$tag(c1),$chr(41),</a>)
var %events join part text me action kick nick rawmode quit topic
var %CurrentLog $+(LogServer\,$network,\,$2,.html)
if (!$isdir($+(LogServer\,$network))) {
if (!$isdir(LogServer)) { mkdir LogServer }
mkdir $+(LogServer\,$network)
}
elseif ($findtok(%events,$1,32)) {
var %match $gettok(%events,$v1,32)
if ($gettok($hget(LogServer,$+($network,$2)),1,32) != $day) {
if ($v1 && $file(%CurrentLog).size) { .copy -o %CurrentLog $+(LogServer\,$network,\,$2,$asctime($calc($ctime - 86400),mm-dd-yyyy),.html) }
write -c %CurrentLog
LogServerWriteStyle $Hash2Color($+($2,$chr(32),$hget(LogServer,$+($network,$2))))
.timer -o 1 2 write -l30 %CurrentLog Logging started $fulldate <br>
.timer -o 1 3 write $+(-il,$calc($lines(%CurrentLog) - 1)) %CurrentLog $+(%timestamp,$chr(32),%nickstamp,$chr(32),$tag(%match),$parseurl($HTMLFormat($strip($4-))),</a><br>)
hadd Logserver $+($network,$2)) $puttok($hget(LogServer,$+($network,$2)),$day,1,32)
}
else {
if ($1 == topic) {
write -l29 %CurrentLog Topic is: $strip($mIRC2HTML($parseurl($chan($2).topic))) <br>
.timer -o 1 2 write $+(-il,$calc($lines(%CurrentLog) - 1)) %CurrentLog $+(%timestamp,$chr(32),%nickstamp,$chr(32),$tag(%match),$parseurl($HTMLFormat($strip($4-))),</a><br>)
}
else {
write $+(-il,$calc($lines(%CurrentLog) - 1)) %CurrentLog $+(%timestamp,$chr(32),%nickstamp,$chr(32),$tag(%match),$parseurl($HTMLFormat($strip($4-))),</a><br>)
}
}
}
}
}
alias -l WriteAllLogs {
var %chans $comchan($3,0),%count 1
while (%count <= %chans) {
WriteLogs $1 $comchan($3,%count) $4-
inc %count
}
}
alias -l symbol return $iif($remove($nick($1,$2).pnick,$2),$left($v1,1))
alias -l parseurl {
return $regsubex($1-,/((http:\/\/|www\.)[^\s^\x5d^\x29]*)/gi,$+(<a target="_blank" href=",\1,">,\1,</a>))
}
alias -l chans { scon $netid($1) return $!regsubex($str(.,$chan(0)),/./g,$+($chr(32),$chan(\n))) }
alias -l NetScID {
var %net $1, %netid $regsubex($str(.,$scon(0)),/./g,$iif($scon(\n).network == %net,\n,$null))
scon %netid return $!cid
}
alias -l nets { return $regsubex($str(.,$scon(0)),/./g,$+($chr(32),$scon(\n).network)) }
alias -l netid {
var %netcount $scon(0)
while %netcount {
if ($scon(%netcount).network == $1) { return %netcount }
dec %netcount
}
}
alias -l LogServerInit {
var %colors black silver gray white maroon red purple fuchsia green lime olive yellow navy blue teal aqua
didtok -a $1 1 32 $nets
did -c $1 1 1
didtok -a $1 2 32 $chans($did(1))
did -c $1 2 1
didtok -a $1 3-13,15 32 %colors
didtok -a $1 16 32 $regsubex($str(.,50),/./g,$+($chr(32),\n))
didtok -a $1 17 32 b i u b/i b/u i/u b/i/u
LogServerWriteDialog
}
alias -l LogServerWriteDialog {
if ($hget(LogServer,$+($did(1),$did(2)))) {
tokenize 32 $v1
did -c $dname $iif($2,18,19)
did -u $dname $iif($2,19,18)
var %start 3
while (%start <= 16) {
if (%start < 14) { did -c $dname %start $($+($,%start),3) }
else { did -c $dname $calc(%start + 1) $($+($,%start),3) }
inc %start
}
did -ra $dname 14 $19-
did -ra $dname 20 $hget(LogServer,Host)
did -ra $dname 21 $hget(LogServer,Port)
did $iif($hget(LogServer,logging),-c,-u) $dname 22
did $iif($hget(LogServer,server),-c,-u) $dname 23
did -ra $dname 50 Logserver for $did(2) on $did(1)
}
else LogServerDefaults $dname
}
alias -l LogServerDefaults {
var %key 0 0 9 9 2 6 6 14 7 11 15 13 4 0 14 30 1,%start 3
while (%start <= 17) {
did -c $1 %start $gettok(%key,%start,32)
inc %start
}
did -ra $1 14 Log File for $did($1,2) on $did($1,1)
did -ra $1 20 $iif($hget(LogServer,Host),$v1,http://127.0.0.1)
did -ra $1 21 $iif($hget(LogServer,Port),$v1,1337)
did -c $1 19
did -u $1 18
did -ra $dname 50 Logserver for $did(2) on $did(1)
}
alias -l LogServerWriteHash {
var %EventInfo $regsubex($str(.,11),/./g,$+($chr(32),$did($calc(\n + 2)).sel))
var %HeaderInfo $regsubex($str(.,3),/./g,$+($chr(32),$did($calc(\n + 14)).sel))
var %day $iif($gettok($hget(LogServer,$+($did(1),$did(2))),1,32),$v1,0)
hadd -m LogServer $+($did(1),$did(2)) %day $did(18).state %EventInfo %HeaderInfo $did(20) $did(21) $did(14)
hadd LogServer Server $did(22).state
hadd LogServer Logging $did(23).state
hadd LogServer Host $did(20)
hadd LogServer Port $did(21)
LogServerWriteStyle $regsubex($str(.,13),/./g,$+($chr(32),$did(\n))) $regsubex($str(.,3),/./g,$+($chr(32),$did($calc(\n + 14)))) $did(14)
}
alias -l LogServerWriteStyle {
var %WriteKey 0 0 0 join part quit kick rawmode nick text action me topic, %LogFile $+(LogServer\,$1,\,$2,.html)
if (!$isdir($+(LogServer\,$1))) {
if (!$isdir(LogServer)) mkdir LogServer
mkdir $+(LogServer\,$1)
}
write -l1 %LogFile <html>
write -l2 %LogFile <head>
write -l3 %LogFile <style type="text/css">
var %start 4
while (%start <= 12) {
write $+(-l,%start) %LogFile $+(a.,$gettok(%WriteKey,%start,32)) $chr(123) color: $($+($,$calc(%start - 1),;),3) background: $+($13,;) $chr(125)
inc %start
}
write -l13 %LogFile
write -l14 %LogFile
write -l15 %LogFile h1 $chr(123) color: $+($14,;) background: $+($13,;) font-size: $+($15,pt;) $TextFormat($16) $chr(125)
write -l16 %LogFile a.c1 $chr(123) color: lime; background: $+($13,;) font-weight: bold; $chr(125)
write -l17 %LogFile a.c2 $chr(123) color: red; background: $+($13,;) $chr(125)
write -l18 %LogFile body $chr(123) color: $+($iif($13 == white,black,white),;) background-color: $+($13,;) background-image: none; $chr(125)
var %start 19
while (%start <= 24) {
write $+(-l,%start) %LogFile
inc %start
}
write -l25 %LogFile </style>
write -l26 %LogFile </head>
write -l27 %LogFile <body>
write -l28 %LogFile <h1> $17- </h1><br>
scid $NetScID($1)
write -l29 %LogFile Topic is: $strip($mIRC2HTML($parseurl($chan($2).topic))) <br>
if ($lines(%LogFile) == 29) {
write -l30 %LogFile
write -l31 %LogFile </body>
write -l32 %LogFile </html>
}
}
alias -l Hash2Color {
var %ColorKey black silver gray white maroon red purple fuchsia green lime olive yellow navy blue teal aqua
var %len $gettok($1-,0,32), %StyleKey b i u b/i b/u i/u b/i/u, %count 3, %result
while (%count <= %len) {
if (%count > 3 && %count < 16) { %result = $+(%result,$chr(32),$gettok(%ColorKey,$gettok($1-,%count,32),32)) }
elseif (%count == 17) { %result = $+(%result,$chr(32),$gettok(%StyleKey,$gettok($1-,%count,32),32)) }
elseif (%count > 19 || %count == 16) { %result = $+(%result,$chr(32),$gettok($1-,%count,32)) }
inc %count
}
return $network $gettok($1-,1,32) %result
}
alias -l mIRC2HTML return $regsubex($1-,/([0-9]{1,2})(?:\x2C[0-9]{1,2})?/g,$+($iif(\n != 1,</font>),<font color= $mIRC2Color($int(\1)),>))) $+ $iif($regml(0),</font>)
alias -l mIRC2Color {
var %key white black blue green red maroon purple olive yellow lime teal aqua namy fuchsia gray silver
return $qt($gettok(%key,$calc($1 + 1),32))
}
alias -l TextFormat return $replacex($1,/,$chr(32),b,font-weight: bold; ,i,font-style: italic;,u,text-decoration: underline;)
alias -l HTMLFormat return $regsubex($1-,/([<>\[\]\{\}\(\)]{1})/g,$+(&#x,$base($asc(\t),10,16),;))

Comments

Sign in to comment.
Kentaro Kurosaki   -  Oct 26, 2011
Its fully working, Don't worry about it :) Fail on my part
 Respond  
Kentaro Kurosaki   -  Oct 26, 2011
Actually It is somewhat working, I just didn't do it right, i thought i had to put different ports for each channel :) Right now i think the script is just off
 Respond  
Aha2Y   -  Oct 25, 2011
Very nice again FordLawnmower :)
 Respond  
FordLawnmower   -  Oct 25, 2011
@Kentaro Kurosaki Explain your problem a little more , I have had this script logging on 4 networks for almost a year with no problems.
 Respond  
Kentaro Kurosaki   -  Oct 25, 2011
I like it :) I use it to log my bot, though I don't know why i'm not able to to log more than one network, even while changing the port for the different network
 Respond  
[nas]peter   -  Oct 17, 2010
i had it lag in a way that when i type something it shows up 5 seconds later, my os is 32 btw. and i don't know why it lagged.
 Respond  
FordLawnmower   -  Oct 16, 2010
Thanks _Teen_ :)
 Respond  
_Teen_   -  Oct 16, 2010
didnt tested the script but as ever nice job
 Respond  
FordLawnmower   -  Oct 16, 2010
Ok cool blackvenomm666 :)
Thanks for testing it.
 Respond  
blackvenomm666   -  Oct 16, 2010
thats what i was saying fl that it works fine. i said i dont see why the script would lag anyones stuff. im running pretty much the bare minimal on everything with my computer but it doesnt lag me at all
 Respond  
FordLawnmower   -  Oct 16, 2010
It should work fine on 6.31 blackvenomm666.
 Respond  
blackvenomm666   -  Oct 16, 2010
im running off of a gig of ram on a 2001 dell don't see why the script would lag anyones but im running v6.31 meh.
 Respond  
FordLawnmower   -  Oct 16, 2010
I haven't had any issues with crashing or lag either napa182.
I haven't tested this on mirc 7 yet but I have tested it on 6.35 with xp, vista and windows 7. I will do some testing later with 7.1 on windows 7 and if I have any issues I will be sure to correct them asap.
Is your vista 64 or 32 [nas]peter?
 Respond  
napa182   -  Oct 16, 2010
shouldn't mater how many mirc's you have open. I have 3 mirc's open all connected to 15 diff servers, and it still hasn't lagged or crashed my PC.
 Respond  
[nas]peter   -  Oct 16, 2010
2 mirc open, and a lot of more things (e.g. 5 different tabs on internet). 4GB ram on my computer but vista takes 1.5 away :(
 Respond  
napa182   -  Oct 16, 2010
odd This snippet hasn't lagged nor crashed my PC.
 Respond  
[nas]peter   -  Oct 16, 2010
os: windows vista
mirc version: 7.1
I was trying to start the logging of a channel (mirc was slow when i was trying to start it) and it just crashed.(didn't respond). And when i am using it, it lags me extremely.
 Respond  
FordLawnmower   -  Oct 16, 2010
Thank You jaytea :)

@[nas]peter Please explain your problem a little better and I will try to help you sort it out. Please include your mIRC version, windows version and some more details describing your problem.
 Respond  
[nas]peter   -  Oct 16, 2010
The only problem with this script is that it makes my mIRC crash, for the rest it is great.
 Respond  
jaytea   -  Oct 16, 2010
FL, you're certainly one of a dying breed: those able to consistently create addons that are useful, complete, well coded and documented, and (judging by their feedback) effective :P massive respect!
 Respond  
FordLawnmower   -  Oct 15, 2010
Thanks SunnyD :)
Thank You napa182 :)
 Respond  
napa182   -  Oct 15, 2010
Nice work Ford. 9/10 +like
 Respond  
SunnyD   -  Oct 15, 2010
Bravo, holy shoot lmao.
 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.