コード例 #1
0
    protected void Page_Load(object sender, System.EventArgs e)
    {
        if (Session["AUTH"] == null)
        {
            return;
        }

        Utils.SettingsPath = AdminPanelUtils.GetWebMailFolder();
        #region Convert Settings in settings.xml

        WebmailSettings wmsNew = new WebmailSettings().CreateInstance(AdminPanelUtils.GetWebMailDataFolder());

        sb.AppendFormat("<font color='black' sise='3' face='verdana'><b>{1}</b>. Start convert settings.xml</font><BR />", "settings.xml", _allOps + 1);
        _allOps++;

        try
        {
            wmsNew.SaveWebmailSettings(AdminPanelUtils.GetWebMailDataFolder());
            sb.AppendFormat("<font color='grey' sise='3' face='verdana'>- Convert settings successful.</font><BR /><BR />");
        }
        catch (Exception ex)
        {
            sb.AppendFormat("<font color='grey' sise='3' face='verdana'>- {0}</font><BR /><BR />", ex.Message);
            _errorCounter++;
        }
        # endregion
コード例 #2
0
    protected void SubmitButton_Click(object sender, System.EventArgs e)
    {
        bool flag = false;

        try
        {
            AdminPanelSettings apSettings = new AdminPanelSettings().Load();

            string licenseKeyFromForm = txtLicenseKey.Value ?? string.Empty;

            if (string.IsNullOrEmpty(licenseKeyFromForm))
            {
                apSettings.LicenseKey = licenseKeyFromForm;
                flag = false;
            }
            else
            {
                try
                {
                    Pop3.LicenseKey = licenseKeyFromForm.Substring(0, 39);
                    Pop3 pop = new Pop3();
                    flag = true;
                }
                catch (Exception error)
                {
                    Log.WriteException(error);
                    _errorMessage         = "License Key is invalid";
                    GetLicenseUrl.Visible = true;
                    flag = false;
                }
                apSettings.LicenseKey = licenseKeyFromForm;
            }
            if (File.Exists(Path.Combine(AdminPanelUtils.GetWebMailDataFolder(), @"settings\settings.xml")))
            {
                WebmailSettings settings = new WebmailSettings().CreateInstance(AdminPanelUtils.GetWebMailDataFolder());
                settings.LicenseKey = licenseKeyFromForm;
                settings.SaveWebmailSettings(AdminPanelUtils.GetWebMailDataFolder());
            }

            apSettings.Save();
            _errorMessage = Constants.mailAdmSaveSuccess;

            if (flag == true)
            {
                Session["LicenseKey"] = txtLicenseKey.Value;
                Response.Redirect("install.aspx?mode=db", true);
            }
            else
            {
                _errorMessage = "Please specify valid license key.";
            }
        }
        catch (Exception error)
        {
            Log.WriteException(error);
            _errorMessage = Constants.mailAdmSaveUnsuccess;
        }
    }
コード例 #3
0
    protected void save_ServerClick(object sender, EventArgs e)
    {
        try
        {
            Context.Application.Remove(Constants.sessionSettings);
            WebmailSettings settings = new WebmailSettings().CreateInstance(AdminPanelUtils.GetWebMailDataFolder());

            settings.WmServerRootPath           = txtWmServerRootPath.Value;
            settings.WmServerHost               = txtWmServerHostName.Value;
            settings.WmAllowManageXMailAccounts = intWmAllowManageXMailAccounts.Checked;

            if (!settings.EnableWmServer)
            {
                settings.SaveWebmailSettings(AdminPanelUtils.GetWebMailDataFolder());
                AdminPanelUtils.SetPageReportMessage(this.Page, Constants.mailAdmSaveSuccess);
            }
            else if (txtWmServerRootPath.Value.Length > 0)
            {
                string fullPath = Path.Combine(txtWmServerRootPath.Value, "domains");
                if (!Directory.Exists(fullPath))
                {
                    throw new WebMailIOException(string.Format(@"Server Root Path '{0}' incorrect.", AdminPanelUtils.EncodeHtml(fullPath)));
                }

                Utils.SettingsPath = AdminPanelUtils.GetWebMailFolder();
                WMServerStorage storage = new WMServerStorage(txtWmServerHostName.Value, null);
                storage.GetDomainList(); // test command

                settings.SaveWebmailSettings(AdminPanelUtils.GetWebMailDataFolder());
                this.Context.Application.Remove(Constants.sessionSettings);

                AdminPanelUtils.SetPageReportMessage(this.Page, Constants.mailAdmSaveSuccess);
            }
            else
            {
                throw new WebMailIOException(@"Server Root Path not set.");
            }
        }
        catch (Exception ex)
        {
            Log.WriteException(ex);
            AdminPanelUtils.SetPageErrorMessage(this.Page, Constants.mailAdmSaveUnsuccess + "<br /> Error:" + ex.Message);
        }
    }
コード例 #4
0
    private bool Save()
    {
        Session["TrySqlPassword"] = null;
        try
        {
            WebmailSettings settings = new WebmailSettings().CreateInstance(AdminPanelUtils.GetWebMailDataFolder());

            Regex r = new Regex(@"[^a-zA-Z0-9_]");
            settings.DbPrefix = r.Replace(DbPrefix.Value, "_");

            bool res = true;
            if (settings.DbPrefix != DbPrefix.Value)
            {
                res = false;
            }

            if (intDbTypeMsAccess.Checked)
            {
                settings.DbType   = SupportedDatabase.MsAccess;
                settings.DbPrefix = "";
            }
            else if (intDbTypeMySql.Checked)
            {
                settings.DbType = SupportedDatabase.MySql;
            }
            else
            {
                settings.DbType = SupportedDatabase.MsSqlServer;
            }
            settings.DbLogin     = txtSqlLogin.Value;
            settings.DbPassword  = txtSqlPassword.Text;
            settings.DbName      = txtSqlName.Value;
            settings.DbDsn       = txtSqlDsn.Value;
            settings.DbHost      = txtSqlSrc.Value;
            settings.DbPathToMdb = txtAccessFile.Value;
            settings.DbCustomConnectionString  = odbcConnectionString.Value;
            settings.UseCustomConnectionString = useCS.Checked;
            settings.UseDSN = useDSN.Checked;

            settings.SaveWebmailSettings(AdminPanelUtils.GetWebMailDataFolder());
            Session.Remove(Constants.sessionDbManager);
            Context.Application.Remove(Constants.sessionSettings);

            if (!res)
            {
                _errorMessage = @"<font color=""red"">Only letters, digits and underscore (""_"") allowed.</font>";
            }
            return(res);
        }
        catch (Exception error)
        {
            Log.WriteException(error);
            _errorMessage = @"<font color=""red"">" + Constants.mailAdmSaveUnsuccess + ": " + error.Message + "</font>";
            return(false);
        }
    }