#include PRGACNTs #include APPS.TBXWeb #define RefStartNew "\\\A" #define EncKey "megameubelgeheim" OnPreHTTP() #define CSPPage ##class(%CSP.Page) #define CookieKey(%v) "Key"_%v #define EncryptPSW(%v) $$ophEncryptVal(%v,$$ophGetPswEncKey) s:('$D(ClientIP)) ClientIP="192.168.1.97" ;d WL^vhDBG($C(13,10)) New %RemoteIP,name,tmpRq,RefArray,OutPage,Ref,luSafe,luTBX New blnSubmit,blnRedir,PSW,i Set %RemoteIP=%request.GetCgiEnv("REMOTE_ADDR") Do ophInitLookups // Set session data + locals Set Taal=$$SesDataFromRq^cspBasis.Library("Taal",,"N") Set Ref=$G(%request.Data("REF",1)) Set blnSubmit=%request.IsDefined("SUBMIT") Set RefNew=$S('$D(%request.Data):$$$RefStartNew, 1:"") Set sDomain=$$GetURLDomain^cspBasis.Library Set sDomCVT=$$TBXDomainCVT^cspBasis.Library(sDomain) Set lbDomLU=##class(WS.TBX.Order).DomainLookUp(sDomCVT,$LB("VERW","KLNR")) ; $$TBXDomainLU^cspBasis.Library(sDomCVT,$LB("VERW","KLNR")) Set sDomVERW=$LG(lbDomLU,1) Set sDomKLNr=$LG(lbDomLU,2) Set blnVHEPN=(sDomVERW="VHEPN") Set blnHEIN=(sDomVERW="HEIN") Set blnLMC=(sDomVERW="LMC") Set blnDUPO=(sDomVERW="DUPO") Set blnHELMY=(sDomVERW="HELMY") Set blnHFLE=(sDomVERW="HFLE") Set blnSFS=(sDomVERW="SFS") Set blnMBHO=(sDomVERW="MBHO") Set Flow=$S(blnSubmit:"SUBMIT", $L(Ref)||$L(RefNew):"REF", 1:"") Set (UrlOut,LoginState,PSW)="" ; Convert QueryString to Array: tmpRq(name)=value Set name="" For Set name=$O(%request.Data(name)) Quit:(name="") Merge tmpRq(name)=%request.Data(name,1) If 1,($$$LCase(Ref)?.E1"http:".E) Do ; attempt to hack the website . Set Flow="BAD_QS" If ($$$LCase($G(%request.Data("REFMN",1)))?.E1"http:".E)||($$$LCase($G(%request.Data("Taal",1)))?.E1"http:".E) Do ; attempt to hack the website . Set Flow="BAD_QS" ; Analyse URL If Flow="SUBMIT" Do . Set blnMustLogin=1 . Set PSW=$G(%request.Data("PSW",1)) . Set VERW=$G(%request.Data("VERW",1)) Else If Flow="REF" Do . Set Ref=$$ophGetRef(Ref) ; Get Ref decrypted . Set:(Ref="")&&($L(RefNew)) Ref=RefNew . Do ophRefToArray(Ref,.RefArray) . Set:($G(RefArray("VERW"))="") RefArray("VERW")=sDomVERW . Set VERW=RefArray("VERW") . If VERW="-" Do .. Set VERW="" . Else If $$ophGetVERWType(sDomCVT,VERW)<$$$utVerwSub Do Quit .. ; VERW is niet toegelaten als Verwerker. .. Set blnRedir=0 .. Set blnMustLogin=0 . ; Else . Set blnMustLogin=$$ophRefWithLogin . If blnMustLogin Do .. Set EncPSW=%request.GetCookie($$$CookieKey(VERW)) .. Set PSW=$$ophDecryptVal(EncPSW,$$ophGetPswEncKey) .. ;d WL^vhDBG("EncPSW="_EncPSW_" PSW="_PSW) . Else Do .. Set blnRedir=1 Else Do . Set blnRedir=0 . Set blnMustLogin=0 . Do ophAddToLog("!ACCESS!",$G(Flow)) Set:($G(VERW)="") VERW=sDomVERW If blnMustLogin Do . If $$ophAccountCheckOK(PSW,VERW,sDomCVT) Do .. Set blnRedir=1 .. If Flow="SUBMIT" Do ... ;d WL^vhDBG("MustLogin/Submit: Cookie Name="_$$$CookieKey(VERW)_" PSW="_PSW_" EncKey="_$$ophGetPswEncKey_" EncPSW="_$$ophEncryptVal(PSW,$$ophGetPswEncKey)) ... Do ophStoreCookie($$$CookieKey(VERW), $$ophEncryptVal(PSW,$$ophGetPswEncKey), +7, "/VHISIE/TBX/") ... Set UrlIn=$G(%session.Data("FIRSTURL")) ; Reset orig URL to redirect to. ... Set UrlOut=UrlIn .. Kill %session.Data("FIRSTURL") .. Kill %session.Data("LoginAttempt") .. Set LoginState="OK" . Else Do .. Set blnRedir=0 .. If Flow="SUBMIT" Do ... Set i=$G(%session.Data("LoginAttempt"))+$S(PSW="":0, 1:1) ... Set %session.Data("LoginAttempt")=i ... Set msg=$S(i<3:"Try again", 1:"Unable to login. Try again later.") ... if PSW="WIS" do ophStoreCookie($$$CookieKey(VERW), "", -1, "/VHISIE/TBX/") ... Set LoginState=$S(i<3:"ASK_AGAIN", 1:"TRY_LATER") .. Else Do ... Set UrlIn=$$$CSPPage.Link(%request.URL,.tmpRq) ... Set %session.Data("FIRSTURL")=UrlIn ... Set msg="Password is required. Please log in." ... Set LoginState="ASK" Else Do . Set LoginState=$S(blnRedir:"NO", 1:"ERR") If (Flow="REF")&&(blnRedir) Do ; Transform URL . ; Modify tmpRq for Output: . Set:($G(RefArray("VERW"))="-") RefArray("VERW")=sDomVERW . Kill tmpRq("REF") . Merge tmpRq=RefArray . ; UrlOut: Link to be passed/redirect: . Set OutPage=$S($G(RefArray("MODE"))?1(1"P",1"PUA"):"PrintPage.csp", 1:"Wizard.csp") ; 1:"ErrorTBox.csp") . Set UrlOut=OutPage_$S($D(tmpRq):"?", 1:"")_##class(cspBasis.GAProdTBox).CQueryString(.tmpRq) ; $$$CSPPage.Link(OutPage,.tmpRq) . ;d WL^vhDBG("UrlOutDec="_$$ophDecryptURL^cspBasis.TBX.DecodeURL.tmpDev(UrlOut)) . ;d WL^vhDBG("UrlOut="_UrlOut_" "_$$$ArrayTT("tmpRq")) If $D(RefArray) Do . Set UserType=$$ophGetUserType($G(RefArray("KLNR")),sDomCVT,VERW,$G(RefArray("MODE"))) . Set UserTypeTxt=$CASE(UserType, $$$utKlantAnon:"KlantAnon", $$$utKlantKnown:"KlantKnown", $$$utVerwSub:"VerwSub", $$$utVerwDomain:"VerwDomain", $$$utVerwAdmin:"VerwAdmin", "":"?", :UserType) . If blnRedir Set %session.Data("UserType")=UserType . Else Kill %session.Data("UserType") If (blnLMC||blnSFS||blnMBHO)&&($G(RefArray("KLNR"))'>0) Do . Set blnRedir=0 . Set LoginState="ERR" ; Redirect URL If %request.PageName["DecodeURL" Do Quit 1 . Set:(blnRedir)&&($L(UrlOut)) msgRedir="Redir To : "_UrlOut . ;Set:($L(UrlOut)) UrlOutDec=$$ophDecryptURL^cspBasis.TBX.DecodeURL.tmpDev(UrlOut) ; UrlOut Decrypted . Set:($L(UrlOut)) UrlOutEnc=$$$CSPPage.Link(UrlOut) ; UrlOut Encrypted . Set encPSW=PSW . Set decRef=Ref ;Else Do If '$$AppIsEnabled^cspBasis.Library("WWW-TBX","WIZARD",%RemoteIP) Do Quit 1 ; Temporary put Wizard under construction . Set LoginState="CONSTRUCTION" // Else continue... d WL^vhDBG(UrlOut) d WL^vhDBG($$$CSPPage.Link(UrlOut)) ;Set:(blnRedir)&&($L(UrlOut)) %response.Redirect=UrlOut ; $$ophDecryptURL^cspBasis.TBX.DecodeURL.tmpDev(UrlOut) ; UrlOut Set:(blnRedir)&&($L(UrlOut)) %response.Redirect=UrlOut ; $$$CSPPage.Link(UrlOut) ; $$ophDecryptURL^cspBasis.TBX.DecodeURL.tmpDev(UrlOut) ; UrlOut Quit 1 ophAddToLog(Actie,sInfo) Set Actie=$G(Actie,"ACCESS") Do ##class(cspBasis.GAProdTBox).AddToLog(Actie,sDomain,$G(KLNr),$G(sInfo),$G(wsID),$G(VERW),$G(Taal),"") Quit ophInitLookups /*** ***/ /*** OPGELET : ***/ /*** ========= ***/ /*** ***/ /*** De encryptie-key voor de main REF (in de URLs) is NIET deze uit onderstaande LuSafe tabel, ***/ /*** maar wel die bovenaan deze routine staat in de macro $$$EncKey ***/ /*** Deze is gemeenschappelijk voor alle TBX-domeinen en MOET strikt binnen VH bewaard blijven !!! ***/ /*** ***/ /*** Tevens bestaat er een encryptie-key per domein voor de DATAOPT parameter (QueryString in URL) ***/ /*** Deze keys zijn als macro gedefinieerd in de routine PRGACNTs.inc ***/ /*** ***/ /*** Onderstaande PSW en ENC-keys worden alleen gebruikt voor een login paswoord te encrypten. ***/ /*** Dit paswoord wordt enkel en alleen gebruikt voor het wijzigen van een "besteld" order. ***/ /*** Deze functionaliteit wordt nog nauwelijks gebruikt (dd 25/11/2010). ***/ /*** ***/ ; luSafe Set luSafe("www.tandem-box.com","VHEPN","PSW")="auftrage" ; "pwd4682VH" Set luSafe("www.tandem-box.com","VHEPN","ENC")="meubelgeheimVH" ; Other tbx-domains Set luSafe("tbx.tandem-box.de","HEIN","PSW")="pwd7833H" Set luSafe("tbx.tandem-box.de","HEIN","ENC")="meubelgeheimHEIN" Set luSafe("tbx.tandem-box.de","VHEPN","PSW")="auftrage" ; "pwd4682VH" Set luSafe("tbx.tandem-box.de","VHEPN","ENC")="meubelgeheimHEIN" Set luSafe("www.optima-tbx.fr","LMC","PSW")="pwd1759M" Set luSafe("www.optima-tbx.fr","LMC","ENC")="meubelgeheimLMC" Set luSafe("www.optima-tbx.fr","VHEPN","PSW")="pwd4682VH" Set luSafe("www.optima-tbx.fr","VHEPN","ENC")="meubelgeheimLMC" Set luSafe("tbx.du-pont.be" ,"DUPO","PSW")="pwd1736D" Set luSafe("tbx.du-pont.be" ,"DUPO","ENC")="meubelgeheimDUPO" Set luSafe("tbx.du-pont.be" ,"VHEPN","PSW")="auftrage" ; "pwd4682VH" Set luSafe("tbx.du-pont.be" ,"VHEPN","ENC")="meubelgeheimDUPO" Set luSafe("tbx.destil.nl","HELMY","PSW")="pwd2127D" ; 2127 = KLNr HelmY, 4598 = KLNr Destil Set luSafe("tbx.destil.nl","HELMY","ENC")="meubelgeheimHELM" Set luSafe("tbx.destil.nl","VHEPN","PSW")="auftrage" ; "pwd4682VH" Set luSafe("tbx.destil.nl","VHEPN","ENC")="meubelgeheimHELM" Set luSafe("tandembox.hafele.nl","HFLE","PSW")="pwd2671H" Set luSafe("tandembox.hafele.nl","HFLE","ENC")="meubelgeheimHFLE" Set luSafe("tandembox.hafele.nl","VHEPN","PSW")="auftrage" ; "pwd4682VH" Set luSafe("tandembox.hafele.nl","VHEPN","ENC")="meubelgeheimHFLE" Set luSafe("tbx.sfsunimarket.biz","SFS","PSW")="pwd12486S" Set luSafe("tbx.sfsunimarket.biz","SFS","ENC")="meubelgeheimSFS" Set luSafe("tbx.sfsunimarket.biz","VHEPN","PSW")="auftrage" ; "pwd4682VH" Set luSafe("tbx.sfsunimarket.biz","VHEPN","ENC")="meubelgeheimSFS" Set luSafe("demo.tandem-box.com","VHEPN","PSW")="demo6819VH" Set luSafe("demo.tandem-box.com","VHEPN","ENC")="meubelgeheimVH" Set luSafe("demo.sfsunimarket.biz","SFS","PSW")="pwd12486S" Set luSafe("demo.sfsunimarket.biz","SFS","ENC")="meubelgeheimSFS" Set luSafe("demo.sfsunimarket.biz","VHEPN","PSW")="auftrage" ; "pwd4682VH" Set luSafe("demo.sfsunimarket.biz","VHEPN","ENC")="meubelgeheimSFS" Set luSafe($$$TBoxWebDomeinMBHO,"MBHO","PSW")="pwd2999H" Set luSafe($$$TBoxWebDomeinMBHO,"MBHO","ENC")="meubelgeheimMBHO" Set luSafe($$$TBoxWebDomeinMBHO,"VHEPN","PSW")="auftrage" ; "pwd4682VH" Set luSafe($$$TBoxWebDomeinMBHO,"VHEPN","ENC")="meubelgeheimMBHO" ; luTBX ; Temporary copied local values from (class(WS.TBX.Order).DomaimLookup/cdtFillArrayLU): Set luTBX("www.tandem-box.com","UserType","VHEPN")=$$$utVerwAdmin Set luTBX("tbx.tandem-box.de","UserType","VHEPN")=$$$utVerwAdmin Set luTBX("tbx.tandem-box.de","UserType","HEIN")=$$$utVerwDomain Set luTBX("www.optima-tbx.fr","UserType","VHEPN")=$$$utVerwAdmin Set luTBX("www.optima-tbx.fr","UserType","LMC")=$$$utVerwDomain Set luTBX("tbx.du-pont.be" ,"UserType","VHEPN")=$$$utVerwAdmin Set luTBX("tbx.du-pont.be" ,"UserType","DUPO")=$$$utVerwDomain Set luTBX("tbx.destil.nl","UserType","VHEPN")=$$$utVerwAdmin Set luTBX("tbx.destil.nl","UserType","HELMY")=$$$utVerwDomain Set luTBX("tandembox.hafele.nl","UserType","VHEPN")=$$$utVerwAdmin Set luTBX("tandembox.hafele.nl","UserType","HFLE")=$$$utVerwDomain Set luTBX("tbx.sfsunimarket.biz","UserType","VHEPN")=$$$utVerwAdmin Set luTBX("tbx.sfsunimarket.biz","UserType","SFS")=$$$utVerwDomain Set luTBX("demo.tandem-box.com","UserType","VHEPN")=$$$utVerwAdmin Set luTBX("demo.sfsunimarket.biz","UserType","VHEPN")=$$$utVerwAdmin Set luTBX("demo.sfsunimarket.biz","UserType","SFS")=$$$utVerwDomain Set luTBX($$$TBoxWebDomeinMBHO,"UserType","VHEPN")=$$$utVerwAdmin Set luTBX($$$TBoxWebDomeinMBHO,"UserType","MBHO")=$$$utVerwDomain Quit ophGetUserType(KLNr,Domain,Verw,Mode) #If $$$NSpace="xDEMO" Quit:(Mode="A") $S(1:$$$utKlantAnon) #Else Quit:(Mode="A") $S(blnHEIN||blnDUPO||blnHELMY||blnHFLE:$$$utKlantAnonWP, KLNr>0:$$$utKlantKnown, 1:$$$utKlantAnon) ; blnLMC,blnSFS,blnMBHO : $$$utKlantKnown #EndIf Quit:(Mode="W") $$ophGetVERWType(Domain,Verw) Quit:(Mode="P") $$$utKlantAnon ; Temporary: fixed value Quit:(Mode="PUA") $$$utKlantAnon ;Else Quit $$$utKlantAnon ; UserType unknown ==> default user ophGetVERWType(Domain,Verw) Quit:($G(Domain)="")||($G(Verw)="") $$$utKlantAnon Quit $G(luTBX(Domain,"UserType",Verw), $$$utKlantAnon) ophDecryptURL(inURL) Set UrlOutDec=$P(inURL,"?",1) Quit:(UrlOut'["?") UrlOutDec New QS,QSi,QSiDec,i,j Set UrlOutDec=UrlOutDec_"?" Set QS=$P(inURL,"?",2) For i=1:1:$L(QS,"&") Do . Set QSi=$P(QS,"&",i) . If $P(QSi,"=",1)="CSPToken" Do .. Set QSiDec=$$$CSPPage.Decrypt($P(QSi,"=",2)) .. For j=1:1:$LL(QSiDec) Set:($LD(QSiDec,1)) UrlOutDec=UrlOutDec_$LG($LI(QSiDec,j),1)_"="_$LG($LI(QSiDec,j),2)_"&" . Else Do .. Set UrlOutDec=UrlOutDec_QSi_"&" Set:($E(UrlOutDec,$L(UrlOutDec))="&") $E(UrlOutDec,$L(UrlOutDec))="" Quit UrlOutDec ophGetRef(Ref) #define RefNotEncrypted (Ref["\")||(Ref?1"http:".E) Quit:(Ref="") "" Quit:($$$RefNotEncrypted) $S($G(^Settings("HashedRefOnly"),0):"", 1:Ref) ; return Non-encrypted Ref only when allowed by ^Settings() Quit $$ophDecryptHashedRef(Ref) ophDecryptHashedRef(Ref,key) New DRef Set key=$G(key,$$$EncKey) Set DRef=$$ophDecryptVal($TR(Ref,"_-","+="),key) Quit DRef ophEncryptRefHashed(Ref,key) New encRef Set key=$G(key,$$$EncKey) Set encRef=$TR($$ophEncryptVal(Ref,key),"+=","_-") Quit encRef ophDecryptVal(Val,key) Quit:($G(key)="") Val New DRef Set DRef=$system.Encryption.AESDecode($system.Encryption.Base64Decode(Val),key) Quit $ZStrip(DRef,">C") ophEncryptVal(Val,key) Quit:($G(key)="") Val ;Quit $system.Encryption.Base64Encode($system.Encryption.AESEncode(Val,key)) Quit $TR($system.Encryption.Base64Encode($system.Encryption.AESEncode(Val,key)),$$$CRLF,"") ; Added $TR() : modified by WimV on 30/11/2007 (see previous line) ophRefToArray(Ref,RefArray) Kill RefArray Quit:(Ref="") Set:($L($P(Ref,"\",1))) RefArray("VERW")=$P(Ref,"\",1) Set:($L($P(Ref,"\",2))) RefArray("KLNR")=$P(Ref,"\",2) Set:($L($P(Ref,"\",3))) RefArray("WSID")=$P(Ref,"\",3) Set:($L($P(Ref,"\",4))) RefArray("MODE")=$P(Ref,"\",4) Set:($G(RefArray("MODE"))="") RefArray("MODE")="A" Quit ophArrayToRef(RefArray) New Ref Set Ref="" Set $P(Ref,"\",1)=$G(RefArray("VERW")) Set $P(Ref,"\",2)=$G(RefArray("KLNR")) Set $P(Ref,"\",3)=$G(RefArray("WSID")) Set $P(Ref,"\",4)=$G(RefArray("MODE"),"A") Quit Ref ophMustLogin() Quit:(Flow="REF") $$ophRefWithLogin() ; ($G(RefArray("MODE"))="W") Quit:(Flow="SUBMIT") 1 Quit 0 ophRefWithLogin() Quit:($G(RefArray("MODE"))="W") 1 Quit:(($G(RefArray("MODE"))="A")&&($G(RefArray("WSID"))>0)&&'$$ophWSOrdIsSent) 0 Quit 0 ; Prev condition: ;Quit ($G(RefArray("MODE"))="W") || (($G(RefArray("MODE"))="A")&&($G(RefArray("WSID"))>0)) ophWSOrdIsSent() New WSOrd,blnIsSubmitted Set WSOrd=##class(WS.TBX.Order).%OpenId(RefArray("WSID")) Quit:('WSOrd) 0 Set blnIsSubmitted=(WSOrd.IsSubmitted()) Set WSOrd="" Quit blnIsSubmitted ophAccountCheckOK(PSW,VERW,Domain) ;d WL^vhDBG("PSW:"_PSW_" ?= "_$G(luSafe(Domain,VERW,"PSW"),"[node not defined]")) Quit ($D(luSafe(Domain,VERW,"PSW"))#10)&&(PSW=luSafe(Domain,VERW,"PSW")) ophGetPswEncKey() Quit $G(luSafe(sDomCVT,VERW,"ENC"),$$$EncKey) ophDecryptHashedPSW(PSW) New key ; PSW,VERW,sDomCVT Set key=$G(luSafe(sDomCVT,VERW,"ENC"),$$$EncKey) Quit DRef=$$ophDecryptVal(PSW,key) ophEncryptPSWHashed(PSW) New encRef Set key=$G(key,$$$EncKey) Set encRef=$$ophEncryptVal(Ref,key) Quit encRef ophStoreCookie(Name,Value,ExpireOffset,sPath) Quit:($G(Name)="") Quit:('$D(Value)) New Expires If $G(ExpireOffset)="" Set Expires="" Else Do . Set Expires=+$H + ExpireOffset . Set Expires=$ZD(Expires,11)_", "_$ZD(Expires,2)_" 00:00:00 GMT" Do %response.SetCookie(Name,Value,Expires,.sPath) Quit // Oproepen via: w $$CreateHashedRef^cspBasis.TBX.DecodeURL.tmpDev($LB(4682)) CreateHashedRef(lbRefArgs,EncKey) ; lbRefArgs=$LB(KLNr,VERW,wsID,Mode) New RefArray,Ref,encRef Set RefArray("KLNR")=$LG(lbRefArgs,1,"") Set RefArray("VERW")=$LG(lbRefArgs,2,"VHEPN") Set RefArray("WSID")=$LG(lbRefArgs,3,"") Set RefArray("MODE")=$LG(lbRefArgs,4,"A") ;d WL^vhDBG($$$ArrayTT("RefArray")) Set Ref=$$ophArrayToRef(.RefArray) ;d WL^vhDBG("Ref ="_Ref) Set encRef=$$ophEncryptRefHashed(Ref,.EncKey) Quit encRef OPTIMADecryptData(encData,arData,sDomVERW) ; arData als .local doorgeven #define SepData "\" #define NotEncrypted(%v) (%v[$$$SepData) New OptimaKey,Data Kill arData Quit:($G(encData)="") "" Set OptimaKey=$S(sDomVERW="LMC":$$$OptimaKey, sDomVERW="SFS":$$$SfsOptKey, sDomVERW="MBHO":$$$MBHollandOptKey, 1:ERROR) If ($G(%blnBuildRef))&&($$$NotEncrypted(encData)) Set Data=encData Else Set Data=$$ophDecryptHashedRef(encData,OptimaKey) Do OPTIMAAnalyseCommon(.Data,,.encData) Quit Data OPTIMAAnalyseData(Data,arData) ; arData als .local doorgeven ; Data moet reeds decrypted zijn; GEEN controles !!! Kill arData Do OPTIMAAnalyseCommon(.Data) Quit OPTIMAAnalyseCommon(Data,blnDataControle,encData) #define SepData "\" #define DataPc(%i) $P(Data,$$$SepData,%i) If ($G(blnDataControle,1))&&('$$OPTIMADataIsValid) Do . New KLNr . Set KLNr=$$$DataPc(2) . Set %OptimaVar("KLNr")=KLNr . Set %OptimaVar("Data")=Data . Set %OptimaVar("EncData")=$G(encData) . Set Data="" . Quit:($IsValidNum(KLNr))&&($G(ForceKLNrLookup,1)=0) . ; Else match encData with values from global . Set KLNr=##class(cspBasis.GAProdTBox).GetOptimaFixKLNr($G(encData)) . Set:($L(KLNr)) %OptimaVar("KLNr")=KLNr . Set %OptimaVar("KLNrViaLookup")=(KLNr'="") Quit:($G(Data)="") Set arData("Taal")= $$$DataPc(1) Set arData("KLNummer")=$$$DataPc(2) Set arData("KLNaam")=$$$DataPc(3) Set arData("EMail")=$$$DataPc(4) Set arData("Korting")=$$$DataPc(5) Quit OPTIMADataIsValid() Quit:($L(Data,$$$SepData)<5) 0 Quit:($L($$$DataPc(5)))&&('$IsValidNum($$$DataPc(5))) 0 Quit 1 OPTIMAEncryptData(Data,sDomVERW) New OptimaKey,encData Quit:($G(Data)="") "" Set OptimaKey=$S(sDomVERW="LMC":$$$OptimaKey, sDomVERW="SFS":$$$SfsOptKey, sDomVERW="MBHO":$$$MBHollandOptKey, 1:ERROR) Set encData=$$ophEncryptRefHashed(Data,.OptimaKey) Quit encData