Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Location Identifier

Location Identifier

Scheduled Pinned Locked Moved C#
comtutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Brendan Vogt
    wrote on last edited by
    #1

    Hi, Lets say I have a website called www.ABC.com, which is the main site. I have other sites, for example www.ABC.co.za, and www.abc.com.au. If the user selects www.abc.com, it must determine that the user is from Australia and redirect him to www.abc.com.au. The above sites I used just as examples. But I think eBay has this feature. If anyone has such sample code, please let me know. Regards ma se ;P

    A 1 Reply Last reply
    0
    • B Brendan Vogt

      Hi, Lets say I have a website called www.ABC.com, which is the main site. I have other sites, for example www.ABC.co.za, and www.abc.com.au. If the user selects www.abc.com, it must determine that the user is from Australia and redirect him to www.abc.com.au. The above sites I used just as examples. But I think eBay has this feature. If anyone has such sample code, please let me know. Regards ma se ;P

      A Offline
      A Offline
      aerosmith2k1
      wrote on last edited by
      #2

      You have to determine this by ip address then redirect them to the contry subdomain. here is some sample code. ' This sample code is provided as is, for aiding understanding. ' I make no warranty about its fitness for purpose. ' If you find it useful please use it. ' Don't expect me to sort out any problems unless you are prepared to pay me. ' Written by Paul Stanley Software http://www.pssuk.com ' Set IP string, 1st check for proxy sIP = Request.ServerVariables("HTTP_X_FORWARDED_FOR") if sIP = "" then sIP = Request.ServerVariables("REMOTE_ADDR") end if ' Handle extended IP addresses nComma = Instr(sIP, ",") if nComma > 0 then sIP = Left(sIP, nComma - 1) end if set oConnIP = CreateObject("ADODB.Connection") sConn = "Driver={Microsoft Access Driver (*.mdb)}; Dbq=" sConn = sConn & Server.MapPath(".") & "\IPCountry.mdb" sConn = sConn & "; Uid=admin; Pwd=" oConnIP.Open sConn set oRSip = CreateObject("ADODB.RecordSet") oRSip.ActiveConnection = oConnIP oRSip.CursorLocation = adUseClient nIP = Dot2LongIP(sIP) sSQL = "SELECT [CountryShort] FROM [IPCOUNTRY] WHERE " & CStr(nIP) & " BETWEEN [ipFrom] AND [ipTo];" oRSip.Open sSQL, oConnIP, adOpenForwardOnly, adLockReadOnly sCountry = oRSip("CountryShort") function Dot2LongIP (ByVal DottedIP) Dim i, pos, PrevPos, num ' Convert IP String like "1.12.124.22" to 32 bit integer if len(DottedIP) < 7 or isnull(DottedIP) or DottedIP = "unknown" then Dot2LongIP = 0 else PrevPos = 0 for i = 1 To 4 pos = InStr(PrevPos + 1, DottedIP, ".", 1) if pos = 0 then If i = 4 Then pos = Len(DottedIP) + 1 else Dot2LongIP = 0 exit function end If end if num = Int(Mid(DottedIP, PrevPos + 1, pos - PrevPos - 1)) PrevPos = pos Dot2LongIP = ((num Mod 256) * (256 ^ (4 - i))) + Dot2LongIP next end If end function

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups