Beispiel #1
0
        protected void cmdPreview_Click(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(SkinSrc))
            {
                string strType = SkinRoot.Substring(0, SkinRoot.Length - 1);

                string strURL = Globals.AddHTTP(Globals.GetDomainName(Request)) + Globals.ApplicationURL(_objPortal.HomeTabId).Replace("~", "");
                //detect if there is already a '?' in the URL (in case of a child portal)
                if (strURL.IndexOf("?") > 0)
                {
                    strURL += "&";
                }
                else
                {
                    strURL += "?";
                }
                strURL += "portalid=" + _objPortal.PortalID + "&" + strType + "Src=" + Globals.QueryStringEncode(SkinSrc.Replace(".ascx", ""));

                if (SkinRoot == SkinInfo.RootContainer)
                {
                    if (Request.QueryString["ModuleId"] != null)
                    {
                        strURL += "&ModuleId=" + Request.QueryString["ModuleId"];
                    }
                }

                Response.Write("<script>window.open('" + strURL + "','_blank')</script>");
            }
        }
Beispiel #2
0
        protected void Page_Load(Object sender, EventArgs e)
        {
            // set page title
            string strTitle = PortalSettings.PortalName + " > Insert Link";

            // show copyright credits?
            if (Globals.GetHashValue(Globals.HostSettings["Copyright"], "Y") == "Y")
            {
                strTitle += " ( DNN " + PortalSettings.Version + " )";
            }
            Title = strTitle;

            HtmlInputHidden htmlhidden      = new HtmlInputHidden();
            PortalSettings  _portalSettings = PortalController.GetCurrentPortalSettings();

            htmlhidden.ID    = "TargetFreeTextBox";
            htmlhidden.Value = Request.Params["ftb"];
            phHidden.Controls.Add(htmlhidden);

            htmlhidden       = new HtmlInputHidden();
            htmlhidden.ID    = "DNNDomainNameTabid";
            htmlhidden.Value = "http://" + Globals.GetDomainName(Request) + "/" + Globals.glbDefaultPage + "?tabid=";
            phHidden.Controls.Add(htmlhidden);

            htmlhidden       = new HtmlInputHidden();
            htmlhidden.ID    = "DNNDomainNameFilePath";
            htmlhidden.Value = "http://" + Globals.GetDomainName(Request) + _portalSettings.HomeDirectory.Replace(Request.ApplicationPath, "");
            phHidden.Controls.Add(htmlhidden);
        }
        /// <summary>
        /// Gets the portal settings.
        /// </summary>
        /// <returns>
        /// The Portal Settings
        /// </returns>
        private PortalSettings GetPortalSettings()
        {
            int iTabId = 0, iPortalId = 0;

            PortalSettings portalSettings;

            try
            {
                if (this.request.QueryString["tabid"] != null)
                {
                    iTabId = int.Parse(this.request.QueryString["tabid"]);
                }

                if (this.request.QueryString["PortalID"] != null)
                {
                    iPortalId = int.Parse(this.request.QueryString["PortalID"]);
                }

                string sDomainName = Globals.GetDomainName(this.Request, true);

                string sPortalAlias = PortalAliasController.GetPortalAliasByPortal(iPortalId, sDomainName);

                PortalAliasInfo objPortalAliasInfo = PortalAliasController.Instance.GetPortalAlias(sPortalAlias);

                portalSettings = new PortalSettings(iTabId, objPortalAliasInfo);
            }
            catch (Exception)
            {
                portalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"];
            }

            return(portalSettings);
        }
Beispiel #4
0
        /// <summary>
        /// Enables processing of HTTP Web requests by a custom HttpHandler that implements the <see cref="T:System.Web.IHttpHandler"/> interface.
        /// </summary>
        /// <param name="context">An <see cref="T:System.Web.HttpContext"/> object that provides references to the intrinsic server objects (for example, Request, Response, Session, and Server) used to service HTTP requests.</param>
        public void ProcessRequest(HttpContext context)
        {
            var portalId = PortalSettings.PortalId;

            // Generate Pages Array
            var pagesArray = new StringBuilder();

            pagesArray.Append("var dnnpagesSelectBox = new Array(");

            var domainName = string.Format("http://{0}", Globals.GetDomainName(context.Request, true));

            foreach (TabInfo tab in TabController.GetPortalTabs(
                         portalId, -1, false, null, true, false, true, true, true))
            {
                var tabUrl = PortalController.GetPortalSettingAsBoolean("ContentLocalizationEnabled", portalId, false) &&
                             !string.IsNullOrEmpty(tab.CultureCode)
                                    ? Globals.FriendlyUrl(
                    tab,
                    string.Format("{0}&language={1}", Globals.ApplicationURL(tab.TabID), tab.CultureCode))
                                    : Globals.FriendlyUrl(tab, Globals.ApplicationURL(tab.TabID));


                tabUrl = Globals.ResolveUrl(Regex.Replace(tabUrl, domainName, "~", RegexOptions.IgnoreCase));

                var tabName = GlobalObject.escape(tab.TabName);

                if (tab.Level.Equals(0))
                {
                    pagesArray.AppendFormat("new Array('| {0}','{1}'),", tabName, tabUrl);
                }
                else
                {
                    var separator = new StringBuilder();

                    for (int index = 0; index < tab.Level; index++)
                    {
                        separator.Append("--");
                    }

                    pagesArray.AppendFormat("new Array('|{0} {1}','{2}'),", separator, tabName, tabUrl);
                }
            }

            if (pagesArray.ToString().EndsWith(","))
            {
                pagesArray.Remove(pagesArray.Length - 1, 1);
            }

            pagesArray.Append(");");

            context.Response.ContentType = "text/javascript";
            context.Response.Write(pagesArray.ToString());
        }
Beispiel #5
0
 /// <summary>
 /// optType_SelectedIndexChanged runs when the Portal Type is changed
 /// </summary>
 /// <history>
 ///     [cnurse]	5/10/2004	Updated to reflect design changes for Help, 508 support
 ///                       and localisation
 /// </history>
 protected void optType_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         if (optType.SelectedValue == "C")
         {
             txtPortalName.Text = Globals.GetDomainName(Request) + "/";
         }
     }
     catch (Exception exc)  //Module failed to load
     {
         Exceptions.ProcessModuleLoadException(this, exc);
     }
 }
        private void BindMarketing(PortalInfo portal)
        {
            //Load DocTypes
            var searchEngines = new Dictionary <string, string>
            {
                { "Google", "http://www.google.com/addurl?q=" + Globals.HTTPPOSTEncode(Globals.AddHTTP(Globals.GetDomainName(Request))) },
                { "Yahoo", "http://siteexplorer.search.yahoo.com/submit" },
                { "Microsoft", "http://search.msn.com.sg/docs/submit.aspx" }
            };

            cboSearchEngine.DataSource = searchEngines;
            cboSearchEngine.DataBind();

            var portalAliasController = new PortalAliasController();
            var aliases = portalAliasController.GetPortalAliasArrayByPortalID(portal.PortalID);

            if (PortalController.IsChildPortal(portal, Globals.GetAbsoluteServerPath(Request)))
            {
                txtSiteMap.Text = Globals.AddHTTP(Globals.GetDomainName(Request)) + @"/SiteMap.aspx?portalid=" + portal.PortalID;
            }
            else
            {
                if (aliases.Count > 0)
                {
                    //Get the first Alias
                    var objPortalAliasInfo = (PortalAliasInfo)aliases[0];
                    txtSiteMap.Text = Globals.AddHTTP(objPortalAliasInfo.HTTPAlias) + @"/SiteMap.aspx";
                }
                else
                {
                    txtSiteMap.Text = Globals.AddHTTP(Globals.GetDomainName(Request)) + @"/SiteMap.aspx";
                }
            }
            optBanners.SelectedIndex = portal.BannerAdvertising;
            if (UserInfo.IsSuperUser)
            {
                lblBanners.Visible = false;
            }
            else
            {
                optBanners.Enabled = portal.BannerAdvertising != 2;
                lblBanners.Visible = portal.BannerAdvertising == 2;
            }
        }
Beispiel #7
0
        protected void cmdPurchase_Click(object sender, EventArgs e)
        {
            var objEvent = default(EventInfo);

            try
            {
                if (this.Page.IsValid)
                {
                    objEvent = this._objCtlEvent.EventsGet(this._itemID, this.ModuleId);
                    // User wants to purchase event, create Event Signup Record
                    this._objEventSignups = new EventSignupsInfo();

                    //Just in case the user has clicked back and has now clicked Purchase again!!
                    var objEventSignupsChk = default(EventSignupsInfo);
                    if (string.IsNullOrEmpty(this._anonEmail))
                    {
                        objEventSignupsChk =
                            this._objCtlEventSignups.EventsSignupsGetUser(
                                objEvent.EventID, this.UserId, objEvent.ModuleID);
                    }
                    else
                    {
                        objEventSignupsChk =
                            this._objCtlEventSignups.EventsSignupsGetAnonUser(
                                objEvent.EventID, this._anonEmail, objEvent.ModuleID);
                    }
                    if (!ReferenceEquals(objEventSignupsChk, null))
                    {
                        this._objEventSignups.SignupID = objEventSignupsChk.SignupID;
                    }
                    this._objEventSignups.EventID  = objEvent.EventID;
                    this._objEventSignups.ModuleID = objEvent.ModuleID;
                    if (string.IsNullOrEmpty(this._anonEmail))
                    {
                        this._objEventSignups.UserID         = this.UserId;
                        this._objEventSignups.AnonEmail      = null;
                        this._objEventSignups.AnonName       = null;
                        this._objEventSignups.AnonTelephone  = null;
                        this._objEventSignups.AnonCulture    = null;
                        this._objEventSignups.AnonTimeZoneId = null;
                    }
                    else
                    {
                        var objSecurity = new PortalSecurity();
                        this._objEventSignups.UserID    = -1;
                        this._objEventSignups.AnonEmail =
                            objSecurity.InputFilter(this._anonEmail, PortalSecurity.FilterFlag.NoScripting);
                        this._objEventSignups.AnonName =
                            objSecurity.InputFilter(this._anonName, PortalSecurity.FilterFlag.NoScripting);
                        this._objEventSignups.AnonTelephone =
                            objSecurity.InputFilter(this._anonTelephone, PortalSecurity.FilterFlag.NoScripting);
                        this._objEventSignups.AnonCulture    = Thread.CurrentThread.CurrentCulture.Name;
                        this._objEventSignups.AnonTimeZoneId = this.GetDisplayTimeZoneId();
                    }
                    this._objEventSignups.PayPalStatus      = "none";
                    this._objEventSignups.PayPalReason      = "PayPal call initiated...";
                    this._objEventSignups.PayPalPaymentDate = DateTime.UtcNow;
                    this._objEventSignups.Approved          = false;
                    this._objEventSignups.NoEnrolees        = int.Parse(this.lblNoEnrolees.Text);

                    this._objEventSignups = this.CreateEnrollment(this._objEventSignups, objEvent);

                    if (!ReferenceEquals(objEventSignupsChk, null))
                    {
                        this._objEventSignups =
                            this._objCtlEventSignups.EventsSignupsGet(objEventSignupsChk.SignupID,
                                                                      objEventSignupsChk.ModuleID, false);
                    }

                    // Mail users
                    if (this.Settings.SendEnrollMessagePaying)
                    {
                        var objEventEmailInfo = new EventEmailInfo();
                        var objEventEmail     = new EventEmails(this.PortalId, this.ModuleId, this.LocalResourceFile,
                                                                ((PageBase)this.Page).PageCulture.Name);
                        objEventEmailInfo.TxtEmailSubject = this.Settings.Templates.txtEnrollMessageSubject;
                        objEventEmailInfo.TxtEmailBody    = this.Settings.Templates.txtEnrollMessagePaying;
                        objEventEmailInfo.TxtEmailFrom    = this.Settings.StandardEmail;
                        if (string.IsNullOrEmpty(this._anonEmail))
                        {
                            objEventEmailInfo.UserEmails.Add(this.PortalSettings.UserInfo.Email);
                            objEventEmailInfo.UserLocales.Add(this.PortalSettings.UserInfo.Profile.PreferredLocale);
                            objEventEmailInfo.UserTimeZoneIds.Add(this.PortalSettings.UserInfo.Profile.PreferredTimeZone
                                                                  .Id);
                        }
                        else
                        {
                            objEventEmailInfo.UserEmails.Add(this._objEventSignups.AnonEmail);
                            objEventEmailInfo.UserLocales.Add(this._objEventSignups.AnonCulture);
                            objEventEmailInfo.UserTimeZoneIds.Add(this._objEventSignups.AnonTimeZoneId);
                        }
                        objEventEmailInfo.UserIDs.Add(objEvent.OwnerID);
                        objEventEmail.SendEmails(objEventEmailInfo, objEvent, this._objEventSignups);
                    }

                    // build PayPal URL
                    var ppurl = this.Settings.Paypalurl + "/cgi-bin/webscr?cmd=_xclick&business=";

                    var socialGroupId = this.GetUrlGroupId();

                    var objEventInfoHelper =
                        new EventInfoHelper(this.ModuleId, this.TabId, this.PortalId, this.Settings);
                    var returnURL = "";
                    if (socialGroupId > 0)
                    {
                        returnURL = objEventInfoHelper.AddSkinContainerControls(
                            Globals.NavigateURL(this.TabId, "PPEnroll", "Mid=" + Convert.ToString(this.ModuleId),
                                                "signupid=" + Convert.ToString(this._objEventSignups.SignupID),
                                                "status=enrolled", "groupid=" + socialGroupId), "?");
                    }
                    else
                    {
                        returnURL = objEventInfoHelper.AddSkinContainerControls(
                            Globals.NavigateURL(this.TabId, "PPEnroll", "Mid=" + Convert.ToString(this.ModuleId),
                                                "signupid=" + Convert.ToString(this._objEventSignups.SignupID),
                                                "status=enrolled"), "?");
                    }
                    if (returnURL.IndexOf("://") + 1 == 0)
                    {
                        returnURL = Globals.AddHTTP(Globals.GetDomainName(this.Request)) + returnURL;
                    }
                    var cancelURL = "";
                    if (socialGroupId > 0)
                    {
                        cancelURL = objEventInfoHelper.AddSkinContainerControls(
                            Globals.NavigateURL(this.TabId, "PPEnroll", "Mid=" + Convert.ToString(this.ModuleId),
                                                "signupid=" + Convert.ToString(this._objEventSignups.SignupID),
                                                "status=cancelled", "groupid=" + socialGroupId), "?");
                    }
                    else
                    {
                        cancelURL = objEventInfoHelper.AddSkinContainerControls(
                            Globals.NavigateURL(this.TabId, "PPEnroll", "Mid=" + Convert.ToString(this.ModuleId),
                                                "signupid=" + Convert.ToString(this._objEventSignups.SignupID),
                                                "status=cancelled"), "?");
                    }
                    if (cancelURL.IndexOf("://") + 1 == 0)
                    {
                        cancelURL = Globals.AddHTTP(Globals.GetDomainName(this.Request)) + cancelURL;
                    }
                    var strPayPalURL = "";
                    strPayPalURL = ppurl + Globals.HTTPPOSTEncode(objEvent.PayPalAccount);
                    strPayPalURL = strPayPalURL + "&item_name=" +
                                   Globals.HTTPPOSTEncode(objEvent.ModuleTitle + " - " + this.lblEventName.Text +
                                                          " ( " + this.lblFee.Text + " " + this.lblFeeCurrency.Text +
                                                          " )");
                    strPayPalURL = strPayPalURL + "&item_number=" +
                                   Globals.HTTPPOSTEncode(Convert.ToString(this._objEventSignups.SignupID));
                    strPayPalURL = strPayPalURL + "&quantity=" +
                                   Globals.HTTPPOSTEncode(Convert.ToString(this._objEventSignups.NoEnrolees));
                    strPayPalURL = strPayPalURL + "&custom=" +
                                   Globals.HTTPPOSTEncode(
                        Convert.ToDateTime(this.lblStartDate.Text).ToShortDateString());

                    // Make sure currency is in correct format
                    var dblFee    = double.Parse(this.lblFee.Text);
                    var uiculture = Thread.CurrentThread.CurrentCulture;
                    Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
                    strPayPalURL = strPayPalURL + "&amount=" +
                                   Globals.HTTPPOSTEncode(Strings.Format(dblFee, "#,##0.00"));
                    Thread.CurrentThread.CurrentCulture = uiculture;

                    strPayPalURL = strPayPalURL + "&currency_code=" +
                                   Globals.HTTPPOSTEncode(this.lblTotalCurrency.Text);
                    strPayPalURL = strPayPalURL + "&return=" + returnURL;
                    strPayPalURL = strPayPalURL + "&cancel_return=" + cancelURL;
                    strPayPalURL = strPayPalURL + "&notify_url=" +
                                   Globals.HTTPPOSTEncode(Globals.AddHTTP(Globals.GetDomainName(this.Request)) +
                                                          "/DesktopModules/Events/EventIPN.aspx");
                    strPayPalURL = strPayPalURL + "&undefined_quantity=&no_note=1&no_shipping=1";
                    //strPayPalURL = strPayPalURL & "&undefined_quantity=&no_note=1&no_shipping=1&rm=2"

                    // redirect to PayPal
                    this.Response.Redirect(strPayPalURL, true);
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Beispiel #8
0
        /// <summary>
        /// Page_Load runs when the control is loaded.
        /// </summary>
        /// <history>
        ///     [cnurse]	5/10/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        protected void Page_Load(Object sender, EventArgs e)
        {
            try
            {
                // ensure portal signup is allowed
                if ((PortalSettings.ActiveTab.ParentId != PortalSettings.SuperTabId || UserInfo.IsSuperUser == false) && Convert.ToString(Globals.HostSettings["DemoSignup"]) != "Y")
                {
                    Response.Redirect(Globals.NavigateURL("Access Denied"), true);
                }

                if (!Page.IsPostBack)
                {
                    string strFolder = Globals.HostMapPath;
                    if (Directory.Exists(strFolder))
                    {
                        // admin.template and a portal template are required at minimum
                        string[] fileEntries = Directory.GetFiles(strFolder, "*.template");
                        lblMessage.Text   = Localization.GetString("AdminMissing", this.LocalResourceFile);
                        cmdUpdate.Enabled = false;

                        for (int i = 0; i < fileEntries.Length; i++)
                        {
                            string strFileName = fileEntries[i];
                            if (Path.GetFileNameWithoutExtension(strFileName) == "admin")
                            {
                                lblMessage.Text   = "";
                                cmdUpdate.Enabled = true;
                            }
                            else
                            {
                                cboTemplate.Items.Add(Path.GetFileNameWithoutExtension(strFileName));
                            }
                        }

                        if (cboTemplate.Items.Count == 0)
                        {
                            lblMessage.Text   = Localization.GetString("PortalMissing", this.LocalResourceFile);
                            cmdUpdate.Enabled = false;
                        }
                        cboTemplate.Items.Insert(0, new ListItem(Localization.GetString("None_Specified"), "-1"));
                        cboTemplate.SelectedIndex = 0;
                    }

                    if (PortalSettings.ActiveTab.ParentId == PortalSettings.SuperTabId)
                    {
                        rowType.Visible       = true;
                        optType.SelectedValue = "P";
                    }
                    else
                    {
                        rowType.Visible = false;
                        string strMessage = string.Format(Localization.GetString("DemoMessage", this.LocalResourceFile), Convert.ToString((Convert.ToString(Globals.HostSettings["DemoPeriod"]) != "") ? (" for " + Convert.ToString(Globals.HostSettings["DemoPeriod"]) + " days") : ""), Globals.GetDomainName(Request));
                        lblInstructions.Text        = strMessage;
                        btnCustomizeHomeDir.Visible = false;
                    }

                    txtHomeDirectory.Text    = "Portals/[PortalID]";
                    txtHomeDirectory.Enabled = false;
                }
            }
            catch (Exception exc)  //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Beispiel #9
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);
                }
            }
        }
Beispiel #10
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Page_Load runs when the control is loaded
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///     [cnurse]	9/10/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        /// -----------------------------------------------------------------------------
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            jQuery.RequestDnnPluginsRegistration();

            cboBillingFrequency.SelectedIndexChanged += OnBillingFrequencyIndexChanged;
            cboTrialFrequency.SelectedIndexChanged   += OnTrialFrequencyIndexChanged;
            cmdDelete.Click         += OnDeleteClick;
            cmdManage.Click         += OnManageClick;
            cmdUpdate.Click         += OnUpdateClick;
            txtRSVPCode.TextChanged += OnRsvpCodeChanged;

            try
            {
                if ((Request.QueryString["RoleID"] != null))
                {
                    _roleID = Int32.Parse(Request.QueryString["RoleID"]);
                }
                var objPortalController = new PortalController();
                var objPortalInfo       = objPortalController.GetPortal(PortalSettings.PortalId);
                if ((objPortalInfo == null || string.IsNullOrEmpty(objPortalInfo.ProcessorUserId)))
                {
                    //Warn users about fee based roles if we have a Processor Id
                    lblProcessorWarning.Visible = true;
                }
                else
                {
                    divServiceFee.Visible    = true;
                    divBillingPeriod.Visible = true;
                    divTrialFee.Visible      = true;
                    divTrialPeriod.Visible   = true;
                }
                if (Page.IsPostBack == false)
                {
                    cmdCancel.NavigateUrl = Globals.NavigateURL();

                    var objUser = new RoleController();

                    var ctlList        = new ListController();
                    var colFrequencies = ctlList.GetListEntryInfoItems("Frequency", "");

                    cboBillingFrequency.DataSource = colFrequencies;
                    cboBillingFrequency.DataBind();
                    cboBillingFrequency.Items.FindByValue("N").Selected = true;

                    cboTrialFrequency.DataSource = colFrequencies;
                    cboTrialFrequency.DataBind();
                    cboTrialFrequency.Items.FindByValue("N").Selected = true;

                    BindGroups();

                    ctlIcon.FileFilter = Globals.glbImageFileTypes;
                    if (_roleID != -1)
                    {
                        lblRoleName.Visible = true;
                        txtRoleName.Visible = false;
                        valRoleName.Enabled = false;

                        var objRoleInfo = objUser.GetRole(_roleID, PortalSettings.PortalId);
                        if (objRoleInfo != null)
                        {
                            lblRoleName.Text    = objRoleInfo.RoleName;
                            txtDescription.Text = objRoleInfo.Description;
                            if (cboRoleGroups.Items.FindByValue(objRoleInfo.RoleGroupID.ToString()) != null)
                            {
                                cboRoleGroups.ClearSelection();
                                cboRoleGroups.Items.FindByValue(objRoleInfo.RoleGroupID.ToString()).Selected = true;
                            }
                            if (objRoleInfo.BillingFrequency != "N")
                            {
                                txtServiceFee.Text    = objRoleInfo.ServiceFee.ToString("N2", CultureInfo.CurrentCulture);
                                txtBillingPeriod.Text = objRoleInfo.BillingPeriod.ToString();
                                if (cboBillingFrequency.Items.FindByValue(objRoleInfo.BillingFrequency) != null)
                                {
                                    cboBillingFrequency.ClearSelection();
                                    cboBillingFrequency.Items.FindByValue(objRoleInfo.BillingFrequency).Selected = true;
                                }
                            }
                            if (objRoleInfo.TrialFrequency != "N")
                            {
                                txtTrialFee.Text    = objRoleInfo.TrialFee.ToString("N2", CultureInfo.CurrentCulture);
                                txtTrialPeriod.Text = objRoleInfo.TrialPeriod.ToString();
                                if (cboTrialFrequency.Items.FindByValue(objRoleInfo.TrialFrequency) != null)
                                {
                                    cboTrialFrequency.ClearSelection();
                                    cboTrialFrequency.Items.FindByValue(objRoleInfo.TrialFrequency).Selected = true;
                                }
                            }
                            chkIsPublic.Checked       = objRoleInfo.IsPublic;
                            chkAutoAssignment.Checked = objRoleInfo.AutoAssignment;
                            txtRSVPCode.Text          = objRoleInfo.RSVPCode;
                            if (!String.IsNullOrEmpty(txtRSVPCode.Text))
                            {
                                lblRSVPLink.Text = Globals.AddHTTP(Globals.GetDomainName(Request)) + "/" + Globals.glbDefaultPage + "?rsvp=" + txtRSVPCode.Text + "&portalid=" + PortalId;
                            }
                            ctlIcon.Url = objRoleInfo.IconFile;

                            UpdateFeeTextBoxes();
                        }
                        else //security violation attempt to access item not related to this Module
                        {
                            Response.Redirect(Globals.NavigateURL("Security Roles"));
                        }
                        if (_roleID == PortalSettings.AdministratorRoleId || _roleID == PortalSettings.RegisteredRoleId)
                        {
                            cmdDelete.Visible = false;
                            ActivateControls(false);
                        }
                        if (_roleID == PortalSettings.RegisteredRoleId)
                        {
                            cmdManage.Visible = false;
                        }
                    }
                    else
                    {
                        cmdDelete.Visible   = false;
                        cmdManage.Visible   = false;
                        lblRoleName.Visible = false;
                        txtRoleName.Visible = true;

                        //select default role group id
                        if (Request.QueryString["RoleGroupID"] != null)
                        {
                            var roleGroupID = Request.QueryString["RoleGroupID"];
                            if (cboRoleGroups.Items.FindByValue(roleGroupID) != null)
                            {
                                cboRoleGroups.ClearSelection();
                                cboRoleGroups.Items.FindByValue(roleGroupID).Selected = true;
                            }
                        }
                    }
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Beispiel #11
0
        protected void PurchaseBtn_Click(Object sender, EventArgs e)
        {
            try
            {
                string strPaymentProcessor  = "";
                string strProcessorUserId   = "";
                string strProcessorPassword = "";

                if (Page.IsValid)
                {
                    PortalController objPortalController = new PortalController();
                    PortalInfo       objPortalInfo       = objPortalController.GetPortal(PortalSettings.PortalId);
                    if (objPortalInfo != null)
                    {
                        strPaymentProcessor  = objPortalInfo.PaymentProcessor;
                        strProcessorUserId   = objPortalInfo.ProcessorUserId;
                        strProcessorPassword = objPortalInfo.ProcessorPassword;
                    }

                    if (strPaymentProcessor == "PayPal")
                    {
                        // build secure PayPal URL
                        string strPayPalURL = "";
                        strPayPalURL = "https://www.paypal.com/xclick/business=" + Globals.HTTPPOSTEncode(strProcessorUserId);
                        strPayPalURL = strPayPalURL + "&item_name=" + Globals.HTTPPOSTEncode(PortalSettings.PortalName + " - " + lblDescription.Text + " ( " + txtUnits.Text + " units @ " + lblFee.Text + " " + lblFeeCurrency.Text + " per " + lblFrequency.Text + " )");
                        strPayPalURL = strPayPalURL + "&item_number=" + Globals.HTTPPOSTEncode(Convert.ToString(RoleID));
                        strPayPalURL = strPayPalURL + "&quantity=1";
                        strPayPalURL = strPayPalURL + "&custom=" + Globals.HTTPPOSTEncode(UserInfo.UserID.ToString());
                        strPayPalURL = strPayPalURL + "&amount=" + Globals.HTTPPOSTEncode(lblTotal.Text);
                        strPayPalURL = strPayPalURL + "&currency_code=" + Globals.HTTPPOSTEncode(lblTotalCurrency.Text);
                        strPayPalURL = strPayPalURL + "&return=" + Globals.HTTPPOSTEncode("http://" + Globals.GetDomainName(Request));
                        strPayPalURL = strPayPalURL + "&cancel_return=" + Globals.HTTPPOSTEncode("http://" + Globals.GetDomainName(Request));
                        strPayPalURL = strPayPalURL + "&notify_url=" + Globals.HTTPPOSTEncode("http://" + Globals.GetDomainName(Request) + "/admin/Sales/PayPalIPN.aspx");
                        strPayPalURL = strPayPalURL + "&undefined_quantity=&no_note=1&no_shipping=1";

                        // redirect to PayPal
                        Response.Redirect(strPayPalURL, true);
                    }
                }
            }
            catch (Exception exc)  //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Beispiel #12
0
        /// <summary>
        /// cmdGoogle_Click runs when the Submit to Google Linkbutton is clicked.
        /// It submits the site's Description, DomainName and Keywords to the Google Site.
        /// </summary>
        /// <history>
        ///     [cnurse]	9/9/2004	Modified
        /// </history>
        protected void cmdGoogle_Click(object sender, EventArgs e)
        {
            try
            {
                string strURL      = "";
                string strComments = "";

                PortalController objPortalController = new PortalController();
                PortalInfo       objPortal           = objPortalController.GetPortal(intPortalId);
                if (objPortal != null)
                {
                    strComments += objPortal.PortalName;
                    if (!String.IsNullOrEmpty(objPortal.Description))
                    {
                        strComments += " " + objPortal.Description;
                    }
                    if (!String.IsNullOrEmpty(objPortal.KeyWords))
                    {
                        strComments += " " + objPortal.KeyWords;
                    }
                }

                strURL += "http://www.google.com/addurl?q=" + Globals.HTTPPOSTEncode(Globals.AddHTTP(Globals.GetDomainName(Request)));
                strURL += "&dq=" + Globals.HTTPPOSTEncode(strComments);
                strURL += "&submit=Add+URL";

                UrlUtils.OpenNewWindow(strURL);
            }
            catch (Exception exc)  //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Beispiel #13
0
        public void OnBeginRequest(object s, EventArgs e)
        {
            HttpApplication   app           = (HttpApplication)s;
            HttpServerUtility Server        = app.Server;
            HttpRequest       Request       = app.Request;
            HttpResponse      Response      = app.Response;
            string            requestedPath = app.Request.Url.AbsoluteUri;

            // URL validation
            // check for ".." escape characters commonly used by hackers to traverse the folder tree on the server
            // the application should always use the exact relative location of the resource it is requesting
            string strURL             = Request.Url.AbsolutePath;
            string strDoubleDecodeURL = Server.UrlDecode(Server.UrlDecode(Request.RawUrl));

            if (strURL.IndexOf("..") != -1 || strDoubleDecodeURL.IndexOf("..") != -1)
            {
                throw (new HttpException(404, "Not Found"));
            }

            //fix for ASP.NET canonicalization issues http://support.microsoft.com/?kbid=887459
            if (Request.Path.IndexOf('\u005C') >= 0 || Path.GetFullPath(Request.PhysicalPath) != Request.PhysicalPath)
            {
                throw (new HttpException(404, "Not Found"));
            }

            //check if we are upgrading/installing
            if (Request.Url.LocalPath.ToLower().EndsWith("install.aspx"))
            {
                return;
            }

            // save original url in context
            app.Context.Items.Add("UrlRewrite:OriginalUrl", app.Request.Url.AbsoluteUri);

            // Friendly URLs are exposed externally using the following format
            // http://www.domain.com/tabid/###/mid/###/ctl/xxx/default.aspx
            // and processed internally using the following format
            // http://www.domain.com/default.aspx?tabid=###&mid=###&ctl=xxx
            // The system for accomplishing this is based on an extensible Regex rules definition stored in /SiteUrls.config
            string sendTo = "";

            // save and remove the querystring as it gets added back on later
            // path parameter specifications will take precedence over querystring parameters
            string strQueryString = "";

            if (!String.IsNullOrEmpty(app.Request.Url.Query))
            {
                strQueryString = Request.QueryString.ToString();
                requestedPath  = requestedPath.Replace(app.Request.Url.Query, "");
            }

            // get url rewriting rules
            RewriterRuleCollection rules = RewriterConfiguration.GetConfig().Rules;

            // iterate through list of rules
            int intMatch = -1;

            for (int intRule = 0; intRule <= rules.Count - 1; intRule++)
            {
                // check for the existence of the LookFor value
                string strLookFor = "^" + RewriterUtils.ResolveUrl(app.Context.Request.ApplicationPath, rules[intRule].LookFor) + "$";
                Regex  objLookFor = new Regex(strLookFor, RegexOptions.IgnoreCase);
                // if there is a match
                if (objLookFor.IsMatch(requestedPath))
                {
                    // create a new URL using the SendTo regex value
                    sendTo = RewriterUtils.ResolveUrl(app.Context.Request.ApplicationPath, objLookFor.Replace(requestedPath, rules[intRule].SendTo));
                    // obtain the RegEx match group which contains the parameters
                    Match  objMatch      = objLookFor.Match(requestedPath);
                    string strParameters = objMatch.Groups[2].Value;
                    // process the parameters
                    if (strParameters.Trim(null).Length > 0)
                    {
                        // split the value into an array based on "/" ( ie. /tabid/##/ )
                        strParameters = strParameters.Replace("\\", "/");
                        string[] arrParameters = strParameters.Split('/');
                        string   strParameterDelimiter;
                        string   strParameterName;
                        string   strParameterValue;
                        // icreate a well formed querystring based on the array of parameters
                        for (int intParameter = 1; intParameter <= arrParameters.Length - 1; intParameter++)
                        {
                            // ignore the page name
                            if (arrParameters[intParameter].ToLower().IndexOf(".aspx") == -1)
                            {
                                // get parameter name
                                strParameterName = arrParameters[intParameter].Trim(null);
                                if (strParameterName.Length > 0)
                                {
                                    // add parameter to SendTo if it does not exist already
                                    if (sendTo.ToLower().IndexOf("?" + strParameterName.ToLower()) == -1 && sendTo.ToLower().IndexOf("&" + strParameterName.ToLower()) == -1)
                                    {
                                        // get parameter delimiter
                                        if (sendTo.IndexOf("?") != -1)
                                        {
                                            strParameterDelimiter = "&";
                                        }
                                        else
                                        {
                                            strParameterDelimiter = "?";
                                        }
                                        sendTo = sendTo + strParameterDelimiter + strParameterName;
                                        // get parameter value
                                        strParameterValue = "";
                                        if (intParameter < (arrParameters.Length - 1))
                                        {
                                            intParameter++;
                                            if (arrParameters[intParameter].Trim() != "")
                                            {
                                                strParameterValue = arrParameters[intParameter].Trim(null);
                                            }
                                        }
                                        // add the parameter value
                                        if (strParameterValue.Length > 0)
                                        {
                                            sendTo = sendTo + "=" + strParameterValue;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    intMatch = intRule;
                    break; // exit as soon as it processes the first match
                }
            }

            // add querystring parameters back to SendTo
            if (!String.IsNullOrEmpty(strQueryString))
            {
                string[] arrParameters = strQueryString.Split('&');
                // iterate through the array of parameters
                for (int intParameter = 0; intParameter <= arrParameters.Length - 1; intParameter++)
                {
                    // get parameter name
                    string strParameterName = arrParameters[intParameter];
                    if (strParameterName.IndexOf("=") != -1)
                    {
                        strParameterName = strParameterName.Substring(0, strParameterName.IndexOf("="));
                    }
                    // check if parameter already exists
                    if (sendTo.ToLower().IndexOf("?" + strParameterName.ToLower()) == -1 && sendTo.ToLower().IndexOf("&" + strParameterName.ToLower()) == -1)
                    {
                        // add parameter to SendTo value
                        if (sendTo.IndexOf("?") != -1)
                        {
                            sendTo = sendTo + "&" + arrParameters[intParameter];
                        }
                        else
                        {
                            sendTo = sendTo + "?" + arrParameters[intParameter];
                        }
                    }
                }
            }

            // if a match was found to the urlrewrite rules
            if (intMatch != -1)
            {
                if (rules[intMatch].SendTo.StartsWith("~"))
                {
                    // rewrite the URL for internal processing
                    RewriterUtils.RewriteUrl(app.Context, sendTo);
                }
                else
                {
                    // it is not possible to rewrite the domain portion of the URL so redirect to the new URL
                    Response.Redirect(sendTo, true);
                }
            }

            // *Note: from this point on we are dealing with a "standard" querystring ( ie. http://www.domain.com/default.aspx?tabid=## )

            int             TabId       = -1;
            int             PortalId    = -1;
            string          DomainName  = null;
            string          PortalAlias = null;
            PortalAliasInfo objPortalAliasInfo;

            // get TabId from querystring ( this is mandatory for maintaining portal context for child portals )
            try
            {
                if (!(Request.QueryString["tabid"] == null))
                {
                    TabId = int.Parse(Request.QueryString["tabid"]);
                }
                // get PortalId from querystring ( this is used for host menu options as well as child portal navigation )
                if (!(Request.QueryString["portalid"] == null))
                {
                    PortalId = int.Parse(Request.QueryString["portalid"]);
                }
            }
            catch (Exception)
            {
                //The tabId or PortalId are incorrectly formatted (potential DOS)
                throw (new HttpException(404, "Not Found"));
            }

            // alias parameter can be used to switch portals
            if (!(Request.QueryString["alias"] == null))
            {
                // check if the alias is valid
                if (PortalSettings.GetPortalAliasInfo(Request.QueryString["alias"]) != null)
                {
                    // check if the domain name contains the alias
                    if (Strings.InStr(1, Request.QueryString["alias"], DomainName, CompareMethod.Text) == 0)
                    {
                        // redirect to the url defined in the alias
                        Response.Redirect(Globals.GetPortalDomainName(Request.QueryString["alias"], Request, true));
                    }
                    else // the alias is the same as the current domain
                    {
                        PortalAlias = Request.QueryString["alias"];
                    }
                }
            }

            // parse the Request URL into a Domain Name token
            DomainName = Globals.GetDomainName(Request);

            // PortalId identifies a portal when set
            if (PortalAlias == null)
            {
                if (PortalId != -1)
                {
                    PortalAlias = PortalSettings.GetPortalByID(PortalId, DomainName);
                }
            }

            // TabId uniquely identifies a Portal
            if (PortalAlias == null)
            {
                if (TabId != -1)
                {
                    // get the alias from the tabid, but only if it is for a tab in that domain
                    PortalAlias = PortalSettings.GetPortalByTab(TabId, DomainName);
                    if (PortalAlias == null || PortalAlias == "")
                    {
                        //if the TabId is not for the correct domain
                        //see if the correct domain can be found and redirect it
                        objPortalAliasInfo = PortalSettings.GetPortalAliasInfo(DomainName);
                        if (objPortalAliasInfo != null)
                        {
                            if (app.Request.Url.AbsoluteUri.ToLower().StartsWith("https://"))
                            {
                                strURL = "https://" + objPortalAliasInfo.HTTPAlias.Replace("*.", "");
                            }
                            else
                            {
                                strURL = "http://" + objPortalAliasInfo.HTTPAlias.Replace("*.", "");
                            }
                            if (strURL.ToLower().IndexOf(DomainName.ToLower()) == -1)
                            {
                                strURL += app.Request.Url.PathAndQuery;
                            }
                            Response.Redirect(strURL, true);
                        }
                    }
                }
            }

            // else use the domain name
            if (PortalAlias == null || PortalAlias == "")
            {
                PortalAlias = DomainName;
            }
            //using the DomainName above will find that alias that is the domainname portion of the Url
            //ie. dotnetnuke.com will be found even if zzz.dotnetnuke.com was entered on the Url
            objPortalAliasInfo = PortalSettings.GetPortalAliasInfo(PortalAlias);
            if (objPortalAliasInfo != null)
            {
                PortalId = objPortalAliasInfo.PortalID;
            }

            // if the portalid is not known
            if (PortalId == -1)
            {
                if (!Request.Url.LocalPath.ToLower().EndsWith(Globals.glbDefaultPage.ToLower()))
                {
                    // allows requests for aspx pages in custom folder locations to be processed
                    return;
                }
                else
                {
                    //the domain name was not found so try using the host portal's first alias
                    if (Convert.ToString(Globals.HostSettings["HostPortalId"]) != "")
                    {
                        PortalId = Convert.ToInt32(Globals.HostSettings["HostPortalId"]);
                        // use the host portal
                        PortalAliasController objPortalAliasController = new PortalAliasController();
                        ArrayList             arrPortalAliases;
                        arrPortalAliases = objPortalAliasController.GetPortalAliasArrayByPortalID(int.Parse(Convert.ToString(Globals.HostSettings["HostPortalId"])));
                        if (arrPortalAliases.Count > 0)
                        {
                            //Get the first Alias
                            objPortalAliasInfo = (PortalAliasInfo)arrPortalAliases[0];
                            if (app.Request.Url.AbsoluteUri.ToLower().StartsWith("https://"))
                            {
                                strURL = "https://" + objPortalAliasInfo.HTTPAlias.Replace("*.", "");
                            }
                            else
                            {
                                strURL = "http://" + objPortalAliasInfo.HTTPAlias.Replace("*.", "");
                            }
                            if (TabId != -1)
                            {
                                strURL += app.Request.Url.Query;
                            }
                            Response.Redirect(strURL, true);
                        }
                    }
                }
            }

            if (PortalId != -1)
            {
                // load the PortalSettings into current context
                PortalSettings _portalSettings = new PortalSettings(TabId, objPortalAliasInfo);
                app.Context.Items.Add("PortalSettings", _portalSettings);
            }
            else
            {
                // alias does not exist in database
                // and all attempts to find another have failed
                //this should only happen if the HostPortal does not have any aliases
                StreamReader objStreamReader;
                objStreamReader = File.OpenText(Server.MapPath("~/404.htm"));
                string strHTML = objStreamReader.ReadToEnd();
                objStreamReader.Close();
                strHTML = strHTML.Replace("[DOMAINNAME]", DomainName);
                Response.Write(strHTML);
                Response.End();
            }
        }
        /// <summary>
        /// cmdGoogle_Click runs when the Submit Page to Google  Button is clicked
        /// </summary>
        /// <history>
        ///     [cnurse]	9/10/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        protected void cmdGoogle_Click(object sender, EventArgs e)
        {
            try
            {
                string strURL      = "";
                string strComments = "";

                strComments += txtTitle.Text;
                if (!String.IsNullOrEmpty(txtDescription.Text))
                {
                    strComments += " " + txtDescription.Text;
                }
                if (!String.IsNullOrEmpty(txtKeyWords.Text))
                {
                    strComments += " " + txtKeyWords.Text;
                }

                strURL += "http://www.google.com/addurl?q=" + Globals.HTTPPOSTEncode(Globals.AddHTTP(Globals.GetDomainName(Request)) + "/" + Globals.glbDefaultPage + "?tabid=" + TabId);
                strURL += "&dq=" + Globals.HTTPPOSTEncode(strComments);
                strURL += "&submit=Add+URL";

                Response.Redirect(strURL, true);
            }
            catch (Exception exc)  //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Beispiel #15
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Page_Load runs when the control is loaded
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///     [cnurse]	9/10/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        /// -----------------------------------------------------------------------------
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            jQuery.RequestDnnPluginsRegistration();

            cboBillingFrequency.SelectedIndexChanged += OnBillingFrequencyIndexChanged;
            cboTrialFrequency.SelectedIndexChanged   += OnTrialFrequencyIndexChanged;
            cmdDelete.Click         += OnDeleteClick;
            cmdManage.Click         += OnManageClick;
            cmdUpdate.Click         += OnUpdateClick;
            txtRSVPCode.TextChanged += OnRsvpCodeChanged;

            try
            {
                if ((Request.QueryString["RoleID"] != null))
                {
                    _roleID = Int32.Parse(Request.QueryString["RoleID"]);
                }
                var objPortalController = new PortalController();
                var objPortalInfo       = objPortalController.GetPortal(PortalSettings.PortalId);
                if ((objPortalInfo == null || string.IsNullOrEmpty(objPortalInfo.ProcessorUserId)))
                {
                    //Warn users about fee based roles if we have a Processor Id
                    lblProcessorWarning.Visible = true;
                }
                else
                {
                    divServiceFee.Visible    = true;
                    divBillingPeriod.Visible = true;
                    divTrialFee.Visible      = true;
                    divTrialPeriod.Visible   = true;
                }
                if (Page.IsPostBack == false)
                {
                    cmdCancel.NavigateUrl = Globals.NavigateURL();

                    var ctlList        = new ListController();
                    var colFrequencies = ctlList.GetListEntryInfoItems("Frequency", "");

                    cboBillingFrequency.DataSource = colFrequencies;
                    cboBillingFrequency.DataBind();
                    cboBillingFrequency.FindItemByValue("N").Selected = true;

                    cboTrialFrequency.DataSource = colFrequencies;
                    cboTrialFrequency.DataBind();
                    cboTrialFrequency.FindItemByValue("N").Selected = true;

                    securityModeList.Items.Clear();
                    foreach (var enumValue in Enum.GetValues(typeof(SecurityMode)))
                    {
                        var enumName = Enum.GetName(typeof(SecurityMode), enumValue);
                        var enumItem = new ListItem(enumName, ((int)enumValue).ToString(CultureInfo.InvariantCulture));

                        securityModeList.AddItem(enumItem.Text, enumItem.Value);
                    }

                    statusList.Items.Clear();
                    foreach (var enumValue in Enum.GetValues(typeof(RoleStatus)))
                    {
                        var enumName = Enum.GetName(typeof(RoleStatus), enumValue);
                        var enumItem = new ListItem(enumName, ((int)enumValue).ToString(CultureInfo.InvariantCulture));

                        statusList.AddItem(enumItem.Text, enumItem.Value);
                    }

                    BindGroups();

                    ctlIcon.FileFilter = Globals.glbImageFileTypes;
                    if (_roleID != -1)
                    {
                        var role = TestableRoleController.Instance.GetRole(PortalSettings.PortalId, r => r.RoleID == _roleID);
                        if (role != null)
                        {
                            lblRoleName.Visible = role.IsSystemRole;
                            txtRoleName.Visible = !role.IsSystemRole;
                            valRoleName.Enabled = !role.IsSystemRole;

                            lblRoleName.Text = role.RoleName;
                            txtRoleName.Text = role.RoleName;

                            txtDescription.Text = role.Description;
                            if (cboRoleGroups.FindItemByValue(role.RoleGroupID.ToString(CultureInfo.InvariantCulture)) != null)
                            {
                                cboRoleGroups.ClearSelection();
                                cboRoleGroups.FindItemByValue(role.RoleGroupID.ToString(CultureInfo.InvariantCulture)).Selected = true;
                            }
                            if (!String.IsNullOrEmpty(role.BillingFrequency))
                            {
                                if (role.ServiceFee > 0)
                                {
                                    txtServiceFee.Text    = role.ServiceFee.ToString("N2", CultureInfo.CurrentCulture);
                                    txtBillingPeriod.Text = role.BillingPeriod.ToString(CultureInfo.InvariantCulture);
                                    if (cboBillingFrequency.FindItemByValue(role.BillingFrequency) != null)
                                    {
                                        cboBillingFrequency.ClearSelection();
                                        cboBillingFrequency.FindItemByValue(role.BillingFrequency).Selected = true;
                                    }
                                }
                            }
                            if (!String.IsNullOrEmpty(role.TrialFrequency))
                            {
                                if (role.TrialFee > 0)
                                {
                                    txtTrialFee.Text    = role.TrialFee.ToString("N2", CultureInfo.CurrentCulture);
                                    txtTrialPeriod.Text = role.TrialPeriod.ToString(CultureInfo.InvariantCulture);
                                    if (cboTrialFrequency.FindItemByValue(role.TrialFrequency) != null)
                                    {
                                        cboTrialFrequency.ClearSelection();
                                        cboTrialFrequency.FindItemByValue(role.TrialFrequency).Selected = true;
                                    }
                                }
                            }

                            if (securityModeList.FindItemByValue(Convert.ToString((int)role.SecurityMode)) != null)
                            {
                                securityModeList.ClearSelection();
                                securityModeList.FindItemByValue(Convert.ToString((int)role.SecurityMode)).Selected = true;
                            }

                            if (statusList.FindItemByValue(Convert.ToString((int)role.Status)) != null)
                            {
                                statusList.ClearSelection();
                                statusList.FindItemByValue(Convert.ToString((int)role.Status)).Selected = true;
                            }

                            chkIsPublic.Checked       = role.IsPublic;
                            chkAutoAssignment.Checked = role.AutoAssignment;
                            txtRSVPCode.Text          = role.RSVPCode;
                            if (!String.IsNullOrEmpty(txtRSVPCode.Text))
                            {
                                lblRSVPLink.Text = Globals.AddHTTP(Globals.GetDomainName(Request)) + "/" + Globals.glbDefaultPage + "?rsvp=" + txtRSVPCode.Text + "&portalid=" + PortalId;
                            }
                            ctlIcon.Url = role.IconFile;

                            UpdateFeeTextBoxes();
                            cmdManage.Visible = role.Status == RoleStatus.Approved;
                        }
                        else //security violation attempt to access item not related to this Module
                        {
                            Response.Redirect(Globals.NavigateURL("Security Roles"));
                        }

                        if (role.IsSystemRole) //disable controls if it's a system role
                        {
                            UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("SystemRoleWarning.Text", LocalResourceFile), ModuleMessage.ModuleMessageType.BlueInfo);
                            ActivateControls(false);
                        }

                        if (_roleID == PortalSettings.RegisteredRoleId)
                        {
                            cmdManage.Visible = false;
                        }
                    }
                    else
                    {
                        cmdDelete.Visible   = false;
                        cmdManage.Visible   = false;
                        lblRoleName.Visible = false;
                        txtRoleName.Visible = true;

                        statusList.SelectedIndex = 1;

                        //select default role group id
                        if (Request.QueryString["RoleGroupID"] != null)
                        {
                            var roleGroupID = Request.QueryString["RoleGroupID"];
                            if (cboRoleGroups.FindItemByValue(roleGroupID) != null)
                            {
                                cboRoleGroups.ClearSelection();
                                cboRoleGroups.FindItemByValue(roleGroupID).Selected = true;
                            }
                        }
                    }
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Beispiel #16
0
 protected void OnRsvpCodeChanged(object sender, EventArgs e)
 {
     lblRSVPLink.Text = Globals.AddHTTP(Globals.GetDomainName(Request)) + @"/" + Globals.glbDefaultPage + @"?rsvp=" + txtRSVPCode.Text + @"&portalid=" + PortalId;
 }
        protected void Page_Load(Object sender, EventArgs e)
        {
            try
            {
                UserInfo objUserInfo = null;
                int      intUserID   = -1;
                if (Request.IsAuthenticated)
                {
                    objUserInfo = UserController.GetCurrentUserInfo();
                    if (objUserInfo != null)
                    {
                        intUserID = objUserInfo.UserID;
                    }
                }

                int intRoleId = -1;
                if (Request.QueryString["roleid"] != null)
                {
                    intRoleId = int.Parse(Request.QueryString["roleid"]);
                }

                string           strProcessorUserId  = "";
                PortalController objPortalController = new PortalController();
                PortalInfo       objPortalInfo       = objPortalController.GetPortal(PortalSettings.PortalId);
                if (objPortalInfo != null)
                {
                    strProcessorUserId = objPortalInfo.ProcessorUserId;
                }

                Hashtable settings = PortalSettings.GetSiteSettings(PortalSettings.PortalId);
                string    strPayPalURL;

                if (intUserID != -1 && intRoleId != -1 && !String.IsNullOrEmpty(strProcessorUserId))
                {
                    strPayPalURL = "https://www.paypal.com/cgi-bin/webscr?";

                    if (Request.QueryString["cancel"] != null)
                    {
                        // build the cancellation PayPal URL
                        strPayPalURL += "cmd=_subscr-find&alias=" + Globals.HTTPPOSTEncode(strProcessorUserId);
                    }
                    else
                    {
                        strPayPalURL += "cmd=_ext-enter";

                        RoleController objRoles = new RoleController();

                        RoleInfo objRole = objRoles.GetRole(intRoleId, PortalSettings.PortalId);
                        if (objRole.RoleID != -1)
                        {
                            int intTrialPeriod = 1;
                            if (objRole.TrialPeriod != 0)
                            {
                                intTrialPeriod = objRole.TrialPeriod;
                            }
                            int intBillingPeriod = 1;
                            if (objRole.BillingPeriod != 0)
                            {
                                intBillingPeriod = objRole.BillingPeriod;
                            }
                            // explicitely format numbers using en-US so numbers are correctly built
                            CultureInfo enFormat   = new CultureInfo("en-US");
                            string      strService = string.Format(enFormat.NumberFormat, "{0:#####0.00}", objRole.ServiceFee);
                            string      strTrial   = string.Format(enFormat.NumberFormat, "{0:#####0.00}", objRole.TrialFee);

                            if (objRole.BillingFrequency == "O" || objRole.TrialFrequency == "O")  //one-time payment
                            {
                                // build the payment PayPal URL
                                strPayPalURL += "&redirect_cmd=_xclick&business=" + Globals.HTTPPOSTEncode(strProcessorUserId);
                                strPayPalURL += "&item_name=" + Globals.HTTPPOSTEncode(PortalSettings.PortalName + " - " + objRole.RoleName + " ( " + string.Format("{0:0.00}", objRole.ServiceFee) + " " + PortalSettings.Currency + " )");
                                strPayPalURL += "&item_number=" + Globals.HTTPPOSTEncode(intRoleId.ToString());
                                strPayPalURL += "&no_shipping=1&no_note=1";
                                strPayPalURL += "&quantity=1";
                                strPayPalURL += "&amount=" + Globals.HTTPPOSTEncode(strService);
                                strPayPalURL += "&currency_code=" + Globals.HTTPPOSTEncode(PortalSettings.Currency);
                            }
                            else //recurring payments
                            {
                                // build the subscription PayPal URL
                                strPayPalURL += "&redirect_cmd=_xclick-subscriptions&business=" + Globals.HTTPPOSTEncode(strProcessorUserId);
                                strPayPalURL += "&item_name=" + Globals.HTTPPOSTEncode(PortalSettings.PortalName + " - " + objRole.RoleName + " ( " + string.Format("{0:0.00}", objRole.ServiceFee) + " " + PortalSettings.Currency + " every " + intBillingPeriod.ToString() + " " + GetBillingFrequencyCode(objRole.BillingFrequency) + " )");
                                strPayPalURL += "&item_number=" + Globals.HTTPPOSTEncode(intRoleId.ToString());
                                strPayPalURL += "&no_shipping=1&no_note=1";
                                if (objRole.TrialFrequency != "N")
                                {
                                    strPayPalURL += "&a1=" + Globals.HTTPPOSTEncode(strTrial);
                                    strPayPalURL += "&p1=" + Globals.HTTPPOSTEncode(intTrialPeriod.ToString());
                                    strPayPalURL += "&t1=" + Globals.HTTPPOSTEncode(objRole.TrialFrequency);
                                }
                                strPayPalURL += "&a3=" + Globals.HTTPPOSTEncode(strService);
                                strPayPalURL += "&p3=" + Globals.HTTPPOSTEncode(intBillingPeriod.ToString());
                                strPayPalURL += "&t3=" + Globals.HTTPPOSTEncode(objRole.BillingFrequency);
                                strPayPalURL += "&src=1";
                                strPayPalURL += "&currency_code=" + Globals.HTTPPOSTEncode(PortalSettings.Currency);
                            }
                        }

                        ListController ctlList = new ListController();

                        strPayPalURL += "&custom=" + Globals.HTTPPOSTEncode(intUserID.ToString());
                        strPayPalURL += "&first_name=" + Globals.HTTPPOSTEncode(objUserInfo.Profile.FirstName);
                        strPayPalURL += "&last_name=" + Globals.HTTPPOSTEncode(objUserInfo.Profile.LastName);
                        try
                        {
                            if (objUserInfo.Profile.Country == "United States")
                            {
                                ListEntryInfo colList = ctlList.GetListEntryInfo("Region", objUserInfo.Profile.Region, "Country:US");
                                strPayPalURL += "&address1=" + Globals.HTTPPOSTEncode(Convert.ToString(!String.IsNullOrEmpty(objUserInfo.Profile.Unit) ? objUserInfo.Profile.Unit + " " : "") + objUserInfo.Profile.Street);
                                strPayPalURL += "&city=" + Globals.HTTPPOSTEncode(objUserInfo.Profile.City);
                                strPayPalURL += "&state=" + Globals.HTTPPOSTEncode(colList.Value);
                                strPayPalURL += "&zip=" + Globals.HTTPPOSTEncode(objUserInfo.Profile.PostalCode);
                            }
                        }
                        catch
                        {
                            // issue getting user address
                        }

                        // Return URL
                        if (Convert.ToString(settings["paypalsubscriptionreturn"]) != "")
                        {
                            strPayPalURL += "&return=" + Globals.HTTPPOSTEncode(Convert.ToString(settings["paypalsubscriptionreturn"]));
                        }
                        else
                        {
                            strPayPalURL += "&return=" + Globals.HTTPPOSTEncode(Globals.AddHTTP(Globals.GetDomainName(Request)));
                        }

                        // Cancellation URL
                        if (Convert.ToString(settings["paypalsubscriptioncancelreturn"]) != "")
                        {
                            strPayPalURL += "&cancel_return=" + Globals.HTTPPOSTEncode(Convert.ToString(settings["paypalsubscriptioncancelreturn"]));
                        }
                        else
                        {
                            strPayPalURL += "&cancel_return=" + Globals.HTTPPOSTEncode(Globals.AddHTTP(Globals.GetDomainName(Request)));
                        }

                        // Instant Payment Notification URL
                        if (Convert.ToString(settings["paypalsubscriptionnotifyurl"]) != "")
                        {
                            strPayPalURL += "&notify_url=" + Globals.HTTPPOSTEncode(Convert.ToString(settings["paypalsubscriptionnotifyurl"]));
                        }
                        else
                        {
                            strPayPalURL += "&notify_url=" + Globals.HTTPPOSTEncode(Globals.AddHTTP(Globals.GetDomainName(Request)) + "/admin/Sales/PayPalIPN.aspx");
                        }

                        strPayPalURL += "&sra=1"; // reattempt on failure
                    }

                    // redirect to PayPal
                    Response.Redirect(strPayPalURL, true);
                }
                else
                {
                    // Cancellation URL
                    if (Convert.ToString(settings["paypalsubscriptioncancelreturn"]) != "")
                    {
                        strPayPalURL = Convert.ToString(settings["paypalsubscriptioncancelreturn"]);
                    }
                    else
                    {
                        strPayPalURL = Globals.AddHTTP(Globals.GetDomainName(Request));
                    }

                    // redirect to PayPal
                    Response.Redirect(strPayPalURL, true);
                }
            }
            catch (Exception exc)  //Page failed to load
            {
                Exceptions.ProcessPageLoadException(exc);
            }
        }