{"id":279983,"date":"2016-10-26T17:15:02","date_gmt":"2016-10-26T13:15:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=279983"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=279983","title":{"rendered":"\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043c\u0435\u0441\u0442\u043e\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u043e IP \u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430 \u043f\u043e\u0441\u0435\u0449\u0435\u043d\u0438\u0439"},"content":{"rendered":"<p>\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435 \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u044b\u0435 \u0425\u0430\u0431\u0440\u0430\u0432\u0447\u0430\u043d\u0435! \u0421\u043e\u0437\u0434\u0430\u0432 \u0441\u0432\u043e\u0439 \u0441\u0430\u0439\u0442, \u044f \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u043d\u0430 \u043d\u0435\u0433\u043e \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u043f\u043e\u0441\u0435\u0449\u0435\u043d\u0438\u0439 \u0441 \u043a\u0430\u043a\u043e\u0433\u043e-\u0442\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430 (\u0447\u0442\u043e-\u0442\u043e \u0442\u0438\u043f\u0430 qoo&#8230;) \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0441 JS. \u0438 \u0447\u0430\u0441\u0442\u0435\u043d\u044c\u043a\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u043b\u0441\u044f. \u0418 \u044f \u043d\u0435 \u043c\u043e\u0433 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0431\u044b\u043b\u043e \u043f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u0435\u0439 \u043d\u0430 \u0441\u0430\u0439\u0442\u0435. \u0422\u0430\u043a \u0436\u0435 \u044f \u0445\u043e\u0442\u0435\u043b \u0437\u043d\u0430\u0442\u044c \u0441 \u043a\u0430\u043a\u0438\u0445 IP \u0430\u0434\u0440\u0435\u0441\u043e\u0432 \u043a\u043e \u043c\u043d\u0435 \u0437\u0430\u0445\u043e\u0434\u044f\u0442, \u0430 \u0442\u0430\u043a \u0436\u0435 \u043a \u043a\u0430\u043a\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0435 \u044d\u0442\u043e\u0442 IP \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f. \u0427\u0442\u043e \u0431\u044b \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434 \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0433\u0443\u043b\u044f\u0442\u044c \u043d\u0430 \u0444\u043e\u0440\u0443\u043c\u0430\u0445. \u043d\u0430\u0448\u0435\u043b \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u043f\u0440\u043e SxGeo. \u041c\u043d\u0435 \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0442\u0430\u043a \u043a\u0430\u043a \u0442\u0430\u043c \u043c\u043e\u0436\u043d\u043e \u0441\u0440\u0430\u0437\u0443 \u0443\u0437\u043d\u0430\u0442\u044c \u0438 \u0441\u0442\u0440\u0430\u043d\u0443 \u0438 \u0433\u043e\u0440\u043e\u0434. \u0422\u0430\u043a \u043a\u0430\u043a \u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u044e \u0438\u0437\u0443\u0447\u0430\u0442\u044c PHP \u0438 \u0442\u0430\u043a\u0438\u0445 \u043b\u044e\u0434\u0435\u0439 \u043d\u0430\u0432\u0435\u0440\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u044f \u0440\u0435\u0448\u0438\u043b \u0432\u044b\u043b\u043e\u0436\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e. \u0422\u043e\u043b\u044c\u043a\u043e \u043d\u0435 \u043a\u0443\u0441\u043e\u0447\u0435\u043a \u043a\u043e\u0434\u0430 \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0437\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u0430\u043d\u044b \u0438 \u0433\u043e\u0440\u043e\u0434\u0430, \u0430 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043a\u043e\u0434. \u0418\u0442\u0430\u043a, \u043d\u0430\u0447\u043d\u0435\u043c.<\/p>\n<p>  <a name=\"habracut\"><\/a>  <\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0432 \u0411\u0414 \u043a\u0443\u0434\u0430 \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u043d\u043e\u0441\u0438\u0442\u044c\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u043f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u044f\u0445. \u0423 \u043c\u0435\u043d\u044f \u0432\u0441\u0435 \u043f\u043e\u043b\u044f \u043a\u0440\u043e\u043c\u0435 id, \u0438\u0434\u0443\u0442 \u0441 \u0442\u0438\u043f\u043e\u043c varchar 255 \u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435\u043c utf8_general_ci, \u0434\u043b\u044f id \u0442\u0438\u043f int 10 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 UNSIGNED \u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435 A\/I. \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0437\u0430\u043f\u0438\u0448\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u043d\u0430\u0448\u0435\u0439 \u0411\u0414. \u0418 \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u043c SxGeo.php \u0438 SxGeoCity.dat \u0441 \u0441\u0430\u0439\u0442\u0430 sypexgeo.net \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043e\u0431\u0430 \u0444\u0430\u0439\u043b\u0430: <a href=\"https:\/\/sypexgeo.net\/files\/SxGeo22_API.zip\">\u0440\u0430\u0437<\/a> \u0438 <a href=\"https:\/\/sypexgeo.net\/files\/SxGeoCity_utf8.zip\">\u0434\u0432\u0430<\/a>.<\/p>\n<p>  <\/p>\n<p>\u0412 SxGeo.php \u043d\u0430 55 \u0441\u0442\u0440\u043e\u043a\u0435 \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u0441 SxGeo.dat \u043d\u0430 SxGeoCity.dat. \u0412\u0441\u0435, \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u043e\u043a\u043e\u043d\u0447\u0435\u043d\u044b.<\/p>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b stats.php (\u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u043d\u0430 \u0432\u0430\u0448 \u0432\u044b\u0431\u043e\u0440) \u0438 \u0432 \u043d\u0435\u043c \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u043d\u0430\u0448\u0435\u0439 \u0411\u0414:<\/p>\n<p>  <\/p>\n<pre><code class=\"php\">&lt;?php include_once ('config.php'); include_once ('SxGeo.php');  $mysqli = new mysqli($server, $user, $pswd, $db); if ($mysqli-&gt;connect_errno) { printf(&quot;\u041d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f: %s\\n&quot;, $mysqli-&gt;connect_error); exit();} $mysqli -&gt; select_db($db) or die (&quot;\u041d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044c $db&quot;); if (!$mysqli-&gt;set_charset(&quot;utf8&quot;)) {     printf(&quot;\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u043d\u0430\u0431\u043e\u0440\u0430 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 utf8: %s\\n&quot;, $mysqli-&gt;error);     exit();}<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0447\u0435\u0440\u0435\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u044e getRealIpAddr() \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c ip-\u043a\u043b\u0438\u0435\u043d\u0442\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"php\">public function getRealIpAddr() {     if (!empty($_SERVER['HTTP_CLIENT_IP']))        \/\/ \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c IP     { $ip=$_SERVER['HTTP_CLIENT_IP']; }     elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))     { $ip=$_SERVER['HTTP_X_FORWARDED_FOR']; }     else { $ip=$_SERVER['REMOTE_ADDR']; }     return $ip;}<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u043b\u0435\u0434\u043e\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u043d\u0435 \u0431\u043e\u0442 \u043b\u0438 \u043a \u043d\u0430\u043c \u0437\u0430\u0448\u0435\u043b \u0432 \u0433\u043e\u0441\u0442\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"php\">if (strstr($_SERVER['HTTP_USER_AGENT'], 'YandexBot')) {$visitor='YandexBot';} \/\/\u0412\u044b\u044f\u0432\u043b\u044f\u0435\u043c \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u044b\u0445 \u0431\u043e\u0442\u043e\u0432 elseif (strstr($_SERVER['HTTP_USER_AGENT'], 'Googlebot')) {$visitor='Googlebot';} else { $visitor=$_SERVER['HTTP_USER_AGENT']; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0432 $ip \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 getRealIpAddr().<\/p>\n<p>  <\/p>\n<pre><code class=\"php\">$ip = getRealIpAddr();<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442 SxGeo \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0433\u043e\u0440\u043e\u0434, \u0441\u0442\u0440\u0430\u043d\u0443 \u0438 \u0440\u0435\u0433\u0438\u043e\u043d:<\/p>\n<p>  <\/p>\n<pre><code class=\"php\">$SxGeo = new SxGeo('SxGeoCity.dat', SXGEO_BATCH | SXGEO_MEMORY); $result = $SxGeo-&gt;getCityFull($ip); <\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u043e\u0436\u0435\u0442\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 var_export(), \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u043a\u0430\u043a\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u043d \u0432\u0430\u043c \u0432\u0435\u0440\u043d\u0435\u0442, \u043c\u043e\u0436\u0435\u0442 \u0412\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0447\u0442\u043e-\u0442\u043e \u0435\u0449\u0435, \u043a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u044f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e. \u0418\u0434\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435. \u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u0430\u043d\u044b, \u0440\u0435\u0433\u0438\u043e\u043d\u0430 \u0438 \u0433\u043e\u0440\u043e\u0434\u0430. \u0418 \u0434\u043b\u044f \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043c\u0435\u0441\u0442\u0430 \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442 SxGeo.<\/p>\n<p>  <\/p>\n<pre><code class=\"php\">$city = $result[&quot;city&quot;][&quot;name_ru&quot;]; $region = $result[&quot;region&quot;][&quot;name_ru&quot;]; $country = $result[&quot;country&quot;][&quot;name_ru&quot;]; unset($SxGeo);<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0434\u0430\u0442\u0443, \u0432\u0440\u0435\u043c\u044f \u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0441\u0430\u0439\u0442\u0430, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0437\u0430\u0445\u043e\u0434\u0438\u043b\u0438.<\/p>\n<p>  <\/p>\n<pre><code class=\"php\">$date = date(&quot;H:i:s d.m.Y&quot;);        \/\/ \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0434\u0430\u0442\u0443 \u0438 \u0432\u0440\u0435\u043c\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u044f $host = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];    \/\/ \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0441\u0430\u0439\u0442\u0430<\/code><\/pre>\n<p>  <\/p>\n<p>\u042d\u043a\u0440\u0430\u043d\u0438\u0440\u0443\u0435\u043c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432 SQL \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u0438 \u0437\u0430\u043d\u043e\u0441\u0438\u043c \u043d\u0430\u0448\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443.<\/p>\n<p>  <\/p>\n<pre><code class=\"php\">$ip   = $mysqli-&gt;real_escape_string($ip); $date = $mysqli-&gt;real_escape_string($date); $host  = $mysqli-&gt;real_escape_string($host); $region = $mysqli-&gt;real_escape_string($region); $country = $mysqli-&gt;real_escape_string($country); $city = $mysqli-&gt;real_escape_string($city); $visitor = $mysqli-&gt;real_escape_string($visitor); if ($query = $mysqli -&gt; query(&quot;INSERT INTO `pre_visitors` (date, visitor, ip, country, region, city, host) VALUES ('&quot;.$date.&quot;', '&quot;.$visitor.&quot;', '&quot;.$ip.&quot;', '&quot;.$country.&quot;', '&quot;.$region.&quot;', '&quot;.$city.&quot;', '&quot;.$host.&quot;')&quot;)){     \/\/printf(&quot;%d \u0441\u0442\u0440\u043e\u043a \u0432\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043e.\\n&quot;, $mysqli-&gt;affected_rows); } else{ printf(&quot;Errorcode: %d\\n&quot;, $mysqli-&gt;errno); };<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043d\u0430 \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u043b\u0430\u0434\u043a\u0438, \u043f\u043e\u0442\u043e\u043c \u044f \u0432 \u043d\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043d\u0435 \u0432\u0438\u0436\u0443. \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430 \u043f\u043e\u0441\u0435\u0449\u0435\u043d\u0438\u0439. \u0421\u0430\u043c\u0443 \u0444\u043e\u0440\u043c\u0443 \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430 \u044f \u0432\u0437\u044f\u043b \u0441 \u0442\u043e\u0433\u043e \u0436\u0435 \u0441\u0430\u0439\u0442\u0430 \u0433\u0434\u0435 \u0438 \u0441\u0430\u043c \u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u0432 div\u044b \u043f\u043e \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u043b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<p><b>1.<\/b> \u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0437\u0430\u0448\u0435\u043b \u0432\u043f\u0435\u0440\u0432\u044b\u0435 \u0438\u043b\u0438 \u0441 \u0434\u0440\u0443\u0433\u043e\u0433\u043e ip-\u0430\u0434\u0440\u0435\u0441\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"php\">if ($result1 = $mysqli -&gt; query(&quot;SELECT * FROM `pre_visitors` WHERE (visitor NOT RLIKE  'bot') GROUP BY ip ORDER BY 'id'&quot;)){ \/\/printf(&quot;%d \u0441\u0442\u0440\u043e\u043a \u0432\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043e.\\n&quot;, $result-&gt;affected_rows); } $res1 = $result1 -&gt; num_rows;<\/code><\/pre>\n<p>  <\/p>\n<p><b>2.<\/b> \u0414\u043b\u044f \u0432\u0441\u0435\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u043e\u0432:<\/p>\n<p>  <\/p>\n<pre><code class=\"php\">if ($result = $mysqli -&gt; query(&quot;SELECT  MAX(id) AS id  FROM `pre_visitors` ORDER BY id&quot;)){ \/\/printf(&quot;%d \u0441\u0442\u0440\u043e\u043a \u0432\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043e.\\n&quot;, $result-&gt;affected_rows); } $res = $result -&gt; fetch_array();<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0443 \u0438 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u0411\u0414:<\/p>\n<p>  <\/p>\n<pre><code class=\"php\">$mysqli -&gt; close(); ?&gt;<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u0441\u0442\u0430\u0442\u0438, \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043d\u0430\u0448 \u0444\u0430\u0439\u043b stats.php \u043a index.php. \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0448\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u0443. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b seestats.php \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043a \u043d\u0430\u0448\u0435\u0439 \u0411\u0414:<\/p>\n<p>  <\/p>\n<pre><code class=\"php\">&lt;?php include_once ('core\/config_class.php'); $mysqli = new mysqli($server, $user, $pswd, $db) or die(&quot;\u041d\u0435 \u043c\u043e\u0433\u0443 \u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0442\u044c\u0441\u044f \u0441 MySQL.&quot;); $mysqli -&gt; select_db($db) or die(&quot;\u041d\u0435 \u043c\u043e\u0433\u0443 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f \u043a \u0431\u0430\u0437\u0435.&quot;); ?&gt;<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e HTML, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0432\u0441\u0435 \u044d\u0442\u043e \u043d\u0430 \u044d\u043a\u0440\u0430\u043d. \u042f \u0435\u0449\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0432\u044b\u0431\u043e\u0440 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0432\u044b\u0432\u043e\u0434\u0438\u043c\u044b\u0445 \u0441\u0442\u0440\u043e\u043a.<\/p>\n<p>  <\/p>\n<pre><code class=\"html\">&lt;html&gt;     &lt;head&gt;         &lt;style type='text\/css'&gt;             td.zz {PADDING-LEFT: 3px; FONT-SIZE: 9pt; PADDING-TOP: 2px; FONT-FAMILY: Arial; }         &lt;\/style&gt;     &lt;\/head&gt;  &lt;body&gt; &lt;center&gt;     &lt;form action=&quot;seestats.php&quot; method=&quot;get&quot;&gt;         &lt;select name=&quot;visualcount&quot;&gt;             &lt;option value=&quot;10&quot; selected&gt;&lt;\/option&gt;             &lt;option value=&quot;50&quot;&gt;50&lt;\/option&gt;             &lt;option value=&quot;100&quot;&gt;100&lt;\/option&gt;             &lt;option value=&quot;250&quot;&gt;250&lt;\/option&gt;             &lt;option value=&quot;500&quot;&gt;500&lt;\/option&gt;             &lt;option value=&quot;1000&quot;&gt;1000&lt;\/option&gt;         &lt;\/select&gt;         &lt;input type=&quot;button&quot; value=&quot;\u0417\u0430\u043f\u0440\u043e\u0441\u0438\u0442\u044c&quot;&gt;     &lt;\/form&gt;<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u043d\u0430\u0448\u0443 \u0444\u043e\u0440\u043c\u0443, \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c \u0432\u0441\u0435 \u043f\u043e\u043b\u044f \u0441 \u043d\u0430\u0448\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044f \u0431\u043e\u0442\u043e\u0432 \u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0435\u0441\u044f ip-\u0430\u0434\u0440\u0435\u0441\u0430, \u0442\u0430\u043a\u0436\u0435 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c MAX id \u0434\u043b\u044f \u043a\u043e\u043d\u0446\u043e\u0432\u043a\u0438 \u043d\u0430\u0448\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b.<\/p>\n<p>  <\/p>\n<pre><code class=\"php\">&lt;?php $lastid =  isset ($_GET['visualcount']) ? ($_GET['visualcount']) : '10'; if ($query = $mysqli-&gt;query(&quot;SELECT * FROM `pre_visitors` WHERE (visitor NOT RLIKE  'bot')  GROUP BY ip  ORDER BY 'id'  DESC LIMIT $lastid&quot;)){     \/\/printf(&quot;%d \u0441\u0442\u0440\u043e\u043a \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043e.\\n&quot;, $mysqli-&gt;affected_rows); } else{ printf(&quot;Errorcode: %d\\n&quot;, $mysqli-&gt;errno); };  if ($result = $mysqli -&gt; query(&quot;SELECT  MAX(id) AS id  FROM `pre_visitors` ORDER BY id&quot;)){ \/\/printf(&quot;%d \u0441\u0442\u0440\u043e\u043a \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043e.\\n&quot;, $result-&gt;affected_rows); } $num_rows = $query -&gt; num_rows; $res = $result -&gt; fetch_array(); ?&gt;<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0441\u0442\u0438\u043b\u0438 \u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a\u0438\u0435 \u0432\u0430\u043c \u043d\u0440\u0430\u0432\u044f\u0442\u0441\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"html\">&lt;table width=&quot;680&quot; cellspacing=&quot;1&quot; cellpadding=&quot;1&quot; border=&quot;0&quot;            STYLE=&quot;table-layout:fixed&quot;&gt;         &lt;tr align = &quot;center&quot; bgcolor=&quot;#eeeeee&quot;&gt;             &lt;td class=&quot;zz&quot; width=&quot;30&quot;&gt;&lt;b&gt;\u2116 \u043f\/\u043f&lt;\/b&gt;&lt;\/td&gt;             &lt;td class=&quot;zz&quot; width=&quot;90&quot;&gt;&lt;b&gt;\u0412\u0440\u0435\u043c\u044f \u0438 \u0434\u0430\u0442\u0430&lt;\/b&gt;&lt;\/td&gt;             &lt;td class=&quot;zz&quot; width=&quot;500&quot;&gt;&lt;b&gt;\u0414\u0430\u043d\u043d\u044b\u0435 \u043e \u043f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u0435&lt;\/b&gt;&lt;\/td&gt;             &lt;td class=&quot;zz&quot; width=&quot;100&quot;&gt;&lt;b&gt;IP\/\u043f\u0440\u043e\u043a\u0441\u0438&lt;\/b&gt;&lt;\/td&gt;             &lt;td class=&quot;zz&quot; width=&quot;100&quot;&gt;&lt;b&gt;\u0421\u0442\u0440\u0430\u043d\u0430&lt;\/b&gt;&lt;\/td&gt;             &lt;td class=&quot;zz&quot; width=&quot;100&quot;&gt;&lt;b&gt;\u0420\u0435\u0433\u0438\u043e\u043d&lt;\/b&gt;&lt;\/td&gt;             &lt;td class=&quot;zz&quot; width=&quot;100&quot;&gt;&lt;b&gt;\u0413\u043e\u0440\u043e\u0434&lt;\/b&gt;&lt;\/td&gt;             &lt;td class=&quot;zz&quot; width=&quot;110&quot;&gt;&lt;b&gt;\u041f\u043e\u0441\u0435\u0449\u0435\u043d\u043d\u044b\u0439 URL&lt;\/b&gt;&lt;\/td&gt;         &lt;\/tr&gt;<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0447\u0435\u0440\u0435\u0437 \u0446\u0438\u043a\u043b \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043d\u0430\u0448\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0438 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u0411\u0414:<\/p>\n<p>  <\/p>\n<pre><code class=\"php\">&lt;?php while($row = $query -&gt; fetch_array()){     echo '&lt;tr bgcolor=&quot;#eeeeee&quot;&gt;&lt;td class=&quot;zz&quot;&gt;'.$row['id'].'&lt;\/td&gt;';     echo '&lt;td class=&quot;zz&quot;&gt;'.$row['date'].'&lt;\/td&gt;';     echo '&lt;td class=&quot;zz&quot;&gt;'.$row['visitor'].'&lt;\/td&gt;';     echo '&lt;td class=&quot;zz&quot;&gt;'.$row['ip'].'&lt;\/td&gt;';     echo '&lt;td align = &quot;center&quot; class=&quot;zz&quot;&gt;'.$row['country'].'&lt;\/td&gt;';     echo '&lt;td align = &quot;center&quot; class=&quot;zz&quot;&gt;'.$row['region'].'&lt;\/td&gt;';     echo '&lt;td align = &quot;center&quot; class=&quot;zz&quot;&gt;'.$row['city'].'&lt;\/td&gt;';     echo '&lt;td class=&quot;zz&quot;&gt;'.$row['host'].'&lt;\/td&gt;&lt;\/tr&gt;'; }  echo '&lt;tr bgcolor=&quot;#eeeeee&quot;&gt;&lt;td class=&quot;zz&quot; colspan = &quot;3&quot; &gt;&lt;b&gt;\u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043d\u043e\u0432\u044b\u0445 \u043f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u0435\u0439&lt;\/b&gt;&lt;\/td&gt;'; echo '&lt;td align = &quot;center&quot;&gt;&lt;b&gt;'.$num_rows.'&lt;\/b&gt;&lt;\/td&gt;'; echo '&lt;td class=&quot;zz&quot; colspan = &quot;3&quot; &gt;&lt;b&gt;\u041e\u0431\u0449\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0441\u0435\u0449\u0435\u043d\u0438\u0439&lt;\/b&gt;&lt;\/td&gt;'; echo '&lt;td align = &quot;center&quot;&gt;&lt;b&gt;'.$res['id'].'&lt;\/b&gt;&lt;\/td&gt;&lt;\/tr&gt;'; echo '&lt;\/table&gt;'; echo '&lt;\/center&gt;'; echo '&lt;\/body&gt;&lt;\/html&gt;'; $mysqli -&gt; close(); ?&gt;<\/code><\/pre>\n<p>  <\/p>\n<p>\u0416\u0430\u043b\u044c \u0442\u043e\u043b\u044c\u043a\u043e, \u0447\u0442\u043e \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c IP \u043f\u0440\u043e\u043a\u0441\u0438-\u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u0430 \u043d\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430.<br \/>  \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!<\/p>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/313676\/\"> https:\/\/habrahabr.ru\/post\/313676\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435 \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u044b\u0435 \u0425\u0430\u0431\u0440\u0430\u0432\u0447\u0430\u043d\u0435! \u0421\u043e\u0437\u0434\u0430\u0432 \u0441\u0432\u043e\u0439 \u0441\u0430\u0439\u0442, \u044f \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u043d\u0430 \u043d\u0435\u0433\u043e \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u043f\u043e\u0441\u0435\u0449\u0435\u043d\u0438\u0439 \u0441 \u043a\u0430\u043a\u043e\u0433\u043e-\u0442\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430 (\u0447\u0442\u043e-\u0442\u043e \u0442\u0438\u043f\u0430 qoo&#8230;) \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0441 JS. \u0438 \u0447\u0430\u0441\u0442\u0435\u043d\u044c\u043a\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u043b\u0441\u044f. \u0418 \u044f \u043d\u0435 \u043c\u043e\u0433 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0431\u044b\u043b\u043e \u043f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u0435\u0439 \u043d\u0430 \u0441\u0430\u0439\u0442\u0435. \u0422\u0430\u043a \u0436\u0435 \u044f \u0445\u043e\u0442\u0435\u043b \u0437\u043d\u0430\u0442\u044c \u0441 \u043a\u0430\u043a\u0438\u0445 IP \u0430\u0434\u0440\u0435\u0441\u043e\u0432 \u043a\u043e \u043c\u043d\u0435 \u0437\u0430\u0445\u043e\u0434\u044f\u0442, \u0430 \u0442\u0430\u043a \u0436\u0435 \u043a \u043a\u0430\u043a\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0435 \u044d\u0442\u043e\u0442 IP \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f. \u0427\u0442\u043e \u0431\u044b \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434 \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0433\u0443\u043b\u044f\u0442\u044c \u043d\u0430 \u0444\u043e\u0440\u0443\u043c\u0430\u0445. \u043d\u0430\u0448\u0435\u043b \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u043f\u0440\u043e SxGeo. \u041c\u043d\u0435 \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0442\u0430\u043a \u043a\u0430\u043a \u0442\u0430\u043c \u043c\u043e\u0436\u043d\u043e \u0441\u0440\u0430\u0437\u0443 \u0443\u0437\u043d\u0430\u0442\u044c \u0438 \u0441\u0442\u0440\u0430\u043d\u0443 \u0438 \u0433\u043e\u0440\u043e\u0434. \u0422\u0430\u043a \u043a\u0430\u043a \u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u044e \u0438\u0437\u0443\u0447\u0430\u0442\u044c PHP \u0438 \u0442\u0430\u043a\u0438\u0445 \u043b\u044e\u0434\u0435\u0439 \u043d\u0430\u0432\u0435\u0440\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u044f \u0440\u0435\u0448\u0438\u043b \u0432\u044b\u043b\u043e\u0436\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e. \u0422\u043e\u043b\u044c\u043a\u043e \u043d\u0435 \u043a\u0443\u0441\u043e\u0447\u0435\u043a \u043a\u043e\u0434\u0430 \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0437\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u0430\u043d\u044b \u0438 \u0433\u043e\u0440\u043e\u0434\u0430, \u0430 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043a\u043e\u0434. \u0418\u0442\u0430\u043a, \u043d\u0430\u0447\u043d\u0435\u043c.<\/p>\n<p>  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-279983","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/279983","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=279983"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/279983\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=279983"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=279983"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=279983"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}