void CSettingsSaver::ImportOldSettings(CPartFile* file) { SettingsList daten; CString datafilepath; datafilepath.Format(_T("%s\\%s\\%s.sivka"), file->GetTempPath(), _T("Extra Lists"), file->GetPartMetFileName()); CString strLine; CStdioFile f; if (!f.Open(datafilepath, CFile::modeReadWrite | CFile::typeText)) return; while(f.ReadString(strLine)) { if (strLine.GetAt(0) == _T('#')) continue; int pos = strLine.Find(_T('\n')); if (pos == -1) continue; CString strData = strLine.Left(pos); CSettingsData* newdata = new CSettingsData(_tstol(strData)); daten.AddTail(newdata); } f.Close(); POSITION pos = daten.GetHeadPosition(); if(!pos) return; if( ((CSettingsData*)daten.GetAt(pos))->dwData == 0 || ((CSettingsData*)daten.GetAt(pos))->dwData == 1) { file->SetEnableAutoDropNNS((((CSettingsData*)daten.GetAt(pos))->dwData)!=0); } else file->SetEnableAutoDropNNS(thePrefs.GetEnableAutoDropNNSDefault()); daten.GetNext(pos); if( ((CSettingsData*)daten.GetAt(pos))->dwData >= 0 && ((CSettingsData*)daten.GetAt(pos))->dwData <= 60000) file->SetAutoNNS_Timer(((CSettingsData*)daten.GetAt(pos))->dwData); else file->SetAutoNNS_Timer(thePrefs.GetAutoNNS_TimerDefault()); daten.GetNext(pos); if( ((CSettingsData*)daten.GetAt(pos))->dwData >= 50 && ((CSettingsData*)daten.GetAt(pos))->dwData <= 100) file->SetMaxRemoveNNSLimit((uint16)((CSettingsData*)daten.GetAt(pos))->dwData); else file->SetMaxRemoveNNSLimit(thePrefs.GetMaxRemoveNNSLimitDefault()); daten.GetNext(pos); if( ((CSettingsData*)daten.GetAt(pos))->dwData == 0 || ((CSettingsData*)daten.GetAt(pos))->dwData == 1) { file->SetEnableAutoDropFQS((((CSettingsData*)daten.GetAt(pos))->dwData)!=0); } else file->SetEnableAutoDropFQS(thePrefs.GetEnableAutoDropFQSDefault()); daten.GetNext(pos); if( ((CSettingsData*)daten.GetAt(pos))->dwData >= 0 && ((CSettingsData*)daten.GetAt(pos))->dwData <= 60000) file->SetAutoFQS_Timer(((CSettingsData*)daten.GetAt(pos))->dwData); else file->SetAutoFQS_Timer(thePrefs.GetAutoFQS_TimerDefault()); daten.GetNext(pos); if( ((CSettingsData*)daten.GetAt(pos))->dwData >= 50 && ((CSettingsData*)daten.GetAt(pos))->dwData <= 100) file->SetMaxRemoveFQSLimit((uint16)((CSettingsData*)daten.GetAt(pos))->dwData); else file->SetMaxRemoveFQSLimit(thePrefs.GetMaxRemoveFQSLimitDefault()); daten.GetNext(pos); if( ((CSettingsData*)daten.GetAt(pos))->dwData == 0 || ((CSettingsData*)daten.GetAt(pos))->dwData == 1) { file->SetEnableAutoDropQRS((((CSettingsData*)daten.GetAt(pos))->dwData)!=0); } else file->SetEnableAutoDropQRS(thePrefs.GetEnableAutoDropQRSDefault()); daten.GetNext(pos); if( ((CSettingsData*)daten.GetAt(pos))->dwData >= 0 && ((CSettingsData*)daten.GetAt(pos))->dwData <= 60000) file->SetAutoHQRS_Timer(((CSettingsData*)daten.GetAt(pos))->dwData); else file->SetAutoHQRS_Timer(thePrefs.GetAutoHQRS_TimerDefault()); daten.GetNext(pos); if( ((CSettingsData*)daten.GetAt(pos))->dwData >= 1000 && ((CSettingsData*)daten.GetAt(pos))->dwData <= 10000) file->SetMaxRemoveQRS((uint16)((CSettingsData*)daten.GetAt(pos))->dwData); else file->SetMaxRemoveQRS(thePrefs.GetMaxRemoveQRSDefault()); daten.GetNext(pos); if( ((CSettingsData*)daten.GetAt(pos))->dwData >= 50 && ((CSettingsData*)daten.GetAt(pos))->dwData <= 100) file->SetMaxRemoveQRSLimit((uint16)((CSettingsData*)daten.GetAt(pos))->dwData); else file->SetMaxRemoveQRSLimit(thePrefs.GetMaxRemoveQRSLimitDefault()); if(daten.GetCount() > 10) // emulate StulleMule <= v2.2 files { // ==> Global Source Limit (customize for files) - Stulle daten.GetNext(pos); if( ((CSettingsData*)daten.GetAt(pos))->dwData == 0 || ((CSettingsData*)daten.GetAt(pos))->dwData == 1) { file->SetGlobalHL((((CSettingsData*)daten.GetAt(pos))->dwData)!=0); } else file->SetGlobalHL(thePrefs.GetGlobalHlDefault()); // <== Global Source Limit (customize for files) - Stulle } else file->SetGlobalHL(thePrefs.GetGlobalHlDefault()); while (!daten.IsEmpty()) delete daten.RemoveHead(); if (_tremove(datafilepath)) if (errno != ENOENT) AddLogLine(true, _T("Failed to delete %s, you will need to do this manually"), datafilepath); }
CUploadQueue::CUploadQueue() : waitinglist(100) { EMULE_TRY m_hTimer = SetTimer(NULL, 141, 100, TimerProc); if (!m_hTimer) AddLogLine(LOG_FL_DBG | LOG_RGB_ERROR, _T(__FUNCTION__) _T(": Fatal Error, failed to create Timer")); m_dwDataRate = 0; m_dwBannedCount = 0; g_iCounter = 0; // Extended Upload stats m_iULSessionSuccessful = 0; m_iULSessionSuccessfulFullChunk = 0; for (int i=0; i<ETS_TERMINATOR; i++) { m_iULSessionSuccessfulPartChunk[i] = 0; m_iULSessionFailed[i] = 0; } m_iULSessionFailedNoDataForRemoteClient = 0; m_iTotalUploadTime = 0; m_dwSumUpDataOverheadInDeque = 0; m_nUpDataRateMSOverhead = 0; m_nUpDataRateOverhead = 0; m_nUpDataOverheadSourceExchange = 0; m_nUpDataOverheadFileRequest = 0; m_nUpDataOverheadOther = 0; m_nUpDataOverheadServer = 0; m_nUpDataOverheadSourceExchangePackets = 0; m_nUpDataOverheadFileRequestPackets = 0; m_nUpDataOverheadOtherPackets = 0; m_nUpDataOverheadServerPackets = 0; m_iLeftOverBandwidth = 0; m_guessedMaxLANBandwidth = 3000; m_lastGaveDataTick = ::GetTickCount(); m_dwLastScheduledBackupTick = ::GetTickCount(); m_pSaveThread = NULL; // Create event responsible for thread termination m_hQuitEvent = ::CreateEvent(NULL, TRUE, FALSE, NULL); if (m_hQuitEvent) { // Create lower priority thread that will do the "job" m_pSaveThread = AfxBeginThread(SaveSourcesThread, reinterpret_cast<LPVOID>(this), THREAD_PRIORITY_BELOW_NORMAL + g_App.m_pPrefs->GetMainProcessPriority(), CREATE_SUSPENDED); if (m_pSaveThread != NULL) { // Disable self termination, because we plan to wait for thread termination m_pSaveThread->m_bAutoDelete = FALSE; m_pSaveThread->ResumeThread(); } else AddLogLine(LOG_FL_DBG | LOG_RGB_ERROR, _T("Error creating SourcesSaveThread")); } else { AddLogLine(LOG_FL_DBG | LOG_RGB_ERROR, _T("Error creating SourcesSaveThread")); } m_strUploadLogFilePath.Format(_T("%supload.log"), g_App.m_pPrefs->GetAppDir()); #if 1 //code left for smooth migration, delete in v1.3 if (GetTextFileFormat(m_strUploadLogFilePath) == tffANSI) { CString strBackupFile(m_strUploadLogFilePath); strBackupFile += _T(".ansi"); _tremove(strBackupFile); _trename(m_strUploadLogFilePath, strBackupFile); } #endif ::InitializeCriticalSection(&m_csUploadQueueList); EMULE_CATCH2 }
int KTestCommon::CleanPathExceptLogAndPak(const TCHAR cszPath[]) { int nRetCode = false; int nResult = false; TCHAR szPathName[MAX_PATH]; TCHAR szFullPathFile[MAX_PATH]; TCHAR* pszFile = NULL; HANDLE hFindFile = INVALID_HANDLE_VALUE; WIN32_FIND_DATA FindFileData; ASSERT(cszPath); nRetCode = _sntprintf(szPathName, MAX_PATH, _T("%s\\%s"), cszPath, _T("*.*")); KGLOG_PROCESS_ERROR(nRetCode != -1); szPathName[MAX_PATH - 1] = _T('\0'); hFindFile = ::FindFirstFile(szPathName, &FindFileData); KGLOG_PROCESS_ERROR(hFindFile != INVALID_HANDLE_VALUE); while (true) { pszFile = FindFileData.cFileName; if (_tcsncmp(pszFile, _T("."), MAX_PATH) != 0 && _tcsncmp(pszFile, _T(".."), MAX_PATH) != 0 && _tcsncmp(pszFile, _T("logs"), MAX_PATH) != 0 && _tcsncmp(pszFile, _T("pak"), MAX_PATH) != 0) { nRetCode = _sntprintf(szFullPathFile, MAX_PATH, _T("%s\\%s"), cszPath, pszFile); KGLOG_PROCESS_ERROR(nRetCode != -1); szFullPathFile[MAX_PATH - 1] = _T('\0'); if (FindFileData.dwFileAttributes != FILE_ATTRIBUTE_DIRECTORY) { nRetCode = _tremove(szFullPathFile); KGLOG_PROCESS_ERROR(nRetCode == 0); } else { nRetCode = CleanPath(szFullPathFile); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = ::RemoveDirectory(szFullPathFile); KGLOG_PROCESS_ERROR(nRetCode); } } if (_tcsncmp(pszFile, _T("pak"), MAX_PATH) == 0) { nRetCode = _sntprintf(szFullPathFile, MAX_PATH, _T("%s\\pak\\update_2.pak"), cszPath); KGLOG_PROCESS_ERROR(nRetCode != -1); szFullPathFile[MAX_PATH - 1] = _T('\0'); nRetCode = _tremove(szFullPathFile); //KGLOG_PROCESS_ERROR(nRetCode == 0); } nRetCode = ::FindNextFile(hFindFile, &FindFileData); if (!nRetCode) { nRetCode = ::GetLastError(); KG_PROCESS_SUCCESS(nRetCode == ERROR_NO_MORE_FILES); } } Exit1: nResult = true; Exit0: if (hFindFile != INVALID_HANDLE_VALUE) { ::FindClose(hFindFile); hFindFile = INVALID_HANDLE_VALUE; } return nResult; }
void CPPgSecurity::OnLoadIPFFromURL() { bool bHaveNewFilterFile = false; CString url; GetDlgItemText(IDC_UPDATEURL,url); if (!url.IsEmpty()) { // add entered URL to LRU list even if it's not yet known whether we can download from this URL (it's just more convenient this way) if (m_pacIPFilterURL && m_pacIPFilterURL->IsBound()) m_pacIPFilterURL->AddItem(url, 0); CString strTempFilePath; _tmakepathlimit(strTempFilePath.GetBuffer(MAX_PATH), NULL, thePrefs.GetMuleDirectory(EMULE_CONFIGDIR), DFLT_IPFILTER_FILENAME, _T("tmp")); strTempFilePath.ReleaseBuffer(); CHttpDownloadDlg dlgDownload; dlgDownload.m_strTitle = GetResString(IDS_DWL_IPFILTERFILE); dlgDownload.m_sURLToDownload = url; dlgDownload.m_sFileToDownloadInto = strTempFilePath; if (dlgDownload.DoModal() != IDOK) { (void)_tremove(strTempFilePath); CString strError = GetResString(IDS_DWLIPFILTERFAILED); if (!dlgDownload.GetError().IsEmpty()) strError += _T("\r\n\r\n") + dlgDownload.GetError(); AfxMessageBox(strError, MB_ICONERROR); return; } CString strMimeType; GetMimeType(strTempFilePath, strMimeType); bool bIsArchiveFile = false; bool bUncompressed = false; CZIPFile zip; if (zip.Open(strTempFilePath)) { bIsArchiveFile = true; CZIPFile::File* zfile = zip.GetFile(_T("ipfilter.dat")); if (zfile == NULL) zfile = zip.GetFile(_T("guarding.p2p")); if (zfile == NULL) zfile = zip.GetFile(_T("guardian.p2p")); if (zfile) { CString strTempUnzipFilePath; _tmakepathlimit(strTempUnzipFilePath.GetBuffer(_MAX_PATH), NULL, thePrefs.GetMuleDirectory(EMULE_CONFIGDIR), DFLT_IPFILTER_FILENAME, _T(".unzip.tmp")); strTempUnzipFilePath.ReleaseBuffer(); if (zfile->Extract(strTempUnzipFilePath)) { zip.Close(); zfile = NULL; if (_tremove(theApp.ipfilter->GetDefaultFilePath()) != 0) TRACE(_T("*** Error: Failed to remove default IP filter file \"%s\" - %s\n"), theApp.ipfilter->GetDefaultFilePath(), _tcserror(errno)); if (_trename(strTempUnzipFilePath, theApp.ipfilter->GetDefaultFilePath()) != 0) TRACE(_T("*** Error: Failed to rename uncompressed IP filter file \"%s\" to default IP filter file \"%s\" - %s\n"), strTempUnzipFilePath, theApp.ipfilter->GetDefaultFilePath(), _tcserror(errno)); if (_tremove(strTempFilePath) != 0) TRACE(_T("*** Error: Failed to remove temporary IP filter file \"%s\" - %s\n"), strTempFilePath, _tcserror(errno)); bUncompressed = true; bHaveNewFilterFile = true; } else { CString strError; strError.Format(GetResString(IDS_ERR_IPFILTERZIPEXTR), strTempFilePath); AfxMessageBox(strError, MB_ICONERROR); } } else { CString strError; strError.Format(GetResString(IDS_ERR_IPFILTERCONTENTERR), strTempFilePath); AfxMessageBox(strError, MB_ICONERROR); } zip.Close(); } else if (strMimeType.CompareNoCase(_T("application/x-rar-compressed")) == 0) { bIsArchiveFile = true; CRARFile rar; if (rar.Open(strTempFilePath)) { CString strFile; if (rar.GetNextFile(strFile) && ( strFile.CompareNoCase(_T("ipfilter.dat")) == 0 || strFile.CompareNoCase(_T("guarding.p2p")) == 0 || strFile.CompareNoCase(_T("guardian.p2p")) == 0)) { CString strTempUnzipFilePath; _tmakepathlimit(strTempUnzipFilePath.GetBuffer(MAX_PATH), NULL, thePrefs.GetMuleDirectory(EMULE_CONFIGDIR), DFLT_IPFILTER_FILENAME, _T(".unzip.tmp")); strTempUnzipFilePath.ReleaseBuffer(); if (rar.Extract(strTempUnzipFilePath)) { rar.Close(); if (_tremove(theApp.ipfilter->GetDefaultFilePath()) != 0) TRACE(_T("*** Error: Failed to remove default IP filter file \"%s\" - %s\n"), theApp.ipfilter->GetDefaultFilePath(), _tcserror(errno)); if (_trename(strTempUnzipFilePath, theApp.ipfilter->GetDefaultFilePath()) != 0) TRACE(_T("*** Error: Failed to rename uncompressed IP filter file \"%s\" to default IP filter file \"%s\" - %s\n"), strTempUnzipFilePath, theApp.ipfilter->GetDefaultFilePath(), _tcserror(errno)); if (_tremove(strTempFilePath) != 0) TRACE(_T("*** Error: Failed to remove temporary IP filter file \"%s\" - %s\n"), strTempFilePath, _tcserror(errno)); bUncompressed = true; bHaveNewFilterFile = true; } else { CString strError; strError.Format(_T("Failed to extract IP filter file from RAR file \"%s\"."), strTempFilePath); AfxMessageBox(strError, MB_ICONERROR); } } else { CString strError; strError.Format(_T("Failed to find IP filter file \"guarding.p2p\" or \"ipfilter.dat\" in RAR file \"%s\"."), strTempFilePath); AfxMessageBox(strError, MB_ICONERROR); } rar.Close(); } else { CString strError; strError.Format(_T("Failed to open file \"%s\".\r\n\r\nInvalid file format?\r\n\r\nDownload latest version of UNRAR.DLL from http://www.rarlab.com and copy UNRAR.DLL into eMule installation folder."), url); AfxMessageBox(strError, MB_ICONERROR); } } else { CGZIPFile gz; if (gz.Open(strTempFilePath)) { bIsArchiveFile = true; CString strTempUnzipFilePath; _tmakepathlimit(strTempUnzipFilePath.GetBuffer(_MAX_PATH), NULL, thePrefs.GetMuleDirectory(EMULE_CONFIGDIR), DFLT_IPFILTER_FILENAME, _T(".unzip.tmp")); strTempUnzipFilePath.ReleaseBuffer(); // add filename and extension of uncompressed file to temporary file CString strUncompressedFileName = gz.GetUncompressedFileName(); if (!strUncompressedFileName.IsEmpty()) { strTempUnzipFilePath += _T('.'); strTempUnzipFilePath += strUncompressedFileName; } if (gz.Extract(strTempUnzipFilePath)) { gz.Close(); if (_tremove(theApp.ipfilter->GetDefaultFilePath()) != 0) TRACE(_T("*** Error: Failed to remove default IP filter file \"%s\" - %s\n"), theApp.ipfilter->GetDefaultFilePath(), _tcserror(errno)); if (_trename(strTempUnzipFilePath, theApp.ipfilter->GetDefaultFilePath()) != 0) TRACE(_T("*** Error: Failed to rename uncompressed IP filter file \"%s\" to default IP filter file \"%s\" - %s\n"), strTempUnzipFilePath, theApp.ipfilter->GetDefaultFilePath(), _tcserror(errno)); if (_tremove(strTempFilePath) != 0) TRACE(_T("*** Error: Failed to remove temporary IP filter file \"%s\" - %s\n"), strTempFilePath, _tcserror(errno)); bUncompressed = true; bHaveNewFilterFile = true; } else { CString strError; strError.Format(GetResString(IDS_ERR_IPFILTERZIPEXTR), strTempFilePath); AfxMessageBox(strError, MB_ICONERROR); } } gz.Close(); } if (!bIsArchiveFile && !bUncompressed) { // Check first lines of downloaded file for potential HTML content (e.g. 404 error pages) bool bValidIPFilterFile = true; FILE* fp = _tfsopen(strTempFilePath, _T("rb"), _SH_DENYWR); if (fp) { char szBuff[16384]; int iRead = fread(szBuff, 1, _countof(szBuff)-1, fp); if (iRead <= 0) bValidIPFilterFile = false; else { szBuff[iRead-1] = '\0'; const char* pc = szBuff; while (*pc == ' ' || *pc == '\t' || *pc == '\r' || *pc == '\n') pc++; if (_strnicmp(pc, "<html", 5) == 0 || _strnicmp(pc, "<xml", 4) == 0 || _strnicmp(pc, "<!doc", 5) == 0) { bValidIPFilterFile = false; } } fclose(fp); } if (bValidIPFilterFile) { (void)_tremove(theApp.ipfilter->GetDefaultFilePath()); VERIFY( _trename(strTempFilePath, theApp.ipfilter->GetDefaultFilePath()) == 0 ); bHaveNewFilterFile = true; } else { AfxMessageBox(GetResString(IDS_DWLIPFILTERFAILED), MB_ICONERROR); } } } if (url.IsEmpty() || bHaveNewFilterFile) OnReloadIPFilter(); // In case we received an invalid IP-filter file (e.g. an 404 HTML page with HTTP status "OK"), // warn the user that there are no IP-filters available any longer. if (bHaveNewFilterFile && theApp.ipfilter->GetIPFilter().GetCount() == 0) { CString strLoaded; strLoaded.Format(GetResString(IDS_IPFILTERLOADED), theApp.ipfilter->GetIPFilter().GetCount()); CString strError; strError.Format(_T("%s\r\n\r\n%s"), GetResString(IDS_DWLIPFILTERFAILED), strLoaded); AfxMessageBox(strError, MB_ICONERROR); } }
void CIPFilterDlg::OnBnClickedAppend() { CString strFilePath; if (DialogBrowseFile(strFilePath, GetResString(IDS_IPFILTERFILES))) { CWaitCursor curWait; CString strTempUnzipFilePath; CZIPFile zip; if (zip.Open(strFilePath)) { CZIPFile::File* zfile = zip.GetFile(_T("guarding.p2p")); if (zfile) { _tmakepath(strTempUnzipFilePath.GetBuffer(MAX_PATH), NULL, thePrefs.GetConfigDir(), DFLT_IPFILTER_FILENAME, _T(".unzip.tmp")); strTempUnzipFilePath.ReleaseBuffer(); if (zfile->Extract(strTempUnzipFilePath)) strFilePath = strTempUnzipFilePath; else { CString strError; strError.Format(_T("Failed to extract IP filter file \"guarding.p2p\" from ZIP file \"%s\"."), strFilePath); AfxMessageBox(strError); } } else { CString strError; strError.Format(_T("Failed to find IP filter file \"guarding.p2p\" in ZIP file \"%s\"."), strFilePath); AfxMessageBox(strError); } zip.Close(); } else { CGZIPFile gz; if (gz.Open(strFilePath)) { _tmakepath(strTempUnzipFilePath.GetBuffer(MAX_PATH), NULL, thePrefs.GetConfigDir(), DFLT_IPFILTER_FILENAME, _T(".unzip.tmp")); strTempUnzipFilePath.ReleaseBuffer(); // add filename and extension of uncompressed file to temporary file CString strUncompressedFileName = gz.GetUncompressedFileName(); if (!strUncompressedFileName.IsEmpty()) { strTempUnzipFilePath += _T('.'); strTempUnzipFilePath += strUncompressedFileName; } if (gz.Extract(strTempUnzipFilePath)) strFilePath = strTempUnzipFilePath; } gz.Close(); } if (theApp.ipfilter->AddFromFile(strFilePath, true)) { InitIPFilters(); m_ipfilter.Update(-1); } if (!strTempUnzipFilePath.IsEmpty()) _tremove(strTempUnzipFilePath); } }
void CIPFilterDlg::OnBnClickedAppend() { CString strFilePath; // Do NOT localize that string if (DialogBrowseFile(strFilePath, _T("All IP Filter Files (*ipfilter.dat;*ip.prefix;*.p2b;*.p2p;*.p2p.txt;*.zip;*.gz;*.rar)|*ipfilter.dat;*ip.prefix;*.p2b;*.p2p;*.p2p.txt;*.zip;*.gz;*.rar|eMule IP Filter Files (*ipfilter.dat;*ip.prefix)|*ipfilter.dat;*ip.prefix|Peer Guardian Files (*.p2b;*.p2p;*.p2p.txt)|*.p2b;*.p2p;*.p2p.txt|Text Files (*.txt)|*.txt|ZIP Files (*.zip;*.gz)|*.zip;*.gz|RAR Files (*.rar)|*.rar|All Files (*.*)|*.*||"))) { CWaitCursor curWait; TCHAR szExt[_MAX_EXT]; _tsplitpath(strFilePath, NULL, NULL, NULL, szExt); _tcslwr(szExt); bool bIsArchiveFile = _tcscmp(szExt, _T(".zip"))==0 || _tcscmp(szExt, _T(".rar"))==0 || _tcscmp(szExt, _T(".gz"))==0; bool bExtractedArchive = false; CString strTempUnzipFilePath; if (_tcscmp(szExt, _T(".zip")) == 0) { CZIPFile zip; if (zip.Open(strFilePath)) { CZIPFile::File* zfile = zip.GetFile(_T("guarding.p2p")); if (zfile == NULL) zfile = zip.GetFile(_T("ipfilter.dat")); if (zfile) { _tmakepathlimit(strTempUnzipFilePath.GetBuffer(MAX_PATH), NULL, thePrefs.GetMuleDirectory(EMULE_CONFIGDIR), DFLT_IPFILTER_FILENAME, _T(".unzip.tmp")); strTempUnzipFilePath.ReleaseBuffer(); if (zfile->Extract(strTempUnzipFilePath)) { strFilePath = strTempUnzipFilePath; bExtractedArchive = true; } else { CString strError; strError.Format(_T("Failed to extract IP filter file from ZIP file \"%s\"."), strFilePath); AfxMessageBox(strError, MB_ICONERROR); } } else { CString strError; strError.Format(_T("Failed to find IP filter file \"guarding.p2p\" or \"ipfilter.dat\" in ZIP file \"%s\"."), strFilePath); AfxMessageBox(strError, MB_ICONERROR); } zip.Close(); } else { CString strError; strError.Format(_T("Failed to open file \"%s\".\r\n\r\nInvalid file format?"), strFilePath); AfxMessageBox(strError, MB_ICONERROR); } } else if (_tcscmp(szExt, _T(".rar")) == 0) { CRARFile rar; if (rar.Open(strFilePath)) { CString strFile; if (rar.GetNextFile(strFile) && (strFile.CompareNoCase(_T("ipfilter.dat")) == 0 || strFile.CompareNoCase(_T("guarding.p2p")) == 0)) { _tmakepathlimit(strTempUnzipFilePath.GetBuffer(MAX_PATH), NULL, thePrefs.GetMuleDirectory(EMULE_CONFIGDIR), DFLT_IPFILTER_FILENAME, _T(".unzip.tmp")); strTempUnzipFilePath.ReleaseBuffer(); if (rar.Extract(strTempUnzipFilePath)) { strFilePath = strTempUnzipFilePath; bExtractedArchive = true; } else { CString strError; strError.Format(_T("Failed to extract IP filter file from RAR file \"%s\"."), strFilePath); AfxMessageBox(strError, MB_ICONERROR); } } else { CString strError; strError.Format(_T("Failed to find IP filter file \"guarding.p2p\" or \"ipfilter.dat\" in RAR file \"%s\"."), strFilePath); AfxMessageBox(strError, MB_ICONERROR); } rar.Close(); } else { CString strError; strError.Format(_T("Failed to open file \"%s\".\r\n\r\nInvalid file format?\r\n\r\nDownload latest version of UNRAR.DLL from http://www.rarlab.com and copy UNRAR.DLL into eMule installation folder."), strFilePath); AfxMessageBox(strError, MB_ICONERROR); } } else if (_tcscmp(szExt, _T(".gz")) == 0) { CGZIPFile gz; if (gz.Open(strFilePath)) { _tmakepathlimit(strTempUnzipFilePath.GetBuffer(MAX_PATH), NULL, thePrefs.GetMuleDirectory(EMULE_CONFIGDIR), DFLT_IPFILTER_FILENAME, _T(".unzip.tmp")); strTempUnzipFilePath.ReleaseBuffer(); // add filename and extension of uncompressed file to temporary file CString strUncompressedFileName = gz.GetUncompressedFileName(); if (!strUncompressedFileName.IsEmpty()) { strTempUnzipFilePath += _T('.'); strTempUnzipFilePath += strUncompressedFileName; } if (gz.Extract(strTempUnzipFilePath)) { strFilePath = strTempUnzipFilePath; bExtractedArchive = true; } gz.Close(); } else { CString strError; strError.Format(_T("Failed to open file \"%s\".\r\n\r\nInvalid file format?"), strFilePath); AfxMessageBox(strError, MB_ICONERROR); } } if ((!bIsArchiveFile || bExtractedArchive) && CGlobalVariable::ipfilter->AddFromFile(strFilePath, true)) { if (thePrefs.GetFilterServerByIP()) theApp.emuledlg->serverwnd->serverlistctrl.RemoveAllFilteredServers(); InitIPFilters(); m_ipfilter.Update(-1); } if (!strTempUnzipFilePath.IsEmpty()) VERIFY( _tremove(strTempUnzipFilePath) == 0); } }