##################################### //Author: Jemte # //Undernet #ViRC or message board # # # //Script: XDCC File Server # # # //Version: 1.00 # # # //Category: File Server # # # //Written: February 2003 # //Released: January 2005 # ##################################### #Known Issues //none #Future //queues //GUI with Columns //checkbox to turn server on/off //pictures on buttons //checkbox for status window //set this to 0 if you dont want the XDCC stats displayed @ $xdcc_showstatements = 1 //check to see if the xdcc file list exists, if not it creates a new one if ($FileExists($ListQuote($getpath()xdccfile.list))!=1) CreateFile $getpath()xdccfile.list endif MenuTree MT_SERVERPOPUP__MERGE M_XDCC 0 0 &XDCC M_XDCC_SETUP 0 1 &XDCC Setup M_XDCC_SEP 0 1 - M_XDCC_BSTART !%isxdccon 1 &Start XDCC server M_XDCC_BSTOP %isxdccon 1 &Stop XDCC server EndMenuTree MenuItem M_XDCC_SETUP on MT_SERVERPOPUP__MERGE XDCC_SETUP EndMenuItem MenuItem M_XDCC_BSTART on MT_SERVERPOPUP__MERGE Halt if ($XDCC_CHECKLIST()) XDCC_DISPLAY clGreen \b[XDCC]\b Server \ustarted\u at $time() with a repeat every $XDCC_decodetime($xdcc_offertime) XDCC_BROADCAST @ $xdcc_active = on EndMenuItem MenuItem M_XDCC_BSTOP on MT_SERVERPOPUP__MERGE XDCC_DISPLAY clBlack \b[XDCC]\b Server \ustopped\u at $time(). @ $xdcc_active = off ^undelay xdcc_broadcast EndMenuItem MergeMenu MT_SERVERPOPUP__MERGE after MT_SERVERPOPUP addsep clobber move MenuTree MT_CHANNELTEXTPOPUP__MERGE M_XDCC 0 0 &XDCC M_XDCC_SETUP 0 1 &XDCC Setup M_XDCC_SEP 0 1 - M_XDCC_BSTART !%isxdccon 1 &Start XDCC server M_XDCC_BSTOP %isxdccon 1 &Stop XDCC server EndMenuTree MenuItem M_XDCC_SETUP on MT_CHANNELTEXTPOPUP__MERGE XDCC_SETUP EndMenuItem MenuItem M_XDCC_BSTART on MT_CHANNELTEXTPOPUP__MERGE Halt if ($XDCC_CHECKLIST()) XDCC_DISPLAY clGreen \b[XDCC]\b Server \ustarted\u at $time() with a repeat every $XDCC_decodetime($xdcc_offertime) XDCC_BROADCAST @ $xdcc_active = on EndMenuItem MenuItem M_XDCC_BSTOP on MT_CHANNELTEXTPOPUP__MERGE XDCC_DISPLAY clBlack \b[XDCC]\b Server \ustopped\u at $time(). @ $xdcc_active = off ^undelay xdcc_broadcast EndMenuItem MergeMenu MT_CHANNELTEXTPOPUP__MERGE after MT_CHANNELTEXTPOPUP addsep clobber move Event XDCC_request "% PRIVMSG % :\AXDCC *" //have switch for get, queues, clr_queues, clr_sends Halt if $isignoring($nick!$user@$host) Halt if ([$xdcc_active]!=[on]) Switch $4 Case send: XDCC_DISPLAY clBlue \b[XDCC]\b $nick has requested pack $5 XDCC_SEND $nick $5 EndSwitch EndEvent Event "*" @ $xdcc_current_sends = 0 EndEvent Event "*" @ $xdcc_current_sends = 0 EndEvent Event "*" if (([$0]==[send]) && ([$2]==[0])) XDCC_DISPLAY clPurple \b[XDCC]\b Complete send of $getdccinfo($1 filename) [$xdcc_decodesize($getdccinfo($1 totalsize))] to $getdccinfo($1 nick) notice $getdccinfo($1 nick) Complete send of $xdcc_getfn($getdccinfo($1 filename)) [$xdcc_decodesize($getdccinfo($1 totalsize))] was completed in $decodeminterval($($mtime()- $getdccinfo($1 starttime))) $xdcc_current_sends-- else if (([$0]==[send]) && ([$2]!=[0])) XDCC_DISPLAY clRed \b[XDCC]\b Send of $getdccinfo($1 filename) failed. [$3-] notice $getdccinfo($1 nick) Send of $xdcc_getfn($getdccinfo($1 filename)) [$xdcc_decodesize($getdccinfo($1 totalsize))] failed. [$3-] $xdcc_current_sends-- endif if ($xdcc_current_sends < 0) @ $xdcc_current_sends = 0 endif EndEvent Alias XDCC_SETUP //---------- @ $sometinstring = $new(TStringList) $sometinstring.LoadFromFile $ListQuote($getpath()xdccfile.list) //--------- @ $xdccform = $new(TForm position 207,50,467,479) @p $xdccform.BorderIcons = [biSystemMenu,biMinimize] @p $xdccform.BorderStyle = bsSingle @p $xdccform.Caption = XDCC Setup for ViRC $ver @p $xdccform.ClientHeight = 452 @p $xdccform.ClientWidth = 459 @p $xdccform.Color = clBtnFace @p $xdccform.Font.Charset = 1 @p $xdccform.Font.Color = clWindowText @p $xdccform.Font.Name = MS Sans Serif @p $xdccform.Font.Style = [] @p $xdccform.FormStyle = fsStayOnTop @p $xdccform.OldCreateOrder = False @p $xdccform.Visible = True @ $xdcc_chancpt = $new(TLabel ownedby $xdccform position 8,376,91,13) @p $xdcc_chancpt.Caption = Channels to offer in @ $xdcc_rptcpt = $new(TLabel ownedby $xdccform position 200,416,161,13) @p $xdcc_rptcpt.Caption = Time (in sec) to repeat XDCC offer @ $xdcc_maxcpt = $new(TLabel ownedby $xdccform position 8,416,53,13) @p $xdcc_maxcpt.Caption = Max Sends @ $xdcc_listbox = $new(TListBox ownedby $xdccform position 16,24,425,281) @p $xdcc_listbox.ItemHeight = 13 @p $xdcc_listbox.TabOrder = 1 //---------------- @l $xdcc_listbox_text = $mapprop($xdcc_listbox.Items) @p $xdcc_listbox_text.Text = $prop($sometinstring.Text) $xdcc_listbox.Items = $prop($xdcc_listbox_text.Text) //---------------- @ $xdcc_addbtn = $new(TButton ownedby $xdccform position 16,312,73,33) @p $xdcc_addbtn.Caption = Add + @p $xdcc_addbtn.TabOrder = 2 @p $xdcc_addbtn.OnClick = _ADDFILE @ $xdcc_delbtn = $new(TButton ownedby $xdccform position 104,312,73,33) @p $xdcc_delbtn.Caption = Remove - @p $xdcc_delbtn.TabOrder = 3 @p $xdcc_delbtn.OnClick = _REMFILE @ $xdcc_chanedit = $new(TEdit ownedby $xdccform position 128,368,321,25) @p $xdcc_chanedit.TabOrder = 4 @p $xdcc_chanedit.Text = $xdcc_chans @ $xdcc_offeredit = $new(TEdit ownedby $xdccform position 392,408,57,25) @p $xdcc_offeredit.TabOrder = 5 @p $xdcc_offeredit.Text = $xdcc_offertime @ $xdcc_maxedit = $new(TEdit ownedby $xdccform position 128,408,33,25) @p $xdcc_maxedit.TabOrder = 6 @p $xdcc_maxedit.Text = $xdcc_max @ $xdcc_exitbtn = $new(TButton ownedby $xdccform position 368,312,73,33) @p $xdcc_exitbtn.Caption = Cancel @p $xdcc_exitbtn.TabOrder = 7 @p $xdcc_exitbtn.OnClick = SafeDestroy $xdccform @ $xdcc_exitbtn = $new(TButton ownedby $xdccform position 280,312,73,33) @p $xdcc_exitbtn.Caption = Okay @p $xdcc_exitbtn.TabOrder = 8 @p $xdcc_exitbtn.OnClick = _CLOSE EndAlias Alias _ADDFILE @l $file = $OpenDialog(All files (*.*)|All Files (*.*)) Halt if ([$file]==[$null]) if ($FileExists($NoAttribs($file))) @l $fsize = $GetFileSize($NoAttribs($file)) if (([$xdcc_offersize]==[$$xdcc_offersize]) || ($xdcc_offersize<0)) @s $xdcc_offersize = 0 endif @s $xdcc_offersize = $($xdcc_offersize + $fsize) @l $fsize = $XDCC_DECODESIZE($fsize) if ([$xdcc_listbox.Items.IndexOf($file [$fsize])]!=[-1]) MessageBox $file already exists in the list! Halt endif $xdcc_listbox.Items.Add $file [$fsize] else MessageBox File selection error! [$file] endif EndAlias Alias _REMFILE @l $selected = $prop($xdcc_listbox.ItemIndex) @s $xdcc_offersize = $($xdcc_offersize - $GetFileSize($NoAttribs($RStrTokL([ $xdcc_listbox.Items.GetString($selected))))) $xdcc_listbox.Items.Delete $selected EndAlias Alias _CLOSE $xdcc_listbox.Items.SavetoFile $ListQuote($getpath()xdccfile.list) @s $xdcc_chans = $prop($xdcc_chanedit.Text) @s $xdcc_offertime = $prop($xdcc_offeredit.Text) @s $xdcc_max = $prop($xdcc_maxedit.Text) //check to see if there are channels if (([$xdcc_chans]==[]) || ([$xdcc_chans]==[$$xdcc_chans])) MessageBox XDCC ERROR - No channels have been specified Halt endif if (($xdcc_offertime<60) || ([$xdcc_offertime]==[$$xdcc_offertime])) MessageBox Server broadcast time set to default time of 300 seconds due to invalid entry in setup. @s $xdcc_offertime = 300 else if !($IsNumeric($xdcc_offertime)) MessageBox Server broadcast time set to default time of 300 seconds due to invalid entry in setup. @s $xdcc_offertime = 300 endif if (($xdcc_max<=0) || ([$xdcc_max]==[$$xdcc_max])) MessageBox Server max sends set to default of 5 due to invalid entry in setup. @s $xdcc_max = 5 else if !($IsNumeric($xdcc_max)) MessageBox Server max sends set to default of 5 due to invalid entry in setup. @s $xdcc_max = 5 endif Destroy $xdccform EndAlias Alias XDCC_DECODESIZE if ($1 < 1024) @ $fresult = $1 bytes else if (($1 >= 1024) && ($1 < 1048576)) @l $kcount = $($1/1024) @l $bcount = $($1%1024) @ $fresult = $kcount.$bcount Kb else if (($1 >= 1048576) && ($1 < 1073741824)) @l $mcount = $($1/1048576) @l $kcount = $($1%1048576) @l $kcount = $substr($kcount 0 3) @ $fresult = $mcount.$kcount Mb else if ($1 >= 1073741824) @ $fresult = $1 bytes endif EndAlias Alias XDCC_SEND if ([$xdcc_current_sends]>=[$xdcc_max]) notice $1 There are currently no sends spots available, please try back later! Halt endif @l $xdccfile = $ListQuote($getpath()xdccfile.list) if ($StrPos(# $2)>0) @l $xdccfileindex = $RStrTokR(# $2) else @l $xdccfileindex = $2 endif if (($xdccfileindex>$GetLinesInFile($xdccfile)) || ($xdccfileindex<=0)) notice $1 The index you selected is not valid! Halt endif @l $xdccfiletosend = $ReadLine($xdccfileindex $xdccfile) @l $xdccfiletosend = $SubStr($xdccfiletosend 0 $($RStrPos([ $xdccfiletosend)-2)) Onserver $currentserver() DCC SEND $1 $xdccfiletosend XDCC_DISPLAY clPurple \b[XDCC]\b Sending $xdccfiletosend to $1 $xdcc_current_sends++ EndAlias Alias XDCC_BROADCAST @l $tempcount = 0 foreach ($tempchan; $xdcc_chans) if !($IsChannel($tempchan)) @l $tempchan = #$tempchan endif if (!($IsOn($N $tempchan))) XDCC_DISPLAY clRed \b[XDCC]\b You attempted to offer in $tempchan but you aren't currently in that channel! $tempcount++ Yield endif if ($tempcount >= $WordCount($xdcc_chans)) XDCC_DISPLAY clBlack \b[XDCC]\b Server \ustopped\u at $time() b/c youre trying to offer in $tempcount channels youre not in! @ $xdcc_active = off ^undelay xdcc_broadcast Halt endif say $tempchan \b*** ViRC XDCC Server 1.00 ***\b say $tempchan \b*** Offering: $XDCC_DECODESIZE($xdcc_offersize) in $GetLinesInFile($NoAttribs($getpath()xdccfile.list)) packs ***\b say $tempchan \b*** Current Sends: $xdcc_current_sends out of $xdcc_max ***\b say $tempchan \b----------------------------------------\b XDCC_PLAYFILE $tempchan say $tempchan \b----------------------------------------\b say $tempchan To get a file, \b/CTCP $N XDCC send #\b endforeach if ([$xdcc_active]==[on]) ^delay xdcc_broadcast $xdcc_offertime XDCC_BROADCAST endif EndAlias Alias XDCC_DECODETIME Halt if !($IsNumeric($1)) @l $t = $1 @l $secs = 0 @l $mins = 0 @l $hours = 0 @l $days = 0 @l $weeks = 0 @l $total = $null if ($t < 60) @l $total = $total\b$t\bs else if (($t >= 60) && ($t < 3600)) @l $mins = $($t/60) @l $secs = $($t%60) @l $total = $total\b$mins\bm $xdcc_decodetime($secs) else if (($t >= 3600) && ($t<86400)) @l $hours = $($t/3600) @l $lom = $($t-$(3600*$hours)) @l $total = $total\b$hours\bh $xdcc_decodetime($lom) else if (($t >= 86400) && ($t<604800)) @l $days = $($t/86400) @l $loh = $($t-$(86400*$days)) @l $total = $total\b$days\bd $xdcc_decodetime($loh) else if (($t >= 604800) && ($t<31536000)) @l $weeks = $($t/604800) @l $lod = $($t-$(604800*$weeks)) @l $total = $total\b$weeks\bw $xdcc_decodetime($lod) else if ($t >= 31536000) @l $years = $($t/31536000) @l $low = $($t-$(31536000*$years)) @l $total = $total\b$years\by $xdcc_decodetime($low) endif @ $fresult = $total EndAlias Alias XDCC_PLAYFILE @l $delaytime = 2 @l $xdccfile = $NoAttribs($getpath()xdccfile.list) for (@l $counter = 1; $counter <= $GetLinesInFile($xdccfile); $counter++) @l $wait = $($ctime() + $delaytime) While ($wait > $ctime()) Yield Endwhile @l $xdccofferfile = $XDCC_GETFN($ReadLine($counter $xdccfile)) say $1 \b#$counter)\b $xdccofferfile endfor EndAlias Alias ISXDCCON @ $fresult = $timerexists(xdcc_broadcast) EndAlias Alias XDCC_DISPLAY if ($xdcc_showstatements==1) TextOut > XDCC $1 $2- endif EndAlias Alias XDCC_GETFN @ $fresult = $RStrTokR(\ $1-) EndAlias Alias XDCC_CHECKLIST @l $xdccfile = $ListQuote($getpath()xdccfile.list) if ($getlinesinfile($xdccfile)<=0) MessageBox XDCC Server cannot start b/c there are no files to share! XDCC_SETUP @ $fresult = 1 Halt endif @ $fresult = 0 EndAlias