protected void Page_Load(object sender, EventArgs e) { string referer, subject; referer = Request.ServerVariables["http_referer"]; subject = Request.Form["fsubject"]; if (Request.IsLocal || (referer.IndexOf("lyons") > 0 && subject != null)) { string body, outcome, fromName, logText = string.Empty, connectionString = string.Empty, notes; string title_id = string.Empty, source_id = string.Empty, country_id = string.Empty; string reason_id = string.Empty, applicantId, utmSessionId, utmSource = string.Empty, utmCampaign = string.Empty; CommonFeatures commonFeatures; if (Request.IsLocal) { connectionString = "Server=localhost;Database=almacantar;Uid=root;Pwd=jhp5uck5;Allow Zero Datetime=True;"; } else { connectionString = "Server=mysql.surgesolutions.co.uk;Database=almacantar;Uid=almacantar_user;Pwd=*d3v3!0pm3nt5*;Allow Zero Datetime=True;"; } if (string.IsNullOrEmpty(Request.Form["ftitle"])) { title_id = "0"; } else { title_id = Request.Form["ftitle"].ToString().Split('|')[0]; } if (string.IsNullOrEmpty(Request.Form["fenquiry-source"])) { source_id = "0"; } else { source_id = Request.Form["fenquiry-source"].ToString().Split('|')[0]; } if (string.IsNullOrEmpty(Request.Form["fcountry"])) { country_id = "0"; } else { country_id = Request.Form["fcountry"].ToString().Split('|')[0]; } if (string.IsNullOrEmpty(Request.Form["freason-for-purchase"])) { reason_id = "0"; } else { reason_id = Request.Form["freason-for-purchase"].ToString().Split('|')[0]; } SiteVariables vars = new SiteVariables(); fromName = Request.Form["ffirst-name"] + " " + Request.Form["flast-name"]; body = "<p>A User has sent the following " + subject + " Request From Lyons Place Website.</p>"; foreach (String sItem in Request.Form) { if (!string.IsNullOrEmpty(sItem)) { body += "<p>" + sItem.Substring(1).ToUpper() + ": " + Request.Form[sItem] + "</p>"; } logText += "\"" + Request.Form[sItem] + "\","; } commonFeatures = new CommonFeatures(connectionString); utmSessionId = CommonFeatures.ReadCookie("utmc"); if (!string.IsNullOrEmpty(utmSessionId)) { UTMItem utmItem = commonFeatures.GetUTMForExport(utmSessionId); if (!string.IsNullOrEmpty(utmItem.ID)) { body += "<p>UTM Campaign: " + utmItem.Campaign + "</p>"; logText += "\"" + utmItem.Campaign + "\","; // save utm utmItem.PageUrl = "ProcessForm.aspx"; utmItem.PageName = "REGD"; utmItem.SessionID = utmSessionId; utmItem.DevelopmentID = "3"; commonFeatures.RecordUTM(utmItem); source_id = "38"; utmSource = utmItem.Source; utmCampaign = utmItem.Campaign; } } LogFile logFile = new LogFile(); logFile.LogFileName = "contact-us-" + DateTime.Now.ToString("dd-MM-yyyy") + ".txt"; logFile.AddLine(logText + "\"" + DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss") + "\""); notes = "Interested in " + Request.Form["interested"] + Environment.NewLine + Environment.NewLine + Request.Form["fcomments"]; List <string> applicant = new List <string>(); applicant.Add(title_id); applicant.Add(Request.Form["ffirst-name"]); applicant.Add(Request.Form["flast-name"]); applicant.Add(Request.Form["fmobile"]); applicant.Add(Request.Form["femail"]); applicant.Add(source_id); applicant.Add(country_id); applicant.Add(reason_id); applicant.Add(notes); applicant.Add("3"); // development Id applicant.Add(utmSessionId); applicant.Add(utmSource); applicant.Add(utmCampaign); applicantId = commonFeatures.RecordApplicantInCRM(applicant); if (!Request.IsLocal) { GenFolders(fromName + "-" + applicantId); } Email oEmail = new Email(); oEmail.SMTPServer = "smtp.socketlabs.com"; oEmail.CredentialUsername = "******"; oEmail.CredentialPassword = "******"; oEmail.EnableSsl = false; oEmail.FromName = fromName; oEmail.EmailFrom = vars["emailfrom"]; oEmail.ReplyToName = fromName; oEmail.ReplyTo = Request.Form["femail"]; oEmail.ToName = vars["toname"]; oEmail.EmailTo = vars["emailto"]; oEmail.Subject = subject + " Request From Lyons Place website"; oEmail.IsBodyHtml = true; oEmail.Body = body; outcome = oEmail.SendEmail(); body = "Hi James Guilfoyle," + "<br /><br />" + "Please see the new lead below." + "<br /><br />" + "<strong>" + fromName + "</strong>: https://www.almacantar.surgesolutions.co.uk/applicant-profile/" + applicantId; oEmail.ToName = "James Guilfoyle"; oEmail.EmailTo = "*****@*****.**"; oEmail.Subject = "Lyons Place - New Lead"; oEmail.Body = body; outcome = oEmail.SendEmail(); Response.Write("OK"); } }
protected void Page_Load(object sender, EventArgs e) { string metaText = string.Empty, currentUrl; if (!string.IsNullOrEmpty(this.MetaTitle)) { Page.Title = this.MetaTitle; } if (!string.IsNullOrEmpty(this.MetaDescription)) { metaText += "<meta name=\"description\" content=\"" + this.MetaDescription + "\" />"; } if (!string.IsNullOrEmpty(this.MetaKeywords)) { metaText += "<meta name=\"keywords\" content=\"" + this.MetaKeywords + "\" />"; } metadata.Text = metaText; currentUrl = HttpContext.Current.Request.RawUrl; if (currentUrl.IndexOf("utm_") != -1) { if (Session["utm"] == null) { Session["utm"] = "y"; } } if (Session["utm"] != null || !string.IsNullOrEmpty(CommonFeatures.ReadCookie("utmc"))) { string connectionString = string.Empty, utmSessionId = string.Empty; int index; // A returning utm visitor will have the utmc cookie utmSessionId = CommonFeatures.ReadCookie("utmc"); // if its NOT a returning utm visitor if (string.IsNullOrEmpty(utmSessionId)) { utmSessionId = Session.SessionID; CommonFeatures.WriteCookie("utmc", utmSessionId); } index = currentUrl.IndexOf("?"); if (index != -1) { currentUrl = currentUrl.Replace("?", "?spg=1&"); } NameValueCollection queryString = HttpUtility.ParseQueryString(currentUrl); if (Request.IsLocal) { connectionString = "Server=localhost;Database=almacantar;Uid=root;Pwd=jhp5uck5;Allow Zero Datetime=True;"; } else { connectionString = "Server=mysql.surgesolutions.co.uk;Database=almacantar;Uid=almacantar_user;Pwd=*d3v3!0pm3nt5*;Allow Zero Datetime=True;"; } CommonFeatures commonFeatures = new CommonFeatures(connectionString); UTMItem utmItem = new UTMItem(); utmItem.Campaign = queryString["utm_campaign"]; utmItem.Content = queryString["utm_content"]; utmItem.Department = queryString["utm_department"]; if (index == -1) { utmItem.PageUrl = "https://www.lyonsplace.co.uk" + currentUrl; } else { utmItem.PageUrl = "https://www.lyonsplace.co.uk" + currentUrl.Substring(0, index); } utmItem.PageName = this.MetaTitle; utmItem.MEID = string.Empty; utmItem.SessionID = utmSessionId; utmItem.Source = queryString["utm_source"]; utmItem.Medium = queryString["utm_medium"]; utmItem.QS = currentUrl; utmItem.DevelopmentID = "3"; commonFeatures.RecordUTM(utmItem); } }