Themes Server — File Browser
ThemesServerv1.0 / ThemesServerv1.0 / MTS_themes_server.mrc
MTS_themes_server.mrc — 8.17 KB — Download this file
; __________________________________________
;| |
;| Themes server |
;| Developed by Dark_Sun |
;| feel free to use/modify/rip it as |
;| you want but keep credits alive :P |
;|__________________________________________|
ctcp ^*:Theme*:?:{ haltdef
if (themeserv* iswm $1) {
if $2- = I HAVE IT { if (!$dialog(thm.sc)) dialog -m thm.sc thm.s
did -a thm.sc 1 $nick | return }
if (*?.*?.?*.*? !iswm $2) .ctcpreply $nick $1 INVALID PARAMETERS
elseif (!%themestatus) || (!%themedir) .ctcpreply $nick $1 SERVER NOT ACTIVE
elseif ($sock(themes.*,1)) .ctcpreply $nick $1 BUSY
else { .timer -m 1 3 themeserv $nick $2- } }
if $1 = themelist { var %zx,%x = $findfile(%themedir,*.mts,0,/set %zx $addtok(%zx,$remove($nofile($1-),%themedir,\),124))
.ctcpreply $nick $1 %zx }
if $1 = theme.start {
sockopen themes. $+ [ $nick ] $4 $5 | sockmark themes. $+ [ $nick ] $3
openwin send $2 | dd send Sending: $3 MTS Theme $_&( $+ $bytes($2).suf $+ ) to: $nick
} }
alias -l perc { if ($1 < 1) { return 0% } | if ($1 == $2) { return 100% }
return $iif($round($calc(($1 * 10000) / ($2 * 100)),1) > 100,100,$int($calc(($1 * 10000) / ($2 * 100)))) $+ %
}
alias -l _& return ( $+ $1- $+ )
alias -l dd { var %a = $$2- | drawtext -prb @theme. $+ [ $1 ] $rgb(text) $rgb(face) Tahoma 11 $int($calc((292 - $width(%a,Tahoma,11,0,1)) / 2)) 0 %a }
alias -l openwin { var %a = @theme. $+ [ $1 ] | window -hdBkopa +fL %a 266 103 292 38 | drawrect -rf %a $rgb(face) 1 0 0 292 38 | titlebar %a $2-
drawline -r %a $rgb(shadow) 1 240 17 1 17 1 30 | drawline -r %a $rgb(hilight) 1 240 17 240 30 1 30
drawline -r %a $rgb(shadow) 1 283 17 245 17 245 30 | drawline -r %a $rgb(hilight) 1 283 17 283 30 245 30
}
alias -l drawprog drawrect -fr @theme. $+ [ $1 ] 0 1 3 19 $int($calc((235 * $2) / $$3)) 10
alias -l drawperc drawrect -fr @theme. $+ [ $1 ] $rgb(face) 1 248 18 30 10 | drawtext -r @theme. $+ [ $1 ] $rgb(text) Tahoma 11 248 17 $2-
alias -l b_ return %themedir
alias inpt .echo -q $input($2-,$1,Themes Server)
alias themelist {
if ($$1 ischan) { dialog $iif($dialog(thm.sc),-a,-m) thm.sc thm.s | .msg $1 who has themes server ? | did -ra thm.sc 3 $$1 | did -r thm.sc 1,2 }
else { dialog $iif($dialog(thm.s),-a,-m) thm.s thm.s | .ctcp $1 themelist | did -ra thm.s 2 Retrieving.. | did -r thm.s 1,3
} }
alias -l thm.port { if (%themeport) return $ifmatch | else { var %c = $rand(2342,6003) | while (!$portfree(%c)) { inc %c } | return %c } }
on *:dialog:thm.s*:dclick:1:{
if $dname = thm.sc { themelist $did(1).seltext | dialog -x $dname }
else { if !$isdir($b_ $+ $did(1).seltext) {
if (!$sock(themeserv)) socklisten themeserv $thm.port | .ctcp $did(3) themeserv $ip $sock(themeserv).port $gettok($did($did).seltext,1,32) | dialog -x $dname
} | else inpt ho You already have $did(1).seltext MTS theme. } }
on *:ctcpreply:THEME*:{
if (themeserv* iswm $1-) {
if ($2- = INVALID PARAMETERS) .timer -m 1 1 inpt ho Invalid parameters sent to themes server of $nick .
elseif ($2- = SERVER NOT ACTIVE) .timer -m 1 1 inpt io Themes server of $nick is not active.
elseif ($2- = BUSY) .timer -m 1 1 inpt io Themes server of $nick is busy, try again later.
else { .ctcp $nick THEME.START $2 $3 $ip $sock(themeserv).port | sockmark themeserv $4
openwin sget $2 | dd sget Receiving: $3 MTS $_&( $+ $bytes($2).suf $+ ) from: $nick | window -a @theme.sget 266 203
} }
if (themelist = $1) { $iif(!$dialog(thm.s),dialog -m thm.s thm.s) | didtok thm.s 1 124 $2- | did -ra thm.s 2 $numtok($2-,124) MTS themes | did -ra thm.s 3 $nick }
halt
}
alias -l themeserv { var %az = 0
if ($input($1 $_&($2) has requested your $4 MTS theme. Would you like to send it to him ?,ik,Theme Server)) {
var %x = $findfile(%themedir $+ $4,*,0,/inc %az $file($+(",$1-,")).size )
.ctcpreply $1 THEMESERV %az $4 $ip }
}
on *:socklisten:themeserv:{ var %d = theme. $+ $ticks $+ $r(1,99999)
sockaccept %d
if ($sock(themeserv).mark != $sock(%d).ip) { sockwrite -n %d fuckin lame | sockclose %d }
}
on *:sockopen:themes.*:{
if ($sockerr = 0) { var %zc = 1,%xc = 1,%fl = $remove($findfile(%themedir $+ $sock($sockname).mark,*,%zc),%themedir)
var %file = $+(",$findfile(%themedir $+ $sock($sockname).mark,*,%zc),")
sockwrite -n $sockname FILE: $file(%file).size %fl
bread %file 0 2000 &sk
sockwrite -n $sockname &sk | %thm.bread.n = 1 | %thm.bread = 0
.timer -m 0 500 breadfile $sockname %file
}
}
dialog -l t.s {
title "Themes server v1.0"
size -1 -1 201 153
option pixels
tab "Conf", 1, 1 3 198 125
text "Themes server now is: X", 2, 6 30 189 16, tab 1 center
edit "", 3, 7 69 166 21, tab 1 read autohs
button "...", 4, 174 70 22 19, tab 1
text "Themes folder", 5, 8 51 80 16, tab 1
box "", 7, 6 41 189 8, tab 1
text "there are 0 *.mts file in that folder", 17, 8 98 184 16, tab 1 center
tab "About", 8
text "Dark_Sun", 9, 70 30 60 16, disable tab 8 center
box "", 10, 6 41 189 8, tab 8
text "On IRC:", 11, 11 56 50 16, tab 8
link "#mircscripter @ Azzurra", 13, 69 56 124 16, tab 8
link "daio86yea@hotmail.com", 14, 69 79 124 16, tab 8
text "Email:", 12, 11 79 50 16, tab 8
box "", 15, 6 93 189 8, tab 8
text "Tanks for using.", 16, 8 104 183 16, tab 8 center
button "&Close", 6, 128 129 71 21, ok
check "Open/close server", 18, 3 129 100 21, push
}
on *:dialog:t.s:*:*:{ var %a = $dname,%b = $did
if $devent = init { if (%themedir) did -a %a 3 $ifmatch | if (%themestatus) did -c %a 18
did -ra %a 17 there are $iif(%themedir,$findfile(%themedir,*.mts,0),0) *.mts file in that folder
did -ra %a 2 Themes server now is: $iif(%themestatus && %themedir,ON,OFF)
}
if $devent = sclick {
if (%b = 18) { set %themestatus $did(18).state | did -ra %a 2 Themes server now is: $iif(%themestatus && %themedir,ON,OFF) }
if %b = 4 { var %z = $sdir(.\,Select MTS themes directory) | if %z { set %themedir %z | did -ra %a 3 %z | did -ra %a 17 there are $iif(%themedir,$findfile(%themedir,*.mts,0),0) *.mts file in that folder
} }
if %b = 13 /server -m irc.azzurra.org -j #mircscripter
if %b = 14 run mailto:daio86yea@hotmail.com
}
}
alias thmserv dialog $iif($dialog(t.s),-a,-m) t.s t.s
dialog -l thm.s {
title "Themes server"
size -1 -1 130 210
option pixels
list 1, 0 20 130 170, size sort
text "Status..", 2, 1 193 128 16
text "", 3, 1 2 128 15, center
}
alias breadfile { inc %thm.bread 2000
bread $2- %thm.bread 2000 &sk | sockwrite -n $1 &sk | drawprog send $sock($1).sent $window(@theme.send).title | drawperc send $perc($sock($1).sent, $window(@theme.send).title)
if ($file($2-).size <= %thm.bread) {
.timer $+ [ $ctimer ] off | unset %thm.bread | inc %thm.bread.n
if ($findfile(%themedir $+ $gettok($remove($nofile($2-),%themedir),1,92),*,%thm.bread.n)) { var %file = $+(",$ifmatch,")
sockwrite -n $1 FILE: $file(%file).size $remove($ifmatch,%themedir)
bread %file 0 2000 &sk | sockwrite -n $1 &sk
.timer 0 1 breadfile $1 %file
}
else { sockclose $1 | unset %thm.brea* | close -@ @theme.send }
} }
on *:sockclose:theme.*:{ if ($window(@theme.sget)) close -@ @theme.sget | sockclose themeserv }
on *:sockread:theme.*:{
if ($sockerr = 0) { tokenize 32 $sock($sockname).mark
if (!$2) {
var %a | sockread %a
if (FILE:* iswm %a) { sockmark $sockname $gettok(%a,-2-,32) | var %aa = $gettok(%a,3-,32)
if (\ isin %aa) && (!$isdir($b_ $+ $nofile(%aa)) ) { mkdir $+(",$b_,$nofile(%aa),") }
return }
}
if ($2) { var %fga = $sockname
:n | sockread &a | bwrite $+(",$b_ ,$2-,") -1 -1 &a
if ($sock(%fga).rcvd) && ($window(@theme.sget).title) { drawprog sget $sock(%fga).rcvd $window(@theme.sget).title | drawperc sget $perc($sock(%fga).rcvd,$window(@theme.sget).title) }
if ($file($b_ $+ $2-).size = $1) sockmark $sockname OK
if ($sockbr != 0) goto n
}
}
}
on *:text:*who has themes server*:#: .ctcp $nick THEMESERV I HAVE IT
menu channel {
-
Themes server: themelist #
}
menu nicklist {
-
Themes list: themelist $$1
}