Ejemplo n.º 1
0
bool CLoginDialog::pinReminder(){
	CString username, email;
	int country=((CComboBox*) GetDlgItem(IDC_COUNTRY))->GetCurSel();
	std::string userPhone=countries[country][1];
	userPhone.erase(std::find(userPhone.begin(), userPhone.end(), '+'));
	userPhone.erase(std::find(userPhone.begin(), userPhone.end(), '-'));
	GetDlgItemText(IDC_PHONE,username);
	username=(CString)userPhone.c_str()+username;
	GetDlgItemText(IDC_EMAIL,email);


	std::string header = "/oneworld/forgotpin?number=";
		header+=(CT2CA)username;
		header+="&email=";
		header+=(CT2CA)email;

	CInternetSession session;
	CHttpConnection *pConnection = session.GetHttpConnection(_T("89.163.142.253"));
	char result[500];
	CString request(header.c_str());
	CHttpFile *pFile = pConnection->OpenRequest(1,request);
	if(!pFile->SendRequest())
		return false;
	//pFile->QueryInfo(HTTP_QUERY_FLAG_REQUEST_HEADERS,result,(LPDWORD)500);
	
#ifdef _DEBUG
	pFile->Read((void*)result,500);
	_cprintf("%s",result);
#endif

	return true;

}
Ejemplo n.º 2
0
BOOL CMainFrame::DonwLoadFile(PSTR pURL, LPSTR SaveAsFilePath)
{
	CInternetSession session; 
	CHttpConnection* pServer = NULL; 
	CHttpFile * pHttpFile = NULL;
	CString strServerName;  //去掉http://
	CString strObject;  
	INTERNET_PORT nPort;
	DWORD dwServiceType; 
	DWORD dwHttpRequestFlags = INTERNET_FLAG_NO_AUTO_REDIRECT; //请求标志
	const TCHAR szHeaders[]=_T("Accept: text/*\r\nUser-Agent:HttpClient\r\n");
	
	BOOL OK=AfxParseURL( 
		pURL, 
		dwServiceType, 
		strServerName, 
		strObject, 
		nPort ); 
	
	pServer = session.GetHttpConnection(strServerName, nPort); //获得服务器名
	
	pHttpFile = pServer-> OpenRequest( CHttpConnection::HTTP_VERB_GET,
		strObject,
		NULL, 
		1, 
		NULL, 
		NULL,
		dwHttpRequestFlags);
	
	pHttpFile->AddRequestHeaders(szHeaders);

	try
	{
		pHttpFile->SendRequest(); //发送请求
	}
	catch (CInternetException* IE)
	{
		return false;
	}

	CStdioFile f; 
	if( !f.Open( SaveAsFilePath, 
		CFile::modeCreate | CFile::modeWrite | CFile::typeBinary ) )
	{ 
		return false;
	}
	
	TCHAR szBuf[1024];
	int length=0;
	long a=pHttpFile->GetLength();
	while (length=pHttpFile->Read(szBuf, 1023))
		f.Write(szBuf,length);
	f.Close();
	pHttpFile ->Close();
	pServer ->Close();
	if (pHttpFile != NULL) delete pHttpFile;
	if (pServer != NULL) delete pServer;
	session.Close();
	return true;
}
Ejemplo n.º 3
0
void Conference::LoadList(){
	CListCtrl *conf= (CListCtrl*)GetDlgItem(IDC_CONFLIST);
	conf->DeleteAllItems();

	std::string header = "/oneworld/conf_list?api_token=";
	header+=((CmicrosipDlg*)GetParent())->getToken();
	CInternetSession session;
	CHttpConnection *pConnection = session.GetHttpConnection(_T("89.163.142.253"));
	char result[500];
	CString request(header.c_str());
	CHttpFile *pFile = pConnection->OpenRequest(1,request);
	if(!pFile->SendRequest())
		return;
	pFile->Read((void*)result,500);
	char* status = strchr(result,']'); //checking if data is receive and is parseable
	char* eom = strchr(result,'}');
#ifdef _DEBUG
	_cprintf("Size: %p, %p, %d\n",result, status, (status-result));
#endif
	if(status==NULL)
		result[eom-result+1]='\0';
	else if(status - result < 4998)
		result[status - result +2]='\0';
#ifdef _DEBUG
	_cprintf("Result: %s\n",result);
#endif

	cJSON *root = cJSON_Parse(result);
	cJSON *msg = cJSON_GetObjectItem(root,"msg");
	if((status==NULL && msg == NULL) || status-result >= 4999 )
		return;
	else if(status==NULL)
		return;
	cJSON *data = cJSON_GetObjectItem(root,"data");
	int size=cJSON_GetArraySize(root); 
	
#ifdef _DEBUG
	_cprintf("Size: %d\n",size);
#endif
	size=cJSON_GetArraySize(data); 
	
#ifdef _DEBUG
	_cprintf("Size: %d\n",size);
#endif
	for(int i=0;i<size;i++){
		cJSON* item= cJSON_GetArrayItem(data,i);
		CString confNum(cJSON_GetObjectItem(item,"confno")->valuestring);
		CString pin(cJSON_GetObjectItem(item,"pin")->valuestring);
#ifdef _DEBUG
		_cprintf("Item: %s\n",(CT2CA)confNum);
		_cprintf("Pin: %s\n",(CT2CA)pin);
#endif
		int index = conf->InsertItem(i, confNum);
		conf->SetItemText(index, 1, pin);
		//conf->SetItemData(i, &confNum);
	}
}
Ejemplo n.º 4
0
bool CLoginDialog::registration(){

	CString phone, name, email;
	int country=((CComboBox*) GetDlgItem(IDC_COUNTRY))->GetCurSel();
	GetDlgItemText(IDC_PHONE,phone);
	GetDlgItemText(IDC_NAME,name);
	GetDlgItemText(IDC_EMAIL,email);

	std::string header = "/oneworld/webreg?country=";
	header+=countries[country][2];
	header+="&number=";
	header+=(CT2CA)phone;
	header+="&name=";
	header+=(CT2CA)name;
	header+="&email=";
	header+=(CT2CA)email;
	header+="&countrycode=";
	header+=countries[country][2];

	CInternetSession session;
	CHttpConnection *pConnection = session.GetHttpConnection(_T("89.163.142.253"));
	char result[500];
	CString request(header.c_str());
	CHttpFile *pFile = pConnection->OpenRequest(1,request);
	if(!pFile->SendRequest())
		return false;
	//pFile->QueryInfo(HTTP_QUERY_FLAG_REQUEST_HEADERS,result,(LPDWORD)500);
	
#ifdef _DEBUG
	pFile->Read((void*)result,500);
	_cprintf("%s",result);
#endif

	CString rest(result);
	int start=rest.Find(_T("success\":\""));
	if(start<0)
		return false;
	start+=((CString)_T("success\":\"")).GetLength();
	int end=rest.Find(_T("\""),start);
	if(end<0)
		return false;
	CString success=rest.Mid(start, end-start);
#ifdef _DEBUG
	_cprintf("%s",(CT2CA)success);
	_cprintf("%s",result);
#endif
	start=rest.Find(_T("msg\":\""));
	start+=((CString)_T("msg\":\"")).GetLength();
	end=rest.Find(_T("\""),start);
	CString msg=rest.Mid(start, end-start);
	SetDlgItemText(IDC_LOGTEXT,msg);
	Sleep(2000);

	return true;
}
Ejemplo n.º 5
0
CString   C51JobWebPost::GeHttptFile(const   char   *url)   
{   
	CString   szContent;   
	char   strProxyList[MAX_PATH],   strUsername[64],   strPassword[64];   
	//in   this   case   "proxya"   is   the   proxy   server   name,   "8080"   is   its   port   
	strcpy(strProxyList,   "125.41.181.59:8080");     
	strcpy(strUsername,   "myusername");   
	strcpy(strPassword,   "mypassword");   

	DWORD   dwServiceType   =   AFX_INET_SERVICE_HTTP;   
	CString   szServer,   szObject;   
	INTERNET_PORT   nPort;   
	AfxParseURL(url,   dwServiceType,   szServer,   szObject,   nPort);   

	CInternetSession   mysession;   
	CHttpConnection*   pConnection;   
	CHttpFile*   pHttpFile;   
	INTERNET_PROXY_INFO   proxyinfo;   
	proxyinfo.dwAccessType   =   INTERNET_OPEN_TYPE_PROXY;   
	proxyinfo.lpszProxy   =   strProxyList;   
	proxyinfo.lpszProxyBypass   =   NULL;   
	mysession.SetOption(INTERNET_OPTION_PROXY,   (LPVOID)&proxyinfo,   sizeof(INTERNET_PROXY_INFO));  
	pConnection   =   mysession.GetHttpConnection("125.41.181.59",     
		INTERNET_FLAG_KEEP_CONNECTION,   
		8080,   
		NULL,   NULL);   
	pHttpFile   =   pConnection->OpenRequest("GET",url,   
		NULL,   0,   NULL,   NULL,   
		INTERNET_FLAG_KEEP_CONNECTION);   
	
	//here   for   proxy
	 
	//pHttpFile->SetOption(INTERNET_OPTION_PROXY_USERNAME,   strUsername,   strlen(strUsername)+1);   
	//pHttpFile->SetOption(INTERNET_OPTION_PROXY_PASSWORD,   strPassword,   strlen(strPassword)+1);   

	pHttpFile->SendRequest(NULL);   
	DWORD   nFileSize   =   pHttpFile->GetLength();   
	LPSTR   rbuf   =   szContent.GetBuffer(nFileSize);
	UINT   uBytesRead   =   pHttpFile->Read(rbuf,   nFileSize);   
	szContent.ReleaseBuffer();   
	pHttpFile->Close();   
	delete   pHttpFile;   
	pConnection->Close();   
	delete   pConnection;   
	mysession.Close();   
	return   szContent;
}   
Ejemplo n.º 6
0
void Conference::OnDelete()
{
	
	CListCtrl *list= (CListCtrl*)GetDlgItem(IDC_CONFLIST);
	POSITION pos = list->GetFirstSelectedItemPosition();
	CString confNum;
	if (pos)
	{
		int i = list->GetNextSelectedItem(pos);
		//Call *pCall = (Call *) list->GetItemData(i);
		confNum=list->GetItemText(i,0);
	}
	if(confNum.GetLength()==0)
		return;

	std::string header = "/oneworld/conf_del?api_token=";
	header+=((CmicrosipDlg*)GetParent())->getToken();
	header+="&confno=";
	header+=(CT2CA)confNum;

#ifdef _DEBUG
	_cprintf("Request: %s\n",header);
#endif

	CInternetSession session;
	CHttpConnection *pConnection = session.GetHttpConnection(_T("89.163.142.253"));
	char result[500];
	CString request(header.c_str());
	CHttpFile *pFile = pConnection->OpenRequest(1,request);
	if(!pFile->SendRequest())
		return;
	pFile->Read((void*)result,500);
	char* status = strchr(result,']'); //checking if data is receive and is parseable
	char* eom = strchr(result,'}');
#ifdef _DEBUG
	_cprintf("Size: %p, %p, %d\n",result, status, (status-result));
#endif
	if(status==NULL)
		result[eom-result+1]='\0';
	else if(status - result < 498)
		result[status - result +2]='\0';
#ifdef _DEBUG
	_cprintf("Result: %s\n",result);
#endif
	LoadList();
}
Ejemplo n.º 7
0
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
	int nRetCode = 0;

	if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
	{
		_tprintf(_T("Fatal Error: MFC initialization failed\n"));
		nRetCode = 1;
	}
	else
	{
		CInternetSession ses;
		CHttpConnection * con;
		CHttpFile * file1=NULL;
		INTERNET_PORT port=80;
		const bufmax=10000;
		char buf[bufmax];
		int rec;
		try
		{
			//соединение с Web-сервером
			con=ses.GetHttpConnection("localhost/P-Lib",port);
			//определяем запрос
			file1=con->OpenRequest(1, "index.htm");
			//послать запрос
			file1->SendRequest();
			do
			{
				//читаем порцию или всю
				rec=file1->Read(buf,bufmax-1);
				buf[rec]='\0';
				printf("%s",buf);
			}while(rec>0);
		}
		catch(CInternetException *pe)
		{
			printf("Error!\n");
			return -1;
		}
		con->Close();
		delete file1;
	}
	return nRetCode;
}
Ejemplo n.º 8
0
void Conference::OnBnClickedConfsubmit()
{

	std::string header = "/oneworld/conf_create?api_token=";
	header+=((CmicrosipDlg*)GetParent())->getToken();
	header+="&pin=";
	CString pinNum;
	GetDlgItemText(IDC_CONFPIN,pinNum);
	header+=(CT2CA)pinNum;
	header+="&length=0";
	CInternetSession session;
	CHttpConnection *pConnection = session.GetHttpConnection(_T("89.163.142.253"));
	char result[500];
	CString request(header.c_str());
	CHttpFile *pFile = pConnection->OpenRequest(1,request);
	if(!pFile->SendRequest())
		return;
	pFile->Read((void*)result,500);
	char* status = strchr(result,']'); //checking if data is receive and is parseable
	char* eom = strchr(result,'}');
#ifdef _DEBUG
	_cprintf("Size: %p, %p, %d\n",result, status, (status-result));
#endif
	if(status==NULL)
		result[eom-result+1]='\0';
	else if(status - result < 498)
		result[status - result +2]='\0';
#ifdef _DEBUG
	_cprintf("Result: %s\n",result);
#endif

	cJSON *root = cJSON_Parse(result);
	cJSON *success = cJSON_GetObjectItem(root,"success");

	
#ifdef _DEBUG
	_cprintf("Success: %s\n",success->valuestring);
#endif
	LoadList();
}
Ejemplo n.º 9
0
void SoftUpdate::OnBnClickedButton1()
{



	m_link.ShowWindow(SW_HIDE);
	m_gif.ShowWindow(SW_SHOW);
	m_gif.Load(_T("res\\checknew.gif"));
	m_gif.Draw();
	checknew.EnableWindow(FALSE);

	DWORD dw;
	if(!IsNetworkAlive(&dw))
	{
		m_gif.ShowWindow(SW_HIDE);
		m_link.ShowWindow(SW_SHOW);
		m_link.SetWindowText(_T("<a href=\"http://www.ltplayer.com/faq.html\">网络连接断开,请检查网络设置</a>"));
		checknew.EnableWindow(TRUE);
		return;
	}


	CInternetSession mysession;
	CHttpConnection *myconn=0;
	CHttpFile *myfile=0;
	mysession.SetOption(INTERNET_OPTION_CONNECT_TIMEOUT, 5); //重试之间的等待延时 
	mysession.SetOption(INTERNET_OPTION_CONNECT_RETRIES, 1); //重试次数 
	try
	{

		myconn=mysession.GetHttpConnection(L"127.0.0.1");
		myfile=myconn->OpenRequest(L"GET",L"/index.asp");
		if(myfile->SendRequest()==0)
		{
			m_gif.ShowWindow(SW_HIDE);
			m_link.ShowWindow(SW_SHOW);
			m_link.SetWindowText(_T("<a href=\"http://www.ltplayer.com/faq.html\">网络连接断开,请检查网络设置</a>"));
			myfile->Close();
			myconn->Close();
			mysession.Close();
			delete myfile;
			delete myconn;
			myfile=0;
			myconn=0;
			checknew.EnableWindow(TRUE);
			return;
		}

		
	}
	catch (CMemoryException* e)
	{
		myfile->Close();
		myconn->Close();
		mysession.Close();
		delete myfile;
		delete myconn;
		myfile=0;
		myconn=0;
		return;
	}
	CString mystr;
	char tmp[1024];
	while(myfile->ReadString((wchar_t*)tmp,1024))
	{
		mystr+=tmp;
	}
	myfile->Close();
	myconn->Close();
	mysession.Close();
	delete myfile;
	delete myconn;
	myfile=0;
	myconn=0;

	mystr=_T("{ptm:2012-7-16,ver:0.0.1.6}");
	CString OFVERSION =GetJsonValue(mystr,_T("ver"));
	CString OFPUBLISH =GetJsonValue(mystr,_T("ptm"));
	if(OFVERSION=="" || OFPUBLISH=="")
	{
		m_gif.ShowWindow(SW_HIDE);
		m_link.ShowWindow(SW_SHOW);
		m_link.SetWindowText(_T("<a href=\"http://www.ltplayer.com/faq.html\">网络连接断开,请检查网络设置</a>"));
		checknew.EnableWindow(TRUE);
		return;
	}
	USES_CONVERSION;
	//CString mystr=_T("0.0.1.7");
	CString newversion=OFVERSION;
	int index=0;
	OFVERSION.Remove(_T('.'));
	int versiontotal=atoi(W2A(OFVERSION));
	if(versiontotal>USERVERSION)
	{
		CString cs;
		cs.Format(_T("<a href=\"http://www.ltplayer.com/download.html\">发现最新版本%s(%s),请点击更新</a>"),newversion,OFPUBLISH);
		m_gif.ShowWindow(SW_HIDE);
		m_link.ShowWindow(SW_SHOW);
		m_link.SetWindowText(cs);
		checknew.EnableWindow(TRUE);
	}
	else
	{
		m_gif.ShowWindow(SW_HIDE);
		m_link.ShowWindow(SW_SHOW);
		m_link.SetWindowText(_T("您使用的是最新版本,无需升级"));
		checknew.EnableWindow(TRUE);

	}
}
HRESULT CMainFrame::GetWMEVersionHttp(CString& WMEVersion)
{
	HRESULT RetCode = S_OK;
	WMEVersion = "0.0.0";

	CString Magic = GetRegString(HKEY_CURRENT_USER, DCGF_TOOLS_REG_PATH, "BBID");

	CInternetSession Session;
	CHttpConnection* Server = NULL;
	CHttpFile* File = NULL;

	DWORD HttpRequestFlags = INTERNET_FLAG_EXISTING_CONNECT | INTERNET_FLAG_NO_AUTO_REDIRECT;
	const TCHAR Headers[] = _T("Accept: text/*\r\nUser-Agent: WME ProjectMan\r\n");


	CString Url = LOC("/str1086/http://www.dead-code.org/vercheck.php");
	
	CString CurrVer;
	CurrVer.Format("%d.%d.%03d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD);
	
	Url += "?product=wme&ver=" + CurrVer;
	Url += "&bbid=" + Magic;
	if(DCGF_VER_BETA) Url += "&beta=1";

	bool DotNet = RegKeyExists(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\.NETFramework\\policy\\v2.0");
	Url += "&dotnet=" + CString(DotNet?"1":"0");
		
	CString ServerName;
	CString Object;
	INTERNET_PORT Port;
	DWORD ServiceType;

	try{
		if(!AfxParseURL(Url, ServiceType, ServerName, Object, Port) || ServiceType != INTERNET_SERVICE_HTTP){
			return E_FAIL;
		}


		Server = Session.GetHttpConnection(ServerName, Port);

		File = Server->OpenRequest(CHttpConnection::HTTP_VERB_GET, Object, NULL, 1, NULL, NULL, HttpRequestFlags);
		File->AddRequestHeaders(Headers);
		if(File->SendRequest()){
			TCHAR sz[1024];
			if(File->ReadString(sz, 1023)){
				WMEVersion = Entry(1, CString(sz), '\n');
			}			
		}

		File->Close();
		Server->Close();
	}
	catch (CInternetException* pEx)
	{
		// catch errors from WinINet
		//TCHAR szErr[1024];
		//pEx->GetErrorMessage(szErr, 1024);
		//MessageBox(szErr, LOC("/str1002/Error"), MB_OK|MB_ICONERROR);

		RetCode = E_FAIL;
		pEx->Delete();
	}

	if (File != NULL) delete File;
	if (Server != NULL) delete Server;
	Session.Close();

	return RetCode;
}
Ejemplo n.º 11
0
BOOL http_command(char *url, char *cmd, int timeout, char *uid, char *pwd, 
				  char *pserver, int pport, char *puid, char *ppwd, char *szReturn)
{
	BOOL bResult = TRUE;
	CString strCmdInfo = _T("");
	CString	strRemoteUrl = _T("");
	CInternetSession *psession = NULL;
	CHttpConnection* pServer = NULL;
	CHttpFile* pFile = NULL;

	if(*pserver)
	{
		char	pbuff[256] = {0};
		sprintf(pbuff, "%s:%d", pserver, pport);
		psession = new CInternetSession("WinInet", 1, 
								INTERNET_OPEN_TYPE_PROXY, pbuff, NULL, 0);
	}
	else
	{
		psession = new CInternetSession("WinInet");
	}

	try
	{
		CString strServerName;
		CString strObject;
		INTERNET_PORT nPort;
		DWORD dwServiceType;

		strCmdInfo.Format("echo %s;%s;echo %s", C_STA, cmd, C_END);
		strCmdInfo.Replace(' ', '+');
		strRemoteUrl.Format("%s?%s", url, strCmdInfo);

		if (!AfxParseURL(strRemoteUrl, dwServiceType, strServerName, strObject, nPort) ||
			dwServiceType != INTERNET_SERVICE_HTTP)
		{
			sprintf(szReturn, "%s", FuncGetStringFromIDS("<%IDS_Utils_1%>"));//<%IDS_Utils_1%>
			return FALSE;
		}

		pServer = psession->GetHttpConnection(strServerName, nPort);

		pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_GET,
			strObject, NULL, 1, NULL, NULL, INTERNET_FLAG_EXISTING_CONNECT | INTERNET_FLAG_NO_AUTO_REDIRECT);
		if(*puid)
		{
			CString	User_Pass = _T("");
			User_Pass.Format("%s:%s", puid, ppwd);

			CString	strOutput = _T("Proxy-Authorization: Basic ");

			CBase64	*pBase64 = new CBase64();
			strOutput.Insert(strOutput.GetLength(), pBase64->Encode(User_Pass, User_Pass.GetLength()));
			delete pBase64;
			pBase64 = NULL;
			
			pFile->AddRequestHeaders(strOutput);
		}

		pFile->SendRequest();

		DWORD dwRet;
		pFile->QueryInfoStatusCode(dwRet);
		if(dwRet == HTTP_STATUS_DENIED)
		{
			CString	User_Pass = _T("");
			User_Pass.Insert(User_Pass.GetLength(), uid);
			User_Pass.Insert(User_Pass.GetLength(), ':');
			User_Pass.Insert(User_Pass.GetLength(), pwd);

			CString	strOutput = _T("Authorization: Basic ");

			CBase64	*pBase64 = new CBase64();
			strOutput.Insert(strOutput.GetLength(), pBase64->Encode(User_Pass, User_Pass.GetLength()));
			delete pBase64;
			pBase64 = NULL;
			
			pFile->AddRequestHeaders(strOutput);
			pFile->SendRequest();
			pFile->QueryInfoStatusCode(dwRet);
		}

		if(dwRet == 200)
		{
			while(1)
			{
				char *ca = NULL, *cb = NULL;
				char buf[8192] = {0};
				int n = pFile->Read(buf, sizeof(buf));
				if(n == 0) break;
				buf[n] = 0;
				strncat(szReturn, buf, n);

				if(ca = strstr(szReturn, C_STA)) 
				{
					if(cb = strstr(szReturn, C_END))
					{
						ca += strlen(C_STA);
						while(*ca == 0x0A || *ca == 0x0D) ca ++;
						while(*cb == 0x0A || *cb == 0x0D) cb ++;
						strncpy(szReturn, ca, cb - ca);
						szReturn[cb - ca] = 0;
						break;
					}
				}
			}
		}
		else
		{
			sprintf(szReturn, "%ld", dwRet);
			bResult = FALSE;
		}

		if(pFile) pFile->Close();
		if(pServer) pServer->Close();
	}
	catch (CInternetException* pEx)
	{
		TCHAR szErr[1024];
		pEx->GetErrorMessage(szErr, 1024);

		sprintf(szReturn, "%s", szErr);
		
		bResult = FALSE;

		pEx->Delete();
	}

	if (pFile != NULL)
		delete pFile;
	if (pServer != NULL)
		delete pServer;
	psession->Close();
	delete psession;

	return bResult;
}
Ejemplo n.º 12
0
bool CDLsyn::PostData(LPCTSTR host, LPCTSTR object, LPCTSTR postdata, LPCTSTR refererlink, int port)
{
	CString strHeaders = _T("Content-Type:application/x-www-form-urlencoded\r\n");
	strHeaders += "Accept-Language:zh-CN\r\n";
	strHeaders += "User-Agent:Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; EmbeddedWB 14.52 from: CIBA; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)\r\n";
	strHeaders += "Host:dlive.sinaapp.com\r\n";
	strHeaders += "Connection:Keep-Alive\r\n";
	strHeaders += "Cache-Control:no-cache\r\n";
	//if(refererlink)
	//{
	//	strHeaders += "\r\nReferer:";
	//	strHeaders += refererlink;
	//}
	CStringA strFormData ="name=Value1&userid=Value2"; 
	CInternetSession session;
	CHttpConnection* pConnection = session.GetHttpConnection(host);
	if(pConnection == NULL) return false;
	CHttpFile* pFile = pConnection->OpenRequest(CHttpConnection::HTTP_VERB_POST,object);
	if(pFile == NULL) return false;
	BOOL result = pFile->SendRequest(strHeaders,(LPVOID)"nnnnnn=tt&name=Value1&userid=Value2",lstrlenA("nnnnnn=tt&name=Value1&userid=Value2"));
	if(result == FALSE) return false;
	//pFile->SendRequestEx(strFormData.GetLength()); 
	//pFile->WriteString(strFormData);
	//pFile->EndRequest();
	DWORD dwRet;
	pFile->QueryInfoStatusCode(dwRet);

	CString m_strHtml=_T("");
	char szBuff[1024];
	UINT nRead;
	pFile->Read(szBuff,1023);
	//while ((nRead = pFile->Read(szBuff,1023))>0)
	//{
	//	m_strHtml+=CString(szBuff,nRead);
	//}
	FILE *fp = fopen("C:\\11.html", "w");
	fwrite(m_strHtml, 1, m_strHtml.GetLength(), fp);
	fclose(fp);

	if (dwRet == HTTP_STATUS_OK)
	{
		return true;
	}


	//LPCSTR lpszAccept[]={"*/*"};// 响应头
	//char *szHeader=new char[3072];
	//memset(szHeader,'\0',3072);
	//char szHeader2[] =
	//{
	//		// 如果提交的是表单,那么这个 MIME 一定要带!
	//		"Content-Type: application/x-www-form-urlencoded\r\n"
	//};

	//strcat(szHeader,"Content-Type:application/x-www-form-urlencoded\r\n");
	//strcat(szHeader,"Accept-Language:zh-CN\r\n");
	////strcat(szHeader,"Referer:http://img.weisanguo.cn/swf/1.0.11120501/WeiSanGuo.swf\r\n");
	////strcat(szHeader,"x-flash-version:11,1,102,55\r\n");
	////strcat(szHeader,"Content-Length:60\r\n");
	////strcat(szHeader,"Accept-Encoding:gzip, deflate\r\n");
	//strcat(szHeader,"User-Agent:Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; QQDownload 538; EmbeddedWB 14.52 from: http://www.bsalsa.com/ EmbeddedWB 14.52; CIBA; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)\r\n");
	//strcat(szHeader,"Host:dlive.sinaapp.com\r\n");
	//strcat(szHeader,"Connection:Keep-Alive\r\n");
	//strcat(szHeader,"Cache-Control:no-cache\r\n");
	////strcat(szHeader,"Cookie:Hm_lvt_b8ba0f59a0da0b7c5da2b95a06d5edf9=1323773260859; Hm_lpvt_b8ba0f59a0da0b7c5da2b95a06d5edf9=1323773260859; saeut=114.93.56.244.1323773244671850; PHPSESSID=65180f5478b3bee238ef9c1b83ebad17\r\n");



 //   // 需要提交的数据就放下面这个变量
 //   char szPostData[] = "name=Value1&userid=Value2";
 //   // 寂寞党可以修改一下 UserAgent 哈哈,我喜欢 Chrome !
 //   HINTERNET hInet = InternetOpenA("Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1;)", INTERNET_OPEN_TYPE_DIRECT, NULL, INTERNET_INVALID_PORT_NUMBER, 0);
 //   // 第二个参数是主机的地址
 //   HINTERNET hConn = InternetConnectA(hInet, "dlive.sinaapp.com"/*www.weisanguo.cn*/, INTERNET_DEFAULT_HTTP_PORT,"", "", INTERNET_SERVICE_HTTP, 0, 1);
 //   // 第三个参数是 URL 的路径部分 你懂的,第五个参数是Referer,有些站判断来源地址,修改这里就好啦
 //   HINTERNET hGETs = HttpOpenRequestA(hConn, "POST","/test.php", HTTP_VERSIONA, "http://img.weisanguo.cn/swf/1.0.11120501/WeiSanGuo.swf", lpszAccept, INTERNET_FLAG_DONT_CACHE, 1);
	//												 
	//// 发送HTTP请求
	////HINTERNET hGETs = HttpOpenRequest(hConn, "POST","/ibaby/test.php", HTTP_VERSION, "http://img.weisanguo.cn/swf/1.0.11120501/WeiSanGuo.swf", lpszAccept, INTERNET_FLAG_DONT_CACHE, 1);

 //   BOOL bRequest = HttpSendRequestA(hGETs, szHeader, lstrlenA(szHeader),szPostData,lstrlenA(szPostData));
 //   // 不需要接受回应的忽略下面的东东...
	//char *szBuffer =new char[3072];
 //   DWORD dwByteRead = 0;
 //   // 防止乱码的方法就是建立完变量立即清空
 //   ZeroMemory(szBuffer, 3072);
 //   // 循环读取缓冲区内容直到结束
 //   while (InternetReadFile(hGETs, szBuffer, 3072, &dwByteRead) && dwByteRead > 0){
 //       // 加入结束标记
 //       szBuffer[dwByteRead] = '\0';
 //       // 应该用变长字符串的 比如 AnsiString
 //       //MessageBox(szBuffer, "1312312c",MB_OK);
 //       // 清空缓冲区以备下一次读取
 //       //ZeroMemory(szBuffer, sizeof(szBuffer));
 //   }
 //   // 清理现场
 //   InternetCloseHandle(hGETs);
 //   InternetCloseHandle(hConn);
 //   InternetCloseHandle(hInet);
	return false;
}
Ejemplo n.º 13
0
int CUG_HTML_DataSource::Open(LPCTSTR name,LPCTSTR option)
{

	// close the current table
	Close();
	CWaitCursor wait;
	char* buff=NULL;
	long length=0;
	int number=1;


	// retrieve the table number
	if(option!=NULL)
		number = _ttoi(option);

	// if this is an URL it *must* have http:// in front of it.
	if(_tcsstr(name,_T("http://"))==NULL)
	{
		// open the file and read it into memory 
		try 
		{
			CFile file(name, CFile::modeRead);
			length = file.GetLength();
			buff = new char[length+1];
			file.Read(buff, length);
		}
		catch(CFileException* e)
		{
			e->ReportError();
			e->Delete();
		}
	}
	else
	{	
		// try to open the given URL and read it into memory
		CInternetSession session;
		CHttpConnection* pServer=NULL;
		CHttpFile* pHttpFile=NULL;
		try
		{
			// check to see if this is a reasonable URL
			CString strServerName;
			CString strObject;
			INTERNET_PORT nPort;
			DWORD dwServiceType;

			if (!AfxParseURL(name, dwServiceType, strServerName, strObject, nPort) ||
				dwServiceType != INTERNET_SERVICE_HTTP)
			{
				AfxMessageBox(_T("Error: can only use URLs beginning with http://\n"));
				TRACE ( _T("Error: can only use URLs beginning with http://\n"));
				return UG_ERROR;
			}
			// open the connection and request
			pServer = session.GetHttpConnection(strServerName, nPort);
			ASSERT(pServer);
			pHttpFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_GET,
				strObject, NULL, 1, NULL, NULL);
			ASSERT (pHttpFile);

			// get the http stream
			pHttpFile->SendRequest();
			DWORD dwRet;
			pHttpFile->QueryInfoStatusCode(dwRet);
			if(dwRet>=200 && dwRet <300)
			{
				length = pHttpFile->GetLength();
				buff = new char[length+1];
				pHttpFile->SetReadBufferSize(length+1);
				pHttpFile->Read(buff, length);
			}
//#ifdef _DEBUG
			else {
				AfxMessageBox(_T("HTTP Query Failed"));
				TRACE (_T("HTTP Query Failed\n"));
			}
//#endif
		}
		catch(CException* e)
		{
			e->ReportError();
			e->Delete();
		}

		// do some clean up
		if(pHttpFile)
		{
			pHttpFile->Close();
			delete pHttpFile;
		}
		if(pServer)
		{
			pServer->Close();
			delete pServer;
		}

	}

	// buff should hold the "file" information
	if(buff)
	{
		int res = LoadTable(buff,buff+length,number);
		TRACE(_T("Result of LoadTable == %d\n"), res);
		if(res == 0)
			AfxMessageBox(_T("No tables found in file!"));
		// update control info
		if(m_ctrl!=NULL)
		{
			m_ctrl->SetNumberRows(m_rows);
			m_ctrl->SetNumberCols(m_cols);
			m_ctrl->RedrawAll();
		}
	}
	else
		return UG_ERROR;


	// delete the temporary mem buffer
	if(buff)
		delete [] buff;

	
	return UG_SUCCESS;
}
Ejemplo n.º 14
0
//负责接收上传操作的页面的URL ,待上传的本地文件路径
int  CWebBase::UploadFile(LPCTSTR strURL, LPCTSTR strLocalFileName)
{
	ASSERT(strURL != NULL && strLocalFileName != NULL);

	BOOL bResult = FALSE;
	DWORD dwType = 0;
	CString strServer;
	CString strObject;
	INTERNET_PORT wPort = 0;
	DWORD dwFileLength = 0;
	char * pFileBuff = NULL;

	CHttpConnection * pHC = NULL;
	CHttpFile * pHF = NULL;
	CInternetSession cis;

	bResult =  AfxParseURL(strURL, dwType, strServer, strObject, wPort);
	if(!bResult)
	{
		return FALSE;
	}
	CFile file;
	try
	{
		if(!file.Open(strLocalFileName, CFile::shareDenyNone | CFile::modeRead))
			return FALSE;
		dwFileLength = file.GetLength();
		if(dwFileLength <= 0)
			return FALSE;
		pFileBuff = new char[dwFileLength];
		memset(pFileBuff, 0, sizeof(char) * dwFileLength);
		file.Read(pFileBuff, dwFileLength);

		const int nTimeOut = 5000;
		cis.SetOption(INTERNET_OPTION_CONNECT_TIMEOUT, nTimeOut); //联接超时设置
		cis.SetOption(INTERNET_OPTION_CONNECT_RETRIES, 1);  //重试1次
		pHC = cis.GetHttpConnection(strServer, wPort);  //取得一个Http联接

		pHF = pHC->OpenRequest(CHttpConnection::HTTP_VERB_POST, strObject);
		if(!pHF->SendRequest(NULL, 0, pFileBuff, dwFileLength))
		{
			delete[]pFileBuff;
			pFileBuff = NULL;
			pHF->Close();
			pHC->Close();
			cis.Close();
			return FALSE;
		}
		DWORD dwStateCode = 0;
		pHF->QueryInfoStatusCode(dwStateCode);

		if(dwStateCode == HTTP_STATUS_OK)
			bResult = TRUE;
	}

	catch(CInternetException * pEx)
	{
		char sz[256] = "";
		pEx->GetErrorMessage(sz, 25);
		CString str;
		str.Format("InternetException occur!\r\n%s", sz);
		AfxMessageBox(str);
	}
	catch(...)
	{
		DWORD dwError = GetLastError();
		CString str;
		str.Format("Unknow Exception occur!\r\n%d", dwError);
		AfxMessageBox(str);
	}

	delete[]pFileBuff;
	pFileBuff = NULL;
	file.Close();
	pHF->Close();
	pHC->Close();
	cis.Close();
	return bResult;
}
CString CHttpRequest::Download (CString strURL, int nMethod, CString strHeaders, CString strData,
	CString strFilename,
	bool* pbCancelDownload, DWORD dwDownloadId, int& nError, int nApproxContentLength,									   
	HWND hwndProgress, HWND hwndStatus, CString strMsg)
{
	gl_stkDownloads.push_back (dwDownloadId);

	bool bUseFile = !strFilename.IsEmpty ();
	strStatusMsg = bUseFile ? strFilename : strMsg;

	// show the UI controls
	if (dwDownloadId == gl_stkDownloads.back ())
	{
		if (hwndProgress != NULL)
		{
			::PostMessage (hwndProgress, PBM_SETPOS, 0, 0);
			::ShowWindow (hwndProgress, SW_SHOW);
		}

		if (hwndStatus != NULL)
			::PostMessage (hwndStatus, SB_SETTEXT, 1, (LPARAM) strStatusMsg.GetBuffer (0));
	}

	/*
	CString strDisplayFilename, strDisplay;
	if (!strFilename.IsEmpty () && (pStatus != NULL))
	{
		strcpy (strDisplayFilename.GetBuffer (strFilename.GetLength () + 1), strFilename.GetBuffer (0));
		strDisplayFilename.ReleaseBuffer ();

		// needs ellipsis?
		CRect r;
		pStatus->GetWindowRect (&r);
		r.right -= 300;
		HDC hdc = ::GetWindowDC (pStatus->GetSafeHwnd ());
		::DrawText (hdc, strDisplayFilename, -1, &r, DT_PATH_ELLIPSIS | DT_MODIFYSTRING);
		::ReleaseDC (pStatus->GetSafeHwnd (), hdc);
	}*/

	CHttpConnection* pHttpConnection = NULL;
	CHttpFile* pHttpFile = NULL;
	LPVOID lpvoid = NULL;

	DWORD dwServiceType;
	CString strServer, strObject;
	INTERNET_PORT nPort;
	AfxParseURL (strURL, dwServiceType, strServer, strObject, nPort);

	// declare CMyInternetSession object
	CInternetSession InternetSession (NULL,
		//"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; (R1 1.3))",
		1, INTERNET_OPEN_TYPE_PRECONFIG);

	CString strRetData;

	try
	{
		// establish the HTTP connection
		pHttpConnection = InternetSession.GetHttpConnection (strServer, nPort, "", "");

		// open the HTTP request
		pHttpFile = pHttpConnection->OpenRequest (nMethod, strObject, NULL, 1, NULL,
			NULL, INTERNET_FLAG_EXISTING_CONNECT | INTERNET_FLAG_NO_AUTO_REDIRECT | INTERNET_FLAG_TRANSFER_BINARY);

		if (pHttpFile->SendRequest (strHeaders, strHeaders.GetLength (),
			static_cast<void*>(strData.GetBuffer (0)), strData.GetLength ()))
		{
			DWORD dwRet;
			// query the HTTP status code
			pHttpFile->QueryInfoStatusCode (dwRet);
			if (dwRet >= 400)
			{
				nError = dwRet;
				gl_stkDownloads.remove (dwDownloadId);
				return "";
			}
			
			CString strContentLen;
			LPSTR lpszResult = NULL;
			UINT nRead = 0, nTotalRead = 0;

			lpvoid = malloc (HTTPFILE_BUFFLEN);
			// memory error
			if (!lpvoid)
			{
				AfxMessageBox("Error allocating memory");
				if (pHttpConnection)
				{
					pHttpConnection->Close();
					delete pHttpConnection;
				}
				if (pHttpFile)
				{
					pHttpFile->Close();
					delete pHttpFile;
				}
				nError = -1;
				gl_stkDownloads.remove (dwDownloadId);
				return "";
			}

			CFile f1;

			DWORD dwSize;
			if (!pHttpFile->QueryInfo (HTTP_QUERY_CONTENT_LENGTH, dwSize))
				dwSize = nApproxContentLength;
			if ((dwDownloadId == gl_stkDownloads.back ()) && (hwndProgress != NULL))
				::PostMessage (hwndProgress, PBM_SETRANGE32, 0, dwSize);

			if (bUseFile)
				if (!f1.Open (strFilename, CFile::modeCreate | CFile::modeWrite))
				{
					nError = -1;
					gl_stkDownloads.remove (dwDownloadId);
					return "";
				}

			DWORD dwStart = GetTickCount ();

			// read the HTTP response
			while (nRead = pHttpFile->Read ((byte*) lpvoid + (bUseFile ? 0 : nTotalRead), HTTPFILE_BUFFLEN))
			{
				if (pbCancelDownload != NULL)
					if (*pbCancelDownload)
					{
						// download cancelled
						if (pHttpConnection)
						{
							pHttpConnection->Close();
							delete pHttpConnection;
						}
						if (pHttpFile)
						{
							pHttpFile->Close();
							delete pHttpFile;
						}

						// delete the file
						if (bUseFile)
						{
							f1.Close ();
							CFile::Remove (strFilename);
						}

						nError = -1;
						gl_stkDownloads.remove (dwDownloadId);
						return "";
					}

				nTotalRead += nRead;

				// store the data
				if (bUseFile)
					f1.Write (lpvoid, nRead);
				else
				{
					lpvoid = realloc (lpvoid, nTotalRead + HTTPFILE_BUFFLEN);
					if (!lpvoid)
					{
						AfxMessageBox ("Error allocating memory");
						if (pHttpConnection)
						{
							pHttpConnection->Close();
							delete pHttpConnection;
						}
						if (pHttpFile)
						{
							pHttpFile->Close();
							delete pHttpFile;
						}

						nError = -1;
						gl_stkDownloads.remove (dwDownloadId);
						return "";
					}
				}

				// UI Feedback
				if (dwDownloadId == gl_stkDownloads.back ())
				{
					// update progress control
					if (hwndProgress != NULL)
						::PostMessage (hwndProgress, PBM_SETPOS, nTotalRead, 0);

					if (hwndStatus != NULL)
					{
						strKB.Format (IDS_DOWNLOADSTATUS_KB,
							nTotalRead / 1024,			// KBs read
							dwSize / 1024);				// Total size (KBs)
						::PostMessage (hwndStatus, SB_SETTEXT, 2, (LPARAM) strKB.GetBuffer (0));

						// percentage
						if (dwSize != 0)
						{
							strPercent.Format (IDS_DOWNLOADSTATUS_PERCENT, nTotalRead * 100 / dwSize);
							::PostMessage (hwndStatus, SB_SETTEXT, 3, (LPARAM) strPercent.GetBuffer (0));
						}

						// KB/s
						strKBs.Format (IDS_DOWNLOADSTATUS_KBS, (double) nTotalRead / 1024.0 / ((GetTickCount () - dwStart) / 1000.0 + 1));
						::PostMessage (hwndStatus, SB_SETTEXT, 4, (LPARAM) strKBs.GetBuffer (0));
					}
				}
			}
					
			if (bUseFile)
				f1.Close();
			else
			{
				// get response headers
				LPSTR lpszBuf = strRetData.GetBuffer (nTotalRead + HTTPFILE_BUFFLEN);
				DWORD dwBufLen = HTTPFILE_BUFFLEN;
				pHttpFile->QueryInfo (HTTP_QUERY_RAW_HEADERS_CRLF, lpszBuf, &dwBufLen);

				// copy contents
				*((LPSTR) lpvoid + nTotalRead) = 0;
				strcpy (lpszBuf + dwBufLen - 1, (LPSTR) lpvoid);

				strRetData.ReleaseBuffer ();
			}
		}
	}
	catch(CInternetException *e)
	{
		//e->ReportError();
		char szError[1001];
		e->GetErrorMessage (szError, 1000);
		CString strMsg;
		strMsg.Format (IDS_ERROR_HTTPREQUEST, strURL.GetBuffer (-1), szError);
		AfxMessageBox (strMsg, MB_ICONEXCLAMATION);

		e->Delete();
	}

	// cleanup
	if (lpvoid)
		free (lpvoid);

	if (pHttpFile)
	{
		pHttpFile->Close();
		delete pHttpFile;
	}
	if (pHttpConnection)
	{
		pHttpConnection->Close();
		delete pHttpConnection;
	}

	// hide UI controls
	if (dwDownloadId == gl_stkDownloads.back ())
	{
		if (hwndProgress != NULL)
			::ShowWindow (hwndProgress, SW_HIDE);
		if (bUseFile)
			if (hwndStatus != NULL)
				for (int i = 1; i <= 4; i++)
					::PostMessage (hwndStatus, SB_SETTEXT, i, (LPARAM) "");
	}

	gl_stkDownloads.remove (dwDownloadId);
	return strRetData;
}
Ejemplo n.º 16
0
BOOL CLoginDlg::AuthWeb()
{
	CString csBuff;
	char		httpBuff[1024];
	CString		csHash;
	CMD5		md5SPIP;
	int			nBytes;
	unsigned char	lpszBuffer[16];

	// Authentication for web pages
	TRY 
	{
		CInternetSession session;
		CString csIdSession, csSession;

		csBuff.Empty();
		memset(httpBuff, 0, 1024);
		session.SetOption(INTERNET_OPTION_CONNECT_TIMEOUT, 1000);
		session.SetOption(INTERNET_OPTION_CONNECT_RETRIES, 3);

		CFile*	pf	= session.OpenURL(URL_LOGIN_WEB, 1, INTERNET_FLAG_TRANSFER_BINARY | INTERNET_FLAG_RELOAD);

		while(nBytes = pf->Read(httpBuff, 1024)) 
		{
			csBuff	+= httpBuff;
		}
		pf->Close();
		if(csBuff.Find('/') != -1)
		{
			csSession	= csBuff.Left(csBuff.Find('/'));
			csIdSession	= csBuff.Mid(csSession.GetLength()+1);

			md5SPIP.SetContent(APP.m_csPassword + csSession);
			memset(lpszBuffer, 0, 16);
			md5SPIP.GetDigest(lpszBuffer);
			csHash	= md5SPIP.ConvertToAscii(lpszBuffer);
			APP.m_bAuthWeb	= TRUE;

			TRY
			{
				CHttpConnection*	phttp	= session.GetHttpConnection(_T(RYZOM_HOST));
				CHttpFile*			pfile	= phttp->OpenRequest(CHttpConnection::HTTP_VERB_POST, "/betatest/betatest_login_valid.php");
				if(pfile)
				{
					CString csHeaders = _T("Content-Type: application/x-www-form-urlencoded");
					CString csFormParams = _T("txtLogin="******"&digest="+csHash+"&idsession="+csIdSession);
					
					TRY
					{
						csBuff.Empty();
						pfile->SendRequest(csHeaders, (LPVOID)(LPCTSTR)csFormParams, csFormParams.GetLength());

					   UINT nRead = pfile->Read(csBuff.GetBuffer(15000), 14999);
					   csBuff.ReleaseBuffer();
					   csBuff.SetAt(nRead, 0);
					   if(csBuff.Find("/news/") == -1)
					   {
							APP.m_bAuthWeb	= FALSE;
					   }
					}
					CATCH_ALL(error)
					{
						APP.m_bAuthWeb	= FALSE;
					}
					END_CATCH_ALL;

					delete pfile;
				}
				else
				{
					APP.m_bAuthWeb	= FALSE;
				}
			}
			CATCH_ALL(error)
			{
				APP.m_bAuthWeb	= FALSE;
			}
			END_CATCH_ALL;
		}
Ejemplo n.º 17
0
bool CLoginDialog::requestPassword(){
	CString header = _T("Content-Type: application/x-www-form-urlencoded");
	CInternetSession session;
	CHttpConnection *pConnection = session.GetHttpConnection(_T("89.163.142.253"));
	CHttpFile *pFile = pConnection->OpenRequest(CHttpConnection::HTTP_VERB_POST,_T("/oneworld/login"));
	
	std::string req="submit=1&number=";
	req+=(CT2CA)m_Account.username;
	req+="&pincode=";
	req+=(CT2CA)m_Account.password;

#ifdef _DEBUG
	_cprintf("Address: 89.163.142.253\n");
	_cprintf("Request: %s\n",req.c_str());
#endif

	long len = req.length();
	BOOL res = pFile->SendRequest(header,lstrlen(header), (LPVOID)req.c_str(),len);

	if(!res){
#ifdef _DEBUG
	_cprintf("Request failed!!!!\n");
#endif
		return res;
	}
	//pFile
	char result[500];
	pFile->Read(result,500);
#ifdef _DEBUG
	_cprintf("***********************************\n");
	_cprintf("%s\n",result);
	_cprintf("***********************************\n");
#endif
	CString rest(result);
	int start=rest.Find(_T("password\":\""));
	if(start<0)
		return false;
	start+=((CString)_T("password\":\"")).GetLength();
	int end=rest.Find(_T("\""),start);
	if(end<0)
		return false;
	CString password=rest.Mid(start, end-start);
#ifdef _DEBUG
	_cprintf("%s\n",(CT2CA)password);
	_cprintf("%s\n",result);
#endif

	start=rest.Find(_T("fname\":\""));
	if(start<0)
		return false;
	start+=((CString)_T("fname\":\"")).GetLength();
	end=rest.Find(_T("\""),start);
	if(end<0)
		return false;
	CString name=rest.Mid(start, end-start);
#ifdef _DEBUG
	_cprintf("%s\n",(CT2CA)name);
	_cprintf("%s\n",result);
#endif


	start=rest.Find(_T("api_token\":\""));
	if(start<0)
		return false;
	start+=((CString)_T("api_token\":\"")).GetLength();
	end=rest.Find(_T("\""),start);
	if(end<0)
		return false;
	CString token=rest.Mid(start, end-start);
	std::string strToken=(CT2CA)token;
	((CmicrosipDlg*)GetParent())->setToken(strToken);
	std::string pin=(CT2CA)m_Account.password;
	((CmicrosipDlg*)GetParent())->setPin(pin);
	//GetParent();
#ifdef _DEBUG
	_cprintf("%s\n",(CT2CA)token);
	_cprintf("%s\n",result);
#endif

	m_Account.password=password;
	m_Account.displayName=name;
	return true;
}