home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 113 / EnigmaAmiga113CD.iso / software / on-line / amserv / amserv.amirx next >
Encoding:
Text File  |  2000-06-06  |  53.5 KB  |  2 lines

  1. /* Optimized with RexxOpt 1.8 */
  2. version.navn="AmServ V1.31";version.dattto="06.06'00";serverlist_filename="ram:filelist.txt";uploadlist_filename="ram:filelist_up.txt";searcher="C:ssearch";options results;port=address();"GETVERSION";vers=result;if vers<2.0 then;do;"ECHO P=«AMSERV» C=4 Error: AmServ must be run under AmIRC2.x or higher.";say 'Error: AmServ must be run under AmIRC2.x or higher.';exit;end;if exists("t:AmServ.tmp") then;do;if upper(arg(1))=="HALT" then;do;"echo P=«AMSERV» C=4 Halting.. (other arexx may have been stopped)";"echo P=«AMSERV» C=4 Now start AmServ again!";ADDRESS COMMAND "C:delete t:amserv.tmp";ADDRESS COMMAND "HI";exit 0;end;'echo P=«AMSERV» C=4 ERROR: Is AmServ still resident in memory?';'echo P=«AMSERV» C=4 TYPE: /rx AmServ.amirx halt';'echo P=«AMSERV» C=4 (Warning, this will stop other arexx-scripts too.)';"echo P=«AMSERV» C=4 exitting...";exit;end;else;do;if upper(arg(1))=="HALT" then;do;"echo P=«AMSERV» C=4 ERROR: No previously amserv running.";"echo P=«AMSERV» C=4 exitting...";exit 0;end;end;"getdcc";if dcc.chat.0>0|dcc.receive.0>0 then;do;if dcc.chat.0>0 THEN;DO i=1 TO dcc.chat.0;parse value dcc.chat.i WITH nick state hostname .;if state==2|state==3 then 'say /DCC CLOSE CHAT 'nick;end;if dcc.chat.0>0 then 'echo P=«AMSERV» C=4 ERROR: Press Right-AMIGA+SHIFT and C. Then click on "Cleanup".';if dcc.receive.0>0 then 'echo P=«AMSERV» C=4 ERROR: Press RightAMIGA+SHIFT and R. Then click on "Cleanup".';'echo P=«AMSERV» C=4        Restart the script.';exit;end;AMIRC_DIR=pragma('d');dummy=substr(AMIRC_DIR,length(AMIRC_DIR),1);if ~(dummy=="/")&~(dummy==":") then AMIRC_DIR=AMIRC_DIR'/';if exists(AMIRC_DIR"rexx/AmServ.config") then;do;call open(conff,AMIRC_DIR"Rexx/AmServ.config",r);line=readln(conff);if ~(line=='AmServ config file')&~(line=='') then;do;"echo P=«AMSERV» C=4 ERROR: Can't reqougnize configfile.";"echo P=«AMSERV» C=4 delete the file manually and try again. sorry!";exit 5;end;if line=='' then break;server=readln(conff);master=readln(conff);trigger=readln(conff);fdir=readln(conff);usrfile=readln(conff);logfile=readln(conff);ratio=readln(conff);credits=readln(conff);dummy=readln(conff);notice=readln(conff);maxusers=readln(conff);holddir=readln(conff);maxhold=readln(conff);advertline=readln(conff);autotimer=readln(conff);advchans=readln(conff);conf7=readln(conff);conf8=readln(conff);call close(conff);parse var dummy maxsend' 'maxups;if (maxups=='') then maxups=3;end;if ~(exists(AMIRC_DIR"rexx/AmServ.config"))|(line=='') then;do;'echo P=«AMSERV» C=4 ERROR: no config file. Opening questionary..';LF='0a'x;ESC='1b'x;CU='1b'x"[A";INTC='1b'x"[0m";GR1b='1b'x"[44m";INV='1b'x"[7m";call open window,"con:60/60/450/200/menu";call writeln(window,GR1b"  AmServ config editor    "LF"  This is a questionary   "INTC||LF);call writeln(window,"If you fail with a question, press ctrl-C and restart."LF);do forever;call writech(window," FileServer name : ");server=readln(window);if ~(server=='') then break;end;do forever;call writech(window," Operator nick (different from servernick): ");master=readln(window);if ~(master=='') then break;end;do forever;call writech(window," Trigger on (ex. !mywavs) : ");trigger=readln(window);if ~(trigger=='') then break;end;do forever;call writech(window," Filedir (ex. DH0:files/) : ");fdir=readln(window);if ~(fdir=='') then break;end;do forever;call writech(window," UserFile (Enter=default) : ");usrfile=readln(window);if (usrfile=='') then;do;usrfile=AMIRC_DIR'Rexx/AmServ.users';call writeln(window,CU||ESC"[28C"INV||usrfile||INTC);end;break;end;do forever;call writech(window," LogFile  (Enter=default) : ");logfile=readln(window);if (logfile=='') then;do;logfile='RAM:AmServ.log';call writeln(window,CU||ESC"[28C"INV||logfile||INTC);end;break;end;do forever;call writech(window," Ratio (ex. 6 = 1:6 ) write a number: ");ratio=readln(window);if ~(ratio=='') then;do;if ~datatype(ratio,n) then;if length(ratio)>2&SUBSTR(ratio,1,2)=='1:' then ratio=SUBSTR(ratio,3,length(ratio)-2);end;if ~(ratio=='') then break;end;do forever;call writech(window," Newuser's start credits (in bytes) : ");credits=readln(window);if ~(credits=='')& datatype(credits,n) then break;end;do forever;call writech(window," Maximum allowed downloads at once pr.user : ");maxsend=readln(window);if ~(maxsend=='')& datatype(maxsend,n) then break;end;do forever;call writech(window," Maximum allowed uploads at once pr.user : ");maxups=readln(window);if ~(maxups=='')& datatype(maxups,n) then break;end;do forever;call writech(window," notice users who joins the #channel? (yes/no) : ");notice=readln(window);notice=upper(notice);if (notice=='Y')|(notice=='N')|(notice=='YES')|(notice=='NO') then break;end;IF (notice=='Y')|(notice=='YES') then notice=1;IF (notice=='N')|(notice=='NO') then notice=0;do forever;call writech(window," Maximum users online at once : ");maxusers=readln(window);if ~(maxusers=='')& datatype(maxusers,n) then break;end;call writech(window," Hold Directory (Enter=default) : ");holddir=readln(window);if (holddir=='') then;do;holddir='RAM:';call writeln(window,CU||ESC"[34C"INV||holddir||INTC);end;else;do;dummy=substr(holddir,length(holddir),1);if ~(dummy=="/")&~(dummy==":") then holddir=holddir'/';end;do forever;call writech(window," Maximum size on hold-packets (bytes) : ");maxhold=readln(window);if ~(maxhold=='')& datatype(maxhold,n) then break;end;call writech(window,LF||LF" Write a line to be used as advertisement (on-joins etc)"LF" You can use these keywords: %n %o %m %t %r %c %v %% %s"LF);call writech(window,"   %s=servername, %o=usersonline %m=maxconnections,"LF"   %t=trigger-keyword, %r=ratio, %c=newcredits,"LF);call writech(window,"   %v=version-tag, %%= %  %s=OperatorNick .."LF||LF);call writech(window," Example: %v Trigger %n with %t. Newusers get %cb free. The ratio is %r [ %o of %m slots in use ]"LF||LF);call writech(window," Enter Line (enter=example as default) : ");advertline=readln(window);if advertline=='' then advertline='%v Trigger %n with %t. Newusers get %cb free. The ratio is %r [ %o of %m slots in use ]';call writeln(window,CU||ESC"[41C"INV||advertline||INTC);replacer(advertline);call writeln(window,result||LF||LF);do forever;call writech(window," Enter the time (in secounds) between each adverticing : ");autotimer=readln(window);if ~(autotimer=='')& datatype(autotimer,n) then break;end;advchans="";call writech(window," You can enter the channels to advertise in later when you are online with the function: SetAdvChans [chan1] [chan2] ..."LF);call writech(window," Default is: ALL channels! "LF);call writech(window,LF"Thank you, writing setup to AMIRC_DIR'Rexx/AmServ.config'...");saveconfig();call writeln(window,"Done!"LF"(press enter)");dummy=readln(window);call close(window);end;"getmynick";mynick=result;if upper(mynick)==upper(master) then;do;'ECHO P=«AMSERV» C=4 ERROR: This nick, 'mynick', is identical to the operator s-nick. Please change the nick here to something else...';exit;end;parse arg arguments;word1=upper(word(arguments,1));word2=upper(word(arguments,2));if ~(word1=="")&~(word1=="NOTICE") then master=word1;if (word1=="NOTICE")|(word2=="NOTICE") then notice=1;init:;check=addlib('rexxsupport.library',0,-30,0);LF='0a'x;if ~exists(usrfile) then;do;open(fil,usrfile,w);call writeln(fil,master'©®©-©®©©®©©®©900000000©®©0©®©0'LF);close(fil);end;if ~exists(logfile) then;do;open(fil,logfile,w);close(fil);end;if ~(substr(fdir,length(fdir),1)=='/')&~(substr(fdir,length(fdir),1)==':') then fdir=fdir'/';'getdcc';users=0;user.='';USHAN.='';receivejobs.="";receivejobs.0=0;sendjobs.="";sendjobs.0=0;holdnr=0;l=result;out='';logging='';bold='';CT_A='';if ~datatype(autotimer,n) then autotimer=0;if advchans=='CONF6' then advchans='';'ECHO P=«AMSERV» C=4 << AmServ.amirx 'version.navn' ('version.dattto') >>';'ECHO P=«AMSERV» C=4 config: Servername = 'server;'ECHO P=«AMSERV» C=4 config: Masternick = 'master;'ECHO P=«AMSERV» C=4 config: Trigger    = 'trigger;'ECHO P=«AMSERV» C=4 config: filesdir   = 'fdir;'ECHO P=«AMSERV» C=4 config: userfile   = 'usrfile;'ECHO P=«AMSERV» C=4 config: logfile    = 'logfile;'ECHO P=«AMSERV» C=4 config: Ratio      = 1:'ratio;'ECHO P=«AMSERV» C=4 config: startcreds = 'credits;'ECHO P=«AMSERV» C=4 config: maxsends   = 'maxsend;'ECHO P=«AMSERV» C=4 config: maxups     = 'maxups;IF notice then 'ECHO P=«AMSERV» C=4 config: Notice     = ON';else 'ECHO P=«AMSERV» C=4 config: Notice     = OFF';'ECHO P=«AMSERV» C=4 config: maxusers   = 'maxusers;'ECHO P=«AMSERV» C=4 config: holddir    = 'holddir;'ECHO P=«AMSERV» C=4 config: maxhold    = 'maxhold;'ECHO P=«AMSERV» C=4 config: advertline = 'advertline;if autotimer>0 then 'ECHO P=«AMSERV» C=4 config: autotimer  = 'autotimer;else 'ECHO P=«AMSERV» C=4 config: autotimer  = 'autotimer' (OFF)';if advchans=='' then 'ECHO P=«AMSERV» C=4 config: advchans   = ALL CHANNELS';else 'ECHO P=«AMSERV» C=4 config: advchans   = 'advchans;'ECHO P=«AMSERV» C=4 I am now running under this copy of amirc!';'ECHO P=«AMSERV» C=4 This copy should not be touched too much, so please keep me iconified:)';'ECHO P=«AMSERV» C=4 Now connect another AmIRC to IRC with nick 'master' and type:';'ECHO P=«AMSERV» C=4 "/MSG 'mynick' 'trigger'" to connect as operator.';open(tmp,'t:AmServ.tmp',w);close(tmp);dato= date('e');timo=time('n');call OPEN(logf,logfile,a);call writeln(logf,'--- 'version.navn' ('version.dattto') started 'dato' 'timo);call CLOSE(logf);timerfrom=time('s');do forever;"getline";parseline();dato= date('e');timo=time('n');"getmynick";mynick=result;if ((upper(nick)==upper(mynick))|(upper(nick)==upper(master)))&(uword1=='QUIT') then;do;'say /MSG 'master' --QUITING--';'echo P=«AMSERV» C=4 --QUITING--';ADDRESS COMMAND "C:DELETE t:AmServ.tmp quiet";EXIT 0;end;IF (what=='PRIVMSG') then;do;if (uword1==upper(trigger)) then connect_user();IF (uword1=='!LIST') then;do;replacer(advertline);'raw NOTICE 'nick' :'result;end;IF (uword1==CT_A'VERSION'CT_A) then 'raw NOTICE 'nick' :'version.navn' ('version.dattto') by Hans Petter Dalsklev. Server:'server' Trigger:'trigger' Ratio 1:'ratio;IF (uword1==CT_A'DCC')&(uword2=='SEND') then getupload();end;if (notice)&(what=='JOIN') then;do;replacer(advertline);'raw NOTICE 'nick' :'result;end;IF (to=='DCCMSG')|(what=='DCCMSG') then;do;docommand();if upper(nick)==upper(master) then domastercommand();end;if 0<receivejobs.0 then checkuploads();checktimeouts();if users>0 then check_dcc_connect();autoadverttimer();end;docommand:;do n=1 until found;found=(user.n.name=nick);if found then leave;end;if (uword1=='HELP')|(uword1=='?') then;do;if ~(upper(nick)==upper(master)) then 'say /MSG 'master' 'n': 'nick' HELP - User Commands';'say /MSG 'nick' ............. User Commands ...............................';'say /MSG 'nick' ..DIR .................... List current directory.        .';'say /MSG 'nick' . LS ..................... Same as DIR, in unix style.    .';'say /MSG 'nick' . CD ([dirname]) ......... Change Directory.              .';'say /MSG 'nick' . ZDIR [zipfile] ......... List an Zip-Archive.           .';'say /MSG 'nick' . GET [filename] ......... Download request a file        .';'say /MSG 'nick' . ADD [filename] ......... Add file to hold (asterix"*"!) .';'say /MSG 'nick' . REMH [filename] ........ Remove file from hold          .';'say /MSG 'nick' . DIRH ................... List files in hold             .';'say /MSG 'nick' . GETH ([ZIP/LHA] def=LHA) Download hold.                 .';'say /MSG 'nick' . WHO .................... Who is on the server           .';'say /MSG 'nick' . SAY/NO [nr] [message] .. Send message to an online user .';'say /MSG 'nick' . RATIO/CREDIT ........... Show current Ratio             .';'say /MSG 'nick' . ABOUT .................. This script                   ..';'say /MSG 'nick' ...........................................................';wlog('HELP User 'nick);end;if (uword1=='@#401') then;do;'say /MSG 'master' 'n': 'nick' WHO-';getdcc;do i=1 to dcc.chat.0;'say /MSG 'nick dcc.chat.i;end;wlog('WHO       'nick);end;if (uword1=='DIR')|(uword1=='LS') then;do;if uword1=='DIR' then wlog('DIR       'nick' -  'user.n.curd' ');if uword1=='LS' then wlog('LS        'nick' -  'user.n.curd' ');if ~(upper(nick)==upper(master)) then if (uword1=='DIR') then 'say /MSG 'master' 'n': 'nick' DIR 'user.n.curd;if ~(upper(nick)==upper(master)) then if (uword1=='LS') then 'say /MSG 'master' 'n': 'nick' LS 'user.n.curd;'say /MSG 'nick' ['upper(user.n.curd)'] Credits: 'user.n.cred;'say /MSG 'nick' -------------------------------------';ADDRESS COMMAND 'c:list >t:fdir.tmp 'fdir||user.n.curd' LFORMAT "%n %l"';ADDRESS COMMAND 'c:sort >nil: t:fdir.tmp t:fdir.tmp';open(dir,'t:fdir.tmp',r);if (uword1=='DIR') then;do forever;line=readln(dir);IF EOF(dir) then leave;IF word(line,2)=='Dir' then 'say /MSG 'nick' ->'bold''upper(word(line,1))||bold'/';end;i=4;dummy='';if (uword1=='LS') then;do forever;line=readln(dir);IF EOF(dir) then leave;IF word(line,2)=='Dir' then;do;i=i+1;if (i==5) then;do;i=1;'say /MSG 'nick' 'dummy;dummy='';end;IF word(line,2)=='Dir' then;do;allign(upper(word(line,1))'/',16,0,' ');dummy=dummy||bold||result||bold;end;end;end;if (uword1=='LS')&~(i==1) then 'say /MSG 'nick' 'dummy;close(dir);open(dir,'t:fdir.tmp',r);if (uword1=='DIR') then;do forever;line=readln(dir);IF EOF(dir) then leave;IF word(line,2) ~='Dir' then;do;'say /MSG 'nick' 'word(line,1)'          'word(line,2)'b';end;end;i=4;dummy='';if (uword1=='LS') then;do forever;line=readln(dir);IF EOF(dir) then leave;i=i+1;if (i==5) then;do;i=1;IF word(line,2) ~='Dir' then;do;'say /MSG 'nick' 'dummy;dummy='';end;end;IF word(line,2) ~='Dir' then;do;allign(upper(word(line,1)),16,0,' ');dummy=dummy||result;end;end;if (uword1=='LS')&~(i==1) then 'say /MSG 'nick' 'dummy;close(dir);ADDRESS COMMAND 'c:delete t:fdir.tmp';'say /MSG 'nick' _-_-/- End of list -\-_-_';end;if uword1=='ZDIR' then;do;if ~(uword2=='') then;do;if ~(upper(nick)==upper(master)) then 'say /MSG 'master' 'n': 'nick' ZDIR 'user.n.curd||uword2;if exists(fdir||user.n.curd||uword2) then;do;wlog('ZDIR      'nick' - 'user.n.curd||word(mess,2));ADDRESS COMMAND 'c:unzip >t:zdir.tmp -l 'fdir||user.n.curd||uword2;'say /MSG 'nick' Contents of -> 'user.n.curd||word(mess,2);'say /MSG 'nick' ------------------------------------------------';open(zdir,"t:zdir.tmp",r);do until eof(zdir);dummy=readln(zdir);if word(dummy,1)=='------' then break;end;do until eof(zdir);dummy=readln(zdir);if word(dummy,1)=='------' then break;allign(word(dummy,4),16,0,' ');'say /MSG 'nick' 'result'   'word(dummy,1);end;close(zdir);ADDRESS COMMAND 'c:delete t:zdir.tmp quiet';'say /MSG 'nick' _-_-/- End of list -\-_-_';end;else;do;wlog('ZDIR fail 'nick' - 'user.n.curd||word(mess,2))' File not found.';"say /MSG "nick" ERROR: File doesn't exist";end;end;else;do;wlog('ZDIR fail 'nick' - No filename specified..');"say /MSG "nick" ERROR: You must specify filename.";"say /MSG "nick" Usage: ZDir [filename]";end;end;if (uword1=='ADD')&~(words(mess)==1) then;do;wlog('ADD       'nick' - 'uword2);if ~(upper(nick)==upper(master)) then 'say /MSG 'master' 'n': 'nick' ADD 'uword2;asterix(fdir||user.n.curd,uword2);if ~(OUTLIST.0==0) then;do j=1 to OUTLIST.0;dummy=statef(fdir||user.n.curd||OUTLIST.j);parse var dummy ftype fsize fblk fbits fday fmin ftick fcom .;if ftype=='FILE' then;do;found=0;if user.n.hold.0>0 then;do i=1 to user.n.hold.0;if (user.n.hold.i.fnam==OUTLIST.j) then;do;found=1;'say /MSG 'nick' Error: File 'OUTLIST.j' is allready in hold!';end;end;if ~found then;if ~((fsize+getUserHoldSize(n))>maxhold) then;do;user.n.hold.0=user.n.hold.0+1;i=user.n.hold.0;user.n.hold.i.fnam=upper(OUTLIST.j);user.n.hold.i.fpat=upper(fdir||user.n.curd);user.n.hold.i.fsiz=fsize;'say /MSG 'nick' Added 'OUTLIST.j' to hold.';end;else 'say /MSG 'nick' Can t add File 'OUTLIST.j' to hold. MaxFileSize-reached! ('maxhold'b)';end;end;else 'say /MSG 'nick' Error: File 'OUTLIST.j' doesn t exist!';drop OUTLIST.;end;if (uword1=='DIRH') then;do;if user.n.hold.0>0 then;do;wlog('DIRH      'nick' - ');if ~(upper(nick)==upper(master)) then 'say /MSG 'master' 'n': 'nick' - DIRH';len=0;do i=1 to user.n.hold.0;if (length(user.n.hold.i.fnam)>len) then len=length(user.n.hold.i.fnam);end;'say /MSG 'nick' You have 'user.n.hold.0' file(s) in hold:';'say /MSG 'nick' -----------------------------';total=0;do i=1 to user.n.hold.0;allign(user.n.hold.i.fnam,len,0," ");dummy=result;allign(user.n.hold.i.fsiz,9,1);dummy= dummy" "result;'say /MSG 'nick' 'dummy'b';total=total+user.n.hold.i.fsiz;end;'say /MSG 'nick' Total = 'total;'say /MSG 'nick' -- END of list --------------';end;else;do;'say /MSG 'nick' No files in hold!';wlog('DIRH      'nick' - failed');if ~(upper(nick)==upper(master)) then 'say /MSG 'master' 'n': 'nick' - DIRH (failed)';end;end;if (uword1=='REMH') then;do;nr=0;do i=1 to user.n.hold.0;if (user.n.hold.i.fnam==uword2) then nr=i;if (user.n.hold.i.fnam==uword2) then break;end;if ~(nr==0) then;do;wlog('REMH      'nick' - Removed 'uword2' from hold');if ~(upper(nick)==upper(master)) then 'say /MSG 'master' 'n': 'nick' - REMH 'uword2;'say /MSG 'nick' Removed 'user.n.hold.nr.fnam' from hold!';do i=nr to user.n.hold.0;i2=i+1;user.n.hold.i.fnam=user.n.hold.i2.fnam;user.n.hold.i.fpat=user.n.hold.i2.fpat;user.n.hold.i.fsiz=user.n.hold.i2.fsiz;end;user.n.hold.i2.fnam='';user.n.hold.i2.fpat='';user.n.hold.i2.fsiz='';user.n.hold.0=user.n.hold.0-1;end;else;do;'say /MSG 'nick' Error: 'uword2' was not in hold!';wlog('REMH      'nick' - failed removing 'uword2' from hold');if ~(upper(nick)==upper(master)) then 'say /MSG 'master' 'n': 'nick' - REMH 'uword2' (failed)';end;end;if (uword1=='GETH') then;do;if (uword2=='ZIP') then;do;if ~(user.n.hold.0==0) then;do;if ~(user.n.cred<GetUserHoldSize(n)) then;do;wlog('GETH ZIP  'nick' - Creating ZIP archive.');if ~(upper(nick)==upper(master)) then 'say /MSG 'master' 'n': 'nick' - GETH ZIP Compressing';'say /MSG 'nick' Compressing archive as ZIP-file.  The file will be sent to you as soon as it is ready.';holdnr=holdnr+1;do i=1 to user.n.hold.0;if ((uword2=="PK")|(uword3=="PK")) then ADDRESS COMMAND "zip -j "holddir"hold"holdnr" "user.n.hold.i.fpat||user.n.hold.i.fnam;else ADDRESS COMMAND "zip -j0 "holddir"hold"holdnr" "user.n.hold.i.fpat||user.n.hold.i.fnam;end;'say /DCC SEND 'nick' 'holddir'hold'holdnr'.zip';user.n.cred=user.n.cred-getUserHoldSize(n);user.n.hold.0=0;end;else 'SAY /MSG 'nick' Error: You need more credits!';end;else;do;'say /MSG 'nick' You have no files in hold!';wlog('GETH ZIP  'nick' - No files in hold.');if ~(upper(nick)==upper(master)) then 'say /MSG 'master' 'n': 'nick' - GETH ZIP (failed)';end;end;if (uword2=='')|(uword2=='LHA') then;do;if ~(user.n.hold.0==0) then;do;if ~(user.n.cred<GetUserHoldSize(n)) then;do;wlog('GETH LHA  'nick' - Creating LHA archive.');if ~(upper(nick)==upper(master)) then 'say /MSG 'master' 'n': 'nick' - GETH LHA Compressing';'say /MSG 'nick' Compressing LHA-archive.  The file will be sent to you as soon as it is ready.';holdnr=holdnr+1;do i=1 to user.n.hold.0;if (uword3=="PK") then ADDRESS COMMAND "lha a "holddir"hold"holdnr" "user.n.hold.i.fpat||user.n.hold.i.fnam;else ADDRESS COMMAND "lha -z a "holddir"hold"holdnr" "user.n.hold.i.fpat||user.n.hold.i.fnam;end;'say /DCC SEND 'nick' 'holddir'hold'holdnr'.lha';user.n.cred=user.n.cred-getUserHoldSize(n);user.n.hold.0=0;end;else 'SAY /MSG 'nick' Error: You need more credits!';end;else;do;'say /MSG 'nick' You have no files in hold!';wlog('GETH LHA  'nick' - No files in hold.');if ~(upper(nick)==upper(master)) then 'say /MSG 'master' 'n': 'nick' - GETH LHA (failed)';end;end;if (uword2=='LZX') then;do;if ~(user.n.hold.0==0) then;do;if ~(user.n.cred<GetUserHoldSize(n)) then;do;wlog('GETH LZX  'nick' - Creating LZX archive.');if ~(upper(nick)==upper(master)) then 'say /MSG 'master' 'n': 'nick' - GETH LZX Compressing';'say /MSG 'nick' Compressing LZX-archive.  The file will be sent to you as soon as it is ready.';holdnr=holdnr+1;do i=1 to user.n.hold.0;if (uword3=="PK") then ADDRESS COMMAND "lzx a "holddir"hold"holdnr" "user.n.hold.i.fpat||user.n.hold.i.fnam;else ADDRESS COMMAND "lzx -0 a "holddir"hold"holdnr" "user.n.hold.i.fpat||user.n.hold.i.fnam;end;'say /DCC SEND 'nick' 'holddir'hold'holdnr'.LZX';user.n.cred=user.n.cred-getUserHoldSize(n);user.n.hold.0=0;end;else 'SAY /MSG 'nick' Error: You need more credits!';end;else;do;'say /MSG 'nick' You have no files in hold!';wlog('GETH LZX  'nick' - No files in hold.');if ~(upper(nick)==upper(master)) then 'say /MSG 'master' 'n': 'nick' - GETH LZX (failed)';end;end;end;if (uword1=='/'|uword1=='CD..'|(uword1=='CD')&(uword2=='..')|(uword1=='CD')&(uword2=='/')) then;do;if ~(upper(nick)==upper(master)) then 'say /MSG 'master' 'n': 'nick' 'mess;if user.n.curd=='' then 'say /MSG 'nick' Error: You are on the lowest directory (jeeezez! ;)..';if user.n.curd ~='' then;do;parent(user.n.curd);user.n.curd=result;end;'say /MSG 'nick' ['user.n.curd']';end;if (uword1==':'|uword1=='CD\'|umess=='CD:'|(uword1=='CD')&(uword2=':')|(uword1='CD')&(uword2='\')) then;do;if ~(upper(nick)==upper(master)) then 'say /MSG 'master' 'n': 'nick' 'mess;user.n.curd='';'say /MSG 'nick' []';end;if (uword1=='CD')&(words(mess)==1) then;do;if ~(upper(nick)==upper(master)) then 'say /MSG 'master' 'n': 'nick' Path: ['user.n.curd']';'say /MSG 'nick' Path: ['user.n.curd']';end;if (words(mess)==2&uword1=='CD')&~(umess=='CD ..'|umess=='CD /'|umess=='CD :') then;do;dummy=strip(uword2,b,'/~()%#');if ~(dummy=='')&exists(fdir||user.n.curd|| dummy) then;do;user.n.curd=user.n.curd|| dummy'/';'say /MSG 'nick' ['user.n.curd']';if ~(upper(nick)==upper(master)) then 'say /MSG 'master' 'n': 'nick' 'mess;if exists(fdir||user.n.curd||'.fserve-dirdesc.dat') then;do;call open(desc,fdir||user.n.curd||'.fserve-dirdesc.dat',r);do until eof(desc);dummy=readln(desc);if ~eof(desc) then 'say /MSG 'nick' 'dummy;end;call close(desc);end;end;else;do;if ~(upper(nick)==upper(master)) then 'say /MSG 'master' 'n': 'nick' 'mess' (failed)';'say /MSG 'nick' "'mess'" Failed: Directory don t exist';end;end;if uword1='GET' then;do;dcc_checksend(user.n.name);'echo P=«AMSERV» C=4 SERV: dcc_checksend('user.n.name') -- user has: 'sendings' files sending';if sendings>=maxsend&words(mess)==2 then;do;'say /MSG 'nick' Error: You cant down more than 'maxsend' files at the time';if ~(upper(nick)==upper(master)) then 'say /MSG 'master' 'n': 'nick' MAXSENDS_exeed ('mess')';wlog('GET (MAX) 'nick' - 'user.n.curd||word(mess,2)' -MAXSENDEXEED');end;if sendings<maxsend&words(mess)==2 then;do;file=word(mess,2);ADDRESS COMMAND 'c:list >t:file.tmp 'fdir||user.n.curd||file' nohead';call OPEN(fl,"t:file.tmp",r);dum=readln(fl);dum=word(dum,2);if dum=='Dir' then dir=1;else dir=0;call CLOSE(fl);if exists(fdir||user.n.curd||file)&~dir then;do;ADDRESS COMMAND 'c:list >t:file.tmp 'fdir||user.n.curd||file' LFORMAT "%l"';open(1,'t:file.tmp');filesize=readln(1);close(1);dummysize=user.n.cred-filesize;if dummysize>=0 then;do;'say /DCC SEND 'nick fdir||user.n.curd||file;if ~(upper(nick)==upper(master)) then 'say /msg 'master' 'n': 'user.n.name '-- Get' user.n.curd||file 'remain:' dummysize'b';user.n.cred=user.n.cred-filesize;wlog('GET       'nick' - 'user.n.curd||file '('filesize'b) Credsleft:'user.n.cred'b');nr=handleusers(5,user.n.name);handleusers(1,nr);USHAN.credsleft=user.n.cred;handleusers(3,nr);end;if dummysize<0 then;do;wlog('GET (LOW) 'nick' - 'user.n.curd||file '('filesize'b) Credsleft:'user.n.cred'b -CREDS TOO LOW');'say /MSG 'nick' not enough credits for 'filesize' (creds:'user.n.cred'b)';end;ADDRESS COMMAND 'c:delete >nil: t:file.tmp';end;else 'say /MSG 'nick' file not found';end;end;if (uword1=='RATIO')|(uword1=='CREDIT') then;do;if ~(upper(nick)==upper(master)) then 'say /MSG 'master' 'n': 'nick' RATIO - 1:'ratio' 'user.n.cred'b';'say /MSG 'nick' creds: 'user.n.cred'b - ratio 1:'ratio;wlog('RATIO     'nick' creds: 'user.n.cred'b - ratio 1:'ratio);end;if (uword1=='WHO')|(uword1=='W') then;do;if ~(upper(nick)==upper(master)) then 'say /MSG 'master' 'n': 'nick' WHO';"GETDCC";do n=1 to DCC.CHAT.0;parse value dcc.chat.n WITH dummy state hostname .;if state==2 then;do;allign(n,2,1,'0');n2=result;if upper(dummy)==upper(master) then dummy2=bold'ONLINE: #'n2' 'dummy||bold' (Master)';else dummy2='ONLINE: #'n2' 'dummy;ups=0;if dcc.receive.0>0 then;do i=1 to dcc.receive.0;parse value dcc.receive.i WITH nickname moveflag hostname state length cps filename .;if (upper(dummy)==upper(nickname))&(state==0|state==1|state==2) then ups=ups+1;end;downs=0;if dcc.send.0>0 then;do i=1 to dcc.send.0;parse value dcc.send.i WITH nickname moveflag hostname state length cps filename .;if (upper(dummy)==upper(nickname))&(state==0|state==2) then downs=downs+1;end;'say /MSG 'nick' 'dummy2' ups:'ups' downs:'downs;end;end;wlog('WHO       'nick' - Who s on..');end;if (uword1=='SAY')|(uword1=='NO') then;do;"GETDCC";if (dcc.chat.0>=uword2) then;do;parse value dcc.chat.uword2 WITH dummy state hostname .;if (state==2) then;do;dummy2='';do i=1 to words(mess)-2;dummy2= dummy2' 'word(mess,i+2);end;'say /MSG 'dummy' 'bold'*'nick'*'bold||dummy2;'say /MSG 'nick' Message sent to 'dummy'.';if ~(upper(dummy)==upper(master))&~(upper(nick)==upper(master)) then 'say /MSG 'master' 'n': 'nick' SAY 'nick'->'dummy' 'dummy2;wlog('SAY       'nick' -> 'dummy' 'dummy2);end;else;do;'say /MSG 'nick' Error: User not connected to server..';if ~(upper(nick)==upper(master)) then 'say /MSG 'master' 'n': 'nick' SAY (failed, user not connected)';wlog('SAY       'nick' - failed, user not connected.');end;end;else;do;'say /MSG 'nick' ERROR: No user at that node.';if ~(upper(nick)==upper(master)) then 'say /MSG 'master' 'n': 'nick' SAY (failed, number too high)';wlog('SAY       'nick' - Number too high.');end;end;if (uword1=='ABOUT') then;do;"GETVERSION";vers=result;'say /MSG 'nick' ....... ABOUT .....................................';'say /MSG 'nick' . 'bold||version.navn' ('version.dattto') ';'say /MSG 'nick' . - The IRC File Server for The AMIGA ';'say /MSG 'nick' . ';'say /MSG 'nick' . - Running under: AmIRC 'vers;'say /MSG 'nick' . - AmServ is email-ware, so please send an';'say /MSG 'nick' .   email if you have reports or dislikes about it';'say /MSG 'nick' . - Thanks to: Olli for AmIRC2.0. CybrFahre';'say /MSG 'nick' .   and Frank Meyer-Pfauder for help and Ideas.';'say /MSG 'nick' . ';'say /MSG 'nick' . Written by Hans Petter Dalsklev, ©1997-©2000 ';'say /MSG 'nick' .            email: hanspd@powertech.no ';'say /MSG 'nick' ...................................................';if ~(upper(nick)==upper(master)) then 'say /MSG 'master' 'n': 'nick' ABOUT';wlog('ABOUT     'nick);end;return 0;domastercommand:;if (uword1=='!?') then;do;'say /MSG 'nick' ................ Operator Commands .......................';'say /MSG 'nick' . Join/Part [#channel] ...... Join or part a Channel     .';'say /MSG 'nick' . ShowChannels .............. Show joined channels       .';'say /MSG 'nick' . Advert [] ................. Advertise in all Ch.       .';'say /MSG 'nick' . Advert [#ch1 #ch2...] ..... Advertise in given Ch      .';'say /MSG 'nick' . ShutD [mins] .............. Warn user about shutdown   .';'say /MSG 'nick' . Kick [nick] ............... Kill connection to user    .';'say /MSG 'nick' . Close [nick] [filename] ... Stop a users download      .';'say /MSG 'nick' . GC [bytes] ................ GiveCredits to user nr     .';'say /MSG 'nick' . Connect [nick] ............ Connect a user to server       .';'say /MSG 'nick' . CleanUpUsers [minbytes].... keep users with x or more bytes         .';'say /MSG 'nick' . MakeFilelists ............. Create filelists to reject unwanted ups .';'say /MSG 'nick' . Set? ..... ................ List the config commands       .';'say /MSG 'nick' . QUIT [ShutdownMsg] ........ Shut down file server      .';'say /MSG 'nick' ..........................................................';wlog('HELP Op   'nick);end;if (uword1=='SET?') then;do;'say /MSG 'nick' .......... Operator Commands - Configuration .............';'say /MSG 'nick' . SetServer [name] .......... Rename Server (not nick)   .';'say /MSG 'nick' . SetMaster [nick] .......... Set master nick, caution!  .';'say /MSG 'nick' . SetTrigger [word] ......... Set new trigger keyword    .';'say /MSG 'nick' . SetFDir [path] ............ Set new files path.        .';'say /MSG 'nick' . SetUserfile [path+file] ... Set new Userfile path.     .';'say /MSG 'nick' . SetLogfile [path+file] .... Set new LogFile path.      .';'say /MSG 'nick' . SetRatio [nr] ............. Set new ratio 1:nr.        .';'say /MSG 'nick' . SetCredits [bytes] ........ Set newuser credits        .';'say /MSG 'nick' . SetMaxSend [nr] ........... Set max downloads pr.user. .';'say /MSG 'nick' . SetMaxUps [nr] ............ Set max uploads pr.user.   .';'say /MSG 'nick' . SetNotice [ON/OFF] ........ Set notice on join/part.   .';'say /MSG 'nick' . SetMaxUsers [nr] .......... Set maximum user-slots     .';'say /MSG 'nick' . SetHoldDir [path] ......... Set hold s temp dir       .';'say /MSG 'nick' . SetMaxHold [bytes] ........ Set maximum size in hold   .';'say /MSG 'nick' . SetAdvertLine [line] ...... Set advertline: %n=.....   .';'say /MSG 'nick' . SetAdvChans [chan1] [chan2] Set channels to advertize. .';'say /MSG 'nick' . SetAdvChans ALL ........... Set advertice all channels..';'say /MSG 'nick' . SetTimer [secs] ........... Set interval for advertizer.';'say /MSG 'nick' . SetTimer 0 ................ Set interval OFF!          .';'say /MSG 'nick' . Info ...................... List config settings       .';'say /MSG 'nick' . SaveConfig ................ Save current settings.     .';'say /MSG 'nick' . RestoreConfig ............. Load settings from file    .';'say /MSG 'nick' ..........................................................';wlog('HELP OpCo 'nick);end;if (uword1=='SETSERVER') then;do;server=word(mess,2);wlog('SETSERVER 'nick' - 'server);'say /MSG 'master' Server name set to: 'server' .... (type saveconfig to save)';end;if (uword1=='SETMASTER') then;do;'say /MSG 'master' Server name set to: 'master' .... Now use this nick to access!..';master=word(mess,2);wlog('SETMASTER 'nick' - 'master);end;if (uword1=='SETTRIGGER') then;do;trigger=word(mess,2);'say /MSG 'master' Trigger keyword set to: 'trigger' .... (type saveconfig to save)';wlog('SETTRIGGR 'nick' - 'trigger);end;if (uword1=='SETFDIR') then;do;fdir=word(mess,2);dummy=substr(fdir,length(fdir),1);if ~(dummy=="/")&~(dummy==":") then fdir=fdir'/';'say /MSG 'master' Files dir set to: "'fdir'" .... (type saveconfig to save)';wlog('SETFILDIR 'nick' - 'fdir);end;if (uword1=='SETUSERFILE') then;do;usrfile=word(mess,2);'say /MSG 'master' Userfile set to: 'usrfile' .... (type saveconfig to save)';wlog('SETUSRFIL 'nick' - 'usrfile);end;if (uword1=='SETLOGFILE') then;do;wlog('SETLOGFIL 'nick' - 'logfile);logfile=word(mess,2);'say /MSG 'master' Userfile set to: 'usrfile' .... (type saveconfig to save)';end;if (uword1=='SETRATIO') then;do;ratio=uword2;'say /MSG 'master' 'n': 'user.n.name' Ratio = 1:'ratio' .... (type saveconfig to save)';wlog('SETRATIO  'nick' - 'ratio);end;if (uword1=='SETCREDITS') then;do;credits=uword2;'say /MSG 'master' New User Credits set to: 'credits'b .... (type saveconfig to save)';wlog('SETCREDIT 'nick' - 'credits);end;if (uword1=='SETMAXSEND') then;do;maxsend=uword2;'say /MSG 'master' Max downloads pr.user set to: 'maxsend' file(s) .... (type saveconfig to save)';wlog('SETMAXSND 'nick' - 'maxsend);end;if (uword1=='SETMAXUPS') then;do;maxups=uword2;'say /MSG 'master' Max uploads pr.user set to: 'maxups' file(s) .... (type saveconfig to save)';wlog('SETMAXUPS 'nick' - 'maxups);end;if (uword1=='SETNOTICE') then;do;if (uword2=="ON") then notice=1;if (uword2=="OFF") then notice=0;if (uword2=="ON")|(uword2=="OFF") then;do;IF notice then;do;'say /MSG 'master' Notice = ON .... (type saveconfig to save)';wlog('SETNOTICE 'nick' - ON');end;else;do;'say /MSG 'master' Notice = OFF .... (type saveconfig to save)';wlog('SETNOTICE 'nick' - OFF');end;end;else 'say /MSG 'master' ERROR: Notice is set either ON or OFF';end;if (uword1=='SETMAXUSERS') then;do;maxusers=uword2;'say /MSG 'master' 'n': 'user.n.name' Maxusers = 'maxusers' .... (type saveconfig to save)';wlog('SETMAXUSE 'nick' - Maximum user-slots set to: 'maxusers);end;if (uword1=='SETHOLDDIR') then;do;holddir=word(mess,2);'say /MSG 'master' Hold dir set to: "'holddir'" .... (type saveconfig to save)';wlog('SETFILDIR 'nick' - 'holddir);end;if (uword1=='SETMAXHOLD') then;do;maxhold=uword2;'say /MSG 'master' 'n': 'user.n.name' Maxhold = 'maxhold'b (must be in bytes).... (type saveconfig to save)';wlog('SETMAXHLD 'nick' - Maxhold set to: 'maxhold);end;if (uword1=='SETADVERTLINE') then;do;advertline=substr(mess,15,length(mess)-14);'say /MSG 'master' 'n': Advertline = 'advertline'  .... (type saveconfig to save)';wlog('SETADVLIN 'nick' - 'advertline);end;if (uword1=='SETADVCHANS') then;do;if words(umess)>1&~(uword2=='ALL') then;do;advchans='';do i=2 to words(umess);advchans=advchans' 'word(mess,i);end;'SAY /MSG 'master' Channel-adverticer set to: 'advchans;wlog('ADVCHANS   'advchans);end;if uword2=='ALL' then;do;advchans='';'SAY /MSG 'master' Channel-adverticer set to: ALL CHANNELS.';wlog('ADVCHANS   ALL CHANNELS');end;end;if (uword1=='SETTIMER') then;do;if uword2>0 then;do;autotimer=uword2;'say /MSG 'master' timer set to 'autotimer's';wlog('AUTOTIMER 'autotimer' secounds');end;else;do;autotimer=uword2;'say /MSG 'master' timer shut OFF';wlog('AUTOTIMER shut off');end;end;if (uword1=='INFO') then;do;'SAY /MSG 'master' config: Servername = 'server;'SAY /MSG 'master' config: Masternick = 'master;'SAY /MSG 'master' config: Trigger    = 'trigger;'SAY /MSG 'master' config: filesdir   = 'fdir;'SAY /MSG 'master' config: userfile   = 'usrfile;'SAY /MSG 'master' config: logfile    = 'logfile;'SAY /MSG 'master' config: Ratio      = 'ratio;'SAY /MSG 'master' config: startcreds = 'credits;'SAY /MSG 'master' config: maxsends   = 'maxsend;'SAY /MSG 'master' config: maxups     = 'maxups;IF notice then 'SAY /MSG 'master' config: Notice     = ON';else 'SAY /MSG 'master' config: Notice     = OFF';'SAY /MSG 'master' config: maxusers   = 'maxusers;'SAY /MSG 'master' config: holddir    = 'holddir;'SAY /MSG 'master' config: maxhold    = 'maxhold;'SAY /MSG 'master' config: advertline = 'advertline;if autotimer>0 then 'SAY /MSG 'master' config: autotimer  = 'autotimer;else 'SAY /MSG 'master' config: autotimer  = 'autotimer' (OFF)';if advchans=='' then 'SAY /MSG 'master' config: advchans   = ALL CHANNELS';else 'SAY /MSG 'master' config: advchans   = 'advchans;wlog('INFO      'nick);end;if (uword1=='SAVECONFIG') then;do;wlog('SAVECONFI 'nick' - Config saved');saveconfig();'say /MSG 'master' Config saved!';end;if (uword1=='RESTORECONFIG') then;do;if exists(AMIRC_DIR"rexx/AmServ.config") then;do;call open(conff,AMIRC_DIR"Rexx/AmServ.config",r);line=readln(conff);if (line=='AmServ config file') then;do;server=readln(conff);master=readln(conff);trigger=readln(conff);fdir=readln(conff);usrfile=readln(conff);logfile=readln(conff);ratio=readln(conff);credits=readln(conff);dummy=readln(conff);notice=readln(conff);maxusers=readln(conff);holddir=readln(conff);maxhold=readln(conff);advertline=readln(conff);autotimer=readln(conff);advchans=readln(conff);conf7=readln(conff);conf8=readln(conff);call close(conff);parse var dummy maxsend' 'maxups;if (maxups=='') then maxups=3;if autotimer='CONF5' then autotimer=0;if advchans=='CONF6' then advchans='';wlog('RESTORCNF 'nick' - Config restored');'say /MSG 'master' Config loaded!';end;else;do;'say /MSG 'master' ERROR: Can t reqognize configfile.';'say /MSG 'master' ------ delete the file manually and try again. sorry!';"echo P=«AMSERV» C=4 ERROR: Can't reqognize configfile.";"echo P=«AMSERV» C=4 delete the file manually and try again. sorry!";wlog('RESTORCNF 'nick' - ERROR: Config not reqognized');end;end;else;do;'say /MSG 'master' ERROR: Can t find configfile.';wlog('RESTORCNF 'nick' - ERROR: Configfile not found');end;end;if (uword1=='JOIN') then;do;'say /join 'word(mess,2);'say /MSG 'master' JOIN: 'word(mess,2);wlog('JOIN      'nick' - Joined: 'word(mess,2));end;if (uword1=='PART') then;do;'say /part 'word(mess,2);'say /MSG 'master' PART: 'word(mess,2);wlog('PART      'nick' - Parted: 'word(mess,2));end;if (uword1=='SHOWCHANNELS') then;do;"CHANNELS";dummy=result;'say /MSG 'master' 'server' is in 'dummy;wlog('SHOWCHANS 'nick' - Current channels: 'dummy);end;if (uword1=='MAKEFILELISTS') then;do;'say /MSG 'master' Making filelists in the background. This can take a while, but the server will run normally. I will work on automatisation in future release of AmServ. Read docs for hint of use.';wlog('MAKELISTS 'nick' - Making filelists');ADDRESS COMMAND "c:run list "fdir" ALL NOHEAD FILES QUICK >"serverlist_filename;ADDRESS COMMAND "c:run list ram:#? NOHEAD FILES QUICK >"uploadlist_filename;end;if (uword1=='GC') then;do;n=word(mess,2);test= datatype(word(mess,2),'N')& datatype(word(mess,3),'N');if test then;do;'say /MSG 'master' Credits to 'n': 'user.n.name word(mess,3)' -> new:'user.n.cred+word(mess,3);'say /MSG 'user.n.name' Given credits from fserve-operator: 'word(mess,3)' (new:'user.n.cred+word(mess,3)')';user.n.cred=user.n.cred+word(mess,3);nr=handleusers(5,user.n.name);handleusers(1,nr);USHAN.credsleft=user.n.cred;handleusers(3,nr);wlog('GIVECREDS 'nick' - Gave 'word(mess,3)'b to: 'user.n.name);end;else;do;'say /MSG 'master' Error: You must write a number in bytes.';wlog('GIVECREDS 'nick' - failed, need numbers not words');end;end;if (uword1=='CLOSE') then;do;"GETDCC";do i=1 to dcc.send.0;parse value dcc.send.i WITH nickname moveflag hostname state length cps filename .;do j=1 to length(filename);char=substr(filename,j,1);if (char==':')|(char=='/') then k=j;end;filename=substr(filename,k+1,length(filename)-k);if (state==0|state==2)&upper(nickname)==uword2&upper(filename)==uword3 then;do;'say /DCC CLOSE SEND 'nickname filename;'say /MSG 'master' File: 'filename' ('length'b) 'cps'cps stopped.';wlog('CLOSESEND 'nickname' - 'filename' ('length'b) 'cps'cps stopped.');end;end;end;if (uword1=='CLOSEUP') then;do;"GETDCC";do i=1 to dcc.receive.0;parse value dcc.receive.i WITH nickname moveflag hostname state length cps filename .;do j=1 to length(filename);char=substr(filename,j,1);if (char==':')|(char=='/') then k=j;end;filename=substr(filename,k+1,length(filename)-k);'say /MSG 'master i': 'nickname filename state length cps;if (state==0|state==2)&upper(nickname)==uword2&upper(filename)==uword3 then;do;'say /DCC close GET 'nickname filename;'say /MSG 'master' File: 'filename' ('length'b) 'cps'cps stopped!';wlog('CLOSERECV 'nickname' - 'filename' ('length'b) 'cps'cps stopped.');end;end;end;if (uword1=='KICK') then;do;"GETDCC";do i=1 to dcc.chat.0;parse value dcc.chat.i WITH nick state hostname .;if (state==2) then;do;if upper(nick)==uword2 then;do;'say /MSG 'nick' Connection closed by operator.';'say /DCC CLOSE CHAT 'nick;'say /MSG 'master' 'i': 'nick' - Connection closed by operator';wlog('KICKUSER  'nickname);end;end;end;end;if (uword1=='CONNECT') then;do;nick=word(mess,2);host='manually connected';'say /MSG 'master' joining!';connect_user();wlog('OPCONNECT 'nick' - Connecting 'nick);end;if (uword1=='ADVERT') then;do;wlog('ADVERT    'nick' - Advertised');"CHANNELS";channel=result;if words(channel)>0 then;do;if words(mess)>1 then;do j=1 to words(mess)-1;do i=1 to words(channel);if upper(word(channel,i))==upper(word(mess,j+1)) then;do;replacer(advertline);'say /MSG 'word(mess,j+1)' 'result;end;if upper(word(channel,i))==upper(word(mess,j+1)) then 'say /MSG 'master' Advertised in 'word(mess,j+1);end;end;else;do;do i=1 to words(channel);replacer(advertline);'say /MSG 'word(channel,i)' 'result;'say /MSG 'master' advertised in 'word(channel,i)' !';end;end;end;else 'say /MSG 'master' ERROR: Join a channel first';end;if (uword1=='CLEANUPUSERS') then;do;if ~(uword2=="") then;do;'say /MSG 'master' Cleaning up userfile!';minbytes=uword2;call open(cf,usrfile,r);usersd=0;usersdleft=0;drop newd.;newd.="";i=1;do forever;i=1;dummy=readln(cf);if dummy=='' then leave;parse var dummy nick'©®©'host'©®©'dumy1'©®©'dumy2'©®©'creds'©®©'dumy3'©®©'dumy4;usersd=usersd+1;if (creds>=minbytes)|(creds<0) then;do;if creds<0 then say nick" has minus credits";usersdleft=usersdleft+1;newd.usersdleft=nick'©®©'host'©®©'dumy1'©®©'dumy2'©®©'creds'©®©'dumy3'©®©'dumy4;end;end;call close(cf);if exists(usrfile".old") then ADDRESS COMMAND "c:delete "usrfile".old quiet";ADDRESS COMMAND "C:rename "usrfile" "usrfile".old";call open(cf,usrfile,w);do i=1 to usersdleft;call writeln(cf,newd.i);end;call close(cf);drop newd;'say /MSG 'master' 'usersdleft' kept from 'usersd' total users. Kept users with 'minbytes' bytes or more.';wlog('CLEANUSRF 'master' - Kept  users');end;else 'say /MSG 'master' You must specify minimum bytes to users you want to keep. ("!?" for help).';end;if (uword1=='SHUTD') then;do;if words(mess)==2 then;do;"GETDCC";do n=1 to DCC.CHAT.0;parse value dcc.chat.n WITH nick state hostname .;if (state==2)&~(upper(nick)==upper(master)) then;do;'say /MSG 'nick' 'bold'WARNING: Shutdown in 'word(mess,2)' minutes.'bold;'say /MSG 'master' Warned: 'nick;end;end;wlog('SHUTDOWN  'master' - Shutdown in 'word(mess,2)' minutes');end;else 'say /MSG 'master' ERROR: ..USAGE: shutd [nr_of_mins]';end;return 0;parseline:;parse var LINE ':' nick '!';host=word(LINE,1);parse var host '!' host;what=word(LINE,2);to=word(LINE,3);parse var LINE ': :' mess;parse var LINE ':' dummy ':' mess;uword1=upper(word(mess,1));uword2=upper(word(mess,2));uword3=upper(word(mess,3));umess=upper(mess);return 0;checkuploads:;'getdcc';if (dcc.receive.0>0)&(receivejobs.0>0) then;do i=1 to dcc.receive.0;parse value dcc.receive.i WITH nickname moveflag hostname state length cps filename .;k=0;do j=1 to length(filename);char=substr(filename,j,1);if (char==':')|(char=='/') then k=j;end;filename=substr(filename,k+1,length(filename)-k);do u=1 to receivejobs.0;if (receivejobs.u.fil==upper(filename))&(receivejobs.u.nic==upper(nickname)) then;do;if (state==3) then;do;test=0;do n=1 to dcc.chat.0;if upper(user.n.name)==upper(nickname) then test=1;if test then;do;user.n.cred=user.n.cred+length*ratio;nr=handleusers(5,user.n.name);call handleusers(1,nr);USHAN.credsleft=user.n.cred;call handleusers(3,nr);'say /MSG 'nickname' Thank you for sending 'filename' . Your credits: 'user.n.cred;if ~(upper(nickname)==upper(master)) then 'say /MSG 'master' 'n': 'user.n.name' Upload of 'filename' completed! (new:'user.n.cred')';wlog('UPLOAD    'user.n.name' - Upload of 'filename' ('length'b) complete.');end;if test then leave;end;if ~(test) then;do;nr=handleusers(5,nickname);if (nr==0) then;do;nick=nickname;credits=length*ratio;host=hostname;handleusers(2);'say /MSG 'nickname' Thank you for sending 'filename' . Your credits: 'credits;if ~(upper(nickname)==upper(master)) then 'say /MSG 'master' x: 'nick' Upload of 'filename' completed! (new user) (new:'user.n.cred')';wlog('UPLOAD    'nickname' - Upload of 'filename' ('length'b) complete. (user was new)');end;if (nr>0) then;do;call handleusers(1,nr);USHAN.credsleft=USHAN.credsleft+length*ratio;call handleusers(3,nr);'say /MSG 'nickname' Thank you for sending 'filename' . Your credits: 'USHAN.credsleft;if ~(upper(nickname)==upper(master)) then 'say /MSG 'master' x: 'nick' Upload of 'filename' completed! (user offline) (new:'user.n.cred')';wlog('UPLOAD    'nickname' - Upload of 'filename' ('length'b) (user not online)');end;end;if u==receivejobs.0 then receivejobs.0=u-1;if u<receivejobs.0 then;do;receivejobs.0=receivejobs.0-1;do j=u to receivejobs.0;jj=j+1;receivejobs.j.nic=receivejobs.jj.nic;receivejobs.j.fil=receivejobs.jj.fil;end;end;end;if (state>3) then;do;'say /MSG 'nickname' Upload of file: 'filename' ('length') failed!  tell 'master' (the operator) to remove it before uploading again';if ~(upper(nickname)==upper(master)) then 'say /MSG 'master' Upload of file: 'filename' ('length') failed! (remove it!)';wlog('UPLOAFAIL 'nickname' - 'filename' ('length'b) failed.');if u==receivejobs.0 then receivejobs.0=u-1;if u<receivejobs.0 then;do;receivejobs.0=receivejobs.0-1;do j=u to receivejobs.0;jj=j+1;receivejobs.j.nic=receivejobs.jj.nic;receivejobs.j.fil=receivejobs.jj.fil;end;end;end;end;end;end;return 0;getupload:;'GETDCC';dcc_checkups(nick);if receivings>=maxups then;do;'say /MSG 'nick' ERROR: You are uploading too many files, rejecting..';if ~(upper(nick)==upper(master)) then 'say /MSG 'master' 'n': 'nick' Incomming file rejected (TOO MANY UPS): 'uword3;wlog('UPRTOMANY 'nick' - Upload of file: 'uword3', rejected! Too many sim.');'say /DCC CLOSE SEND 'nick' 'uword3;return 0;end;if exists(serverlist_filename) then;do;ADDRESS COMMAND searcher" >T:amserv_fileexist_serv FROM "serverlist_filename" SEARCH "uword3" nonum";call open(fexist,"T:amserv_fileexist_serv",r);do until eof(fexist);dummy=upper(readln(fexist));if dummy==uword3 then;do;'say /MSG 'nick' ERROR: File 'uword3' allready exists on server. Try uploading something else.';if ~(upper(nick)==upper(master)) then 'say /MSG 'master' 'n': 'nick' Incomming file rejected (EXISTS ON SERVER): 'uword3;wlog('UPREXISTS 'nick' - Upload of file: 'uword3', rejected! Exists on server');call close(fexist);ADDRESS COMMAND "c:delete T:amserv_fileexist_serv quiet >NIL:";return 0;end;end;call close(fexist);ADDRESS COMMAND "c:delete t:amserv_fileexist_serv quiet >NIL:";end;if exists(uploadlist_filename) then;do;ADDRESS COMMAND searcher" >T:amserv_fileexist_upload FROM "uploadlist_filename" SEARCH "uword3" nonum";call open(fexist,"T:amserv_fileexist_upload",r);do until eof(fexist);dummy=upper(readln(fexist));if dummy==uword3 then;do;'say /MSG 'nick' ERROR: File 'uword3' allready exists on server. Try uploading something else.';if ~(upper(nick)==upper(master)) then say '/MSG 'master' 'n': 'nick' Incomming file rejected (EXISTS IN UPDIR): 'uword3;wlog('UPREXISTS 'nick' - Upload of file: 'uword3', rejected! Exists in updir');call close(fexist);ADDRESS COMMAND "c:delete T:amserv_fileexist_upload quiet >NIL:";return 0;end;end;call close(fexist);ADDRESS COMMAND "c:delete T:amserv_fileexist_upload quiet >NIL:";end;'say /DCC GET 'nick' 'uword3;wlog('INCOMMING 'nick' - Incomming file: 'uword3);if exists(uploadlist_filename) then;do;call open(fil,uploadlist_filename,a);call writeln(fil,uword3);call close(fil);end;i=1+receivejobs.0;receivejobs.i.nic=upper(nick);receivejobs.i.fil=uword3;receivejobs.0=i;return 0;dcc_checksend:procedure expose sendings;sendings=0;'GETDCC';if dcc.send.0>0 THEN;DO i=1 TO dcc.send.0;parse value dcc.send.i WITH nick moveflag hostname state length cps filename .;if ((state=2|state=0)&upper(nick)=upper(arg(1))) then sendings=sendings+1;end;return 0;dcc_checkups:procedure expose receivings;receivings=0;'GETDCC';if dcc.receive.0>0 THEN;DO i=1 TO dcc.receive.0;parse value dcc.receive.i WITH nick moveflag hostname state length cps filename .;if ((state=2)&upper(nick)=upper(arg(1))) then receivings=receivings+1;end;return 0;connect_user:;if getOnline()>=maxusers then;do;'raw NOTICE 'nick' :AmServ Busy, maximum users reached. Please try again later.';return 0;end;"getdcc";IF (dcc.chat.0>0) then;do i=1 to dcc.chat.0;parse value dcc.chat.i WITH dummy dummy2 dummy3 .;if ((dummy2==2)|(dummy2==3))&(upper(nick)==upper(dummy)) then;do;'raw NOTICE 'nick' :AmServ won t log you in twice!';RETURN 0;end;end;users=users+1;n=users;logging=logging' 'n;found=0;do m=1 until found;found=(user.m.name=nick);if found then leave;if m>dcc.chat.0 then leave;end;if m<=dcc.chat.0 then user.m.curd='';user.n.name=nick;user.n.host=host;user.n.cred=credits;user.n.curd='';user.n.hold='';user.n.hold.0=0;user.n.timer.0=time('s');'say /DCC CHAT 'nick;'say /NOTICE 'nick' ---> Connecting you to 'server'...';'say /MSG 'master' 'n': 'nick' is attempting to connect..';call delay(20);wlog('COMMINGIN 'nick);return 0;check_dcc_connect:;'getdcc';lognr=0;logloop=words(logging);loggingnew='';do while logloop>0;lognr=lognr+1;n=word(logging,lognr);stat=word(dcc.chat.n,2);if (stat=0)|(stat=1)|(stat=3) then loggingnew=loggingnew n;if stat=2 then connect_user_login();logloop=logloop-1;end;logging=loggingnew;return 0;connect_user_login:;parse value dcc.chat.n WITH nick state hostname .;wlog('CONNECTED 'nick' (DCC#'n')');'say /MSG 'nick '>>> 'version.navn' ('version.dattto'), ©1997-2000 by HP.Dalsklev';'say /MSG 'nick '~~~';if exists(AMIRC_DIR'Rexx/AmServ.login') then;do;call open(desc,AMIRC_DIR'Rexx/AmServ.login',r);do until eof(desc);dummy=readln(desc);'say /MSG 'nick' . 'dummy;end;call close(desc);end;else 'say /MSG 'nick' 'server' has no login-message.';'say /MSG 'nick 'Users connected: 'getOnline();nr=handleusers(5,nick);if ~(nr==0) then;do;handleusers(1,nr);user.n.cred=USHAN.credsleft;'say /MSG 'nick 'You are in the userlist, your credits: 'user.n.cred;end;else;do;host=hostname;handleusers(2);'say /MSG 'nick 'You are new to the userlist. The system gives you 'credits'b to play with!';end;if ~(upper(nick)==upper(master)) then 'say /MSG 'nick' You have USER-access!';else;do;'say /MSG 'nick' You have MASTER-access!';'say /MSG 'nick' "!?" for OperatorHelp, "set?" for Config commands.';end;'say /MSG 'nick' "?" for Help.';if ~(upper(nick)==upper(master)) then 'say /MSG 'master' 'n': 'nick' has joined 'Server;'say /MSG 'nick' Ready...';what='';return 0;handleusers:procedure expose nick dato LF host credits USHAN. usrfile result;if arg(1)==1 then;do;open(userfile,usrfile,r);if ~(arg(2)==1) then;do i=1 to arg(2)-1;dummy=readln(userfile);end;dummy=readln(userfile);close(userfile);parse var dummy USHAN.nicknm'©®©'USHAN.hostnm'©®©'USHAN.firston'©®©'USHAN.laston'©®©'USHAN.credsleft'©®©'USHAN.usrups'©®©'USHAN.usrdowns;return 0;end;if arg(1)==2 then;do;dato="";call open(userfile,usrfile,a);call writeln(userfile,nick'©®©'host'©®©'dato'©®©'dato'©®©'credits'©®©0©®©0');call close(userfile);return 0;end;if arg(1)==3 then;do;drop USRFIL;USRFIL.='';i=1;call open(userfile,usrfile,r);if ~(arg(2)==1) then;do i=1 to arg(2)-1;USRFIL.i=readln(userfile);end;dummy=readln(userfile);USRFIL.i=USHAN.nicknm'©®©'USHAN.hostnm'©®©'USHAN.firston'©®©'USHAN.laston'©®©'USHAN.credsleft'©®©'USHAN.usrups'©®©'USHAN.usrdowns;do while ~EOF(userfile);i=i+1;USRFIL.i=readln(userfile);end;i=i-1;call close(userfile);call open(userfile,usrfile,w);do j=1 to i;call writeln(userfile,USRFIL.j);end;call close(userfile);drop USRFIL;return 0;end;if arg(1)==4 then;do;drop USRFIL;USRFIL.='';i=1;call open(userfile,usrfile,r);if ~(arg(2)==1) then;do i=1 to arg(2)-1;USRFIL.i=readln(userfile);end;dummy=readln(userfile);i=i-1;do while ~EOF(userfile);i=i+1;USRFIL.i=readln(userfile);end;i=i-1;call close(userfile);call open(userfile,usrfile,w);do j=1 to i;call writeln(userfile,USRFIL.j);end;call close(userfile);drop USRFIL;return 0;end;if arg(1)==5 then;do;i=0;dummy2=upper(arg(2));call open(userfile,usrfile,r);do while ~EOF(userfile);i=i+1;dummy=readln(userfile);parse var dummy dummy'©®©';if (upper(dummy)==dummy2) then break;end;call close(userfile);if (upper(dummy)==dummy2) then return i;else return 0;end;return-1;autoadverttimer:;if autotimer>0 then;do;if (time('s')-timerfrom)>autotimer then;do;"CHANNELS";channel=result;if words(channel)>0 then;do;if words(advchans)>0 then;do j=1 to words(advchans);do i=1 to words(channel);if upper(word(channel,i))==upper(word(advchans,j)) then;do;replacer(advertline);'say /MSG 'word(advchans,j)' 'result;end;if upper(word(channel,i))==upper(word(advchans,j)) then 'say /MSG 'master' Advertised in 'word(advchans,j);end;end;else;do;do i=1 to words(channel);replacer(advertline);'say /MSG 'word(channel,i)' 'result;'say /MSG 'master' advertised in 'word(channel,i)' !';end;end;end;else 'SAY /MSG 'master' ERROR: did not auto-advertice. No Channels joined.';timerfrom=time('s');end;timenow=time('s')-timerfrom;if timenow<0 then timenow=timenow+86400;end;return 0;asterix:procedure expose OUTLIST.;dir=arg(1);key=arg(2);if exists(dir)&~(key=="") then;do;dummy='';asterix=0;do i=1 to length(key);char=substr(key,i,1);if char=='*' then;do;dummy= dummy'#?';asterix=1;end;else dummy= dummy||char;end;key= dummy;if asterix then;do;ADDRESS COMMAND "c:list >t:hold.tmp "dir||key" FILES LFORMAT %n";call open(tmp,"T:hold.tmp",r);i=0;drop OUTLIST.;OUTLIST.='';do forever;file=readln(tmp);if eof(tmp) then break;i=i+1;OUTLIST.i=upper(file);end;call close(tmp);ADDRESS COMMAND "c:delete t:hold.tmp quiet";OUTLIST.0=i;return 0;end;else;do;drop OUTLIST.;OUTLIST.='';if exists(dir||key) then;do;OUTLIST.0=1;OUTLIST.1=upper(key);return 0;end;else;do;OUTLIST.0=0;OUTLIST.1='';return 1;end;end;end;return 1;saveconfig:;call open(conff,AMIRC_DIR"Rexx/AmServ.config",w);call writech(conff,"AmServ config file"LF||server||LF||master||LF||trigger||LF||fdir||LF||usrfile||LF||logfile||LF||ratio||LF||credits||LF||maxsend' 'maxups||LF||notice||LF||maxusers||LF||holddir||LF||maxhold||LF||advertline||LF||autotimer||LF||advchans||LF||conf7||LF||conf8||LF);call close(conff);return 0;replacer:procedure expose result server master maxusers trigger ratio credits version.navn;line=arg(1);if length(line)==0 then return 1;new="";do i=1 to length(line);if substr(line,i,1)=="%" then;do;i=i+1;c=substr(line,i,1);if c=="n" then new=new||server;if c=="s" then new=new||master;if c=="o" then new=new||getOnline();if c=="m" then new=new||maxusers;if c=="t" then new=new||trigger;if c=="r" then new=new||"1:"ratio;if c=="c" then new=new||credits;if c=="v" then new=new||"["version.navn"]";if c=="d" then new=new||version.dattto;if c=="%" then new=new||"%";end;else new=new||substr(line,i,1);end;result=new;return 0;getOnline:procedure expose master;'GETDCC';nou=0;IF (dcc.chat.0>0) then;DO i=1 to DCC.CHAT.0;parse value dcc.chat.i WITH nick state hostname .;if ((state==1)|(state==2)|(state==3))&~(upper(nick)==upper(master)) then nou=nou+1;END;return nou;getUserHoldSize:;ret=0;if user.n.hold.0==0 then RETURN 0;do ii=1 to user.n.hold.0;ret=ret+user.n.hold.ii.fsiz;end;RETURN ret;checktimeouts:procedure expose user.;'getdcc';IF (dcc.chat.0>0) then;do i=1 to dcc.chat.0;parse value dcc.chat.i WITH nick state hostname .;if (state==3) then if (time('s')-user.i.timer.0)>=70 then;do;'say /DCC CLOSE CHAT 'nick;'echo P=«AMSERV» C=4 User 'i' 'nick' timed out.';end;end;return 0;wlog:;call OPEN(logf,logfile,a);call WRITELN(logf,dato timo arg(1));call CLOSE(logf);return 0;saveline:;if ~exists(arg(1)) then call open(tmp,arg(1),w);if exists(arg(1)) then call open(tmp,arg(1),a);call writeln(tmp,arg(2));call close(tmp);return 0;parent:procedure expose result;pos=length(arg(1));do until found;pos=pos-1;if pos=0 then leave;found='/'==substr(arg(1),pos,1);end;result=substr(arg(1),1,pos);return 0;allign:procedure expose result;string=arg(1);colls=arg(2);direct=arg(3);path=arg(4);if path=="" then path=" ";if direct==1 then;do i=(length(string)+1) to colls;string=path||string;end;if direct==0 then;do i=(length(string)+1) to colls;string=string||path;end;result=string;return 0