public AppPressDemoSessionData(AppPressDemo p, string loginUserId, string email) : base(email, loginUserId, null) { this.email = email; if (loginUserId != null) { this.loginName = p.ExecuteString("Select [dbo].[FullName](FirstName,MiddleName,LastName) From \"application.users\" Where Id = " + loginUserId); string imgUrlQry = @" Select Case When ""Application_Files"".Id Is Null Then Case When CV.gender = 1 Then '" + AppPress.GetBaseUrl() + @"Resources/img/img_Female.jpg' Else '" + AppPress.GetBaseUrl() + @"Resources/img/img_Male.jpg' End Else Concat('" + AppPress.GetBaseUrl() + AppPress.GetDefaultAspx() + @"?GetFile=&width=100&id=',Application_Files.Id) End as Image From ""application.users"" CV Left Join ""Application_Files"" On ""Application_Files"".Id = CV.PhotoUpload Where CV.Id = " + loginUserId; this.loginImgUrl = p.ExecuteString(imgUrlQry); // Add the URL to session for inbuilt security this.AddSecureUrl(loginImgUrl); } }
internal static int ValidateLogin(AppPressDemo p, ref string email, string password, bool cookieLogin) { int employeeId = 0; var loginLink = "<br/><br/><a href='" + AppPress.GetDefaultAspx() + "?&FromSignout='>Login</a>"; if (AppPressApplication.Settings.developer) { if (int.TryParse(email, out employeeId)) { var firstName = p.ExecuteString("Select FirstName from \"application.users\" Where Id = " + employeeId); if (firstName == null) { throw new AppPressException("Could not find employee id. "); } email = "support+" + firstName.ToLower().Replace(" ", ".") + "." + employeeId + "@sysmates.com"; } } if (employeeId <= 0) { var tempemail = email.Trim().ToLower(); var ttttEmail = tempemail; var query = "Select id From \"application.users\" Where (Email='" + p.EscapeSQLString(tempemail) + "' or PersonalEmail ='" + p.EscapeSQLString(tempemail) + "') "; var obj = p.ExecuteScalar(query); if (obj == null) { if (cookieLogin) { return(0); } throw new AppPressException("Wrong Email. There is no account available with this email." + loginLink); } if (!AppPressApplication.Settings.developer) { if (password != null) { var newPassword = obj.ToString() + "_" + System.Text.Encoding.Default.GetString((byte[])p.ExecuteScalar("Select HASHBYTES('SHA2_256','" + p.EscapeSQLString(password) + "')")); query += "and Password = HASHBYTES('SHA2_256','" + p.EscapeSQLString(newPassword) + "')"; } obj = p.ExecuteScalar(query); } if (obj == null) { if (cookieLogin) { return(0); } throw new AppPressException("Wrong Email or Password." + loginLink); } employeeId = Convert.ToInt32(obj); } return(employeeId); }
public static string Domain(AppPressDemo p, DiscussionClass.ParticipantsFieldClass Participants) { string query = null; var baseFormData = Participants.FormData.IsPopup ? Participants.FormData.FormDataPopupCaller : Participants.FormData; if (baseFormData.GetType() == typeof(UserControlsClass)) { query = @"Select Case When PhotoUpload Is Null Then Case When gender = 1 Then '" + AppPress.GetBaseUrl() + @"Resources/img/img_Female.jpg' Else '" + AppPress.GetBaseUrl() + @"Resources/img/img_Male.jpg' End Else Concat('" + AppPress.GetBaseUrl() + AppPress.GetDefaultAspx() + @"?getFile=&id=', PhotoUpload, '&width=100') End as Photo, [dbo].[FullName](FirstName,MiddleName,LastName) Name, case when id=" + p.loginUserId + @" then 'Self' else 'ReportingTo' end Level, Isnull(Email,PersonalEmail) Email From ""Application.Users"" Where Id in (" + p.loginUserId + @"," + ((UserControlsClass)baseFormData).ReportingTo.val + ")"; } return(query); }
internal static void ErrorResponse(HttpResponse Response, string message, string stackTrace) { Response.Clear(); Response.ContentType = "text/html"; try { string skin = System.IO.File.ReadAllText(HttpContext.Current.Server.MapPath("~/Skins/Error.html")); //skin = CompileSkin(a, skin, false, SkinType.HTML); skin = skin.Replace("_DefaultAspxPage_", AppPress.GetDefaultAspx()); skin = skin.Replace("_ThisIsReplacedByErrorMessage_", System.Web.HttpUtility.HtmlEncode(message).Replace("\n", "<br/>")); skin = skin.Replace("_ThisIsReplacedByLoginUrl_", System.Web.HttpUtility.HtmlEncode(AppPress.GetBaseUrl() + AppPress.GetDefaultAspx()).Replace("\n", "<br/>")); skin = skin.Replace("_ThisIsReplacedByStackTrace_", System.Web.HttpUtility.HtmlEncode(stackTrace)); Response.AddHeader("Cache-Control", "no-store; no-cache"); Response.Write(skin); } catch { Response.Write(message); } }
internal static void InitApplication() { if (Settings != null) { return; } try { bool isDebug = false; #if DEBUG isDebug = true; #endif Settings = new ApplicationSettings(); string ip = System.Web.HttpContext.Current.Request.UserHostAddress; Settings.IsLocalHost = (ip == "127.0.0.1" || ip == "::1"); string dbName = "AppPressDemo"; Settings.developer = isDebug; Settings.DEBUG = isDebug; Settings.databaseType = DatabaseType.SqlServer; Settings.NetDateFormat = "dd-MMM-yyyy"; Settings.NetDateTimeFormat = "dd-MMM-yyyy HH:mm"; Settings.NetDateMonthFormat = "MMM-yyyy"; Settings.JQueryDateMonthFormat = "M-yy"; if (Settings.databaseType == DatabaseType.SqlServer) { Settings.SQLDateFormat = "dd-MMM-yyyy"; } else // MySQL { Settings.SQLDateFormat = "%d-%b-%Y"; } if (Settings.databaseType == DatabaseType.SqlServer) { Settings.SQLDateTimeFormat = Settings.SQLDateFormat + " hh:mm"; } else // MySQL { Settings.SQLDateTimeFormat = Settings.SQLDateFormat + " %h:%i %p"; } Settings.JQueryDateFormat = "dd-M-yy"; Settings.AdditionalInputDateFormats = "dd-MM-yyyy | dd/MM/yyyy"; Settings.DefaultForm = "Login"; Settings.applicationAssembly = System.Reflection.Assembly.GetExecutingAssembly(); Settings.applicationNameSpace = "Application"; Settings.applicationClassName = "AppLogic"; Settings.pluginAssemblyNames = new List <string>(); Settings.ProductName = "AppPressDemo"; Settings.ProductURL = "http://www.hrmates.com"; Settings.Instances.Add(new AppPressInstance { InstanceId = 4, InstanceBaseUrl = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/" + AppPress.GetDefaultAspx(), ApplicationData = "AppPressDemo", LocalInstance = dbName == "AppPressDemo" }); Settings.ConnectionString = ConfigurationManager.ConnectionStrings["AppPressDemo"].ConnectionString; Settings.LogoPathSmall = AppPress.GetBaseUrl() + "Resources/img/Logo_Small.png"; var smtpSection = (SmtpSection)ConfigurationManager.GetSection("system.net/mailSettings/smtp"); Settings.Smtp = new Smtp(); Settings.Smtp.Host = smtpSection.Network.Host; Settings.Smtp.Port = smtpSection.Network.Port; Settings.Smtp.EnableSsl = smtpSection.Network.EnableSsl; Settings.Smtp.UserName = smtpSection.Network.UserName; Settings.Smtp.Password = smtpSection.Network.Password; //Settings.encryptionKey = EmpireEncryption.EmpireKey.GetEncryptionKey(site.dbName); Settings.encryptionKey = @"https://"; Settings.DebugEmail = "*****@*****.**"; Settings.useDebugEmail = AppPressApplication.Settings.IsLocalHost; Settings.ApplicationAppPress = typeof(AppLogic.AppPressDemo); AppPress.InitAppPress(Settings); var site = new DAOBasic(); try { var a = new AppPress(site); // Do any Database specific work here } finally { site.Close(); } if (PurgeUnusedFilesThread == null) { PurgeUnusedFilesThread = new Thread(PurgeUnusedFiles); PurgeUnusedFilesThread.Priority = ThreadPriority.Lowest; PurgeUnusedFilesThread.Start(); } // just in case you host Debug version on server if (Settings.DEBUG && !Settings.IsLocalHost) { throw new Exception("Debug version is hosted on server. Need release version to run application."); } } catch { Settings = null; throw; } }