public static string ToQueryString(NameValueCollection collection, bool startWithQuestionMark = true) { if (collection == null || !collection.HasKeys()) return String.Empty; var sb = new StringBuilder(); if (startWithQuestionMark) sb.Append("?"); var j = 0; var keys = collection.Keys; foreach (string key in keys) { var i = 0; var values = collection.GetValues(key); foreach (var value in values) { sb.Append(key) .Append("=") .Append(value); if (++i < values.Length) sb.Append("&"); } if (++j < keys.Count) sb.Append("&"); } return sb.ToString(); }
public void HasKeys () { NameValueCollection c = new NameValueCollection (5, CaseInsensitiveHashCodeProvider.DefaultInvariant, CaseInsensitiveComparer.DefaultInvariant); Assert.IsTrue (!c.HasKeys (), "#1"); c.Add ("foo1", "bar1"); Assert.IsTrue (c.HasKeys (), "#2"); }
public static string GetParameter(Uri requestUri, string keyParam) { System.Collections.Specialized.NameValueCollection nvp = System.Web.HttpUtility.ParseQueryString(requestUri.OriginalString); if (nvp.HasKeys()) { return(nvp.GetValues(keyParam).FirstOrDefault()); } return(null); }
protected static NameValueCollection GetCleanedNameValueCollection(NameValueCollection requestQueryString) { var nvc = new NameValueCollection(requestQueryString); if (nvc.HasKeys()) { nvc.Remove(null); } return nvc; }
public void SetUtmValuesCookie() { var collection = HttpContext.Current.Request.QueryString; var validCollection = new NameValueCollection(); var current = HttpContext.Current.Request.Cookies.Get("sourceData"); if (current == null) { current = new HttpCookie("sourceData"); } foreach (string key in collection.AllKeys) { if (key != null) { if (ValidValues.ContainsKey(key)) { validCollection.Add(key, collection[key]); } } } //Check if the valid collection has anything to set, otherwise dont set cookie if (validCollection.HasKeys()) { bool hasChanged = false; foreach (var key in validCollection.AllKeys) { var value = collection[key]; if (current.Values.AllKeys.Contains(key)) { if (current.Values[key] != collection[key]) { current.Values[key] = collection[key]; hasChanged = true; } } else { current.Values.Add(key, value); hasChanged = true; } } if (hasChanged) { HttpContext.Current.Response.Cookies.Add(current); } } }
public override void Initialize(string name, NameValueCollection config) { if (config == null || !config.HasKeys()) throw new ArgumentNullException("config"); name = "UnlockedStateProvider"; base.Initialize(name, config); if (!Configuration.ConfiguredAsStandardProvider) { lock (Configuration.ConfigurationCreationLock) { Configuration.ConfigureAsSdandardProvider(config); } } }
private string HttpVarsToString(System.Collections.Specialized.NameValueCollection nvc, string strTitle, bool blnSuppressEmpty, string strSuppressKeyPattern) { if (!nvc.HasKeys()) { return(string.Empty); } StringBuilder sb = new StringBuilder(4096); sb.Append(strTitle); sb.Append(Environment.NewLine); sb.Append(Environment.NewLine); bool blnDisplay; foreach (string strKey in nvc) { blnDisplay = true; if (blnSuppressEmpty) { blnDisplay = nvc[strKey] != string.Empty; } if (strKey == _strViewstateKey) { _strViewstate = nvc[strKey]; blnDisplay = false; } if (blnDisplay && strSuppressKeyPattern != string.Empty) { blnDisplay = !Regex.IsMatch(strKey, strSuppressKeyPattern); } if (blnDisplay) { AppendLine(sb, strKey, nvc[strKey]); } } sb.Append(Environment.NewLine); return(sb.ToString()); }
/// <summary> /// IPNMessage constructor /// </summary> /// <param name="nvc"></param> public IPNMessage(NameValueCollection nvc) { try { if (nvc.HasKeys()) { foreach (string key in nvc.Keys) { nvcMap.Add(key, nvc[key]); } ipnRequest = ConstructQueryString(nvc); ipnRequest += "&cmd=_notify-validate"; } } catch (System.Exception ex) { logger.Debug(this.GetType().Name + " : " + ex.Message); } }
/// <summary> /// Retrieve all the parameters from the Request /// </summary> /// <param name="request"></param> /// <param name="excludeParameters">Do not include any parameters from the provided collection</param> /// <returns></returns> public static IEnumerable <KeyValuePair <string, string> > TupledParameters(Uri requestUri, string[] excludeParameters = null) { var list = new List <KeyValuePair <string, string> >(); System.Collections.Specialized.NameValueCollection nvp = System.Web.HttpUtility.ParseQueryString(requestUri.OriginalString); if (nvp.HasKeys()) { foreach (string key in nvp.Keys) { if (excludeParameters == null || !excludeParameters.Contains(key)) { foreach (string val in nvp.GetValues(key)) { list.Add(new KeyValuePair <string, string>(key, val)); } } } } return(list); }
/// <summary> /// Create Uri /// </summary> /// <param name="baseUri">base uri</param> /// <param name="pathInfos">path infos</param> /// <param name="queryStrings">query strings</param> /// <param name="fragment">fragment string</param> /// <returns>request uri</returns> public static Uri CreateUri( Uri baseUri, IEnumerable<string> pathInfos, NameValueCollection queryStrings, string fragment) { UriBuilder uriBuilder; // build pathInfo if (pathInfos != null && pathInfos.Any()) { uriBuilder = new UriBuilder(new Uri(baseUri, new Uri(ToPathInfo(pathInfos), UriKind.Relative))); } else { uriBuilder = new UriBuilder(baseUri); } // build queryString if (queryStrings != null && queryStrings.HasKeys()) { var query = HttpUtility.ParseQueryString(baseUri.Query); foreach (string key in queryStrings) { query[key] = queryStrings[key]; } uriBuilder.Query = ToQueryString(query); } // append fragment if (!string.IsNullOrWhiteSpace(fragment)) { uriBuilder.Fragment = HttpUtility.UrlEncode(fragment); } return uriBuilder.Uri; }
public static string rq(string keyName) { string sRetValue = ""; string sKeyname = keyName.ToLower(); System.Web.HttpRequest r = System.Web.HttpContext.Current.Request; System.Collections.Specialized.NameValueCollection n = r.QueryString; if (n.HasKeys()) { for (int i = 0; i < n.Count; i++) { if (n.GetKey(i) != null) { string key = n.GetKey(i).ToLower(); if (key == sKeyname) { sRetValue = n.Get(i); break; } } } } return(sRetValue); }
/// <summary> /// Sets up the profile providers /// </summary> /// <param name="name"></param> /// <param name="config"></param> public override void Initialize(string name, NameValueCollection config) { // verify that the configuration section was properly passed if (!config.HasKeys()) { throw new ArgumentNullException("config"); } // Application Name this._appName = config["applicationName"].ToStringDBNull(Config.ApplicationName); // Connection String Name this._connStrName = config["connectionStringName"].ToStringDBNull(Config.ConnectionStringName); // is the connection string set? if (!string.IsNullOrEmpty(this._connStrName)) { string connStr = ConfigurationManager.ConnectionStrings[_connStrName].ConnectionString; ConnectionString = connStr; ConnectionStringName = SqlDbAccess.GetConnectionStringNameFromConnectionString(connStr); // set the app variable... if (YafContext.Current.Get<HttpApplicationStateBase>()[_connStrAppKeyName] == null) { YafContext.Current.Get<HttpApplicationStateBase>().Add(_connStrAppKeyName, connStr); } else { YafContext.Current.Get<HttpApplicationStateBase>()[_connStrAppKeyName] = connStr; } } base.Initialize(name, config); }
/// <summary> /// Initializing nvcMap and constructing query string /// </summary> /// <param name="nvc"></param> private void Initialize(NameValueCollection nvc) { List<string> items = new List<string>(); try { if (nvc.HasKeys()) { foreach (string key in nvc.Keys) { items.Add(string.Concat(key, "=", System.Web.HttpUtility.UrlEncode(nvc[key], Encoding.GetEncoding(IPNEncoding)))); nvcMap.Add(key, nvc[key]); } ipnRequest = string.Join("&", items.ToArray())+"&cmd=_notify-validate"; } } catch (System.Exception ex) { logger.Error(this.GetType().Name + ": " + ex.Message, ex); } }
/// <summary> /// Sets up the profile providers /// </summary> /// <param name="name"> /// </param> /// <param name="config"> /// </param> public override void Initialize(string name, NameValueCollection config) { // verify that the configuration section was properly passed if (!config.HasKeys()) { ExceptionReporter.ThrowArgument("ROLES", "CONFIGNOTFOUND"); } // Application Name this._appName = config["applicationName"].ToStringDBNull(Config.ApplicationName); // Connection String Name this._connStrName = config["connectionStringName"].ToStringDBNull(Config.ConnectionStringName); // is the connection string set? if (this._connStrName.IsSet()) { string connStr = ConfigurationManager.ConnectionStrings[this._connStrName].ConnectionString; _connectionString = connStr; ConnectionStringName = VZF.Data.DAL.SqlDbAccess.GetConnectionStringNameFromConnectionString(connStr); // set the app variable... if (YafContext.Current.Get<HttpApplicationStateBase>()[ConnStrAppKeyName] == null) { YafContext.Current.Get<HttpApplicationStateBase>().Add(ConnStrAppKeyName, connStr); } else { YafContext.Current.Get<HttpApplicationStateBase>()[ConnStrAppKeyName] = connStr; } } base.Initialize(name, config); // application name this._appName = config["applicationName"]; if (string.IsNullOrEmpty(this._appName)) { this._appName = "YetAnotherForum"; } }
private UriTemplate FindBestMatchingTemplate(UriTemplateTable templates, object resourceKey, string uriName, NameValueCollection keyValues) { resourceKey = this.EnsureIsNotType(resourceKey); var matchingTemplates = from template in templates.KeyValuePairs let descriptor = (UrlDescriptor)template.Value where CompatibleKeys(resourceKey, descriptor.ResourceKey) where UriNameMatches(uriName, descriptor.UriName) let templateParameters = template.Key.PathSegmentVariableNames.Concat(template.Key.QueryValueVariableNames).ToList() let hasKeys = keyValues != null && keyValues.HasKeys() where (templateParameters.Count == 0) || (templateParameters.Count > 0 && hasKeys && templateParameters.All(x => keyValues.AllKeys.Contains(x, StringComparison.OrdinalIgnoreCase))) orderby templateParameters.Count descending select template.Key; return matchingTemplates.FirstOrDefault(); }
public override void Initialize(string name, NameValueCollection config) { if (string.IsNullOrEmpty(name)) { name = typeof(RoleTypeProvider).Name; } base.Initialize(name, config); if (string.IsNullOrEmpty(config["applicationName"])) { throw new ProviderException(string.Format("Key applicationName is required")); } ApplicationName = config["applicationName"]; config.Remove("applicationName"); if (config.HasKeys()) { throw new ProviderException(string.Format("Unrecognized key {0}", config.GetKey(0))); } }
public static PostContentData[] FromNamedValueCollection(NameValueCollection nvc) { var result = new List<PostContentData>(); try { if (nvc != null && nvc.Count > 0 && nvc.HasKeys()) { var keys = nvc.AllKeys.ToList(); foreach (var key in keys) { var vals = ""; foreach (var val in nvc.GetValues(key)) vals += val; result.Add(new PostContentData(key, vals)); } } } catch (Exception ex) { } return result.ToArray(); }
private string CreatePathWithQueryStrings(string path, IConnectionConfigurationValues global, IRequestParameters request = null) { //Make sure we append global query string as well the request specific query string parameters var copy = new NameValueCollection(global.QueryStringParameters); var formatter = new UrlFormatProvider(this.ConnectionSettings); if (request != null) copy.Add(request.QueryString.ToNameValueCollection(formatter)); if (!copy.HasKeys()) return path; var queryString = copy.ToQueryString(); var tempUri = new Uri("http://localhost:9200/" + path).Purify(); if (tempUri.Query.IsNullOrEmpty()) path += queryString; else path += "&" + queryString.Substring(1, queryString.Length - 1); return path; }
/// <summary> /// Create an instance of the service using the System.Environment and /// AppDomain.CurrentDomain.SetupInformation.ActivationArguments /// </summary> public ShellParameterService() { this.ArgTable = new System.Collections.Specialized.NameValueCollection(); List<string> Args = new List<string>(System.Environment.GetCommandLineArgs()); Args.RemoveAt(0); string AppWebsite = ""; string website = "http://connectomes.utah.edu/Rabbit/Volume.VikingXML"; // string homepage = "http://connectomes.utah.edu/"; if (Args.Count > 0) { website = Args[0]; } else { bool ShowUsage = true; if (AppDomain.CurrentDomain.SetupInformation.ActivationArguments != null) { string[] ClickOnceArgs = AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData; if (ClickOnceArgs != null && ClickOnceArgs.Length > 0) { Trace.WriteLine("ActivationArguments: "); foreach (string arg in ClickOnceArgs) Trace.WriteLine(arg, "Viking"); string FirstArg = System.Web.HttpUtility.HtmlDecode(ClickOnceArgs[0]); string[] HttpArgs = FirstArg.Split('?'); AppWebsite = HttpArgs[0]; //The website we use to launch Viking Trace.WriteLine("Application Website: " + AppWebsite, "Viking"); if (HttpArgs.Length == 0) { //Sometimes the only argument passed is the application directory if (!HttpArgs[0].ToLower().EndsWith(".application")) { website = HttpArgs[1]; ShowUsage = false; } } //Parse the arguments else if (HttpArgs.Length > 1) { ArgTable = System.Web.HttpUtility.ParseQueryString(HttpArgs[1]); if (ArgTable.HasKeys()) { //PORT WPF //UI.State.StartupArguments = QueryTable; string VolumeValue = ArgTable["Volume"]; if (VolumeValue != null) { website = VolumeValue; ShowUsage = false; } } else { website = HttpArgs[1]; ShowUsage = false; } } } } if (ShowUsage) { //Launch the viking home page and exit System.Windows.MessageBox.Show("No volume definition file was specified. Loading RC1 by default. You can pass a website as the first argument to launch a different volume, or select a volume definition from the website: http://connectomes.utah.edu/", "Viking", System.Windows.MessageBoxButton.OK); //System.Diagnostics.Process WebBrowser = new System.Diagnostics.Process(); //WebBrowser.StartInfo.FileName = homepage; //WebBrowser.Start(); } } //Make sure the website includes a file, if it does not then include Volume.VikingXML by default Uri WebsiteURI = new Uri(website); string path = WebsiteURI.GetComponents(UriComponents.Path, UriFormat.SafeUnescaped); if (path.Contains(".") == false) { if (website.EndsWith("/") == false) website = website + "/"; website = website + "volume.VikingXML"; WebsiteURI = new Uri(website); } string HostPath = System.IO.Path.GetDirectoryName(website); //Add the host property to the properties ArgTable.Add("Host", website); ArgTable.Add("HostPath", HostPath); //Add the host's subpath to the properties //Remove the Host, determine the path of the volume XDocument XDoc = Utils.IO.Load(WebsiteURI); //Update the Volume property in case we trimmed the file name this.InitializationXML = XDoc; }
public void Test01() { IntlStrings intl; NameValueCollection nvc; // simple string values string[] values = { "", " ", "a", "aA", "text", " SPaces", "1", "$%^#", "2222222222222222222222222", System.DateTime.Today.ToString(), Int32.MaxValue.ToString() }; // keys for simple string values string[] keys = { "zero", "oNe", " ", "", "aa", "1", System.DateTime.Today.ToString(), "$%^#", Int32.MaxValue.ToString(), " spaces", "2222222222222222222222222" }; int cnt = 0; // Count // [] initialize IntStrings intl = new IntlStrings(); // [] NameValueCollection is constructed as expected //----------------------------------------------------------------- nvc = new NameValueCollection(); cnt = nvc.Count; if (cnt != 0) { Assert.False(true, string.Format("Error, count is {0} instead of {1} after default ctor", nvc.Count, 0)); } // // [] on empty collection // if (nvc.HasKeys()) { Assert.False(true, "Error, HasKeys returned true after default ctor"); } // [] Add simple strings and HasKeys() // cnt = nvc.Count; for (int i = 0; i < values.Length; i++) { nvc.Add(keys[i], values[i]); } if (nvc.Count != values.Length) { Assert.False(true, string.Format("Error, count is {0} instead of {1}", nvc.Count, values.Length)); } if (!nvc.HasKeys()) { Assert.False(true, string.Format("Error, returned false for collection with {0} items", nvc.Count)); } // // [] Add Intl strings and HasKeys() // int len = values.Length; string[] intlValues = new string[len * 2]; // fill array with unique strings // for (int i = 0; i < len * 2; i++) { string val = intl.GetRandomString(MAX_LEN); while (Array.IndexOf(intlValues, val) != -1) val = intl.GetRandomString(MAX_LEN); intlValues[i] = val; } // Add items // cnt = nvc.Count; for (int i = 0; i < len; i++) { nvc.Add(intlValues[i + len], intlValues[i]); } if (nvc.Count != (cnt + len)) { Assert.False(true, string.Format("Error, count is {0} instead of {1}", nvc.Count, cnt + len)); } if (!nvc.HasKeys()) { Assert.False(true, string.Format("Error, returned false for collection with {0} items", nvc.Count)); } // // [] Add item with null-key and call HasKeys() // nvc.Clear(); cnt = nvc.Count; for (int i = 0; i < values.Length; i++) { nvc.Add(null, values[i]); } if (nvc.Count != 1) { Assert.False(true, string.Format("Error, count is {0} instead of {1}", nvc.Count, 1)); } if (nvc.HasKeys()) { Assert.False(true, "Error, returned true for collection null-key"); } }
public static string HttpRequestURLSyn(RequestHeader currentHeader, string requestUrl) { System.Collections.Specialized.NameValueCollection nv = new System.Collections.Specialized.NameValueCollection(StringComparer.InvariantCultureIgnoreCase); StringBuilder urlBuilder = new StringBuilder(); int qIdx = requestUrl.IndexOf('?'); if (qIdx != -1) { string paramStr = requestUrl.Substring(qIdx + 1); urlBuilder.Append(requestUrl.Substring(0, qIdx) + "?"); string[] subParams = paramStr.Split(new char[] { '&' }, StringSplitOptions.RemoveEmptyEntries); string[] kvPairs = new string[2]; foreach (string crtParam in subParams) { kvPairs = crtParam.Split('='); if (kvPairs.Length == 2) { nv.Set(kvPairs[0], kvPairs[1]); } else { //TODO? nv.Set(crtParam, crtParam); } } } if (!nv.HasKeys()) { urlBuilder.Append(requestUrl + "?"); } #region 参数附加 /* * 参数名 参数说明 * sid 参考2.4.2 * imei 参考2.4.5 * imsi 参考2.4.6 * nid 参考2.4.3 * did 参考2.4.1 * dtd 拨号方式说明: * 0-CTNET * 1-CTWAP */ nv.Set("sid", currentHeader.ESP_SoftwareID.ToString()); nv.Set("imei", currentHeader.ESP_IMEI.GetRawString()); nv.Set("imsi", currentHeader.ESP_IMEI.GetRawString()); //?? nv.Set("nid", currentHeader.ESP_NID.GetHashCode().ToString()); nv.Set("did", currentHeader.ESP_DID.ToString()); nv.Set("dtd", currentHeader.ESP_DailType.GetHashCode().ToString()); #endregion foreach (string key in nv.AllKeys) { urlBuilder.AppendFormat("{0}={1}&", key, nv[key]); } return(urlBuilder.ToString().TrimEnd('&')); }
/// <summary> /// Initialize Membership Provider /// </summary> /// <param name="name"> /// Membership Provider Name /// </param> /// <param name="config"> /// <see cref="NameValueCollection"/> of configuration items /// </param> public override void Initialize(string name, NameValueCollection config) { // Verify that the configuration section was properly passed if (!config.HasKeys()) { ExceptionReporter.ThrowArgument("ROLES", "CONFIGNOTFOUND"); } // Retrieve information for provider from web config // config ints // Minimum Required Password Length from Provider configuration this._minimumRequiredPasswordLength = int.Parse(config["minRequiredPasswordLength"] ?? "6"); // Minimum Required Non Alpha-numeric Characters from Provider configuration this._minRequiredNonAlphanumericCharacters = int.Parse(config["minRequiredNonalphanumericCharacters"] ?? "0"); // Maximum number of allowed password attempts this._maxInvalidPasswordAttempts = int.Parse(config["maxInvalidPasswordAttempts"] ?? "5"); // Password Attempt Window when maximum attempts have been reached this._passwordAttemptWindow = int.Parse(config["passwordAttemptWindow"] ?? "10"); // Check whething Hashing methods should use Salt this._useSalt = (config["useSalt"] ?? "false").ToBool(); // Check whether password hashing should output as Hex instead of Base64 this._hashHex = (config["hashHex"] ?? "false").ToBool(); // Check to see if password hex case should be altered this._hashCase = config["hashCase"].ToStringDBNull("None"); // Check to see if password should have characters removed this._hashRemoveChars = config["hashRemoveChars"].ToStringDBNull(); // Check to see if password/salt combination needs to asp.net standard membership compliant this._msCompliant = (config["msCompliant"] ?? "false").ToBool(); // Application Name this._appName = config["applicationName"].ToStringDBNull(Config.ApplicationName); // Connection String Name this._connStrName = config["connectionStringName"].ToStringDBNull(Config.ConnectionStringName); this._passwordStrengthRegularExpression = config["passwordStrengthRegularExpression"].ToStringDBNull(); // Password reset enabled from Provider Configuration this._enablePasswordReset = (config["enablePasswordReset"] ?? "true").ToBool(); this._enablePasswordRetrieval = (config["enablePasswordRetrieval"] ?? "false").ToBool(); this._requiresQuestionAndAnswer = (config["requiresQuestionAndAnswer"] ?? "true").ToBool(); this._requiresUniqueEmail = (config["requiresUniqueEmail"] ?? "true").ToBool(); string strPasswordFormat = config["passwordFormat"].ToStringDBNull("Hashed"); switch (strPasswordFormat) { case "Clear": this._passwordFormat = MembershipPasswordFormat.Clear; break; case "Encrypted": this._passwordFormat = MembershipPasswordFormat.Encrypted; break; case "Hashed": this._passwordFormat = MembershipPasswordFormat.Hashed; break; default: ExceptionReporter.Throw("MEMBERSHIP", "BADPASSWORDFORMAT"); break; } // is the connection string set? if (this._connStrName.IsSet()) { string connStr = ConfigurationManager.ConnectionStrings[this._connStrName].ConnectionString; ConnectionString = connStr; ConnectionStringName = SqlDbAccess.GetConnectionStringNameFromConnectionString(connStr); // set the app variable... if (YafContext.Current.Get<HttpApplicationStateBase>()[ConnStrAppKeyName] == null) { YafContext.Current.Get<HttpApplicationStateBase>().Add(ConnStrAppKeyName, connStr); } else { YafContext.Current.Get<HttpApplicationStateBase>()[ConnStrAppKeyName] = connStr; } } base.Initialize(name, config); }
/// <summary> /// Function that puts the authentication parameters from the request url in the request authentication header and parses the arguments as parameters for the controller /// </summary> /// <param name="request"></param> /// <returns></returns> public HttpRequestMessage CombobulateArgumentRequest(HttpRequestMessage request) { NameValueCollection requestParams = request.RequestUri.ParseQueryString(); // Derive Authorization header from parameter if (request.Headers.Authorization == null) { string test = requestParams["arg0"]; string test2 = requestParams["arg1"]; string authHeader = String.Format("ApiUser={0}, SharedSecret={1}", requestParams["arg0"], requestParams["arg1"]); request.Headers.Authorization = new AuthenticationHeaderValue("LSR-DIGEST", authHeader); } // Build new uri without method and data array StringBuilder newPath = new StringBuilder(request.RequestUri.Scheme + "://"); newPath.Append(request.RequestUri.Authority); newPath.Append(request.RequestUri.AbsolutePath); newPath.Append("/" + requestParams["method"] + "/"); //// Find the data[], aka the function parameters NameValueCollection functionParams = new NameValueCollection(); Regex r = new Regex(@"arg[0-9]+\[(?<parm>\w+)\]", RegexOptions.IgnoreCase); foreach (String s in requestParams.AllKeys) { Match m = r.Match(s); if (m.Success) functionParams.Add(r.Match(s).Result("${parm}"), requestParams[s]); } if (functionParams.HasKeys()) { newPath.Append("?"); foreach (String s in functionParams.AllKeys) { newPath.Append("&" + s + "=" + functionParams[s]); } } request.RequestUri = new Uri(newPath.ToString()); return request; }
internal string ParseRequest(string url, NameValueCollection arguments, out long length) { try { var retval = url; if (arguments.HasKeys() && url == "/approve.html") if (arguments["cid"] != null && arguments["action"] != null) { var client = Exts.FromBase64(arguments["cid"]); if (DHCP.Clients.ContainsKey(client) && !DHCP.Clients[client].ActionDone) { if (arguments["action"] == "0") { DHCP.Clients[client].NextAction = Definitions.NextActionOptionValues.Referral; DHCP.Clients[client].ActionDone = true; } else { DHCP.Clients[client].NextAction = Definitions.NextActionOptionValues.Abort; DHCP.Clients[client].ActionDone = true; } } } if (retval == "/approve.html") retval = "/requests.html"; if (retval == "/") retval = "/index.html"; if (!retval.EndsWith(".htm") && !retval.EndsWith(".html") && !retval.EndsWith(".js") && !retval.EndsWith(".css") && !retval.EndsWith(".png") && !retval.EndsWith(".gif") && !retval.EndsWith(".ico")) throw new Exception("Unsupportet Content type!"); var size = Filesystem.Size("http{0}".F(retval)); length = size; if (size > Settings.MaxAllowedFileLength) // 10 MB return null; return "http{0}".F(retval); } catch (Exception) { length = 0; return null; } }
private string CreatePathWithQueryStrings(string path, IConnectionConfigurationValues global, IRequestParameters request = null) { //Make sure we append global query string as well the request specific query string parameters var copy = new NameValueCollection(global.QueryStringParameters); var formatter = new UrlFormatProvider(this.ConnectionSettings); if (request != null) copy.Add(request.QueryString.ToNameValueCollection(formatter)); if (!copy.HasKeys()) return path; var queryString = copy.ToQueryString(); path += queryString; return path; }