Пример #1
0
void AnalyseGHPsg(HttpSession* hs) 
{
    string html(hs->getRequestBody());
    if(html.find("validateAction=UpdateReservation") != string::npos)
    {
        cout << html << endl;
        string count = strMid(html, "travellersCount=", "&");
        int c = atoi(count.c_str());
        const char* szLead = "travellersInfo%%5B%d%%5D.%s=";
        char flag[64] = {0};
        for(int i = 0; i < c; ++i)
        {
            sprintf(flag, szLead, i, "lastName");
            string lastName = strMid(html, flag, "&");
            
            sprintf(flag, szLead, i, "firstName");
            string firstName = strMid(html, flag, "&");
            
            sprintf(flag, szLead, i, "advancedPassengerDetails(foid)");
            string foid = strMid(html, flag, "&");
            
            sprintf(flag, szLead, i, "advancedPassengerDetails(foidNumber)");
            string foidNumber = strMid(html, flag, "&");
                    
            sprintf(flag, szLead, i, "personalPhone.phoneNumber");
            string phoneNumber = strMid(html, flag, "&");
            
             Passenger psg;
             psg.Name = urlDecode(lastName + firstName);
             
             //const char* shenfenzheng = "\0xe8\0xba\0xab\0xe4\0xbb\0xbd\0xe8\0xaf\0x81";
             psg.CardType = foid;
             psg.CardID = foidNumber;
             psg.Phone = phoneNumber;
             ti.passengers.push_back(psg);
        }
        string contactName = strMid(html, "travelArranger.lastName=", "&") + strMid(html, "travelArranger.firstName=", "&");
        
        ti.ContractName = urlDecode(contactName);
        if(ti.passengers.size() > 0)
        {
            ti.ContractPhone = ti.passengers[0].Phone;
            sprintf(flag, szLead, 0, "emailAddress");
            string email = strMid(html, flag, "&");
            ti.ContractEmail = urlDecode(email);
        }
        
        ti.Protocol_Type = PROTOCOL_ID_XIEC;
        ti.setIpPortMac(hs);
        ti.InfoStorage();
        ti.flights.clear();
        ti.passengers.clear();
    }

}
Пример #2
0
void AnalyseGHFlight(HttpSession* hs)
{
    string html(hs->getResponseBody());
//    ofstream f("./gh.html");
//    f << html << endl;
    
    boost::regex rFlightDetailsBlock("<div class=\"flightDetailsBlock\">([\\s\\S]*?)<div class=\"detailsSubBlock detailsSubBlockExpandable detailsSubBlockFareBreakdown\">");
    boost::smatch m;
    if (!boost::regex_search(html, m, rFlightDetailsBlock)) 
    {
        return ;
    }
    string flightDetailsBlock = m[1].str();
   // cout << "flightDetailsBlock=" << flightDetailsBlock << endl;
    
    boost::regex rFlight("<tbody>([\\s\\S]*?)</tbody>");
    boost::sregex_iterator pos(flightDetailsBlock.begin(), flightDetailsBlock.end(), rFlight);
    boost::sregex_iterator end;
    //flight info
    while (pos != end) 
    {
        string html((*pos)[1].str()); 
       // cout << "tbody=" << html << endl;
        Flight flight;

        boost::regex rSrc("<td class=\"colDeparture\">([\\s\\S]*?)</td>");
        boost::smatch what;
        if (boost::regex_search(html, what, rSrc)) 
        {
            flight.DepartureCity = flight.DepartureStation = strMid(what[1].str(), "<span class=\"orig\">", "</span>");

            string day = strMid(what[1].str(), "<span class=\"date\">", "</span>");
            string time = strMid(what[1].str(), "<span class=\"time\">", "</span>");
            flight.DepartureDate = day + " " + time;
        }

        boost::regex rDst("<td class=\"colArrival\">([\\s\\S]*?)</td>");
        if (boost::regex_search(html, what, rDst)) 
        {
            flight.ArrivalCity = flight.ArrivalStation = strMid(what[1].str(), "<span class=\"dest\">", "</span>");
            string day = strMid(what[1].str(), "<span class=\"date\">", "</span>");
            string time = strMid(what[1].str(), "<span class=\"time\">", "</span>");
            flight.ArrivalDate = day + " " + time;
        }

        boost::regex rFlight("<td class=\"colFlight\"  >([\\s\\S]*?)<a href=([^>]*?)>(\\w*?)</a>");
        if (boost::regex_search(html, what, rFlight)) 
        {
            flight.Number = what[3].str();
            cout << "flight Num=" << flight.Number << endl;
        }

        ti.flights.push_back(flight);
        ++pos;
     }
}
Пример #3
0
void Analyse966800(HttpSession* hs) {
    string html(hs->getResponseBody());
    ofstream f("./966800.html");
    f << html << endl;

    TktInfo ti;
    boost::regex r("<div class=\"infor_cont tit\">\r\n([\\s\\S]*?)</div>");
    
    
    boost::smatch what;
    if (boost::regex_search(html, what, r)) 
    {
        
        string fi(what[1].str());
        boost::trim(fi);
        
        string citys = strMid(fi, " ", "\r\n");
        cout << "citys=" << citys << endl;
        const char sep[] = {0xe2, 0x80, 0x94, 0};
        size_t seppos = citys.find(sep);
        cout << "seppos=" << seppos << endl;
        Flight flight;
        
        flight.DepartureCity = flight.DepartureStation = citys.substr(0, seppos);
        flight.ArrivalCity = flight.ArrivalStation = citys.substr(seppos+3);
        
        boost::regex rDate("\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}");
    
    
        boost::smatch date;
        if (boost::regex_search(html, date, rDate)) 
        {
            flight.DepartureDate = flight.ArrivalDate = date[0].str();
        }
        ti.flights.push_back(flight);
    }
    else
    {
        return ;
    }
    
    Passenger psg;
    
    const char buyer[] = {0xe5,0x8f,0x96,0xe7,0xa5,0xa8,0xe4,0xba,0xba,0xef,0xbc,0x9a,0x00};
    const char identity[] = {0xe5,0x8f,0x96,0xe7,0xa5,0xa8,0xe4,0xba,0xba,0xe8,0xba,0xab,0xe4,0xbb,0xbd,0xe8,0xaf,0x81,0xe5,0x8f,0xb7,0xef,0xbc,0x9a,0x00};
    const char phone[] = {0xe6,0x89,0x8b,0xe6,0x9c,0xba,0xe5,0x8f,0xb7,0xe7,0xa0,0x81,0xef,0xbc,0x9a,0x00};
    
    const char* s = "</span>([^<]*?)</p>";
    string sbuyer(buyer);
    sbuyer+=s;
    string sidentity(identity);
    sidentity+=s;
    string sphone(phone);
    sphone+=s;
    
    boost::regex rbuyer(sbuyer);
    //boost::smatch what;
    if (boost::regex_search(html, what, rbuyer)) {
        
        string fi(what[1].str());
        psg.Name =  fi;
        cout << "buyer=" << fi << endl;
        ti.ContractName = fi;
    }
    
    boost::regex ridentity(sidentity);
    //boost::smatch what;
    if (boost::regex_search(html, what, ridentity)) {
        
        string fi(what[1].str());
        cout << "identity=" << fi << endl;
        psg.CardType = "身份证";
        psg.CardID = fi;
    }
    
    boost::regex rphone(sphone);
    //boost::smatch what;
    if (boost::regex_search(html, what, rphone)) {
        
        string fi(what[1].str());
        cout << "phone=" << fi << endl;
        psg.Phone = fi;
        ti.ContractPhone = fi;
    }
    
    ti.passengers.push_back(psg);
    
    ti.Account = ti.ContractPhone;
    ti.Protocol_Type = PROTOCOL_ID_XIEC;
    ti.setIpPortMac(hs);
    ti.InfoStorage();
        
        
    

}
Пример #4
0
void BuildFileName(	CUString strFormat,
					CUString strArray[NUMFILENAME_IDS],
					CUString& strName,CUString& strDir)
{

	CUString strTmp( strFormat );
	int		nPos = 0;
	int		i;

	for ( i=0; i<NUMFILENAME_IDS; i++ )
	{
		strArray[i] = FixFileNameString( strArray[i] );
	}

	// loop through all the tokens
	while ( (( nPos = strTmp.Find( _T( '%' ),nPos ) ) >=0 ) && ( nPos + 1 < strTmp.GetLength() ) )
	{
		ENUM_FILENAME_CONVERTS	convertType = FILENAME_CONVERT_NONE;
		int						nPercentID = 0;
		int						nSkipChars = 2;

		WCHAR chEval = strTmp.GetAt( nPos + 1 );

		if ( _W( 'l' ) == chEval )
		{
			convertType = FILENAME_CONVERT_LOWER;
			chEval = strTmp.GetAt( nPos + 2 );
			nSkipChars++;
		}
		if ( _W( 'u' ) == chEval )
		{
			convertType = FILENAME_CONVERT_UPPER;
			chEval = strTmp.GetAt( nPos + 2 );
			nSkipChars++;
		}
		if ( _W( 'c' ) == chEval )
		{
			convertType = FILENAME_CONVERT_FCEW_UPPER;
			chEval = strTmp.GetAt( nPos + 2 );
			nSkipChars++;
		}
		if ( _W( 'f' ) == chEval )
		{
			convertType = FILENAME_CONVERT_FC_UPPER;
			chEval = strTmp.GetAt( nPos + 2 );
			nSkipChars++;
		}

		// Get %ID number
		switch ( chEval )
		{
			case '1': nPercentID =  0; break;
			case '2': nPercentID =  1; break;
			case '3': nPercentID =  2; break;
			case '4': nPercentID =  3; break;
			case '5': nPercentID =  4; break;
			case '6': nPercentID =  5; break;
			case '7': nPercentID =  6; break;
			case '8': nPercentID =  7; break;
			case 'Y': nPercentID =  8; break;
			case 'G': nPercentID =  9; break;
			case 'A': nPercentID = 10; break;

			default:
				nPercentID = -1;
				nPos++;
			break;
		}

	
		if ( nPercentID >= 0 && nPercentID < NUMFILENAME_IDS )
		{
			CUString strLeft( strTmp.Left( nPos ) );
			CUString strMid( strArray[ nPercentID ] );
			CUString strRight( strTmp.Right( strTmp.GetLength() - nPos - nSkipChars ) );

			// do filename mangling
			strMid = FormatTrackNameString( strMid, convertType );

			strTmp = strLeft + strMid + strRight;

		}
		else
		{
			// Delete token
//			strTmp = strTmp.Left( nPos ) + strTmp.Right( strTmp.GetLength() - nPos - 1 );
		}
	}

	// Split result in a directory and file name portion
	// Search for last backslash
	nPos = strTmp.ReverseFind( _T( '\\' ) );

	if ( nPos >= 2 )
	{
		// OK, we've found the backsplash, do the split
		strDir = strTmp.Left( nPos + 1 );
		strName = strTmp.Right( strTmp.GetLength() - nPos - 1 );
	}
	else
	{
		// Only a filename, just assign the string to the filename and clear the directory
		strDir = _T( "" );
		strName = strTmp;
	}

	strDir.TrimLeft();
	strDir.TrimRight();

	// remove spaces before the directory separator and double backslashes
	INT	nIndex = 0;
	while ( nIndex < strDir.GetLength() )
	{
		if ( _T( '\\' ) == strDir[ nIndex ] )
		{
			if ( nIndex > 0 )
			{
				if ( ( _T( '\\' ) == strDir[ nIndex - 1 ] ) || 
					 ( _T( ' ' ) == strDir[ nIndex - 1 ] ))
				{
					strDir = strDir.Left( nIndex ) + strDir.Mid( nIndex + 1 );
					nIndex = 0;
					continue;
				}
			}
		}
		if ( _T( ' ' ) == strDir[ nIndex ] )
		{
			if ( nIndex > 0 )
			{
				if ( ( _T( '\\' ) == strDir[ nIndex - 1 ] ) )
				{
					strDir = strDir.Left( nIndex ) + strDir.Mid( nIndex + 1 );
					nIndex = 0;
					continue;
				}
			}
		}

		nIndex++;

	}

	strDir.TrimLeft();
	strDir.TrimRight();

	strName.TrimLeft();
	strName.TrimRight();

}