/// -----------------------------------------------------------------------------
        /// <summary>
        /// cmdUpdate_Click runs when the Update button is clicked
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// 	[cnurse]	5/10/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        /// -----------------------------------------------------------------------------
        private void cmdUpdate_Click(Object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                try
                {
                    bool blnChild;
                    string strPortalAlias;
                    string strChildPath = string.Empty;
                    var closePopUpStr = string.Empty;

                    var objPortalController = new PortalController();

                    //check template validity
                    var messages = new ArrayList();
                    string schemaFilename = Server.MapPath(string.Concat(AppRelativeTemplateSourceDirectory, "portal.template.xsd"));
                    string xmlFilename = Globals.HostMapPath + cboTemplate.SelectedItem.Text + ".template";
                    var xval = new PortalTemplateValidator();
                    if (!xval.Validate(xmlFilename, schemaFilename))
                    {
                        UI.Skins.Skin.AddModuleMessage(this, "", String.Format(Localization.GetString("InvalidTemplate", LocalResourceFile), cboTemplate.SelectedItem.Text + ".template"), ModuleMessage.ModuleMessageType.RedError);
                        messages.AddRange(xval.Errors);
                        lstResults.Visible = true;
                        lstResults.DataSource = messages;
                        lstResults.DataBind();
                        return;
                    }

                    //Set Portal Name
                    txtPortalName.Text = txtPortalName.Text.ToLowerInvariant();
                    txtPortalName.Text = txtPortalName.Text.Replace("http://", "");

                    //Validate Portal Name
                    if (!Globals.IsHostTab(PortalSettings.ActiveTab.TabID))
                    {
                        blnChild = true;
                        strPortalAlias = txtPortalName.Text;
                    }
                    else
                    {
                        blnChild = (optType.SelectedValue == "C");

                        strPortalAlias = blnChild ? txtPortalName.Text.Substring(txtPortalName.Text.LastIndexOf("/") + 1) : txtPortalName.Text;
                    }

                    string message = String.Empty;
                    ModuleMessage.ModuleMessageType messageType = ModuleMessage.ModuleMessageType.RedError;
                    if (!PortalAliasController.ValidateAlias(strPortalAlias, blnChild))
                    {
                        message = Localization.GetString("InvalidName", LocalResourceFile);
                    }

                    //Validate Password
                    if (txtPassword.Text != txtConfirm.Text)
                    {
                        if (!String.IsNullOrEmpty(message)) message += "<br/>";
                        message += Localization.GetString("InvalidPassword", LocalResourceFile);
                    }
                    string strServerPath = Globals.GetAbsoluteServerPath(Request);

                    //Set Portal Alias for Child Portals
                    if (String.IsNullOrEmpty(message))
                    {
                        if (blnChild)
                        {
                            strChildPath = strServerPath + strPortalAlias;

                            if (Directory.Exists(strChildPath))
                            {
                                message = Localization.GetString("ChildExists", LocalResourceFile);
                            }
                            else
                            {
                                if (!Globals.IsHostTab(PortalSettings.ActiveTab.TabID))
                                {
                                    strPortalAlias = Globals.GetDomainName(Request, true) + "/" + strPortalAlias;
                                }
                                else
                                {
                                    strPortalAlias = txtPortalName.Text;
                                }
                            }
                        }
                    }

                    //Get Home Directory
                    string homeDir = txtHomeDirectory.Text != @"Portals/[PortalID]" ? txtHomeDirectory.Text : "";

                    //Validate Home Folder
                    if (!string.IsNullOrEmpty(homeDir))
                    {
                        if (string.IsNullOrEmpty(String.Format("{0}\\{1}\\", Globals.ApplicationMapPath, homeDir).Replace("/", "\\")))
                        {
                            message = Localization.GetString("InvalidHomeFolder", LocalResourceFile);
                        }
                        if (homeDir.Contains("admin") || homeDir.Contains("DesktopModules") || homeDir.ToLowerInvariant() == "portals/")
                        {
                            message = Localization.GetString("InvalidHomeFolder", LocalResourceFile);
                        }
                    }

                    //Validate Portal Alias
                    if (!string.IsNullOrEmpty(strPortalAlias))
                    {
                        PortalAliasInfo portalAlias = PortalAliasController.GetPortalAliasLookup(strPortalAlias.ToLower());
                        if (portalAlias != null)
                        {
                            message = Localization.GetString("DuplicatePortalAlias", LocalResourceFile);
                        }
                    }

                    //Create Portal
                    if (String.IsNullOrEmpty(message))
                    {
                        string strTemplateFile = cboTemplate.SelectedItem.Text + ".template";

                        //Attempt to create the portal
                        var objAdminUser = new UserInfo();
                        int intPortalId;
                        try
                        {
                            objAdminUser.FirstName = txtFirstName.Text;
                            objAdminUser.LastName = txtLastName.Text;
                            objAdminUser.Username = txtUsername.Text;
                            objAdminUser.DisplayName = txtFirstName.Text + " " + txtLastName.Text;
                            objAdminUser.Email = txtEmail.Text;
                            objAdminUser.IsSuperUser = false;

                            objAdminUser.Membership.Approved = true;
                            objAdminUser.Membership.Password = txtPassword.Text;
                            objAdminUser.Membership.PasswordQuestion = txtQuestion.Text;
                            objAdminUser.Membership.PasswordAnswer = txtAnswer.Text;

                            objAdminUser.Profile.FirstName = txtFirstName.Text;
                            objAdminUser.Profile.LastName = txtLastName.Text;
                            intPortalId = objPortalController.CreatePortal(txtTitle.Text,
                                                                           objAdminUser,
                                                                           txtDescription.Text,
                                                                           txtKeyWords.Text,
                                                                           Globals.HostMapPath,
                                                                           strTemplateFile,
                                                                           homeDir,
                                                                           strPortalAlias,
                                                                           strServerPath,
                                                                           strChildPath,
                                                                           blnChild);
                        }
                        catch (Exception ex)
                        {
                            intPortalId = Null.NullInteger;
                            message = ex.Message;
                        }
                        if (intPortalId != -1)
                        {
                            //Create a Portal Settings object for the new Portal
                            PortalInfo objPortal = objPortalController.GetPortal(intPortalId);
                            var newSettings = new PortalSettings { PortalAlias = new PortalAliasInfo { HTTPAlias = strPortalAlias }, PortalId = intPortalId, DefaultLanguage = objPortal.DefaultLanguage };
                            string webUrl = Globals.AddHTTP(strPortalAlias);
                            try
                            {
                                if (!Globals.IsHostTab(PortalSettings.ActiveTab.TabID))
                                {
                                    message = Mail.SendMail(PortalSettings.Email,
                                                               txtEmail.Text,
                                                               PortalSettings.Email + ";" + Host.HostEmail,
                                                               Localization.GetSystemMessage(newSettings, "EMAIL_PORTAL_SIGNUP_SUBJECT", objAdminUser),
                                                               Localization.GetSystemMessage(newSettings, "EMAIL_PORTAL_SIGNUP_BODY", objAdminUser),
                                                               "",
                                                               "",
                                                               "",
                                                               "",
                                                               "",
                                                               "");
                                }
                                else
                                {
                                    message = Mail.SendMail(Host.HostEmail,
                                                               txtEmail.Text,
                                                               Host.HostEmail,
                                                               Localization.GetSystemMessage(newSettings, "EMAIL_PORTAL_SIGNUP_SUBJECT", objAdminUser),
                                                               Localization.GetSystemMessage(newSettings, "EMAIL_PORTAL_SIGNUP_BODY", objAdminUser),
                                                               "",
                                                               "",
                                                               "",
                                                               "",
                                                               "",
                                                               "");
                                }
                            }
                            catch (Exception exc)
                            {
                                DnnLog.Error(exc);

                                closePopUpStr = (PortalSettings.EnablePopUps) ? "onclick=\"return " + UrlUtils.ClosePopUp(true,webUrl,true) + "\"" : "";
                                message = string.Format(Localization.GetString("UnknownSendMail.Error", LocalResourceFile), webUrl, closePopUpStr);
                            }
                            var objEventLog = new EventLogController();
                            objEventLog.AddLog(objPortalController.GetPortal(intPortalId), PortalSettings, UserId, "", EventLogController.EventLogType.PORTAL_CREATED);

                            //Redirect to this new site
                            if (message == Null.NullString)
                            {
                                webUrl = (PortalSettings.EnablePopUps) ? UrlUtils.ClosePopUp(true, webUrl, false) : webUrl;
                                Response.Redirect(webUrl,true);
                            }
                            else
                            {
                                closePopUpStr = (PortalSettings.EnablePopUps) ? "onclick=\"return " + UrlUtils.ClosePopUp(true, webUrl, true) + "\"" : "";
                                message = string.Format(Localization.GetString("SendMail.Error", LocalResourceFile), message, webUrl, closePopUpStr);
                                messageType = ModuleMessage.ModuleMessageType.YellowWarning;
                            }
                        }
                    }
                    UI.Skins.Skin.AddModuleMessage(this, "", message, messageType);
                }
                catch (Exception exc) //Module failed to load
                {
                    Exceptions.ProcessModuleLoadException(this, exc);
                }
            }
        }
Exemplo n.º 2
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        ///   AddPortal manages the Installation of a new DotNetNuke Portal
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///   [cnurse]	11/06/2004	created
        /// </history>
        /// -----------------------------------------------------------------------------
        public static int AddPortal(XmlNode node, bool status, int indent)
        {

            int portalId = -1;
            try
            {
                string hostMapPath = Globals.HostMapPath;
                string childPath = "";
                string domain = "";

                if ((HttpContext.Current != null))
                {
                    domain = Globals.GetDomainName(HttpContext.Current.Request, true).ToLowerInvariant().Replace("/install", "");
                }
                DnnInstallLogger.InstallLogInfo(Localization.Localization.GetString("LogStart", Localization.Localization.GlobalResourceFile) + "AddPortal:" + domain);
                string portalName = XmlUtils.GetNodeValue(node.CreateNavigator(), "portalname");
                if (status)
                {
                    if (HttpContext.Current != null)
                    {
                        HtmlUtils.WriteFeedback(HttpContext.Current.Response, indent, "Creating Site: " + portalName + "<br>");
                    }
                }

                var portalController = new PortalController();
                XmlNode adminNode = node.SelectSingleNode("administrator");
                if (adminNode != null)
                {
                    string firstName = XmlUtils.GetNodeValue(adminNode.CreateNavigator(), "firstname");
                    string lastName = XmlUtils.GetNodeValue(adminNode.CreateNavigator(), "lastname");
                    string username = XmlUtils.GetNodeValue(adminNode.CreateNavigator(), "username");
                    string password = XmlUtils.GetNodeValue(adminNode.CreateNavigator(), "password");
                    string email = XmlUtils.GetNodeValue(adminNode.CreateNavigator(), "email");
                    string description = XmlUtils.GetNodeValue(node.CreateNavigator(), "description");
                    string keyWords = XmlUtils.GetNodeValue(node.CreateNavigator(), "keywords");
                    string templateFileName = XmlUtils.GetNodeValue(node.CreateNavigator(), "templatefile");
                    string serverPath = Globals.ApplicationMapPath + "\\";
                    bool isChild = bool.Parse(XmlUtils.GetNodeValue(node.CreateNavigator(), "ischild"));
                    string homeDirectory = XmlUtils.GetNodeValue(node.CreateNavigator(), "homedirectory");

                    //Get the Portal Alias
                    XmlNodeList portalAliases = node.SelectNodes("portalaliases/portalalias");
                    string strPortalAlias = domain;
                    if (portalAliases != null)
                    {
                        if (portalAliases.Count > 0)
                        {
                            if (!string.IsNullOrEmpty(portalAliases[0].InnerText))
                            {
                                strPortalAlias = portalAliases[0].InnerText;
                            }
                        }
                    }

                    //Create default email
                    if (string.IsNullOrEmpty(email))
                    {
                        email = "admin@" + domain.Replace("www.", "");
                        //Remove any domain subfolder information ( if it exists )
                        if (email.IndexOf("/") != -1)
                        {
                            email = email.Substring(0, email.IndexOf("/"));
                        }
                    }

                    if (isChild)
                    {
                        childPath = PortalController.GetPortalFolder(strPortalAlias);
                    }

                    var template = FindBestTemplate(templateFileName);
                    var userInfo = CreateUserInfo(firstName, lastName, username, password, email);

                    //Create Portal
                    portalId = portalController.CreatePortal(portalName, 
                                                             userInfo,
                                                             description,
                                                             keyWords,
                                                             template,
                                                             homeDirectory,
                                                             strPortalAlias,
                                                             serverPath,
                                                             serverPath + childPath,
                                                             isChild);

                    if (portalId > -1)
                    {
                        //Add Extra Aliases
                        if (portalAliases != null)
                        {
                            foreach (XmlNode portalAlias in portalAliases)
                            {
                                if (!string.IsNullOrEmpty(portalAlias.InnerText))
                                {
                                    if (status)
                                    {
                                        if (HttpContext.Current != null)
                                        {
                                            HtmlUtils.WriteFeedback(HttpContext.Current.Response, indent, "Creating Site Alias: " + portalAlias.InnerText + "<br>");
                                        }
                                    }
                                    portalController.AddPortalAlias(portalId, portalAlias.InnerText);
                                }
                            }
                        }

                        //Force Administrator to Update Password on first log in
                        PortalInfo portal = portalController.GetPortal(portalId);
                        UserInfo adminUser = UserController.GetUserById(portalId, portal.AdministratorId);
                        adminUser.Membership.UpdatePassword = true;
                        UserController.UpdateUser(portalId, adminUser);
                    }


                    return portalId;
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);

                if (HttpContext.Current != null)
                {
                    HtmlUtils.WriteFeedback(HttpContext.Current.Response, indent, "<font color='red'>Error: " + ex.Message + ex.StackTrace + "</font><br>");
					DnnInstallLogger.InstallLogError(ex);
                }
                // failure
                portalId = - 1;
            }
            return portalId;
        }
Exemplo n.º 3
0
        private void CreateSite(PortalConfig portal, InstallConfig installConfig)
        {

            var domain = "";
            if ((HttpContext.Current != null))
            {
                domain = Globals.GetDomainName(HttpContext.Current.Request, true).ToLowerInvariant().Replace("/install/launchautoinstall", "").Replace("/install", "").Replace("/runinstall", "");
            }

            var portalController = new PortalController();
            var serverPath = Globals.ApplicationMapPath + "\\";

            //Get the Portal Alias
            var portalAlias = domain;
            if (portal.PortAliases.Count > 0) portalAlias = portal.PortAliases[0];

            //Verify that portal alias is not present
            if (PortalAliasController.GetPortalAliasLookup(portalAlias.ToLower()) != null)
            {
                string description = Localization.Localization.GetString("SkipCreatingSite", LocalInstallResourceFile);
                Details = string.Format(description, portalAlias);
                return;
            }
            
            //Create default email
            var email = portal.AdminEmail;
            if (string.IsNullOrEmpty(email))
            {
                email = "admin@" + domain.Replace("www.", "");
                //Remove any domain subfolder information ( if it exists )
                if (email.IndexOf("/") != -1)
                {
                    email = email.Substring(0, email.IndexOf("/"));
                }
            }

            //install LP if installing in a different language            
            string culture = installConfig.InstallCulture;
            if (!culture.Equals("en-us", StringComparison.InvariantCultureIgnoreCase))
            {
                string installFolder = HttpContext.Current.Server.MapPath("~/Install/language");
                Upgrade.InstallPackage(installFolder + "\\installlanguage.resources", "Language", false);
            }

            var template = Upgrade.FindBestTemplate(portal.TemplateFileName);
            UserInfo userInfo;
            
            if (!String.IsNullOrEmpty(portal.AdminUserName))
                userInfo = Upgrade.CreateUserInfo(portal.AdminFirstName, portal.AdminLastName, portal.AdminUserName, portal.AdminPassword, email);
            else
                userInfo = Upgrade.CreateUserInfo(installConfig.SuperUser.FirstName, installConfig.SuperUser.LastName, installConfig.SuperUser.UserName, installConfig.SuperUser.Password, installConfig.SuperUser.Email);

            var childPath = string.Empty;
            if (portal.IsChild)
                childPath = portalAlias.Substring(portalAlias.LastIndexOf("/") + 1);
            
            //Create Portal
            var portalId = portalController.CreatePortal(portal.PortalName,
                                                     userInfo,
                                                     portal.Description,
                                                     portal.Keywords,
                                                     template,
                                                     portal.HomeDirectory,
                                                     portalAlias,
                                                     serverPath,
                                                     serverPath + childPath,
                                                     portal.IsChild);

            if (portalId > -1)
            {
                foreach (var alias in portal.PortAliases)
                {
                    portalController.AddPortalAlias(portalId, alias);
                }
            }

            //remove en-US from portal if installing in a different language
			if (!culture.Equals("en-us", StringComparison.InvariantCultureIgnoreCase))
            {
                var locale = LocaleController.Instance.GetLocale("en-US");              
                Localization.Localization.RemoveLanguageFromPortal(portalId, locale.LanguageId);
            }

            //Log user in to site
            var loginStatus = UserLoginStatus.LOGIN_FAILURE;
            UserController.UserLogin(portalId, userInfo.Username, installConfig.SuperUser.Password, "", "", "", ref loginStatus, false);

            InstallController.Instance.RemoveFromInstallConfig("//dotnetnuke/superuser/password");
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// InstallPortal installs the Host Portal
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// 	[cnurse]	02/19/2007 Created
        /// </history>
        /// -----------------------------------------------------------------------------
        private bool InstallPortal()
        {
            bool success = false;
            string strErrorMessage = usrAdmin.Validate();

            if (!string.IsNullOrEmpty(strErrorMessage))
            {
                string strError = LocalizeString(strErrorMessage);
                if (strErrorMessage == "PasswordLength")
                {
                    strError = string.Format(strError, MembershipProviderConfig.MinPasswordLength);
                }
                lblPortalError.Text = string.Format(LocalizeString("AdminUserError"), strError);
            }
            else
            {
                try
                {
                    var objPortalController = new PortalController();
                    string strServerPath = Globals.ApplicationMapPath + "\\";
                    string strPortalAlias = Globals.GetDomainName(HttpContext.Current.Request, true).Replace("/Install", "");
                    string strTemplate = cboPortalTemplate.SelectedValue + ".template";

                    //Create Portal
                    PortalId = objPortalController.CreatePortal(txtPortalTitle.Text,
                                                                usrAdmin.FirstName,
                                                                usrAdmin.LastName,
                                                                usrAdmin.UserName,
                                                                usrAdmin.Password,
                                                                usrAdmin.Email,
                                                                "",
                                                                "",
                                                                Globals.HostMapPath,
                                                                strTemplate,
                                                                "",
                                                                strPortalAlias,
                                                                strServerPath,
                                                                "",
                                                                false);
                    success = (PortalId > Null.NullInteger);

                    Config.Touch();
                    Response.Redirect("~/Default.aspx", true);
                }
                catch (ThreadAbortException)
                {
                    //do nothing - we swallow this exception - becuase of redirect
                }
                catch (Exception ex)
                {
                    Instrumentation.DnnLog.Error(ex);
                    success = false;
                    strErrorMessage = ex.Message;
                }
                if (!success)
                {
                    lblPortalError.Text = string.Format(LocalizeString("InstallPortalError"), strErrorMessage);
                }
            }
            return success;
        }
Exemplo n.º 5
0
        /// <summary>
        /// AddPortal manages the Installation of a new DotNetNuke Portal
        /// </summary>
        /// <remarks>
        /// </remarks>
        public static int AddPortal(XmlNode node, bool status, int indent)
        {
            try
            {
                int intPortalId;
                string strHostPath = Globals.HostMapPath;
                string strChildPath = "";
                string strDomain = "";

                if (HttpContext.Current != null)
                {
                    strDomain = Globals.GetDomainName(HttpContext.Current.Request, true).Replace("/Install", "");
                }

                string strPortalName = XmlUtils.GetNodeValue(node, "portalname", "");
                if (status)
                {
                    HtmlUtils.WriteFeedback(HttpContext.Current.Response, indent, "Creating Portal: " + strPortalName + "<br>");
                }

                PortalController objPortalController = new PortalController();
                PortalSecurity objSecurity = new PortalSecurity();
                XmlNode adminNode = node.SelectSingleNode("administrator");
                string strFirstName = XmlUtils.GetNodeValue(adminNode, "firstname", "");
                string strLastName = XmlUtils.GetNodeValue(adminNode, "lastname", "");
                string strUserName = XmlUtils.GetNodeValue(adminNode, "username", "");
                string strPassword = XmlUtils.GetNodeValue(adminNode, "password", "");
                string strEmail = XmlUtils.GetNodeValue(adminNode, "email", "");
                string strDescription = XmlUtils.GetNodeValue(node, "description", "");
                string strKeyWords = XmlUtils.GetNodeValue(node, "keywords", "");
                string strTemplate = XmlUtils.GetNodeValue(node, "templatefile", "");
                string strServerPath = Globals.ApplicationMapPath + "\\";
                bool isChild = bool.Parse(XmlUtils.GetNodeValue(node, "ischild", ""));
                string strHomeDirectory = XmlUtils.GetNodeValue(node, "homedirectory", "");

                //Get the Portal Alias
                XmlNodeList portalAliases = node.SelectNodes("portalaliases/portalalias");
                string strPortalAlias = strDomain;
                if (portalAliases.Count > 0)
                {
                    if (portalAliases[0].InnerText != "")
                    {
                        strPortalAlias = portalAliases[0].InnerText;
                    }
                }

                //Create default email
                if (strEmail == "")
                {
                    strEmail = "admin@" + strDomain.Replace("www.", "");
                    //Remove any domain subfolder information ( if it exists )
                    if (strEmail.IndexOf("/") != -1)
                    {
                        strEmail = strEmail.Substring(0, strEmail.IndexOf("/"));
                    }
                }

                if (isChild)
                {

                    strChildPath = strPortalAlias.Substring(strPortalAlias.LastIndexOf("/") + 1 - 1);
                }

                //Create Portal
                intPortalId = objPortalController.CreatePortal(strPortalName, strFirstName, strLastName, strUserName, objSecurity.Encrypt(Convert.ToString(Globals.HostSettings["EncryptionKey"]), strPassword), strEmail, strDescription, strKeyWords, strHostPath, strTemplate, strHomeDirectory, strPortalAlias, strServerPath, strServerPath + strChildPath, isChild);

                if (intPortalId > -1)
                {
                    //Add Extra Aliases
                    foreach (XmlNode portalAlias in portalAliases)
                    {
                        if (!String.IsNullOrEmpty(portalAlias.InnerText))
                        {
                            if (status)
                            {
                                HtmlUtils.WriteFeedback(HttpContext.Current.Response, indent, "Creating Portal Alias: " + portalAlias.InnerText + "<br>");
                            }
                            objPortalController.AddPortalAlias(intPortalId, portalAlias.InnerText);
                        }
                    }
                }

                return intPortalId;
            }
            catch (Exception ex)
            {
                HtmlUtils.WriteFeedback(HttpContext.Current.Response, indent, "<font color='red'>Error: " + ex.Message + "</font><br>");                
                return -1; // failure
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// cmdUpdate_Click runs when the Update button is clicked
        /// </summary>
        /// <history>
        /// 	[cnurse]	5/10/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        protected void cmdUpdate_Click( Object sender, EventArgs e )
        {
            if( Page.IsValid )
            {
                try
                {
                    bool blnChild;
                    string strMessage = String.Empty;
                    string strPortalAlias;
                    int intCounter;
                    string strServerPath;
                    
                    string strChildPath = String.Empty;

                    PortalController objPortalController = new PortalController();
                    PortalSecurity objSecurity = new PortalSecurity();

                    // check template validity
                    ArrayList messages = new ArrayList();
                    string schemaFilename = Server.MapPath( "admin/Portal/portal.template.xsd" );
                    string xmlFilename = Globals.HostMapPath + cboTemplate.SelectedItem.Text + ".template";
                    PortalTemplateValidator xval = new PortalTemplateValidator();
                    if( ! xval.Validate( xmlFilename, schemaFilename ) )
                    {
                        strMessage = Localization.GetString( "InvalidTemplate", this.LocalResourceFile );
                        lblMessage.Text = string.Format( strMessage, cboTemplate.SelectedItem.Text + ".template" );
                        messages.AddRange( xval.Errors );
                        lstResults.Visible = true;
                        lstResults.DataSource = messages;
                        lstResults.DataBind();
                        return;
                    }

                    //Set Portal Name
                    txtPortalName.Text = txtPortalName.Text.ToLower();
                    txtPortalName.Text = txtPortalName.Text.Replace("http://", "");

                    //Validate Portal Name
                    if( PortalSettings.ActiveTab.ParentId != PortalSettings.SuperTabId )
                    {
                        blnChild = true;

                        // child portal
                        for( intCounter = 1; intCounter <= txtPortalName.Text.Length; intCounter++ )
                        {
                            if( "abcdefghijklmnopqrstuvwxyz0123456789-".IndexOf(txtPortalName.Text.Substring(intCounter, 1 )) == 0 )
                            {
                                strMessage += "<br>" + Localization.GetString( "InvalidName", this.LocalResourceFile );
                            }
                        }

                        strPortalAlias = txtPortalName.Text;
                    }
                    else
                    {
                        blnChild = optType.SelectedValue == "C";

                        if( blnChild )
                        {
                            strPortalAlias = txtPortalName.Text.Substring(txtPortalName.Text.LastIndexOf("/") + 1);
                        }
                        else
                        {
                            strPortalAlias = txtPortalName.Text;
                        }

                        string strValidChars = "abcdefghijklmnopqrstuvwxyz0123456789-";
                        if( ! blnChild )
                        {
                            strValidChars += "./:";
                        }

                        for( intCounter = 1; intCounter <= strPortalAlias.Length; intCounter++ )
                        {
                            if (strValidChars.IndexOf(strPortalAlias.Substring(intCounter - 1, 1)) == 0)
                            {
                                strMessage += "<br>" + Localization.GetString( "InvalidName", this.LocalResourceFile );
                            }
                        }
                    }

                    //Validate Password
                    if( txtPassword.Text != txtConfirm.Text )
                    {
                        strMessage += "<br>" + Localization.GetString( "InvalidPassword", this.LocalResourceFile );
                    }

                    strServerPath = Globals.GetAbsoluteServerPath( Request );

                    //Set Portal Alias for Child Portals
                    if( strMessage == "" )
                    {
                        if( blnChild )
                        {
                            strChildPath = strServerPath + strPortalAlias;

                            if( Directory.Exists( strChildPath ) )
                            {
                                strMessage = Localization.GetString( "ChildExists", this.LocalResourceFile );
                            }
                            else
                            {
                                if( PortalSettings.ActiveTab.ParentId != PortalSettings.SuperTabId )
                                {
                                    strPortalAlias = Globals.GetDomainName( Request ) + "/" + strPortalAlias;
                                }
                                else
                                {
                                    strPortalAlias = txtPortalName.Text;
                                }
                            }
                        }
                    }

                    //Get Home Directory
                    string HomeDir;
                    if( txtHomeDirectory.Text != "Portals/[PortalID]" )
                    {
                        HomeDir = txtHomeDirectory.Text;
                    }
                    else
                    {
                        HomeDir = "";
                    }

                    //Create Portal
                    if( strMessage == "" )
                    {
                        string strTemplateFile = cboTemplate.SelectedItem.Text + ".template";

                        //Attempt to create the portal
                        int intPortalId;
                        try
                        {
                            intPortalId = objPortalController.CreatePortal( txtTitle.Text, txtFirstName.Text, txtLastName.Text, txtUsername.Text, objSecurity.Encrypt( Convert.ToString( Globals.HostSettings["EncryptionKey"] ), txtPassword.Text ), txtEmail.Text, txtDescription.Text, txtKeyWords.Text, Globals.HostMapPath, strTemplateFile, HomeDir, strPortalAlias, strServerPath, strChildPath, blnChild );
                        }
                        catch( Exception ex )
                        {
                            intPortalId = Null.NullInteger;
                            strMessage = ex.Message;
                        }

                        if( intPortalId != - 1 )
                        {
                            // notification
                            UserInfo objUser = UserController.GetUserByName( intPortalId, txtUsername.Text, false );

                            //Create a Portal Settings object for the new Portal
                            PortalSettings newSettings = new PortalSettings();
                            newSettings.PortalAlias = new PortalAliasInfo();
                            newSettings.PortalAlias.HTTPAlias = strPortalAlias;
                            newSettings.PortalId = intPortalId;
                            string webUrl = Globals.AddHTTP( strPortalAlias );

                            try
                            {
                                if( PortalSettings.ActiveTab.ParentId != PortalSettings.SuperTabId )
                                {
                                    Mail.SendMail( PortalSettings.Email, txtEmail.Text, PortalSettings.Email + ";" + Convert.ToString( PortalSettings.HostSettings["HostEmail"] ), Localization.GetSystemMessage( newSettings, "EMAIL_PORTAL_SIGNUP_SUBJECT", objUser ), Localization.GetSystemMessage( newSettings, "EMAIL_PORTAL_SIGNUP_BODY", objUser ), "", "", "", "", "", "" );
                                }
                                else
                                {
                                    Mail.SendMail( Convert.ToString( PortalSettings.HostSettings["HostEmail"] ), txtEmail.Text, Convert.ToString( PortalSettings.HostSettings["HostEmail"] ), Localization.GetSystemMessage( newSettings, "EMAIL_PORTAL_SIGNUP_SUBJECT", objUser ), Localization.GetSystemMessage( newSettings, "EMAIL_PORTAL_SIGNUP_BODY", objUser ), "", "", "", "", "", "" );
                                }
                            }
                            catch( Exception )
                            {
                                strMessage = string.Format( Localization.GetString( "SendMail.Error", this.LocalResourceFile ), webUrl, null );
                            }

                            EventLogController objEventLog = new EventLogController();
                            objEventLog.AddLog( objPortalController.GetPortal( intPortalId ), PortalSettings, UserId, "", EventLogController.EventLogType.PORTAL_CREATED );

                            // Redirect to this new site
                            if( strMessage == Null.NullString )
                            {
                                Response.Redirect( webUrl, true );
                            }
                        }
                    }

                    lblMessage.Text = "<br>" + strMessage + "<br><br>";
                }
                catch( Exception exc ) //Module failed to load
                {
                    Exceptions.ProcessModuleLoadException( this, exc );
                }
            }
        }