Location Identifier
-
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
-
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
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