public static EmailConfig GetEmailConfig() { var configRoot = (new ConfigurationBuilder()) .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json") .Build(); // read the config settings from the appsettings.json file string smtpHost = configRoot.GetValue <string>("Email.SmtpHost")?.Trim(); string smtpPort = configRoot.GetValue <string>("Email.SmtpPort")?.Trim(); string fromAddress = configRoot.GetValue <string>("Email.FromAddress")?.Trim(); if (string.IsNullOrWhiteSpace(smtpHost) || string.IsNullOrWhiteSpace(smtpPort) || string.IsNullOrWhiteSpace(fromAddress)) { throw new Exception("Could not read all the Email config parameters from the config file."); } // create the EmailSenderConfig object var config = new EmailConfig(); config.SmtpHost = smtpHost; config.SmtpPort = StringModule.ToInt(smtpPort); config.FromAddress = fromAddress; return(config); }
private void addCookie(ArrayValue array, string cookies, int start, int end, bool isMagicQuotes) { int eqIndex = cookies.indexOf('=', start); string name = ""; string value = ""; StringValue valueV; if (eqIndex < end) { name = cookies.substring(start, eqIndex); StringValue nameV = cleanCookieName(name); if (array.get(nameV) != UnsetValue.UNSET) { return; } value = cookies.substring(eqIndex + 1, end); value = decodeValue(value); valueV = createString(value); if (isMagicQuotes) // php/0876 { valueV = StringModule.addslashes(valueV); } array.append(nameV, valueV); } else { name = cookies.substring(start, end); StringValue nameV = cleanCookieName(name); if (nameV.length() > 0 && nameV[0] == '$') { array.append(nameV, getEmptyString()); } } }
private static void put(ArrayValue array, Value key, Value value, bool addSlashes) { if (addSlashes && value.isString()) { value = StringModule.addslashes(value.ToStringValue()); } if (key == null) { array.put(value); } else { array.put(key, value); } }
public static AppConfig GetGeneralConfig() { var configRoot = (new ConfigurationBuilder()) .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json") .Build(); // read the config settings from the appsettings.json file string environment = configRoot.GetValue <string>("App.Environment")?.Trim(); string restrictUsersTo = configRoot.GetValue <string>("App.RestrictUsersTo")?.Trim(); string enablePerformanceProfiling = configRoot.GetValue <string>("App.PerformanceProfiling.Enabled")?.Trim(); string path_tempWorkingDir = configRoot.GetValue <string>("Path.TempWorkingDir")?.Trim(); var config = new AppConfig(); config.Environment = EnumModule.EnumFromString <RunningEnvironment>(environment) ?? RunningEnvironment.Dev; config.RestrictedUsers = restrictUsersTo?.Split(',').Select(s => s.Trim().ToUpper()).ToArray() ?? new string[0]; config.EnablePerformanceProfiling = StringModule.ToBool(enablePerformanceProfiling, false); config.Path_TempWorkingDir = path_tempWorkingDir.IfEmpty(@"C:\Temp\TempWorkingDir"); return(config); }