Processing table: prc.upload_file




 
If:
 

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

 
If:
 

 
 
Then:
declare global ErrMsg,ErrReturn(8,*),OutFile(256,*),FString

 
If:
 

 
 
Then:
declare global UName,Pass(20,*),FName,LName,Email,URL,SessID,Expire,SIDString,PEncode(40,*),SessUName,FileRoot

 
If:
 

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

 
If:
 

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

 
If:
 

 
 
Then:
declare global CString,CSan(1,YESNO),CNoAmp(1,YESNO),CNoQuest(1,YESNO),CNoSlash(1,YESNO),CNoSpUn(1,YESNO)

 
If:
 

 
 
Then:
declare global CNoPlus(1,YESNO)

 
If:
 

 
 
Then:
declare Cookie,CLUName,CLPass

 
If:
 

 
 
Then:
declare global CookiePresent(1,YESNO)

 
If:
 

 
 
Then:
declare FControl(20,.0)

 
If:
 

 
 
Then:
ErrReturn="NOT DONE"

 
If:
 

 
 
Then:
OutFile=getenv("ONEGATE_OUTFILE")

 
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:
Restricted="N"

 
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 "upfile" and cgi(4) eq "Y"

 
 
Then:
UpReal=cgi(7);UpOrig=cgi(5);UpSize=cgi(6)

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

 
 
Then:
UpPass=cgi(3);Restricted="Y"

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

 
 
Then:
UpDesc=cgi(3)

 
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:
UpReal eq ""

 
 
Then:
call "upform";exit

 
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:
IHandle=open("flfss.fileroot","r")

 
If:
IHandle lt "0"

 
 
Then:
ErrMsg="Could not open storage root configuration file.";call "generr";t)

 
If:
ErrReturn eq "DONE"

 
 
Then:
goto myexit

 
If:
 

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

 
If:
 

 
 
Then:
ln=close(IHandle);

 
If:
 

 
 
Then:
CNoSpUn="Y";CSan="Y";CNoAmp="N";CNoQuest="N";CNoSlash="N";CNoPlus="N";CString=UpOrig;call "clean_strings";UpOrig=CString

 
If:
 

 
 
Then:
CNoSpUn="Y";CSan="Y";CNoAmp="N";CNoQuest="N";CNoSlash="N";CNoPlus="N";CString=UpPass;call "clean_strings";UpPass=CString

 
If:
 

 
 
Then:
CNoSpUn="Y";CSan="Y";CNoAmp="N";CNoQuest="N";CNoSlash="N";CNoPlus="N";CString=UpDesc;call "clean_strings";UpDesc=CString

 
If:
 

 
 
Then:
lookup ctrl = flfss_fcodectl k=(UName) i=A -npx

 
If:
ctrl

 
 
Then:
FControl=ctrl(2);ctrl(2)=FControl+"1";write ctrl;close ctrl;goto ctrldn

 
If:
 

 
 
Then:
close ctrl;FControl="1"

 
If:
 

 
 
Then:
lookup ctlst = flfss_fcodectl r=free -n

 
If:
not ctlst

 
 
Then:
ErrMsg="Could not obtain free record for control number.";call "upform";exit

 
If:
 

 
 
Then:
ctlst(1)=Uname;ctlst(2)=FControl+"1";write ctlst;close ctlst

If:
 

 
 
Then:
UpBase=UpReal

 
If:
 

 
 
Then:
FString=UpBase;call "make_basename";UpBase=FString;bn=UpBase

 
If:
 

 
 
Then:
RmBase=UpOrig

 
If:
 

 
 
Then:
FString=RmBase;call "make_basename";RmBase=FString

 
If:
 

 
 
Then:
uf(3,ALLUP)=mid(Uname,"1","1");us(3,ALLUP)=mid(Uname,len(Uname),"1")

 
If:
 

 
 
Then:
bt=instr(bn,".")

 
If:
bt ne "0"

 
 
Then:
bp=bt-"1"

 
If:
bt eq "0"

 
 
Then:
bp=len(bn)

 
If:
 

 
 
Then:
bf(3,ALLUP)=mid(bn,bp-"1","1");bs(3,ALLUP)=mid(bn,bp,"1")

 
If:
(uf lt "0" or uf gt "9") and (uf lt "A" or uf gt "Z")

 
 
Then:
uf="SYM"

 
If:
(us lt "0" or us gt "9") and (us lt "A" or us gt "Z")

 
 
Then:
us="SYM"

 
If:
(bf lt "0" or bf gt "9") and (bf lt "A" or bf gt "Z")

 
 
Then:
bf="SYM"

 
If:
(bs lt "0" or bs gt "9") and (bs lt "A" or bs gt "Z")

 
 
Then:
bs="SYM"

 
If:
 

 
 
Then:
UpDest=FileRoot{"/"{""{uf{""{"/"{""{bf{""{"/"{""{us{""{"/"{""{bs{""{"/"{UpBase

 
If:
 

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

 
If:
IHandle lt "0"

 
 
Then:
ErrMsg="Could not open upload file.";call "upform";exit

 
If:
 

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

 
If:
OHandle lt "0"

 
 
Then:
ErrMsg="Could not open storage file.";call "upform";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 "upform";exit

 
If:
 

 
 
Then:
lo=write(OHandle,FLine)

 
If:
lo ne ln

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

 
If:
FPos lt UpSize

 
 
Then:
FPos=FPos+ln;goto cploop

 
If:
 

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

 
If:
 

 
 
Then:
lookup upld = flfss_uploads r=free -n

 
If:
not upld

 
 
Then:
ErrMsg="Could not find free record for file upload entry.";call "upform";exit

 
If:
 

 
 
Then:
upld(1)=UName;upld(2)=RmBase;upld(3)=UpDest;upld(4)=UpSize

 
If:
 

 
 
Then:
upld(5)="0";upld(6)=@td;upld(7)=@tm;upld(8)=Restricted;upld(9)=UName{"-"{FControl;upld(10)="N"

 
If:
UpDesc ne ""

 
 
Then:
upld(11)=UpDesc

 
If:
UpPass ne ""

 
 
Then:
Pass=UpPass;call "scramble_pass";upld(12)=PEncode

 
If:
 

 
 
Then:
write upld;close upld

 
If:
 

 
 
Then:
ErrMsg="Upload successful!";call "updone";exit

If:
 

 
 
Then:
exit