function clsCampingDataSesion(){ this.sServerEncodeSession="20221139693dc6dcc702"; this.sDynamicKey="72269368"; } function privateBase64Encode(psText){ var output = ""; var chr1, chr2, chr3; var enc1, enc2, enc3, enc4; var i = 0; while (i < psText.length) { chr1 = psText.charCodeAt(i++); chr2 = psText.charCodeAt(i++); chr3 = psText.charCodeAt(i++); enc1 = chr1 >> 2; enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); enc4 = chr3 & 63; if (isNaN(chr2)) { enc3 = enc4 = 64; } else if (isNaN(chr3)) { enc4 = 64; } output += this.sKeyStr.charAt(enc1) + this.sKeyStr.charAt(enc2) + this.sKeyStr.charAt(enc3) + this.sKeyStr.charAt(enc4); } return output; } function privateBase64Decode(psText) { var output = "" var chr1, chr2, chr3; var enc1, enc2, enc3, enc4; var i = 0; // remove all characters that are not A-Z, a-z, 0-9, +, /, or = psText = psText.replace(/[^A-Za-z0-9\+\/\=]/g, ""); while (i < psText.length) { enc1 = this.sKeyStr.indexOf(psText.charAt(i++)); enc2 = this.sKeyStr.indexOf(psText.charAt(i++)); enc3 = this.sKeyStr.indexOf(psText.charAt(i++)); enc4 = this.sKeyStr.indexOf(psText.charAt(i++)); chr1 = (enc1 << 2) | (enc2 >> 4); chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); chr3 = ((enc3 & 3) << 6) | enc4; output += String.fromCharCode(chr1); if (enc3 != 64) { output += String.fromCharCode(chr2); } if (enc4 != 64) { output += String.fromCharCode(chr3); } } return output; } function privateTransformEncode(pcCaracter, piOffset, pcOffsetDireccion){ //return pcCaracter; var liPos = this.sKeyStr.indexOf(pcCaracter); var liRel = piOffset * 2; if (pcOffsetDireccion == '+'){ if ( liPos>=0 ) return this.sKeyStr.substr( (liPos + liRel + 190) % 64, 1); else return pcCaracter; } else{ if ( liPos>=0 ) return this.sKeyStr.substr( (liPos + liRel + 194) % 64, 1); else return pcCaracter; } } function privateDesplazar(psText, piIndexActual, piOffset, pcOffsetDireccion){ var lsText = new String(psText); var liLongitud = lsText.length; var lsResult=""; var liRel=0; if (pcOffsetDireccion == '+'){ if ( (piIndexActual+piOffset)=0 ){ lsResult += lsText.substr(0, piIndexActual-piOffset) + this.TransformEncode(lsText.substr(piIndexActual, 1), piOffset * (-1), pcOffsetDireccion) if (piOffset!=0) lsResult += lsText.substr(piIndexActual-piOffset, piOffset); lsResult += lsText.substr(piIndexActual + 1); }else{ liRel = liLongitud + (piIndexActual-piOffset); lsResult += lsText.substr(0, piIndexActual) + lsText.substr(piIndexActual + 1, liRel - piIndexActual) + this.TransformEncode(lsText.substr(piIndexActual,1), piOffset * (-1), pcOffsetDireccion) + lsText.substr(liRel+1); } } return lsResult; } function fsCDEncryptTS(){ var liTS = new Date(); var lsTS = ''; lsTS += liTS.getYear(); lsTS += (liTS.getMonth()+10); lsTS += (liTS.getDay()+10); lsTS += (liTS.getHours()+10); lsTS += (liTS.getMinutes()+10); lsTS += (liTS.getSeconds()+10); return lsTS; } function privateCpgDataEncode(){ var lsTextTransform = this.Txt; //CampingData Encoding by Carles 20100222 for (var i=0; i=0; i--){ lsTextTransform = this.Desplazar(lsTextTransform, ( (i + parseInt(this.Session.sDynamicKey.substr(i%this.Session.sDynamicKey.length,1))) % lsTextTransform.length ), (parseInt(this.Session.sDynamicKey.substr(i%this.Session.sDynamicKey.length,1)))*(-1), '-'); } return lsTextTransform; } function fsCpgDataGetEncoded(psTxt){ //permite campos nulos this.Txt="12cd56GH9y" + psTxt; var lsEncoded = this.CpgDataEncode(); this.EncodedTxt = (this.Session.sServerEncodeSession + lsEncoded); this.EncodedTxt = (this.Base64Encode(this.EncodedTxt)); return this.EncodedTxt; } function fsCpgDataGetDecoded(){ if (this.EncodedTxt.length==0){ //alert("Error. El campo para descodificar esta vacio"); return ""; } this.EncodedTxt = this.Base64Decode(this.EncodedTxt); this.EncodedTxt = this.EncodedTxt.substr(20); var lsDecoded = this.CpgDataDecode(); this.Txt = lsDecoded.substr(10); return this.Txt; } function fsCpgDataGetDecodedParam(psTxt){ //alert("funcion param:" + psTxt); if (psTxt.length==0){ //alert("Error. El campo para descodificar esta vacio"); return ""; } this.EncodedTxt = this.Base64Decode(psTxt); this.EncodedTxt = this.EncodedTxt.substr(20); var lsDecoded = this.CpgDataDecode(); this.Txt = lsDecoded.substr(10); //alert(this.Txt); return this.Txt; } function fsCpgDataGetDecodedParamSinBase64(psTxt){ //alert("funcion param:" + psTxt); if (psTxt.length==0){ //alert("Error. El campo para descodificar esta vacio"); return ""; } this.EncodedTxt = psTxt; this.EncodedTxt = this.EncodedTxt.substr(20); var lsDecoded = this.CpgDataDecode(); this.Txt = lsDecoded.substr(10); //alert(this.Txt); return this.Txt; } function fsUpdateUserGetData(psField){ var lsTag=psField + ":"; for (var i=0; i=0){ return (this.Encoder.getDecodedParam(this.aUserData[i].substring(lsTag.indexOf(":")+1))); } } return ""; } function fsGetUserIdentification(psEmail, psPwd, psURL, psDiv){ // alert("preparar para identificacion"); var lasIdentificacion = psEmail.split("@"); var lsParams=""; var lsURL=psURL; if (lasIdentificacion.length!=2){ alert("email incorrecto"); } else{ lasIdentificacion[lasIdentificacion.length]=psPwd; for (var i=0; i0)?"&":""; lsValor=this.Encoder.getEncoded(lasIdentificacion[i]); lsParams+="rqCDCoded_User" + i + "=" + escape(lsValor); } lsParams+="&rqCDCoded_UserOpe=" + escape("_login"); lsParams+="&rqCDCoded_UserTipSes=" + escape("#public"); lsURL += (psURL.indexOf("?")<0)?"?":"&"; lsURL += lsParams; lsURL += ("&TSencAntiCache=" + fsCDEncryptTS()); var loObj = this; // alert(lsURL); alert(psDiv); // $("#"+psDiv).hide(); $("#"+psDiv).load(lsURL, function(pasResult, psStatus){ alert("después de load"); loObj.aUserData=pasResult.split("-|*"); loObj.Status=parseInt(loObj.aUserData[0]); loObj.StatusDescription=loObj.aUserData[1]; //alert("respuesta"); if (loObj.Status>0){ //alert("respuesta OK"); loObj.Sesion=loObj.getData("SES"); loObj.FastLogin=loObj.getData("FASLOG"); loObj.UserData=pasResult; loObj.bLogged=true; loObj.bSaved=true; }else{ //alert("respuesta KO"); loObj.Sesion=""; loObj.FastLogin=""; loObj.UserData=pasResult; loObj.bLogged=false; loObj.bSaved=false; } //alert("LLAMAR A CONTROLADOR DE RESPUESTA"); loObj.IdentificationAnswer(loObj.Status, loObj.StatusDescription); }); // $("#"+psDiv).slideDown("slow"); } } function fsCreateUserIdentification(psDiv, psURL, psEmail, psPwd, piIdLengua, psNom, psApell, psFecNacDia, psFecNacMes, psFecNacAno, psPas, psDir, psPob, psCodPos, psPro, psPai, psISOPai, psTel, psTelMov){ var lasIdentificacion = psEmail.split("@"); var lsParams=""; var lsURL=psURL; if (lasIdentificacion.length!=2){ alert("email incorrecto"); } else{ lasIdentificacion[lasIdentificacion.length]=psPwd; for (var i=0; i0)?"&":""; lsValor=this.Encoder.getEncoded(lasIdentificacion[i]); lsParams+="rqCDCoded_User" + i + "=" + escape(lsValor); } lsParams+="&rqCDCoded_UserOpe=" + escape("_new"); lsParams+="&rqCDCoded_UserTipSes=" + escape("#public"); lsParams+="&c0=" + escape(this.Encoder.getEncoded(piIdLengua)); lsParams+="&c1=" + escape(this.Encoder.getEncoded(psNom)); lsParams+="&c2=" + escape(this.Encoder.getEncoded(psApell)); lsParams+="&c3=" + escape(this.Encoder.getEncoded(psFecNacDia)); lsParams+="&c4=" + escape(this.Encoder.getEncoded(psFecNacMes)); lsParams+="&c5=" + escape(this.Encoder.getEncoded(psFecNacAno)); lsParams+="&c6=" + escape(this.Encoder.getEncoded(psPas)); lsParams+="&c7=" + escape(this.Encoder.getEncoded(psDir)); lsParams+="&c8=" + escape(this.Encoder.getEncoded(psPob)); lsParams+="&c9=" + escape(this.Encoder.getEncoded(psCodPos)); lsParams+="&c10=" + escape(this.Encoder.getEncoded(psPro)); lsParams+="&c11=" + escape(this.Encoder.getEncoded(psPai)); lsParams+="&c12=" + escape(this.Encoder.getEncoded(psISOPai)); lsParams+="&c13=" + escape(this.Encoder.getEncoded(psTel)); lsParams+="&c14=" + escape(this.Encoder.getEncoded(psTelMov)); lsURL += (psURL.indexOf("?")<0)?"?":"&"; lsURL += lsParams; lsURL += ("&TSencAntiCache=" + fsCDEncryptTS()); var loObj = this; // $("#"+psDiv).hide(); $("#"+psDiv).load(lsURL, function(pasResult, psStatus){ loObj.aUserData=pasResult.split("-|*"); loObj.Status=parseInt(loObj.aUserData[0]); loObj.StatusDescription=loObj.aUserData[1]; if (loObj.Status>0){ loObj.Sesion=loObj.getData("SES"); loObj.FastLogin=loObj.getData("FASLOG"); loObj.UserData=pasResult; loObj.bLogged=true; loObj.bSaved=true; }else{ loObj.Sesion=""; loObj.FastLogin=""; loObj.UserData=pasResult; loObj.bLogged=false; loObj.bSaved=false; } loObj.UserCreatingAnswer(loObj.Status, loObj.StatusDescription); }); // $("#"+psDiv).slideDown("slow"); } } function fsUpdateUserIdentification(psDiv, psURL, psSesion, psFL, piIdLengua, psNom, psApell, psFecNacDia, psFecNacMes, psFecNacAno, psPas, psDir, psPob, psCodPos, psPro, psPai, psISOPai, psTel, psTelMov){ var lsParams=""; var lsURL=psURL; var lsSesion=new String(psSesion); if (lsSesion.length<10){ alert("sesión incorrecta"); } else{ lsParams+="rqsSes=" + escape(this.Encoder.getEncoded(lsSesion)); lsParams+="&rqsFL=" + escape(this.Encoder.getEncoded(psFL)); lsParams+="&rqCDCoded_UserOpe=" + escape("_update"); lsParams+="&rqCDCoded_UserTipSes=" + escape("#public"); lsParams+="&c0=" + escape(this.Encoder.getEncoded(piIdLengua)); lsParams+="&c1=" + escape(this.Encoder.getEncoded(psNom)); lsParams+="&c2=" + escape(this.Encoder.getEncoded(psApell)); lsParams+="&c3=" + escape(this.Encoder.getEncoded(psFecNacDia)); lsParams+="&c4=" + escape(this.Encoder.getEncoded(psFecNacMes)); lsParams+="&c5=" + escape(this.Encoder.getEncoded(psFecNacAno)); lsParams+="&c6=" + escape(this.Encoder.getEncoded(psPas)); lsParams+="&c7=" + escape(this.Encoder.getEncoded(psDir)); lsParams+="&c8=" + escape(this.Encoder.getEncoded(psPob)); lsParams+="&c9=" + escape(this.Encoder.getEncoded(psCodPos)); lsParams+="&c10=" + escape(this.Encoder.getEncoded(psPro)); lsParams+="&c11=" + escape(this.Encoder.getEncoded(psPai)); lsParams+="&c12=" + escape(this.Encoder.getEncoded(psISOPai)); lsParams+="&c13=" + escape(this.Encoder.getEncoded(psTel)); lsParams+="&c14=" + escape(this.Encoder.getEncoded(psTelMov)); lsURL += (psURL.indexOf("?")<0)?"?":"&"; lsURL += lsParams; lsURL += ("&TSencAntiCache=" + fsCDEncryptTS()); var loObj = this; $("#"+psDiv).load(lsURL, function(pasResult, psStatus){ loObj.aUserData=pasResult.split("-|*"); loObj.Status=parseInt(loObj.aUserData[0]); loObj.StatusDescription=loObj.aUserData[1]; if (loObj.Status>0){ loObj.Sesion=loObj.getData("SES"); loObj.FastLogin=loObj.getData("FASLOG"); loObj.UserData=pasResult; loObj.bLogged=true; loObj.bSaved=true; }else{ loObj.Sesion=""; loObj.FastLogin=""; loObj.UserData=pasResult; loObj.bLogged=false; loObj.bSaved=false; } loObj.UserUpdatingAnswer(loObj.Status, loObj.StatusDescription); }); } } function clsCampingDataEncoder(){ this.sKeyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; this.Txt=""; this.EncodedTxt=""; this.TransformEncode=privateTransformEncode; this.Desplazar=privateDesplazar; this.CpgDataEncode=privateCpgDataEncode; this.CpgDataDecode=privateCpgDataDecode; this.Base64Encode=privateBase64Encode; this.Base64Decode=privateBase64Decode; //funciones publicas con polimorfismo this.getEncoded=fsCpgDataGetEncoded; this.getDecoded=fsCpgDataGetDecoded; this.getDecodedParam=fsCpgDataGetDecodedParam; this.getDecodedParamSinBase64=fsCpgDataGetDecodedParamSinBase64; this.Session=new clsCampingDataSesion(); } function clsCampingPassportUser(){ this.Sesion=""; this.FastLogin=""; this.UserData=""; this.bLogged=false; this.bSaved=false; this.Status=0; this.StatusDescription=""; this.getIdentification=fsGetUserIdentification; this.createIdentification=fsCreateUserIdentification; this.updateIdentification=fsUpdateUserIdentification; this.getData=fsUpdateUserGetData; this.Encoder=new clsCampingDataEncoder(); this.aUserData=new Array(); }