From 0da8fb0c46b610f97197ad77923706cd2b509ee0 Mon Sep 17 00:00:00 2001 From: maestropanel2 Date: Tue, 8 Dec 2015 03:23:02 +0200 Subject: [PATCH] Plesk 10.x.x Data Sync added --- .gitignore | 117 ++++- MpImport.v11.suo | Bin 345088 -> 354304 bytes MpMigrate.Core/MigrateManager.cs | 6 + MpMigrate.Data/Dal/Plesk_10X_MySql.cs | 620 ++++++++++++++++++++++++++ MpMigrate.Data/MpMigrate.Data.csproj | 1 + MpMigrate/Main.Designer.cs | 1 + MpMigrate/Main.cs | 6 + 7 files changed, 743 insertions(+), 8 deletions(-) create mode 100644 MpMigrate.Data/Dal/Plesk_10X_MySql.cs diff --git a/.gitignore b/.gitignore index a0aa1d6..94711da 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,109 @@ -################################################################################ -# This .gitignore file was automatically created by Microsoft(R) Visual Studio. -################################################################################ - -/MpMigrate.Core/obj/Debug -/MpMigrate.Test/obj/Debug -/MpMigrate/bin/Release -/MpMigrate.Data/obj/Release +# Build Folders (you can keep bin if you'd like, to store dlls and pdbs) +[Bb]in/ +[Oo]bj/ + +# mstest test results +TestResults + +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.sln.docstates + +# Build results +[Dd]ebug/ +[Rr]elease/ +x64/ +*_i.c +*_p.c +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.log +*.vspscc +*.vssscc +.builds + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper* + +# NCrunch +*.ncrunch* +.*crunch*.local.xml + +# Installshield output folder +[Ee]xpress + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish + +# Publish Web Output +*.Publish.xml + +# NuGet Packages Directory +packages + +# Windows Azure Build Output +csx +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +[Bb]in +[Oo]bj +TestResults +[Tt]est[Rr]esult* +*.Cache +ClientBin +[Ss]tyle[Cc]op.* +~$* +*.dbmdl +Generated_Code #added for RIA/Silverlight projects + +_UpgradeReport_Files/ +UpgradeLog*.XML + +*.exe +*.msi +*.zip +*.msu \ No newline at end of file diff --git a/MpImport.v11.suo b/MpImport.v11.suo index b0ae67784a9d9e104ab2725b12cb0b575c6ec036..3f9615cb277f05f2c3c57b843e9cf4b0a35e2161 100644 GIT binary patch delta 10805 zcmd6t30zc1wuigwRs$+vi-3qMEg&Kywn$tMp&Jo_D57yeMFVb8VwAW|VpLkA851)J z^fjD}&ln^IGj4-)hU;XJmN;f}e5l0HxCD*ajPVhllf{Yh{?*+e=EY=wGjExTU)Or; zRGm6?s_wm7Hw0K40!mE-bgh>`r^7#;C%Dzp(jv1N@B{CH_dpSNXkTF`?yKuuJ!8^< zW9)t8IO^0Dd<8$l)o*wX@1j$WS>xF;b(yk}IaDUPmGnoY7_bPuM|8n<2=CE-AnUZZ zgO2F9%)6T%bU=Bl9mslj+5zVMPD5}t_H%YH84doD9n_LtDqCt$w}*j?w^MMEZbx!7d7IWq!ry*urRP`YlpYUIl51f*+__2jfjr)L1t zCCHT|y{9beg9fF$kPcHy?GEJDAj?ABVHm=2VASdCB}dmVTdyd4RMc7K^LN`$#y@5| zKGJsLAsL-<+ReYL?Wmrp5cCUP7RLVYBA zrN^H!o-nKZMz);N#HP-b4V>kxEG3hw`v`yg^o*C3RwHDUIR=}5zH8+d_f+o+JsAcS>#vq12Of*n>{;Vx2%KV zcoeAz*QVOKU{+V3?Nk}VE1%{yjbE~WeFOVkxRLVR;v=C0+ zGTx2ZZ|5F{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V{$;`?xldYW4A<`q(9MM{Q!zU@ZZ_pilFg0{o!_Z3gq#cv*s$ zXd1P;YbdVG-dc2ED&|67q-%$v>GC#R$R1gG}zSoizx z4z$CZ)R+o(1j6C;cvn&HC_%u^CP3Aav>dyK}u_wTb-rO~9# Qt@52V$i(L0PS)6809!v)a{vGU diff --git a/MpMigrate.Core/MigrateManager.cs b/MpMigrate.Core/MigrateManager.cs index 1466ab1..659bdb4 100644 --- a/MpMigrate.Core/MigrateManager.cs +++ b/MpMigrate.Core/MigrateManager.cs @@ -18,6 +18,7 @@ public enum PanelTypes Plesk_11, Plesk_12, Plesk_10, + Plesk_10x, MaestroPanel, Entrenix, Helm, @@ -423,6 +424,9 @@ private void LoadVariations() variationList.Add(new Tuple (PanelTypes.Plesk_10, DatabaseProviders.MYSQL, new Plesk_10_MySql(), new Plesk_10_Discover())); + variationList.Add(new Tuple + (PanelTypes.Plesk_10x, DatabaseProviders.MYSQL, new Plesk_10X_MySql(), new Plesk_10_Discover())); + variationList.Add(new Tuple (PanelTypes.Entrenix, DatabaseProviders.ACCESS, new Entrenix_Access(), new Entrenix_Discover())); @@ -443,6 +447,8 @@ private void LoadVariations() variationList.Add(new Tuple (PanelTypes.Plesk_82, DatabaseProviders.OLEDB_ACCESS, new Plesk_82_Access(), new Plesk_86_Discover())); + + } private void SetSourceDatabaseAutomatically(IDiscovery discover) diff --git a/MpMigrate.Data/Dal/Plesk_10X_MySql.cs b/MpMigrate.Data/Dal/Plesk_10X_MySql.cs new file mode 100644 index 0000000..70994e8 --- /dev/null +++ b/MpMigrate.Data/Dal/Plesk_10X_MySql.cs @@ -0,0 +1,620 @@ +namespace MpMigrate.Data.Dal +{ + using MpMigrate.Data.Entity; + using MySql.Data.MySqlClient; + using System; + using System.Collections.Generic; + using System.Linq; + using System.Text; + + public class Plesk_10X_MySql : DboFactory + { + private string connectionString; + + public override List GetDomains() + { + var tmp = new List(); + + var securePassword = SecurePasswords(); + + using (MySqlConnection _conn = new MySqlConnection(connectionString)) + { + _conn.Open(); + + using (MySqlCommand _cmd = new MySqlCommand(@"SELECT + domains.id, + domains.name, + domains.name AS fp_adm, + accounts.password, + clients.login, + accounts.password as DomainPass, + domains.status AS STATUS, + Limits.value AS expiration, + domains.htype + FROM domains + LEFT JOIN hosting ON hosting.dom_id = domains.id + LEFT JOIN sys_users ON hosting.sys_user_id = sys_users.id + LEFT JOIN accounts ON accounts.id = sys_users.account_id + LEFT JOIN clients ON clients.id = domains.cl_id + LEFT JOIN Limits ON domains.Limits_id = Limits.id AND Limits.limit_name = 'expiration' ORDER BY domains.name", _conn)) + { + using (MySqlDataReader _read = _cmd.ExecuteReader()) + { + while (_read.Read()) + { + var _d = new Domain(); + _d.Id = Convert.ToInt32(DataExtensions.GetColumnValue(_read, "id")); + _d.Name = DataExtensions.GetColumnValue(_read, "name").ToLower(); + _d.ClientName = DataExtensions.GetColumnValue(_read, "login"); + _d.DomainPassword = securePassword ? DataHelper.GetPassword() : DataExtensions.GetColumnValue(_read, "DomainPass"); + _d.Username = DataExtensions.GetColumnValue(_read, "fp_adm"); + _d.Password = securePassword ? DataHelper.GetPassword() : DataExtensions.GetColumnValue(_read, "password"); + _d.Status = Convert.ToInt64(DataExtensions.GetColumnValue(_read, "STATUS")); + _d.Expiration = DateTime.Now.AddYears(1); + + var hostingType = DataExtensions.GetColumnValue(_read, "htype"); + _d.isForwarding = (hostingType == "std_fwd" || hostingType == "frm_fwd"); + + if (_d.isForwarding) + { + var frw = GetForwarding(_d.Name); + _d.ForwardUrl = frw.ForwardUrl; + } + + _d.Aliases = GetDomainAliases(_d.Name); + _d.Databases = GetDatabases(_d.Name); + _d.Limits = GetDomainLimits(_d.Name); + _d.Subdomains = GetSubdomains(_d.Name); + _d.Zone = GetDnsZone(_d.Name); + _d.Emails = GetEmails(_d.Name); + + tmp.Add(_d); + } + } + } + _conn.Close(); + } + + return tmp; + } + + public override List GetEmails(string domainName) + { + var securePassword = SecurePasswords(); + + var _tmp = new List(); + + using (MySqlConnection _conn = new MySqlConnection(connectionString)) + { + _conn.Open(); + using (MySqlCommand _cmd = new MySqlCommand(@"SELECT + mail.mail_name, domains.name, + accounts.password, domains.status, + mail.redirect, mail.redir_addr, mail.mbox_quota + FROM domains + LEFT OUTER JOIN mail ON mail.dom_id = domains.id + LEFT OUTER JOIN accounts ON accounts.id = mail.account_id + WHERE + (mail.mail_name <> '') AND (domains.name = @NAME)", _conn)) + { + _cmd.Parameters.AddWithValue("@NAME", domainName); + + using (MySqlDataReader _read = _cmd.ExecuteReader()) + { + while (_read.Read()) + { + var _d = new Email(); + _d.Name = DataExtensions.GetColumnValue(_read, "mail_name").ToLower(); + _d.DomainName = DataExtensions.GetColumnValue(_read, "name").ToLower(); + _d.Password = securePassword ? DataHelper.GetPassword() : DataExtensions.GetColumnValue(_read, "password"); + _d.Redirect = DataExtensions.GetColumnValue(_read, "redirect"); + _d.RedirectedEmail = DataExtensions.GetColumnValue(_read, "redir_addr"); + + var mboxQuota = Convert.ToDouble(DataExtensions.GetColumnValue(_read, "mbox_quota")); + if (mboxQuota > 0) + _d.Quota = Math.Round(((mboxQuota / 1024) / 1024), 0); + else + _d.Quota = -1; + + _tmp.Add(_d); + } + } + } + _conn.Close(); + } + + return _tmp; + } + + public override HostLimit GetDomainLimits(string domainName) + { + var _tmp_limits = new List(); + + using (MySqlConnection _conn = new MySqlConnection(connectionString)) + { + _conn.Open(); + using (MySqlCommand _cmd = new MySqlCommand(@"SELECT L.limit_name, L.value FROM domains D LEFT JOIN Limits L ON L.id = D.limits_id WHERE D.name = @NAME", _conn)) + { + _cmd.Parameters.AddWithValue("@NAME", domainName); + + using (MySqlDataReader _read = _cmd.ExecuteReader()) + { + while (_read.Read()) + { + var _d = new LimitRow(); + _d.Name = DataExtensions.GetColumnValue(_read, "limit_name"); + + var arrayValue = DataExtensions.GetColumnValue(_read, "value"); + var LimitValue = arrayValue != null ? Convert.ToInt64(Encoding.ASCII.GetString(arrayValue)) : -1; + + if (_d.Name == "disk_space" || _d.Name == "max_traffic" || _d.Name == "mbox_quota" + || _d.Name == "mssql_dbase_space" || _d.Name == "mysql_dbase_space" + || _d.Name == "max_traffic_soft" || _d.Name == "disk_space_soft") + { + _d.Value = (int)((LimitValue / 1024) / 1024); + } + else if (_d.Name == "expiration") + { + + } + else + { + if(LimitValue > int.MaxValue) + throw new InvalidCastException(_d.Name +": "+ LimitValue.ToString()); + + _d.Value = Convert.ToInt32(LimitValue); + } + + _tmp_limits.Add(_d); + } + } + } + _conn.Close(); + } + + return new HostLimit(_tmp_limits); + } + + public override DnsZone GetDnsZone(string domainName) + { + var _tmp = new DnsZone(); + + using (MySqlConnection _conn = new MySqlConnection(connectionString)) + { + _conn.Open(); + using (MySqlCommand _cmd = new MySqlCommand(@"SELECT dns_zone.* FROM dns_zone + LEFT JOIN domains ON dns_zone.name = domains.name WHERE domains.name = @NAME", _conn)) + { + _cmd.Parameters.AddWithValue("@NAME", domainName); + + using (MySqlDataReader _read = _cmd.ExecuteReader()) + { + while (_read.Read()) + { + _tmp.Name = DataExtensions.GetColumnValue(_read, "name").ToLower(); + _tmp.mininum = Convert.ToInt32(DataExtensions.GetColumnValue(_read, "minimum")); + _tmp.refresh = Convert.ToInt32(DataExtensions.GetColumnValue(_read, "refresh")); + _tmp.retry = Convert.ToInt32(DataExtensions.GetColumnValue(_read, "retry")); + _tmp.expire = Convert.ToInt32(DataExtensions.GetColumnValue(_read, "expire")); + + var serial = DataExtensions.GetColumnValue(_read, "serial"); + _tmp.serial = Convert.ToInt32(serial); + + _tmp.ttl = Convert.ToInt32(DataExtensions.GetColumnValue(_read, "ttl")); + _tmp.Email = DataExtensions.GetColumnValue(_read, "email"); + } + } + } + _conn.Close(); + } + + _tmp.Records = GetZoneRecords(domainName); + + return _tmp; + } + + public override List GetZoneRecords(string domainName) + { + var _tmp = new List(); + + using (MySqlConnection _conn = new MySqlConnection(connectionString)) + { + _conn.Open(); + using (MySqlCommand _cmd = new MySqlCommand(@"SELECT dns_recs.* FROM dns_zone + LEFT JOIN dns_recs ON dns_recs.dns_zone_id = dns_zone.id + WHERE dns_zone.name = @NAME AND dns_recs.type <> 'PTR'", _conn)) + { + _cmd.Parameters.AddWithValue("@NAME", domainName); + + using (MySqlDataReader _read = _cmd.ExecuteReader()) + { + while (_read.Read()) + { + var _d = new DnsZoneRecord(); + + var hostName = DataExtensions.GetColumnValue(_read, "host"); + + if (hostName == domainName || hostName == String.Format("{0}.", domainName)) + _d.name = "@"; + else + _d.name = hostName.Split('.').FirstOrDefault().ToLower(); + + + _d.type = DataExtensions.GetColumnValue(_read, "type"); + _d.value = DataExtensions.GetColumnValue(_read, "val").ToLower(); + + var pri = 0; + + var options = DataExtensions.GetColumnValue(_read, "opt"); + + if (int.TryParse(options, out pri)) + _d.priority = pri; + else + _d.priority = 0; + + + _tmp.Add(_d); + } + } + } + _conn.Close(); + } + + return _tmp; + } + + public override Forwarding GetForwarding(string domainName) + { + var _tmp = new Forwarding(); + + using (MySqlConnection _conn = new MySqlConnection(connectionString)) + { + _conn.Open(); + using (MySqlCommand _cmd = new MySqlCommand(@"SELECT D.name, F.redirect FROM domains D JOIN forwarding F ON F.dom_id = D.Id WHERE D.name = @NAME", _conn)) + { + _cmd.Parameters.AddWithValue("@NAME", domainName); + + using (MySqlDataReader _read = _cmd.ExecuteReader()) + { + while (_read.Read()) + { + _tmp.Name = DataExtensions.GetColumnValue(_read, "name"); + _tmp.ForwardUrl = DataExtensions.GetColumnValue(_read, "redirect"); + } + } + } + _conn.Close(); + } + + return _tmp; + } + + public override List GetDomainAliases(string domainName) + { + var _tmp = new List(); + + using (MySqlConnection _conn = new MySqlConnection(connectionString)) + { + _conn.Open(); + using (MySqlCommand _cmd = new MySqlCommand(@"SELECT domainaliases.name as alias, domains.name AS domain, domainaliases.status + FROM domainaliases + INNER JOIN domains ON domainaliases.dom_id = domains.id + WHERE domainaliases.status = 0 AND domains.name = @NAME", _conn)) + { + _cmd.Parameters.AddWithValue("@NAME", domainName); + + using (MySqlDataReader _read = _cmd.ExecuteReader()) + { + while (_read.Read()) + { + var _d = new DomainAlias(); + _d.Domain = DataExtensions.GetColumnValue(_read, "domain"); + _d.Alias = DataExtensions.GetColumnValue(_read, "alias"); + _d.Status = Convert.ToInt64(DataExtensions.GetColumnValue(_read, "status")); + + _tmp.Add(_d); + } + } + } + _conn.Close(); + } + + return _tmp; + } + + public override List GetDatabases(string domainName) + { + var _tmp = new List(); + + using (MySqlConnection _conn = new MySqlConnection(connectionString)) + { + _conn.Open(); + using (MySqlCommand _cmd = new MySqlCommand(@"SELECT data_bases.id as db_id, domains.name AS domain, data_bases.name, data_bases.type, + data_bases.db_server_id + FROM data_bases LEFT OUTER JOIN + domains ON domains.id = data_bases.dom_id LEFT OUTER JOIN + db_users ON db_users.id = data_bases.default_user_id + WHERE (domains.name = @NAME)", _conn)) + { + _cmd.Parameters.AddWithValue("@NAME", domainName); + + using (MySqlDataReader _read = _cmd.ExecuteReader()) + { + while (_read.Read()) + { + var _d = new Database(); + _d.Id = Convert.ToInt32(DataExtensions.GetColumnValue(_read, "db_id")); + _d.Name = DataExtensions.GetColumnValue(_read, "name"); + _d.Domain = DataExtensions.GetColumnValue(_read, "domain"); + _d.DbType = DataExtensions.GetColumnValue(_read, "type"); + _d.ServerId = Convert.ToInt32(DataExtensions.GetColumnValue(_read, "db_server_id")); + _d.Users = GetDatabaseUsers(_d.Id); + + _tmp.Add(_d); + } + } + } + _conn.Close(); + } + + return _tmp; + } + + public override List GetDatabaseUsers(int database_id) + { + var _tmp = new List(); + var securePassword = SecurePasswords(); + + using (MySqlConnection _conn = new MySqlConnection(connectionString)) + { + _conn.Open(); + using (MySqlCommand _cmd = new MySqlCommand(@"SELECT db_users.login, accounts.password FROM db_users LEFT JOIN accounts ON db_users.account_id = accounts.id WHERE db_users.db_id = @ID", _conn)) + { + _cmd.Parameters.AddWithValue("@ID", database_id); + + using (MySqlDataReader _read = _cmd.ExecuteReader()) + { + while (_read.Read()) + { + var _d = new DatabaseUser(); + _d.Username = DataExtensions.GetColumnValue(_read, "login"); + _d.Password = securePassword ? DataHelper.GetPassword() : DataExtensions.GetColumnValue(_read, "password"); + + _tmp.Add(_d); + } + } + } + _conn.Close(); + } + + return _tmp; + } + + public override List GetSubdomains(string domainName) + { + var _tmp = new List(); + var securePassword = SecurePasswords(); + using (MySqlConnection _conn = new MySqlConnection(connectionString)) + { + _conn.Open(); + using (MySqlCommand _cmd = new MySqlCommand(@"SELECT + subdomains.name, + domains.name AS domain, + sys_users.login, + accounts.password + FROM accounts RIGHT OUTER JOIN + sys_users ON accounts.id = sys_users.account_id RIGHT OUTER JOIN + subdomains ON sys_users.id = subdomains.sys_user_id LEFT OUTER JOIN + domains ON subdomains.dom_id = domains.id + WHERE domains.name = @NAME", _conn)) + { + _cmd.Parameters.AddWithValue("@NAME", domainName); + + using (MySqlDataReader _read = _cmd.ExecuteReader()) + { + while (_read.Read()) + { + var _d = new Subdomain(); + _d.Domain = DataExtensions.GetColumnValue(_read, "domain"); + _d.Login = DataExtensions.GetColumnValue(_read, "login"); + _d.Password = securePassword ? DataHelper.GetPassword() : DataExtensions.GetColumnValue(_read, "password"); + _d.Name = DataExtensions.GetColumnValue(_read, "name"); + _d.UserType = ""; + + _tmp.Add(_d); + } + } + } + _conn.Close(); + } + + return _tmp; + } + + public override List GetResellers() + { + var tmp = new List(); + var securePassword = SecurePasswords(); + + using (MySqlConnection _conn = new MySqlConnection(connectionString)) + { + _conn.Open(); + using (MySqlCommand _cmd = new MySqlCommand(@"SELECT C.id, cname, pname, login, accounts.password, phone, fax, email, address, city, state, pcode, country + FROM clients C LEFT JOIN accounts ON accounts.id = C.account_id WHERE C.`type`='reseller' OR C.`type`='client'", _conn)) + { + using (MySqlDataReader _read = _cmd.ExecuteReader()) + { + while (_read.Read()) + { + var res = new Reseller(); + res.Id = Convert.ToInt32(DataExtensions.GetColumnValue(_read, "id")); + res.Address1 = DataExtensions.GetColumnValue(_read, "address"); + res.City = DataExtensions.GetColumnValue(_read, "city"); + res.Country = DataExtensions.GetColumnValue(_read, "country"); + res.fax = DataExtensions.GetColumnValue(_read, "fax"); + res.Phone = DataExtensions.GetColumnValue(_read, "phone"); + res.PostalCode = DataExtensions.GetColumnValue(_read, "pcode"); + res.Province = DataExtensions.GetColumnValue(_read, "country"); + + res.FirstName = DataExtensions.GetColumnValue(_read, "pname"); + + res.Password = securePassword ? DataHelper.GetPassword() : DataExtensions.GetColumnValue(_read, "password"); + res.Username = DataExtensions.GetColumnValue(_read, "login"); + res.Email = DataExtensions.GetColumnValue(_read, "email"); + res.Organization = DataExtensions.GetColumnValue(_read, "cname"); + + res.Limits = ResellerLimits(res.Username); + + tmp.Add(res); + } + } + } + _conn.Close(); + } + + return tmp; + } + + public override PanelStats GetPanelStats() + { + var pstats = new PanelStats(); + + using (MySqlConnection _conn = new MySqlConnection(connectionString)) + { + _conn.Open(); + + #region Disk Space + using (MySqlCommand _cmd = new MySqlCommand(@"SELECT CAST(SUM(httpdocs) AS SIGNED) as httpdocs, + CAST((SUM(dbases)) AS SIGNED) as totaldbsize, + CAST(SUM(mailboxes) AS SIGNED) as totalmailboxsize, + CAST(SUM(subdomains) AS SIGNED) as subdomainsize + FROM disk_usage", _conn)) + { + using (MySqlDataReader _read = _cmd.ExecuteReader()) + { + while (_read.Read()) + { + //form MySQL 4 + if (_read["httpdocs"] is System.Int64) + pstats.TotalDomainDiskSpace = Convert.ToDecimal(DataExtensions.GetColumnValue(_read, "httpdocs")); + else + pstats.TotalDomainDiskSpace = DataExtensions.GetColumnValue(_read, "httpdocs"); + + if (_read["totaldbsize"] is System.Int64) + pstats.TotalDatabaseDiskSpace = Convert.ToDecimal(DataExtensions.GetColumnValue(_read, "totaldbsize")); + else + pstats.TotalDatabaseDiskSpace = DataExtensions.GetColumnValue(_read, "totaldbsize"); + + if (_read["totalmailboxsize"] is System.Int64) + pstats.TotalEmailDiskSpace = Convert.ToDecimal(DataExtensions.GetColumnValue(_read, "totalmailboxsize")); + else + pstats.TotalEmailDiskSpace = DataExtensions.GetColumnValue(_read, "totalmailboxsize"); + + if (_read["subdomainsize"] is System.Int64) + pstats.TotalSubdomainDiskSpace = Convert.ToDecimal(DataExtensions.GetColumnValue(_read, "subdomainsize")); + else + pstats.TotalSubdomainDiskSpace = DataExtensions.GetColumnValue(_read, "subdomainsize"); + } + } + } + #endregion + + #region Count + using (MySqlCommand _cmd = new MySqlCommand(@"SELECT + (SELECT COUNT(*) FROM domains) as domaincount, + (SELECT COUNT(*) FROM mail) as mailcount, + (SELECT COUNT(*) FROM clients) as resellercount, + (SELECT COUNT(*) FROM data_bases) as databasecount, + (SELECT COUNT(*) FROM domainaliases) as aliascount, + (SELECT COUNT(*) FROM subdomains) as subdomaincount", _conn)) + { + using (MySqlDataReader _read = _cmd.ExecuteReader()) + { + while (_read.Read()) + { + pstats.TotalDomainCount = DataExtensions.GetColumnValue(_read, "domaincount"); + pstats.TotalEmailCount = DataExtensions.GetColumnValue(_read, "mailcount"); + pstats.TotalResellerCount = DataExtensions.GetColumnValue(_read, "resellercount"); + pstats.TotalDatabaseCount = DataExtensions.GetColumnValue(_read, "databasecount"); + pstats.TotalDomainAliasCount = DataExtensions.GetColumnValue(_read, "aliascount"); + pstats.TotalSubdomainCount = DataExtensions.GetColumnValue(_read, "subdomaincount"); + } + } + } + #endregion + + _conn.Close(); + } + + return pstats; + } + + public override HostLimit ResellerLimits(string clientName) + { + var _tmp_limits = new List(); + + using (MySqlConnection _conn = new MySqlConnection(connectionString)) + { + _conn.Open(); + using (MySqlCommand _cmd = new MySqlCommand(@"SELECT L.limit_name, L.value FROM clients C LEFT JOIN Limits L ON L.id = C.limits_id WHERE C.login = @NAME", _conn)) + { + _cmd.Parameters.AddWithValue("@NAME", clientName); + + using (MySqlDataReader _read = _cmd.ExecuteReader()) + { + while (_read.Read()) + { + var _d = new LimitRow(); + _d.Name = DataExtensions.GetColumnValue(_read, "limit_name"); + + var limitObj = DataExtensions.GetColumnValue(_read, "value"); + var LimitValue = limitObj != null ? Convert.ToInt64(Encoding.ASCII.GetString(limitObj)) : -1; + + if (_d.Name == "disk_space" || _d.Name == "max_traffic" || _d.Name == "mbox_quota" + || _d.Name == "mssql_dbase_space" || _d.Name == "mysql_dbase_space" + || _d.Name == "max_traffic_soft" || _d.Name == "disk_space_soft") + { + _d.Value = (int)((LimitValue / 1024) / 1024); + } + else + { + _d.Value = Convert.ToInt32(LimitValue); + } + + _tmp_limits.Add(_d); + + } + } + } + _conn.Close(); + } + + return new HostLimit(_tmp_limits); + } + + public override void LoadConnectionString(string connectionString) + { + this.connectionString = connectionString; + } + + public override bool SecurePasswords() + { + var securePass = false; + + using (MySqlConnection _conn = new MySqlConnection(connectionString)) + { + _conn.Open(); + using (MySqlCommand _cmd = new MySqlCommand(@"SELECT val FROM misc WHERE param = 'secure_passwords'", _conn)) + { + var secure_passwords = _cmd.ExecuteScalar(); + + if (secure_passwords != null) + bool.TryParse(secure_passwords.ToString(), out securePass); + } + _conn.Close(); + } + + return securePass; + } + } +} diff --git a/MpMigrate.Data/MpMigrate.Data.csproj b/MpMigrate.Data/MpMigrate.Data.csproj index afb8918..31aa776 100644 --- a/MpMigrate.Data/MpMigrate.Data.csproj +++ b/MpMigrate.Data/MpMigrate.Data.csproj @@ -58,6 +58,7 @@ + diff --git a/MpMigrate/Main.Designer.cs b/MpMigrate/Main.Designer.cs index 7ebe217..2152048 100644 --- a/MpMigrate/Main.Designer.cs +++ b/MpMigrate/Main.Designer.cs @@ -1065,6 +1065,7 @@ private void InitializeComponent() "Plesk 12.x", "Plesk 11.x", "Plesk 10.x", + "Plesk 10.x.x", "Plesk 9.x", "Plesk 8.2", "Plesk 8.x", diff --git a/MpMigrate/Main.cs b/MpMigrate/Main.cs index 198735b..66a5ea0 100644 --- a/MpMigrate/Main.cs +++ b/MpMigrate/Main.cs @@ -118,6 +118,9 @@ private PanelTypes SetSourcePanelType() case "Plesk 10.x": ptype = PanelTypes.Plesk_10; break; + case "Plesk 10.x.x": + ptype = PanelTypes.Plesk_10x; + break; case "Plesk 9.x": ptype = PanelTypes.Plesk_95; break; @@ -237,6 +240,9 @@ private void SelectSourcePanel(PanelTypes paneltype) case PanelTypes.Plesk_10: comboSourcePanel.SelectedIndex = comboSourcePanel.FindStringExact("Plesk 10.x"); break; + case PanelTypes.Plesk_10x: + comboSourcePanel.SelectedIndex = comboSourcePanel.FindStringExact("Plesk 10.x.x"); + break; case PanelTypes.Entrenix: comboSourcePanel.SelectedIndex = comboSourcePanel.FindStringExact("Entrenix"); break;