Site Manager
-
- Posts: 1
- Joined: Thu Aug 31, 2023 6:21 pm
Site Manager
Is there a converter or another working solution to change sites in sitemanager from versions: ftprush 2.2 and so on to new ftprush 3.x ? Since ftprush 3.x got .json and old ones got csv html plaintext and xml...
-
- Site Admin
- Posts: 2091
- Joined: Tue Sep 29, 2009 6:09 am
Re: Site Manager
OK, you may click the button "Terminal" on the tool bar, and excute the following C# script to import v2 sites (suppose you already exported sites to a csv file "d:/v2sites.txt"):
Code: Select all
using System.IO;
string csvFilePath = "d:/v2sites.txt";
using (TextReader reader = new StreamReader(csvFilePath))
{
string line;
reader.ReadLine();
while ((line = reader.ReadLine()) != null)
{
string[] fields = line.Split(',');
string strName = fields[0];
string strHost = fields[1];
int nPort = int.Parse(fields[2]);
string User = fields[3];
string Pass = fields[4];
string RemotePath = fields[5];
if(strName.Contains("@"))
{
string[] arrName = strName.Split('@');
strName = arrName[1];
}
else if(strName.Contains(":"))
{
string[] arrName = strName.Split(':');
strName = arrName[1];
}
int nProtocol = 1; //1=FTP,2=SFTP,3=TFTP
if(nPort == 69 && User == "" && Pass == "")
{
nProtocol = 3;
}
else if(nPort == 22 || nPort == 2222)
{
Server oServer = new Server { Protocol = ServerProtocol.SFTP, Host = strHost, Port = nPort, Username = User, Password = Pass, DefaultRemotePath = RemotePath };
Site.Add(strName, oServer);
}
else
{
Server oServer;
if(nPort == 990)
oServer = new Server { Protocol = ServerProtocol.FTP, FTPEnryptMode = FTPEnryptMode.Implicit, Host = strHost, Port = nPort, Username = User, Password = Pass, DefaultRemotePath = RemotePath };
else
oServer = new Server { Protocol = ServerProtocol.FTP, FTPEnryptMode = FTPEnryptMode.Explicit, Host = strHost, Port = nPort, Username = User, Password = Pass, DefaultRemotePath = RemotePath };
Site.Add(strName, oServer);
}
}
}