Exemplo n.º 1
0
 public string GetUserHomePageUrl(int userId)
 {
     return(PortalUtils.GetUserHomePageUrl(userId));
 }
        private void CreateHostingSpace()
        {
            if (!Page.IsValid)
                return;

            string spaceName = ddlPlans.SelectedItem.Text;

            string ftpAccount = (rbFtpAccountName.SelectedIndex == 0) ? null : ftpAccountName.Text;

            string domainName = txtDomainName.Text.Trim();
            
            PackageResult result = null;
            try
            {
                result = ES.Services.Packages.AddPackageWithResources(PanelSecurity.SelectedUserId,
                    Utils.ParseInt(ddlPlans.SelectedValue, 0),
                    spaceName,
                    Utils.ParseInt(ddlStatus.SelectedValue, 0),
                    chkPackageLetter.Checked,
                    chkCreateResources.Checked, domainName, false, chkCreateWebSite.Checked,
                    chkCreateFtpAccount.Checked, ftpAccount, chkCreateMailAccount.Checked, txtHostName.Text);

                if (result.Result < 0)
                {
                    ShowResultMessage(result.Result);
                    lblMessage.Text = PortalAntiXSS.Encode(GetExceedingQuotasMessage(result.ExceedingQuotas));
                    return;

                }
                else
                {
                    if ((chkIntegratedOUProvisioning.Checked) & !string.IsNullOrEmpty(domainName))
                    {
                        UserInfo user = UsersHelper.GetUser(PanelSecurity.SelectedUserId);

                        if (user != null)
                        {
                            if (user.Role != UserRole.Reseller)
                            {
                                UserSettings settings = ES.Services.Users.GetUserSettings(user.UserId, UserSettings.EXCHANGE_POLICY);
                                string orgId = domainName.ToLower();

                                if (settings != null && settings["OrgIdPolicy"] != null)
                                {
                                    orgId = GetOrgId(settings["OrgIdPolicy"], domainName, result.Result);
                                }

                                ES.Services.Organizations.CreateOrganization(result.Result, orgId, domainName.ToLower(), domainName.ToLower());

                                if (result.Result < 0)
                                {
                                    ShowErrorMessage("USERWIZARD_CREATE_ACCOUNT");
                                    return;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ShowErrorMessage("USERWIZARD_CREATE_ACCOUNT", ex);
                return;
            }

            // Save addons
            try
            {
                int spaceId = result.Result;
                foreach (RepeaterItem item in repHostingAddons.Items)
                {
                    PackageAddonInfo addon = new PackageAddonInfo();
                    addon.PackageAddonId = 0; //PanelRequest.PackageAddonID;
                    addon.PackageId = spaceId; //PanelSecurity.PackageId;
                    addon.Comments = "";
                    addon.PlanId = Utils.ParseInt(GetDropDownListSelectedValue(item, "ddlPlan"), 0);
                    addon.StatusId = Utils.ParseInt(ddlStatus.SelectedValue, 0);
                    addon.PurchaseDate = DateTime.Now;
                    addon.Quantity = Utils.ParseInt(GetTextBoxText(item, "txtQuantity"), 1);
                    PackageResult addonResult = ES.Services.Packages.AddPackageAddon(addon);
                }

                if (rbPackageQuotas.Checked)
                {
                    //TODO: add logic to recalculate quota
                    //If checked rbPackageQuotas take all addons quota, sum it and replace to main hosting quota
                    //You can look the idea from SpaceEditDetails, but in SpaceEditDetails it is manually, need automatic here
                    //At this moment here is a lot of work, maybe later.
                }

                //PackageContext cntx = PackagesHelper.GetCachedPackageContext(spaceId);
                //string resourceGroup = "VPS2012";
                //if (cntx != null && cntx.Groups.ContainsKey(resourceGroup))
                //{
                //    string pageId = "SpaceVPS2012";
                //    string pageUrl = PortalUtils.NavigatePageURL(
                //pageId, PortalUtils.SPACE_ID_PARAM, spaceId.ToString(), null);
                //    Response.Redirect(pageUrl);
                //}               
                    
            }
            catch
            {
                //If something happens here, just ignore it. Addons not so important that a Hosting Space
            }

            if (chkRedirectToCreateVPS.Checked)
            {
                string pageId = "SpaceVPS2012";
                string pageUrl = PortalUtils.NavigatePageURL(
                            pageId, PortalUtils.SPACE_ID_PARAM, result.Result.ToString(), null);
                Response.Redirect(pageUrl);
            }
            else
            {
                // go to space home
                Response.Redirect(PortalUtils.GetSpaceHomePageUrl(result.Result));
            }            
        }
Exemplo n.º 3
0
 public string GetSpaceHomeUrl(int spaceId)
 {
     return(PortalUtils.GetSpaceHomePageUrl(spaceId));
 }
Exemplo n.º 4
0
 protected void ddlTheme_SelectedIndexChanged(object sender, EventArgs e)
 {
     PortalUtils.SetCurrentTheme(ddlTheme.SelectedValue);
     Response.Redirect(Request.Url.ToString());
 }
Exemplo n.º 5
0
 private void SetCurrentLanguage()
 {
     PortalUtils.SetCurrentLanguage(ddlLanguage.SelectedValue);
     Response.Redirect(Request.Url.ToString());
 }
Exemplo n.º 6
0
        private void ShortcutRedirect()
        {
            if (PanelSecurity.EffectiveUser.Role == UserRole.Administrator)
            {
                return; // not for administrators
            }
            string shortcut = Request["shortcut"];

            if ("vps".Equals(shortcut, StringComparison.InvariantCultureIgnoreCase))
            {
                // load hosting spaces
                PackageInfo[] packages = ES.Services.Packages.GetMyPackages(PanelSecurity.EffectiveUserId);
                if (packages.Length == 0)
                {
                    return; // no spaces - exit
                }
                // check if some package has VPS resource enabled
                foreach (PackageInfo package in packages)
                {
                    int            packageId = package.PackageId;
                    PackageContext cntx      = PackagesHelper.GetCachedPackageContext(packageId);
                    if (cntx.Groups.ContainsKey(ResourceGroups.VPS))
                    {
                        // VPS resource found
                        // check created VPS
                        VirtualMachineMetaItemsPaged vms = ES.Services.VPS.GetVirtualMachines(packageId, "", "", "", 0, Int32.MaxValue, false);
                        if (vms.Items.Length == 1)
                        {
                            // one VPS - redirect to its properties screen
                            Response.Redirect(PortalUtils.NavigatePageURL("SpaceVPS", "SpaceID", packageId.ToString(),
                                                                          "ItemID=" + vms.Items[0].ItemID.ToString(), "ctl=vps_general", "moduleDefId=VPS"));
                        }
                        else
                        {
                            // several VPS - redirect to VPS list page
                            Response.Redirect(PortalUtils.NavigatePageURL("SpaceVPS", "SpaceID", packageId.ToString(),
                                                                          "ctl=", "moduleDefId=VPS"));
                        }
                    }


                    if (cntx.Groups.ContainsKey(ResourceGroups.VPS2012))
                    {
                        // VPS resource found
                        // check created VPS
                        VirtualMachineMetaItemsPaged vms = ES.Services.VPS2012.GetVirtualMachines(packageId, "", "", "", 0, Int32.MaxValue, false);
                        if (vms.Items.Length == 1)
                        {
                            // one VPS - redirect to its properties screen
                            Response.Redirect(PortalUtils.NavigatePageURL("SpaceVPS2012", "SpaceID", packageId.ToString(),
                                                                          "ItemID=" + vms.Items[0].ItemID.ToString(), "ctl=vps_general", "moduleDefId=VPS2012"));
                        }
                        else
                        {
                            // several VPS - redirect to VPS list page
                            Response.Redirect(PortalUtils.NavigatePageURL("SpaceVPS2012", "SpaceID", packageId.ToString(),
                                                                          "ctl=", "moduleDefId=VPS2012"));
                        }
                    }


                    if (cntx.Groups.ContainsKey(ResourceGroups.VPSForPC))
                    {
                        // VPS resource found
                        // check created VPS
                        VirtualMachineMetaItemsPaged vms = ES.Services.VPSPC.GetVirtualMachines(packageId, "", "", "", 0, Int32.MaxValue, false);
                        if (vms.Items.Length == 1)
                        {
                            // one VPS - redirect to its properties screen
                            Response.Redirect(PortalUtils.NavigatePageURL("SpaceVPSForPC", "SpaceID", packageId.ToString(),
                                                                          "ItemID=" + vms.Items[0].ItemID.ToString(), "ctl=vps_general", "moduleDefId=VPSForPC"));
                        }
                        else
                        {
                            // several VPS - redirect to VPS list page
                            Response.Redirect(PortalUtils.NavigatePageURL("SpaceVPSForPC", "SpaceID", packageId.ToString(),
                                                                          "ctl=", "moduleDefId=VPSForPC"));
                        }
                    }
                }

                // no VPS resources found
                // redirect to space home
                if (packages.Length == 1)
                {
                    Response.Redirect(PortalUtils.GetSpaceHomePageUrl(packages[0].PackageId));
                }
            }
        }
Exemplo n.º 7
0
        private void LoginUser(string username, string password, bool rememberLogin,
                               string preferredLocale, string theme)
        {
            // status
            int loginStatus = PortalUtils.AuthenticateUser(username, password, ipAddress,
                                                           rememberLogin, preferredLocale, theme);

            if (loginStatus < 0)
            {
                ShowWarningMessage("WrongLogin");
                return;
            }

            // Access IP Settings
            SCP.SystemSettings settings  = ES.Services.System.GetSystemSettings(SCP.SystemSettings.ACCESS_IP_SETTINGS);
            String             AccessIps = String.Empty;

            String[] arAccessIps = null;
            if (settings != null)
            {
                AccessIps   = settings.GetValueOrDefault(SCP.SystemSettings.ACCESS_IPs, string.Empty);
                arAccessIps = AccessIps.Split(',');
            }

            if (!String.IsNullOrEmpty(AccessIps))
            {
                String RequestIP = Request.ServerVariables["REMOTE_ADDR"];
                // String l_stSubnet = Knom.Helpers.Net.SubnetMask.ReturnSubnetmask(AccessIps);
                Boolean l_Mach = false;

                try {
                    foreach (String l_AccessIP in arAccessIps)
                    {
                        l_Mach = Knom.Helpers.Net.SubnetMask.IsInRange(RequestIP, l_AccessIP.Trim());
                        if (l_Mach)
                        {
                            break; // Once it passed then don't need to check for other access;
                        }
                    }
                } catch (Exception)
                { }
                if (!l_Mach)
                {
                    PortalUtils.UserSignOutOnly();
                    // messageBox.RenderMessage(MessageBoxType.Warning, "Unauthorized IP", "Unauthorized IP", null);
                    ShowWarningMessage("IPAccessProhibited");
                    return;
                }
            }



            if (loginStatus == BusinessSuccessCodes.SUCCESS_USER_ONETIMEPASSWORD)
            {
                // One time password should be changed after login
                Response.Redirect("Default.aspx?mid=1&ctl=change_onetimepassword&onetimepassword=true&UserID=" + PanelSecurity.LoggedUserId.ToString());
            }
            else
            {
                // redirect by shortcut
                ShortcutRedirect();

                // standard redirect
                Response.Redirect(RedirectUrl, true);
            }
        }