Геолокатор: Where Are You?
WoBistDu?
Малeнький пробный движок, собирающий информацию о посетителях по части геолокации их провайдеров… Работает как на смартфонах, так и на кнопочниках…:p const http = require("http"); const ipapi = require("ipapi.co"); const hosting = ""; const port = process.env.PORT; const html = ["<!doctype html>" ,"<html>" ,"<head >" ,"<meta content='text/html; charset=utf8' http-equiv='Content-Type' />" ,"<meta content='ru-RU' http-equiv='Content-Language' />" ,"<meta content='300' http-equiv='refresh' />" ,"<head><title>WoBistDu?</title>" ,"<style>" ,"p {" ," text-align :right" ,"}" ,"</style>" ,"</head>" ,"<body>" ,"..." ,"</body>" ]; var users = []; var ips = []; var callback = function(res) { if(this.neo) { var pos = [ res.longitude, res.latitude ].join(); var args = [ "l=map", "pt=" + pos, "z=" + 16 ].join("&"); var msg = this.msg.replace(/[<>&]+/gm, " ").substr(0, 16); users.unshift("<a target='_blank' name='#" + (users.length + 1) + "' href='https://yandex.ru/maps/?" + args + "'><img src='http://bootstraptema.ru/plugins/2016/flag-icon-css/4x3-2/" + res.country.toLowerCase() + ".svg' width='16' height='12' />" + res.city + "." + res.country + "#" + (users.length + 1) + "</a>" + msg); } this.res.statusCode = 200; this.res.setHeader("Content-Type", "text/html; charset=utf-8"); this.res.end(html.join("\r\n").replace("...", users.join("<br />"))); }; async function my_server(req, res) { //////////////////////////////////////////////////////// var cb; var ipAddr = req.ip || req.headers["x-forwarded-for"] || req.connection.remoteAddress; if(ipAddr) ipAddr = ipAddr.split(",").pop(); else ipAddr = req.connection.remoteAddress; var theIP = ipAddr.split(/:+/).pop().split(".").join("."); var msg = req.url.match(/say=([^&?]*)/); if(ips.join().indexOf(theIP) < 0) { if(ips.length >= 100) ips.length = 99; ips.unshift(theIP); cb = callback.bind({res: res, neo: true, msg: (msg ? ":" + unescape(msg[1]) : "")}); } else cb = callback.bind({res: res, neo: false, msg: ""}); ipapi.location(cb, theIP); // Complete location for your IP address }; const server = http.createServer(my_server); server.listen(port, hosting, () => { console.log(`Server running at http://${hosting}:${port}/`); ipapi.location(console.log); });Теперь можно им обновлять свою геолокацию и пользоваться своими репликами: WoBistDu/Как дела? Что нового? WoBistDu/Всё отлично! Пиво дать? WoBistDu/Хочу вот сюда:координаты Форма входа с репликой: <form action="http://wobistdu.ru/" target="_blank"><input name="_" type="text" list="cookies" placeholder="Введите свою реплику…" value="" /><input type="submit" value="Перейти в «ВуБистДу.Ру» со своей репликой…"> <datalist id="cookies"> <option value="А я иду шагаю по…" /> <option value="Бухгалтер, милый мой бухгалтер!" /> </datalist></form>(Сделать полноценный чат на самой странице можно, но смысла нет: «ВоБистДу» - не мессенджер…) Добавил на страницу тематический видеоклип… А также поле реплики до 64 символов… |
Часовой пояс GMT +3, время: 08:34. |