protected void Page_Load(object sender, EventArgs e) { if (Session != null) { // Store essential session information temporarily string culture = Session["culture"] as string ?? "nl-NL"; Session["culture"] = null; // Restore the essential session information Session["culture"] = culture; } if (!Request.IsAuthenticated) { if (Request.Params["pid"] != null || Request.Params["tid"] != null) { Response.Redirect(string.Format("~/Account/Login.aspx?tid={0}&pid={1}", Request.Params["tid"], Request.Params["pid"]), false); } else { Response.Redirect("~/Default.aspx", false); } } ShowLoggedOnView(); Literal name = HeadLoginView.FindControl("HeadLoginName") as Literal; if (name != null) { if (Session["userid"] != null) { long userId = Util.UserId; using (Database db = new MySqlDatabase()) { ClientInfo ci = db.GetClientInfo(userId); name.Text = string.Format(" {0}", ci.FirstName);// ci.GetFullName()); } } } if (!IsPostBack) { BasePage obj = new BasePage(); obj.IncludePage(FooterLiteral, Resources.Resource.FooterSection); } }
protected void AuthenticateUser() { string userID = Request.QueryString["userId"]; string key = Request.QueryString["key"].Replace(" ", "+"); string pwd = EncryptionClass.Decrypt(key); string email = string.Empty; using (Database db = new MySqlDatabase()) { UserInfo ui = db.GetUser(Convert.ToInt64(userID)); email = ui.Email; ClientInfo ci = db.GetClientInfo(Convert.ToInt64(userID)); Session["UserName"] = ci.GetFullName(); } string username = Membership.GetUserNameByEmail(email); FormsAuthentication.SetAuthCookie(username, false); FormsAuthenticationTicket ticket1 = new FormsAuthenticationTicket( 1, // version username, // get username from the form DateTime.Now, // issue time is now DateTime.Now.AddMinutes(10), // expires in 10 minutes false, // cookie is not persistent "" // role assignment is stored // in userData ); HttpCookie cookie1 = new HttpCookie( FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket1)); Response.Cookies.Add(cookie1); Membership.ValidateUser(username, pwd); // 4. Do the redirect. String returnUrl1; // the login is successful returnUrl1 = "FirstLogon.aspx"; Response.Redirect(returnUrl1); }
protected void Page_Load(object sender, EventArgs e) { if (!User.Identity.IsAuthenticated) Response.Redirect("~/"); long userid = Util.UserId; if (!IsPostBack) { Country.Items.Clear(); string[] countries = Util.GetCountries(); foreach (string country in countries) Country.Items.Add(new ListItem(country)); Country.SelectedIndex = Country.Items.IndexOf(Country.Items.FindByText("Netherlands")); if (userid > 0) { using (Database db = new MySqlDatabase()) { ClientInfo ci = db.GetClientInfo(userid); if (ci != null && ci.ClientId > 0) { LastName.Text = ci.LastName; FirstName.Text = ci.FirstName; AddressLine1.Text = ci.AddressLine1; AddressLine2.Text = ci.AddressLine2; Zipcode.Text = ci.ZipCode; State.Text = ci.State; City.Text = ci.City; Country.SelectedIndex = Country.Items.IndexOf(Country.Items.FindByText(ci.Country)); Telephone.Text = ci.Telephone; Cellular.Text = ci.Cellular; AccountOwner.Text = ci.AccountOwner; TwitterID.Text = ci.TwitterId; FacebookID.Text = ci.FacebookId; OwnerKind.SelectedIndex = OwnerKind.Items.IndexOf(OwnerKind.Items.FindByText(ci.OwnerKind)); CreditCardNr.Text = ci.CreditCardNr; CVVNr.Text = ci.CreditCardCvv; EmailForReceipt.Text = ci.EmailReceipt; Referer.Text = ci.Referer; } } } } }
protected void Page_Load(object sender, EventArgs e) { IncludePage(ActivateInc, Resources.Resource.incActivate); IncludePage(ProtectInc, Resources.Resource.incProtect); IncludePage(RhosMovementInc, Resources.Resource.incRhosMovement); if (!IsPostBack) { if (Request.Params["uid"] != null) { string uid = Request.Params["uid"]; using (Database db = new MySqlDatabase()) { // Check the UID against the database long userId = db.GetUserIdByUid(uid); db.ActivateUser(userId); } } } }
protected void Page_Load(object sender, EventArgs e) { //audioFilePath = Convert.ToString(Session["sound"]); //lblSound.Text = "Sound : " + Convert.ToString(Session["soundName"]); string MusicFile = string.Empty; using (Database db = new MySqlDatabase()) { MusicFile = db.GetMusicPathByRegID(Convert.ToInt32(Request.QueryString["play"])); //MusicFile = db.GetMusicPathByRegID(Convert.ToInt32(Session["songId"])); if (MusicFile.Contains("/trackprotect_repos/repository")) { QTPlayer1.MOVFile = ConfigurationManager.AppSettings["SiteNavigationLink"] + MusicFile.Substring(MusicFile.IndexOf("/trackprotect_repos/repository")).Replace("\\", "/"); } else { QTPlayer1.MOVFile = ConfigurationManager.AppSettings["SiteNavigationLink"] + "/trackprotect_repos/repository" + MusicFile.Replace("\\", "/"); } } }
public static ConfirmationRequestResult RequestConfirmation( string email, string firstname, string lastname, string guid, long requestingUserId, int relationType, string language = "") { long requestedUserId = 0; ClientInfo requestingClientInfo = null; ClientInfo requestedClientInfo = null; using (Database db = new MySqlDatabase()) { requestedUserId = db.GetUserIdByEmail(email); requestingClientInfo = db.GetClientInfo(requestingUserId); requestedClientInfo = db.GetClientInfo(requestedUserId); if (db.RelationExists(requestingUserId, requestedUserId, relationType)) return ConfirmationRequestResult.Exists; if (db.ConfirmationExists(requestingUserId, email)) return ConfirmationRequestResult.AlreadyRequested; db.RequestConfirmation(guid, requestingUserId, requestedUserId, email, relationType); } string fullName = requestedClientInfo.GetFullName(); if (string.IsNullOrEmpty(fullName) || fullName == " ") fullName = firstname; if (!string.IsNullOrEmpty(fullName)) fullName += " "; fullName += lastname; string templatePath = string.Empty; string subject = string.Empty; if (relationType == 1) { if (!string.IsNullOrEmpty(language)) { if (language.ToLower().Contains("en")) { templatePath = "~/Templates/confirmmgmt.tpl"; subject = "invites you as a managed musician"; } else if (language.ToLower().Contains("du")) { templatePath = "~/Templates/nl/confirmmgmt.tpl"; subject = "nodigt je uit als managed muzikant"; } } else { templatePath = Resources.Resource.ConfirmMgmtTemplate; subject = Resources.Resource.InviteManagedArtistSubject; } } else { if (!string.IsNullOrEmpty(language)) { if (language.ToLower().Contains("en")) { templatePath = "~/Templates/confirm.tpl"; subject = "invites you as a co-creator"; } else if (language.ToLower().Contains("du")) { templatePath = "~/Templates/nl/confirm.tpl"; subject = "heeft je als co-creator uitgenodigd"; } } else { templatePath = Resources.Resource.ConfirmTemplate; subject = Resources.Resource.InviteRelationsubject; } } using (TextReader rdr = new StreamReader(HttpContext.Current.Server.MapPath(templatePath))) { string body = rdr.ReadToEnd(); string link = string.Empty; if (requestedUserId != 0) link = string.Format(ConfigurationManager.AppSettings["SiteNavigationLink"] + "/Member/Confirm.aspx?id={0}&tp={1}", guid, relationType); else link = string.Format(ConfigurationManager.AppSettings["SiteNavigationLink"] + "/Member/Confirm.aspx?id={0}&tp={1}&requestingUserinfo={2}", guid, relationType, EncryptionClass.Encrypt(fullName)); body = body.Replace("{%EmailHeaderLogo%}", ConfigurationManager.AppSettings["EmailHeaderLogo"]); body = body.Replace("{%EmailmailToLink%}", ConfigurationManager.AppSettings["EmailmailToLink"]); body = body.Replace("{%SiteNavigationLink%}", ConfigurationManager.AppSettings["SiteNavigationLink"]); body = body.Replace("{%EmailFooterLogo%}", ConfigurationManager.AppSettings["EmailFooterLogo"]); body = body.Replace("{%EmailFBlink%}", ConfigurationManager.AppSettings["EmailFBlink"]); body = body.Replace("{%EmailFBLogo%}", ConfigurationManager.AppSettings["EmailFBLogo"]); body = body.Replace("{%EmailTwitterLink%}", ConfigurationManager.AppSettings["EmailTwitterLink"]); body = body.Replace("{%EmailTwitterLogo%}", ConfigurationManager.AppSettings["EmailTwitterLogo"]); body = body.Replace("{%EmailSoundCloudLink%}", ConfigurationManager.AppSettings["EmailSoundCloudLink"]); body = body.Replace("{%EmailSoundCloudLogo%}", ConfigurationManager.AppSettings["EmailSoundCloudLogo"]); body = body.Replace("{%receivingRelation%}", fullName); body = body.Replace("{%firstname%}", requestingClientInfo.FirstName); body = body.Replace("{%lastname%}", requestingClientInfo.LastName); body = body.Replace("{%confirmlink%}", link); if (!string.IsNullOrEmpty(requestedClientInfo.FirstName)) body = body.Replace("{%firstname_invitee%}", requestedClientInfo.FirstName); else body = body.Replace("{%firstname_invitee%}", fullName); body = body.Replace("{%firstname_invitor%}", requestingClientInfo.FirstName); body = body.Replace("{%FAQ%}", ConfigurationManager.AppSettings["SiteNavigationLink"] + "/FAQ.aspx"); body = body.Replace("{%lastname_invitor%}", requestingClientInfo.LastName); try { Util.SendEmail(new string[] { email }, "*****@*****.**", requestingClientInfo.FirstName + " " + subject, body, null, 0); } catch { return ConfirmationRequestResult.Failed; } } return ConfirmationRequestResult.Success; }
protected void Page_Load(object sender, EventArgs e) { if (Session != null) { // Store essential session information temporarily string culture = Session["culture"] as string ?? "nl-NL"; // Restore the essential session information Session.Clear(); Session.RemoveAll(); Session["culture"] = culture; } if (!IsPostBack) { long userId = Util.UserId; Session["bodyid"] = "user-home"; #region Generating product information and binding their price ------- ! List<Product> listProductInformation = new List<Product>(); using (Database db = new MySqlDatabase()) { ClientInfo ci = null; if (userId > -1) ci = db.GetClientInfo(userId); string currency = "EUR"; string countryIso2 = "NL"; string currencyFmt = "{0} {1:N2}"; if (ci != null) { countryIso2 = Util.GetCountryIso2(ci.Country); currency = Util.GetCurrencyIsoNameByCountryIso2("NL"); currencyFmt = Util.GetCurrencyFormatByCountryIso2("NL"); } string culture = "en-US"; if (Session["culture"] != null) culture = Session["culture"] as string; if (culture.Length == 2) { switch (culture) { case "nl": culture += "-NL"; break; case "en": culture += "US"; break; case "NL": culture = "nl-" + culture; break; case "US": culture = "en" + culture; break; } } ProductInfoList pil = db._GetProducts(); string price = string.Empty; string link = string.Empty; int i = 0; foreach (ProductInfo prod in pil) { //Added by Nagesh ProductPriceInfoList ppil = db.GetProductPrices(prod.ProductId, culture); if (ppil[0].Price > 0m) { price = string.Format( currencyFmt, Util.GetCurrencySymbolByCountryIso2("NL"), ppil[0].Price); } else { price = Resources.Resource.Quotation; } if (ppil[0].Price > 0m) { // Normal products, just process them //link = string.Format(Session["userid"] != null ? // "/Member/BuyProduct.aspx?pid={0}&country={1}&price={2}" : // "/Account/Login.aspx?pid={0}&country={1}&price={2}", // prod.ProductId, countryIso2, ppil[0].Price); link = string.Format(Session["userid"] != null ? "/Member/BuyProduct.aspx?pid={0}&country={1}&price={2}" : "/Account/Login.aspx?pid={0}&country={1}&price={2}", prod.ProductId, "NL", ppil[0].Price); } else { // Special products, check the description field to // find out more about the product switch (prod.Extra.ToLower()) { case "subscription": link = string.Format(Session["userid"] != null ? "/Member/Subscription.aspx?pid={0}&country={1}&price={2}" : "/Account/Login.aspx?pid={0}&country={1}&price={2}&sub=1" ); break; default: link = string.Format(Session["userid"] != null ? "/Member/Quotation.aspx?pid={0}&country={1}&price={2}" : "/Account/Login.aspx?pid={0}&country={1}&price={2}&sub=0", prod.ProductId, countryIso2, 0); break; } } //End Here string desc = db.GetProduct_Desc_Price(prod.ProductId, culture); Product _product = new Product(); _product.ProductPlan = prod.ProductPlan; _product.Credits = Convert.ToString(prod.Credits); _product.ProductDesc = desc.Split('#')[0]; _product.ProductPrice = desc.Split('#')[1]; _product.ProductId = prod.ProductId; listProductInformation.Add(_product); string planCss = "plans"; if (i == 3) { planCss = "plans managed"; } ltrProducts.Text = ltrProducts.Text + "<li> <div class='" + planCss + "'><div class='icon-img'><i class='icon-logo'></i></div><h2 class='plan-title'> " + _product.ProductPlan + "<span class='number'>" + _product.Credits + "</span></h2><p class='description'>" + _product.ProductDesc + "</p><div class='row'><div class='small-6 columns'> <h2 class='price'>" + price + "</h2></div> <div class='small-6 columns'><a href=" + link + " class='button'>" + Resources.Resource.BuyNow + "</a></div></div><p class='footnote'> " + _product.ProductPrice + "</p> </div></li>"; i++; } } #endregion #region Setting en/nl contents ------- ! //ProductList.DataSource = listProductInformation; //ProductList.DataBind(); if (Session["culture"] == null) { string _culture = "nl-NL"; string lang = "en"; if (Request.UserLanguages != null) lang = Request.UserLanguages[0] ?? "en"; lang = lang.Split(';')[0].Trim(); switch (lang) { case "en": _culture = "en-US"; break; case "nl": _culture = "nl-NL"; break; } Session["culture"] = _culture; Culture = _culture; UICulture = _culture; Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(_culture); Thread.CurrentThread.CurrentUICulture = new CultureInfo(_culture); } IncludePage(InfoGraphicLiteral, Resources.Resource.InfoGraphicSection); IncludePage(UpsLiteral, Resources.Resource.UpsSection); IncludePage(AboutLiteral, Resources.Resource.AboutSection); IncludePage(IntroLiteral, Resources.Resource.IntroSection); IncludePage(FooterLiteral, Resources.Resource.FooterSection); IncludePage(FAQLiteral, Resources.Resource.FAQTop10); IncludePage(newsLiteral, Resources.Resource.NewsLiteral); #endregion FormsAuthentication.SignOut(); } //------- Highlight the selected lang button ------- ! if (Convert.ToString(Session["culture"]).Contains("nl")) { ClientScript.RegisterStartupScript(this.GetType(), "HighLightLangBtn", "HighLightLangBtn('" + "LanguageNL" + "');", true); ClientScript.RegisterStartupScript(this.GetType(), "UnHighLightLangBtn", "UnHighLightLangBtn('" + "LanguageUS" + "');", true); ClientScript.RegisterStartupScript(this.GetType(), "HighLightLangBtn", "HighLightLangBtn('" + "btnNLSmall" + "');", true); ClientScript.RegisterStartupScript(this.GetType(), "UnHighLightLangBtn", "UnHighLightLangBtn('" + "btnENSmall" + "');", true); } else { ClientScript.RegisterStartupScript(this.GetType(), "HighLightLangBtn", "HighLightLangBtn('" + "LanguageUS" + "');", true); ClientScript.RegisterStartupScript(this.GetType(), "UnHighLightLangBtn", "UnHighLightLangBtn('" + "LanguageNL" + "');", true); ClientScript.RegisterStartupScript(this.GetType(), "HighLightLangBtn", "HighLightLangBtn('" + "btnENSmall" + "');", true); ClientScript.RegisterStartupScript(this.GetType(), "UnHighLightLangBtn", "UnHighLightLangBtn('" + "btnNLSmall" + "');", true); } }
public override bool ValidateUser(string username, string password) { bool isValid = false; using (Database db = new MySqlDatabase()) { UserState us = db.VerifyUser(username, password); if (us.State >= 0) { UserInfo ui = db.GetUser(username, password); if (ui != null && CheckPassword(md5(password), ui.Password)) { if (ui.IsApproved > 0) { isValid = true; HttpContext.Current.Session["access"] = password; HttpContext.Current.Session["useruid"] = ui.UserUid; HttpContext.Current.Session["userid"] = ui.UserId; db.UpdateUserLogon(username, _applicationName); string culture = "en-US"; ClientInfo ci = db.GetClientInfo(ui.UserId); if (ci != null) { if (!string.IsNullOrEmpty(ci.Country) && !string.IsNullOrEmpty(ci.Language)) { string cultLang = Util.GetLanguageCodeByEnglishName(ci.Language); string cultCtry = Util.GetCountryIso2(ci.Country); culture = string.Format("{0}-{1}", cultLang, cultCtry); } } if (string.IsNullOrEmpty(culture) || culture == "-") culture = "en-US"; //HttpContext.Current.Session["culture"] = culture; } } } } return isValid; }
public override bool UnlockUser(string username) { bool res = false; using (Database db = new MySqlDatabase()) { res = db.UnlockUser(username, _applicationName); } return res; }
public override string GetUserNameByEmail(string email) { string username = string.Empty; using (Database db = new MySqlDatabase()) { username = db.GetUserNameByEmail(email, _applicationName); } if (username == null) username = string.Empty; return username; }
public override bool ChangePassword(string username, string oldPwd, string newPwd) { if (!ValidateUser(username, oldPwd)) return false; ValidatePasswordEventArgs args = new ValidatePasswordEventArgs(username, newPwd, true); OnValidatingPassword(args); if (args.Cancel) { if (args.FailureInformation != null) throw args.FailureInformation; throw new MembershipPasswordException("Change password canceled due to new password validation failure."); } int rowsAffected = 0; using (Database db = new MySqlDatabase()) { rowsAffected = db.ChangePassword(username, _applicationName, newPwd); } if (rowsAffected > 0) return true; return false; // update failed }
protected void Page_Load(object sender, EventArgs e) { new BasePage(); Session["bodyid"] = "coupon"; Control ctrlDiv = this.Master.FindControl("logoutDiv"); ctrlDiv.Visible = false; if (!IsPostBack) { if (!string.IsNullOrEmpty(Request.QueryString["TrackID"])) { using (Database db = new MySqlDatabase()) { IDictionary<string, string> trackInfo = new Dictionary<string, string>(); try { string decryptString = EncryptionClass.Decrypt(Request.QueryString["TrackID"]); if (!string.IsNullOrEmpty(decryptString)) { if (Convert.ToInt32(decryptString) != 0) { trackInfo = db.getTrackInformationByID(Convert.ToInt32(decryptString)); StageName.Text = trackInfo["StageName"]; TrackName.Text = trackInfo["TrackName"]; ISRCCode.Text = trackInfo["isrcCode"]; string tags = string.Empty; tags = tags + (string.IsNullOrEmpty(trackInfo["genre1"]) ? string.Empty : trackInfo["genre1"] + " "); tags = tags + (string.IsNullOrEmpty(trackInfo["genre2"]) ? string.Empty : trackInfo["genre2"] + " "); tags = tags + (string.IsNullOrEmpty(trackInfo["genre3"]) ? string.Empty : trackInfo["genre3"] + " "); tags = tags + (string.IsNullOrEmpty(trackInfo["subgenre1"]) ? string.Empty : trackInfo["subgenre1"] + " "); tags = tags + (string.IsNullOrEmpty(trackInfo["subgenre2"]) ? string.Empty : trackInfo["subgenre2"] + " "); tags = tags + (string.IsNullOrEmpty(trackInfo["subgenre3"]) ? string.Empty : trackInfo["subgenre3"] + " "); tags = tags + (string.IsNullOrEmpty(trackInfo["tag1"]) ? string.Empty : trackInfo["tag1"] + " "); tags = tags + (string.IsNullOrEmpty(trackInfo["tag2"]) ? string.Empty : trackInfo["tag2"] + " "); tags = tags + (string.IsNullOrEmpty(trackInfo["tag3"]) ? string.Empty : trackInfo["tag3"] + " "); AddedTags.Text = tags; } else { StageName.Text = TrackName.Text = ISRCCode.Text = AddedTags.Text = Resources.Resource.NoTrackInfoFound; ClientScript.RegisterStartupScript (this.GetType(), "alert", "alert('" + Resources.Resource.TrackInfoCannotShown + "');", true); } } else { StageName.Text = TrackName.Text = ISRCCode.Text = AddedTags.Text = Resources.Resource.NoTrackInfoFound; ClientScript.RegisterStartupScript (this.GetType(), "alert", "alert('" + Resources.Resource.TrackInfoCannotShown + "');", true); } } catch { StageName.Text = TrackName.Text = ISRCCode.Text = AddedTags.Text = Resources.Resource.NoTrackInfoFound; ClientScript.RegisterStartupScript (this.GetType(), "alert", "alert('" + Resources.Resource.TrackInfoCannotShown + "');", true); } } } else { ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + Resources.Resource.NoTrackInfoFound + "');", true); } } if (Convert.ToString(Session["culture"]).Contains("nl")) { ClientScript.RegisterStartupScript(this.GetType(), "HighLightLangBtn", "HighLightLangBtn('" + "ctl00_LanguageNL" + "');", true); ClientScript.RegisterStartupScript(this.GetType(), "UnHighLightLangBtn", "UnHighLightLangBtn('" + "ctl00_LanguageUS" + "');", true); } else { ClientScript.RegisterStartupScript(this.GetType(), "HighLightLangBtn", "HighLightLangBtn('" + "ctl00_LanguageUS" + "');", true); ClientScript.RegisterStartupScript(this.GetType(), "UnHighLightLangBtn", "UnHighLightLangBtn('" + "ctl00_LanguageNL" + "');", true); } }
protected void Page_PreRender(Object o, EventArgs e) { using (Database db = new MySqlDatabase()) { ClientInfo ci = db.GetClientInfo(Util.UserId); bool isNotExpired = true; Facebook.AuthenticationService authService = new Facebook.AuthenticationService(); Facebook.Me me; string accessToken = string.Empty; if (authService.TryAuthenticate(out me, out accessToken)) { isNotExpired = true; } else { db.RemoveSocialCredential(ci.ClientId, SocialConnector.Facebook); db.UpdateFacebookID(ci.ClientId); isNotExpired = false; } if (!string.IsNullOrEmpty(ci.SoundCloudId)) SoundcloudItag.Attributes.Add("class", "soundcloud"); else SoundcloudItag.Attributes.Add("class", "soundcloud disabled"); if (isNotExpired) FacebookHeading.Attributes.Add("class", "social facebook"); else FacebookHeading.Attributes.Add("class", "social facebook disabled"); if (!string.IsNullOrEmpty(ci.TwitterId)) TwitterHeading.Attributes.Add("class", "social twitter"); else TwitterHeading.Attributes.Add("class", "social twitter disabled"); } }
protected void Page_Load(object sender, EventArgs e) { Session["bodyid"] = "user-home"; //IncludePage(PayResultInc, Resources.Resource.incPayResult); //IncludePage(RhosMovementInc, Resources.Resource.incRhosMovement2); using (Database db = new MySqlDatabase()) { UserInfo ui = db.GetUser(Util.UserId); email = ui.Email; ClientInfo ci = db.GetClientInfo(Util.UserId); name = ci.FirstName; DataSet ds = db.GetRegister(Util.UserId); int protectedTracks = ds.Tables[0].Rows.Count; LoggedOnTitle.Text = Resources.Resource.LoggedOnTitle; LoggedOnUserName.Text = string.Format("<span><b>{0}</b></span>", ci.FirstName); // ci.GetFullName()); CreditsLiteral.Text = Convert.ToString(Util.GetUserCredits(Util.UserId)); ProtectedLiteral.Text = Convert.ToString(protectedTracks); decimal percentComplete = 0m; if (Session["percentComplete"] != null) percentComplete = Convert.ToDecimal(Session["percentComplete"]); CompletedLiteral.Text = string.Empty; if (percentComplete < 100) CompletedLiteral.Text = string.Format(Resources.Resource.PercentComplete, percentComplete / 100m); divAccPerCompleted.Visible = ClickToLinkLiteral.Visible = (CompletedLiteral.Text != string.Empty); } string res = Request.Params["res"] ?? "unknown"; if (!string.IsNullOrEmpty(res)) { switch (res.ToLower()) { case "success": ProcessTransaction(); break; case "error": ProcessFailure(); break; case "postback": ProcessPostback(); break; default: break; } } if (Convert.ToString(Session["culture"]).Contains("nl")) { ClientScript.RegisterStartupScript(this.GetType(), "HighLightLangBtn", "HighLightLangBtn('" + "ctl00_HeadLoginView_LanguageNL" + "');", true); ClientScript.RegisterStartupScript(this.GetType(), "UnHighLightLangBtn", "UnHighLightLangBtn('" + "ctl00_HeadLoginView_LanguageUS" + "');", true); } else { ClientScript.RegisterStartupScript(this.GetType(), "HighLightLangBtn", "HighLightLangBtn('" + "ctl00_HeadLoginView_LanguageUS" + "');", true); ClientScript.RegisterStartupScript(this.GetType(), "UnHighLightLangBtn", "UnHighLightLangBtn('" + "ctl00_HeadLoginView_LanguageNL" + "');", true); } CreditsLiteral.Text = Convert.ToString(Util.GetUserCredits(Util.UserId)); }
private void ProcessTransaction() { long userId = Util.UserId; long prodId = 0L; string country = "NL"; string currency = "EUR"; string culture = "nl-NL"; decimal amount = 0m; if (Session["pid"] != null) prodId = Convert.ToInt64(Session["pid"]); if (Session["amt"] != null) amount = Convert.ToDecimal(Session["amt"]); if (Session["culture"] != null) culture = Session["culture"] as string; country = culture.Substring(3); currency = Util.GetCurrencyIsoNameByCountryIso2(country); Logger.Instance.Write(LogLevel.Info, "Process successful transaction: {0}", Request.RawUrl); string res = Request.Params["res"] ?? string.Empty; string status = Request.Params["Status"] ?? string.Empty; string statusCode = Request.Params["StatusCode"] ?? string.Empty; string merchant = Request.Params["Merchant"] ?? string.Empty; string orderId = Request.Params["OrderID"] ?? string.Empty; string paymentId = Request.Params["PaymentID"] ?? string.Empty; string reference = Request.Params["Reference"] ?? string.Empty; string transid = Request.Params["TransactionID"] ?? string.Empty; string paymentMethod = Request.Params["PaymentMethod"] ?? string.Empty; if (!string.IsNullOrEmpty(statusCode)) statusCode = Uri.UnescapeDataString(statusCode); using (Database db = new MySqlDatabase()) { StringBuilder sb = new StringBuilder(); ProductInfo pi = db.GetProductById(prodId); switch (db.UpdateTransaction(orderId, res, status, statusCode, merchant, paymentId, reference, transid, paymentMethod, amount, pi, currency, country)) { case TransactionResult.Success: { long Transaction_id = 0; long.TryParse(orderId, out Transaction_id); db.UpdateUserCredits(userId, prodId, pi.Credits); db.AddCreditHistory(userId, prodId, pi.Credits, Transaction_id); sb.Append("<div>"); sb.AppendFormat("<p><strong>{0}</strong></p>", Resources.Resource.TransactionSuccessful); sb.AppendFormat(Resources.Resource.HasCreditsNow, Util.GetUserCredits(userId)); sb.Append("</div>"); } break; case TransactionResult.NotFound: { sb.Append("<div>"); sb.AppendFormat("<p><strong>{0}</strong></p>", Resources.Resource.TransactionFailed); sb.AppendFormat(Resources.Resource.HasCreditsNow, Util.GetUserCredits(userId)); sb.Append("</div>"); } break; case TransactionResult.AlreadyCompleted: { sb.Append("<div>"); sb.AppendFormat("<p><strong>{0}</strong></p>", Resources.Resource.TransactionAlreadyCompleted); sb.AppendFormat(Resources.Resource.HasCreditsNow, Util.GetUserCredits(userId)); sb.Append("</div>"); } break; } ResultLiteral.Text = sb.ToString(); } sendMail(orderId, Resources.Resource.CreditPurchaseSuccessSubject, Resources.Resource.CreditPurchaseSuccessBody); }
public override MembershipUser GetUser(string username, bool userIsOnline) { MembershipUser user = null; using (Database db = new MySqlDatabase()) { user = db.GetUser(Name, username, _applicationName, userIsOnline); } return user; }
public override MembershipUser GetUser(object providerUserKey, bool userIsOnline) { MembershipUser u = null; using (Database db = new MySqlDatabase()) { u = db.GetUser(Name, providerUserKey, _applicationName, userIsOnline); } return u; }
public override bool ChangePasswordQuestionAndAnswer(string username, string password, string newQuestion, string newAnswer) { if (!ValidateUser(username, password)) return false; int rowsAffected = 0; using (Database db = new MySqlDatabase()) { rowsAffected = db.ChangePasswordQuestionAndAnswer(username, _applicationName, newQuestion, newAnswer); } return (rowsAffected > 0); }
public override string ResetPassword(string username, string answer) { if (!EnablePasswordReset) throw new NotSupportedException("Password reset is not enabled."); if (string.IsNullOrEmpty(answer) && RequiresQuestionAndAnswer) { UpdateFailureCount(username, "passwordAnswer"); throw new ProviderException("Password answer required for password reset."); } string newPassword = System.Web.Security.Membership.GeneratePassword(NEW_PASSWORD_LENGTH, MinRequiredNonAlphanumericCharacters); ValidatePasswordEventArgs args = new ValidatePasswordEventArgs(username, newPassword, true); OnValidatingPassword(args); if (args.Cancel) { if (args.FailureInformation != null) throw args.FailureInformation; else throw new MembershipPasswordException("Reset password canceled due to password validation failure."); } string res = string.Empty; using (Database db = new MySqlDatabase()) { res = db.ResetPassword( username, _applicationName, answer, newPassword, PasswordAttemptWindow, RequiresQuestionAndAnswer, PasswordFormat, MaxInvalidPasswordAttempts, this); } if (!string.IsNullOrEmpty(res)) return newPassword; throw new MembershipPasswordException("User not found, or user is locked out. Password not reset."); }
public override MembershipUser CreateUser( string username, string password, string email, string question, string answer, bool isApproved, object providerUserKey, out MembershipCreateStatus status) { if (string.IsNullOrEmpty(username)) username = email; status = MembershipCreateStatus.ProviderError; ValidatePasswordEventArgs args = new ValidatePasswordEventArgs(username, password, true); OnValidatingPassword(args); if (args.Cancel) { status = MembershipCreateStatus.InvalidPassword; return null; } if (RequiresUniqueEmail && GetUserNameByEmail(email) != "") { status = MembershipCreateStatus.DuplicateEmail; return null; } MembershipUser user = GetUser(username, false); if (user == null) { if (providerUserKey == null) { providerUserKey = Guid.NewGuid(); } else { if (!(providerUserKey is Guid)) { status = MembershipCreateStatus.InvalidProviderUserKey; return null; } } int subscriptionType = 0; if (HttpContext.Current.Session["subscriptiontype"] != null) subscriptionType = (int)HttpContext.Current.Session["subscriptiontype"]; using (Database db = new MySqlDatabase()) { if (db.RegisterUser( username, _applicationName, email, "", password, question, answer, subscriptionType) > 0) status = MembershipCreateStatus.Success; } return GetUser(username, false); } status = MembershipCreateStatus.DuplicateUserName; return null; }
public override void UpdateUser(MembershipUser user) { using (Database db = new MySqlDatabase()) { db.UpdateUser(user, _applicationName); } }
public override bool DeleteUser(string username, bool deleteAllRelatedData) { bool res = false; using (Database db = new MySqlDatabase()) { res = db.DeleteUser(username, _applicationName, deleteAllRelatedData); } return res; }
private void UpdateFailureCount(string username, string failureType) { using (Database db = new MySqlDatabase()) { db.UpdateFailureCount(username, _applicationName, failureType, PasswordAttemptWindow, MaxInvalidPasswordAttempts); } }
public override MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords) { MembershipUserCollection users = new MembershipUserCollection(); using (Database db = new MySqlDatabase()) { users = db.FindUsersByName(Name, usernameToMatch, _applicationName, pageIndex, pageSize, out totalRecords); } return users; }
protected void Page_Load(object sender, EventArgs e) { IncludePage(SelectProductInc, Resources.Resource.incSelectProduct); IncludePage(RhosMovementInc, Resources.Resource.incRhosMovement2); long userId = Util.UserId; divSignUp.Visible = (Session["userid"] == null); if (!IsPostBack) { using (Database db = new MySqlDatabase()) { ClientInfo ci = null; if (userId > -1) ci = db.GetClientInfo(userId); string currency = "EUR"; string countryIso2 = "NL"; string currencyFmt = "{0} {1:N2}"; if (ci != null) { countryIso2 = Util.GetCountryIso2(ci.Country); currency = Util.GetCurrencyIsoNameByCountryIso2("NL"); currencyFmt = Util.GetCurrencyFormatByCountryIso2("NL"); } string culture = "en-US"; if (Session["culture"] != null) culture = Session["culture"] as string; if (culture.Length == 2) { switch (culture) { case "nl": culture += "-NL"; break; case "en": culture += "US"; break; case "NL": culture = "nl-" + culture; break; case "US": culture = "en" + culture; break; } } ProductInfoList pil = db.GetProducts(); int i = 0; foreach (ProductInfo prod in pil) { ProductPriceInfoList ppil = db.GetProductPrices(prod.ProductId, culture); TableRow row = new TableRow(); row.VerticalAlign = VerticalAlign.Top; TableCell cell = new TableCell(); if (i < 4) { Image img = new Image(); img.ImageUrl = string.Format(Resources.Resource.imgVaultFmt, _desc[i]); cell.Controls.Add(img); ++i; } else { cell.Text = " "; } row.Cells.Add(cell); string desc = db.GetProductTitle(prod.ProductId, culture); cell = new TableCell(); Literal lit = new Literal(); lit.Text = "<div style=\"margin-left:8px;margin-right:8px;\">" + desc + "</div>"; cell.Controls.Add(lit); row.Cells.Add(cell); cell = new TableCell(); cell.Width = Unit.Pixel(50); cell.Font.Bold = true; cell.HorizontalAlign = HorizontalAlign.Center; if (ppil[0].Price > 0m) { cell.Text = string.Format( currencyFmt, Util.GetCurrencySymbolByCountryIso2("NL"), ppil[0].Price); } else { cell.Text = Resources.Resource.Quotation; } row.Cells.Add(cell); cell = new TableCell(); HyperLink hl = new HyperLink(); hl.CssClass = "linkBuy"; if (string.IsNullOrEmpty(countryIso2)) countryIso2 = "NL"; if (ppil[0].Price > 0m) { // Normal products, just process them hl.NavigateUrl = string.Format(Session["userid"] != null ? "~/Member/BuyProduct.aspx?pid={0}&country={1}&price={2}" : "~/Account/Login.aspx?pid={0}&country={1}&price={2}", prod.ProductId, countryIso2, ppil[0].Price); hl.ImageUrl = Resources.Resource.imgBuyCredits; } else { // Special products, check the description field to // find out more about the product switch (prod.Extra.ToLower()) { case "subscription": hl.NavigateUrl = string.Format(Session["userid"] != null ? "~/Member/Subscription.aspx?pid={0}&country={1}&price={2}" : "~/Account/Login.aspx?pid={0}&country={1}&price={2}&sub=1" ); break; default: hl.NavigateUrl = string.Format(Session["userid"] != null ? "~/Member/Quotation.aspx?pid={0}&country={1}&price={2}" : "~/Account/Login.aspx?pid={0}&country={1}&price={2}&sub=0", prod.ProductId, countryIso2, 0); hl.ImageUrl = Resources.Resource.imgQuotation; break; } } cell.Controls.Add(hl); row.Cells.Add (cell); ProductTable.Rows.Add (row); } } } else { } }
public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords) { totalRecords = 0; MembershipUserCollection users = new MembershipUserCollection(); using (Database db = new MySqlDatabase()) { totalRecords = db.GetUserCount(_applicationName); if (totalRecords <= 0) return users; users = db.GetAllUsers(Name, _applicationName, pageIndex, pageSize); } return users; }
public static ConfirmationResult ProcessConfirmation(string guid, int relationType) { ConfirmationResult result = ConfirmationResult.ConfirmationFailed; string emailRequested = string.Empty; string emailRequesting = string.Empty; ClientInfo requestingClientInfo = null; ClientInfo requestedClientInfo = null; using (Database db = new MySqlDatabase()) { result = db.ProcessConfirmation(guid, relationType, out emailRequested, out emailRequesting); long requestedUserId = db.GetUserIdByEmail(emailRequested); long requestingUserId = db.GetUserIdByEmail(emailRequesting); requestingClientInfo = db.GetClientInfo(requestingUserId); requestedClientInfo = db.GetClientInfo(requestedUserId); } if (result == ConfirmationResult.Success) { string _template = string.Empty; if (relationType == 1) _template = Resources.Resource.ConfirmRequestorTemplate; else _template = Resources.Resource.TemplateConfirmrelationcreate; using (TextReader rdr = new StreamReader(HttpContext.Current.Server.MapPath(_template))) { string body = rdr.ReadToEnd(); body = body.Replace("{%EmailHeaderLogo%}", ConfigurationManager.AppSettings["EmailHeaderLogo"]); body = body.Replace("{%EmailmailToLink%}", ConfigurationManager.AppSettings["EmailmailToLink"]); body = body.Replace("{%SiteNavigationLink%}", ConfigurationManager.AppSettings["SiteNavigationLink"]); body = body.Replace("{%EmailFooterLogo%}", ConfigurationManager.AppSettings["EmailFooterLogo"]); body = body.Replace("{%EmailFBlink%}", ConfigurationManager.AppSettings["EmailFBlink"]); body = body.Replace("{%EmailFBLogo%}", ConfigurationManager.AppSettings["EmailFBLogo"]); body = body.Replace("{%EmailTwitterLink%}", ConfigurationManager.AppSettings["EmailTwitterLink"]); body = body.Replace("{%EmailTwitterLogo%}", ConfigurationManager.AppSettings["EmailTwitterLogo"]); body = body.Replace("{%EmailSoundCloudLink%}", ConfigurationManager.AppSettings["EmailSoundCloudLink"]); body = body.Replace("{%EmailSoundCloudLogo%}", ConfigurationManager.AppSettings["EmailSoundCloudLogo"]); body = body.Replace("{%receivingRelation%}", requestingClientInfo.GetFullName()); body = body.Replace("{%firstname%}", requestedClientInfo.FirstName); body = body.Replace("{%lastname%}", requestedClientInfo.LastName); body = body.Replace("{%firstname_invitee%}", requestedClientInfo.FirstName); body = body.Replace("{%firstname_invitor%}", requestingClientInfo.FirstName); body = body.Replace("{%lastname_invitor%}", requestingClientInfo.LastName); body = body.Replace("{%FAQ%}", ConfigurationManager.AppSettings["SiteNavigationLink"] + "/FAQ.aspx"); try { Util.SendEmail(new string[] { emailRequesting }, "*****@*****.**", Resources.Resource.ConfirmationManagedMusician, body, null, 0); } catch (Exception ex) { Logger.Instance.Write(LogLevel.Error, ex, "[ProcessConfirmation]"); } } } return result; }
public override int GetNumberOfUsersOnline() { int numOnline = 0; using (Database db = new MySqlDatabase()) { numOnline = db.GetNumberOfUsersOnline(_applicationName); } return numOnline; }
private static string GetConfiguration(string key) { string res = null; using (Database db = new MySqlDatabase()) { res = db.GetSetting(key); } return res; }
public override string GetPassword(string username, string answer) { if (!EnablePasswordRetrieval) throw new ProviderException("Password retrieval not enabled."); if (PasswordFormat == MembershipPasswordFormat.Hashed) throw new ProviderException("Cannot retrieve hashed passwords."); string password = null; string passwordAnswer = null; using (Database db = new MySqlDatabase()) { password = db.GetPassword(username, answer, _applicationName, out passwordAnswer); } if (RequiresQuestionAndAnswer && !CheckPassword(answer, passwordAnswer)) { UpdateFailureCount(username, "passwordAnswer"); throw new MembershipPasswordException("Incorrect password answer."); } if (PasswordFormat == MembershipPasswordFormat.Encrypted) password = UnEncodePassword(password); return password; }