B
B
Bohdan Yurchuck2017-12-14 13:27:14
MySQL
Bohdan Yurchuck, 2017-12-14 13:27:14

How to find out the IP of a person who entered your site using JS?

I want to find out the IP of the site visitor, and then use the IP to determine the city. Task for the online store. There are many solutions in PHP, but are there any in JavaScript ???

Answer the question

In order to leave comments, you need to log in

6 answer(s)
R
Ruslan., 2019-10-03
@hax

You can try that.
Here I took into account cases when the exit time is greater than the entry time.

SELECT userGUID, areaGUID, timeHappened AS times
  FROM users in_u
  LEFT JOIN users out_u
         ON out_u.userGUID     = in_u.userGUID
        AND out_u.areaGUID     = in_u.areaGUID
        AND out_u.inOut        = 2
        AND out_u.timeHappened > in_u.timeHappened
 WHERE in_u.inOut  = 1
   AND out_u.inOut IS NULL
ORDER BY userGUID, areaGUID

K
Konstantin Tsvetkov, 2019-10-03
@tsklab

For each user, determine the maximum time record and filter out those who have inOut = 1.

A
Anton R., 2019-10-03
@anton_reut

who are currently in the zones and have not left it yet?

To understand that the user has exited, the counter of his inputs / outputs must return an even number , that is, for 1 input there is always 1 output = the counter returns at least 2. So you need to count all users whose counter returns an odd number , that's all.

O
Oleg, 2017-12-14
@Tigermax139

No way on bare js.
But if there is such a task, you can use a similar crap https://javascript.ru/forum/misc/2272-opredelenie-...

A
Alexey Arkh, 2017-12-14
@AlekseyArh

Just make an API request to the server, which will return the required data.
For example, you can pull it from Yandex maps

https://api-maps.yandex.ru/2.0-stable/?load=package.standard&lang=ru-RU

E
Egor Zhivagin, 2017-12-14
@Krasnodar_etc

Node.js can in the definition of IP, google it. Php doesn't do it on the client anyway)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question