Esempio n. 1
0
        public void GetData(MySqlCommand cmd)
        {
            // REMOTE_ADDR
            string ipRemoteAddr = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];

            REMOTE_ADDR = new IpInfo(cmd, ipRemoteAddr.Trim());

            // HTTP_X_FORWARDED_FOR
            string ipList = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

            if (ipList != null)
            {
                string[] ipArray = ipList.Split(',');

                List_HTTP_X_FORWARDED_FOR = new List <IpInfo>();
                foreach (string ip in ipArray)
                {
                    List_HTTP_X_FORWARDED_FOR.Add(new IpInfo(cmd, ip.Trim()));
                }
            }

            foreach (IpInfo ipInfoXForwarded in List_HTTP_X_FORWARDED_FOR)
            {
                if (ipInfoXForwarded.IsValidPublicIP)
                {
                    HTTP_X_FORWARDED_FOR = ipInfoXForwarded;
                }
            }

            // HTTP_CLIENT_IP
            string ipClientIp = HttpContext.Current.Request.ServerVariables["HTTP_CLIENT_IP"];

            if (ipClientIp != null)
            {
                HTTP_CLIENT_IP = new IpInfo(cmd, ipClientIp.Trim());
            }
        }
Esempio n. 2
0
 public IPLite(MySqlCommand cmd, string ipAddress)
 {
     REMOTE_ADDR = new IpInfo(cmd, ipAddress.Trim());
 }