Exemplo n.º 1
0
void XaLanguage::List() {

	vector<string> WhereFields={};
	vector<string> WhereValues={};
	vector<string> OrderByFields={};
	vector<string> GroupByFields={};

	string PassedLimit=HTTP.GetHttpParam("limit");
	int Limit={0};

	if (PassedLimit!="NoHttpParam") {
		Limit=FromStringToInt(PassedLimit);
	};

	string OrderBy=HTTP.GetHttpParam("order_by");
	string Status=HTTP.GetHttpParam("status");

	vector<string> ReturnedFields=ListPrepare({"XaLanguage"},"/XaLanguage/fieldset/field");

	DbResMap DbRes=XaLibSql::Select(DB_READ,"XaLanguage",{ReturnedFields},{WhereFields}, {WhereValues}, {OrderByFields},{GroupByFields},Limit);
	RESPONSE.Content=ListResponse(DbRes,ReturnedFields);	
	//Quali campi
	//
	/*
	vector<string> FieldsToRead = XaLibModel::ReadPrepare({"XaLanguage"},"/XaLanguage/fieldset/field");
	DbResMap DbRes = ReadExecute("XaLanguage",FieldsToRead,HTTP.GetHttpParam("id"));
	RESPONSE.Content= ReadResponse(DbRes,FieldsToRead);
	*/
};
Exemplo n.º 2
0
void XaUserAddressPhone::Update() {

	int Id=FromStringToInt(HTTP.GetHttpParam("id"));
        vector<string> FieldName;	
	vector<string> FieldValue;
	UpdatePrepare({"XaUserAddressPhone"},"/XaUserAddressPhone/fieldset/field",FieldName,FieldValue);
	RESPONSE.Content=UpdateResponse(UpdateExecute("XaUserAddressPhone",FieldName,FieldValue,Id));
};
Exemplo n.º 3
0
/*TEST CASE
 TUTTE LE COMBINAZIONI
 */
void XaUserLogin::Login () {

	string StrUsername=HTTP.GetHttpParam("username");
	string StrPassword=HTTP.GetHttpParam("password");

	if (StrUsername !="" && StrPassword !="") {

		string ShaPassword=XaLibCrypto::GetSha1(StrPassword);

		LOG.Write("INF", __FILE__, __FUNCTION__,__LINE__,"USER Encrypted Password -> "+ShaPassword);
		
		string SqlQry="SELECT id FROM XaUser WHERE username=\""+StrUsername+"\" AND password=\""+ShaPassword+"\" AND status in (0,1)";
		DbResMap DbRes=XaLibSql::FreeQuerySelect(DB_SESSION,SqlQry);

		int n=DbRes.size();

		if (n==0) {

			LOG.Write("ERR", __FILE__, __FUNCTION__,__LINE__,"ERROR-45: USER Does Not Exist Or The Password Is Wrong -> " + StrUsername);
			throw 45;

		} else if (n==1){

			LOG.Write("INF", __FILE__, __FUNCTION__,__LINE__,"USER Valid With ID ->"+DbRes[0]["id"]);

			XaLibToken LibToken;

			int TokenCheck=LibToken.CheckUserToken(atoi(DbRes[0]["id"].c_str()));

			if (TokenCheck==1) {

				LOG.Write("INF", __FILE__, __FUNCTION__,__LINE__,"USER already has a Token to Deactivate");
				LibToken.DeactivateUserToken (atoi(DbRes[0]["id"].c_str()));
			}

			SESSION.Token=LibToken.CreateToken(FromStringToInt(DbRes[0]["id"]));

			LOG.Write("INF", __FILE__, __FUNCTION__,__LINE__,"USER Valid With ID ->"+DbRes[0]["id"]+" And Token  ->"+RESPONSE.Content);

		} else {

			LOG.Write("ERR", __FILE__, __FUNCTION__,__LINE__,"ERROR-46: User Is Not Unique");
			throw 46;
		}

	} else {

		LOG.Write("ERR", __FILE__, __FUNCTION__,__LINE__,"ERROR-47: Username Or Password Is Empty");
		throw 47;
	}

};
Exemplo n.º 4
0
void XaLibAction::CheckResponse(const string& Response) {

	xmlDocPtr XmlResponse=XaLibDom::DomFromString(Response);
	string Error=XaLibDom::GetElementValueByXPath(XmlResponse,"//error/number");

	if (Error!="ELEMENT-NOT-DEFINED") {

		string Description=XaLibDom::GetElementValueByXPath(XmlResponse,"//error/description");

		LOG.Write("ERR", __FILE__, __FUNCTION__,__LINE__,"BackEnd Returned An Error-> Number "+Error+" :: Description "+Description);

		throw FromStringToInt(Error);
	}
};
Exemplo n.º 5
0
int XaLibModel::DeleteExecute(const string& DbTable,const string& FieldId) {

    //TODO: ERROR CHECK
    if (XaLibSql::Update(DB_WRITE,DbTable, {"status"}, {"4"}, {"id"}, {FieldId})==1) {

        return FromStringToInt(FieldId);

    }
    else {

        return 0;
    }

};
Exemplo n.º 6
0
string XaLibHttp::SetCookie(){

	string cookie="";

	if (SESSION.Token.size()==FromStringToInt(SETTINGS["SessionIdLength"])){
	
		string cookie1="Set-Cookie:XaSessionId=";
		string cookie2=";path=/;HttpOnly;";
		cookie= cookie1+SESSION.Token+cookie2;

		LOG.Write("INF", __FILE__, __FUNCTION__,__LINE__,"Generated Set Cookie -> " +cookie);

	} else {
		
		LOG.Write("ERR", __FILE__, __FUNCTION__,__LINE__,"Error Creating Cookie -> " +cookie);

		throw 801;
	};
	
return cookie;
};
Exemplo n.º 7
0
void XaUserAddressPhone::List() {

	vector<string> WhereFields={};
	vector<string> WhereValues={};
	vector<string> OrderByFields={};
	vector<string> GroupByFields={};

	string PassedLimit=HTTP.GetHttpParam("limit");
	int Limit={0};

	if (PassedLimit!="NoHttpParam") {
		Limit=FromStringToInt(PassedLimit);
	};

	string OrderBy=HTTP.GetHttpParam("order_by");
	string Status=HTTP.GetHttpParam("status");

	vector<string> ReturnedFields=ListPrepare({"XaUserAddressPhone"},"/XaUserAddressPhone/fieldset/field");

	DbResMap DbRes=XaLibSql::Select(DB_READ,"XaUserAddressPhone",{ReturnedFields},{WhereFields}, {WhereValues}, {OrderByFields},{GroupByFields},Limit);
	RESPONSE.Content=ListResponse(DbRes,ReturnedFields);

};
Exemplo n.º 8
0
void XaLanguage::ListAsOptions() {

	vector<string> WhereFields={};
	vector<string> WhereValues={};
	vector<string> OrderByFields={};
	vector<string> GroupByFields={};

	/*LIMIT*/
	string PassedLimit=HTTP.GetHttpParam("limit");
	int Limit={0};

	if (PassedLimit!="NoHttpParam") {
		Limit=FromStringToInt(PassedLimit);
	};

	/*ORDER BY*/
	string PassedOrderBy=HTTP.GetHttpParam("order_by");
	
	if (PassedOrderBy!="NoHttpParam") {
	
		OrderByFields.push_back(PassedOrderBy);
	};
	
	/*STATUS*/
	string PassedStatus=HTTP.GetHttpParam("status");
	
	if (PassedStatus!="NoHttpParam") {

		WhereFields.push_back("status");
		WhereValues.push_back(PassedStatus);
	};

	vector<string> ReturnedFields={"id","name"};

	DbResMap DbRes=XaLibSql::Select(DB_READ,"XaLanguage",{ReturnedFields},{WhereFields}, {WhereValues}, {OrderByFields},{GroupByFields},Limit);
	RESPONSE.Content=ListResponse(DbRes,ReturnedFields);
};