LOCAL cResp, cCmd, cIdUser,cItemGrupo
DECLARE aParam [1]

oApp.explode(oJs.cParam,@aParam,'|')

cLogin = aParam[1]
cPassword = aParam[2]

cPassword = enc3(cPassword)

cResp = '{result:\"-1\"}'

IF oApp.sqlexec('SELECT * FROM user WHERE TRIM(UCASE(login)) = "'+cLogin+'" AND TRIM(ucase(password)) = "'+cPassword+'";')>0

	cIdUser = SQLRESULT.Id

	cResp = '{'
	
	cResp = cResp + oJs.jset('result',   IIF(SQLRESULT.bloqueado=1,'1',IIF(SQLRESULT.bloqueado=2,'2','0')))
	cResp = cResp + oJs.jset('iduser',	  cIdUser)
	cResp = cResp + oJs.jset('nameuser', SQLRESULT.NAME)
	cResp = cResp + oJs.jset('loginuser',SQLRESULT.login)
	cResp = cResp + oJs.jset('seriepv',  SQLRESULT.seriepv)
	
	cResp = cResp + '}'
ENDIF


cCmd = 'json/set_respuesta.php?id='+oJs.cIdCmd+'&resp='+cResp

oApp.runLink(cCmd)

MESSAGEBOX(oApp.cWebResult)


FUNCTION enc3 
	PARAMETERS s
	LOCAL sRet, i, l, c
	sRet=''
	l = LEN (ALLTRIM(S))
	FOR i = 1 TO l
	    c = ASC(SUBSTR (s, i, 1))
	    c = IIF(i%2==0, c-7, c+5)
	    sRet = sRet + chr(c)
	NEXT
	RETURN sRet
ENDFUNC
