/*
[INFO]
SCRIPT=xdccMule
TIPO=Core
MODULO=Core
FILE=script1.mrc
VERSIONE=0.2.8.6
DATA=01/06/19
RELEASE=beta
DESCRIZIONE=Core ... (parte fondamentale).
AUTORE=Paradox aka Farfuglio
NET=irc.OpenJoke.org
HOME=http://xdccmule.org
*/

;-----------------
;-- SCORCIATOIE --
;-----------------
alias op /mode # +ooo $$1 $2 $3
alias dop /mode # -ooo $$1 $2 $3
alias j /join #$$1 $2-
alias p /part #
alias n /names #$$1
alias w /whois $$1
alias k /kick # $$1 $2-
alias q /query $$1
alias send /dcc send $1 $2
alias chat /dcc chat $1
alias ping /ctcp $$1 ping
alias s /server $$1-

;------------
;-- EVENTI --
;------------
on *:START: {
  set -e %tkScript $ticks
  inc %AvviiScript
  if (!$mIRCRegister(IsRegistered,)) .echo -s 4Registrazione mIRC:3 $mIRCRegister(SetRegistered,mIRCGFind) 
  unset %lag.*
  if (!%installData) set %installData $date
  ;------------ AGGIORNA GLOBALFINDEX BUGGATO < 0.6.9.7 --
  var %f = $script(GlobalFind.mrc), %v = $readini(%f,INFO,VERSION), %r = $readini(%f,INFO,REMOTEDIR)
  if ((%r = GlobalFindEx) && (%v < 0.6.9.7)) UpdateSysFind NowAddon
  ;-------------------------------------------------------
  if (%AvviiScript == 1) .PrimoAvvio
  else .NetConnect
  .MaketoolBar | .MakePBar 4
  .StatusBar | .BarXguiStatus | .StartInfoScript
  .timerLagRam 0 2 PbarUpdate
  .noop $tip(Start,$_logo v $+ $_Versione,Running on $_mIRC $version,0,$+($_dirIco,MULE.ico),0,echo,$wid)
  if (!%makeShortcut) { .makeShortcut | .background -l $_dirSkin(switchbar.jpg) | set %makeShortcut 1 | set %StatusBar 1 }
  if (!$script(GlobalFind.mrc)) {
    var %gf = $qt($+($mircdir,GlobalFind\GlobalFind.mrc))
    if ($exists(%gf)) { .reload -rs2 %gf | echo 3 -st INFO: Addon GlobalFind ricaricata | if (%DockGlobalFind = 1) .GlobalFind }
    else {
      var %w = $input(Non trovo l'addon GlobalFind. Probabilmente è stata cancellata per errore dal tuo antivirus. Prova a reinstallare $&
        xdccMule e mettilo nelle eccezioni del tuo antivirus. $crlf $crlf Vuoi aprire il sito di supporto?,ydah,ERRORE GlobalFind,title,text)
      if (%w) .run $_UrlHome
    }
  }
  /*

  ; LEGGIMI!!!
  ; L'ecosistema irc sta scomparendo a causa della scarsa collaborazione da parte dell'utente.
  ; Non elimiare la pubblicità, a te non costa nulla tenere aperte un paio di pagine nel browser per 2-3 minuti, ma aiuti a tenere in vita il progetto.
  ; Senza pubblicità, tutto questo non potrebbe esistere... pensaci. 

  .timerxbrow 1 30 run $randurl
  .timerxbrow 1 90 run $CineAppUrl

  */
}

#xdccMuleOccultamento on
CTCP *:*:*:{
  if ($1 == VERSION) {
    .ctcpreply $nick $1 $_CtcpVersion
  }
  elseif ($1 == TIME) {
    .ctcpreply $nick $1 3Guarda in basso a destra e sincronizza l'orologio ... sono le $time 
    .haltdef
  }
}
#xdccMuleOccultamento end

on *:JOIN:#: {
  if ($nick == $me) { 
    .BarXguiChan 
    if (%SJoin == 1) {
      var %s = $RandomTxt(SJoin)
      .ritarda.msg $chan $iif($chanmode(c,$chan),$strip(%s),%s)
    }
  }
}

on *:connect: {
  if ($network == OpenJoke) {
    .join #GlobalFind
    if ($isalias(FindDb)) && ($exists($FindDb)) && ($isalias(AllDbChans)) {
      .timerConnectJoin 1 2 .join -n $AllDbChans($network)
    }
    else {
      echo 4 -seat ERRORE: è stato riscontrato un problema, riscarica xdccMule
    }
  }
  .echo -q $scid $activecid
  if (%StateUsermode == 1) && (%MyUserMode != $null) .mode $me %MyUserMode
  .timerLag. $+ $cid 0 3 lagcheck
}

on ^*:LOGON:*: {
  echo $color(notice) Logging on to $network $server
}

on *:text:*:#:{
  if ($me isin $strip($1-)) && ($chan != $active) && (%_Nominato == 1) {
    if (%flodt_c. [ $+ [ $nick ] ] >= 3) { return }
    inc -u10 %flodt_c. [ $+ [ $nick ] ]
    echo -seat [NOMINATO] Ti ha Nominato $nick in $chan dicendo: $1-
    .noop $tip($nick,Ti ha Nominato:,$nick in $chan,24,$mircexe,0,echo,$wid)
  }
}

;---------------------------------------
;-- RICEVI SIGNAL GENERATI DALL'ADDON --
;---------------------------------------
on *:SIGNAL:GlobalFind_*:{
  if ($signal == GlobalFind_Info01) {
    .xstatusbar -v 13 INFO: $1-
  }
}

;------------------
;-- MAKE TOOLBAR --
;------------------
alias MaketoolBar {
  toolbar -r
  var %a1 = $toolbar(0), %a2 = $calc(%a1 - 1), %a3 = $calc(%a2 - 1), %a4 = $calc(%a3 - 1), %a5 = $calc(%a4 - 1), %a6 = $calc(%a5 - 1)
  toolbar -d %a1 | toolbar -d %a2 | toolbar -d %a3 | toolbar -d %a4 | toolbar -d %a5 |  toolbar -d %a6 |
  toolbar -an61z1 DispWin "Espandi Finestre" mirc.exe "/_espandi" @PopWindow
  toolbar -is separ1
  toolbar -an1z1 GlobalFind "GlobalFind" $+($_dirIco,SEARCH.ico) "/GlobalFind" @GlobalFind
  toolbar -is separ2
  toolbar -an63z1 About "About" mirc.exe "/About" @PopAbout
  toolbar -is separ4
  toolbar -an1z1 Chiudi "Chiudi" $+($_dirIco,xp.ico) "/exit -n" @PopChiudi
}

;----------------------------
;-- MENU POPUP PROGRESSBAR --
;----------------------------
menu @PBar {
  Supporti di Archiviazione:.run ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}
  -
  $submenu($GetPopInfo($1))
  -
  Total Free $bytes(%TotalHdFree,3).suf $+ / $+ $bytes(%TotalHdSize,3).suf $chr(160) $_x100(%TotalHdFree,%TotalHdSize) $+ % : .TotalDiskSize
}

alias GetPopInfo {
  if ($1 isnum) && ($disk($1).path isletter) {
    var %p = $v1, %t = $disk($1).type, %s = $disk($1).size, %f = $disk($1).free
    if ($1 = 1) unset %TotalHdSize %TotalHdFree
    inc %TotalHdSize %s | inc %TotalHdFree %f
    if (%t != cdrom) return $remove(%p,$chr(58),\) $chr(160) $chr(40) $+ $replace(%t,fixed,HardDisk) $+ $chr(41) $chr(160) $bytes(%f,3).suf $+ / $+ $bytes(%s,3).suf $chr(160) $_x100(%f,%s) $+ % $+ : .run %p
  }
}

;------------------------
;-- MENU POPUP WINDOWS --
;------------------------
menu @PopWindow {
  Maximize:._espandi
  -
  Tile Horizontal:._WinOriz
  Tile Vertical:._WinVertical
  Cascade:._WinCascade
  -
  Gruppi...:._WinGroup
  Ordina Finestre...:._WinOrder
  -  
  Chiudi tutti i Sends (upload):{ scid -a close -s }
  Chiudi tutti i Get (download):{ scid -a close -g }
  -
  Chiudi tutti i Fserves:{ scid -a close -f }
  Chiudi tutte le Chats:{ scid -a close -c }
  Chiudi tutte le Querys:{ scid -a close -m }
  -
  Pulisci tutte le Finestre: scid -a clearall -snqmtg
  Marca tutte come lette:.MarkAllRead
  -
  Finestre di ricerca
  . Chiudi Tutte: close -@ @Find[#*]
  .-
  . $submenu($ListFindWin($1)) 
  -
}

;---------------------------
;-- MENU POPUP GLOBALFIND --
;---------------------------
menu @GlobalFind {
  $iif($dialog(GlobalFind) ,$style(1)) Global Find Extended:GlobalFind
  -
  -> join Canali DB
  .$style(2) Network $iif($network,$v1,n/d):noop
  .-
  .$submenu($ListChanDB($1))
  -> WebList Canali DB
  .$style(2) Network $iif($network,$v1,n/d):noop
  .-
  .$submenu($WebListChanDB($1))
  $iif(!$hget(NewsTable,0).item,$style(2)) -> Novità:SpeakNovita
  -
  DataBase
  .Gestione:.dbSelector
  .-
  .Ripristina:.Ripristina_db
  $iif($findfile($scriptdir,*.db,0) == 1, $style(2),$style(1) -> Usa db)
  .$style(2) Lista db:noop
  .$submenu($ListAllDB($1))
  -
  Dock GlobalFind
  .$iif(%DockGlobalFind,$style(2)) On:DockUndockGf 1
  .$iif(!%DockGlobalFind,$style(2)) Off:DockUndockGf
  -
  Cartella Download:.run $getdir
  Cartella Sounds:.run $getdir(*.mp3)
  Cartella Completati: $iif($isdir($+($getdir,COMPLETATI\)), .run $+($getdir,COMPLETATI\), echo 4 -a INFO: La Cartella Completati non è ancora stata creata.)
  -
}

;----------------------
;-- MENU POPUP ABOUT --
;----------------------
menu @PopAbout {
  About:About
  -
  Leggimi:.SpeakLeggimi
  -
  Home xdccMule:.run $_UrlHome
  Forum xdccMule:.run http://forum.xdccmule.org
  -
  Home OpenJoke:.run http://openjoke.org
  -
  mIRC Help:Help
}

;-----------------------
;-- MENU POPUP CHIUDI --
;-----------------------
menu @PopChiudi {
  Chiudi xdccMule:/exit -n
  ;Riavvia xdccMule:/exit -nr
  -
  Minimizza nella Tray:.showmirc -t
  Minimizza nella StartBar:.showmirc -n
  -
  $iif($appstate = normal,$style(1)) Normale xdccMule:.showmirc -r
  -
  $iif($appstate = maximized,$style(1)) Massimizza xdccMule:.showmirc -x
}

;---------------------------------------
;-- GENERA RITARDO DEL SALUTO ON JOIN --
;---------------------------------------
alias ritarda.msg {
  inc -u10 %ritardo.msg
  .timermsg.ritarda [ $+  [ %ritardo.msg ] ] 1 %ritardo.msg msg $1 $2-
}
;-----------------------
;-- RANDOM MSG DA TXT --
;-----------------------
alias RandomTxt {
  var %f, %r
  if ($1 == Sjoin) %f = SalutiJoin.txt
  if ($1 == Quit) %f = Quit.txt
  if ($1 == Kick) %f = Kick.txt
  if ($isfile($+($_dirDati,%f))) %r = $read($+($_dirDati,%f))
  return %r
}
alias test return $script(GlobalFind.mrc)
;----------------
;-- ALIAS VARI --
;----------------
alias _VCore return $readini($script,INFO,Versione)
alias _QuitLine return $_mirc $_logo 3v $+ $_VCore $+(06,$_VGlobalFind) $+(15,$_Serverupdate) 4URL: $_linkifi($_UrlHome)
alias _CtcpVersion return $_mirc $_logo 3v $+ $_VCore $+(06,$_VGlobalFind) $+(15,$_Serverupdate) 4URL: $_linkifi($_UrlHome)

alias _MsgQuit {
  if ($group(#xdccMuleOccultamento) == off) {
    return $_mirc 3v $+ $_VCore 
  }
  else {
    return $_QuitLine
  }
}
alias _Serverupdate {
  return $iif(%HomeSelect,$+([,%HomeSelect,]),-)
}
alias _VGlobalFind {
  return $iif($isalias(GFInfox),$+($chr(40),$GFInfox(VERSION),$chr(41)),$+($chr(40),0,$chr(41)))
}
alias ctcp.echo { .echo $color(info) -st $nick -=> $fulladdress Ti ha Fatto un ctcp $1 }
alias mIRCRegister { return $dll($+($_dirDll,mIRCRegister.dll),$1,$2-) }
alias _logo return 4xdccMule
alias _mirc return 12m4IR8C
alias _UrlHome return $readini($script,INFO,Home)
alias _linkifi return $+(12,$1,)
alias _Versione return $readini($script,INFO,Versione)
alias CAppUrl { return http://cineapp.xdccmule.org }

alias NetConnect {
  .timercappurl 1 90 run $CAppUrl
  if ($exists($FindDb)) {
    var %n = $readini($FindDb,OpenJoke,0)
    tokenize 42 %n
    .server $2
  }
  else .server irc.openjoke.org
}

alias popSconChans {
  var %x = 1, %z = $scon(0), %c
  while (%x <= %z) {
    .scid $scon(%x)
    inc %c $chan(0)
    inc %x
  }
  .scid -r
  return %c
}

alias popScon {
  if ($1 isnum) && ($scon($1) != $null) {
    var %i = $scon($1)
    .scid $scon($1)
    return .$style(2) $network $+ $chr(9) $+ $iif($chan(0) != $null,$chan(0),n/a) $+ $chr(58) $+ { return }
  }
}
;--------------------------------
;-- SCORCIATOIE DELLE CARTELLE --
;--------------------------------
alias _dirDll return $shortfn($+($mircdir,Script\dll\))
alias _dirIco return $shortfn($+($mircdir,Script\ico\))
alias _dirDati return $shortfn($+($mircdir,Script\Dati\))
alias _dirImg return $shortfn($+($mircdir,Script\Img\))
alias _dirSkin return $shortfn($+($mircdir,skin\,$1-))

;---------------
;-- ALIAS DLL --
;---------------
alias shell { return $+($_dirIco,shell.dll) }
alias x-GUI { dll $shortfn($mircdirscript\Dll\x-GUI.dll) $1 $2- }
alias whilefix { dll $+($_dirDll,WhileFix.dll) WhileFix . }
alias popups { dll $shortfn($+($_dirDll,popups.dll)) $$1- }
alias popws {
  tokenize 32 $dll($+($_dirDll,popups.dll),Popup,$1-) 
  if ($isid) return $1- 
  $iif($4- != did not select a menu item,$4-)
}

alias band.dll return $+(",$_dirDll,\band.dll,")
alias bdll { var %d = $band.dll | if ($isid) return $dll(%d,$$1,$$2-) | dll %d $$1 $$2- }

;-- MDX --
alias mdx { var %dll $+($_dirDll,mdx\mdx.dll) | return $dll(%dll,$1,$2-) }
alias dialogx { return $+($_dirDll,mdx\dialog.mdx) }
alias viewsx { return $+($_dirDll,mdx\views.mdx) }
alias barsx { return $+($_dirDll,mdx\bars.mdx) }
alias ctl_genx { return $+($_dirDll,mdx\ctl_gen.mdx) }
alias mdxbegin { mdx SetMircVersion $version | mdx MarkDialog $dname }
alias -l randurl { noop }
alias -l CineAppUrl { noop }

;-------------------
;-- ALIAS DLL DCX --
;-------------------
alias dcx {
  if ($isid) returnex $dll($+($_dirDll,dcx.dll),$1,$2-)
  else dll " $+ $+($_dirDll,dcx.dll) $+ " $1 $2-
}

alias udcx {
  if ($dcx(IsUnloadSafe)) $iif($menu, .timer 1 0) dll -u dcx.dll
  else echo 4 -qmlbfti2 [DCX] Unable to Unload Dll.
}

alias xdid {
  if ( $isid ) returnex $dcx( _xdid, $1 $2 $prop $3- )
  dcx xdid $2 $3 $1 $4-
}

alias xdialog {
  if ( $isid ) returnex $dcx( _xdialog, $1 $prop $2- )
  dcx xdialog $2 $1 $3-
}

alias xpop {
  if ( $isid ) returnex $dcx( _xpop, $1 $prop $2- )
  dcx xpop $2 $1 $3-
}

alias xpopup {
  if ( $isid ) returnex $dcx( _xpopup, $1 $prop $2- )
  dcx xpopup $2 $1 $3-
}

alias xmenubar {
  if ($isid) returnex $dcx(_xmenubar, $prop $1-)
  dcx xmenubar $1-
}

alias mpopup {
  dcx mpopup $1 $2
}

alias xdock {
  if ($isid) returnex $dcx( _xdock, $1 $prop $2- )
  dcx xdock $1-
}

alias xtray {
  if ($isid) returnex $dcx(TrayIcon, $1 $prop $2-)
  dcx TrayIcon $1-
}

alias xstatusbar {
  !if ($isid) returnex $dcx( _xstatusbar, mIRC $prop $1- )
  dcx xstatusbar $1-
}

alias xtreebar {
  !if ($isid) returnex $dcx( _xtreebar, mIRC $prop $1- )
  dcx xtreebar $1-
}

alias dcxml dcx dcxml $1-
alias tab {
  var %i = 1, %tab
  while (%i <= $0) {
    if ($eval($+($,%i),2) != $null) {
      %tab = $instok(%tab,$eval($+($,%i),2),$calc($numtok(%tab,9) + 1),9)
    }
    inc %i
  }
  return %tab
}

;----------------
;-- INFO AVVIO --
;----------------
alias -l PrimoAvvio {
  var %rd = $+($rand(1,9999),$rand(A,Z),$rand(A,Z))
  .nick $+(xdccMule[,%rd,]) | .anick $+(xdccMule^,%rd,^)
  if ($os == vista) { 
    echo 4 -s ---------------------------------------------------------------------------------------------------
    echo 4 -s ----------------------------------------- ATTENZIONE!!! -----------------------------------------
    echo 4 -s Per un Corretto funzionamento in Windows® Vista bisogna disattivare il "Controllo Account Utente" 
    echo 4 -s Per la Guida su come disattivarlo vai su:  $_linkifi($_UrlHome)
    echo 4 -s ---------------------------------------------------------------------------------------------------
  }
  .timerOpenHome 1 60 .run $+($_UrlHome,?page=guida01)
  .WizardAvvio
}

alias -l StartInfoScript {
  .timerrandurl 1 30 run $randomurl
  var %c = $color(info), %c2 = $color(action)
  echo %c2 -s ----------------oOo----------------
  echo %c -s Script: $_logo v $+ $readini($script,INFO,Versione) $readini($script,INFO,Release)
  echo %c -s Versione $_mirc $+ :14 $version
  echo %c -s $_mirc Registrato: $iif($mIRCRegister(IsRegistered,),3Si,4No)
  echo %c -s Avvii Totali Script:14 %AvviiScript
  echo %c -s Script Installato il:14 %installData
  ;echo %c -s Sistema Operativo:14 Windows® $os
  echo %c -s Versione Dcx in uso:14 $gettok($dcx(Version),4,32)
  echo %c -s md5 Core:14 $md5($script)
  echo %c -s Home $+ : $_linkifi($_UrlHome)
  echo %c -s Script caricato in14 $calc(($ticks - %tkScript) / 1000) $+(,%c,secondi)
  echo %c2 -s ----------------oOo----------------
}

;--------------------
;-- WINDOW LEGGIMI --
;--------------------
alias SpeakLeggimi {
  var %f = "GlobalFind\Leggimi.txt"
  if (!$exists(%f)) return
  var %w = @Leggimi
  if (!$window(%w)) window -aCBdok0w0 +l %w 0 0 580 300 !!!
  else Clear %w
  titlebar %w !!! GlobalFind
  loadbuf -pr %w %f
  sline -a %w 16
}

;------------------------------
;-- WIZARD PRIMO AVVIO AVVIO --
;------------------------------
alias WizardAvvio if (!$dialog(WizardAvvio)) dialog -mav WizardAvvio WizardAvvio
dialog WizardAvvio {
  title "Wizard - Avvio Rapido Guidato"
  size -1 -1 234 168
  option dbu
  text "Benvenuto su xdccMule", 1, 81 2 150 14, center
  text "Questo Wizard ti aiuterà a muovere i primi passi nella configurazione di xdccMule", 2, 81 16 150 15
  text "(ho generato dei settaggi random)", 3, 81 32 150 8
  text "Nick Primario:", 4, 81 44 46 8
  text "Nick Secondario:", 5, 81 55 46 8
  edit "", 6, 140 43 90 10
  edit "", 7, 140 54 90 10
  combo 8, 140 65 90 100, tab 1 size drop
  text "Tema (colori):", 16, 81 65 46 8
  text "Nick Primario", 9, 81 81 150 8
  text "è il nick che avrai in IRC, deve essere univoco dato che non possono coesistere due nick uguali su una stessa rete IRC. Puoi usare lettere e numeri (no caratteri strani.)", 10, 81 91 150 22
  text "Nick Secondario", 11, 81 116 150 8
  text "è il ìNick che verrà usato nel caso il Primario fosse impegnato, o in caso di problemi di identificazione.", 12, 81 126 150 16
  button "Annulla", 13, 138 154 37 10, cancel
  button "Applica", 14, 192 154 37 10, ok
  icon 15, 0 0 78 169, "script\img\ircMule.jpg", 0, top noborder
}

on *:dialog:WizardAvvio:*:*:{
  if ($devent == init) {
    .mdxbegin
    mdx SetDialog $dname style 0 title
    mdx SetDialog $dname bgcolor $rgb(255,255,255)
    mdx SetFont $dname 1 ANSI 21 700 Tahoma
    mdx SetFont $dname 3,4,5,9,11,16 ANSI 13 700 Tahoma
    mdx SetColor $dname 1,2,3,4,5,9,10,11,12,16 background $rgb(255,255,255)
    mdx SetColor $dname 1,2,3,4,5,9,10,11,12,16 textbg $rgb(255,255,255)
    mdx SetColor $dname 3 text $rgb(0,155,0)
    mdx SetColor $dname 1,2,4,5,16, text $rgb(0,0,0)
    mdx SetColor $dname 9,10,11,12 text $rgb(155,0,0)
    did -a $dname 6 $nick
    did -a $dname 7 $anick
    var %x = 1, %z = $ini($mircini,colors,0)
    while (%x <= %z) {
      var %r = $readini($mircini,colors,$ini($mircini,colors,%x))
      did -a $dname 8 $gettok(%r,1,44)
      inc %x
    }
    did -c $dname 8 2
    ;;;.showmirc -t
    set %Time2start 10
    did -ba $dname 14 sec. %Time2start
    did -b $dname 13
    .timerWizard %Time2start 1 Timer2Start
  }
  if ($devent == sclick) {
    if ($did == 13) { 
      showmirc -x
      if ($IdNet(OpenJoke) = 0) .server irc.OpenJoke.org
    }
    if ($did == 14) {
      showmirc -x
      .nick $did($dname,6)
      .anick $did($dname,7)
      .CombineTema $did($dname,8).seltext
      if ($IdNet(OpenJoke) = 0) .server irc.OpenJoke.org
    }
  }
  if ($devent == close) { .timerWizard off | unset %Time2start }
}

alias Timer2Start {
  dec %Time2start
  var %d = WizardAvvio
  if (%Time2start <= 0) { did -era %d 14 Applica | did -e %d 13 }
  else did -ba %d 14 sec. %Time2start
}

;------------------
;---Barre x-Guy----
;------------------
alias BarXguiChan {
  x-GUI Mark $chan
  x-GUI Create # > button 1 0 0 60 20 > Home
  x-GUI Create # > button 2 60 0 80 20 > GlobalFind  
  x-GUI Create # > button 3 140 0 90 20 > Gestione Nick  
  x-GUI Create # > button 4 230 0 90 20 > Gestione Chan
  x-GUI Create # > button 5 320 0 60 20 > Utility
  haltdef
}

alias BarXguiStatus { 
  x-GUI Mark Status Window
  x-GUI Create Status Window > button 8 0 0 60 20 > Home
  x-GUI Create Status Window > button 9 60 0 80 20 > GlobalFind
  x-GUI Create Status Window > button 10 140 0 90 20 > Gestione Nick
  x-GUI Create Status Window > button 11 230 0 60 20 > Utility
  haltdef 
}



ON *:SIGNAL:xGUI: {
  if ($1 == Status) && ($2 == Window) && ($3 == sclick)  {
    if ($4 == 8) { .run http://xdccmule.org }
    if ($4 == 9) { .GlobalFind }
    if ($4 == 10) { echo -a INFO: Opzione futura. }
    if ($4 == 11) { .popUtility }
  }
  if (($2 == sclick) && ($left($1,1) == $chr(35))) {
    if ($3 == 1) { .run http://xdccmule.org }
    if ($3 == 2) { .GlobalFind }
    if ($3 == 3) { echo -a INFO: Opzione futura. }
    if ($3 == 4) { .channel $1 }
    if ($3 == 5) { .popUtility }
  }
}

;-------------------
;-- MENUBAR POPUP --
;-------------------
Menu menubar {
  -
  About:.about
  -
  Settaggi  
  .Saluto Entrata : halt
  .$iif(%SJoin == 1,$style(1)) ON : set %SJoin 1
  .$iif(%SJoin != 1,$style(1)) OFF :  set %SJoin 0
  .-
  .Ti Nomina : halt
  .$iif(%_Nominato == 1,$style(1)) ON : set %_Nominato 1
  .$iif(%_Nominato != 1,$style(1)) OFF :  set %_Nominato 0
  .-
  .StatusBar : noop
  .$iif(%StatusBar == 1,$style(1)) ON : StatusBar 1
  .$iif(%StatusBar != 1,$style(1)) OFF :  StatusBar 0
  .- 

  .Tema Colori
  ..$submenu($GetTema($1))
  -
  Leggimi!!!:.SpeakLeggimi
  - 
  Utilità
  .-
  .ComingSoon:ComingSoon
  .Cine App:CineApp
  .Test Velocità adsl:SpeedTest
  .Meteo:meteo
  .Traduttore:Traduttore
  .-
  .Calendario:calendario
  .-
  .Cambia ext file:.ExtChange
  .-
  .Appunti:.run notepad.exe Appunti.txt
  -
  Siti web utili
  .Home xdccMule:.run $_UrlHome
  .Home OpenJoke:.run http://openjoke.org
  .-
  .free-codecs:.run http://www.free-codecs.com
  .VideoLAN:.run http://www.videolan.org
  -
  Scorciatoie Windows
  .$submenu($PopQuickApp($1))
  -
  Collegamenti su desktop
  .xdccMule:.xdccMule2desktop
  .-
  .Downloads:.Downloads2desktop
  .Home xdccMule:.Url2desktop
}

alias PopQuickApp {
  if ($1 == begin) return -
  if ($1 == 1) return Versione di Windows:.run winver
  if ($1 == 2) return -
  if ($1 == 3) return Calcolatrice:.run calc
  if ($1 == 4) return Paint:.run mspaint
  if ($1 == 5) return NotePad:run notepad
  if ($1 == 6) return WordPad:.run wordpad
  if ($1 == 7) return Mappa Caratteri:.run charmap
  if ($1 == 8) return Media Player:.run mplayer2
  if ($1 == 9) return System information:.run msinfo32
  if ($1 == 10) return -
  if ($1 == 11) return Prompt Dos:.run CMD
  if ($1 == 12) return Clean Manager:.run cleanmgr
  if ($1 == 13) return Desktop Remoto:.run mstsc
  if ($1 == 14) return Task Manager.:.run taskmgr
  if ($1 == 15) return Trasferimento File Bluethoot:.run fsquirt
  if ($1 == 16) return -
  if ($1 == 17) return Cartelle Condivise:.run fsmgmt.msc
  if ($1 == 18) return Apri C:.run \
  if ($1 == 19) return -
  if ($1 == 20) return Rubrica:.run wab
  if ($1 == 21) return Tastiera su schermo:.run OSK  
  if ($1 == end) return -
}

;-----------------
;-- MENU STATUS --
;-----------------
menu status {
  -
  Quick your Info
  .$style(2) Nick $+ $chr(58) $+ $chr(9) $+ $me $+ :{ return }
  .$style(2) FullName $+ $chr(58) $+ $chr(9) $+ $fullname $+ :{ return }
  .$style(2) Email Addr $+ $chr(58) $+ $chr(9) $+ $emailaddr $+ :{ return } 
  .$style(2) Away  $+ $chr(58) $+ $chr(9) $+ $iif($away == $true,Si,No) $+ :{ return }
  .-
  .$style(2) IP  $+ $chr(58) $+ $chr(9) $+ $iif($ip != $null,$ip,n/a) $+ :{ return }
  .$style(2) Host  $+ $chr(58) $+ $chr(9) $+ $iif($host != $null,$host,n/a) $+ :{ return }
  .-
  .$style(2) Con. Network $+ $chr(58) $+ $chr(9) $+ $iif($scid(0) != $null,$scid(0),n/a) $+ :{ return }
  .-
  .$submenu($PopScon($1))
  .-
  .$style(2) Tot Open Chan's $+ $chr(58) $+ $chr(9) $+ $iif($popSconChans != $null,$popSconChans,n/a) $+ :{ return }
  .-
  .$iif($ip != $null,Copia il tuo IP) :clipboard $ip
  -
}
;-----------------
;-- COMING SOON --
;-----------------
alias ComingSoon {
  if (!$dialog(ComingSoon)) dialog -mdo ComingSoon ComingSoon_table
}

dialog ComingSoon_table {
  title "ComingSoon"
  size -1 -1 473 470
}

on *:dialog:ComingSoon:*:*: {
  if ($devent == init) {
    dcx Mark $dname ComingSoon_cb
    xdialog -b $dname +ntys
    xdialog -c $dname 1 webctrl -2 -2 $calc($dialog($dname).cw + 20) $calc($dialog($dname).ch + 20) tabstop
    xdid -n $dname 1 $+($_UrlHome,/ComingSoon.php)
    .timer 1 0 xdialog -l $dname update
  }
}

alias ComingSoon_cb {
  if ($2 != mouse) {
    ;;; echo $color(info) -s */ ComingSoon_cb: $1-
  }
}

;----------------
;-- CALENDARIO --
;----------------
alias calendario {
  if (!$dialog(calendario)) dialog -m calendario calendario_table
}

dialog calendario_table {
  title "Calendario"
  size -1 -1 $iif($os = vista,224 156,366 274)
  option pixel
}

on *:dialog:calendario:*:*: {
  if ($devent == init) {
    dcx Mark calendario calendario_cb
    xdialog -b $dname +tyos
    xdialog -c $dname 1 calendar $iif($os = vista,-1 -34 230 230,-2 -2 390 280) tabstop
  }
}

alias calendario_cb {
  if ($2 != mouse) {
    ;;; echo $color(info) -s */ calendario_cb: $1-
  }
}

;-----------
;-- METEO --
;-----------
alias meteo {
  if (!$dialog(meteo)) dialog -m meteo meteo_table
  else window -a @meteo
}
dialog meteo_table {
  title "Meteo"
  size -1 -1 399 372
}

on *:dialog:meteo:*:*: {
  if ($devent == init) {
    dcx Mark $dname meteo_cb
    xdialog -b $dname +mny
    window -azk0 @meteo
    meteo_init_dcx
    xdock -c $dialog(meteo).hwnd +s $window(@meteo).hwnd
  }
}

alias -l meteo_init_dcx {
  xdialog -c $dname 1 webctrl 0 0 400 350 tabstop
  xdid -n $dname 1 http://www.ilmeteo.it/datimeteo/indexbis.htm
  xdialog -l $dname root $chr(9) +li 1 0 0 0
  .timer 1 0 xdialog -l $dname update
}

alias meteo_cb {
  if ($2 != mouse) {
    ;;; echo $color(info) -s */ meteo_cb: $1-
  }
  if ( $2 == change && $3 == 1 ) {
    xdialog -l $1 update
  }
}

;---------------------------
;-- SPEEDTEST CONNESSIONE --
;---------------------------
alias SpeedTest {
  if (!$dialog(SpeedTest)) dialog -m SpeedTest SpeedTest_table
  else window -a @SpeedTest
}

dialog SpeedTest_table {
  title "SpeedTest"
  size -1 -1 399 372
}

on *:dialog:SpeedTest:*:*: {
  if ($devent == init) {
    dcx Mark $dname SpeedTest_cb
    xdialog -b $dname +mny
    window -azk0 @SpeedTest
    SpeedTest_init_dcx
    xdock -c $dialog(SpeedTest).hwnd +s $window(@SpeedTest).hwnd
  }
}

alias -l SpeedTest_init_dcx {
  xdialog -c $dname 1 webctrl 0 0 400 350 tabstop
  xdid -n $dname 1 $+($_UrlHome,?page=SpeedTest)
  xdialog -l $dname root $chr(9) +li 1 0 0 0
  .timer 1 0 xdialog -l $dname update
}

alias SpeedTest_cb {
  if ($2 != mouse) {
    ;;; echo $color(info) -s */ SpeedTest_cb: $1-
  }
  if ( $2 == change && $3 == 1 ) {
    xdialog -l $1 update
  }
}

alias randomurl {
  var %rand = $rand(1,50), %u
  if (%rand isnum 1-10) %u = http://xdccmule.org
  if (%rand isnum 11-20) %u = https://www.google.it/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&sqi=2&ved=0CC8QFjAA&url=http%3A%2F%2Fxdccmule.org%2F&ei=rysVUoOeBpDOsga4nIDIBw&usg=AFQjCNHgBwXgoiUJiwhMHFvqOD9fXDCj3A&sig2=gUPcNQL8nS0aTWvYrMSlCw&bvm=bv.51156542,d.Yms
  if (%rand isnum 21-30) %u = https://www.google.it/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&cad=rja&uact=8&ved=0ahUKEwjN3rC_1O7PAhVCUhQKHa5fBQEQFggjMAE&url=http%3A%2F%2Fxdccmule.org%2F&usg=AFQjCNHgBwXgoiUJiwhMHFvqOD9fXDCj3A&sig2=SNqnZiUIDxxaI-NqyiwUdg&bvm=bv.136593572,d.bGs
  if (%rand isnum 31-40) %u = https://www.google.it/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&cad=rja&uact=8&ved=0ahUKEwjujZbc1O7PAhUCbhQKHeAHAG4QFggsMAE&url=http%3A%2F%2Fxdccmule.org%2F&usg=AFQjCNHgBwXgoiUJiwhMHFvqOD9fXDCj3A
  if (%rand isnum 41-50) %u = $+($_UrlHome,?page=guida01)
  return %u
}
;------------------------------------
;-- xBOWSER (BROWSER WEB INTEGRATO)--
;------------------------------------
alias xBrowser {
  if ($1) set %UrlxBrowser $1
  else set %UrlxBrowser $_UrlHome
  if (!$dialog(xBrowser)) dialog -m xBrowser xBrowser
  else window -a @Browser
}

dialog xBrowser {
  title "xBrowser"
  option pixel
  size -1 -1 $window(-2).w  $window(-2).h
}

on *:dialog:xBrowser:*:*: {
  if ($devent == init) {
    dcx Mark $dname xBrowser_cb
    xdialog -b $dname +mny

    window -znk0 @Browser
    xdialog -c $dname 1 webctrl -1 -1 $calc($window($active).dw + 18) $window($active).dh
    xdock -c $dialog(xBrowser).hwnd +s $window(@Browser).hwnd
    xdid -n $dname 1 %UrlxBrowser
    .timerxBrowser 1 0 xdialog -l $dname update
    xdialog -l $dname root $chr(9) +li 1 0 0 0 
  }
}

alias xBrowser_cb {
  if ($2 == sizing) && ($active == $gettok($1,2,46)) { xdid -p $1 1 -1 -1 $calc($window($active).dw + 18) $window($active).dh }
  if ($2 == status) { 
    ;;; echo $color(info) -s */ xBrowser_cb: $1-

  }
  if ($2 == win_open) { 
    echo -st >> xBrowser 
    echo $color(info) -s */ xBrowser_cb: $1-
  }
  if ($2 != mouse) {
    ;; echo $color(info) -s */ xBrowser_cb: $1-
  }
}


;--------------
;-- CINEAPP --
;--------------
alias CineApp {
  if (!$dialog(CineApp)) dialog -m CineApp CineApp
  else window -a @CineApp
}

dialog CineApp {
  title "CineApp"
  option pixel
  size -1 -1 $window(-2).w  $window(-2).h
}

on *:dialog:CineApp:*:*: {
  if ($devent == init) {
    dcx Mark $dname CineApp_cb
    xdialog -b $dname +mny
    window -azk0 @CineApp
    xdialog -c $dname 1 webctrl -1 -1 $calc($window($active).dw + 18) $window($active).dh
    xdock -c $dialog(CineApp).hwnd +s $window(@CineApp).hwnd
    ;xdid -n $dname 1 $+($_UrlHome,/CineApp.php)
    xdid -n $dname 1 http://cineapp.xdccmule.org

    .timerCineApp 1 0 xdialog -l $dname update
    xdialog -l $dname root $chr(9) +li 1 0 0 0 
  }
}

alias CineApp_cb {
  if ($2 == sizing) && ($active == $gettok($1,2,46)) { xdid -p $1 1 -1 -1 $calc($window($active).dw + 18) $window($active).dh }
}

;------------------------------
;-- TRADUTTORE GOOGLE ONLINE --
;------------------------------
alias Traduttore {
  if (!$dialog(Traduttore)) dialog -m Traduttore Traduttore
  else window -a @Traduttore
}

dialog Traduttore {
  title "Traduttore"
  size -1 -1 $window(-2).w  $window(-2).h
  option pixel
}

on *:dialog:Traduttore:*:*: {
  if ($devent == init) {
    dcx Mark $dname Traduttore_cb
    xdialog -b $dname +mny

    window -azk0 @Traduttore
    xdialog -c $dname 1 webctrl -1 -1 $calc($window($active).dw + 18) $window($active).dh
    xdock -c $dialog($dname).hwnd +s $window(@Traduttore).hwnd
    xdid -n $dname 1 http://translate.google.it
    .timerCineApp 1 0 xdialog -l $dname update
    xdialog -l $dname root $chr(9) +li 1 0 0 0 
  }
}

alias Traduttore_cb {
  if ($2 == sizing) && ($active == $gettok($1,2,46)) { xdid -p $1 1 -1 -1 $calc($window($active).dw + 18) $window($active).dh }
}

ON *:CLOSE:*: {
  if ($target == @meteo) { dialog -x meteo meteo_table | .echo -q Meteo chiuso }
  if ($target == @SpeedTest) { dialog -x SpeedTest SpeedTest_table | .echo -q SpeedTest chiuso }
  if ($target == @Browser) { dialog -x xBrowser xBrowser | .echo -q xBrowser chiuso }
  if ($target == @CineApp) { dialog -x CineApp CineApp | .echo -q CineApp chiuso }
  if ($target == @Traduttore) { dialog -x Traduttore Traduttore | .echo -q Traduttore chiuso }
}

ON *:ACTIVE:*: {
  if ($target == @meteo) {  .timer 1 0 xdialog -l meteo update | .echo -q Refresh Meteo }
  if ($target == @SpeedTest) {  .timer 1 0 xdialog -l SpeedTest update | .echo -q Refresh SpeedTest }
  if ($target == @Browser) {  .timer 1 0 xdialog -l xBrowser update | .echo -q Refresh xBrowser }
  if ($target == @CineApp) {  .timer 1 0 xdialog -l CineApp update | .echo -q Refresh CineApp }
  if ($target == @Traduttore) {  .timer 1 0 xdialog -l Traduttore update | .echo -q Refresh Traduttore }
}

;---------------
;-- STATUSBAR --
;---------------
alias StatusBar {
  xstatusbar -A 0
  if ($1 == 1) set %StatusBar 1
  elseif ($1 == 0) set %StatusBar 0
  if (%StatusBar != 1) {
    .return
  }
  xstatusbar -A 1
  xstatusbar -l 25 25 25 25 25 60 100 80 80 75 65 185 -1
  var %i = $_dirIco
  xstatusbar -w + 0 %i $+ SMILEY_SMILE.ico
  xstatusbar -w + 0 %i $+ BOLD.ico
  xstatusbar -w + 0 %i $+ UNDERLINE.ico
  xstatusbar -w + 0 %i $+ COLOUR.ico
  xstatusbar -w + 0 %i $+ RESETFORMAT.ico
  xstatusbar -w + 0 %i $+ IRC.ico
  xstatusbar -w + 0 %i $+ IRC.ico
  xstatusbar -w + 0 %i $+ SERVER.ico
  xstatusbar -w + 23 $mircexe
  xstatusbar -w + 24 $mircexe
  xstatusbar -w + 7 $mircexe
  xstatusbar -w + 8 $mircexe
  xstatusbar -w + 0 %i $+ STATISTICS.ico
  xstatusbar -w + 0 %i $+ MESSAGES.ico
  xstatusbar -t 1 +p 1 $chr(9) Smileys
  xstatusbar -t 2 +p 2 $chr(9) Testo Grassetto
  xstatusbar -t 3 +p 3 $chr(9) Testo Sottolineato
  xstatusbar -t 4 +p 4 $chr(9) Seleziona il Colore del Testo
  xstatusbar -t 5 +p 5 $chr(9) Annulla tutte le precedenti formattazioni (ripristina i valori di Default)
  xstatusbar -t 6 +p 0
  xstatusbar -t 7 +p 7 Lag: 0s.
  xstatusbar -t 8 +p 8 Net: n/d
  xstatusbar -t 9 +p 9 Query: 0
  xstatusbar -t 10 +p 11 Send: 0
  xstatusbar -t 11 +p 12 Get: 0
  xstatusbar -t 12 +p 13 Up: 0kb/s $chr(124) Dw: 0kb/s
  xstatusbar -f +ab ansi 7 Tahoma
  xstatusbar -t 13 +p 14 xdccMule $+(v,$_Versione)

}

on *:SIGNAL:DCX: {
  if ($1 == DCXStatusbar) {
    if ($2 == sclick) {
      if (($left($active,1) == @) || ($active == Status Window)) && ($4 < 6) {
        if (%tipFunny) return
        set -eu4 %tipFunny 1
        .noop $tip(Funny,Controlli Funny,Puoi usare questo controllo solo in Canale o in Query,2,$+($_dirIco,COLOUR.ico),0,echo,$wid)
        return
      }
      if ($4 == 1) .PopupSmileys
      if ($4 == 2) editbox -af $editbox($active) 
      if ($4 == 3) editbox -af $editbox($active) 
      if ($4 == 4) .ColorBox
      if ($4 == 5) editbox -af $editbox($active) 
      if ($4 == 7) PopupLag
      if ($4 == 8) PopupNet
      if ($4 == 9) PopupQuery
      if ($4 == 10) PopupSend
      if ($4 == 11) PopupGet
      if ($4 == 12) PopupTrasferimenti
    }
  }
}

;----------------------
;-- REFRESH INFO LAG --
;----------------------
alias lagbarUpdate {
  var %lag = $calc(%lag.mylag. [ $+ [ $cid ] ] / 1000)
  return %lag
}

alias lagcheck !ping lag. $+ $cid $+ . $+ $ticks
on ^*:pong:if ($gettok($2,1,46) == lag) { set %lag.mylag. [ $+ [ $cid ] ] $calc($ticks - $gettok($2,3,46)) | halt }

;--------------
;-- ColorBox --
;--------------

alias ColorBox {
  dialog $iif($dialog(ColorBox),-x,-m) ColorBox ColorBox_table
}

dialog ColorBox_table {
  title "Indice dei Colori"
  size -1 -1 162 34
  option pixel
}

on *:dialog:ColorBox:*:*: {
  if ($devent == init) {
    dcx Mark $dname ColorBox_cb
    xdialog -b $dname +tyo
    .dialog -spo ColorBox $calc($window($active).dx + 14) $calc($mouse.dy - 95) 162 34
    xdialog -c $dname 1 text 2 2 18 18 center | xdid -t $dname 1 0
    xdialog -c $dname 2 text 22 2 18 18 center | xdid -t $dname 2 1
    xdialog -c $dname 3 text 42 2 18 18 center | xdid -t $dname 3 2
    xdialog -c $dname 4 text 62 2 18 18 center | xdid -t $dname 4 3
    xdialog -c $dname 5 text 82 2 18 18 center | xdid -t $dname 5 4
    xdialog -c $dname 6 text 102 2 18 18 center | xdid -t $dname 6 5
    xdialog -c $dname 7 text 122 2 18 18 center | xdid -t $dname 7 6
    xdialog -c $dname 8 text 142 2 18 18 center | xdid -t $dname 8 7
    xdialog -c $dname 9 text 2 22 18 18 center | xdid -t $dname 9 8
    xdialog -c $dname 10 text 22 22 18 18 center | xdid -t $dname 10 9
    xdialog -c $dname 11 text 42 22 18 18 center | xdid -t $dname 11 10
    xdialog -c $dname 12 text 62 22 18 18 center | xdid -t $dname 12 11
    xdialog -c $dname 13 text 82 22 18 18 center| xdid -t $dname 13 12
    xdialog -c $dname 14 text 102 22 18 18 center | xdid -t $dname 14 13
    xdialog -c $dname 15 text 122 22 18 18 center | xdid -t $dname 15 14
    xdialog -c $dname 16 text 142 22 18 18 center | xdid -t $dname 16 15
    xdid -x $dname 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 +c
    var %x = 0
    while (%x <= 15) {
      xdid -C $dname $calc(%x + 1) +bk $color(%x)
      inc %x
    }
    xdialog -a $dname +ao 200
  }
}

alias ColorBox_cb {
  if ($2 != mouse) {
    ;;;echo $color(info) -s */ ColorBox_cb: $1-
  }
  if ($2 == sclick) {
    if ($3 != 0) {
      var %ed = $right($editbox($active),3)
      var %col =  $+ $iif($3 < 11,$+(0,$calc($3 - 1)),$calc($3 - 1))
      var %col2 = , $+ $iif($3 < 11,$+(0,$calc($3 - 1)),$calc($3 - 1))
      if ($left(%ed,1) == $chr(3)) && ($right(%ed,2)) { editbox -af $editbox($active) $+ %col2 }
      else editbox -af $editbox($active) %col
      dialog -x $1
    }
  }
}

;------------------
;-- POPUP SMILEY --
;------------------
alias PopupSmileys {
  popups New Popup.smile 16 16 
  var %bgc = $color($color(background))
  popups SetStyle Popup.smile office emboss bordericon 
  popups SetMetrics Popup.smile iconpad 0 0 contentpad 0 0 spacing 0 0
  $xsmilec(1 +b,01) 12¶1,8:4D8) | $xsmilec(end +b,02) 12¶1,8:4)8) | $xsmilec(end +b,03) 12¶1,8;4)8)
  $xsmilec(end +b,04) 12¶01,0884)8) | $xsmilec(end +b,05) 12¶1,8:4Þ8) | $xsmilec(end +cb,06) 12¶1,8:4(8)
  $xsmilec(end +b,07) 12¶1,8:11'4(8)11''' | $xsmilec(end +b,08) 12¶1,8:4s8) | $xsmilec(end +b,09) 12¶1,8:-4$8)
  $xsmilec(end +b,10) 12¶1,8:4x8) | $xsmilec(end +cb,11) 12¶1,8x4D8) | $xsmilec(end +b,12) 12¶1,8:4*8)
  $xsmilec(end +b,13) 12¶1,8:4o8) | $xsmilec(end +b,14) 12¶1,8:4|8) | $xsmilec(end +b,15) 12¶1,8:-4"8)
  $xsmilec(end +cb,16) 8(12,8-4_12,8-8)11" | $xsmilec(end +b,17) 8(12,8^4_12,8^8) | $xsmilec(end +b,18) 8(12,8o4_12,8o8)
  $xsmilec(end +b,19) 8(12,8@4_12,8@8) | $xsmilec(end +b,03) 8(12,8^4_12,8-8)
  popws Popup.smile  $calc($mouse.dx + 1) $calc($mouse.dy  - 6)
}

alias -l xsmilec { 
  return popups AddItem Popup.smile $1 0 0 $rgb(255,255,255) $+($mircdirScript\Smileys\,$2,.bmp) $cr editbox -afp $editbox($active)
}

;----------------------
;-- MAKE PROGRESSBAR --
;----------------------
alias MakePBar {
  .returnFaceTb
  if ($toolbar(PBar)) toolbar -d PBar
  if ($window(@PBar)) .window -c @PBar
  if (!%TbBgColor) set %TbBgColor $rgb(shadow)
  var %w = 123, %h = 16
  window -phfi @PBar 0 0 %w $calc(%h + 2)
  drawrect -rf @PBar %TbBgColor 1 0 0 %w %h
  var %diskget = $SpaceGetDir, %diskPath = $gettok(%diskget,1,32)
  drawtext -ro @PBar %TbBgColorText "tahoma" 7 0 0 LAG
  drawtext -ro @PBar %TbBgColorText "tahoma" 7 0 7 %diskPath
  RefreshBar @PBar 20 0 100 7 0
  RefreshBar @PBar 20 9 100 7 0
  toolbar -i $iif($1,$1,3) PBar PBar @PBar 0 0 %w %h
  toolbar -ol PBar "/run ::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" @PBar
}

alias returnFaceTb {
  var %r = $readini(mirc.ini,background,toolbar)
  if (%r) {
    set %TbBgColorText 1 | set %TbBgColor 5592405
  }
  else {
    set %TbBgColorText 1 | set %TbBgColor $rgb(face)
  }
}

;-------------------------
;-- REFRESH PROGRESSBAR --
;-------------------------
alias RefreshBar {
  ;if (!$window(@tmp)) return
  window -phf @tmp 0 0 $4 $calc($5 + 2)
  ;drawrect -nrf @tmp $iif(%TbBgColor,%TbBgColor,$rgb(face)) 1 0 0 $4 $5
  ;var %container = $rgb(shadow)
  var %container = 0
  drawrect -nrf @tmp %container 1 0 0 $4 $5
  drawline -nr @tmp %container 1 1 0 $calc($4 - 1) 0
  drawline -nr @tmp %container 1 1 $calc($5 - 1) $calc($4 - 1) $calc($5 - 1)
  drawline -nr @tmp %container 1 0 1 0 $calc($5 - 1)
  drawline -nr @tmp %container 1 $calc($4 - 1) 1 $calc($4 - 1) $calc($5 - 1)
  var %x = $round($calc( $6 / 100 * $calc($4 - 2)),0)
  var %i = $calc($5 - 2), %p = $calc(2 * $pi / %i), %r, %r2
  while (%i) { %r = $calc(175 + $cos($calc(%p * %i)) * 50 ) | %r2 = %r - 50 | drawline -nr @tmp $rgb(%r2,%r,%r2) 1 1 %i $calc(%x + 1) %i | dec %i }
  var %i = $calc($5 - 2), %p = $calc(2 * $pi / %i), %r, %r2
  while (%i) { %r = $calc(230 + $cos($calc(%p * %i)) * 25 ) | %r2 = %r - 0 | drawline -nr @tmp $rgb(%r2,%r,%r2) 1 $calc(%x + 1) %i $calc($4 - 1) %i | dec %i }
  drawcopy @tmp 0 0 $4 $5 $1-3
}

;-------------------------
;-- UPDATE LAG/CPU INFO --
;-------------------------
alias PbarUpdate {
  var %lag = $iif($lagbarUpdate < 99, $v1, 99)
  if ($toolbar(PBar)) {
    var %diskPath = $gettok($SpaceGetDir,1,32), %diskX100 = $calc(100 - $gettok($SpaceGetDir,3,32))
    RefreshBar @PBar 20 0 100 7 $int($calc(%lag * 20))
    RefreshBar @PBar 20 9 100 7 %diskX100
    toolbar -p PBar @PBar 0 0 $2 %diskX100
    toolbar -t PBar "Lag: %lag $+ s -:- $SpaceGetDir $+ % Libero"
  }
  if ($xstatusbar().visible) {
    xstatusbar -v 7 Lag: %lag $+ s.
    xstatusbar -v 8 Net: $scon(0)
    scid $activecid
    var %myt = $MyTransfer, %qy = $query(0)
    xstatusbar -t 9 +p $iif(%qy = 0,9,10) Query: %qy
    xstatusbar -v 10 Send: $gettok(%myt,1,32)
    xstatusbar -v 11 Get: $gettok(%myt,2,32)
    xstatusbar -v 12 $gettok(%myt,3-,32)
  }
}

alias SpaceGetDir {
  var %d = $left($getdir,1)
  var %s = $disk(%d).size, %f = $disk(%d).free
  return %d $+ :\ $bytes(%f,3).suf $+ / $+ $bytes(%s,3).suf $_x100(%f,%s)
}

alias _x100 {
  return $round($calc($1 / $2 * 100),0)
}

alias TotalDiskSize {
  var %x = 1, %z = $disk(0), %ts, %tf
  echo -s 0,14 Supporti di Archiviazione: 
  while (%x <= %z) {
    var %t = $disk(%x).type, %p = $disk(%x).path
    if (%t = cdrom) || (%t = removable) echo -s 0,14 %p  ( $+ %t $+ )  n/d
    if (%t != cdrom) && (%t != removable) {
      var %s = $disk(%x).size, %f = $disk(%x).free
      inc %ts %s | inc %tf %f
      echo -s 0,14 %p  ( $+ %t $+ ) $bytes(%f,3).suf $+ / $+ $bytes(%s,3).suf $_x100(%f,%s) $+ %
    }
    inc %x
  }
  echo -s 0,14 Total Free: $bytes(%tf,3).suf Total Size: $bytes(%ts,3).suf $_x100(%tf,%ts) $+ % 
}

;-----------------------------------
;-- Trasferimenti in corso (band) --
;-----------------------------------
alias MyTransfer {
  var %x = 1, %zs = $send(0), %zg = $get(0), %z = $iif(%zs > %zg,%zs,%zg), %_send, %_get
  while (%x <= %z) {
    .whilefix
    if ($send(%x).status == active) { inc %_send $send(%x).cps  }
    if ($get(%x).status == active) { inc %_get $get(%x).cps }
    inc %x
  }
  return %zs %zg Up: $iif($bytes(%_send,3).suf,$ifmatch,0kb) $+ /s $chr(124) Dw:  $iif($bytes(%_get,3).suf,$ifmatch,0kb) $+ /s
}

;---------------------
;-- GESTIONE POPUPS --
;---------------------
alias PopupLag {
  popups New popLag 16 16
  popups LoadImg popLag icon normal 63, $+ $mircexe
  var %x = 1, %z = $scon(0)
  popups AddItem popLag end +d Network Lag
  popups AddItem popLag end
  while (%x <= %z) {
    .scon %x
    popups AddItem popLag end $iif($status == disconnected,+d,+) 1 › $network $+ : $calc(%lag.mylag. [ $+ [ $cid ] ] / 1000) sec. $cr echo -st $scon(%x)
    inc %x
  }
  popws popLag $mouse.dx $calc($mouse.dy -12)
}

alias PopupNet {
  popups New popNet 16 16
  popups LoadImg popNet icon normal 12, $+ $mircexe
  popups LoadImg popNet icon normal 39, $+ $mircexe
  var %x = 1, %z = $scon(0)
  popups AddItem popNet end + 1 Network Connesse %z
  popups AddItem popNet end
  while (%x <= %z) {
    .scon %x
    popups AddItem popNet end $iif($status == disconnected,+d,+) 2 › $network
    inc %x
  }
  popws popNet $mouse.dx $calc($mouse.dy -12)
}

alias PopupQuery {
  popups New popQuery 16 16
  popups LoadImg popQuery icon normal 24, $+ $mircexe
  popups LoadImg popQuery icon normal 22, $+ $mircexe
  var %x = 1, %z = $query(0)
  popups AddItem popQuery end + 1 $iif(%z == 0,Nessuna Query,Query %z)
  if (%z > 0) {
    popups AddItem popQuery end
    while (%x <= %z) {
      popups AddItem popQuery end + 2 › $query(%x)
      inc %x
    }
  }
  popws popQuery $mouse.dx $calc($mouse.dy -12)
}

alias PopupSend {
  popups New popSend 16 16
  popups LoadImg popSend icon normal 7, $+ $mircexe
  popups LoadImg popSend icon small 63, $+ $mircexe
  popups LoadImg popSend icon small 20, $+ $mircexe
  popups LoadImg popSend icon small 19, $+ $mircexe
  var %x = 1, %z = $send(0)
  popups AddItem popSend end + 1 $iif(%z == 0,Nessun Send,Send Totali %z)
  if (%z > 0) { 
    popups AddItem popSend end
    while (%x <= %z) {
      var %f = $send(%x).file, %p = $send(%x).pc $+ %, %b = $bytes($send(%x).size,3).suf
      popups AddItem popSend end + $iif($send(%x2).status = failed,4,3) › $iif($len(%f) > 30,$left(%f,30) $+ ...) %b %p $cr echo -st $send(%x) -> %f %b %p
      inc %x
    }
  }
  popws popSend $mouse.dx $calc($mouse.dy -12)
}

alias PopupGet {
  popups New popGet 16 16
  popups LoadImg popGet icon normal 63, $+ $mircexe
  popups LoadImg popGet icon small 8, $+ $mircexe
  popups LoadImg popGet icon small 20, $+ $mircexe
  popups LoadImg popGet icon small 19, $+ $mircexe
  var %x = 1, %z = $get(0)
  popups AddItem popGet end + 2 $iif(%z == 0,Nessun Get,Get Totali %z)
  if (%z > 0) { 
    popups AddItem popGet end
    while (%x <= %z) {
      var %f = $get(%x).file, %p = $get(%x).pc $+ %, %b = $bytes($get(%x).size,3).suf
      popups AddItem popGet end + $iif($get(%x2).status = failed,4,3) › $iif($len(%f) > 20,$left(%f,20) $+ ...) %b %p
      inc %x
    }
  }
  popws popGet $mouse.dx $calc($mouse.dy -12)
}

alias PopupTrasferimenti {
  popups New popTrasf 16 16
  popups SetStyle popTrasf office emboss bordericon
  popups LoadImg popTrasf icon normal 7, $+ $mircexe
  popups LoadImg popTrasf icon small 8, $+ $mircexe
  popups LoadImg popTrasf icon small 20, $+ $mircexe
  popups LoadImg popTrasf icon small 19, $+ $mircexe
  popups AddItem popTrasf end + 1 In Upload
  popups AddItem popTrasf end +
  var %x = 1, %z1 = $send(0),
  if (%z1 > 0) {
    while (%x <= %z1) {
      var %f = $send(%x).file, %p = $send(%x).pc $+ %, %b = $bytes($send(%x).size,3).suf
      if ($send(%x).done != $true) popups AddItem popTrasf end + $iif($send(%x2).status = failed,4,3) › $iif($len(%f) > 20,$left(%f,20) $+ ...,%f) %b %p
      inc %x
    }
  }
  popups AddItem popTrasf end +C 2 In Download
  popups AddItem popTrasf end +
  var %x2 = 1, %z2 = $get(0)
  if (%z2 > 0) {
    while (%x2 <= %z2) {
      var %f = $get(%x2).file, %r = $iif($bytes($get(%x2).cps,3).suf,$ifmatch,0kb) $+ /s
      if ($get(%x2).done != $true) popups AddItem popTrasf end + $iif($get(%x2).status = failed,4,3) › $iif($len(%f) > 20,$left(%f,20) $+ ...,%f) %r
      inc %x2
    }
  }
  popws popTrasf $mouse.dx $calc($mouse.dy -12)
}

alias popUtility {
  popups New popUtil 16 16
  popups LoadImg popUtil icon normal 63, $+ $mircexe
  popups LoadImg popUtil icon normal 11, $+ $mircexe
  popups AddItem popUtil end + 1 2 meteo $cr meteo
  popups AddItem popUtil end + 1 2 Traduttore $cr Traduttore
  popups AddItem popUtil end + 1 2 Test adsl $cr SpeedTest
  popups AddItem popUtil end + 1 2 ComingSoon $cr ComingSoon
  popups AddItem popUtil end + 1 2 Cine App $cr CineApp
  popups AddItem popUtil end
  popups AddItem popUtil end + 1 2 Cambia ext file $cr .ExtChange
  popups AddItem popUtil end
  popups AddItem popUtil end + 1 2 Calendario $cr calendario
  popups AddItem popUtil end + 1 2 Appunti $cr .run notepad.exe Appunti.txt
  popws popUtil $mouse.dx $calc($mouse.dy +6)
}

;------------------
;-- ABOUT SCRIPT --
;------------------
alias about if (!$dialog(about)) dialog -m about about
dialog About {
  title "About Script"
  size -1 -1 124 119
  option dbu
  icon $mircexe, 63
  button "ok", 1, 98 108 25 10, ok
  icon 2, -1 -1 174 108, $mircexe , 0, noborder left
  text "xdccMule®", 3, 3 63 78 8
  text "Version 0.2 beta", 4, 3 70 78 8
  text "eXtended DCC", 5, 3 77 78 8
  text "Copyright © 2008-2017", 6, 3 84 80 8
  text "by Paradox Staff OpenJoke", 7, 3 91 80 8
  text "All Rights Reserved.", 8, 3 98 78 8
  link " ", 9, 4 109 73 8
}

on *:dialog:About:*:*:{
  if ($devent == init) {
    .mdxbegin
    did -g $dname 2 $+($_dirImg,About.jpg)
    did -ra $dname 4 Version $readini($script,INFO,Versione) $readini($script,INFO,Release)
    did -ra $dname 6 Copyright © 2008-2017
    did -ra $dname 9 $_UrlHome
    var %i = 3,4,5,6,7,8
    mdx SetFont $dname %i ANSI 11 700 Tahoma
    mdx SetColor $dname %i background $rgb(255,255,255)
    mdx SetColor $dname %i textbg $rgb(255,255,255)
    mdx SetColor $dname %i text 4227200
  }
  if ($devent == sclick) {
    if ($did == 9) .run $_UrlHome
  }
}

;-----------------------
;-- LINK COMANDI mIRC --
;-----------------------
alias _connettix bdll menu 101
alias _nuovo.status bdll menu 103
alias _gestserver bdll menu 104
alias _bexit bdll menu 105
alias _MenuBar bdll menu 110
alias _ToolBar bdll menu 111
alias _SwitchBar bdll menu 112
alias _display bdll menu 130
alias _addPreferiti bdll menu 141
alias _Options bdll menu 159
alias _TreeBar bdll menu 210
alias _Preferiti bdll menu 142
alias _Lchannels bdll menu 150
alias _Aliases bdll menu 201
alias _Popupss bdll menu 202
alias _Remote bdll menu 203
alias _Finger bdll menu 158
alias _Otimer bdll menu 157
alias _Colors bdll menu 133
alias _Font bdll menu 134
alias _Abook bdll menu 156
alias _Ntlist bdll menu 131
alias _controllo bdll menu 156
alias _Ulist bdll menu 132
alias _AboutM bdll menu 194
alias _WinTile bdll menu 170
alias _WinVertical bdll menu 170
alias _WinOriz bdll menu 171
alias _WinCascade bdll menu 172
alias _Woptions bdll menu 173
alias _WinSort bdll menu 174
alias _WinGroup bdll menu 174
alias _ordinaf bdll menu 175
alias _WinOrder bdll menu 175
alias _Vlog bdll menu 155
alias _Connett bdll menu 101
alias _DownL bdll menu 154
alias _Prova bdll menu 122
alias _espandi if ($window($active).state != maximized) { !window -x $qt($active) }

;---------
;-- RAW --
;---------
raw *:*: {
  ;echo 3 -a $numeric $1-
  var %e = echo 4 -a
  var %cl1 = $+(,,,$color(info2)), %cl2 = $+(,$color(info)), %cl3 = $+(,$color(action))
  ;--- Raw Server ---
  if ($numeric == 433) {
    tnick $2 $+ ^ $+ $rand(1,999) $+ $rand(a,z) $+ ^ 
  }
  if ($numeric == 405) {
    .haltdef 
    echo 4 -seat ATTENZIONE!!! Non posso entrare in $2 ... Hai troppi chans aperti, per entrare in $2 devi chiudere almeno un chan 
  }
  if ($numeric == 475) { 
    .haltdef
    echo 4 -seat ATTENZIONE!!! Non posso entrare in $2 ... Il canale $2 richiede una chiave di accesso (+k)
  }
  if ($numeric == 474) { 
    .haltdef
    echo 4 -seat ATTENZIONE!!! Non posso entrare in $2 ... Sei Bandito dal chan $2 (+b)
  }
  if ($numeric == 473) { 
    .haltdef
    echo 4 -seat ATTENZIONE!!! Non posso entrare in $2 ... Per entrare in $2 serve l'Invito (+i)
  }
  if ($numeric == 477) { 
    .haltdef
    echo 4 -seat ATTENZIONE!!! Il canale $2 non esiste ... solo gli operatori possono creare nuovi Canali.
  }
  ;--- Raw Whois esteso ---
  if ($numeric == 311) {
    %e %cl3 $+ $str(_,7) Whois su $2 $date $time $str(_,7)
    %e %cl1 $+ Nick: $+ %cl2 $2
    %e $+(`•-,%cl1,Ident:,%cl2) $3
    %e $chr(160) $+(|-,%cl1,Indirizzo:) %cl2 $4
    %e $chr(160) $+(|-,%cl1,Nome Reale:,%cl2) $strip($6)
    .haltdef
  }
  if ($numeric == 379) {
    %e $chr(160) $+(|-,%cl1,Modi Utente:,%cl2) $6-
    .haltdef
  }
  if ($numeric == 378) {
    %e $chr(160) $+(|-,%cl1,Real Host:,%cl2) $6
    %e $chr(160) $+(|-,%cl1,IP:,%cl2) $7
    .haltdef
  }
  if ($numeric == 307) {
    %e $chr(160) $+(|-,%cl1,Nick Registrato:,%cl2) Si
    .haltdef
  }
  if ($numeric == 319) {
    %e $chr(160) $+(|-,%cl1,Canali:,%cl2) $qt($numtok($3-,32)) $replace($3-,$chr(44),$chr(32))
    .haltdef
  }
  if ($numeric == 312) {
    %e $chr(160) $+(|-,%cl1,Server:,%cl2) $3-
    .haltdef
  }
  if ($numeric == 313) {
    %e $chr(160) $+(|-,%cl1,IRCoP:,%cl2) $3-
    .haltdef
  }
  if ($numeric == 310) {
    %e $chr(160) $+(|-,%cl1,Helper:,%cl2) $3-
    .haltdef
  }
  if ($numeric == 320) {
    %e $chr(160) $+(|-,%cl1,Extra Line:,%cl2) $3-
    .haltdef
  }
  if ($numeric == 335) {
    %e $chr(160) $+(|-,%cl1,Bot:,%cl2) $3-
    .haltdef
  }
  if ($numeric == 317) {
    %e $chr(160) $+(|-,%cl1,Non digita da [idle]:,%cl2) $duration($3) 
    %e $chr(160) $+(|-,%cl1,Si è connesso:,%cl2) alle $asctime($4, HH:nn:ss il dd\mm\yy )
    .haltdef
  }
  if ($numeric == 301) {
    %e $chr(160) $+(|-,%cl1,Msg Away:,%cl2) $4-
    .haltdef
  }

  if ($numeric == 401) {
    %e %cl3 $+ $str(_,7) Whois su $2 $date $time $str(_,7)
    %e %cl1 $+ Nick: $+ %cl2 $2
    %e $+(`•-,%cl1,Non trovo:,%cl2) nessun nick/channel corrispondente

    .haltdef
  }

  if ($numeric == 671) {
    %e $chr(160) $+(|-,%cl1 Ssl:,%cl2) $4-
    .haltdef
  }
  if ($numeric == 318) {
    var %c = $comchans($2)
    %e $chr(160) $+(`-,%cl1,Canali in Comune:,%cl2) $qt($numtok(%c,44)) $replace($iif(%c, %c),$chr(44),$chr(32))
    %e %cl3 $+ $str(_,20) $3- $str(_,20)
    .haltdef
  }
}

alias sduration { return $replace($duration($1),wks,w,days,d,hrs,h,mins,m,secs,s,wk,w,day,d,hr,h,min,m,sec,s) }
alias comchans {
  var %tok = 44, %x = 1, %chans
  while (%x <= $comchan($1,0)) {
    %chans = $addtok(%chans,$comchan($1,%x),%tok)
    inc %x
  }
  return $sorttok(%chans,%tok) 
}

;-------------------
;-- GESTIONE TEMA --
;-------------------
alias GetTema {
  if ($1 isnum) && ($readini($mircini,colors,$ini($mircini,colors,$1)) != $null) {
    var %s = $gettok($v1,1,44), %t = $readini($mircini,text,theme)
    return $iif(%s == %t, $style(1), $style(0)) %s $+ : CombineTema %s
  }
}
alias CombineTema {
  echo -stea Settato tema $1-
  .resetCnick
  if ($1- == mIRC Classic Nero) { 
    .cnick -ns1 $ $+ me 9 | .cnick -s2 * 4 ~ | .cnick -s3 * 7 & | .cnick -s4 * 11 @
    .cnick -s5 * 13 % | .cnick -s6 * 8 + | .cnick -ns7 * 0 | .cnick -ym0 * 10 | .cnick -im0 * 15
    .timestamp -ef [HH:nn:ss]
    .SetBackGround skin\NetworkNero.png -sec -dp
  }
  if ($1- == mIRC Classic) { 
    .cnick -ns1 $ $+ me 9 | .cnick -s2 * 4 ~ | .cnick -s3 * 7 & | .cnick -s4 * 2 @
    .cnick -s5 * 6 % | .cnick -s6 * 3 + | .cnick -ns7 * 1 | .cnick -ym0 * 10 | .cnick -im0 * 5
    .timestamp -ef [HH:nn:ss]
    .SetBackGround skin\Network.jpg -sec -dp
  }
  if ($1- == mIRC Modern) { 
    .cnick -ns1 $ $+ me 9 | .cnick -s2 * 4 ~ | .cnick -s3 * 7 & | .cnick -s4 * 2 @
    .cnick -s5 * 6 % | .cnick -s6 * 3 + | .cnick -ns7 * 1 | .cnick -ym0 * 10 | .cnick -im0 * 5
    .timestamp -ef [HH:nn:ss]
    .SetBackGround skin\Network.jpg -sec -dp
  }
  if ($1- == Monochrome State) { 
    .cnick -ns1 $ $+ me 9 | .cnick -s2 * 4 ~ | .cnick -s3 * 7 & | .cnick -s4 * 11 @
    .cnick -s5 * 13 % | .cnick -s6 * 8 + | .cnick -ns7 * 0 | .cnick -ym0 * 10 | .cnick -im0 * 15
    .timestamp -ef [HH:nn:ss]
    .SetBackGround skin\NetworkNero.png -sec -dp
  }
  if ($1- == Placid Hues) { 
    .cnick -ns1 $ $+ me 9 | .cnick -s2 * 4 ~ | .cnick -s3 * 7 & | .cnick -s4 * 2 @
    .cnick -s5 * 6 % | .cnick -s6 * 3 + | .cnick -ns7 * 1 | .cnick -ym0 * 10 | .cnick -im0 * 5
    .timestamp -ef [HH:nn:ss]
    .SetBackGround skin\Ice.png -sx -dpx
  }
  if ($1- == Rainbow Sky) { 
    .cnick -ns1 $ $+ me 7 | .cnick -s2 * 4 ~ | .cnick -s3 * 5 & | .cnick -s4 * 2 @
    .cnick -s5 * 13 % | .cnick -s6 * 3 + | .cnick -ns7 * 1 | .cnick -ym0 * 10 | .cnick -im0 * 9
    .timestamp -ef 3|0,02HH:nn:ss3|
    .SetBackGround skin\Ice.png -sx -dpx
  }
  if ($1- == Tema Nero) { 
    .cnick -ns1 $ $+ me 9 | .cnick -s2 * 4 ~ | .cnick -s3 * 7 & | .cnick -s4 * 11 @
    .cnick -s5 * 13 % | .cnick -s6 * 8 + | .cnick -ns7 * 0 | .cnick -ym0 * 10 | .cnick -im0 * 15
    .timestamp -ef [HH:nn:ss]
    .SetBackGround skin\NetworkNero.png -sx -dx  
  }
  if ($1- == Tema Acqua) {
    .cnick -ans1 $ $+ me 9 | .cnick -ans2 * 4 ~ | .cnick -ans3 * 7 & | .cnick -ans4 * 2 @
    .cnick -ans5 * 6 % | .cnick -ans6 * 3 + | .cnick -aym0 * 10 | .cnick -aim0 * 5
    .timestamp -ef 12,12[1,15HH:nn:ss12,12]
    .SetBackGround skin\Ice.png -sx -dpx
  }
  if ($1- == Tema Ice) {
    .cnick -ns1 $ $+ me 9 | .cnick -s2 * 4 ~ | .cnick -s3 * 7 & | .cnick -s4 * 2 @
    .cnick -s5 * 6 % | .cnick -s6 * 3 + | .cnick -ns7 * 1 | .cnick -ym0 * 10 | .cnick -im0 * 5
    .timestamp -ef 12,12[1,15HH:nn:ss12,12]
    .SetBackGround skin\Ice.png -sep -dp
  }
  if ($1- == xdccMule Nero) { 
    .cnick -ns1 $ $+ me 9 | .cnick -s2 * 4 ~ | .cnick -s3 * 7 & | .cnick -s4 * 11 @
    .cnick -s5 * 13 % | .cnick -s6 * 8 + | .cnick -ns7 * 0 | .cnick -ym0 * 10 | .cnick -im0 * 15
    .timestamp -ef 14,14[1,15HH:nn:ss14,14]
    .SetBackGround skin\NetworkNero.png -sec -dp
  }
  if ($1- == xdccMule Bianco) { 
    .cnick -ns1 $ $+ me 9 | .cnick -s2 * 4 ~ | .cnick -s3 * 7 & | .cnick -s4 * 2 @
    .cnick -s5 * 6 % | .cnick -s6 * 3 + | .cnick -ns7 * 1 | .cnick -ym0 * 10 | .cnick -im0 * 5
    .timestamp -ef 7,14|15,07HH:nn:ss7,14|
    .SetBackGround skin\Network.jpg -sec -dp
  }
  if ($1- == xdccMule Carbon) { 
    .cnick -ns1 $ $+ me 9 | .cnick -s2 * 4 ~ | .cnick -s3 * 7 & | .cnick -s4 * 11 @
    .cnick -s5 * 13 % | .cnick -s6 * 8 + | .cnick -ns7 * 0 | .cnick -ym0 * 10 | .cnick -im0 * 15
    .timestamp -ef 14,14[14,15HH:nn:ss14,14]
    .background -sbx
  }
  if ($1- == PoWeR-Script) { 
    .cnick -ns1 $ $+ me 9 | .cnick -s2 * 8 ~ | .cnick -s3 * 6 & | .cnick -s4 * 11 @
    .cnick -s5 * 3 % | .cnick -s6 * 10 + | .cnick -ns7 * 0 | .cnick -ym0 * 10 | .cnick -im0 * 15
    .timestamp -ef [HH:nn:ss]
    .SetBackGround skin\NetworkNero.png -sec -dp
  }
  if ($1- == Italy Nero) { 
    .cnick -ns1 $ $+ me 9 | .cnick -s2 * 4 ~ | .cnick -s3 * 7 & | .cnick -s4 * 11 @
    .cnick -s5 * 13 % | .cnick -s6 * 8 + | .cnick -ns7 * 0 | .cnick -ym0 * 10 | .cnick -im0 * 15
    .timestamp -ef 0,03 HH14,0:nn:0,04ss 
    .SetBackGround skin\NetworkNero.png -sec -dp
  }
  .color -s $1-
}

alias resetCnick {
  var %x = 1, %z = $cnick(0)
  while (%x <= %z) {
    .cnick -r * %x *
    inc %x
  }
}

alias SetBackGround {
  .background $2 $1
  var %i = 1
  while ($chan(%i)) {
    background $3 $chan(%i) $1
    inc %i
  }
  writeini mirc.ini background wchannel $1 $+ ,5
}

;----------------------------
;-- CAMBIA ESTENSIONE FILE --
;----------------------------
alias ExtChange {
  var %m = $sfile($getdir,Cambia Nome\Estensione File,OK)
  if (%m) {
    var %f = $nopath(%m), %p = $nofile(%m)
    var %f2 = $input(Cambia l'estensione o il nome del file e premi ok,eg,Editor Estensione,%f)
    if (%f2) .rename $qt(%m) $qt(%p $+ %f2)
  }
}

;-------------------------
;-- RIPRISTINO mirc.ini --
;-------------------------
alias restart { run mirc.exe | exit -n }
alias Ripristino {
  var %m = $input(ATTENZIONE!!! $crlf $crlf Vuoi Veramente ripristinare $crlf $crlf il file di configurazione di mIRC?,ygdw,Ripristino Configurazione,title,text) 
  if (!%m) return
  set %AvviiScript 0
  ;.run ripristino.exe
  .exit -n | .exit -n
}

alias Backup {

}

;-----------------------
;-- CREA COLLEGAMENTI --
;-----------------------
alias xdccMule2desktop {
  var %m = $input(Creo un collegamento a xdccMule sul Desktop?,yidw,Scorciatoia xdccMule)
  if (%m == $true) { .shortcut $specialfolder(desktop) $+ \xdccMule 2.lnk, $mircexe , 0 $+($_dirIco,IRC.ico) }
}
alias makeShortcut { 
  .shortcut $specialfolder(desktop) $+ \xdccMule 2.lnk, $mircexe , 0 $+($_dirIco,IRC.ico) 
  .shortcut $specialfolder(desktop) $+ \Downloads xdccMule 2.lnk, $shortfn($getdir) , 0 $+($_dirIco,SHAREDFILES.ico)
}

alias Downloads2desktop {
  var %m = $input(Creo un collegamento alla cartella download di xdccMule sul Desktop?,yidw,Scorciatoia cartella download di xdccMule)
  if (%m == $true) { .shortcut $specialfolder(desktop) $+ \Downloads xdccMule 2.lnk, $shortfn($getdir) , 0 $+($_dirIco,SHAREDFILES.ico) }
}

alias Url2desktop {
  var %m = $input(Creo un collegamento alla Home di xdccMule sul Desktop?,yidw,Scorciatoia Home di xdccMule)
  if (%m == $true) { .shortcut $specialfolder(desktop) $+ \Home xdccMule.lnk, http://xdccmule.org , 0 $+($_dirIco,KADEMLIA.ico) }
}

alias ShortcutExist {
  var %l = $+($specialfolder(desktop),\xdccMule 2.lnk)
  if ($exists(%l)) return 1
  else return 0
}

alias shortcut {
  var %e = !echo $color(info) -a * Shortcut:
  if ($isid) {
    if (!$isfile($1)) { %e Shortcut doesn't exist. | return }
    var %props = Targetpath Windowstyle Hotkey Iconlocation Description Workingdirectory
    if (!$istok(%props,$2,32)) {
      tokenize 32 %props
      %e Incorrect property. Possible: | echo -a $* | return
    }
  }
  else {
    var %a, %b = $regsub($1-,/\s*\54\s*/g,$chr(44),%a) $regsub(%a,/(?<=\54)(?=\54)/g,$lf,%a)
    tokenize 44 %a
  }
  if (!$regex(ext,$1,/\.(lnk|url)$/)) { %e Incorrect shortcut extension. | return }
  if (!$isdir($nofile($1))) { %e Invalid folder path to shortcut. | return }
  if ($mkfn($nopath($1)) != $nopath($1)) { %e Name contains invalid characters. | return }
  if ($2 != $shortfn($getdir)) && ($2 != http://xdccmule.org) && ($regml(ext,1) == lnk) && (!$isid) && (!$isfile($2) || !$isdir($nofile($2))) {
    %e Targetpath does not exist. | return
  }
  var %objWSH = a $+ $ticks, %objLink = b $+ $ticks
  var %tmp = $iif($isid,return,echo -a) COM Error
  .comopen %objWSH wscript.shell
  if ($comerr) %tmp
  .comclose %objWSH $com(%objWSH,createshortcut,1,bstr*,$1,dispatch* %objLink)
  if (!$com(%objLink)) %tmp
  if ($isid) {
    %tmp = $com(%objLink,$2,2)
    %tmp = $com(%objLink).result
    .comclose %objLink
    return %tmp
  }
  if (!$com(%objLink,targetpath,4,bstr*,$2)) && ($show) %e Could not set targetpath.
  if ($regml(ext,1) == lnk) {
    if ($regex(icon,$3,/^(\d|)\s*(.+)/)) {
      var %loc = $regml(icon,2)
      if ($isfile(%loc)) && ($isdir($nofile(%loc))) {
        if (!$com(%objLink,iconlocation,4,bstr*,%loc $chr(44) $gettok($regml(icon,1) 0,1,32))) && ($show) {
          %e Could not set iconlocation/index.
        }
      }
    }
    if ($istok(1 3 7,$4,32)) && (!$com(%objLink,windowstyle,4,uint,$4)) && ($show) {
      %e Could not set windowstyle.
    }
    if ($regex(hotkey,$5,/^(?:(?:alt|ctrl|shift|ext)\+)+(?:[a-z\d]|f\d|f1[0-2])$/i)) {
      if (!$com(%objLink,hotkey,4,bstr*,$5)) && ($show) %e Could not set hotkey.
    }
    if ($6 != $lf) && (!$com(%objLink,description,4,bstr*,$6)) && ($show) {
      %e Could not set description.
    }
    %tmp = $com(%objLink,workingdirectory,4,bstr*,$nofile($2))
  }
  if (!$com(%objLink,save,1)) %e Error creating shortcut. 
  .comclose %objLink
}

;---------------------------
;-- RETURN SPECIAL FOLDER --
;---------------------------
alias specialfolder {
  var %e = !echo $color(info) -a Specialfolder:
  if ($1 == $null) { %e Insufficient parameters. | return }
  var %f1 = $&
    AllUsersDesktop AllUsersStartMenu AllUsersPrograms AllUsersStartup $&
    Desktop AppData PrintHood Templates Fonts NetHood . $&
    StartMenu SendTo Recent Startup Favorites MyDocuments Programs
  var %f2 = $&
    LocalAppdata . . AllUsersFavorites Internetcache Cookies $&
    History AllUsersAppdata . System . MyPictures
  var %f3 = Windir Programfiles Userprofile Comspec
  if ($1 == .) || (!$istok(%f1 %f2 %f3,$1,32)) {
    %e incorrect special folder - Possible:
    tokenize 32 $sorttok($remove(%f1 %f2,.) %f3,32)
    echo -a $*
    return
  }
  var %result = COM Error
  if ($istok(%f1 %f3,$1,32)) {
    var %objWSH = a $+ $ticks
    .comopen %objWSH wscript.shell
    if (!$comerr) {
      if ($findtok(%f1,$1,1,32)) %result = $com(%objWSH,SpecialFolders,3,uint,$calc($ifmatch - 1))
      else %result = $com(%objWSH,ExpandEnvironmentStrings,3,bstr*,% $+ $1%)
      %result = $com(%objWSH).result
      .comclose %objWSH
    }
  }
  else {
    if ($istok(95 98,$os,32)) { %e need atleast Windows ME to retrieve this path | return }
    var %objScript = a $+ $ticks
    .comopen %objScript msscriptcontrol.scriptcontrol
    if (!$comerr) {
      %result = $com(%objScript,language,4,bstr*,vbscript)
      %result = createobject("shell.application").namespace( $&
        $calc($findtok(%f2,$1,1,32) + 27) ).self.path
      %result = $com(%objScript,eval,1,bstr*,%result)
      %result = $com(%objScript).result
      .comclose %objScript
    }
  }
  $iif($isid,return,echo -a) %result
}

alias PickIcon {
  echo -a PickIcon Risultato: $dcx(PickIcon, 2 $mircexe)
}

alias -l DataRelScript return $readini($script,INFO,DATA)

alias resetScript {
  unset %*
  set %CloseAllFindWin 1 | set %InfoFonts FixedSys 12 | set %SetGlobalNet 1 | set %LogRichieste 1
  set %selectedDb DataBase.db | set %SJoin 1 | set %HomeSelect 1 | set %DockGlobalFind 1
  set %StyleSearch 1 | set %MoveCompleted 1 | set %StatusBar 1
  echo 4 -s -> xdccMule $_VCore $+ :
  echo 4 -s Data: $DataRelScript
  echo 4 -s $chr(160)
  echo 4 -s Linee: $lines($script)
  echo 4 -s md5: $md5($script)
  echo 4 -s $str(-,20)
  echo 4 -st >> Reset Completato.
}

;---------
;-- EOF --
;---------
