Esempio n. 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
Esempio n. 2
0
 public Subadmin(int id, string login, string password, string description)
 {
     _id          = id;
     _login       = login;
     _password    = AdminPanelUtils.EncryptPassword(password);
     _description = description;
 }
Esempio n. 3
0
    public bool AddNewWebMailDomain()
    {
        bool result = false;
        // create webmail domain
        string domainName   = textDomainName.Value;
        string incomingMail = txtIncomingMail.Value;
        string outgoingMail = txtOutgoingMail.Value;
        bool   useSmtpAuth  = intReqSmtpAuthentication.Checked;
        int    incomingPort = 0;

        int.TryParse(intIncomingMailPort.Value, out incomingPort);
        int outgoingPort = 0;

        int.TryParse(intOutgoingMailPort.Value, out outgoingPort);
        IncomingMailProtocol mail_protocol = IncomingMailProtocol.Pop3;

        switch (intIncomingMailProtocol.SelectedIndex)
        {
        case 0:
            mail_protocol = IncomingMailProtocol.Pop3;
            break;

        case 1:
            mail_protocol = IncomingMailProtocol.Imap4;
            break;

        case 2:
            mail_protocol = IncomingMailProtocol.WMServer;
            break;
        }

        try
        {
            Domain dom = Domain.GetDomain(domainName);
            if (dom == null)
            {
                Domain new_dom = new Domain(0, domainName, mail_protocol, incomingMail, incomingPort, outgoingMail, outgoingPort, useSmtpAuth);


                new_dom.Global_addr_book = false;

                new_dom.Save();
                result = true;
            }
            else
            {
                result = false;
                AdminPanelUtils.SaveState("SessPageErrorMessage", "Such domain already exists.", Page.Session);
            }
        }
        catch (Exception error)
        {
            result = false;
            Log.WriteException(error);
            AdminPanelUtils.SetPageErrorMessage(this.Page, (error.InnerException != null ? error.InnerException.Message : error.Message));
        }
        return(result);
    }
Esempio n. 4
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;
        }
    }
Esempio n. 5
0
    public void UpdateWebMailDomain()
    {
        try
        {
            string domainName   = textDomainName.Value;
            string incomingMail = txtIncomingMail.Value;
            string outgoingMail = txtOutgoingMail.Value;
            int    domainID     = Int32.Parse(hidWebMailDomainID.Value);

            if (!AdminPanelUtils.IsSuperAdmin(Page.Session, (Page as DefaultPage).Settings))
            {
                if (!Subadmin.IsSubadminDomain(int.Parse(Session["AdminID"].ToString()), domainID))
                {
                    return;
                }
            }

            bool useSmtpAuth  = intReqSmtpAuthentication.Checked;
            int  incomingPort = 0;
            int.TryParse(intIncomingMailPort.Value, out incomingPort);
            int outgoingPort = 0;
            int.TryParse(intOutgoingMailPort.Value, out outgoingPort);
            IncomingMailProtocol mail_protocol = IncomingMailProtocol.Pop3;
            switch (intIncomingMailProtocol.SelectedIndex)
            {
            case 0:
                mail_protocol = IncomingMailProtocol.Pop3;
                break;

            case 1:
                mail_protocol = IncomingMailProtocol.Imap4;
                break;

            case 2:
                mail_protocol = IncomingMailProtocol.WMServer;
                break;
            }
            Domain dom = Domain.GetDomain(domainID);

            dom.Name = domainName;
            dom.MailIncomingProtocol       = mail_protocol;
            dom.MailIncomingHost           = incomingMail;
            dom.MailIncomingPort           = incomingPort;
            dom.MailOutgoingHost           = outgoingMail;
            dom.MailOutgoingPort           = outgoingPort;
            dom.MailOutgoingAuthentication = useSmtpAuth;


            dom.Global_addr_book = false;

            dom.Save();
        }
        catch (Exception error)
        {
            Log.WriteException(error);
            AdminPanelUtils.SetPageErrorMessage(this.Page, (error.InnerException != null ? error.InnerException.Message : error.Message));
        }
    }
Esempio n. 6
0
    protected void create_database_Click(object sender, System.EventArgs e)
    {
        Session["TrySqlPassword"] = txtSqlPassword.Text;
        txtSqlPassword.Attributes.Add("Value", txtSqlPassword.Text);

        if (intDbTypeMsAccess.Checked)
        {
            return;
        }

        Utils.SettingsPath = AdminPanelUtils.GetWebMailFolder();

        DbManager         dbMan            = null;
        string            connectionString = string.Empty;
        SupportedDatabase dbType           = SupportedDatabase.MsSqlServer;

        if (intDbTypeMsAccess.Checked)
        {
            dbMan  = new MsAccessDbManager();
            dbType = SupportedDatabase.MsAccess;
        }
        else if (intDbTypeMySql.Checked)
        {
            dbMan  = new MySqlDbManager();
            dbType = SupportedDatabase.MySql;
        }
        else
        {
            dbMan  = new MsSqlDbManager();
            dbType = SupportedDatabase.MsSqlServer;
        }

        string dsn = txtSqlDsn.Value;

        if (!useDSN.Checked)
        {
            dsn = string.Empty;
        }

        connectionString = DbManager.CreateConnectionString(useCS.Checked, odbcConnectionString.Value,
                                                            dsn, dbType, txtAccessFile.Value, txtSqlLogin.Value,
                                                            txtSqlPassword.Text, null, txtSqlSrc.Value);
        try
        {
            dbMan.Connect(connectionString);
            dbMan.CreateDatabase(txtSqlName.Value);
            _errorMessageCreateDB = @"<br /><font color=""green"">Database create successfily.</font>";
        }
        catch (WebMailDatabaseException error)
        {
            Log.WriteException(error);
            _errorMessageCreateDB = @"<br /><font color=""red"">" + error.Message + "</font>";
        }
        finally
        {
            dbMan.Disconnect();
        }
    }
Esempio n. 7
0
    private void Save()
    {
        Session["TrySqlPassword"] = null;
        try
        {
            WebmailSettings settings = new WebMailSettingsCreator().CreateWebMailSettings(AdminPanelUtils.GetWebMailDataFolder());

            if (intDbTypeMsAccess.Checked)
            {
                settings.DbType = SupportedDatabase.MsAccess;
            }
            else if (intDbTypeMySql.Checked)
            {
                settings.DbType = SupportedDatabase.MySql;
            }
            else
            {
                settings.DbType = SupportedDatabase.MsSqlServer;
            }

            string rrr = Request[txtSqlLogin.ClientID];

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

            settings.SaveWebmailSettings(AdminPanelUtils.GetWebMailDataFolder());
            this.Session.Remove(Constants.sessionDbManager);
            this.Context.Application.Remove(Constants.sessionSettings);
        }
        catch (Exception error)
        {
            Log.WriteException(error);
            AdminPanelUtils.SetPageErrorMessage(this.Page, Constants.mailAdmSaveUnsuccess);
        }
    }
Esempio n. 8
0
    protected void SaveButton_Click(object sender, System.EventArgs e)
    {
        try
        {
            WebmailSettings settings = new WebMailSettingsCreator().CreateWebMailSettings(AdminPanelUtils.GetWebMailDataFolder());

            if (standartLoginRadio.Checked)
            {
                settings.HideLoginMode = LoginMode.Default;
            }
            else if (hideLoginRadio.Checked)
            {
                if (hideLoginSelect.SelectedIndex == 0)
                {
                    settings.HideLoginMode = LoginMode.HideLoginFieldLoginIsEmail;
                }
                else
                {
                    settings.HideLoginMode = LoginMode.HideLoginFieldLoginIsAccount;
                }
            }
            else
            {
                if ((intDisplayDomainAfterLoginField.Checked) && (intLoginAsConcatination.Checked))
                {
                    settings.HideLoginMode = LoginMode.HideEmailFieldDisplayDomainAfterLoginAndLoginIsLoginAndDomain;
                }
                else if (intDisplayDomainAfterLoginField.Checked)
                {
                    settings.HideLoginMode = LoginMode.HideEmailFieldDisplayDomainAfterLogin;
                }
                else if (intLoginAsConcatination.Checked)
                {
                    settings.HideLoginMode = LoginMode.HideEmailFieldLoginIsLoginAndDomain;
                }
                else
                {
                    settings.HideLoginMode = LoginMode.HideEmailField;
                }
            }
            settings.DefaultDomainOptional = txtUseDomain.Value;

            settings.AllowAdvancedLogin            = intAllowAdvancedLogin.Checked;
            settings.AutomaticCorrectLoginSettings = intAutomaticCorrectLogin.Checked;
            settings.AllowLanguageOnLogin          = intAllowLangOnLogin.Checked;

            settings.SaveWebmailSettings(AdminPanelUtils.GetWebMailDataFolder());
            Context.Application.Remove(Constants.sessionSettings);
            AdminPanelUtils.SetPageReportMessage(Page, Constants.mailAdmSaveSuccess);
        }
        catch (Exception error)
        {
            Log.WriteException(error);
            AdminPanelUtils.SetPageErrorMessage(Page, Constants.mailAdmSaveUnsuccess);
        }
    }
Esempio n. 9
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);
        }
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         WebmailSettings settings = new WebmailSettings().CreateInstance(AdminPanelUtils.GetWebMailDataFolder());
         txtWmServerRootPath.Value             = settings.WmServerRootPath;
         txtWmServerHostName.Value             = settings.WmServerHost;
         intWmAllowManageXMailAccounts.Checked = settings.WmAllowManageXMailAccounts;
     }
 }
Esempio n. 11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        WebmailSettings settings = new WebMailSettingsCreator().CreateWebMailSettings(AdminPanelUtils.GetWebMailDataFolder());

        if (!Page.IsPostBack)
        {
            Utils.SettingsPath = AdminPanelUtils.GetWebMailFolder();
            string logPath = Utils.GetLogFilePath();
            intEnableLogging.Checked = settings.EnableLogging;
            txtPathForLog.Value      = logPath;
        }
    }
Esempio n. 12
0
 protected void SaveDomain_OnClick(object sender, EventArgs e)
 {
     if (_isUpdate)
     {
         UpdateDomain();
     }
     else if (AdminPanelUtils.IsSuperAdmin(Page.Session, (Page as DefaultPage).Settings))
     {
         AddNewDomain();
     }
     Response.Redirect("default.aspx?mode=domains", false);
 }
Esempio n. 13
0
 protected void ClearLogButton_ServerClick(object sender, System.EventArgs e)
 {
     try
     {
         Utils.ClearLog();
         AdminPanelUtils.SetPageReportMessage(this.Page, Constants.mailAdmLogClearSuccess);
     }
     catch (Exception error)
     {
         Log.WriteException(error);
         AdminPanelUtils.SetPageErrorMessage(this.Page, Constants.mailAdmLogClearUnsuccess);
     }
 }
Esempio n. 14
0
        protected void ShowLog()
        {
            Response.Clear();
            Response.AddHeader("Content-Type", "text/html");
            Response.Write(@"<html><body><pre class=""wm_print_content"">");
            Utils.SettingsPath = AdminPanelUtils.GetWebMailFolder();
            string logPath = Utils.GetLogFilePath();

            Response.Write(HttpUtility.HtmlEncode(Utils.LoadFromFile(logPath, Encoding.Default)));
            Response.Write("</pre></body></html>");
            Response.Flush();
            Response.Close();
        }
Esempio n. 15
0
    public override bool CanLoadPlugin()
    {
        bool result = false;

        if (Plugin.IsPluginExist(MapPath("../../"), AdminPanelConstants.PluginName.WebMailLite))
        {
            result = true;
        }
        else
        {
            result = AdminPanelUtils.ValidationLicenseKey((Page as DefaultPage).Settings.LicenseKey);
        }
        return(result && AdminPanelUtils.IsSuperAdmin(Session, (Page as DefaultPage).Settings));
    }
Esempio n. 16
0
    protected void SubmitButton_Click(object sender, System.EventArgs e)
    {
        try
        {
            WebmailSettings settings = new WebMailSettingsCreator().CreateWebMailSettings(AdminPanelUtils.GetWebMailDataFolder());

            try
            {
                settings.MailsPerPage = short.Parse(intMailsPerPage.Value, CultureInfo.InvariantCulture);
                if (settings.MailsPerPage < 0)
                {
                    settings.MailsPerPage = Math.Abs(settings.MailsPerPage);
                }
            }
            catch (Exception error)
            {
                Log.WriteException(error);
            }

            settings.DefaultSkin              = txtDefaultSkin.Value;
            settings.DefaultLanguage          = txtDefaultLanguage.Value;
            settings.AllowUsersChangeSkin     = intAllowUsersChangeSkin.Checked;
            settings.AllowUsersChangeLanguage = intAllowUsersChangeLanguage.Checked;
            settings.ShowTextLabels           = intShowTextLabels.Checked;
            settings.AllowDhtmlEditor         = intAllowDHTMLEditor.Checked;
            settings.AllowContacts            = intAllowContacts.Checked;
            settings.AllowCalendar            = intAllowCalendar.Checked;

            ViewMode mode = ViewMode.WithoutPreviewPane;
            if (intRightMessagePane.Checked)
            {
                mode |= ViewMode.WithPreviewPane;
            }
            if (intAlwaysShowPictures.Checked)
            {
                mode |= ViewMode.AlwaysShowPictures;
            }
            settings.ViewMode = mode;

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

            AdminPanelUtils.SetPageReportMessage(this.Page, Constants.mailAdmSaveSuccess);
        }
        catch (Exception error)
        {
            Log.WriteException(error);
            AdminPanelUtils.SetPageErrorMessage(this.Page, Constants.mailAdmSaveUnsuccess);
        }
    }
Esempio n. 17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        install _page = Page as install;

        _web_step = _page._web_step;
        _max_step = _page._max_step;

        if (Page.IsPostBack)
        {
            AdminPanelUtils.SaveState("AUTH", true, Page.Session);

            AdminPanelSettings apSettings = new AdminPanelSettings().Load();
            AdminPanelUtils.SaveState("Admin", apSettings.User, Page.Session);

            Response.Redirect("default.aspx", true);
        }
    }
Esempio n. 18
0
    public void UpdateDomain()
    {
        switch (_domainType)
        {
        case "vir":
        case "reg":
            this.UpdateXMailDomain();
            break;

        case "rem":
            this.UpdateWebMailDomain();
            break;
        }

        AdminPanelUtils.SaveState("SessPageReportMessage", WebMail.Constants.mailAdmUpdateAccountSuccess, Page.Session);
        InitDomain();
    }
Esempio n. 19
0
    public static void ShowReportAndReportMessages(Page page)
    {
        string _PageReportMessage = (AdminPanelUtils.LoadState("SessPageReportMessage", page.Session) != null) ? AdminPanelUtils.LoadState("SessPageReportMessage", page.Session).ToString() : null;
        string _PageErrorMessage  = (AdminPanelUtils.LoadState("SessPageErrorMessage", page.Session) != null) ? AdminPanelUtils.LoadState("SessPageErrorMessage", page.Session).ToString() : null;

        if (_PageReportMessage != null)
        {
            AdminPanelUtils.SetPageReportMessage(page, _PageReportMessage);
            AdminPanelUtils.SaveState("SessPageReportMessage", null, page.Session);
        }

        if (_PageErrorMessage != null)
        {
            AdminPanelUtils.SetPageErrorMessage(page, _PageErrorMessage);
            AdminPanelUtils.SaveState("SessPageErrorMessage", null, page.Session);
        }
    }
Esempio n. 20
0
    protected void Page_Load(object sender, EventArgs e)
    {
        controlPrefix = this.ClientID;

        install _page = Page as install;

        _web_step = _page._web_step;
        _max_step = _page._max_step;

        intDbTypeMsSql_label.Attributes["for"]    = intDbTypeMsSql.ClientID;
        intDbTypeMySql_label.Attributes["for"]    = intDbTypeMySql.ClientID;
        intDbTypeMsAccess_label.Attributes["for"] = intDbTypeMsAccess.ClientID;

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

        if (Session["TrySqlPassword"] == null)
        {
            Session["TrySqlPassword"] = settings.DbPassword;
        }
        txtSqlPassword.Attributes.Add("Value", Session["TrySqlPassword"].ToString());

        switch (settings.DbType)
        {
        case SupportedDatabase.MsAccess:
            intDbTypeMsAccess.Checked = true;
            break;

        case SupportedDatabase.MsSqlServer:
            intDbTypeMsSql.Checked = true;
            break;

        case SupportedDatabase.MySql:
            intDbTypeMySql.Checked = true;
            break;
        }
        txtSqlLogin.Value          = settings.DbLogin;
        txtSqlName.Value           = settings.DbName;
        txtSqlDsn.Value            = settings.DbDsn;
        txtSqlSrc.Value            = settings.DbHost;
        txtAccessFile.Value        = settings.DbPathToMdb;
        odbcConnectionString.Value = settings.DbCustomConnectionString;
        useCS.Checked  = settings.UseCustomConnectionString;
        useDSN.Checked = settings.UseDSN;
        DbPrefix.Value = settings.DbPrefix;
    }
Esempio n. 21
0
    protected void SaveButton_Click(object sender, System.EventArgs e)
    {
        try
        {
            WebmailSettings settings = new WebMailSettingsCreator().CreateWebMailSettings(AdminPanelUtils.GetWebMailDataFolder());

            settings.EnableLogging = intEnableLogging.Checked;
            settings.SaveWebmailSettings(AdminPanelUtils.GetWebMailDataFolder());
            this.Context.Application.Remove(Constants.sessionSettings);

            AdminPanelUtils.SetPageReportMessage(this.Page, Constants.mailAdmSaveSuccess);
        }
        catch (Exception error)
        {
            Log.WriteException(error);
            AdminPanelUtils.SetPageErrorMessage(this.Page, Constants.mailAdmSaveUnsuccess);
        }
    }
 public void SaveSettings(object sender, System.EventArgs e)
 {
     if (txtPassword.Text.Trim() != AdminPanelConstants.DummyPassword)
     {
         apSettings.Pass = txtPassword.Text;
     }
     try
     {
         apSettings.Save();
         AdminPanelUtils.SetPageReportMessage(Page, "Settings are successfully saved!");
         Response.Redirect("install.aspx?mode=connection", true);
     }
     catch (Exception ex)
     {
         Log.WriteException(ex);
         AdminPanelUtils.SetPageErrorMessage(Page, (ex.InnerException != null ? ex.InnerException.Message : ex.Message));
     }
 }
    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);
        }
    }
Esempio n. 24
0
        public HMailServer()
        {
            string AssemblyPath = Path.Combine(AdminPanelUtils.GetWebMailFolder(), @"bin\Interop.hMailServer.dll");

            if (File.Exists(AssemblyPath))
            {
                try
                {
                    _assembly    = System.Reflection.Assembly.LoadFrom(AssemblyPath);
                    _application = assembly.CreateInstance("hMailServer.ApplicationClass");
                }
                catch (Exception ex)
                {
                    _assembly = null;
                    Log.WriteException(ex);
                    throw;
                }
            }
        }
Esempio n. 25
0
    public void UpdateXMailDomain()
    {
        try
        {
            XMLayer xmLayer = XMServer.CreateXMLayer();
            xmLayer.Login();

            if (Int32.Parse(hidCustomDomain.Value) == 1)
            {
                // edit custom domain
                StringBuilder redirect = new StringBuilder("redirect");

/*
 *              if (Request.Params[RedirectionsListDDL.UniqueID] != null)
 *              {
 *                  string[] RedirectionsList = Request.Params[RedirectionsListDDL.UniqueID].ToString().Split(',');
 *                  for (int i = 0; i < RedirectionsList.Length; i++)
 *                      redirect.AppendFormat("\t\"{0}\"", RedirectionsList[i]);
 *              }
 */
                StringBuilder lredirect = new StringBuilder("lredirect");
                if (Request.Params[LRedirectionsListDDL.UniqueID] != null)
                {
                    string[] LRedirectionsList = Request.Params[LRedirectionsListDDL.UniqueID].ToString().Split(',');
                    for (int i = 0; i < LRedirectionsList.Length; i++)
                    {
                        lredirect.AppendFormat("\t\"{0}\"", LRedirectionsList[i]);
                    }
                }
                string data = string.Format("{0}\r\n{1}\r\n{2}\r\n.\r\n", redirect.ToString(), lredirect.ToString(), AdvancedID.Text);
                xmLayer.SetCustomDomainTab(textDomainName.Value.Trim(), data);
            }

            xmLayer.Logout();
        }
        catch (Exception ex)
        {
            Log.WriteException(ex);
            AdminPanelUtils.SetPageErrorMessage(this.Page, ex.Message);
        }
    }
Esempio n. 26
0
        protected void ShowLogPartial()
        {
            Response.Clear();
            Response.AddHeader("Content-Type", "text/html");
            Response.Write(@"<html><body><pre class=""wm_print_content"">");
            Utils.SettingsPath = AdminPanelUtils.GetWebMailFolder();
            string    logPath      = Utils.GetLogFilePath();
            FileInfo  fi           = new FileInfo(logPath);
            string    log          = string.Empty;
            const int lastPartSize = 20000;

            if (fi.Exists)
            {
                log = fi.Length > lastPartSize ? (string)Utils.LoadFromFile(logPath, Encoding.Default, (int)fi.Length - lastPartSize, lastPartSize) : Utils.LoadFromFile(logPath, Encoding.Default, 0, lastPartSize);
            }

            Response.Write(log);
            Response.Write("</pre></body></html>");
            Response.Flush();
            Response.Close();
        }
Esempio n. 27
0
    public void DeleteWebMailDomain(string name)
    {
        Domain dom = new Domain();

        if (!string.IsNullOrEmpty(name))
        {
            try
            {
                dom = Domain.LoadFromDb(name);
                if (dom != null)
                {
                    dom.Delete();
                    Account.UpdateAccountsByDomain(dom.Name, dom.ID, 0, -1);
                }
            }
            catch (WebMailException ex)
            {
                Log.WriteException(ex);
                AdminPanelUtils.SetPageErrorMessage(Page, ex.Message);
            }
        }
    }
Esempio n. 28
0
 protected void SubmitButton_Click(object sender, System.EventArgs e)
 {
     if (Save())
     {
         if (chNotCreate.Checked)
         {
             if (!create_tables())
             {
                 Response.Redirect("install.aspx?mode=common", true);
             }
         }
         else
         {
             Response.Redirect("install.aspx?mode=common", true);
         }
     }
     else
     {
         WebmailSettings settings = new WebmailSettings().CreateInstance(AdminPanelUtils.GetWebMailDataFolder());
         DbPrefix.Value = settings.DbPrefix;
     }
 }
Esempio n. 29
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Session.Timeout = AdminPanelConstants.SessionTimeout;

        string mode = (!string.IsNullOrEmpty(Request.QueryString["mode"]) ? Request.QueryString["mode"] : string.Empty);

        if (!Page.IsPostBack)
        {
            switch (mode)
            {
            case "logout":
                Session.Clear();
                Session.Abandon();
                break;
            }
        }

        if (Session["AUTH"] == null)
        {
            Control ctrl = LoadControl("core/Login.ascx");
            if (ctrl != null)
            {
                mainPlaceHolder.Controls.Add(ctrl);
            }
        }
        else
        {
            if (File.Exists(Path.Combine(Page.MapPath(""), "install.htm")))
            {
                AdminPanelUtils.SetPageErrorMessage(Page, @"Please delete install.htm file.");
            }

            Control ctrl = LoadControl("core/AdminPanel.ascx");
            if (ctrl != null)
            {
                mainPlaceHolder.Controls.Add(ctrl);
            }
        }
    }
Esempio n. 30
0
    public static void SetControlAccounts(List <AdminPanelControlAccount> cAccounts)
    {
        try
        {
            XMLayer xm    = XMServer.CreateXMLayer();
            string  param = string.Empty;

            foreach (AdminPanelControlAccount ca in cAccounts)
            {
                param += '\"' + ca.Name + '\"' + '\t' + '\"' + AdminPanelUtils.EncryptPassword(ca.Password) + '\"' + "\r\n";
            }

            xm.Login();
            xm.SetCtrlAccounts(param);
            xm.Logout();
        }
        catch (Exception error)
        {
            Log.WriteException(error);
            throw new WebMail.WebMailException(error);
        }
    }