void CDownloadProperties_MirrorsPage::FillMirrsList()
{
	fsInternetDownloader* dldr = m_dld->pMgr->GetDownloadMgr ()->GetDownloader ();

	m_wndMirrs.DeleteAllItems ();

	for (int i = 0; i < dldr->GetMirrorURLCount (); i++)
	{
		fsDownload_NetworkProperties *dnp = dldr->MirrorDNP (i);
		fsURL url;
		char szUrl [10000];
		DWORD dwLen = sizeof (szUrl);

		url.Create (fsNPToScheme (dnp->enProtocol), dnp->pszServerName,
			dnp->uServerPort, "", "", dnp->pszPathName, szUrl, &dwLen);

		m_wndMirrs.InsertItem (i, szUrl);
	}
}
Exemplo n.º 2
0
BOOL CSCRDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	((CStatic*) GetDlgItem (IDC_DLGICON))->SetIcon (LoadIcon (NULL, IDI_QUESTION));

	CString str;
	TCHAR szUrl [10000];
	DWORD dwLen = _countof (szUrl);
	fsURL url;

	url.Create (fsNPToScheme (m_dnp->enProtocol), m_dnp->pszServerName, m_dnp->uServerPort,
		NULL, NULL, m_dnp->pszPathName, szUrl, &dwLen);

	str.Format (LS (L_SIZECHANGEDWTD), szUrl);
	SetDlgItemText (IDC_MESSAGE, str);

	ApplyLanguage ();
	
	return TRUE;
}
Exemplo n.º 3
0
fsInternetResult fsInternetUploader::OpenUrl()
{
	fsInternetResult ir;
	fsUpload_NetworkProperties* dnp = &m_unp;

	BOOL bOpenAnotherReq = m_pInetFile != NULL;

	if (bOpenAnotherReq == FALSE)
	{
		m_pInetFile = new fsInternetURLFile;
		m_pInetFile->SetDialogFunc (_InetFileDialogFunc, this, 0);
	
		vmsInternetSession* pSession = new vmsInternetSession;
		char szProxy [10000];
		vmsMakeWinInetProxy (dnp->pszProxyName, dnp->enProtocol, dnp->enProtocol, szProxy);
		ir  = pSession->Create (dnp->pszAgent, dnp->enAccType, szProxy, dnp->enProtocol);
		if (ir != IR_SUCCESS)
		{
			delete pSession;
			SAFE_DELETE (m_pInetFile);
			return ir;
		}
	
		ApplyProxySettings (pSession, dnp);
	
		m_pInetFile->Initialize (pSession, TRUE);

		ApplyProperties (m_pInetFile, dnp);

		
		if (dnp->enProtocol == NP_FTP && dnp->enFtpTransferType == FTT_UNKNOWN)
		{
			int posPath = strlen (dnp->pszPathName) - 1;
			int posExt = 0;
			LPSTR pszExt = new char [MAX_PATH];

			while (posPath && dnp->pszPathName [posPath] != '.')
				pszExt [posExt++] = dnp->pszPathName [posPath--];

			if (posPath)
			{
				LPSTR pszExtension = new char [MAX_PATH];

				pszExt [posExt] = 0;

				int i = 0;
				for (i = 0; i < posExt; i++)
					pszExtension [i] = pszExt [posExt - i - 1];

				pszExtension [i] = 0;
			
				if (IsExtInExtsStr (_pDllCaller->GetSettings ()->FtpAsciiExts (), pszExtension))
					m_pInetFile->FtpSetTransferType (FTT_ASCII);
				else
					m_pInetFile->FtpSetTransferType (FTT_BINARY);

				delete [] pszExtension;
			}
			else 
			{
				m_pInetFile->FtpSetTransferType (FTT_BINARY);
			}

			delete [] pszExt;
		}
	}

	
	
	m_uPosition -= m_uPosition % m_dwUploadPartSize;

	if (bOpenAnotherReq)
	{
		ir = m_pInetFile->OpenAnotherRequestOnServer (dnp->pszPathName, m_uPosition,
			min (m_dwUploadPartSize, m_uFileSize - m_uPosition), m_uFileSize);
	}
	else
	{
		ir = m_pInetFile->OpenEx (fsNPToScheme (dnp->enProtocol), dnp->pszServerName,
					dnp->pszUserName, dnp->pszPassword, dnp->uServerPort, 
					dnp->pszPathName, m_uPosition, FALSE, 
					min (m_dwUploadPartSize, m_uFileSize - m_uPosition), m_uFileSize);
	}

	if (m_bNeedStop)
	{
		SAFE_DELETE (m_pInetFile);
		return IR_S_FALSE;
	}

	if (ir != IR_SUCCESS)
	{
		
		SAFE_DELETE (m_pInetFile);
		return ir;
	}
	
	return IR_SUCCESS;
}
Exemplo n.º 4
0
fsInternetResult fsUploadMgr::ValidateCaptcha()
{
	if (m_bCaptchaValidated)
		return IR_S_FALSE;

	Event (UMGRE_VALIDATING_UPLOAD);

	fsString strCookie;
	CString strPngFile, strCaptchaValidateUrl, strCaptchaVal;
	fsUpload_Properties up;
	ZeroMemory (&up, sizeof (up));
	vmsInternetSession* pSession = NULL;

	

	fsInternetResult ir = fsUP_GetByUrl (&up, m_strCaptchaUrl);
	if (ir != IR_SUCCESS)
		goto _lErr;

	pSession = new vmsInternetSession;
	char szProxy [10000];
	vmsMakeWinInetProxy (up.pszProxyName, up.enProtocol, up.enProtocol, szProxy);
	ir  = pSession->Create (up.pszAgent, up.enAccType, szProxy, up.enProtocol);
	if (ir != IR_SUCCESS)
		goto _lErr;
	
	pSession->SetProxyAuth (up.pszProxyUserName, up.pszProxyPassword);
	pSession->SetTimeout (up.uTimeout);

	m_memDldr.Initialize (pSession);

	m_memDldr.Get_File ()->UseHttp11 (TRUE);
	m_memDldr.Get_File ()->UseCookie (TRUE);

	ir = m_memDldr.Download (m_strCaptchaUrl);

	if (ir != IR_SUCCESS)
		goto _lErr;

	if (m_bNeedStop)
	{
		ir = IR_S_FALSE;
		goto _lErr;
	}

	strCookie = m_memDldr.Get_File ()->GetCookiesFromResponse ();

	m_memDldr.Get_File ()->CloseHandle ();
	fsUP_GetByUrl_Free (&up);

	char szTmpPath [MAX_PATH];
	GetTempPath (MAX_PATH, szTmpPath);
	if (szTmpPath [lstrlen (szTmpPath) - 1] != '\\')
		lstrcat (szTmpPath, "\\");

	int i; i = 0;
	do {
		strPngFile.Format ("%s%u%d.png", szTmpPath, m_nFileId, i++);
	}
	while (GetFileAttributes (strPngFile) != DWORD (-1));

	HANDLE hFile; hFile = CreateFile (strPngFile, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
		FILE_ATTRIBUTE_HIDDEN, NULL);
	DWORD dw;
	WriteFile (hFile, m_memDldr.Get_FileBuffer (), m_memDldr.Get_FileSize (), &dw, NULL);
	CloseHandle (hFile);

	

_lAskCaptchaValue:

	LPSTR pszCV; pszCV = strCaptchaVal.GetBuffer (100);
	*pszCV = 0;
	Event (UMGRE_NEED_ASK_CAPTCHA_VALUE, (DWORD)(LPCSTR)strPngFile, pszCV);
	strCaptchaVal.ReleaseBuffer ();

	if (strCaptchaVal.IsEmpty ())
	{
		DeleteFile (strPngFile);
		ir = IR_S_FALSE;
		goto _lErr;
	}

	

	strCaptchaVal = fsHttpUrlEncode (strCaptchaVal);

	strCaptchaValidateUrl = m_strCaptchaValidateUrl;
	strCaptchaValidateUrl.Replace ("jcaptchaCode", strCaptchaVal);
	ir = fsUP_GetByUrl (&up, strCaptchaValidateUrl);
	if (ir != IR_SUCCESS)
	{
		DeleteFile (strPngFile);
		goto _lErr;
	}

	m_networkOpFile.Initialize (pSession, FALSE);

	m_networkOpFile.SetCookies (strCookie);

	m_networkOpFile.set_EnableAutoRedirect (TRUE);

	m_networkOpFile.set_Charset ("");

	ir = m_networkOpFile.OpenEx (fsNPToScheme (up.enProtocol), up.pszServerName,
		up.pszUserName, up.pszPassword, up.uServerPort, 
		up.pszPathName, 0, FALSE, _UI64_MAX, _UI64_MAX);

	if (ir == IR_FILENOTFOUND)
		goto _lAskCaptchaValue;

	DeleteFile (strPngFile);
	
	if (ir != IR_SUCCESS)
		goto _lErr;

	m_bCaptchaValidated = TRUE;

	m_networkOpFile.CloseHandle ();

	delete pSession;

	Event (UMGRE_VALIDATING_UPLOAD_DONE);

	return IR_SUCCESS;

_lErr:
	if (pSession)
		delete pSession;
	Event (UMGRE_VALIDATING_UPLOAD_FAILED, ir);
	return ir;
}
Exemplo n.º 5
0
fsInternetResult fsUploadMgr::SendUploadDetails()
{
	if (m_bDetailsWasSent)
		return IR_S_FALSE;

	Event (UMGRE_SENDING_UPLOAD_DETAILS);

	CString str;
	fsString strDet;

	strDet = "saveDetails=&";

	strDet += "fid=";
	char sz [100]; 
	strDet += itoa (m_nFileId, sz, 10);

	strDet += "&crc=";
	str.Format ("%u", m_dwUploadFileCrc32);
	strDet += str;
	
	strDet += "&storagePeriodDays=";
	strDet += itoa (m_pkg.m_nNumberOfDaysToKeepThisUpload, sz, 10);

	strDet += "&email="; 
	strDet += fsUtf8HttpUrlEncode (m_pkg.m_strRecipientEmail);

	strDet += "&description=";
	strDet += fsUtf8HttpUrlEncode (m_pkg.m_strDescription);

	strDet += "&password="******"&confirmPassword="******"&packageName=";
		strDet += fsUtf8HttpUrlEncode (m_pkg.m_strName);

		strDet += "&packageDescription=";
		strDet += fsUtf8HttpUrlEncode (m_strZipContentsDescHtml);
	}

	strDet += "&userName="******"&userEmail=";
	strDet += fsUtf8HttpUrlEncode (m_pkg.m_strOwnerEmail);

	strDet += "&tagString=";
	strDet += fsUtf8HttpUrlEncode (m_pkg.m_strTags);

	strDet += "&plannedDownloadCount=";
	strDet += itoa (m_pkg.m_nSupposedNumberOfDlds, sz, 10);

	strDet += "&addToDirectory=";
	strDet += m_pkg.m_bAddLinkToUploadInCatalogue ? "1" : "0";

	strDet += "&FUM=1";

	fsUpload_Properties up;
	ZeroMemory (&up, sizeof (up));

	fsInternetResult ir = fsUP_GetByUrl (&up, m_strDetailsScriptUrl);
	if (ir != IR_SUCCESS)
		goto _lErr;

	vmsInternetSession* pSession; pSession = new vmsInternetSession;
	char szProxy [10000];
	vmsMakeWinInetProxy (up.pszProxyName, up.enProtocol, up.enProtocol, szProxy);
	ir = pSession->Create (up.pszAgent, up.enAccType, szProxy, up.enProtocol);
	if (ir != IR_SUCCESS)
	{
		delete pSession;
		goto _lErr;
	}
	
	pSession->SetProxyAuth (up.pszProxyUserName, up.pszProxyPassword);
	pSession->SetTimeout (up.uTimeout);

	m_networkOpFile.Initialize (pSession);

	m_networkOpFile.UseHttp11 (up.bUseHttp11);
	m_networkOpFile.UseCookie (up.bUseCookie);
	m_networkOpFile.set_Charset ("UTF-8");

	

	m_networkOpFile.set_UseMultipart (FALSE);
	m_networkOpFile.set_EnableAutoRedirect (TRUE);

	ir = m_networkOpFile.OpenEx (fsNPToScheme (up.enProtocol), up.pszServerName,
			up.pszUserName, up.pszPassword, up.uServerPort, 
			up.pszPathName, 0, FALSE, strDet.GetLength (), strDet.GetLength ());

	if (ir != IR_SUCCESS)
		goto _lErr;

	DWORD dw;
	ir = m_networkOpFile.Write ((LPBYTE)(LPCSTR)strDet, strDet.GetLength (), &dw);

	delete pSession;

	if (ir != IR_SUCCESS)
		goto _lErr;

	m_bDetailsWasSent = TRUE;

	fsUP_GetByUrl_Free (&up);

	Event (UMGRE_SENDING_UPLOAD_DETAILS_DONE);

	return IR_SUCCESS;

_lErr:
	Event (UMGRE_SENDING_UPLOAD_DETAILS_FAILED, ir);
	return ir;
}
Exemplo n.º 6
0
BOOL CDownloadProperties_GeneralPage::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();
	
	const vmsDownloadSmartPtr dld0 = m_pvDlds->at (0);
	const fsDownload_NetworkProperties *dnp0 = dld0->pMgr->GetDownloadMgr ()->GetDNP ();
	
	const int size = m_pvDlds->size ();
	

	if (size == 1)	
	{
		

		fsURL url;
		CHAR szUrl [10000];
		DWORD dwLen = sizeof (szUrl);

		url.Create (fsNPToScheme (dnp0->enProtocol), dnp0->pszServerName, dnp0->uServerPort,
			NULL, NULL, dnp0->pszPathName, szUrl, &dwLen);

		SetDlgItemText (IDC_URL, szUrl);
		SetDlgItemText (IDC_SAVEAS, m_pvDlds->at (0)->pMgr->GetDownloadMgr ()->GetDP ()->pszFileName);

		m_strUrl = szUrl;
	}
	else
	{
		

		GetDlgItem (IDC_URL)->EnableWindow (FALSE);
		GetDlgItem (IDC_SAVEAS)->EnableWindow (FALSE);
		GetDlgItem (IDC__GENERAL)->EnableWindow (FALSE);
		GetDlgItem (IDC__URL)->EnableWindow (FALSE);
		GetDlgItem (IDC__SAVEDAS)->EnableWindow (FALSE);
	}

	m_wndGroups.Fill ();

	for (int i = 1; i < size; i++)
	{
		if (dld0->pGroup->nId != m_pvDlds->at (i)->pGroup->nId)
			break;
	}

	if (i == size)	
		m_wndGroups.SelectGroup (dld0->pGroup);
	else
		m_wndGroups.SelectGroup (NULL);

	for (i = 1; i < size; i++)
	{
		if (dld0->strComment != m_pvDlds->at (i)->strComment)
			break;
	}

	if (i == size)
		SetDlgItemText (IDC_COMMENT, dld0->strComment);

	m_bCommentModified = FALSE;
	m_bNeedProcessDownloads = FALSE;

	ReadAuthorization ();  

	

	ApplyLanguage ();

	return TRUE;  
	              
}