Processing table: prc.download_file




 
If:
 

 
 
Then:
2=@td;3=@tm;write

 
If:
 

 
 
Then:
declare global ErrMsg,ErrReturn(8,*),OutFile(256,*),FString,FileID,UpRestrict(1,YESNO),TypeFile(256,*),MimeType

 
If:
 

 
 
Then:
declare global UName,Pass,FName,LName,Email,URL,SessID,Expire,SIDString,PEncode,SessUName,FileRoot,UpOwner(12,ALLUP)

 
If:
 

 
 
Then:
declare global UpReal,UpOrig,UpSize,UpDest,UpBase,RmBase,SUpdate(1,YESNO),Deleted(1,YESNO),UpPass,OUpPass

 
If:
 

 
 
Then:
declare OHandle(4,.0),Msg,IHandle(4,.0),SelfURL,Style,Pre,FPos(20,.0),FLine

 
If:
 

 
 
Then:
declare Cookie,CLUName,CLPass

 
If:
 

 
 
Then:
declare global CookiePresent(1,YESNO),PassThru(1,YESNO),PrePass

 
If:
 

 
 
Then:
declare FControl(20,.0)

 
If:
 

 
 
Then:
ErrReturn="NOT DONE"

 
If:
 

 
 
Then:
OutFile=getenv("ONEGATE_OUTFILE");TypeFile=getenv("ONEGATE_MIMEFILE")

 
If:
 

 
 
Then:
declare global OGParseResult(4,*)

 
If:
 

 
 
Then:
call "onegate/ogcgixml"

 
If:
OGParseResult eq "FAIL"

 
 
Then:
ErrMsg="OGCGIXML Parse Failed.";call "generr"

 
If:
ErrReturn eq "DONE"

 
 
Then:
goto myexit

 
If:
 

 
 
Then:
UpPass=""

 
If:
 

 
 
Then:
lookup cgi = onegate k=@PW i=A -npx

If:
not cgi

 
 
Then:
close cgi;goto postcgi

 
If:
cgi(1) ne @PW

 
 
Then:
close cgi;goto postcgi

 
If:
cgi(2) eq "session" and cgi(8) eq "N"

 
 
Then:
SessID=cgi(3)

 
If:
cgi(2) eq "flfsslog" and cgi(8) eq "Y"

 
 
Then:
Cookie=cgi(3)

 
If:
cgi(2) eq "fileid" and cgi(8) eq "N"

 
 
Then:
FileID=cgi(3)

 
If:
cgi(2) eq "pass" and cgi(8) eq "N"

 
 
Then:
UpPass=cgi(3);PrePass=cgi(3)

 
If:
cgi(2) eq "passthru" and cgi(8) eq "N"

 
 
Then:
PassThru="Y"

 
If:
 

 
 
Then:
delete cgi;getnext cgi;goto cgiloop

If:
Cookie eq ""

 
 
Then:
goto nocook

 
If:
Cookie ne ""

 
 
Then:
cp=instr(Cookie,"|");CookiePresent="Y"

 
If:
cp ne "0"

 
 
Then:
CLUName=mid(Cookie,"1",cp-"1");CLPass=mid(Cookie,cp+"1",len(Cookie)-cp);PEncode=CLPass

 
If:
 

 
 
Then:
lookup ckchk = flfss_accounts k=(CLUName) i=A -nx

 
If:
not ckchk

 
 
Then:
close ckchk;goto nocook

 
If:
 

 
 
Then:
Pass=ckchk(9);close ckchk

If:
(SessID eq "" or SessID eq "NOSESSION") and Cookie eq ""

 
 
Then:
ErrMsg="Your session has expired. Please log in again.";call "loginform";exit

 
If:
 

 
 
Then:
SUpdate="Y";call "verify_session"

 
If:
SessID eq "CHANGEDIP"

 
 
Then:
ErrMsg="Your session ID does not match your IP Address.";call "loginform";exit

 
If:
(SessID eq "" or SessID eq "NOSESSION") and Cookie eq ""

 
 
Then:
ErrMsg="Your session has expired. Please log in again.";call "loginform";exit

 
If:
(SessID eq "" or SessID eq "NOSESSION") and (Cookie ne "" and PEncode eq Pass)

 
 
Then:
UName=CLUname;SIDString=@PW;call "make_sessionid";SessID=SIDString;UName=CLUName;call "insert_session";SUpdate="N"

 
If:
SUpdate eq "Y"

 
 
Then:
call "update_session"

 
If:
Cookie eq ""

 
 
Then:
UName=SessUName

 
If:
Cookie ne ""

 
 
Then:
UName=CLUname

 
If:
 

 
 
Then:
lookup downfl = flfss_uploads k=(FileID) i=b -npx

 
If:
not downfl

 
 
Then:
ErrMsg="File does not exist.";close downfl;call "logindone";exit

 
If:
 

 
 
Then:
UpOrig=downfl(2);UpDest=downfl(3);UpSize=downfl(4);UpRestrict=downfl(8);Deleted=downfl(10)

 
If:
 

 
 
Then:
UpOwner=downfl(1);OUpPass=downfl(12)

 
If:
Deleted eq "Y" and UpOwner ne UName

 
 
Then:
close downfl;ErrMsg="File does not exist.";call "logindone";exit

 
If:
UpRestrict eq "Y" and UpPass eq ""

 
 
Then:
close downfl;call "downpassform";exit

 
If:
 

 
 
Then:
Pass=UpPass;call "scramble_pass";UpPass=PEncode

 
If:
UpRestrict eq "Y" and UpPass ne OUpPass

 
 
Then:
close downfl;ErrMsg="Password `incorrect. File access denied.";call "downpassform";exit

 
If:
UpRestrict eq "Y" and PassThru ne "Y"

 
 
Then:
close downfl;PassThru="Y";call "downpassthru";exit

 
If:
 

 
 
Then:
downfl(5)=downfl(5)+"1";write downfl;close downfl

 
If:
 

 
 
Then:
IHandle=open("flfss.styleurl","r")

 
If:
IHandle lt "0"

 
 
Then:
Style="";goto skiprd

 
If:
 

 
 
Then:
ln=readline(IHandle,Style,"999")

 
If:
 

 
 
Then:
ln=close(Ihandle)

If:
 

 
 
Then:
IHandle=open("flfss.baseurl","r")

 
If:
IHandle lt "0"

 
 
Then:
SelfURL="/~fairlite/cgi-bin/cgiwrap/filepro/onegate";goto skiprd2

 
If:
 

 
 
Then:
ln=readline(IHandle,SelfURL,"999")

 
If:
 

 
 
Then:
ln=close(IHandle)

If:
 

 
 
Then:
OHandle=open(TypeFile,"wc0t")

 
If:
OHandle lt "0"

 
 
Then:
ErrMsg="Could not open MIME type file.";call "logindone";exit

 
If:
 

 
 
Then:
call "determine_mimetype"

 
If:
 

 
 
Then:
ln=writeline(OHandle,MimeType,len(MimeType))

 
If:
OHandle lt "0"

 
 
Then:
ErrMsg="Could not write to MIME type file.";call "logindone";exit

 
If:
 

 
 
Then:
ln=close(IHandle)

 
If:
 

 
 
Then:
IHandle=open(UpDest,"rb")

 
If:
IHandle lt "0"

 
 
Then:
ErrMsg="Could not open uploaded file.";call "logindone";exit

 
If:
 

 
 
Then:
OHandle=open(OutFile,"wc0b")

 
If:
OHandle lt "0"

 
 
Then:
ErrMsg="Could not open output file.";call "logindone";exit

 
If:
 

 
 
Then:
FPos="0"

If:
 

 
 
Then:
ln=read(IHandle,FLine,"8192")

 
If:
FPos lt UpSize and ln eq "0"

 
 
Then:
ErrMsg="Premature end of file during copy.";call "logindone";exit

 
If:
 

 
 
Then:
lo=write(OHandle,FLine)

 
If:
lo ne ln

 
 
Then:
ErrMsg="Could not write entire line to file during copy.";call "logindone";exit

 
If:
FPos lt UpSize

 
 
Then:
FPos=FPos+ln;goto cploop

 
If:
 

 
 
Then:
ln=close(IHandle);ln=close(OHandle);exit

If:
 

 
 
Then:
exit